From 36358cc533d6cc697919fe31d2d14dc62c12a423 Mon Sep 17 00:00:00 2001 From: garvinhicking <garvinhicking> Date: Wed, 4 Oct 2006 08:16:42 +0000 Subject: [PATCH] Add new hooks --- docs/NEWS | 8 ++- include/admin/templates.inc.php | 88 +++++++++++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 6 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index cf41f79..031b02e 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,9 +3,15 @@ Version 1.1-beta4 () ------------------------------------------------------------------------ + * Added new plugin hooks: + backend_templates_configuration_top + backend_templates_configuration_bottom + backend_templates_configuration_none + for the theme configuration (garvinhicking) + * Allow to set $serendipity['CacheControl'] to make serendipity emit Cache-Control: HTTP headers. Thanks to annonymous from the forums! - + * Use seperate PHP session ID when using HTTPS login. Set 'secure' cookie parameters when using HTTPS. Thanks to lynoure! diff --git a/include/admin/templates.inc.php b/include/admin/templates.inc.php index a3c537e..80141a8 100644 --- a/include/admin/templates.inc.php +++ b/include/admin/templates.inc.php @@ -10,6 +10,39 @@ if (!serendipity_checkPermission('adminTemplates')) { return; } +class template_option { + var $config = null; + var $values = null; + var $keys = null; + + function introspect_config_item($item, &$bag) { + foreach($this->config[$item] AS $key => $val) { + $bag->add($key, $val); + } + } + + function get_config($item) { + return $this->values[$item]; + } + + function set_config($item, $value) { + global $serendipity; + serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options + WHERE okey = 't_" . serendipity_db_escape_string($serendipity['template']) . "' + AND name = '" . serendipity_db_escape_string($item) . "'"); + serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (okey, name, value) + VALUES ('t_" . serendipity_db_escape_string($serendipity['template']) . "', '" . serendipity_db_escape_string($item) . "', '" . serendipity_db_escape_string($value) . "')"); + return true; + } + + function import(&$config) { + foreach($config AS $key => $item) { + $this->config[$item['var']] = $item; + $this->keys[$item['var']] = $item['var']; + } + } +} + if ($serendipity['GET']['adminAction'] == 'install' ) { serendipity_plugin_api::hook_event('backend_templates_fetchtemplate', $serendipity); @@ -23,13 +56,58 @@ if ($serendipity['GET']['adminAction'] == 'install' ) { ?> <?php - if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] .'/layout.php') ) { - echo '<div class="serendipityAdminMsgNote">'. WARNING_TEMPLATE_DEPRECATED .'</div>'; +if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] .'/layout.php') ) { + echo '<div class="serendipityAdminMsgNote">'. WARNING_TEMPLATE_DEPRECATED .'</div>'; +} + +echo '<h3>' . STYLE_OPTIONS . '</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'; +} + +if (is_array($template_config)) { + serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config); + + if ($serendipity['POST']['adminAction'] == 'configure') { + foreach($serendipity['POST']['template'] AS $option => $value) { + template_option::set_config($option, $value); + } + echo '<div class="serendipityAdminMsgSuccess">' . DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } -?> + echo '<form method="post" action="serendipity_admin.php">'; + echo '<input type="hidden" name="serendipity[adminModule]" value="templates" />'; + echo '<input type="hidden" name="serendipity[adminAction]" value="configure" />'; + + include S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; + $template_vars =& serendipity_loadThemeOptions($template_config); + + $template_options = new template_option(); + $template_options->import($template_config); + $template_options->values =& $template_vars; + + serendipity_plugin_config( + $template_options, + $template_vars, + $serendipity['template'], + $serendipity['template'], + $template_options->keys, + true, + true, + true, + true, + 'template' + ); + echo '</form><br />'; + serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); +} else { + echo '<p>' . STYLE_OPTIONS_NONE . '</p>'; + serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config); +} -<?php echo SELECT_TEMPLATE; ?> +echo '<h3>' . SELECT_TEMPLATE . '</h3>'; +?> <br /><br /> <?php $i = 0; @@ -95,7 +173,7 @@ if ($serendipity['GET']['adminAction'] == 'install' ) { <td valign="top"> <?php echo AUTHOR; ?>: <?php echo $info['author'];?><br /> <?php echo LAST_UPDATED; ?>: <?php echo $info['date']; ?><br /> - <?php echo CUSTOM_ADMIN_INTERFACE; ?>: <?php echo (isset($info['custom_admin_interface']) ? $info['custom_admin_interface'] : NO); ?><br /> + <?php echo CUSTOM_ADMIN_INTERFACE; ?>: <?php echo $info['custom_admin_interface']; ?><br /> </td> </tr> </table> -- 2.39.5