Turn off smarty debugging.
[rockboxthemes.git] / private / templater.class.php
bloba17ce4788b3a3a63cda3145b9a0aaf7a5513f56b
1 <?php
2 /***************************************************************************
3 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * \/ \/ \/ \/ \/
9 * $Id$
11 * Copyright (C) 2009 Jonas Häggqvist
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
24 class templater {
25 private $s;
27 public function __construct($smartydir) {
28 /* Load and set up Smarty */
29 require_once(sprintf("%s/Smarty.class.php", $smartydir));
30 $s = new smarty();
31 $s->template_dir = sprintf("%s/templates", config::privdir);
32 $s->compile_dir = sprintf("%s/compiled", $s->template_dir);
33 $s->cache_dir = sprintf("%s/cache", $s->template_dir);
34 $s->caching = false;
35 $s->debugging = false;
36 $s->security = true;
37 $s->security_settings['IF_FUNCS'] = array('array_key_exists', 'isset', 'is_array', 'count');
38 $s->secure_dir = array(
39 config::datadir
41 $this->s = $s;
44 public function assign($name, $value) {
45 $this->s->assign($name, $value);
48 public function render($pagename, $vars = array()) {
49 if (is_array($vars)) {
50 foreach($vars as $name => $value) {
51 $this->assign($name, $value);
54 $this->s->display($pagename);
55 /* printf("<xmp>"); print_r($vars); print("</xmp>"); */