Commit a715e679758e8cbeb02f6cd4607f8b05b625e48f

Authored by nbm
1 parent 9eae1e4d

KTSmartyTemplate implements the KTTemplate interface, using the Smarty

templating language.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3446 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/templating/smartytemplate.inc.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * $Id$
  4 + *
  5 + * Smarty Template implementation
  6 + *
  7 + * Copyright (c) 2005 Jam Warehouse http://www.jamwarehouse.com
  8 + *
  9 + * This program is free software; you can redistribute it and/or modify
  10 + * it under the terms of the GNU General Public License as published by
  11 + * the Free Software Foundation; either version 2 of the License, or
  12 + * (at your option) any later version.
  13 + *
  14 + * This program is distributed in the hope that it will be useful,
  15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17 + * GNU General Public License for more details.
  18 + *
  19 + * You should have received a copy of the GNU General Public License
  20 + * along with this program; if not, write to the Free Software
  21 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22 + *
  23 + * @version $Revision$
  24 + * @author Neil Blakey-Milner, Jam Warehouse (Pty) Ltd, South Africa
  25 + */
  26 +
  27 +require_once(KT_LIB_DIR . "/templating/template.inc.php");
  28 +require_once(KT_DIR . "/thirdparty/Smarty/Smarty.class.php");
  29 +
  30 +class KTSmartyTemplate extends KTTemplate {
  31 + function KTSmartyTemplate ($sPath) {
  32 + $this->KTTemplate($sPath);
  33 + }
  34 +
  35 + function render($aDict) {
  36 + $smarty = new Smarty;
  37 + $smarty->compile_dir = "/tmp";
  38 + foreach ($aDict as $k => $v) {
  39 + $smarty->assign($k, $v);
  40 + }
  41 + return $smarty->fetch($this->sPath);
  42 + }
  43 +}
  44 +
  45 +?>
... ...