b2evolution PHP Cross Reference Blogging Systems

Source: /inc/plugins/views/_plugin_settings.form.php - 185 lines - 6990 bytes - Text - Print

Description: Form to edit settings of a plugin. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * Form to edit settings of a plugin.
   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_settings.form.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   * @global Plugin
  38   */
  39  global $edit_Plugin;
  40  
  41  /**
  42   * @global Plugins_admin
  43   */
  44  global $admin_Plugins;
  45  
  46  global $edited_plugin_name, $edited_plugin_shortdesc, $edited_plugin_priority, $edited_plugin_code;
  47  global $admin_url;
  48  
  49  load_funcs('plugins/_plugin.funcs.php');
  50  
  51  
  52  $Form = new Form( NULL, 'pluginsettings_checkchanges' );
  53  
  54  // Restore defaults button:
  55  $Form->global_icon( T_('Restore defaults'), 'reload', regenerate_url( 'action,plugin_class', 'action=default_settings&amp;plugin_ID=' . $edit_Plugin->ID . '&amp;crumb_plugin=' . get_crumb( 'plugin' ) ), T_('Restore defaults'),5,4,
  56      array(
  57              'onclick'=>'if (!confirm(\''.TS_('Are you sure you want to restore the default settings? This cannot be undone!').'\')) { cancelClick(event); }',
  58          )
  59      );
  60  
  61  // Info button:
  62  $Form->global_icon( T_('Display info'), 'info', regenerate_url( 'action,plugin_class', 'action=info&amp;plugin_class='.$edit_Plugin->classname ) );
  63  
  64  // Close button:
  65  $Form->global_icon( T_('Cancel edit!'), 'close', regenerate_url() );
  66  
  67  $Form->begin_form( 'fform', '',
  68      // enable all form elements on submit (so values get sent):
  69      array( 'onsubmit'=>'var es=this.elements; for( var i=0; i < es.length; i++ ) { es[i].disabled=false; };' ) );
  70  
  71      $Form->add_crumb( 'plugin' );
  72      $Form->hidden_ctrl();
  73      $Form->hidden( 'plugin_ID', $edit_Plugin->ID );
  74  
  75  
  76  // --------------------------- INFO ---------------------------
  77  $Form->begin_fieldset( T_('Plugin info'), array( 'class' => 'clear' ) );
  78      // Name:
  79      $Form->text_input( 'edited_plugin_name', $edited_plugin_name, 25, T_('Name'), '', array('maxlength' => 255) );
  80      // Desc:
  81      $Form->text_input( 'edited_plugin_shortdesc', $edited_plugin_shortdesc, 50, T_('Short desc'), '', array('maxlength' => 255) );
  82      // Links to external manual (dh> has been removed from form's global_icons before by fp, but is very useful IMHO):
  83      if( $edit_Plugin->get_help_link('$help_url') )
  84      {
  85          $Form->info( T_('Help'), $edit_Plugin->get_help_link('$help_url') );
  86      }
  87  $Form->end_fieldset();
  88  
  89  
  90  // --------------------------- SETTINGS ---------------------------
  91  if( $edit_Plugin->Settings ) // NOTE: this triggers PHP5 autoloading through Plugin::__get() and therefor the 'isset($this->Settings)' hack in Plugin::GetDefaultSettings() still works, which is good.
  92  {
  93      load_funcs('plugins/_plugin.funcs.php');
  94  
  95      // We use output buffers here to only display the fieldset if there's content in there
  96      // (either from PluginSettings or PluginSettingsEditDisplayAfter).
  97      ob_start();
  98      foreach( $edit_Plugin->GetDefaultSettings( $tmp_params = array('for_editing'=>true) ) as $l_name => $l_meta )
  99      {
 100          // Display form field for this setting:
 101          autoform_display_field( $l_name, $l_meta, $Form, 'Settings', $edit_Plugin );
 102      }
 103  
 104      // This can be used add custom input fields or display custom output (e.g. a test link):
 105      $admin_Plugins->call_method( $edit_Plugin->ID, 'PluginSettingsEditDisplayAfter', $tmp_params = array( 'Form' => & $Form ) );
 106  
 107      $setting_contents = ob_get_contents();
 108      ob_end_clean();
 109  
 110      if( $setting_contents )
 111      {
 112          $Form->begin_fieldset( T_('Plugin settings'), array( 'class' => 'clear' ) );
 113          echo $setting_contents;
 114          $Form->end_fieldset();
 115      }
 116  }
 117  
 118  
 119  // --------------------------- VARIABLES ---------------------------
 120  $Form->begin_fieldset( T_('Plugin variables').' ('.T_('Advanced').')', array( 'class' => 'clear' ) );
 121      $Form->text_input( 'edited_plugin_code', $edited_plugin_code, 15, T_('Code'), T_('The code to call the plugin by code. This is also used to link renderer plugins to items.'), array('maxlength'=>32) );
 122      $Form->text_input( 'edited_plugin_priority', $edited_plugin_priority, 4, T_('Priority'), '', array( 'maxlength' => 4 ) );
 123  $Form->end_fieldset();
 124  
 125  
 126  // --------------------------- EVENTS ---------------------------
 127  $Form->begin_fieldset( T_('Plugin events').' ('.T_('Advanced').') '.get_icon( 'collapse', 'imgtag', array( 'id' => 'clickimg_pluginevents' ) ),
 128                                               array('legend_params' => array( 'onclick' => 'toggle_clickopen(\'pluginevents\')') )
 129                                               );
 130      ?>
 131  
 132      <div id="clickdiv_pluginevents">
 133  
 134      <?php
 135  
 136      if( $edit_Plugin->status != 'enabled' )
 137      {
 138          echo '<p class="notes">'.T_('Note: the plugin is not enabled.').'</p>';
 139      }
 140  
 141      echo '<p>'.T_('Warning: by disabling plugin events you change the behaviour of the plugin! Only change this, if you know what you are doing.').'</p>';
 142  
 143      $enabled_events = $admin_Plugins->get_enabled_events( $edit_Plugin->ID );
 144      $supported_events = $admin_Plugins->get_supported_events();
 145      $registered_events = $admin_Plugins->get_registered_events( $edit_Plugin );
 146      $count = 0;
 147      foreach( array_keys($supported_events) as $l_event )
 148      {
 149          if( ! in_array( $l_event, $registered_events ) )
 150          {
 151              continue;
 152          }
 153          $Form->hidden( 'edited_plugin_displayed_events[]', $l_event ); // to consider only displayed ones on update
 154          $Form->checkbox_input( 'edited_plugin_events['.$l_event.']', in_array( $l_event, $enabled_events ), $l_event, array( 'note' => $supported_events[$l_event] ) );
 155          $count++;
 156      }
 157      if( ! $count )
 158      {
 159          echo T_( 'This plugin has no registered events.' );
 160      }
 161      ?>
 162  
 163      </div>
 164  
 165      <?php
 166  $Form->end_fieldset();
 167  ?>
 168  
 169  
 170  <script type="text/javascript">
 171      <!--
 172      toggle_clickopen('pluginevents');
 173      // -->
 174  </script>
 175  
 176  <?php
 177  if( $current_User->check_perm( 'options', 'edit', false ) )
 178  {
 179      $Form->buttons_input( array(
 180          array( 'type' => 'submit', 'name' => 'actionArray[update_settings]', 'value' => T_('Save !'), 'class' => 'SaveButton' ),
 181          ) );
 182  }
 183  $Form->end_form();
 184  
 185  ?>

title

Description

title

Description

title

Description

title

title

Body