From: garvinhicking Date: Tue, 20 Jun 2006 07:44:43 +0000 (+0000) Subject: Add experimental XML engine support X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9b4d3d51ae5e3a13b7460fb1ec0189929c5fd1d7;p=s9y.git Add experimental XML engine support --- diff --git a/docs/NEWS b/docs/NEWS index 5182ff6..8d23c07 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.1-alpha7() ------------------------------------------------------------------------ + * Added experimental XML-engine, for XSLT templating support + (garvinhicking) + * Added experimental PHP-engine templating support, bypassing Smarty. Work in progress, mostly proof-of-concept. Might be changed completely. Read instructions in the diff --git a/include/plugin_internal.inc.php b/include/plugin_internal.inc.php index 79fbf19..aaa2b5e 100644 --- a/include/plugin_internal.inc.php +++ b/include/plugin_internal.inc.php @@ -1410,6 +1410,9 @@ class serendipity_categories_plugin extends serendipity_plugin { $is_form = serendipity_db_bool($this->get_config('allow_select')); if ($which_category === "login") { $which_category = (int)$serendipity['authorid']; + if ($which_category === 0) { + $which_category = -1; // Set to -1 for anonymous authors to get a proper match. + } } $categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category, '', $sort); diff --git a/include/template_api.inc.php b/include/template_api.inc.php index 50ab843..f9983b5 100644 --- a/include/template_api.inc.php +++ b/include/template_api.inc.php @@ -175,3 +175,87 @@ class serendipity_smarty_emulator { } } +/* + *@author Garvin Hicking + *@state EXPERIMENTAL + * + * XML Engine + */ + +class serendipity_smarty_emulator_xml extends serendipity_smarty_emulator { + /** + * Parses a template file into another. + * + * @access public + * @return null + */ + function fetch() { + return true; + } + + /** + * Outputs a smarty template. + * + * @access public + * @return null + */ + function display() { + echo "\n"; + return true; + } + + function __construct() { + header('Content-Type: text/xml; charset=' . LANG_CHARSET); + echo '' . "\n"; + /* + echo '' . "\n"; + */ + echo "\n"; + ob_end_flush(); // This ends the started ob from index.php! + } + + function serendipity_smarty_emulator_xml() { + $this->__construct(); + } + + /** + * Assign one or multiple template variable + * @TODO: Why can't this function accept references. This sucks. + * + * @param mixed Either a variable name, or an array of variables + * @param mixed Either null or the variable content. + * @access public + * @return null + */ + function assign($tpl_var, $value = null, $level = 0) { + if (is_array($tpl_var)) { + foreach ($tpl_var as $key => $val) { + if ($key != '') { + $this->createXML($level, $key, $val); + } + } + } else { + $this->createXML($level, $tpl_var, $value); + } + + return true; + } + + function createXML(&$level, &$key, &$val) { + if (is_numeric($key)) { + $openkey = 'item index="' . $key . '"'; + $closekey = 'item'; + } else { + $openkey = $closekey = $key; + } + + if (is_array($val)) { + echo str_repeat("\t", $level) . "<$openkey>\n"; + $this->assign($val, null, $level + 1); + echo str_repeat("\t", $level) . "\n"; + } else { + echo str_repeat("\t", $level) . "<$openkey>" . htmlspecialchars($val) . "\n"; + } + } +} + diff --git a/templates/default-xml/index.tpl b/templates/default-xml/index.tpl new file mode 100644 index 0000000..2922023 --- /dev/null +++ b/templates/default-xml/index.tpl @@ -0,0 +1 @@ + diff --git a/templates/default-xml/info.txt b/templates/default-xml/info.txt new file mode 100644 index 0000000..21b03d8 --- /dev/null +++ b/templates/default-xml/info.txt @@ -0,0 +1,4 @@ +Name: XML Engine. EXPERIMENTAL. (Developers only) +Author: Garvin Hicking +Date: 06.06.2006 +Require Serendipity: 1.1 diff --git a/templates/default-xml/preview.png b/templates/default-xml/preview.png new file mode 100644 index 0000000..4bad5ac Binary files /dev/null and b/templates/default-xml/preview.png differ diff --git a/templates/default-xml/template.inc.php b/templates/default-xml/template.inc.php new file mode 100644 index 0000000..264cf99 --- /dev/null +++ b/templates/default-xml/template.inc.php @@ -0,0 +1,7 @@ +