b2evolution PHP Cross Reference Blogging Systems

Source: /inc/plugins/views/_plugin_list_available.view.php - 210 lines - 6825 bytes - Text - Print

Description: This file implements the UI view for the available plugins. 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 implements the UI view for the available plugins.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.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)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * Daniel HAHLER grants Francois PLANQUE the right to license
  22   * Daniel HAHLER's contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package admin
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author fplanque: Francois PLANQUE.
  30   * @author blueyed: Daniel HAHLER.
  31   *
  32   * @version $Id: _plugin_list_available.view.php 6136 2014-03-08 07:59:48Z manuel $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  /**
  37   * @var User
  38   */
  39  global $current_User;
  40  /**
  41   * @var Plugins
  42   */
  43  global $admin_Plugins;
  44  
  45  global $dispatcher;
  46  
  47  $Table = new Table();
  48  
  49  $Table->title = T_('Plugins available for installation').get_manual_link('plugins_available_for_installation');
  50  
  51  $Table->global_icon( T_('Cancel install!'), 'close', regenerate_url(), T_('Cancel'), 3, 4 );
  52  
  53  $Table->cols = array(
  54          array( 'th' => T_('Plugin') ),
  55          array( 'th' => T_('Description') ),
  56          array( 'th' => T_('Version') ),
  57          array( 'th' => T_('Help'),
  58                       'td_class' => 'nowrap' ),
  59          array( 'th' => T_('Actions'),
  60                       'td_class' => 'nowrap' ),
  61      );
  62  
  63  $Table->display_init();
  64  
  65  $Table->display_list_start();
  66  
  67  // TITLE / COLUMN HEADERS:
  68  $Table->display_head();
  69  
  70  // BODY START:
  71  $Table->display_body_start();
  72  
  73  if( empty($AvailablePlugins) || ! is_a( $AvailablePlugins, 'Plugins_admin_no_DB' ) )
  74  { // (may have been instantiated for action 'info')
  75      load_class( 'plugins/model/_plugins_admin_no_db.class.php', 'Plugins_admin_no_DB' );
  76      $AvailablePlugins = new Plugins_admin_no_DB(); // do not load registered plugins/events from DB
  77      $AvailablePlugins->discover();
  78  }
  79  
  80  // Sort the plugins by group
  81  $AvailablePlugins->sort('group');
  82  // Grouping
  83  $current_group = false; // False so it does the header once
  84  $current_sub_group = '';
  85  
  86  $number_of_groups = count($AvailablePlugins->get_plugin_groups());
  87  
  88  while( $loop_Plugin = & $AvailablePlugins->get_next() )
  89  {
  90  
  91      if( $loop_Plugin->group !== $current_group && $number_of_groups )
  92      { // Reason why $current_group is false
  93          $current_group = $loop_Plugin->group;
  94          $current_sub_group = '';
  95          ?>
  96          <tr class="group">
  97              <td colspan="5" class="first"><?php
  98              if( $current_group == '' || $current_group == 'Un-Grouped' )
  99              {
 100                  echo T_('Un-Classified');
 101              }
 102              else
 103              {
 104                  echo $current_group;
 105              }
 106              ?></td>
 107          </tr>
 108          <?php
 109      }
 110  
 111      if( $loop_Plugin->sub_group != $current_sub_group )
 112      {
 113          $current_sub_group = $loop_Plugin->sub_group;
 114          ?>
 115          <tr class="PluginsSubGroup">
 116              <th colspan="5"><?php echo $current_sub_group; ?></th>
 117          </tr>
 118          <?php
 119      }
 120  
 121      // fp> TODO: support for table.grouped tr.PluginsSubGroup td.firstcol (maybe... subgroups seem crazy anyway - where does it stop?).
 122      $Table->display_line_start();
 123  
 124          $Table->display_col_start();
 125        ?>
 126              <strong><a title="<?php echo T_('Display info') ?>" href="<?php echo regenerate_url( 'action,plugin_class', 'action=info&amp;plugin_class='.$loop_Plugin->classname) ?>">
 127          <?php echo format_to_output($loop_Plugin->name); ?></a></strong>
 128          <?php
 129          $Table->display_col_end();
 130  
 131          $Table->display_col_start();
 132              echo format_to_output($loop_Plugin->short_desc);
 133              /*
 134              // Available events:
 135              $registered_events = implode( ', ', $AvailablePlugins->get_registered_events( $loop_Plugin ) );
 136              if( empty($registered_events) )
 137              {
 138                  $registered_events = '-';
 139              }
 140              echo '<span class="advanced_info notes"><br />'.T_('Registered events:').' '.$registered_events.'</span>';
 141              */
 142          $Table->display_col_end();
 143  
 144          $Table->display_col_start();
 145              $clean_version = preg_replace( array('~^(CVS\s+)?\$'.'Revision:\s*~i', '~\s*\$$~'), '', $loop_Plugin->version );
 146  
 147              echo format_to_output($clean_version);
 148          $Table->display_col_end();
 149  
 150          // HELP COL:
 151          $Table->display_col_start();
 152              echo action_icon( T_('Display info'), 'info', regenerate_url( 'action,plugin_class', 'action=info&amp;plugin_class='.$loop_Plugin->classname ) );
 153              // Help icons, if available:
 154              $help_icons = array();
 155              if( $help_external = $loop_Plugin->get_help_link() )
 156              {
 157                  $help_icons[] = $help_external;
 158              }
 159              if( ! empty($help_icons) )
 160              {
 161                  echo ' '.implode( ' ', $help_icons );
 162              }
 163          $Table->display_col_end();
 164  
 165          $Table->display_col_start();
 166              $registrations = $admin_Plugins->count_regs($loop_Plugin->classname);
 167  
 168              if( $current_User->check_perm( 'options', 'edit', false )
 169                      && ( ! isset( $loop_Plugin->number_of_installs )
 170                           || $registrations < $loop_Plugin->number_of_installs ) )
 171              { // number of installations are not limited or not reached yet and user has "edit options" perms
 172                  ?>
 173                  [<a href="<?php echo $dispatcher ?>?ctrl=plugins&amp;action=install&amp;plugin=<?php echo rawurlencode($loop_Plugin->classname).'&amp;'.url_crumb('plugin') ?>"><?php
 174                      echo T_('Install');
 175                      if( $registrations )
 176                      {    // This plugin is already installed
 177                          echo ' #'.($registrations+1);
 178                      }
 179                      ?></a>]
 180                  <?php
 181              }
 182          $Table->display_col_end();
 183  
 184      $Table->display_line_end();
 185  
 186      evo_flush();
 187      // free memory:
 188      $AvailablePlugins->unregister($loop_Plugin);
 189  }
 190  
 191  // BODY END:
 192  $Table->display_body_end();
 193  
 194  
 195  $Table->display_list_end();
 196  
 197  
 198  // Note about how to make plugins available for installation.
 199  // It should make clear that the above list are not all available plugins (e.g. through an online channel)!
 200  global $plugins_path;
 201  echo '<p>';
 202  echo T_('The above plugins are those already installed into your "plugins" directory.');
 203  echo "</p>\n<p>";
 204  printf( T_('You can find more plugins online at %s or other channels.'), '<a href="http://plugins.b2evolution.net/">plugins.b2evolution.net</a>');
 205  echo "</p>\n<p>";
 206  printf( T_('To make a plugin available for installation, extract it into the "%s" directory on the server.'),
 207      rel_path_to_base($plugins_path) );
 208  echo '</p>';
 209  
 210  ?>

title

Description

title

Description

title

Description

title

title

Body