Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_templatechooser
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23061/plugins/serendipity_event_templatechooser
Added Files:
serendipity_event_templatechooser.php
Log Message:
Bundled plugins, Template chooser
--- NEW FILE: serendipity_event_templatechooser.php ---
<?php # $Id: serendipity_event_templatechooser.php,v 1.1 2004/03/03 08:18:00 garvinhicking Exp $
switch ($serendipity['lang']) {
case 'de':
@define('PLUGIN_EVENT_TEMPLATECHOOSER_NAME', 'Templateauswahl');
@define('PLUGIN_EVENT_TEMPLATECHOOSER_DESC', 'Ermöglicht Besuchern das Template zu ändern');
break;
case 'en':
default:
@define('PLUGIN_EVENT_TEMPLATECHOOSER_NAME', 'Template chooser');
@define('PLUGIN_EVENT_TEMPLATECHOOSER_DESC', 'Allows users to change the template');
break;
}
class serendipity_event_templatechooser extends serendipity_event
{
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_TEMPLATECHOOSER_NAME);
$propbag->add('description', PLUGIN_EVENT_TEMPLATECHOOSER_DESC);
$propbag->add('event_hooks', array('frontend_configure' => true));
// Register (multiple) dependencies. KEY is the name of the depending plugin. VALUE is a mode of either 'remove' or 'keep'.
// If the mode 'remove' is set, removing the plugin results in a removal of the depending plugin. 'Keep' meens to
// not touch the depending plugin.
$this->dependencies = array('serendipity_plugin_templatedropdown' => 'remove');
}
function generate_content(&$title) {
$title = PLUGIN_EVENT_TEMPLATECHOOSER_NAME;
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_configure':
if (isset($_REQUEST['user_template']) && (in_array($_REQUEST['user_template'], serendipity_fetchTemplates())) ) {
$_SESSION['serendipityUseTemplate'] = $_REQUEST['user_template'];
}
if (isset($_SESSION['serendipityUseTemplate']) ) {
$eventData['CONFIG']['template'] = $_SESSION['serendipityUseTemplate'];
}
return true;
break;
default:
return false;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
|