[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
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-2007 by Francois PLANQUE - {@link http://fplanque.net/} 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,v 1.1 2007/06/25 11:00:54 fplanque Exp $ 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 $edit_Plugin; 51 load_funcs('plugins/_plugin.funcs.php'); 52 53 54 $Results = new Results( ' 55 SELECT plug_status, plug_ID, plug_priority, plug_code, plug_apply_rendering FROM T_plugins', 56 'plug_', '-A-' /* by name */, 0 /* no limit */ ); 57 58 $Results->Cache = & $admin_Plugins; 59 60 /* 61 // TODO: dh> make this an optional view (while also removing the "group" col then)? 62 // It's nice to have, but does not allow sorting by priority really.. 63 // fp> Yes, 90% pf the time, seing a grouped list is what we'd need most. (sorted by priority within each group by default) 64 // 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 65 // 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). 66 // BTW, "category" or "class" or "family" would be a better name for plugin "group"s. "group" sounds arbitrary. I think this shoudl convey the idea of a "logical grouping" by "main" purpose of the plugin. 67 // 68 $Results->group_by_obj_prop = 'group'; 69 $Results->grp_cols[] = array( 70 'td' => '% ( empty( {Obj}->group ) && $this->current_group_count[0] > 1 ? T_(\'Un-Grouped\') : {Obj}->group ) %', 71 'td_colspan' => 0, 72 ); 73 */ 74 75 $Results->title = T_('Installed plugins'); 76 77 /* 78 * STATUS TD: 79 */ 80 function plugin_results_td_status( $plug_status, $plug_ID ) 81 { 82 global $admin_Plugins; 83 84 if( $plug_status == 'enabled' ) 85 { 86 return get_icon('enabled', 'imgtag', array('title'=>T_('The plugin is enabled.')) ); 87 } 88 elseif( $plug_status == 'broken' ) 89 { 90 return get_icon('warning', 'imgtag', array( 91 'title' => T_('The plugin is broken.') 92 .// Display load error from Plugins::register() (if any): 93 ( isset( $admin_Plugins->plugin_errors[$plug_ID] ) 94 && ! empty($admin_Plugins->plugin_errors[$plug_ID]['register']) 95 ? ' '.$admin_Plugins->plugin_errors[$plug_ID]['register'] 96 : '' ) 97 ) ); 98 } 99 elseif( $plug_status == 'install' ) 100 { 101 return get_icon('disabled', 'imgtag', array('title'=>T_('The plugin is not installed completely.')) ); 102 } 103 else 104 { 105 return get_icon('disabled', 'imgtag', array('title'=>T_('The plugin is disabled.')) ); 106 } 107 } 108 $Results->cols[] = array( 109 'th' => /* TRANS: shortcut for enabled */ T_('En'), 110 'order' => 'plug_status', 111 'td' => '%plugin_results_td_status( \'$plug_status$\', $plug_ID$ )%', 112 'td_class' => 'center', 113 ); 114 115 /* 116 * PLUGIN NAME TD: 117 */ 118 function plugin_results_td_name( $Plugin ) 119 { 120 global $current_User; 121 $r = '<strong>'.$Plugin->name.'</strong>'; 122 123 if( $current_User->check_perm( 'options', 'edit', false ) ) 124 { // Wrap in "edit settings" link: 125 $r = '<a href="'.regenerate_url( '', 'action=edit_settings&plugin_ID='.$Plugin->ID ) 126 .'" title="'.T_('Edit plugin settings!').'">'.$r.'</a>'; 127 } 128 return $r; 129 } 130 function plugin_results_name_order_callback( $a, $b, $order ) 131 { 132 $r = strcasecmp( $a->name, $b->name ); 133 if( $order == 'DESC' ) { $r = -$r; } 134 return $r; 135 } 136 $Results->cols[] = array( 137 'th' => T_('Plugin'), 138 'order_objects_callback' => 'plugin_results_name_order_callback', 139 'td' => '% plugin_results_td_name( {Obj} ) %', 140 ); 141 142 if( count($admin_Plugins->get_plugin_groups()) ) 143 { 144 /* 145 * PLUGIN GROUP TD: 146 */ 147 function plugin_results_group_order_callback( $a, $b, $order ) 148 { 149 global $admin_Plugins; 150 151 $r = $admin_Plugins->sort_Plugin_group( $a->ID, $b->ID ); 152 if( $order == 'DESC' ) { $r = -$r; } 153 return $r; 154 } 155 $Results->cols[] = array( 156 'th' => T_('Group'), 157 'order_objects_callback' => 'plugin_results_group_order_callback', 158 'td' => '% {Obj}->group %', 159 ); 160 } 161 162 /* 163 * PRIORITY TD: 164 */ 165 $Results->cols[] = array( 166 'th' => T_('Priority'), 167 'order' => 'plug_priority', 168 'td' => '$plug_priority$', 169 'td_class' => 'right', 170 ); 171 172 /* 173 * APPLY RENDERING TD: 174 */ 175 $apply_rendering_values = $admin_Plugins->get_apply_rendering_values(true); // with descs 176 function plugin_results_td_apply_rendering($apply_rendering) 177 { 178 global $admin_Plugins, $apply_rendering_values; 179 180 return '<span title="'.format_to_output( $apply_rendering_values[$apply_rendering], 'htmlattr' ) 181 .'">'.$apply_rendering.'</span>'; 182 } 183 $Results->cols[] = array( 184 'th' => T_('Apply'), 185 'th_title' => T_('When should rendering apply?'), 186 'order' => 'plug_apply_rendering', 187 'td' => '%plugin_results_td_apply_rendering( \'$plug_apply_rendering$\' )%', 188 ); 189 190 /* 191 * PLUGIN CODE TD: 192 */ 193 $Results->cols[] = array( 194 'th' => /* TRANS: Code of a plugin */ T_('Code'), 195 'th_title' => T_('The code to call the plugin by code (SkinTag) or as Renderer.'), 196 'order' => 'plug_code', 197 'td' => '% {Obj}->code %', 198 ); 199 200 /* 201 * PLUGIN DESCRIPTION TD: 202 */ 203 function plugin_results_desc_order_callback( $a, $b, $order ) 204 { 205 $r = strcasecmp( $a->short_desc, $b->short_desc ); 206 if( $order == 'DESC' ) { $r = -$r; } 207 return $r; 208 } 209 $Results->cols[] = array( 210 'th' => T_('Description'), 211 'td' => '% {Obj}->short_desc %', 212 'order_objects_callback' => 'plugin_results_desc_order_callback', 213 ); 214 215 /* 216 * HELP TD: 217 */ 218 function plugin_results_td_help( $Plugin ) 219 { 220 return action_icon( T_('Display info'), 'info', regenerate_url( 'action,plugin_class', 'action=info&plugin_class='.$Plugin->classname ) ) 221 // Help icons, if available: 222 .$Plugin->get_help_link('$help_url') 223 .' '.$Plugin->get_help_link('$readme'); 224 } 225 $Results->cols[] = array( 226 'th' => T_('Help'), 227 'td_class' => 'nowrap', 228 'td' => '% plugin_results_td_help( {Obj} ) %', 229 ); 230 231 /* 232 * ACTIONS TD: 233 */ 234 function plugin_results_td_actions($Plugin) 235 { 236 $r = ''; 237 if( $Plugin->status == 'enabled' ) 238 { 239 $r .= action_icon( T_('Disable the plugin!'), 'deactivate', 'admin.php?ctrl=plugins&action=disable_plugin&plugin_ID='.$Plugin->ID ); 240 } 241 elseif( $Plugin->status != 'broken' ) 242 { 243 $r .= action_icon( T_('Enable the plugin!'), 'activate', 'admin.php?ctrl=plugins&action=enable_plugin&plugin_ID='.$Plugin->ID ); 244 } 245 $r .= $Plugin->get_edit_settings_link(); 246 $r .= action_icon( T_('Un-install this plugin!'), 'delete', 'admin.php?ctrl=plugins&action=uninstall&plugin_ID='.$Plugin->ID ); 247 return $r; 248 } 249 if( $current_User->check_perm( 'options', 'edit', false ) ) 250 { 251 $Results->cols[] = array( 252 'th' => T_('Actions'), 253 'td' => '% plugin_results_td_actions( {Obj} ) %', 254 'td_class' => 'shrinkwrap', 255 ); 256 } 257 258 // Action icons: 259 260 if( $current_User->check_perm( 'options', 'edit' ) ) 261 { // Display action link to reload plugins: 262 $Results->global_icon( T_('Reload events and codes for installed plugins.'), 'reload', regenerate_url( 'action', 'action=reload_plugins' ), T_('Reload plugins'), 3, 4 ); 263 } 264 265 $Results->global_icon( T_('Install new plugin...'), 'new', regenerate_url( 'action', 'action=list_available' ), T_('Install new'), 3, 4 ); 266 267 268 269 // if there happened something with a plugin_ID, apply fadeout to the row: 270 $highlight_fadeout = empty($edit_Plugin) || ! is_object($edit_Plugin) /* may be error string */ ? array() : array( 'plug_ID'=>array($edit_Plugin->ID) ); 271 272 $Results->display( NULL, $highlight_fadeout ); 273 274 unset($Results); // free memory 275 276 277 /* 278 * $Log: _plugin_list.view.php,v $ 279 * Revision 1.1 2007/06/25 11:00:54 fplanque 280 * MODULES (refactored MVC) 281 * 282 * Revision 1.52 2007/06/05 00:01:21 blueyed 283 * Fixed display of the available plugins Results table, by using 0 for no limit 284 * 285 * Revision 1.51 2007/04/26 00:11:12 fplanque 286 * (c) 2007 287 * 288 * Revision 1.50 2007/03/19 21:22:48 blueyed 289 * doc 290 * 291 * Revision 1.49 2007/02/05 22:17:29 blueyed 292 * Fixed sorting plugins by description 293 * 294 * Revision 1.48 2007/01/14 08:21:01 blueyed 295 * Optimized "info", "disp_help" and "disp_help_plain" actions by refering to them through classname, which makes Plugins::discover() unnecessary 296 * 297 * Revision 1.47 2007/01/13 22:28:13 fplanque 298 * doc 299 * 300 * Revision 1.46 2007/01/13 19:37:39 blueyed 301 * Removed grouping by group from installed plugins. It should be an alternative view probably, if it is useful at all 302 * 303 * Revision 1.45 2007/01/13 19:19:58 blueyed 304 * Group by plugin group; removed the "Group" column therefor 305 * 306 * Revision 1.44 2007/01/07 18:42:35 fplanque 307 * cleaned up reload/refresh icons & links 308 * 309 * Revision 1.43 2006/12/20 23:07:23 blueyed 310 * Moved list of available plugins to separate sub-screen/form 311 * 312 * Revision 1.42 2006/12/16 04:07:10 fplanque 313 * visual cleanup 314 * 315 * Revision 1.41 2006/12/05 05:41:42 fplanque 316 * created playground for skin management 317 * 318 * Revision 1.40 2006/11/30 05:43:39 blueyed 319 * Moved Plugins::discover() to Plugins_admin::discover(); Renamed Plugins_no_DB to Plugins_admin_no_DB (and deriving from Plugins_admin) 320 * 321 * Revision 1.39 2006/11/30 00:30:33 blueyed 322 * Some minor memory optimizations regarding "Plugins" screen 323 * 324 * Revision 1.38 2006/11/24 18:27:26 blueyed 325 * Fixed link to b2evo CVS browsing interface in file docblocks 326 * 327 * Revision 1.37 2006/11/05 18:21:08 fplanque 328 * This is about the 4th time I fix the CSS for the plugins list :( 329 * 330 * Revision 1.36 2006/10/26 21:24:14 blueyed 331 * Do not display "reload events" links, if no perms 332 * 333 * Revision 1.35 2006/10/08 19:50:10 blueyed 334 * Re-enabled sorting plugins by name, group and desc again 335 */ 336 ?>
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 |
![]() |