/**
* Constructor
*
* @param array $config A named configuration array for object construction.
* name: the name (optional) of the view (defaults to the view class name suffix).
* charset: the character set to use for display
* escape: the name (optional) of the function to use for escaping strings
* base_path: the parent path (optional) of the views directory (defaults to the component folder)
* template_plath: the path (optional) of the layout directory (defaults to base_path + /views/ + view name
* helper_path: the path (optional) of the helper files (defaults to base_path + /helpers/)
* layout: the layout (optional) to use to display the view
*
* @since 3.0
*/
public function __construct($config = array())
{
parent::__construct($config);
// Set the charset (used by the variable escaping functions)
if (\array_key_exists('charset', $config)) {
@trigger_error('Setting a custom charset for escaping is deprecated. Override \\JViewLegacy::escape() instead.', E_USER_DEPRECATED);
$this->_charset = $config['charset'];
}
// Set a base path for use by the view
if (\array_key_exists('base_path', $config)) {
$this->_basePath = $config['base_path'];
} else {
$this->_basePath = JPATH_COMPONENT;
}
// Set the default template search path
if (\array_key_exists('template_path', $config)) {
// User-defined dirs
$this->_setPath('template', $config['template_path']);
} elseif (is_dir($this->_basePath . '/tmpl/' . $this->getName())) {
$this->_setPath('template', $this->_basePath . '/tmpl/' . $this->getName());
} elseif (is_dir($this->_basePath . '/View/' . $this->getName() . '/tmpl')) {
$this->_setPath('template', $this->_basePath . '/View/' . $this->getName() . '/tmpl');
} elseif (is_dir($this->_basePath . '/view/' . $this->getName() . '/tmpl')) {
$this->_setPath('template', $this->_basePath . '/view/' . $this->getName() . '/tmpl');
} elseif (is_dir($this->_basePath . '/views/' . $this->getName() . '/tmpl')) {
$this->_setPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl');
} else {
$this->_setPath('template', $this->_basePath . '/views/' . $this->getName());
}
// Set the default helper search path
if (\array_key_exists('helper_path', $config)) {
// User-defined dirs
$this->_setPath('helper', $config['helper_path']);
} else {
$this->_setPath('helper', $this->_basePath . '/helpers');
}
// Set the layout
if (\array_key_exists('layout', $config)) {
$this->setLayout($config['layout']);
} else {
$this->setLayout('default');
}
$this->baseurl = Uri::base(true);
}