b2evolution PHP Cross Reference Blogging Systems

Source: /inc/generic/views/_generic_list.inc.php - 137 lines - 4771 bytes - Summary - Text - Print

Description: This file implements the element list editor list.

   1  <?php
   2  /**
   3   * This file implements the element list editor list.
   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   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
  22   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package admin
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author fplanque: Francois PLANQUE.
  30   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  31   *
  32   * @version $Id: _generic_list.inc.php 6136 2014-03-08 07:59:48Z manuel $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  global $perm_name, $perm_level;
  37  
  38  global $result_fadeout;
  39  
  40  global $GenericElementCache;
  41  
  42  global $list_title, $default_col_order, $form_below_list;
  43  
  44  
  45  // EXPERIMENTAL
  46  if ( !isset( $default_col_order ) )
  47  { // The default order column is not set, so the default is the name column
  48      $default_col_order = '-A-';
  49  }
  50  
  51  // Create result set:
  52  
  53  $SQL = new SQL();
  54  $SQL->SELECT( $GenericElementCache->dbIDname . ', '
  55      . $GenericElementCache->dbprefix . 'name' );
  56  $SQL->FROM( $GenericElementCache->dbtablename );
  57  
  58  $Results = new Results( $SQL->get(), $GenericElementCache->dbprefix, $default_col_order );
  59  
  60  if( isset( $list_title ) )
  61  {
  62      $Results->title = $list_title;
  63  }
  64  
  65  $Results->cols[] = array(
  66          'th' => T_('ID'),
  67          'order' => $GenericElementCache->dbIDname,
  68          'th_class' => 'shrinkwrap',
  69          'td_class' => 'shrinkwrap',
  70          'td' => "\$$GenericElementCache->dbIDname\$",
  71      );
  72  
  73  
  74  function link_name( $title , $ID )
  75  {
  76      global $GenericElementCache;
  77  
  78      global $locked_IDs, $perm_name, $perm_level, $current_User;
  79  
  80      if( ( empty( $locked_IDs ) || !in_array( $ID, $locked_IDs ) )
  81              && ( !isset( $perm_name ) || $current_User->check_perm( $perm_name, $perm_level, false ) ) )
  82      {    // The element is not locked and we have permission permission to edit:
  83          return '<strong><a href="'.regenerate_url( 'action,ID', $GenericElementCache->dbIDname.'='.$ID.'&amp;action=edit' ).'">'.$title.'</a></strong>';
  84      }
  85      else
  86      {
  87          return '<strong>'.$title.'</strong>';
  88      }
  89  }
  90  $Results->cols[] = array(
  91          'th' => T_('Name'),
  92          'order' => $GenericElementCache->dbprefix.'name',
  93           'td' => '%link_name( #'.$GenericElementCache->dbprefix.'name#, #'.$GenericElementCache->dbIDname.'# )%',
  94      );
  95  
  96  
  97  if( !isset( $perm_name ) || $current_User->check_perm( $perm_name, $perm_level, false ) )
  98  {    // We have permission permission to edit:
  99  
 100  	function edit_actions( $ID )
 101      {
 102          global $locked_IDs, $GenericElementCache;
 103  
 104          $r = action_icon( T_('Duplicate...'), 'copy', regenerate_url( 'action,'.$GenericElementCache->dbIDname, $GenericElementCache->dbIDname.'='.$ID.'&amp;action=copy' ) );
 105  
 106          if( empty( $locked_IDs ) || !in_array( $ID, $locked_IDs ) )
 107          { // This element is NOT locked:
 108              $r = action_icon( T_('Edit...'), 'edit', regenerate_url( 'action,'.$GenericElementCache->dbIDname, $GenericElementCache->dbIDname.'='.$ID.'&amp;action=edit' ) )
 109                          .$r
 110                          .action_icon( T_('Delete!'), 'delete', regenerate_url( 'action,'.$GenericElementCache->dbIDname, $GenericElementCache->dbIDname.'='.$ID.'&amp;action=delete&amp;'.url_crumb('element') ) );
 111  
 112          }
 113  
 114          return $r;
 115      }
 116  
 117      $Results->cols[] = array(
 118              'th' => T_('Actions'),
 119              'td_class' => 'shrinkwrap',
 120              'td' => '%edit_actions( #'.$GenericElementCache->dbIDname.'# )%',
 121          );
 122  
 123  }
 124  
 125  if( !$form_below_list )
 126  {    // Need to dispaly global icon to add new geenric element:
 127      if( !isset( $perm_name ) || $current_User->check_perm( $perm_name, $perm_level, false ) )
 128      {    // We have permission permission to edit:
 129          $Results->global_icon( T_('Create a new element...'), 'new', regenerate_url( 'action,'.$GenericElementCache->dbIDname, 'action=new' ), T_('New element').' &raquo;', 3, 4 );
 130      }
 131  }
 132  
 133  // EXPERIMENTAL
 134  // $Results->display();
 135  $Results->display( NULL, $result_fadeout );
 136  
 137  ?>

title

Description

title

Description

title

Description

title

title

Body