b2evolution PHP Cross Reference Blogging Systems

Source: /inc/items/views/_itemtypes.view.php - 123 lines - 3846 bytes - Summary - Text - Print

Description: 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 is part of the evoCore framework - {@link http://evocore.net/}
   4   * See also {@link http://sourceforge.net/projects/evocms/}.
   5   *
   6   * @copyright (c)2009-2014 by Francois PLANQUE - {@link http://fplanque.net/}
   7   * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.
   8   *
   9   * {@internal License choice
  10   * - If you have received this file as part of a package, please find the license.txt file in
  11   *   the same folder or the closest folder above for complete license terms.
  12   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  13   *   then you must choose one of the following licenses before using the file:
  14   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  15   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  16   * }}
  17   *
  18   * {@internal Open Source relicensing agreement:
  19   * The Evo Factory grants Francois PLANQUE the right to license
  20   * The Evo Factory's contributions to this file and the b2evolution project
  21   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  22   * }}
  23   *
  24   * @package evocore
  25   *
  26   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  27   * @author efy-sergey: Evo Factory / Sergey.
  28   * @author fplanque: Francois Planque.
  29   *
  30   * @version $Id: _itemtypes.view.php 6136 2014-03-08 07:59:48Z manuel $
  31   */
  32  
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  load_class( 'items/model/_itemtype.class.php', 'ItemType' );
  36  
  37  global $dispatcher;
  38  
  39  // Create query
  40  $SQL = new SQL();
  41  $SQL->SELECT( '*' );
  42  $SQL->FROM( 'T_items__type' );
  43  
  44  // Create result set:
  45  $Results = new Results( $SQL->get(), 'ptyp_' );
  46  
  47  $Results->title = T_('Item/Post/Page types');
  48  
  49  // get reserved ids
  50  global $reserved_ids;
  51  $reserved_ids = ItemType::get_reserved_ids();
  52  
  53  /**
  54   * Callback to build possible actions depending on item type id
  55   *
  56   */
  57  function get_actions_for_itemtype( $id )
  58  {
  59      global $reserved_ids;
  60      $action = action_icon( T_('Duplicate this item type...'), 'copy',
  61                                          regenerate_url( 'action', 'ptyp_ID='.$id.'&amp;action=new') );
  62      if( ($id < $reserved_ids[0]) || ($id > $reserved_ids[1]) )
  63      { // not reserved id
  64          $action = action_icon( T_('Edit this item type...'), 'edit',
  65                                          regenerate_url( 'action', 'ptyp_ID='.$id.'&amp;action=edit') )
  66                              .$action
  67                              .action_icon( T_('Delete this item type!'), 'delete',
  68                                          regenerate_url( 'action', 'ptyp_ID='.$id.'&amp;action=delete&amp;'.url_crumb('itemtype').'') );
  69      }
  70      return $action;
  71  }
  72  
  73  /**
  74   * Callback to make item type name depending on item type id
  75   *
  76   */
  77  function get_name_for_itemtype( $id, $name )
  78  {
  79      global $reserved_ids;
  80  
  81      if( ($id < $reserved_ids[0]) || ($id > $reserved_ids[1]) )
  82      {    // not reserved id
  83          $ret_name = '<strong><a href="'.regenerate_url( 'action,ID', 'ptyp_ID='.$id.'&amp;action=edit' ).'">'.$name.'</a></strong>';
  84      }
  85      else
  86      {
  87          $ret_name = '<strong>'.$name.'</strong>';
  88      }
  89      return $ret_name;
  90  }
  91  
  92  
  93  $Results->cols[] = array(
  94          'th' => T_('ID'),
  95          'order' => 'ptyp_ID',
  96          'th_class' => 'shrinkwrap',
  97          'td_class' => 'shrinkwrap',
  98          'td' => '$ptyp_ID$',
  99      );
 100  
 101  $Results->cols[] = array(
 102          'th' => T_('Name'),
 103          'order' => 'ptyp_name',
 104          'td' => '%get_name_for_itemtype(#ptyp_ID#, #ptyp_name#)%',
 105      );
 106  
 107  if( $current_User->check_perm( 'options', 'edit', false ) )
 108  { // We have permission to modify:
 109      $Results->cols[] = array(
 110                              'th' => T_('Actions'),
 111                              'th_class' => 'shrinkwrap',
 112                              'td_class' => 'shrinkwrap',
 113                              'td' => '%get_actions_for_itemtype( #ptyp_ID# )%',
 114                          );
 115  
 116      $Results->global_icon( T_('Create a new element...'), 'new',
 117                  regenerate_url( 'action', 'action=new' ), T_('New item type').' &raquo;', 3, 4  );
 118  }
 119  
 120  // Display results:
 121  $Results->display();
 122  
 123  ?>

title

Description

title

Description

title

Description

title

title

Body