b2evolution PHP Cross Reference Blogging Systems

Source: /inc/links/views/_link_list.inc.php - 181 lines - 4588 bytes - Summary - Text - Print

Description: This file displays the links attached to an Object, which can be an Item, Comment, ... (called within the attachment_frame) This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**

   3   * This file displays the links attached to an Object, which can be an Item, Comment, ... (called within the attachment_frame)

   4   *

   5   * This file is part of the evoCore framework - {@link http://evocore.net/}

   6   * See also {@link http://sourceforge.net/projects/evocms/}.

   7   *

   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}

   9   *

  10   * {@internal License choice

  11   * - If you have received this file as part of a package, please find the license.txt file in

  12   *   the same folder or the closest folder above for complete license terms.

  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)

  14   *   then you must choose one of the following licenses before using the file:

  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php

  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php

  17   * }}

  18   *

  19   * @package admin

  20   *

  21   * @version $Id: $

  22   */
  23  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  24  
  25  /**

  26   * @var Blog

  27   */
  28  global $Blog;
  29  
  30  global $blog;
  31  
  32  /**

  33   * Needed by functions

  34   * @var LinkOwner

  35   */
  36  global $LinkOwner;
  37  
  38  $SQL = $LinkOwner->get_SQL( 'link_ID' );
  39  $Results = new Results( $SQL->get(), 'link_' );
  40  
  41  $Results->title = T_('Attachments');
  42  
  43  /*

  44   * TYPE

  45   */
  46  function display_type( & $row )
  47  {
  48      if( !empty($row->file_ID) )
  49      {
  50          return T_('File');
  51      }
  52  
  53      return '?';
  54  }
  55  $Results->cols[] = array(
  56                          'th' => T_('Type'),
  57                          'th_class' => 'shrinkwrap',
  58                          'td_class' => 'shrinkwrap',
  59                          'td' => '%display_type( {row} )%',
  60                      );
  61  
  62  
  63  /*

  64   * Sub Type column

  65   */
  66  function display_subtype( & $row )
  67  {
  68      if( empty($row->file_ID) )
  69      {
  70          return '';
  71      }
  72  
  73      global $current_File;
  74      // Instantiate a File object for this line:

  75      $current_File = new File( $row->file_root_type, $row->file_root_ID, $row->file_path ); // COPY!

  76      // Flow meta data into File object:

  77      $current_File->load_meta( false, $row );
  78  
  79      return $current_File->get_preview_thumb( 'fulltype' );
  80  }
  81  $Results->cols[] = array(
  82                          'th' => T_('Icon/Type'),
  83                          'td_class' => 'shrinkwrap',
  84                          'td' => '%display_subtype( {row} )%',
  85                      );
  86  
  87  
  88  /*

  89   * LINK column

  90   */
  91  function display_link( & $row )
  92  {
  93      if( !empty($row->file_ID) )
  94      {
  95          /**

  96           * @var File

  97           */
  98          global $current_File;
  99  
 100          $r = '';
 101  
 102          // File relative path & name:

 103          if( $current_File->is_dir() )
 104          { // Directory
 105              $r .= $current_File->dget( '_name' );
 106          }
 107          else
 108          { // File
 109              if( $view_link = $current_File->get_view_link() )
 110              {
 111                  $r .= $view_link;
 112              }
 113              else
 114              { // File extension unrecognized
 115                  $r .= $current_File->dget( '_name' );
 116              }
 117          }
 118  
 119          $title = $current_File->dget('title');
 120          if( $title !== '' )
 121          {
 122              $r .= '<span class="filemeta"> - '.$title.'</span>';
 123          }
 124  
 125          return $r;
 126      }
 127  
 128      return '?';
 129  }
 130  $Results->cols[] = array(
 131                          'th' => T_('Destination'),
 132                          'td' => '%display_link( {row} )%',
 133                      );
 134  
 135  
 136  if( $current_User->check_perm( 'files', 'view', false, $blog ) )
 137  {
 138  	function file_actions( $link_ID )
 139      {
 140          /**

 141           * @var File

 142           */
 143          global $current_File;
 144          global $LinkOwner, $current_User;
 145  
 146          $r = '';
 147  
 148          if( isset($current_File) && $current_User->check_perm( 'files', 'view', false, $current_File->get_FileRoot() ) )
 149          {
 150              if( $current_File->is_dir() )
 151                  $title = T_('Locate this directory!');
 152              else
 153                  $title = T_('Locate this file!');
 154              $r = $current_File->get_linkedit_link( $LinkOwner->type, $LinkOwner->get_ID(), get_icon( 'locate', 'imgtag', array( 'title'=>$title ) ), $title ).' ';
 155          }
 156  
 157          if( $LinkOwner->check_perm( 'edit', false ) )
 158          {    // Check that we have permission to edit LinkOwner object:
 159              $r .= action_icon( T_('Delete this link!'), 'unlink',
 160                                regenerate_url( 'p,itm_ID,action', 'link_ID='.$link_ID.'&amp;action=unlink&amp;'.url_crumb('link') ) );
 161          }
 162  
 163          return $r;
 164      }
 165      $Results->cols[] = array(
 166                              'th' => T_('Actions'),
 167                              'td_class' => 'shrinkwrap',
 168                              'td' => '%file_actions( #link_ID# )%',
 169                          );
 170  }
 171  
 172  if( $current_User->check_perm( 'files', 'view', false, $blog )
 173      && $LinkOwner->check_perm( 'edit' ) )
 174  {    // Check that we have permission to edit LinkOwner object:
 175      $Results->global_icon( T_('Link a file...'), 'link', url_add_param( $Blog->get_filemanager_link(),
 176                                                          'fm_mode=link_object&amp;link_type='.$LinkOwner->type.'&amp;link_object_ID='.$LinkOwner->get_ID() ), T_('Link files'), 3, 4 );
 177  }
 178  
 179  $Results->display();
 180  
 181  ?>

title

Description

title

Description

title

Description

title

title

Body