From 6a967e24d43f3d23244c21104e6a3f09d5923cb9 Mon Sep 17 00:00:00 2001 From: Harvie Date: Mon, 29 Nov 2010 01:33:21 +0100 Subject: [PATCH] Prepared to experimentaly fire smarty from database... --- wwwroot/inc/getTemplate.inc | 23 ---------- wwwroot/inc/smarty/resource.kyberia.php | 57 +++++++++++++++++++++++++ wwwroot/nodes.php | 1 + 3 files changed, 58 insertions(+), 23 deletions(-) delete mode 100644 wwwroot/inc/getTemplate.inc create mode 100644 wwwroot/inc/smarty/resource.kyberia.php diff --git a/wwwroot/inc/getTemplate.inc b/wwwroot/inc/getTemplate.inc deleted file mode 100644 index 00269c9..0000000 --- a/wwwroot/inc/getTemplate.inc +++ /dev/null @@ -1,23 +0,0 @@ -$add_template_id 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 index 0000000..3a08f08 --- /dev/null +++ b/wwwroot/inc/smarty/resource.kyberia.php @@ -0,0 +1,57 @@ +$add_template_id 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')); + diff --git a/wwwroot/nodes.php b/wwwroot/nodes.php index 723f940..96926f5 100644 --- a/wwwroot/nodes.php +++ b/wwwroot/nodes.php @@ -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; -- 2.30.2