Source for file Render.php
Documentation is available at Render.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* This source file is subject to version 2.1 of the GNU Lesser General Public
* License, that is bundled with this package in the file COPYING, available
* through the world wide web at the following URI:
* http://www.gnu.org/copyleft/lesser.html.
* @subpackage Presentation
* @author Alessandro Rossini <http://www.alessandrorossini.org>
* @author Graziano Liberati <http://www.liberati.org>
* @copyright 2004-2007 The ZNF Development Team
* @license LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
* @version SVN $Id: Render.php 44 2007-07-22 23:55:30Z evolic $
* @link http://www.zeronotice.org
require_once('ZNF/Config/AppConfig.php');
* <i>ZNF_Presentation_Render</i> specifies the abstract class that renderization classes should extends.
* @subpackage Presentation
* @author Alessandro Rossini <http://www.alessandrorossini.org>
* @author Graziano Liberati <http://www.liberati.org>
* @copyright 2004-2007 The ZNF Development Team
* @license LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
* @version SVN $Id: Render.php 44 2007-07-22 23:55:30Z evolic $
* @link http://www.zeronotice.org
* The <i>ZNF_Config_AppConfig</i> instance.
* @var ZNF_Config_AppConfig $_appConfig
* The name of the package to which the template refers.
* The <i>path</i> property of the <i>ZNF_Action_ActionMapping</i>.
* The <i>nextPath</i> property of the <i>ZNF_Action_ActionMapping</i>.
* Constructs a new <i>ZNF_Presentation_Render</i> object and sets the internal properties with application settings.
* @param string $package Name of the package to which the template refers,
* leave null this parameter to refer to the theme
* @param ZNF_Action_ActionMapping $mapping
public function __construct($package = null, $mapping = null)
$this->_path = $mapping->getPath();
* Get the ZNF constants to be assigned to the templates.
* <li>znf.baseHref: concatenation of hostname and relative path of the
* public script directory, used as prefix in hyperlinks in order to
* refer to correct URIs.</li>
* <li>znf.actionIndex: Name of the GET attribute used to select the
* action to execute.</li>
* <li>znf.moduleIndex: Name of the GET attribute used to select the
* module configuration.</li>
* <li>znf.changeModuleIndex: Name of the GET attribute used to select
* persistently the module configuration.</li>
* <li>znf.themePath: relative path of the current theme, used as prefix
* in hyperlinks (css, javascripts, images...) in order to refer to
* <li>znf.packagePath: relative path of the package in use, used as
* prefix in hyperlinks (css, javascripts, images...) in order to refer
* <li>znf.path: current action path.</li>
* <li>znf.nextPath: next action path to request.</li>
* <li>znf.credits: ZNF credits.</li>
if (isset ($_SERVER['HTTPS'])) {
$constants['baseHref'] = $protocol . "{ $_SERVER['SERVER_NAME']}";
if ($_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443') {
$constants['baseHref'] .= ":{$_SERVER['SERVER_PORT']}";
if (dirname($_SERVER['SCRIPT_NAME']) != '/') {
$constants['baseHref'] .= dirname($_SERVER['SCRIPT_NAME']);
$constants['baseHref'] .= '/';
$constants['actionIndex'] = ZNF::ACTION_INDEX;
$constants['moduleIndex'] = ZNF::MODULE_INDEX;
$constants['changeModuleIndex'] = ZNF::CHANGE_MODULE_INDEX;
$constants['packagePath'] = $this->_package;
$constants['path'] = $this->_path;
$constants['credits'] = ZNF::CREDITS;
* Returns the path of a theme template, tries to load the template in a predefined order.
* <li>current theme and current lang template</li>
* <li>current theme and default lang template</li>
* <li>default theme and default lang template</li>
* @param string $template File name of the template to get
// loading current theme and current lang template
$path = ZNF::THEME_DIR . "/{$_SESSION['znf']['theme']}/{$_SESSION['znf']['lang']}/{$template}";
// loading current theme and default lang template
// loading default theme and default lang template
// default theme and default lang template not found
* Returns the path of a package template, tries to load the template in a predefined order.
* <li>overloaded package template in the current theme and lang path</li>
* <li>current package and current lang template</li>
* <li>current package and default lang template</li>
* @param string $template File name of the template to get
// loading overloaded package template in the current theme and lang path
$path = ZNF::THEME_DIR . "/{$_SESSION['znf']['theme']}/" . ZNF::TEMPLATE_OVERLAY_DIR . "/{$this->_package}/{ $_SESSION['znf']['lang']}/{ $template}";
// loading current package and current lang template
$path = ZNF::MODULES_DIR . "/{ $this->_package}/ " . ZNF::TEMPLATE_DIR . "/{ $_SESSION['znf']['lang']}/{ $template}";
// loading current package and default lang template
// current package and default lang template not found
$translation = new ZNF_Presentation_Translation('ZNF', $_SESSION['znf']['lang']);
throw new ZNF_Presentation_RenderException($translation->get('errorLoadPackageTemplate'));
* Returns the path to get the template requested.
* @param string $template File name of the template
protected function _getTemplatePath($template)
* Returns the path of a theme, tries to find the theme base directory in a predefined order.
* <li>current theme and current lang theme base directory</li>
* <li>current theme and default lang theme base directory</li>
* <li>default theme and default lang theme base directory</li>
protected function _getThemePath()
// loading current theme and current lang theme base directory
$path = ZNF::THEME_DIR . "/{ $_SESSION['znf']['theme']}/{ $_SESSION['znf']['lang']}";
// loading current theme and default lang theme base directory
$path = ZNF::THEME_DIR . "/{ $_SESSION['znf']['theme']}/{ $this->_appConfig->getLang()}";
// loading default theme and default lang theme base directory
// default theme and default lang theme base dir not found
$translation = new ZNF_Presentation_Translation('ZNF', $_SESSION['znf']['lang']);
throw new ZNF_Presentation_RenderException($translation->get('errorLoadThemeBaseDir'));
* Assigns values to template parameters.
* @param string $param The template parameter name
* @param mixed $value The value to assign
abstract public function assign($param, $value);
* Executes the renderization and displays the result.
* @param string $template File name of the template
* @param mixed $data Additional data to process
abstract public function display($template, $data = null);
* Executes the renderization and returns the result.
* @param string $template File name of the template
* @param mixed $data Additional data to process
abstract public function fetch($template, $data = null);
* <i>ZNF_Presentation_RenderException</i> is the exception type for the <i>ZNF_Presentation_Render</i> class.
* <i>ZNF_Presentation_RenderException</i> extends the <i>Exception</i> class of PHP5.
* @subpackage Presentation
* @author Alessandro Rossini <http://www.alessandrorossini.org>
* @author Graziano Liberati <http://www.liberati.org>
* @copyright 2004-2007 The ZNF Development Team
* @license LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
* @version SVN $Id: Render.php 44 2007-07-22 23:55:30Z evolic $
* @link http://www.zeronotice.org
class ZNF_Presentation_RenderException extends Exception
|