From: garvinhicking Date: Wed, 4 Oct 2006 08:16:42 +0000 (+0000) Subject: Add new hooks X-Git-Tag: 1.1~85 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=36358cc533d6cc697919fe31d2d14dc62c12a423;p=s9y.git Add new hooks --- 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' ) { ?> '. WARNING_TEMPLATE_DEPRECATED .''; +if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] .'/layout.php') ) { + echo '
'. WARNING_TEMPLATE_DEPRECATED .'
'; +} + +echo '

' . STYLE_OPTIONS . '

'; +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 '
' . DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '
'; } -?> + echo '
'; + echo ''; + echo ''; + + 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 '

'; + serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); +} else { + echo '

' . STYLE_OPTIONS_NONE . '

'; + serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config); +} - +echo '

' . SELECT_TEMPLATE . '

'; +?>

:
:
- :
+ :