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
$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);
}
}
+/*
+ *@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 "</serendipity>\n";
+ return true;
+ }
+
+ function __construct() {
+ header('Content-Type: text/xml; charset=' . LANG_CHARSET);
+ echo '<?xml version="1.0" encoding="' . LANG_CHARSET . '" ?>' . "\n";
+ /*
+ echo '<?xml-stylesheet href="' . serendipity_getTemplateFile('xml.css') . '" type="text/css" ?>' . "\n";
+ */
+ echo "<serendipity>\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) . "</$closekey>\n";
+ } else {
+ echo str_repeat("\t", $level) . "<$openkey>" . htmlspecialchars($val) . "</$closekey>\n";
+ }
+ }
+}
+