From 38104f37e2cc4fe5297fd1693812040e8222dbd5 Mon Sep 17 00:00:00 2001 From: onli Date: Fri, 2 Mar 2012 15:39:58 +0100 Subject: [PATCH] smartified plugins.nc.php --- include/admin/plugins.inc.php | 327 +++++++---------------- include/admin/tpl/plugins.inc.tpl | 210 +++++++++++++++ include/serendipity_smarty_class.inc.php | 2 +- 3 files changed, 307 insertions(+), 232 deletions(-) create mode 100644 include/admin/tpl/plugins.inc.tpl diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index 2273cd4a..fef620c4 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -10,6 +10,8 @@ if (!serendipity_checkPermission('adminPlugins')) { return; } +$data = array(); + include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php'; include_once S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php'; include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; @@ -63,7 +65,8 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { if (!($plugin->protected === FALSE || $plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) { return; } - + $data['plugin_to_conf'] = true; + $bag = new serendipity_property_bag; $plugin->introspect($bag); @@ -120,78 +123,44 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $plugin->cleanup(); } -?> - 0 ) { ?> -
- - \n"; - echo "\n"; - ?> -
- -
- -
- - - - - - + if (@file_exists(dirname($plugin->pluginFile) . '/documentation_' . $serendipity['lang'] . '.html')) { + $data['documentation_local'] = '/documentation_' . $serendipity['lang'] . '.html'; + } elseif (@file_exists(dirname($plugin->pluginFile) . '/documentation_en.html')) { + $data['documentation_local'] = '/documentation_en.html'; + } elseif (@file_exists(dirname($plugin->pluginFile) . '/documentation.html')) { + $data['documentation_local'] = '/documentation.html'; + } elseif (@file_exists(dirname($plugin->pluginFile) . '/README')) { + $data['documentation_local'] = '/README'; + } - - - - - '; - } - ?> -
()
- ' . PLUGIN_DOCUMENTATION . ''; - } - - if (@file_exists(dirname($plugin->pluginFile) . '/ChangeLog')) { - echo '
' . PLUGIN_DOCUMENTATION_CHANGELOG . ''; - } - - if (@file_exists(dirname($plugin->pluginFile) . '/documentation_' . $serendipity['lang'] . '.html')) { - echo '
' . PLUGIN_DOCUMENTATION_LOCAL . ''; - } elseif (@file_exists(dirname($plugin->pluginFile) . '/documentation_en.html')) { - echo '
' . PLUGIN_DOCUMENTATION_LOCAL . ''; - } elseif (@file_exists(dirname($plugin->pluginFile) . '/documentation.html')) { - echo '
' . PLUGIN_DOCUMENTATION_LOCAL . ''; - } elseif (@file_exists(dirname($plugin->pluginFile) . '/README')) { - echo '
' . PLUGIN_DOCUMENTATION_LOCAL . ''; - } - ?> -
'.MEDIA_PROPERTY_COPYRIGHT.''.$license.'
-
- - -
- - -

- -

- -
- $e_name) { - echo ERROR . ': ' . $e_name . '
'; - } + $data['errorstack'] = $errorstack; if ($serendipity['GET']['only_group'] == 'UPGRADE') { serendipity_plugin_api::hook_event('backend_pluginlisting_header_upgrade', $pluggroups); } -?> - - $groupstack) { - if (empty($pluggroup)) { - ?> - - - - - - - - - - - - -' . PLUGIN_DOCUMENTATION . ''; - } - - if (!empty($plug['local_documentation'])) { - $pluginInfo[] = '' . PLUGIN_DOCUMENTATION_LOCAL . ''; - } - - if (!empty($plug['changelog'])) { - $pluginInfo[] = '' . PLUGIN_DOCUMENTATION_CHANGELOG . ''; - } - - if (!empty($plug['upgrade_version']) && $plug['upgrade_version'] != $plug['version']) { - $pluginInfo[] = sprintf(UPGRADE_TO_VERSION, $plug['upgrade_version']); - } - - if (!empty($plug['pluginlocation']) && $plug['pluginlocation'] != 'local') { - $pluginInfo[] = '(' . htmlspecialchars($plug['pluginlocation']) . ')'; - $installimage = serendipity_getTemplateFile('admin/img/install_now_' . strtolower($plug['pluginlocation']) . '.png'); - } else { - $installimage = serendipity_getTemplateFile('admin/img/install_now.png'); - } - - if (!isset($plug['customURI'])) { - $plug['customURI'] = ''; - } - if ( !empty($plug['requirements']['serendipity']) && version_compare($plug['requirements']['serendipity'], serendipity_getCoreVersion($serendipity['version']), '>') ) { - $notice['requirements_failures'][] = 's9y ' . $plug['requirements']['serendipity']; + $requirement_failures[$plug['class_name']] = array("s9y" => true); } if ( !empty($plug['requirements']['php']) && version_compare($plug['requirements']['php'], phpversion(), '>') ) { - $notice['requirements_failures'][] = 'PHP ' . $plug['requirements']['php']; + if (isset($requirement_failures[$plug['class_name']])) { + $requirement_failures[$plug['class_name']] = array_merge($requirement_failures[$plug['class_name']] , array("php" => true)); + } else { + $requirement_failures[$plug['class_name']] = array("php" => true); + } } - /* Enable after Smarty 2.6.7 upgrade. - * TODO: How can we get current Smarty version here? $smarty is not created! if ( !empty($plug['requirements']['smarty']) && version_compare($plug['requirements']['smarty'], '2.6.7', '>') ) { - $notice['requirements_failures'][] = 'Smarty: ' . $plug['requirements']['smarty']; + if (isset($requirement_failures[$plug['class_name']])) { + $requirement_failures[$plug['class_name']] = array_merge($requirement_failures[$plug['class_name']] , array("smarty" => true)); + } else { + $requirement_failures[$plug['class_name']] = array("smarty" => true); + } } - */ - - if (count($notice['requirements_failures']) > 0) { - $plug['requirements_fail'] = true; - } - -?> - - - - - - - -
-
- - - - - : - -
-
PluginAction
> - - - - - - - - - 0) { ?> - - - - -
- - - - <?php echo UPGRADE ?> - - <?php echo INSTALL ?> - - - -
()
-
- - + if (isset($_POST['SAVE'])) { + $data['save'] = true; + $data['timestamp'] = serendipity_strftime('%H:%M:%S'); + } - -
- - -
-'; - echo '
' . PREFERENCE_USE_JS_WARNING . '
'; + $data['eyecandy'] = true; } - serendipity_plugin_api::hook_event('backend_pluginlisting_header', $serendipity['eyecandy']); -?> -
+ serendipity_plugin_api::hook_event("backend_pluginlisting_header" ,$eyecandy); -

- - - + ob_start(); + serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity); + $data['backend_plugins_sidebar_header'] = ob_get_contents(); + ob_end_clean(); + ob_start(); + show_plugins(false, $sidebars); + $data['sidebar_plugins'] = ob_get_contents(); + ob_end_clean(); -
-
+ ob_start(); + $data['backend_plugins_event_header'] = ob_get_contents(); + ob_end_clean(); + ob_start(); + show_plugins(true); + $data['event_plugins'] = ob_get_contents(); + ob_end_clean(); -

- - - - - 0) { ?> -

Memory Usage

-
-
-
- - 0) { + $data['$memsnaps'] = $serendipity['memSnaps']; + } + } + +if (!is_object($serendipity['smarty'])) { + serendipity_smarty_init(); +} + +$serendipity['smarty']->assign($data); +$tfile = dirname(__FILE__) . "/tpl/plugins.inc.tpl"; +$content = $serendipity['smarty']->fetch('file:'. $tfile); +echo $content; /* vim: set sts=4 ts=4 expandtab : */ diff --git a/include/admin/tpl/plugins.inc.tpl b/include/admin/tpl/plugins.inc.tpl new file mode 100644 index 00000000..156fd06c --- /dev/null +++ b/include/admin/tpl/plugins.inc.tpl @@ -0,0 +1,210 @@ +{if $plugin_to_conf} + {if is_array($save_errors)} +
+ + {$CONST.ERROR}:
+ +
+ {elseif $saveconf} +
+ + {$CONST.DONE}: {{$CONST.SETTINGS_SAVED_AT}|sprintf:"{$timestamp}"} +
+ {/if} +
+ {$formToken} + + + + + + + + + + + {if !empty($license)} + + + + + {/if} +
{$CONST.NAME}{$name} ({$class})
{$CONST.DESCRIPTION} + {$desc} + {if ! empty($documentation) } +
{$CONST.PLUGIN_DOCUMENTATION} + {/if} + {if $changelog} +
{$CONST.PLUGIN_DOCUMENTATION_CHANGELOG} + {/if} + {if $documentation_local} +
{$CONST.PLUGIN_DOCUMENTATION_LOCAL} + {/if} +
{$CONST.MEDIA_PROPERTY_COPYRIGHT}{$license}
+
+ {$config} +
+ +{elseif $adminAction == "addnew"} + {if $type == "event"} +

{$CONST.EVENT_PLUGINS}

+ {else} +

{$CONST.SIDEBAR_PLUGINS}

+ {/if} +
+ {foreach $errorstack as $e_idx => $e_name} + {$CONST.ERROR}: {$e_name}
+ {/foreach} + + {foreach $pluggroups AS $pluggroup => $groupstack} + {if empty($pluggroup)} + + + + {if !empty($only_group)} + {continue} + {/if} + {elseif ! empty($only_group) && $pluggroup != $only_group} + {continue} + {else} + + + + {/if} + + + + + {foreach $groupstack as $plug} + + + + {/foreach} + {/foreach} + + + +
+
+ {$formToken} + + + + {$CONST.FILTERS} + + +
+
{$groupnames.{$available_group}}
PluginAction
+ + + + + + + + + + + +
{$plug.name} + {if isset($requirements_failures.{$plug.class_name})} + + {$CONST.UNMET_REQUIREMENTS|sprintf:"{if $requirements_failures.{$plug.class_name}.s9y}s9y $plug.requirements..serendipity,{/if} {if $requirements_failures.{$plug.class_name}.php}PHP $plug.requirements.php,{/if} {if $requirements_failures.{$plug.class_name}.smarty}Smarty $plug.requirements.smarty{/if}"} + + {elseif $plug['upgradable'] == true} + + {$CONST.UPGRADE} + + {elseif $plug.installable == true} + + {$CONST.INSTALL} + + {else} + {$CONST.ALREADY_INSTALLED} + {/if} +
{$plug.description}
({$plug.class_name}) + {if ! empty($plug.author)} + {$CONST.AUTHOR}: {$plug.author} + {/if} + + {if ! empty($plug.version)} + {$CONST.VERSION}: {$plug.version} + {/if} + + {if ! empty($plug.website)} + {$CONST.PLUGIN_DOCUMENTATION} + {/if} + + {if ! empty($plug.local_documentation)} + {$CONST.PLUGIN_DOCUMENTATION_LOCAL} + {/if} + + {if ! empty($plug.changelog)} + {$CONST.PLUGIN_DOCUMENTATION_CHANGELOG} + {/if} + + {if ! empty({$plug.upgrade_version}) && $plug.upgrade_version != $plug.version} + {$CONST.UPGRADE_TO_VERSION|sprintf:"{$plug.upgrade_version}"} + {/if} + + {if ! empty($plug.pluginlocation) && $plug.pluginlocation != 'local'} + ({$plug.pluginlocation|escape:"html"}) + {/if} + +
+
{$CONST.PLUGIN_AVAILABLE_COUNT|sprintf:"count({$pluginstack})"}
+{else} + {if $save} +
+ + {$CONST.DONE}:{$CONST.SETTINGS_SAVED_AT|sprintf:"$timestamp"}
+ {/if} +
{$CONST.BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS}
+ {if $eyecandy} + +
{$CONST.PREFERENCE_USE_JS_WARNING}
+ {/if} +
+ + +

{$CONST.SIDEBAR_PLUGINS}

+ + + {$CONST.CLICK_HERE_TO_INSTALL_PLUGIN|sprintf:"{$CONST.SIDEBAR_PLUGIN}"} + + {$backend_plugins_sidebar_header} + {$sidebar_plugins} +
+
+ +

{$CONST.EVENT_PLUGINS}

+ + + {{$CONST.CLICK_HERE_TO_INSTALL_PLUGIN}|sprintf:"{$CONST.EVENT_PLUGIN}"} + + {$backend_plugins_event_header} + {$event_plugins} + + {if $memsnaps} +

Memory Usage

+
+
{$memSnaps|print_r}
+
+ {/if} +{/if} + + + + + + \ No newline at end of file diff --git a/include/serendipity_smarty_class.inc.php b/include/serendipity_smarty_class.inc.php index 9c7608c1..70ab5311 100644 --- a/include/serendipity_smarty_class.inc.php +++ b/include/serendipity_smarty_class.inc.php @@ -10,7 +10,7 @@ class Serendipity_Smarty_Security_Policy extends Smarty_Security { // these are the allowed functions only. - default as is - public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time', 'nl2br', 'serendipity_categoryURL', 'serendipity_archiveURL'); + public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time', 'nl2br', 'serendipity_categoryURL', 'serendipity_archiveURL', 'serendipity_groupname'); // to disable all PHP functions #public $php_functions = null;