Ejemplo n.º 1
0
 /**
  * Load a template helper
  * 
  * This function merges the elements of the attached view model state with the parameters passed to the helper
  * so that the values of one are appended to the end of the previous one. 
  * 
  * If the view state have the same string keys, then the parameter value for that key will overwrite the state.
  *
  * @param   string  Name of the helper, dot separated including the helper function to call
  * @param   mixed   Parameters to be passed to the helper
  * @return  string  Helper output
  */
 public function renderHelper($identifier, $params = array())
 {
     $view = $this->getView();
     if (KInflector::isPlural($view->getName())) {
         if ($state = $view->getModel()->getState()) {
             $params = array_merge($state->getData(), $params);
         }
     } else {
         if ($item = $view->getModel()->getItem()) {
             $params = array_merge($item->getData(), $params);
         }
     }
     return parent::renderHelper($identifier, $params);
 }
Ejemplo n.º 2
0
 /**
  * Returns a directory path for temporary files
  *
  * Additionally checks for Joomla tmp folder if the system directory is not writable
  *
  * @throws KTemplateException
  * @return string Folder path
  */
 protected function _getTemporaryDirectory()
 {
     if (!self::$_temporary_directory) {
         $result = false;
         $candidates = array(ini_get('upload_tmp_dir'), JPATH_ROOT . '/tmp');
         if (function_exists('sys_get_temp_dir')) {
             array_unshift($candidates, sys_get_temp_dir());
         }
         foreach ($candidates as $folder) {
             if ($folder && @is_dir($folder) && is_writable($folder)) {
                 $result = rtrim($folder, '\\/');
                 break;
             }
         }
         if ($result === false) {
             throw new KTemplateException('Cannot find a writable temporary directory');
         }
         self::$_temporary_directory = $result;
     }
     return self::$_temporary_directory;
 }