b2evolution PHP Cross Reference Blogging Systems

Source: /inc/slugs/views/_slug_list.view.php - 227 lines - 6131 bytes - Summary - Text - Print

Description: This file display the slugs list This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}. See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file display the slugs list
   4   *
   5   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.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 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10   *
  11   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
  12   *
  13   * @package admin
  14   *
  15   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  16   * @author evfy-asimo: Attila Simo.
  17   *
  18   * @version $Id: _slug_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  19   */
  20  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  21  
  22  /**
  23   * @var Slug
  24   */
  25  global $Sug, $current_User;
  26  
  27  $SQL = new SQL();
  28  
  29  $SQL->SELECT( '*, post_title AS target_title' ); // select target_title for sorting
  30  $SQL->FROM( 'T_slug LEFT OUTER JOIN T_items__item ON slug_itm_ID = post_ID' );
  31  
  32  // filters
  33  if( get_param( 'slug_filter' ) )
  34  { // add slug_title filter
  35      $like = $DB->escape( strtolower(get_param( 'slug_filter' )) );
  36      $SQL->WHERE_and( '(
  37          LOWER(slug_title) LIKE "%'.$like.'%"
  38          OR LOWER(post_title) LIKE "%'.$like.'%")' );
  39  }
  40  if( $filter_type = get_param( 'slug_type' ) )
  41  { // add filter for item type
  42      $SQL->WHERE_and( 'slug_type = "'.$DB->escape( get_param('slug_ftype') ).'"' );
  43  }
  44  if( $filter_item_ID = get_param( 'slug_item_ID' ) )
  45  { // add filter for item ID
  46      if( is_number( $filter_item_ID ) )
  47      {
  48          $SQL->WHERE_and( 'slug_itm_ID = '.$DB->quote($filter_item_ID) );
  49      }
  50  }
  51  
  52  // Create result set:
  53  $Results = new Results( $SQL->get(), 'slug_', 'A' );
  54  
  55  $Results->title = T_('Slugs').' ('.$Results->total_rows.')' . get_manual_link('slugs-list');
  56  $Results->Cache = get_SlugCache();
  57  
  58  /**
  59   * Callback to add filters on top of the result set
  60   *
  61   * @param Form
  62   */
  63  function filter_slugs( & $Form )
  64  {
  65      $Form->text_input( 'slug_filter', get_param('slug_filter'), 24, T_('Slug'), '', array( 'maxlength' => 253 ) );
  66  
  67      $item_ID_filter_note = '';
  68      if( $filter_item_ID = get_param( 'slug_item_ID' ) )
  69      { // check item_Id filter. It must be a number
  70          if( ! is_number( $filter_item_ID ) )
  71          { // It is not a number
  72              $item_ID_filter_note = T_('Must be a number');
  73          }
  74      }
  75      $Form->text_input( 'slug_item_ID', $filter_item_ID, 9, T_('Item ID'), $item_ID_filter_note, array( 'maxlength' => 9 ) );
  76  }
  77  $Results->filter_area = array(
  78      'callback' => 'filter_slugs',
  79      'url_ignore' => 'slug_filter,results_slug_page',
  80      'presets' => array(
  81          'all' => array( T_('All'), '?ctrl=slugs' ),
  82          )
  83      );
  84  
  85  function get_slug_link( $Slug )
  86  {
  87      global $current_User;
  88      if( $current_User->check_perm( 'slugs', 'edit') )
  89      {
  90          return '<strong><a href="admin.php?ctrl=slugs&amp;slug_ID='.$Slug->ID.'&amp;action=edit">'.$Slug->get('title').'</a></strong>';
  91      }
  92      else
  93      {
  94          return '<strong>'.$Slug->get('title').'</strong>';
  95      }
  96  }
  97  $Results->cols[] = array(
  98              'th' => T_('Slug'),
  99              'th_class' => 'small',
 100              'td_class' => 'small',
 101              'order' => 'slug_title',
 102              'td' => '%get_slug_link({Obj})%',
 103          );
 104  
 105  $Results->cols[] = array(
 106              'th' => T_('Type'),
 107              'th_class' => 'small',
 108              'order' => 'slug_type',
 109              'td' => '$slug_type$',
 110              'td_class' => 'shrinkwrap small',
 111          );
 112  
 113  
 114  /**
 115   * Get a link to the target object
 116   *
 117   * @param Slug Slug object
 118   * @return string
 119   */
 120  function get_target_ID( $Slug )
 121  {
 122      switch( $Slug->type )
 123      {
 124          case 'item':
 125              $r = $Slug->itm_ID;
 126              break;
 127  
 128          default:
 129              $r = 'n.a.';
 130      }
 131  
 132      if( is_null($r) )
 133          $r = 'null';
 134  
 135      return $r;
 136  }
 137  $Results->cols[] = array(
 138              'th' => T_('Target'),
 139              'th_class' => 'small',
 140              'order' => 'target_title',
 141              'td' => '%get_target_ID({Obj})%',
 142              'td_class' => 'shrinkwrap small',
 143          );
 144  
 145  
 146  /**
 147   * Get a link to the target object
 148   *
 149   * @param Slug Slug object
 150   * @return string target link if exists, target title otherwise
 151   */
 152  function get_target_coll( $Slug )
 153  {
 154      /**
 155      * @var User
 156      */
 157      global $current_User;
 158  
 159      switch( $Slug->type )
 160      {
 161          case 'item':
 162          // case other: (add here)
 163              $target = & $Slug->get_object();
 164              if( empty( $target ) )
 165              {    // The Item was not found... (it has probably been deleted):
 166                  return '<i>'.T_('(missing)').'</i>';
 167              }
 168  
 169              $allow_edit = false;
 170              $allow_view = false;
 171              switch( $Slug->get( 'type') )
 172              {
 173                  case 'item':
 174                      $allow_edit = $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $target );
 175                      $allow_view = $current_User->check_perm( 'item_post!CURSTATUS', 'view', false, $target );
 176                      break;
 177                  // Other types permission check write here
 178              }
 179  
 180              // permanent link to object
 181              $coll = action_icon( T_('Permanent link to full entry'), 'permalink', $Slug->get_url_to_object( 'public_view' ) );
 182  
 183              if( $allow_edit )
 184              { // edit object link
 185                  $coll .= ' '.action_icon( sprintf( T_('Edit this %s...'), $Slug->get( 'type' ) ),
 186                              'properties', $Slug->get_url_to_object( 'edit' ) );
 187              }
 188              if( $allow_view )
 189              { // view object link
 190                  $coll .= ' '.$Slug->get_link_to_object();
 191              }
 192              else
 193              { // Display just the title (If there is no object title need to change this)
 194                  $coll .= ' '.$target->get( 'title' );
 195              }
 196              return $coll;//'<a href="'.$target->get_single_url().'">'.$target->dget('title').'</a>';
 197  
 198          default:
 199              return 'n.a.';
 200      }
 201  }
 202  $Results->cols[] = array(
 203              'th' => T_('Target'),
 204              'th_class' => 'small',
 205              'order' => 'target_title',
 206              'td' => '%get_target_coll({Obj})%',
 207              'td_class' => 'small left',
 208          );
 209  
 210  if( $current_User->check_perm( 'slugs', 'edit' ) )
 211  {
 212      $Results->cols[] = array(
 213                  'th' => T_('Actions'),
 214                  'th_class' => 'shrinkwrap small',
 215                  'td_class' => 'shrinkwrap',
 216                  'td' => action_icon( TS_('Edit this slug...'), 'properties',
 217                          'admin.php?ctrl=slugs&amp;slug_ID=$slug_ID$&amp;action=edit' )
 218                           .action_icon( T_('Delete this slug!'), 'delete',
 219                            regenerate_url( 'slug_ID,action,slug_filter', 'slug_ID=$slug_ID$&amp;action=delete&amp;'.url_crumb('slug') ) ),
 220                          );
 221  
 222      $Results->global_icon( T_('Add a new slug...'), 'new', regenerate_url( 'action', 'action=new'), T_('New slug').' &raquo;', 3, 4  );
 223  }
 224  
 225  $Results->display();
 226  
 227  ?>

title

Description

title

Description

title

Description

title

title

Body