b2evolution PHP Cross Reference Blogging Systems

Source: /inc/regional/views/_region_list.view.php - 248 lines - 7563 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-maxim: Evo Factory / Maxim.

  28   * @author fplanque: Francois Planque.

  29   *

  30   * @version $Id: _region_list.view.php 13 2011-10-24 23:42:53Z fplanque $

  31   */
  32  
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  global $dispatcher;
  36  
  37  // Get params from request

  38  $s = param( 's', 'string', '', true );
  39  $c = param( 'c', 'integer', 0, true );
  40  
  41  // Create query

  42  $SQL = new SQL();
  43  $SQL->SELECT( 'rgn_ID, rgn_code, rgn_name, rgn_enabled, rgn_preferred, ctry_ID, ctry_name' );
  44  $SQL->FROM( 'T_regional__region' );
  45  $SQL->FROM_add( 'LEFT JOIN T_regional__country ON rgn_ctry_ID=ctry_ID' );
  46  $SQL->ORDER_BY( '*, ctry_name, rgn_name' );
  47  
  48  $sql_where = array();
  49  if( !empty($s) )
  50  {    // We want to filter on search keyword:
  51      // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL

  52      $sql_where[] = 'CONCAT_WS( " ", rgn_code, rgn_name ) LIKE "%'.$DB->escape($s).'%"';
  53  }
  54  if( $c > 0 )
  55  {    // We want to filter on search country:
  56      $sql_where[] = 'rgn_ctry_ID = "'.$DB->escape($c).'"';
  57  }
  58  
  59  if( count( $sql_where ) > 0 )
  60  {    // Some filters are applied
  61      $SQL->WHERE( implode( ' AND ', $sql_where ) );
  62  }
  63  
  64  // Create result set:

  65  $Results = new Results( $SQL->get(), 'rgn_', '----A' );
  66  
  67  $Results->title = T_('Regions/States').get_manual_link('countries_list');
  68  
  69  /*

  70   * STATUS TD:

  71   */
  72  function rgn_td_enabled( $rgn_enabled, $rgn_ID )
  73  {
  74  
  75      global $dispatcher;
  76  
  77      $r = '';
  78  
  79      if( $rgn_enabled == true )
  80      {
  81          $r .= action_icon( T_('Disable the region!'), 'bullet_full',
  82                                          regenerate_url( 'action', 'action=disable_region&amp;rgn_ID='.$rgn_ID.'&amp;'.url_crumb('region') ) );
  83      }
  84      else
  85      {
  86          $r .= action_icon( T_('Enable the region!'), 'bullet_empty',
  87                                          regenerate_url( 'action', 'action=enable_region&amp;rgn_ID='.$rgn_ID.'&amp;'.url_crumb('region') ) );
  88      }
  89      return $r;
  90  
  91  }
  92  
  93  function rgn_td_preferred( $rgn_preferred, $rgn_ID )
  94  {
  95  
  96      global $dispatcher;
  97  
  98      $r = '';
  99  
 100      if( $rgn_preferred == true )
 101      {
 102          $r .= action_icon( T_('Remove from preferred regions'), 'bullet_full',
 103                                          regenerate_url( 'action', 'action=disable_region_pref&amp;rgn_ID='.$rgn_ID.'&amp;'.url_crumb('region') ) );
 104      }
 105      else
 106      {
 107          $r .= action_icon( T_('Add to preferred regions'), 'bullet_empty',
 108                                          regenerate_url( 'action', 'action=enable_region_pref&amp;rgn_ID='.$rgn_ID.'&amp;'.url_crumb('region') ) );
 109      }
 110      return $r;
 111  
 112  }
 113  
 114  
 115  
 116  $Results->cols[] = array(
 117          'th' => /* TRANS: shortcut for enabled */ T_('En'),
 118          'th_title' => T_('Enabled'),
 119          'order' => 'rgn_enabled',
 120          'td' => '%rgn_td_enabled( #rgn_enabled#, #rgn_ID# )%',
 121          'th_class' => 'shrinkwrap',
 122          'td_class' => 'shrinkwrap'
 123      );
 124  
 125  $Results->cols[] = array(
 126          'th' => /* TRANS: shortcut for preferred */ T_('Pref'),
 127          'th_title' => T_('Preferred'),
 128          'order' => 'rgn_preferred',
 129          'default_dir' => 'D',
 130          'td' => '%rgn_td_preferred( #rgn_preferred# , #rgn_ID# )%',
 131          'th_class' => 'shrinkwrap',
 132          'td_class' => 'shrinkwrap'
 133      );
 134  
 135  
 136  /**

 137   * Callback to add filters on top of the result set

 138   *

 139   * @param Form

 140   */
 141  function filter_regions( & $Form )
 142  {
 143      load_class( 'regional/model/_country.class.php', 'Country' );
 144      $CountryCache = & get_CountryCache( T_('All') );
 145      $Form->select_country( 'c', get_param('c'), $CountryCache, T_('Country'), array( 'allow_none' => true ) );
 146  
 147      $Form->text( 's', get_param('s'), 30, T_('Search'), '', 255 );
 148  }
 149  
 150  $Results->filter_area = array(
 151      'callback' => 'filter_regions',
 152      'presets' => array(
 153          'all' => array( T_('All'), '?ctrl=regions' ),
 154          )
 155      );
 156  
 157  
 158  if( $current_User->check_perm( 'options', 'edit', false ) )
 159  { // We have permission to modify:
 160      $Results->cols[] = array(
 161                              'th' => T_('Country'),
 162                              'order' => 'ctry_name',
 163                                          'td' => '<a href="?ctrl=countries&amp;ctry_ID=$ctry_ID$&amp;action=edit" title="'.T_('Edit this country...')
 164                                              .'"><strong>$ctry_name$</strong></a>',
 165                          );
 166  }
 167  else
 168  {    // View only:
 169      $Results->cols[] = array(
 170                              'th' => T_('Country'),
 171                              'order' => 'ctry_name',
 172                              'td' => '$ctry_name$',
 173                          );
 174  
 175  }
 176  
 177  
 178  $Results->cols[] = array(
 179                          'th' => T_('Code'),
 180                          'td_class' => 'center',
 181                          'order' => 'rgn_code',
 182                          'td' => '<strong>$rgn_code$</strong>',
 183                          'th_class' => 'shrinkwrap',
 184                          'td_class' => 'shrinkwrap'
 185                      );
 186  
 187  
 188  if( $current_User->check_perm( 'options', 'edit', false ) )
 189  { // We have permission to modify:
 190      $Results->cols[] = array(
 191                              'th' => T_('Name'),
 192                              'order' => 'rgn_name',
 193                              'td' => '<a href="?ctrl=regions&amp;rgn_ID=$rgn_ID$&amp;action=edit" title="'.T_('Edit this region...').'"><strong>$rgn_name$</strong></a>',
 194                          );
 195  }
 196  else
 197  {    // View only:
 198      $Results->cols[] = array(
 199                              'th' => T_('Name'),
 200                              'order' => 'rgn_name',
 201                              'td' => '$rgn_name$',
 202                          );
 203  
 204  }
 205  
 206  /*

 207   * ACTIONS TD:

 208   */
 209  function rgn_td_actions($rgn_enabled, $rgn_ID )
 210  {
 211      global $dispatcher;
 212  
 213      $r = '';
 214  
 215      if( $rgn_enabled == true )
 216      {
 217          $r .= action_icon( T_('Disable the region!'), 'deactivate', 
 218                                          regenerate_url( 'action', 'action=disable_region&amp;rgn_ID='.$rgn_ID.'&amp;'.url_crumb('region') ) );
 219      }
 220      else
 221      {
 222          $r .= action_icon( T_('Enable the region!'), 'activate',
 223                                          regenerate_url( 'action', 'action=enable_region&amp;rgn_ID='.$rgn_ID.'&amp;'.url_crumb('region') ) );
 224      }
 225      $r .= action_icon( T_('Edit this region...'), 'edit',
 226                                          regenerate_url( 'action', 'rgn_ID='.$rgn_ID.'&amp;action=edit' ) );
 227      $r .= action_icon( T_('Duplicate this region...'), 'copy',
 228                                          regenerate_url( 'action', 'rgn_ID='.$rgn_ID.'&amp;action=new' ) );
 229      $r .= action_icon( T_('Delete this region!'), 'delete',
 230                                          regenerate_url( 'action', 'rgn_ID='.$rgn_ID.'&amp;action=delete&amp;'.url_crumb('region') ) );
 231  
 232      return $r;
 233  }
 234  if( $current_User->check_perm( 'options', 'edit', false ) )
 235  {
 236      $Results->cols[] = array(
 237              'th' => T_('Actions'),
 238              'td' => '%rgn_td_actions( #rgn_enabled#, #rgn_ID# )%',
 239              'td_class' => 'shrinkwrap',
 240          );
 241  
 242      $Results->global_icon( T_('Create a new region...'), 'new',
 243                  regenerate_url( 'action', 'action=new'), T_('New region').' &raquo;', 3, 4  );
 244  }
 245  
 246  $Results->display();
 247  
 248  ?>

title

Description

title

Description

title

Description

title

title

Body