template and plugin option groups, experimental

This commit is contained in:
Garvin Hicking 2011-01-03 09:11:17 +00:00
parent ec75a0d14e
commit a1603ec936
9 changed files with 121 additions and 21 deletions

View File

@ -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

View File

@ -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'])) {
</table>
<br />
<?php serendipity_plugin_config($plugin, $bag, $name, $desc, $config_names); ?>
<?php serendipity_plugin_config($plugin, $bag, $name, $desc, $config_names, true, true, true, true, 'plugin', $config_groups); ?>
</form>
<?php

View File

@ -69,7 +69,7 @@ if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath']
echo '<div class="serendipityAdminMsgNote"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="" />'. WARNING_TEMPLATE_DEPRECATED .'</div>';
}
echo '<h3>' . STYLE_OPTIONS . '</h3>';
echo '<h3>' . STYLE_OPTIONS . ' (' . $serendipity['template'] . ')</h3>';
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 '</form><br />';
serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config);

View File

@ -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) {
?>
<script type="text/javascript" language="JavaScript">
function showConfig(id) {
@ -505,8 +491,26 @@ function showConfigAll(count) {
}
}
</script>
<?php
}
/**
* 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) {
serendipity_printConfigJS($folded);
}
if (!$noForm) {

View File

@ -355,9 +355,10 @@ function placement_box($name, $val, $is_plugin_editable = false, $is_event = fal
* @param boolean Shows a plugin's "example" method output?
* @param boolean Spawn a plugins' configuration WYSIWYG items?
* @param string The array index name of POSTed values ($serendipity['POST'][xxx])
* @param array An array that groups certain config keys
* @return boolean
*/
function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_names, $showTable = true, $showSubmit = true, $showExample = true, $spawnNuggets = true, $postKey = 'plugin') {
function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_names, $showTable = true, $showSubmit = true, $showExample = true, $spawnNuggets = true, $postKey = 'plugin', $config_groups = NULL) {
global $serendipity;
if (empty($config_names)) {
@ -380,6 +381,9 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
$elcount = 0;
$htmlnugget = array();
$out_stack = array();
foreach ($config_names as $config_item) {
$elcount++;
$cbag = new serendipity_property_bag;
@ -424,6 +428,8 @@ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_nam
$is_multi_select = false;
$ctype = $cbag->get('type');
ob_start();
switch ($ctype) {
case 'seperator':
?>
@ -909,8 +915,60 @@ 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;
?>
<tr>
<td colspan="2">
<div align="right">
<a style="border:0; text-decoration: none" href="#" onClick="showConfigAll(<?php echo sizeof($config_groups); ?>)" title="<?php echo TOGGLE_ALL; ?>"><img src="<?php echo serendipity_getTemplateFile('img/'. ($folded === true ? 'plus' : 'minus') .'.png') ?>" id="optionall" alt="+/-" border="0" />&nbsp;<?php echo TOGGLE_ALL; ?></a></a><br />
</div>
</td>
</tr>
<?php
foreach($config_groups AS $config_header => $config_groupkeys) {
$hid++;
echo '<tr>';
echo '<td colspan="2">';
echo '<h2>';
echo '<a style="border:0; text-decoration: none;" href="#" onClick="showConfig(\'el' . $hid . '\'); return false" title="' . TOGGLE_OPTION . '"><img src="' . serendipity_getTemplateFile('img/'. ($folded === true ? 'plus' : 'minus') .'.png') . '" id="optionel' . $hid . '" alt="+/-" border="0" />&nbsp;';
echo $config_header;
echo '</a>';
echo '</h2>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan="2">';
echo '<table class="plugin_optiongroup" id="el' . $hid . '" border="0" cellspacing="0" cellpadding="3" width="100%">';
foreach($config_groupkeys AS $config_groupkey) {
echo $out_stack[$config_groupkey];
echo "\n";
unset($out_stack[$config_groupkey]);
}
echo '</table>';
echo '<script type="text/javascript" language="JavaScript">';
echo 'document.getElementById("el' . $hid . '").style.display = "none";' . "\n";
echo '</script>';
echo '</td>';
echo '</tr>';
}
echo '<tr><td colspan="2" style="height: 100px" id="configuration_footer">&nbsp;</td></tr>';
}
echo implode("\n", $out_stack);
if ($showTable) {
?>
</table>
@ -918,6 +976,8 @@ EOS;
<?php
}
serendipity_printConfigJS();
if ($showSubmit) {
?>
<div style="padding-left: 20px">

View File

@ -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'];

View File

@ -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',

View File

@ -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',

View File

@ -1,6 +1,8 @@
<?php
// Colorsets
@define('THEME_COLORSET', 'Colorset');
@define('THEME_HEADER', 'Header');
@define('USER_STYLESHEET','Use additional user stylesheet. Users have to create this stylesheet in the template directory. It has to be named user.css and can be used to override selected styles.');
// Layout
@define('LAYOUT_TYPE','Blog layout (B = Blog entriee, S = Sidebar, CF = Content first)');