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,11 +3,29 @@
Version 1.1-beta4 () 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 * Made category-recursion show orphaned categories because of
permission restrictions (garvinhicking) permission restrictions (garvinhicking)
* Fix some markup functions in textile plugin (Matthias Leisi) * Fix some markup functions in textile plugin (Matthias Leisi)
* Add Smarty function to show commentform (garvinhicking) * Add Smarty function to show commentform (garvinhicking)
* Group management now allows to disallow certain plugins or even * Group management now allows to disallow certain plugins or even
@ -26,15 +44,15 @@ Version 1.1-beta3 ()
* Fix a bug in the HTTP 304 Conditional GET RSS-Feed caching when * Fix a bug in the HTTP 304 Conditional GET RSS-Feed caching when
the server timezone offset was not set to zero. Thanks to dand! the server timezone offset was not set to zero. Thanks to dand!
* Added ability to use HTTP Authentication to the blog. Can be * Added ability to use HTTP Authentication to the blog. Can be
triggered by submitting HTTP Auth credentials [only supported when triggered by submitting HTTP Auth credentials [only supported when
the server runs with mod_php, not as CGI]. Authentication can be the server runs with mod_php, not as CGI]. Authentication can be
forced URLs with the "?http_auth=true" parameter, which forced URLs with the "?http_auth=true" parameter, which
will then send a "401 Unauthorized" header. will then send a "401 Unauthorized" header.
If your server does not support mod_php, you can submit REQUEST If your server does not support mod_php, you can submit REQUEST
variables: ?http_auth_user=XXX&http_auth_pw=YYY. variables: ?http_auth_user=XXX&http_auth_pw=YYY.
Note that specifying username and password in the URI will lead Note that specifying username and password in the URI will lead
to password disclosure in HTTP logfiles. to password disclosure in HTTP logfiles.
This feature is most importantly meant for RSS-feeds, to make This feature is most importantly meant for RSS-feeds, to make
RSS readers able to submit login credentials. (garvinhicking) RSS readers able to submit login credentials. (garvinhicking)
@ -55,7 +73,7 @@ Version 1.1-beta1 (August 14th, 2006)
by authors. New permalink structure: by authors. New permalink structure:
"/comments/[AUTHORNAME]/comments|trackbacks|comments_and_trackbacks/P[PAGENUMBER]/FROM [YYYY-MM-DD]/TO [YYYY-MM-DD]" "/comments/[AUTHORNAME]/comments|trackbacks|comments_and_trackbacks/P[PAGENUMBER]/FROM [YYYY-MM-DD]/TO [YYYY-MM-DD]"
Instead of /FROM and /TO you can also use /F and /T. Instead of /FROM and /TO you can also use /F and /T.
Instead of /FROM and /TO you can also specify /last_X, where X Instead of /FROM and /TO you can also specify /last_X, where X
is the amount of past days to show comments for. is the amount of past days to show comments for.
(garvinhicking) (garvinhicking)
@ -91,7 +109,7 @@ Version 1.1-beta1 (August 14th, 2006)
Bottom line: Plugins that use "*plugin*.tpl" filenames or check Bottom line: Plugins that use "*plugin*.tpl" filenames or check
via file_exists() on the returned variable are safe. via file_exists() on the returned variable are safe.
(garvinhicking) (garvinhicking)
* Added arabic (sa) language by Way * Added arabic (sa) language by Way
* Add patch to allow entryproperties plugin to define passwords for * Add patch to allow entryproperties plugin to define passwords for
@ -123,14 +141,14 @@ Version 1.1-beta1 (August 14th, 2006)
* Added experimental PHP-engine templating support, bypassing * Added experimental PHP-engine templating support, bypassing
Smarty. Work in progress, mostly proof-of-concept. Might Smarty. Work in progress, mostly proof-of-concept. Might
be changed completely. Read instructions in the be changed completely. Read instructions in the
include/template_api.inc.php file. Dedicated to Davey. ;) include/template_api.inc.php file. Dedicated to Davey. ;)
(garvinhicking) (garvinhicking)
* Support to crop images from within the media database. Pick a * Support to crop images from within the media database. Pick a
picture in the MDB, go to the property section of that image picture in the MDB, go to the property section of that image
and click on the "EDIT" link. (garvinhicking) and click on the "EDIT" link. (garvinhicking)
TODO: TODO:
- Operate also on PNG, TIFF etc. (currently only JPEG!) - Operate also on PNG, TIFF etc. (currently only JPEG!)
- Support image magick (currently ony gdlib!) - Support image magick (currently ony gdlib!)
@ -139,14 +157,14 @@ Version 1.1-beta1 (August 14th, 2006)
- Add options to only affect the images thumbnail instead - Add options to only affect the images thumbnail instead
of always saving the whole picture. of always saving the whole picture.
- Internationalization! - Internationalization!
* Move the DB charset option to serendipity_config_local.inc.php to * Move the DB charset option to serendipity_config_local.inc.php to
issue propper DB connections instantly. (garvinhicking) issue propper DB connections instantly. (garvinhicking)
Version 1.1-alpha6() Version 1.1-alpha6()
------------------------------------------------------------------------ ------------------------------------------------------------------------
* Use possibly existing local PEAR by default. Patch by Davey * Use possibly existing local PEAR by default. Patch by Davey
(garvinhicking) (garvinhicking)
* Add missing indices for the statistics visitor DB tables * Add missing indices for the statistics visitor DB tables
@ -160,7 +178,7 @@ Version 1.1-alpha6()
* Fix bug #1494653: Non-Unique index constraint for 'exits' table. * Fix bug #1494653: Non-Unique index constraint for 'exits' table.
Thanks to Markus Brueckner! (garvinhicking) Thanks to Markus Brueckner! (garvinhicking)
Version 1.1-alpha5() Version 1.1-alpha5()
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -294,7 +312,7 @@ Version 1.0.1 ()
* Fix multi-authors view only showing first author (garvinhicking) * Fix multi-authors view only showing first author (garvinhicking)
* Fix bug sending comment-notification mails to subscribed users * Fix bug sending comment-notification mails to subscribed users
without an email address (garvinhicking) without an email address (garvinhicking)
* Fixed icelandic language bug preventing upgrade (garvinhicking) * Fixed icelandic language bug preventing upgrade (garvinhicking)
@ -305,7 +323,7 @@ Version 1.0 (June 15th, 2006)
* Insert logic for saving an entry that prevents the iframe for * Insert logic for saving an entry that prevents the iframe for
trackbacks/xml-rpc pings to save an entry multiple times upon trackbacks/xml-rpc pings to save an entry multiple times upon
failure. Many thanks to tharos from the Forums! (garvinhicking) failure. Many thanks to tharos from the Forums! (garvinhicking)
* Add smarty parameter $view which can be used to detect what kind * Add smarty parameter $view which can be used to detect what kind
of page is being displayed. One of: archives, entry, feed, admin, of page is being displayed. One of: archives, entry, feed, admin,
archives, plugin, categories, authors, search, css, start, 404 archives, plugin, categories, authors, search, css, start, 404

View File

@ -351,16 +351,33 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
} else { } else {
/* show general plugin list */ /* show general plugin list */
/* get sidebar locations */
serendipity_smarty_init();
if (is_array($template_config)) {
$template_vars =& serendipity_loadThemeOptions($template_config);
}
$col_assoc = array(
'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 */ /* preparse Javascript-generated input */
if (isset($_POST['SAVE']) && !empty($_POST['serendipity']['pluginorder'])) { if (isset($_POST['SAVE']) && !empty($_POST['serendipity']['pluginorder'])) {
$parts = explode(':', $_POST['serendipity']['pluginorder']); $parts = explode(':', $_POST['serendipity']['pluginorder']);
$col_assoc = array(
'left_col' => 'left',
'right_col' => 'right',
'hide_col' => 'hide',
'event_col' => 'event',
'eventh_col' => 'eventh'
);
foreach($parts AS $sidepart) { foreach($parts AS $sidepart) {
preg_match('@^(.+)\((.*)\)$@imsU', $sidepart, $matches); preg_match('@^(.+)\((.*)\)$@imsU', $sidepart, $matches);
if (!isset($col_assoc[$matches[1]])) { if (!isset($col_assoc[$matches[1]])) {
@ -375,7 +392,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
} }
$serendipity['POST']['placement'][$pluginname] = $col_assoc[$matches[1]]; $serendipity['POST']['placement'][$pluginname] = $col_assoc[$matches[1]];
$new_order[] = $pluginname; $new_order[] = $pluginname;
} }
} }
@ -466,7 +483,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
<h3><?php echo SIDEBAR_PLUGINS ?></h3> <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> <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 serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity); ?>
<?php show_plugins(false); ?> <?php show_plugins(false, $sidebars); ?>
<br /> <br />
<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 * @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown
* @return null * @return null
*/ */
function show_plugins($event_only = false) function show_plugins($event_only = false, $sidebars = null)
{ {
static $opts = array( static $opts = array(
'left' => LEFT,
'right' => RIGHT,
'hide' => HIDDEN,
'event' => PLUGIN_ACTIVE, 'event' => PLUGIN_ACTIVE,
'eventh' => PLUGIN_INACTIVE 'eventh' => PLUGIN_INACTIVE
); );
global $serendipity; 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']); $eyecandy = !isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy']);
if (!$eyecandy) { if (!$eyecandy) {
echo ' <form action="?serendipity[adminModule]=plugins" method="post">'; echo ' <form action="?serendipity[adminModule]=plugins" method="post">';
} elseif (!$event_only) { } 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 ' <form action="?serendipity[adminModule]=plugins" method="post" onsubmit="pluginMovergetSort(); return true">';
echo ' <input type="hidden" name="serendipity[pluginorder]" id="order" value="" />'; echo ' <input type="hidden" name="serendipity[pluginorder]" id="order" value="" />';
@ -86,7 +109,7 @@ function show_plugins($event_only = false)
if ($event_only) { if ($event_only) {
$plugin_placements = array('event', 'eventh'); $plugin_placements = array('event', 'eventh');
} else { } else {
$plugin_placements = array('left', 'hide', 'right'); $plugin_placements = $sidebars;
} }
$total = 0; $total = 0;
@ -133,10 +156,10 @@ function show_plugins($event_only = false)
} }
if ($event_only) { 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'; $event_only_uri = '&amp;serendipity[event_plugin]=true';
} else { } 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 = ''; $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 * @param boolean Toggle whether a plugin is an event plugin
* @return string HTML code for placement select box * @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) {
'left' => LEFT, $opts = array(
'right' => RIGHT, 'left' => LEFT,
'hide' => HIDDEN 'right' => RIGHT,
); 'hide' => HIDDEN
);
}
static $event_opts = array( static $event_opts = array(
'event' => PLUGIN_ACTIVE, 'event' => PLUGIN_ACTIVE,
@ -273,7 +298,7 @@ function placement_box($name, $val, $is_plugin_editable = false, $is_event = fal
if ($is_event) { if ($is_event) {
$gopts =& $event_opts; $gopts =& $event_opts;
} else { } else {
$gopts = &$opts; $gopts =& $opts;
} }
$x = "\n<select name=\"$name\">\n"; $x = "\n<select name=\"$name\">\n";