b2evolution PHP Cross Reference Blogging Systems

Source: /inc/regional/views/_currency_list.view.php - 182 lines - 5587 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: _currency_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  31   */
  32  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  33  
  34  global $dispatcher;
  35  
  36  // Get params from request
  37  $s = param( 's', 'string', '', true );
  38  
  39  //Create query
  40  $SQL = new SQL();
  41  $SQL->SELECT( '*' );
  42  $SQL->FROM( 'T_regional__currency' );
  43  
  44  if( !empty($s) )
  45  {    // We want to filter on search keyword:
  46      // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
  47      $SQL->WHERE( 'CONCAT_WS( " ", curr_code, curr_name ) LIKE "%'.$DB->escape($s).'%"' );
  48  }
  49  
  50  // Create result set:
  51  $Results = new Results( $SQL->get(), 'curr_', '-A');
  52  
  53  $Results->Cache = & get_CurrencyCache();
  54  
  55  $Results->title = T_('Currencies list').get_manual_link('currencies_list');
  56  
  57  /*
  58   * STATUS TD:
  59   */
  60  function curr_td_enabled( $curr_enabled, $curr_ID )
  61  {
  62      global $dispatcher;
  63  
  64      $r = '';
  65  
  66      if( $curr_enabled == true )
  67      {
  68          $r .= action_icon( T_('Disable the currency!'), 'bullet_full',
  69                                          regenerate_url( 'action', 'action=disable_currency&amp;curr_ID='.$curr_ID.'&amp;'.url_crumb('currency') ) );
  70      }
  71      else
  72      {
  73          $r .= action_icon( T_('Enable the currency!'), 'bullet_empty',
  74                                          regenerate_url( 'action', 'action=enable_currency&amp;curr_ID='.$curr_ID.'&amp;'.url_crumb('currency') ) );
  75      }
  76  
  77      return $r;
  78  
  79  }
  80  $Results->cols[] = array(
  81          'th' => /* TRANS: shortcut for enabled */ T_('En'),
  82          'th_title' => T_('Enabled'),
  83          'order' => 'curr_enabled',
  84          'td' => '%curr_td_enabled( #curr_enabled#, #curr_ID# )%',
  85          'td_class' => 'center'
  86      );
  87  
  88  /**
  89   * Callback to add filters on top of the result set
  90   *
  91   * @param Form
  92   */
  93  function filter_currencies( & $Form )
  94  {
  95      $Form->text( 's', get_param('s'), 30, T_('Search'), '', 255 );
  96  }
  97  
  98  $Results->filter_area = array(
  99      'callback' => 'filter_currencies',
 100      'presets' => array(
 101          'all' => array( T_('All'), '?ctrl=currencies' ),
 102          )
 103      );
 104  
 105  if( $current_User->check_perm( 'options', 'edit', false ) )
 106  { // We have permission to modify:
 107      $Results->cols[] = array(
 108                              'th' => T_('Code'),
 109                              'order' => 'curr_code',
 110                              'td' => '<strong><a href="'.$dispatcher.'?ctrl=currencies&amp;curr_ID=$curr_ID$&amp;action=edit" title="'.
 111                                              T_('Edit this currency...').'">$curr_code$</a></strong>',
 112                              'td_class' => 'center',
 113                          );
 114  }
 115  else
 116  {    // View only:
 117      $Results->cols[] = array(
 118                              'th' => T_('Code'),
 119                              'order' => 'curr_code',
 120                              'td' => '<strong>$curr_code$</strong>',
 121                              'td_class' => 'center',
 122                          );
 123  
 124  }
 125  
 126  $Results->cols[] = array(
 127                          'th' => T_('Shortcut'),
 128                          'order' => 'curr_shortcut',
 129                          'td' => '$curr_shortcut$',
 130                          'td_class' => 'center',
 131                      );
 132  
 133  $Results->cols[] = array(
 134                          'th' => T_('Name'),
 135                          'order' => 'curr_name',
 136                          'td' => '$curr_name$',
 137                      );
 138  
 139  /*
 140   * ACTIONS TD:
 141   */
 142  function curr_td_actions($curr_enabled, $curr_ID )
 143  {
 144      global $dispatcher;
 145  
 146      $r = '';
 147  
 148      if( $curr_enabled == true )
 149      {
 150          $r .= action_icon( T_('Disable the currency!'), 'deactivate', 
 151                                          regenerate_url( 'action', 'action=disable_currency&amp;curr_ID='.$curr_ID.'&amp;'.url_crumb('currency') ) );
 152      }
 153      else
 154      {
 155          $r .= action_icon( T_('Enable the currency!'), 'activate', 
 156                                          regenerate_url( 'action', 'action=enable_currency&amp;curr_ID='.$curr_ID.'&amp;'.url_crumb('currency') ) );
 157      }
 158      $r .= action_icon( T_('Edit this currency...'), 'edit',
 159                                          regenerate_url( 'action', 'curr_ID='.$curr_ID.'&amp;action=edit' ) );
 160      $r .= action_icon( T_('Duplicate this currency...'), 'copy',
 161                                          regenerate_url( 'action', 'curr_ID='.$curr_ID.'&amp;action=new' ) );
 162      $r .= action_icon( T_('Delete this currency!'), 'delete',
 163                                          regenerate_url( 'action', 'curr_ID='.$curr_ID.'&amp;action=delete&amp;'.url_crumb('currency') ) );
 164  
 165      return $r;
 166  }
 167  if( $current_User->check_perm( 'options', 'edit', false ) )
 168  { // We have permission to modify:
 169      $Results->cols[] = array(
 170              'th' => T_('Actions'),
 171              'th_class' => 'shrinkwrap',
 172              'td' => '%curr_td_actions( #curr_enabled#, #curr_ID# )%',
 173              'td_class' => 'shrinkwrap',
 174          );
 175  
 176      $Results->global_icon( T_('Create a new currency...'), 'new',
 177                  regenerate_url( 'action', 'action=new'), T_('New currency').' &raquo;', 3, 4  );
 178  }
 179  
 180  $Results->display();
 181  
 182  ?>

title

Description

title

Description

title

Description

title

title

Body