b2evolution PHP Cross Reference Blogging Systems

Source: /inc/plugins/views/_plugin_list.view.php - 264 lines - 8477 bytes - Summary - Text - Print

Description: This file implements the UI view for the plugin settings.

   1  <?php
   2  /**
   3   * This file implements the UI view for the plugin settings.
   4   *
   5   * @todo dh> Move plugin's group name to DB setting?!
   6   * fp> this would actually make more sense than renaming the name and code of plugins, but it's still complexity we don't really need.
   7   * fp> When you reach that level of needs you're already a plugin maniac/developper and you hack the plugin php code anyway.
   8   *
   9   * This file is part of the evoCore framework - {@link http://evocore.net/}
  10   * See also {@link http://sourceforge.net/projects/evocms/}.
  11   *
  12   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  13   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  14   *
  15   * {@internal License choice
  16   * - If you have received this file as part of a package, please find the license.txt file in
  17   *   the same folder or the closest folder above for complete license terms.
  18   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  19   *   then you must choose one of the following licenses before using the file:
  20   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  21   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  22   * }}
  23   *
  24   * {@internal Open Source relicensing agreement:
  25   * Daniel HAHLER grants Francois PLANQUE the right to license
  26   * Daniel HAHLER's contributions to this file and the b2evolution project
  27   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  28   * }}
  29   *
  30   * @package admin
  31   *
  32   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  33   * @author fplanque: Francois PLANQUE.
  34   * @author blueyed: Daniel HAHLER.
  35   *
  36   * @version $Id: _plugin_list.view.php 6136 2014-03-08 07:59:48Z manuel $
  37   */
  38  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  39  
  40  
  41  /**
  42   * @var User
  43   */
  44  global $current_User;
  45  /**
  46   * @var Plugins
  47   */
  48  global $admin_Plugins;
  49  
  50  global $Session;
  51  
  52  $fadeout_id = $Session->get('fadeout_id');
  53  
  54  load_funcs('plugins/_plugin.funcs.php');
  55  
  56  $SQL = new SQL();
  57  $SQL->SELECT( 'plug_status, plug_ID, plug_priority, plug_code' );
  58  $SQL->FROM( 'T_plugins' );
  59  
  60  $Results = new Results( $SQL->get(), 'plug_', '--A' /* by name */, 0 /* no limit */ );
  61  
  62  $Results->Cache = & $admin_Plugins;
  63  
  64  /*
  65  // TODO: dh> make this an optional view (while also removing the "group" col then)?
  66  //           It's nice to have, but does not allow sorting by priority really..
  67  // fp> Yes, 90% of the time, seing a grouped list is what we'd need most. (sorted by priority within each group by default)
  68  // in the remaining 10% we need an overall priority view because a plugin is not in the right group or more problematic: in multiple groups
  69  // BTW, when does the priority apply besides for rendering? I think we should document that at the bottom of the screen. ("Apply" needs an short explanation too).
  70  // BTW, "category" or "class" or "family" would be a better name for plugin "group"s. "group" sounds arbitrary. I think this should convey the idea of a "logical grouping" by "main" purpose of the plugin.
  71  //
  72  $Results->group_by_obj_prop = 'group';
  73  $Results->grp_cols[] = array(
  74          'td' => '% ( empty( {Obj}->group ) && $this->current_group_count[0] > 1 ? T_(\'Un-Grouped\') : {Obj}->group ) %',
  75          'td_colspan' => 0,
  76      );
  77  */
  78  
  79  $Results->title = T_('Installed plugins').get_manual_link('installed_plugins');
  80  
  81  if( count( $admin_Plugins->get_plugin_groups() ) )
  82  {
  83      /*
  84       * Grouping params:
  85       */
  86      $Results->group_by_obj_prop = 'group';
  87  
  88  
  89      /*
  90       * Group columns:
  91       */
  92      $Results->grp_cols[] = array(
  93              'td_colspan' => 0,
  94              'td' => '% {Obj}->group %',
  95          );
  96  }
  97  
  98  /*
  99   * STATUS TD:
 100   */
 101  function plugin_results_td_status( $plug_status, $plug_ID )
 102  {
 103      global $admin_Plugins;
 104  
 105      if( $plug_status == 'enabled' )
 106      {
 107          return get_icon('enabled', 'imgtag', array('title'=>T_('The plugin is enabled.')) );
 108      }
 109      elseif( $plug_status == 'broken' )
 110      {
 111          return get_icon('warning', 'imgtag', array(
 112              'title' => T_('The plugin is broken.')
 113                  .// Display load error from Plugins::register() (if any):
 114                  ( isset( $admin_Plugins->plugin_errors[$plug_ID] )
 115                      && ! empty($admin_Plugins->plugin_errors[$plug_ID]['register'])
 116                      ? ' '.$admin_Plugins->plugin_errors[$plug_ID]['register']
 117                      : '' )
 118              ) );
 119      }
 120      elseif( $plug_status == 'install' )
 121      {
 122          return get_icon('disabled', 'imgtag', array('title'=>T_('The plugin is not installed completely.')) );
 123      }
 124      else
 125      {
 126          return get_icon('disabled', 'imgtag', array('title'=>T_('The plugin is disabled.')) );
 127      }
 128  }
 129  $Results->cols[] = array(
 130          'th' => /* TRANS: shortcut for enabled */ T_('En'),
 131          'th_title' => T_('Enabled'),
 132          'order' => 'plug_status',
 133          'td' => '%plugin_results_td_status( \'$plug_status$\', $plug_ID$ )%',
 134          'td_class' => 'center',
 135      );
 136  
 137  /*
 138   * PLUGIN NAME TD:
 139   */
 140  function plugin_results_td_name( $Plugin )
 141  {
 142      global $current_User;
 143      $r = '<strong>'.$Plugin->name.'</strong>';
 144  
 145      if( $current_User->check_perm( 'options', 'edit', false ) )
 146      { // Wrap in "edit settings" link:
 147          $r = '<a href="'.regenerate_url( '', 'action=edit_settings&amp;plugin_ID='.$Plugin->ID )
 148              .'" title="'.T_('Edit plugin settings!').'">'.$r.'</a>';
 149      }
 150      return $r;
 151  }
 152  function plugin_results_name_order_callback( $a, $b, $order )
 153  {
 154      $r = strcasecmp( $a->name, $b->name );
 155      if( $order == 'DESC' ) { $r = -$r; }
 156      return $r;
 157  }
 158  $Results->cols[] = array(
 159          'th' => T_('Plugin'),
 160          'order_objects_callback' => 'plugin_results_name_order_callback',
 161          'td' => '% plugin_results_td_name( {Obj} ) %',
 162      );
 163  
 164  /*
 165   * PRIORITY TD:
 166   */
 167  $Results->cols[] = array(
 168          'th' => T_('Priority'),
 169          'order' => 'plug_priority',
 170          'td' => '$plug_priority$',
 171          'td_class' => 'right',
 172      );
 173  
 174  /*
 175   * PLUGIN DESCRIPTION TD:
 176   */
 177  function plugin_results_desc_order_callback( $a, $b, $order )
 178  {
 179      $r = strcasecmp( $a->short_desc, $b->short_desc );
 180      if( $order == 'DESC' ) { $r = -$r; }
 181      return $r;
 182  }
 183  $Results->cols[] = array(
 184          'th' => T_('Description'),
 185          'td' => '% {Obj}->short_desc %',
 186          'order_objects_callback' => 'plugin_results_desc_order_callback',
 187      );
 188  
 189  /*
 190   * PLUGIN CODE TD:
 191   */
 192  $Results->cols[] = array(
 193          'th' => /* TRANS: Code of a plugin */ T_('Code'),
 194          'th_title' => T_('The code to call the plugin by code (SkinTag) or as Renderer.'),
 195          'order' => 'plug_code',
 196          'td' => '% {Obj}->code %',
 197      );
 198  
 199  /*
 200   * HELP TD:
 201   */
 202  function plugin_results_td_help( $Plugin )
 203  {
 204      return action_icon( T_('Display info'), 'info', regenerate_url( 'action,plugin_class', 'action=info&amp;plugin_class='.$Plugin->classname ) )
 205          // Help icons, if available:
 206          .$Plugin->get_help_link('$help_url');
 207  }
 208  $Results->cols[] = array(
 209          'th' => T_('Help'),
 210          'td_class' => 'nowrap',
 211          'td' => '% plugin_results_td_help( {Obj} ) %',
 212      );
 213  
 214  /*
 215   * ACTIONS TD:
 216   */
 217  function plugin_results_td_actions($Plugin)
 218  {
 219      global $dispatcher;
 220  
 221      $r = '';
 222      if( $Plugin->status == 'enabled' )
 223      {
 224          $r .= action_icon( T_('Disable the plugin!'), 'deactivate', $dispatcher.'?ctrl=plugins&amp;action=disable_plugin&amp;plugin_ID='.$Plugin->ID.'&amp;'.url_crumb('plugin') );
 225      }
 226      elseif( $Plugin->status != 'broken' )
 227      {
 228          $r .= action_icon( T_('Enable the plugin!'), 'activate', $dispatcher.'?ctrl=plugins&amp;action=enable_plugin&amp;plugin_ID='.$Plugin->ID.'&amp;'.url_crumb('plugin') );
 229      }
 230      $r .= $Plugin->get_edit_settings_link();
 231      $r .= action_icon( T_('Un-install this plugin!'), 'delete', $dispatcher.'?ctrl=plugins&amp;action=uninstall&amp;plugin_ID='.$Plugin->ID.'&amp;'.url_crumb('plugin') );
 232      return $r;
 233  }
 234  if( $current_User->check_perm( 'options', 'edit', false ) )
 235  {
 236      $Results->cols[] = array(
 237              'th' => T_('Actions'),
 238              'td' => '% plugin_results_td_actions( {Obj} ) %',
 239              'td_class' => 'shrinkwrap',
 240          );
 241  }
 242  
 243  // Action icons:
 244  
 245  if( $current_User->check_perm( 'options', 'edit' ) )
 246  { // Display action link to reload plugins:
 247      $Results->global_icon( T_('Reload events and codes for installed plugins.'), 'reload', regenerate_url( 'action', 'action=reload_plugins' ).'&amp;'.url_crumb('plugin'), T_('Reload plugins'), 3, 4 );
 248  }
 249  
 250  $Results->global_icon( T_('Install new plugin...'), 'new', regenerate_url( 'action', 'action=list_available' ), T_('Install new'), 3, 4 );
 251  
 252  
 253  
 254  // if there happened something with a plugin, apply fadeout to the row:
 255  $highlight_fadeout = empty($fadeout_id) /* may be error string */ ? array() : array( 'plug_ID'=>array($fadeout_id) );
 256  
 257  $Results->display( NULL, $highlight_fadeout );
 258  
 259  unset($Results); // free memory
 260  
 261  //Flush fadeout
 262  $Session->delete( 'fadeout_id');
 263  
 264  ?>

title

Description

title

Description

title

Description

title

title

Body