Jeste lepsi vychytafka trasovani templat :-)
[mirrors/Kyberia-bloodline.git] / wwwroot / inc / smarty / resource.kyberia.php
CommitLineData
6a967e24
H
1<?php
2
3function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj) {
4
5 global $db,$error,$node, $error_messages;
ef7d6c1d
DH
6 $template_id = preg_replace('/\.tpl$/', '', $tpl_name);
7
8 //from now on module names need not to be numeric!
9 if (!is_numeric($template_id)) {
10 $template_id=nodes::getNodeIdByName($tpl_name);
11 if (!is_numeric($template_id)) {
12 $error = $error_messages['NOT_NUMERIC'];
13 return false;
14 }
6a967e24
H
15 }
16
ef7d6c1d
DH
17 if (is_numeric($template_id)) {
18 $tpl_source = nodes::getNodeById($template_id,empty($_SESSION['user_id']) ? "" : $_SESSION['user_id']);
19 }
8b1d21e6
H
20 $template_name = $tpl_source['node_name'];
21 $tpl_source = "\n\n<!-- BEGIN TEMPLATE $template_id [$template_name] -->\n\n".
ca9205d7 22 $tpl_source['node_content'].
8b1d21e6 23 "\n\n<!-- END TEMPLATE $template_id [$template_name] -->\n\n";
ef7d6c1d 24
6a967e24 25 // return true on success, false to generate failure notification
ef7d6c1d 26 return (bool)$tpl_source;
6a967e24
H
27}
28
29
30function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
31{
32 // do database call here to populate $tpl_timestamp
33 // with unix epoch time value of last template modification.
34 // This is used to determine if recompile is necessary.
ca9205d7 35 $recompile = 10; //recompile every N seconds
c0aaf671 36 $tpl_timestamp = floor(time()/$recompile)*$recompile;
37 // this example will recompile even unchanged templates! XXX!!! FIXME!!! TODO!!!
6a967e24
H
38 // return true on success, false to generate failure notification
39 return true;
40}
41
42function db_get_secure($tpl_name, &$smarty_obj)
43{
44 // assume all templates are secure
45 return true; //FIXME!!! TODO!!!
46}
47
48function db_get_trusted($tpl_name, &$smarty_obj)
49{
50 // not used for templates
51}
52
53// register the resource name "kyberia"
54$smarty->register_resource('kyberia', array('db_get_template',
55 'db_get_timestamp',
56 'db_get_secure',
57 'db_get_trusted'));
58
This page took 0.342053 seconds and 4 git commands to generate.