From a1603ec936a793e06083b067cbc428abe1810a2a Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Mon, 3 Jan 2011 09:11:17 +0000 Subject: [PATCH] template and plugin option groups, experimental --- docs/NEWS | 6 ++ include/admin/plugins.inc.php | 3 +- include/admin/templates.inc.php | 5 +- include/functions_installer.inc.php | 36 ++++++----- include/functions_plugins_admin.inc.php | 62 ++++++++++++++++++- include/functions_smarty.inc.php | 2 +- .../serendipity_event_spamblock.php | 21 +++++++ templates/bulletproof/config.inc.php | 5 ++ templates/bulletproof/lang_en.inc.php | 2 + 9 files changed, 121 insertions(+), 21 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 8e592776..5a99fc20 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,12 @@ Version 1.6 () ------------------------------------------------------------------------ + * Experimental: Config-Groups for template and plugin options, + currently mimics fold in/out of global configuration. + Usage through "config_groups", examples are in config.inc.php of + bulletproof and spamblock plugin. Needs documentation. + (garvinhicking) + * Added new parameter "empty" to {serendipity_showPlugin}. When no callable plugins were found, the string in the "empty" parameter will be shown instead, allowing users to get notified of a missing diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index df618255..2273cd4a 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -78,6 +78,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) { $documentation = $bag->get('website'); $config_names = $bag->get('configuration'); + $config_groups = $bag->get('config_groups'); if (isset($_POST['SAVECONF']) && serendipity_checkFormToken()) { /* enum properties and set their values */ @@ -178,7 +179,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
- + '. WARNING_TEMPLATE_DEPRECATED .''; } -echo '

' . STYLE_OPTIONS . '

'; +echo '

' . STYLE_OPTIONS . ' (' . $serendipity['template'] . ')

'; if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) { serendipity_smarty_init(); include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php'; @@ -110,7 +110,8 @@ if (is_array($template_config)) { true, true, true, - 'template' + 'template', + $template_config_groups ); echo '
'; serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); diff --git a/include/functions_installer.inc.php b/include/functions_installer.inc.php index d9f21ad6..8c78fae0 100644 --- a/include/functions_installer.inc.php +++ b/include/functions_installer.inc.php @@ -457,21 +457,7 @@ function serendipity_guessInput($type, $name, $value='', $default='') { } } -/** - * Parses the configuration array and displays the configuration screen - * - * @access public - * @param array Configuration superarray - * @param array The previous values submitted by the user - * @param boolean If true, no HTML FORM container will be emitted - * @param boolean If true, the configuration sections will all be folded - * @param boolean If true, the user can turn config sections on and off - * @param boolean If true, the user can NOT display possibly dangerous options - * @return null - */ -function serendipity_printConfigTemplate($config, $from = false, $noForm = false, $folded = true, $allowToggle = true, $showDangerous = false) { - global $serendipity; - if ( $allowToggle ) { +function serendipity_printConfigJS($folded = true) { ?> - get('type'); + + ob_start(); switch ($ctype) { case 'seperator': ?> @@ -909,7 +915,59 @@ EOS; serendipity_plugin_api::hook_event('backend_pluginconfig_' . $ctype, $eventData, $addData); break; } + + $out_stack[$config_item] = ob_get_contents(); + ob_end_clean(); } + + if (is_array($config_groups)) { + $hid = 0; + $folded = true; +?> + + +
+ +/- 
+
+ + + $config_groupkeys) { + $hid++; + echo ''; + echo ''; + + echo '

'; + echo '+/- '; + echo $config_header; + echo ''; + echo '

'; + echo ''; + echo ''; + + echo ''; + echo ''; + echo ''; + + foreach($config_groupkeys AS $config_groupkey) { + echo $out_stack[$config_groupkey]; + echo "\n"; + unset($out_stack[$config_groupkey]); + } + echo '
'; + + echo ''; + + echo ''; + echo ''; + } + + echo ' '; + } + + echo implode("\n", $out_stack); if ($showTable) { ?> @@ -918,6 +976,8 @@ EOS;
diff --git a/include/functions_smarty.inc.php b/include/functions_smarty.inc.php index 8d1f87ff..01721c80 100644 --- a/include/functions_smarty.inc.php +++ b/include/functions_smarty.inc.php @@ -859,7 +859,7 @@ function &serendipity_replaceSmartyVars($tpl_source, &$smarty) { * @return null */ function serendipity_smarty_init($vars = array()) { - global $serendipity, $template_config, $template_global_config; + global $serendipity, $template_config, $template_global_config, $template_config_groups; if (!isset($serendipity['smarty'])) { $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template']; diff --git a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php index 88eb90cd..69850b00 100644 --- a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php +++ b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php @@ -73,6 +73,27 @@ var $filter_defaults; 'logtype', 'logfile')); $propbag->add('groups', array('ANTISPAM')); + $propbag->add('config_groups', array( + 'Content Filter' => array( + 'contentfilter_activate', + 'contentfilter_urls', + 'contentfilter_authors', + 'contentfilter_words', + 'contentfilter_emails', + 'bloggdeblacklist', + 'akismet', + 'akismet_server', + 'akismet_filter', + ), + 'Trackbacks' => array( + 'trackback_ipvalidation' , + 'trackback_ipvalidation_url_exclude' , + 'forcemoderationt', + 'forcemoderationt_treat', + 'disable_api_comments', + 'trackback_check_url', + ) + )); $this->filter_defaults = array( 'authors' => 'casino;phentermine;credit;loans;poker', diff --git a/templates/bulletproof/config.inc.php b/templates/bulletproof/config.inc.php index b4378986..37b67e34 100644 --- a/templates/bulletproof/config.inc.php +++ b/templates/bulletproof/config.inc.php @@ -36,6 +36,11 @@ if ($serendipity['GET']['adminModule'] == 'templates') { } } +$template_config_groups = array( + THEME_COLORSET => array('colorset', 'userstylesheet', 'layouttype', 'jscolumns'), + THEME_HEADER => array('custheader', 'headerimage', 'headertype') +); + $template_config = array( array( 'var' => 'colorset', diff --git a/templates/bulletproof/lang_en.inc.php b/templates/bulletproof/lang_en.inc.php index 31f39b10..eac5319e 100644 --- a/templates/bulletproof/lang_en.inc.php +++ b/templates/bulletproof/lang_en.inc.php @@ -1,6 +1,8 @@