]> git.mjollnir.org Git - s9y.git/commitdiff
Add new hooks
authorgarvinhicking <garvinhicking>
Wed, 4 Oct 2006 08:16:42 +0000 (08:16 +0000)
committergarvinhicking <garvinhicking>
Wed, 4 Oct 2006 08:16:42 +0000 (08:16 +0000)
docs/NEWS
include/admin/templates.inc.php

index cf41f79587e7fa26e5adc5e6931e08eee1ff76f6..031b02ee3ef34c64bb6ecef47600d9604b4bc835 100644 (file)
--- 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!
 
index a3c537e9ef1dff1f7d3bb2511ba75755a96c6f3a..80141a831bb2d09b118c9786247906e58afdc532 100644 (file)
@@ -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>