public function __construct($options = array()) { $options = $this->_initialize($options); // Add a rule to the template for form handling and secrity tokens KTemplateDefault::addRules(array(KFactory::get('lib.koowa.template.rule.form'))); // Set a base path for use by the view $this->assign('baseurl', $options['base_url']); parent::__construct($options); }
/** * 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 loadHelper($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::loadHelper($identifier, $params); }
/** * Constructor * * @param array An optional associative array of configuration settings. */ public function __construct(array $options = array()) { // Initialize the options $options = $this->_initialize($options); // Mixin the KMixinClass $this->mixin(new KMixinClass($this, 'View')); // Assign the classname with values from the config $this->setClassName($options['name']); // set the charset (used by the variable escaping functions) $this->_charset = $options['charset']; // user-defined escaping callback $this->setEscape($options['escape']); // Set a base path for use by the view $this->_basePath = $options['base_path']; // set the default template search path if ($options['template_path']) { // user-defined dirs $this->setTemplatePath($options['template_path']); } else { $this->setTemplatePath($this->_basePath . DS . 'tmpl'); } // assign the document object if ($options['document']) { $this->_document = $options['document']; } else { $this->_document = KFactory::get('lib.joomla.document'); } // set the layout $this->setLayout($options['layout']); //Register the view stream wrapper KTemplateDefault::register(); KTemplateDefault::addRules($options['template_rules']); //Add the include paths for the helpers KViewHelper::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_' . $this->getClassName('prefix') . DS . 'helpers'); }