Example #1
0
 /**
  * Constructor
  *
  * @param   array  $config
  * @return  void
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Set a base path for use by the view
     if (!array_key_exists('base_path', $config)) {
         $config['base_path'] = __DIR__;
     }
     $this->_basePath = $config['base_path'];
     // Set the default template search path
     if (!array_key_exists('template_path', $config)) {
         $config['template_path'] = $this->_basePath . DS . 'Views';
     }
     $this->_setPath('template', $config['template_path']);
 }
Example #2
0
 /**
  * Load a template file -- first look in the templates folder for an override
  *
  * [!] Override to wrap html view in mail template
  * 
  * @param   string  $tpl  The name of the template source file; automatically searches the template paths and compiles as needed.
  * @return  string  The output of the the template script.
  */
 public function loadTemplate($tpl = null)
 {
     // hold reference to template passed in
     $template = $tpl === false ? null : $tpl;
     // call load template and hold on to content
     $content = parent::loadTemplate($template);
     // if we want to wrap in mail template
     if ($tpl !== false) {
         $this->_mailTemplate->setBuffer($content, 'component');
         $content = $this->_mailTemplate->render();
         //$this->_mailTemplate->setBuffer(null, array('type' => 'head', 'name' => 'email'));
         $this->_mailTemplate->setBuffer(null, 'component');
         $this->_mailTemplate->setBuffer(null, 'head');
     }
     // return content
     return $content;
 }
Example #3
0
 /**
  * Dynamically handle calls to the class.
  *
  * @param   string  $method
  * @param   array   $parameters
  * @return  mixed
  * @throws  \BadMethodCallException
  * @since   1.3.1
  */
 public function __call($method, $parameters)
 {
     if (!static::hasHelper($method)) {
         foreach ($this->_path['helper'] as $path) {
             $file = $path . DS . $method . '.php';
             if (file_exists($file)) {
                 include_once $file;
                 break;
             }
         }
         $option = $this->option ? $this->option : \Request::getCmd('option');
         $option = ucfirst(substr($option, 4));
         // Namespaced
         $invokable1 = '\\Components\\' . $option . '\\Helpers\\' . ucfirst($method);
         // Old naming scheme "OptionHelperMethod"
         $invokable2 = $option . 'Helper' . ucfirst($method);
         $callback = null;
         if (class_exists($invokable1)) {
             $callback = new $invokable1();
         } else {
             if (class_exists($invokable2)) {
                 $callback = new $invokable2();
             }
         }
         if (is_callable($callback)) {
             $callback->setView($this);
             $this->helper($method, $callback);
         }
     }
     return parent::__call($method, $parameters);
 }
Example #4
0
 /**
  * Dynamically handle calls to the class.
  *
  * @param   string  $method
  * @param   array   $parameters
  * @return  mixed
  * @throws  \BadMethodCallException
  * @since   1.3.1
  */
 public function __call($method, $parameters)
 {
     if (!static::hasHelper($method)) {
         foreach ($this->_path['helper'] as $path) {
             $file = $path . DS . $method . '.php';
             if (file_exists($file)) {
                 include_once $file;
                 break;
             }
         }
         // Namespaced
         $invokable1 = '\\Plugins\\' . ucfirst($this->_folder) . '\\' . ucfirst($this->_element) . '\\Helpers\\' . ucfirst($method);
         // Old naming scheme "PluginFolderElementHelperMethod"
         $invokable2 = 'Plugin' . ucfirst($this->_folder) . ucfirst($this->_element) . 'Helper' . ucfirst($method);
         $callback = null;
         if (class_exists($invokable1)) {
             $callback = new $invokable1();
         } else {
             if (class_exists($invokable2)) {
                 $callback = new $invokable2();
             }
         }
         if (is_callable($callback)) {
             $callback->setView($this);
             $this->helper($method, $callback);
         }
     }
     return parent::__call($method, $parameters);
 }