From: Harvie Date: Mon, 29 Nov 2010 00:33:21 +0000 (+0100) Subject: Prepared to experimentaly fire smarty from database... X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=6a967e24d43f3d23244c21104e6a3f09d5923cb9;p=mirrors%2FKyberia-bloodline.git Prepared to experimentaly fire smarty from database... --- 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;