[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
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-2007 by Francois PLANQUE - {@link http://fplanque.net/} 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,v 1.2 2007/09/12 21:00:32 fplanque Exp $ 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, $edited_plugin_apply_rendering; 47 global $admin_url; 48 49 load_funcs('plugins/_plugin.funcs.php'); 50 51 52 $Form = & new Form( NULL, 'pluginsettings_checkchanges' ); 53 $Form->hidden_ctrl(); 54 55 56 // Info button: 57 $Form->global_icon( T_('Display info'), 'info', regenerate_url( 'action,plugin_class', 'action=info&plugin_class='.$edit_Plugin->classname ) ); 58 59 // Close button: 60 $Form->global_icon( T_('Cancel edit!'), 'close', regenerate_url() ); 61 62 $Form->begin_form( 'fform', '', 63 // enable all form elements on submit (so values get sent): 64 array( 'onsubmit'=>'var es=this.elements; for( var i=0; i < es.length; i++ ) { es[i].disabled=false; };' ) ); 65 66 $Form->hidden( 'plugin_ID', $edit_Plugin->ID ); 67 68 69 // --------------------------- INFO --------------------------- 70 $Form->begin_fieldset( T_('Plugin info'), array( 'class' => 'clear' ) ); 71 // Name: 72 $Form->text_input( 'edited_plugin_name', $edited_plugin_name, 25, T_('Name'), '', array('maxlength' => 255) ); 73 // Desc: 74 $Form->text_input( 'edited_plugin_shortdesc', $edited_plugin_shortdesc, 50, T_('Short desc'), '', array('maxlength' => 255) ); 75 // Links to external manual (dh> has been removed from form's global_icons before by fp, but is very useful IMHO): 76 if( $edit_Plugin->get_help_link('$help_url') ) 77 { 78 $Form->info( T_('Help'), $edit_Plugin->get_help_link('$help_url').' '.$edit_Plugin->get_help_link('$readme') ); 79 } 80 $Form->end_fieldset(); 81 82 83 // --------------------------- SETTINGS --------------------------- 84 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. 85 { 86 load_funcs('plugins/_plugin.funcs.php'); 87 88 // We use output buffers here to only display the fieldset if there's content in there 89 // (either from PluginSettings or PluginSettingsEditDisplayAfter). 90 ob_start(); 91 foreach( $edit_Plugin->GetDefaultSettings( $tmp_params = array('for_editing'=>true) ) as $l_name => $l_meta ) 92 { 93 // Display form field for this setting: 94 autoform_display_field( $l_name, $l_meta, $Form, 'Settings', $edit_Plugin ); 95 } 96 97 // This can be used add custom input fields or display custom output (e.g. a test link): 98 $admin_Plugins->call_method( $edit_Plugin->ID, 'PluginSettingsEditDisplayAfter', $tmp_params = array( 'Form' => & $Form ) ); 99 100 $setting_contents = ob_get_contents(); 101 ob_end_clean(); 102 103 if( $setting_contents ) 104 { 105 $Form->begin_fieldset( T_('Plugin settings'), array( 'class' => 'clear' ) ); 106 echo $setting_contents; 107 $Form->end_fieldset(); 108 } 109 } 110 111 112 // --------------------------- VARIABLES --------------------------- 113 $Form->begin_fieldset( T_('Plugin variables').' ('.T_('Advanced').')', array( 'class' => 'clear' ) ); 114 $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) ); 115 $Form->text_input( 'edited_plugin_priority', $edited_plugin_priority, 4, T_('Priority'), '', array( 'maxlength' => 4 ) ); 116 $render_note = get_manual_link('Plugin/apply_rendering'); 117 if( empty( $edited_plugin_code ) ) 118 { 119 $render_note .= ' '.T_('Note: The plugin code is empty, so this plugin will not work as an "opt-out", "opt-in" or "lazy" renderer.'); 120 } 121 $Form->select_input_array( 'edited_plugin_apply_rendering', $edited_plugin_apply_rendering, 122 $admin_Plugins->get_apply_rendering_values(), T_('Apply rendering'), $render_note ); 123 $Form->end_fieldset(); 124 125 126 // --------------------------- EVENTS --------------------------- 127 $Form->begin_fieldset( T_('Plugin events').' ('.T_('Advanced') 128 .') <img src="'.get_icon('expand', 'url').'" id="clickimg_pluginevents" />', array('legend_params' => array( 'onclick' => 'toggle_clickopen(\'pluginevents\')') ) ); 129 ?> 130 131 <div id="clickdiv_pluginevents"> 132 133 <?php 134 135 if( $edit_Plugin->status != 'enabled' ) 136 { 137 echo '<p class="notes">'.T_('Note: the plugin is not enabled.').'</p>'; 138 } 139 140 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>'; 141 142 $enabled_events = $admin_Plugins->get_enabled_events( $edit_Plugin->ID ); 143 $supported_events = $admin_Plugins->get_supported_events(); 144 $registered_events = $admin_Plugins->get_registered_events( $edit_Plugin ); 145 $count = 0; 146 foreach( array_keys($supported_events) as $l_event ) 147 { 148 if( ! in_array( $l_event, $registered_events ) ) 149 { 150 continue; 151 } 152 $Form->hidden( 'edited_plugin_displayed_events[]', $l_event ); // to consider only displayed ones on update 153 $Form->checkbox_input( 'edited_plugin_events['.$l_event.']', in_array( $l_event, $enabled_events ), $l_event, array( 'note' => $supported_events[$l_event] ) ); 154 $count++; 155 } 156 if( ! $count ) 157 { 158 echo T_( 'This plugin has no registered events.' ); 159 } 160 ?> 161 162 </div> 163 164 <?php 165 $Form->end_fieldset(); 166 ?> 167 168 169 <script type="text/javascript"> 170 <!-- 171 toggle_clickopen('pluginevents'); 172 // --> 173 </script> 174 175 <?php 176 if( $current_User->check_perm( 'options', 'edit', false ) ) 177 { 178 $Form->buttons_input( array( 179 array( 'type' => 'submit', 'name' => 'actionArray[update_settings]', 'value' => T_('Save !'), 'class' => 'SaveButton' ), 180 array( 'type' => 'submit', 'name' => 'actionArray[update_settings][review]', 'value' => T_('Save (and review)'), 'class' => 'SaveButton' ), 181 array( 'type' => 'reset', 'value' => T_('Reset'), 'class' => 'ResetButton' ), 182 array( 'type' => 'submit', 'name' => 'actionArray[default_settings]', 'value' => T_('Restore defaults'), 'class' => 'SaveButton' ), 183 ) ); 184 } 185 $Form->end_form(); 186 187 188 /* 189 * $Log: _plugin_settings.form.php,v $ 190 * Revision 1.2 2007/09/12 21:00:32 fplanque 191 * UI improvements 192 * 193 * Revision 1.1 2007/06/25 11:00:55 fplanque 194 * MODULES (refactored MVC) 195 * 196 * Revision 1.36 2007/06/19 20:41:10 fplanque 197 * renamed generic functions to autoform_* 198 * 199 * Revision 1.35 2007/06/19 00:03:26 fplanque 200 * doc / trying to make sense of automatic settings forms generation. 201 * 202 * Revision 1.34 2007/04/26 00:11:12 fplanque 203 * (c) 2007 204 * 205 * Revision 1.33 2007/04/02 20:33:27 blueyed 206 * Added (real) link to external manual/wiki 207 * 208 * Revision 1.31 2007/02/19 23:17:00 blueyed 209 * Only display Plugin(User)Settings fieldsets if there is content in them. 210 * 211 * Revision 1.30 2007/01/23 08:57:36 fplanque 212 * decrap! 213 * 214 * Revision 1.29 2007/01/14 08:21:01 blueyed 215 * Optimized "info", "disp_help" and "disp_help_plain" actions by refering to them through classname, which makes Plugins::discover() unnecessary 216 * 217 * Revision 1.28 2006/12/09 01:55:36 fplanque 218 * feel free to fill in some missing notes 219 * hint: "login" does not need a note! :P 220 * 221 * Revision 1.27 2006/11/24 18:27:26 blueyed 222 * Fixed link to b2evo CVS browsing interface in file docblocks 223 * 224 * Revision 1.26 2006/11/14 00:22:13 blueyed 225 * doc 226 * 227 * Revision 1.25 2006/11/09 23:40:57 blueyed 228 * Fixed Plugin UserSettings array type editing; Added jquery and use it for AJAHifying Plugin (User)Settings editing of array types 229 * 230 * Revision 1.24 2006/11/05 18:33:58 fplanque 231 * no external links in action icons 232 * 233 * Revision 1.23 2006/10/30 19:00:36 blueyed 234 * Lazy-loading of Plugin (User)Settings for PHP5 through overloading 235 * 236 * Revision 1.22 2006/10/17 18:36:47 blueyed 237 * Priorize NULL for plug_name/plug_shortdesc (localization); minor fixes in this area 238 */ 239 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |