PageRenderTime 24ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/framework/core/gui/GuiSmarty2.php

http://zoop.googlecode.com/
PHP | 105 lines | 60 code | 19 blank | 26 comment | 3 complexity | d4a4737b259952f678b22039ba10a1e9 MD5 | raw file
  1<?php
  2/**
  3 * Object extends the Smarty templating system to allow easy separation of business and
  4 * presentation logic
  5 *
  6 */
  7class GuiSmarty2 extends Smarty2
  8{
  9	private $layout;
 10	 
 11	function __construct()
 12	{
 13		$config = GuiModule::sGetConfig();
 14		$tmpPath = Zoop::getTmpDir();
 15		
 16		//	call the parent contructor
 17		$this->Smarty();
 18		$this->template_dir = array();
 19   		
 20   		//	set the default for the base template dir
 21		//	this should be using the new config stuff, not defines
 22   		if(!defined("gui_template_dir") )
 23   			define("gui_template_dir", app_dir . "/templates");
 24   		
 25   		//	set the standard template directory and any others registerd with zoop
 26   		$this->addTemplateDir(gui_template_dir);
 27		
 28		//	set the compile directory
 29		$modTmpDir = $tmpPath . '/smarty2';
 30		if(!is_dir($modTmpDir))
 31			mkdir($modTmpDir);
 32		$this->setCompileDir($modTmpDir);
 33		
 34		//	set the cache_dir directory
 35		//	what does this even do?  I'm pretty sure that is not set up
 36		$this->setCacheDir($tmpPath . "/guicache");
 37		
 38		//	set the config directory
 39		//	what does this even do?  I'm pretty sure that is not set up
 40		$this->setConfigDir(app_dir . "/guiconfig");
 41		
 42		//	set the plugin directories
 43		$this->addPluginDir(zoop_dir . '/vendor/smarty2/plugins');	//	one for plugins added into gui
 44		$this->addPluginDir(app_dir . "/guiplugins");			//	one or plugins specific to the app
 45		
 46		//	we shouldn't use the blanket app_status define any more, we should use specific varabiles
 47		//	for each behavior, and it should use the new config system
 48		// $smarty->debugging = defined('app_status') && app_status == 'dev' ? true : false;
 49		// $smarty->compile_check = defined('app_status') && app_status == 'dev' ? true : false;
 50		
 51		//	we want to run this filter on every single smarty script that we execute
 52		//	it finds all places where we echo out a simple variable and escapes the html
 53		//
 54		//	unfortunately this filters everything.  The entire contents if the template.  I think it is escaping include.
 55		//	If we can get it to not do that then we can put this back in.
 56		//
 57		//$this->autoload_filters = array('pre' => array("strip_html"));
 58	}
 59	
 60	function setTemplateDir($inDir)
 61	{
 62		$this->template_dir = $inDir;
 63	}
 64	
 65	function addTemplateDir($inDir)
 66	{
 67		$this->template_dir[] = $inDir;
 68	}
 69	
 70	function setCompileDir($inDir)
 71	{
 72		$this->compile_dir = $inDir;
 73	}
 74	
 75	function setCacheDir($inDir)
 76	{
 77		$this->cache_dir = $inDir;
 78	}
 79	
 80	function setConfigDir($inDir)
 81	{
 82		$this->config_dir = $inDir;
 83	}
 84	
 85	function addPluginDir($inDir)
 86	{
 87		$this->plugins_dir[] = $inDir;
 88	}
 89	
 90	public function setLayout($layout)
 91	{
 92		$this->layout = $layout;
 93	}
 94	
 95	function fetch($tpl_file, $cache_id = null, $compile_id = null, $display = false)
 96	{
 97		if($this->layout)
 98		{
 99			$this->assign("TEMPLATE_CONTENT", $tpl_file);
100			return parent::fetch("layouts/{$this->layout}.tpl", $cache_id, $compile_id, $display);
101		}
102		
103		return parent::fetch($tpl_file, $cache_id, $compile_id, $display);
104	}
105}