Commit | Line | Data |
---|---|---|
6a967e24 H |
1 | <?php |
2 | ||
3 | function 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 | } | |
20 | $tpl_source = $tpl_source['node_content']; | |
21 | ||
6a967e24 | 22 | // return true on success, false to generate failure notification |
ef7d6c1d | 23 | return (bool)$tpl_source; |
6a967e24 H |
24 | } |
25 | ||
26 | ||
27 | function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj) | |
28 | { | |
29 | // do database call here to populate $tpl_timestamp | |
30 | // with unix epoch time value of last template modification. | |
31 | // This is used to determine if recompile is necessary. | |
2b81c646 | 32 | $recompile = 100; //recompile every N seconds |
c0aaf671 | 33 | $tpl_timestamp = floor(time()/$recompile)*$recompile; |
34 | // this example will recompile even unchanged templates! XXX!!! FIXME!!! TODO!!! | |
6a967e24 H |
35 | // return true on success, false to generate failure notification |
36 | return true; | |
37 | } | |
38 | ||
39 | function db_get_secure($tpl_name, &$smarty_obj) | |
40 | { | |
41 | // assume all templates are secure | |
42 | return true; //FIXME!!! TODO!!! | |
43 | } | |
44 | ||
45 | function db_get_trusted($tpl_name, &$smarty_obj) | |
46 | { | |
47 | // not used for templates | |
48 | } | |
49 | ||
50 | // register the resource name "kyberia" | |
51 | $smarty->register_resource('kyberia', array('db_get_template', | |
52 | 'db_get_timestamp', | |
53 | 'db_get_secure', | |
54 | 'db_get_trusted')); | |
55 |