Prepared to experimentaly fire smarty from database...
authorHarvie <tomas@mudrunka.cz>
Mon, 29 Nov 2010 00:33:21 +0000 (01:33 +0100)
committerHarvie <tomas@mudrunka.cz>
Mon, 29 Nov 2010 00:33:21 +0000 (01:33 +0100)
wwwroot/inc/getTemplate.inc [deleted file]
wwwroot/inc/smarty/resource.kyberia.php [new file with mode: 0644]
wwwroot/nodes.php

diff --git a/wwwroot/inc/getTemplate.inc b/wwwroot/inc/getTemplate.inc
deleted file mode 100644 (file)
index 00269c9..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-function getTemplate($add_template_id) {
-
-        global $db,$error,$node, $error_messages;
-
-        if (!is_numeric($add_template_id)) {
-            $error = $error_messages['NOT_NUMERIC'];
-            return false;
-        }
-
-                               /*
-        //logging of every template for security reasons
-        $params['node_creator'] = UBIK_ID;
-        $params['node_parent'] = 2029360;
-        $params['node_name'] = "addTemplate execute: node $add_template_id";
-        $params['node_content'] = mysql_real_escape_string("addTemplate execute: node <a href='$add_template_id'>$add_template_id</a> by user ".$_SESSION['user_name']);
-        nodes::addNode($params);
-                               */
-
-        if(!($set=$db->query("select node_content from nodes where node_id='$add_template_id'"))) return false;
-        $set->next();
-        return stripslashes($set->getString('node_content'));
-}
diff --git a/wwwroot/inc/smarty/resource.kyberia.php b/wwwroot/inc/smarty/resource.kyberia.php
new file mode 100644 (file)
index 0000000..3a08f08
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) {
+
+        global $db,$error,$node, $error_messages;
+                               $add_template_id = $tpl_name;
+
+        if (!is_numeric($add_template_id)) {
+            $error = $error_messages['NOT_NUMERIC'];
+            return false;
+        }
+
+                               /*
+        //logging of every template for security reasons FIXME!!! TODO!!!
+        $params['node_creator'] = UBIK_ID;
+        $params['node_parent'] = 2029360;
+        $params['node_name'] = "addTemplate execute: node $add_template_id";
+        $params['node_content'] = mysql_real_escape_string("addTemplate execute: node <a href='$add_template_id'>$add_template_id</a> by user ".$_SESSION['user_name']);
+        nodes::addNode($params);
+                               */
+
+        if(!($set=$db->query("select node_content from nodes where node_id='$add_template_id'"))) return false;
+        $set->next();
+    // populating $tpl_source with actual template contents
+    $tpl_source = stripslashes($set->getString('node_content'));
+    // return true on success, false to generate failure notification
+    return true;
+}
+
+
+function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
+{
+    // do database call here to populate $tpl_timestamp
+    // with unix epoch time value of last template modification.
+    // This is used to determine if recompile is necessary.
+    $tpl_timestamp = time(); // this example will always recompile! FIXME!!! TODO!!!
+    // return true on success, false to generate failure notification
+    return true;
+}
+
+function db_get_secure($tpl_name, &$smarty_obj)
+{
+    // assume all templates are secure
+    return true; //FIXME!!! TODO!!!
+}
+
+function db_get_trusted($tpl_name, &$smarty_obj)
+{
+    // not used for templates
+}
+
+// register the resource name "kyberia"
+$smarty->register_resource('kyberia', array('db_get_template',
+                                       'db_get_timestamp',
+                                       'db_get_secure',
+                                       'db_get_trusted'));
+
index 723f940753f7ea3a0a08f0066779c0b23eda7e8a..96926f58272f9e9fb68b091e956a880da12f30b4 100644 (file)
@@ -94,6 +94,7 @@ if (!empty($_GET['node_name'])) {
 //loading smarty template engine and setting main parameters
 require(SMARTY_DIR.'Smarty.class.php');
 $smarty = new Smarty;
+require(INCLUDE_DIR.'smarty/resource.kyberia.php');
 
 //$smarty->php_handling = SMARTY_PHP_REMOVE; //XXX
 $smarty->template_dir = TEMPLATE_DIR;
This page took 0.255257 seconds and 4 git commands to generate.