New 'sidebar' template configuration option. EXPERIMENTAL

This commit is contained in:
Garvin Hicking 2006-08-27 20:44:55 +00:00
parent 45c6d01eeb
commit a6c89547c9
3 changed files with 98 additions and 38 deletions

View File

@ -3,6 +3,24 @@
Version 1.1-beta4 ()
------------------------------------------------------------------------
* Added possibility for templates to define the sidebars they use.
The template specifies this via the $template_config array in
the config.inc.php file of a template. It looks like this:
$template_config = array(
array(
'var' => 'sidebars',
'title' => 'Sidebars',
'type' => 'string',
'default' => 'left,hide,right'
)
);
Note some things: Seperate the sidebar keys with a "," only -
do not use spaces. Also never use more than 6 characters for
the descriptors.
If you do not want to make it configurable, you can also use
the $serendipity['sidebars'] array to define the sidebars
that are available.
* Made category-recursion show orphaned categories because of
permission restrictions (garvinhicking)

View File

@ -351,16 +351,33 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
} else {
/* show general plugin list */
/* preparse Javascript-generated input */
if (isset($_POST['SAVE']) && !empty($_POST['serendipity']['pluginorder'])) {
$parts = explode(':', $_POST['serendipity']['pluginorder']);
/* get sidebar locations */
serendipity_smarty_init();
if (is_array($template_config)) {
$template_vars =& serendipity_loadThemeOptions($template_config);
}
$col_assoc = array(
'left_col' => 'left',
'right_col' => 'right',
'hide_col' => 'hide',
'event_col' => 'event',
'eventh_col' => 'eventh'
);
if (isset($template_vars['sidebars'])) {
$sidebars = explode(',', $template_vars['sidebars']);
} elseif (isset($serendipity['sidebars'])) {
$sidebars = $serendipity['sidebars'];
} else {
$sidebars = array('left', 'hide', 'right');
}
foreach($sidebars AS $sidebar) {
$col_assoc[$sidebar . '_col'] = $sidebar;
}
/* preparse Javascript-generated input */
if (isset($_POST['SAVE']) && !empty($_POST['serendipity']['pluginorder'])) {
$parts = explode(':', $_POST['serendipity']['pluginorder']);
foreach($parts AS $sidepart) {
preg_match('@^(.+)\((.*)\)$@imsU', $sidepart, $matches);
if (!isset($col_assoc[$matches[1]])) {
@ -466,7 +483,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
<h3><?php echo SIDEBAR_PLUGINS ?></h3>
<a href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/install.png') ?>" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" /><?php echo sprintf(CLICK_HERE_TO_INSTALL_PLUGIN, SIDEBAR_PLUGIN) ?></a>
<?php serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity); ?>
<?php show_plugins(false); ?>
<?php show_plugins(false, $sidebars); ?>
<br />
<br />

View File

@ -49,23 +49,46 @@ function serendipity_pluginListSort($x, $y) {
* @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown
* @return null
*/
function show_plugins($event_only = false)
function show_plugins($event_only = false, $sidebars = null)
{
static $opts = array(
'left' => LEFT,
'right' => RIGHT,
'hide' => HIDDEN,
'event' => PLUGIN_ACTIVE,
'eventh' => PLUGIN_INACTIVE
);
global $serendipity;
if (is_array($sidebars)) {
foreach($sidebars AS $sidebar) {
$up = strtoupper($sidebar);
if ($sidebar == 'hide') {
$opts[$sidebar] = HIDDEN;
} elseif (defined('SIDEBAR_' . $up)) {
$opts[$sidebar] = constant('SIDEBAR_' . $up);
} elseif (defined($up)) {
$opts[$sidebar] = constant($up);
} else {
$opts[$sidebar] = $up;
}
}
}
$eyecandy = !isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy']);
if (!$eyecandy) {
echo ' <form action="?serendipity[adminModule]=plugins" method="post">';
} elseif (!$event_only) {
echo '<script type="text/javascript">addLoadEvent(pluginMoverInit);</script>';
echo '<script type="text/javascript"> function templatePluginMoverInit() { ';
$is_first = true;
foreach($sidebars AS $sidebar) {
?>
<?php echo ($is_first ? 'var ' : ''); ?> list = document.getElementById("<?php echo $sidebar; ?>_col");
DragDrop.makeListContainer(list, 'g1');
list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
list.onDragOut = function() { this.style["border"] = "none"; };
<?php
$is_first = false;
}
echo ' } addLoadEvent(templatePluginMoverInit);</script>';
echo ' <form action="?serendipity[adminModule]=plugins" method="post" onsubmit="pluginMovergetSort(); return true">';
echo ' <input type="hidden" name="serendipity[pluginorder]" id="order" value="" />';
@ -86,7 +109,7 @@ function show_plugins($event_only = false)
if ($event_only) {
$plugin_placements = array('event', 'eventh');
} else {
$plugin_placements = array('left', 'hide', 'right');
$plugin_placements = $sidebars;
}
$total = 0;
@ -133,10 +156,10 @@ function show_plugins($event_only = false)
}
if ($event_only) {
$place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, true);
$place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, true, $opts);
$event_only_uri = '&amp;serendipity[event_plugin]=true';
} else {
$place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable);
$place = placement_box('serendipity[placement][' . $plugin_data['name'] . ']', $plugin_data['placement'], $is_plugin_editable, false, $opts);
$event_only_uri = '';
}
@ -257,13 +280,15 @@ function ownership($authorid, $name, $is_plugin_owner = false) {
* @param boolean Toggle whether a plugin is an event plugin
* @return string HTML code for placement select box
*/
function placement_box($name, $val, $is_plugin_editable = false, $is_event = false)
function placement_box($name, $val, $is_plugin_editable = false, $is_event = false, $opts = null)
{
static $opts = array(
if ($opts === null) {
$opts = array(
'left' => LEFT,
'right' => RIGHT,
'hide' => HIDDEN
);
}
static $event_opts = array(
'event' => PLUGIN_ACTIVE,
@ -273,7 +298,7 @@ function placement_box($name, $val, $is_plugin_editable = false, $is_event = fal
if ($is_event) {
$gopts =& $event_opts;
} else {
$gopts = &$opts;
$gopts =& $opts;
}
$x = "\n<select name=\"$name\">\n";