Source for file Smarty.php
Documentation is available at Smarty.php
declare(encoding = "utf-8");
* This file is part of ForwardFW a web application framework.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* @author Alexander Opitz <opitz.alexander@primacom.net>
* @copyright 2009-2010 The Authors
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @link http://forwardfw.sourceforge.net
* @since File available since Release 0.0.2
require_once 'ForwardFW/Controller.php';
require_once 'ForwardFW/Request.php';
require_once 'ForwardFW/Response.php';
require_once 'ForwardFW/Interface/Templater.php';
require_once 'Smarty/Smarty.class.php';
* Class to use Smarty as Templater.
* @author Alexander Opitz <opitz.alexander@primacom.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @link http://forwardfw.sourceforge.net
* @var Smarty The smarty instance
* @var array Blocks to show
* @param ForwardFW_Interface_Application $application The running application
ForwardFW_Interface_Application $application
$strCompilePath = $arConfig['CompilePath'];
if (!is_dir($strCompilePath)) {
mkdir($strCompilePath, 0770, true);
$this->smarty->compile_dir = $strCompilePath;
$this->smarty->register_block('block', array(&$this, '__block'));
$this->smarty->register_function('texter', array(&$this, '__texter'));
$this->strTemplatePath = $arConfig['TemplatePath'];
* Sets file to use for templating
* @param string $_strFile Complete path and filename.
* @return ForwardFW_Templater_Smarty The instance.
$this->strFile = $_strFile;
* Sets a var in the template to a value
* @param string $_strName Name of template var.
* @param mixed $_mValue Value of template var.
* @return ForwardFW_Templater_Smarty The instance.
public function setVar($_strName, $_mValue)
$this->smarty->assign($_strName, $_mValue);
* Returns compiled template for outputing.
* @return string Content of template after compiling.
// Catch Exceptions and clear output cache
$result = $this->smarty->fetch(
$this->strTemplatePath . '/' . $this->strFile
* Defines blocks in template.
* Deprecated or should be used for template engines without conditions?
* Shows block in template.
* Deprecated or should be used for template engines without conditions?
* Hide block in template.
* Deprecated or should be used for template engines without conditions?
* Block implementation for smarty.
* Deprecated or should be used for template engines without conditions?
public function __block($params, $content, &$smarty, &$repeat)
* Texter implementation for smarty.
* More later, if it exists.
public function __texter($params, &$smarty)
$strTextKey = $params['key'];
$texter = ForwardFW_Texter::factory($this->strApplicationName);
$result = $texter->getText($strTextKey);
|