Esempio n. 1
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $dirs = Zend_Registry::get('dirs');
     $template = Zend_Registry::get('theme');
     $config = Zend_Registry::get('config');
     $qool_module = Zend_Registry::get('Qool_Module');
     // Class Constructor.
     // These automatically get set with each new instance.
     $loader = new Twig_Loader_Filesystem(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP);
     $twig = new Twig_Environment($loader, array('cache' => APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'twig' . DIR_SEP));
     $lexer = new Twig_Lexer($twig, array('tag_comment' => array('<#', '#>}'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<<', '>>')));
     $twig->setLexer($lexer);
     include_once APPL_PATH . $dirs['structure']['lib'] . DIR_SEP . 'Qool' . DIR_SEP . 'Template' . DIR_SEP . 'template.php';
     if (file_exists(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php')) {
         include_once APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php';
     }
     $funcs = get_defined_functions();
     foreach ($funcs['user'] as $k => $v) {
         $twig->addFunction($v, new Twig_Function_Function($v));
     }
     $this->_twig = $twig;
     $this->assign('config', $config);
     Zend_Registry::set('tplExt', 'html');
 }
Esempio n. 2
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     if (isset($config['phptal'])) {
         System_Options::setOptions($this->getEngine(), (array) $config['phptal']);
     }
 }
Esempio n. 3
0
 /**
  * Constructor
  *
  * Pass it a an array with the following configuration options:
  *
  * scriptPath: the directory where your templates reside
  * compileDir: the directory where you want your compiled templates (must be
  * writable by the webserver)
  * configDir: the directory where your configuration files reside
  *
  * both scriptPath and compileDir are mandatory options, as Smarty needs
  * them. You can't set a cacheDir, if you want caching use Zend_Cache
  * instead, adding caching to the view explicitly would alter behaviour
  * from Zend_View.
  *
  * @see Zend_View::__construct
  * @param array $config
  * @throws Exception
  */
 public function __construct($config = array())
 {
     $this->_smarty = new Smarty();
     //smarty object
     //compile dir must be set
     if (!array_key_exists('compileDir', $config)) {
         throw new Exception('compileDir must be set in $config for ' . get_class($this));
     } else {
         $this->_smarty->compile_dir = $config['compileDir'];
     }
     //configuration files directory
     if (array_key_exists('configDir', $config)) {
         $this->_smarty->config_dir = $config['configDir'];
     }
     if (array_key_exists('leftDelimiter', $config)) {
         $this->_smarty->left_delimiter = $config['leftDelimiter'];
     }
     if (array_key_exists('rightDelimiter', $config)) {
         $this->_smarty->right_delimiter = $config['rightDelimiter'];
     }
     if (array_key_exists('templateDir', $config)) {
         $this->_smarty->template_dir = array($config['templateDir']);
     }
     if (array_key_exists('pluginDir', $config)) {
         $this->_smarty->plugins_dir = $config['pluginDir'];
     }
     //call parent constructor
     parent::__construct($config);
 }
Esempio n. 4
0
 function __construct(Am_Di $di = null)
 {
     parent::__construct();
     if (null === $di) {
         $this->di = Am_Di::getInstance();
     } else {
         $this->di = $di;
     }
     if ($this->di->hasService('theme')) {
         $this->theme = $this->di->theme;
     } else {
         $this->theme = new Am_Theme($this->di, 'default', array());
     }
     $this->setHelperPath('Am/View/Helper', 'Am_View_Helper_');
     $this->setEncoding('UTF-8');
     foreach ($this->di->viewPath as $dir) {
         $this->addScriptPath($dir);
     }
     if (!$this->getScriptPaths()) {
         $this->addScriptPath(dirname(__FILE__) . '/../../application/default/views');
     }
     $this->headScript()->prependScript("window.rootUrl = " . Am_Controller::getJson(REL_ROOT_URL) . ";\n");
     $this->headScript()->prependScript("window.CKEDITOR_BASEPATH = " . Am_Controller::getJson(REL_ROOT_URL . '/application/default/views/public/js/ckeditor/') . ";\n");
     $this->headScript()->prependScript("window.amLangCount = " . Am_Controller::getJson(count(Am_Di::getInstance()->config->get('lang.enabled'))) . ";\n");
 }
Esempio n. 5
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     $dirs = Zend_Registry::get('dirs');
     $template = Zend_Registry::get('theme');
     $qool_module = Zend_Registry::get('Qool_Module');
     //set Qool directories
     $templates = APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP;
     $templates_c = APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'smarty' . DIR_SEP . 'templates_c' . DIR_SEP;
     $configs = APPL_PATH . 'config' . DIR_SEP . 'smarty' . DIR_SEP;
     $cache = APPL_PATH . $dirs['structure']['cache'] . DIR_SEP . 'smarty' . DIR_SEP . 'cache' . DIR_SEP;
     // Class Constructor.
     // These automatically get set with each new instance.
     $this->_smarty = new Smarty();
     $this->_smarty->setTemplateDir($templates);
     $this->_smarty->setCompileDir($templates_c);
     $this->_smarty->setConfigDir($configs);
     $this->_smarty->setCacheDir($cache);
     $this->_smarty->caching = Smarty::CACHING_LIFETIME_CURRENT;
     $this->_smarty->caching = false;
     //get the template file and register all functions in it to smarty
     include_once APPL_PATH . $dirs['structure']['lib'] . DIR_SEP . 'Qool' . DIR_SEP . 'Template' . DIR_SEP . 'template.php';
     if (file_exists(APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php')) {
         include_once APPL_PATH . $dirs['structure']['templates'] . DIR_SEP . $qool_module . DIR_SEP . $template . DIR_SEP . 'functions.php';
     }
     // $this_smarty->register_function('date_now', 'print_current_date');
     Zend_Registry::set('tplExt', 'tpl');
 }
Esempio n. 6
0
 public function __construct($config = array())
 {
     if (APPLICATION_ENV == "testing") {
         $this->_testing = true;
         $this->_streamUrl = 'php://memory';
     }
     parent::__construct($config);
 }
Esempio n. 7
0
 /**
  * Constructor
  *
  * Register Zend_View_Stream stream wrapper if short tags are disabled.
  *
  * @param  array $config
  * @return void
  */
 public function __construct($config = array())
 {
     if (array_key_exists('mail', $config)) {
         $this->setMail($config['mail']);
     }
     parent::__construct($config);
     $this->addHelperPath('App/Mail/View/Helper', 'App_Mail_View_Helper');
 }
Esempio n. 8
0
 /**
  * Constructor
  * @access public
  */
 public function __construct($options = array(), $engine = null)
 {
     parent::__construct($options);
     if ($engine === null) {
         $engine = new PHPTAL();
     }
     $this->_engine = $engine;
     $this->_engine->set('this', $this);
 }
Esempio n. 9
0
 /**
  * Class Constructor
  *
  * @param array [OPTIONAL] $data
  * @return ZendSmarty
  */
 public function __construct($webConfig)
 {
     parent::__construct(array());
     $configSmarty = $webConfig->smarty;
     $templateDir = $configSmarty->templateDirectory;
     $compileDir = $configSmarty->compileDirectory;
     $configDir = $configSmarty->configDirectory;
     $cacheDir = $configSmarty->cacheDirectory;
     $this->smarty = new ProjectSmarty($templateDir, $compileDir, $configDir, $cacheDir, false);
 }
Esempio n. 10
0
 /**
  * Constructor
  *
  * Register Zend_View_Stream stream wrapper if short tags are disabled.
  *
  * @param  array $config
  * @return void
  */
 public function __construct($config = array())
 {
     $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
     if ($this->_useViewStream) {
         if (!in_array('zend.view', stream_get_wrappers())) {
             stream_wrapper_register('zend.view', 'Zend_View_Stream');
         }
     }
     if (array_key_exists('useStreamWrapper', $config)) {
         $this->setUseStreamWrapper($config['useStreamWrapper']);
     }
     parent::__construct($config);
 }
Esempio n. 11
0
 public function __construct($options = array())
 {
     if (!isset($options["zf"])) {
         $options["zf"] = array();
     }
     if (!isset($options["twig"])) {
         $options["twig"] = array();
     }
     parent::__construct($options["zf"]);
     $this->_twig = new Twig_Environment(null, array_merge($this->_twigOptions, $options["twig"]));
     if (isset($options["twig"]["extensions"])) {
         $exts = (array) $options["twig"]["extensions"];
         $this->setExtensions($exts);
     }
 }
Esempio n. 12
0
 /**
  * @param array $config View configuration.
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Setting the XHTML1_STRICT doctype fixes validation errors for ZF's form elements
     $this->doctype()->setDoctype('HTML5');
     $this->addHelperPath(VIEW_HELPERS_DIR, 'Omeka_View_Helper');
     try {
         $mvc = Zend_Registry::get('plugin_mvc');
         foreach ($mvc->getHelpersDirs() as $pluginDirName => $dir) {
             $this->addHelperPath($dir, "{$pluginDirName}_View_Helper");
         }
     } catch (Zend_Exception $e) {
         // no plugins or MVC component, so we can't add helper paths
     }
 }
Esempio n. 13
0
 /**
  * Constructor
  *
  * Register Zend_View_Stream stream wrapper if short tags are disabled.
  *
  * @param  array $config
  * @return void
  */
 public function __construct($config = array())
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/config.ini', 'default');
     $config = $config->resources->view->toArray();
     $this->_useViewStream = (bool) ini_get('short_open_tag') ? false : true;
     if ($this->_useViewStream) {
         if (!in_array('zend.view', stream_get_wrappers())) {
             require_once 'Zend/View/Stream.php';
             stream_wrapper_register('zend.view', 'Zend_View_Stream');
         }
     }
     if (array_key_exists('useStreamWrapper', $config)) {
         $this->setUseStreamWrapper($config['useStreamWrapper']);
     }
     parent::__construct($config);
 }
Esempio n. 14
0
 /**
  * Constructor
  *
  * Pass it a an array with the following configuration options:
  *
  * scriptPath: the directory where your templates reside
  * compileDir: the directory where you want your compiled templates
  * (must be
  * writable by the webserver)
  * configDir: the directory where your configuration files reside
  *
  * both scriptPath and compileDir are mandatory options, as Smarty
  * needs
  * them. You can't set a cacheDir, if you want caching use
  * Zend_Cache
  * instead, adding caching to the view explicitly would alter
  * behaviour
  * from Zend_View.
  *
  * @see Zend_View::__construct
  * @param array $config
  * @throws Exception
  */
 public function __construct($config = array())
 {
     $this->_smarty = new Smarty();
     //smarty object
     if (!array_key_exists('compileDir', $config)) {
         throw new Exception('compileDir must be set in $config for ' . get_class($this));
     } else {
         $this->_smarty->compile_dir = $config['compileDir'];
     }
     //compile dir must be set
     if (array_key_exists('configDir', $config)) {
         $this->_smarty->config_dir = $config['configDir'];
     }
     //configuration files directory
     parent::__construct($config);
     //call parent constructor
 }
Esempio n. 15
0
 /**
  * Constructor.
  *
  * @param array $config Configuration key-value pairs.
  */
 public function __construct(array $config = array())
 {
     // Disable streams
     if (array_key_exists('streamFlag', $config)) {
         $this->setStreamFlag($config['streamFlag']);
     }
     // Stream protocol
     if (array_key_exists('streamProtocol', $config)) {
         $this->setStreamProtocol($config['streamProtocol']);
     }
     // Stream wrapper
     if (array_key_exists('streamWrapper', $config)) {
         $this->setStreamWrapper($config['streamWrapper']);
     }
     // User-defined stream filters
     if (array_key_exists('streamFilter', $config)) {
         $this->addFilter($config['streamFilter']);
     }
     // Call parent
     parent::__construct($config);
 }
Esempio n. 16
0
 public function __construct()
 {
     $config = Zend_Registry::getInstance()->get('config');
     var_dump($config);
     $this->config = $config['resources']['view'];
     $this->_smarty = new Smarty();
     $this->_smarty->template_dir = DIR_INCLUDES . 'layouts' . DS . 'default';
     $this->_smarty->compile_dir = DIR_TMP . 'cache';
     $this->_smarty->cache_dir = DIR_TMP . 'cache';
     $this->_smarty->config_dir = SMARTY_DIR . 'configs';
     $this->_smarty->caching = LIVE;
     $this->_smarty->compile_check = !LIVE;
     $this->_smarty->cache_lifetime = LIVE ? 3600 : 0;
     $this->_smarty->debugging = false;
     $this->_smarty->force_compile = !LIVE;
     $this->_smarty->php_handling = SMARTY_PHP_ALLOW;
     $this->_smarty->error_reporting = E_ALL | E_STRICT;
     $this->_smarty->register_block('block', array(&$this, 'smarty_block'));
     $this->_smarty->register_function('extends', array(&$this, 'smarty_extends'));
     $this->_extends = array();
     $this->placeholder('title')->set($_SERVER['HTTP_HOST']);
     parent::__construct($this->config);
     return $this;
 }
Esempio n. 17
0
 /**
  * Constructor
  *
  * RemovedZend_View_Stream since I have that in my php.ini file turned on
  *
  * @paramarray $config
  * @return void
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->setBasePath(ROOT . '/view');
     $this->addScriptPath(ROOT . '/view/layouts');
 }
Esempio n. 18
0
 /**
  * Class definition and constructor
  *
  * Let's start with the class definition and the constructor part. My class Travello_View_Smarty is extending the Zend_View_Abstract class. In the constructor the parent constructor from Zend_View_Abstract is called first. After that a Smarty object is instantiated, configured and stored in a private attribute.
  * Please note that I use a configuration object from the object store to get the configuration data for Smarty.
  *
  * @param array $smartyConfig
  * @param array $config
  */
 public function __construct($smartyConfig, $config = array())
 {
     $this->_config = $smartyConfig;
     parent::__construct($config);
     $this->_loadSmarty();
 }
Esempio n. 19
0
 /**
  * When a master view is created, it is passed its
  * script immediately. 
  *
  * @param unknown_type $viewFile
  */
 public function __construct($script = '')
 {
     $this->setViewFile($script);
     if (is_array($script)) {
         parent::__construct($script);
     } else {
         parent::__construct();
     }
     $this->addHelperPath(APP_DIR . '/helpers', 'Helper');
 }