*/';
protected $_stylesheetRenderType = self::CSS_LINK;
protected $_layoutTemplate;
protected $_smarty;
protected $_smartyPluginPaths = array(
'lib/Smarty/Smarty/plugins',
'lib/Smarty/app_plugins'
);
protected $_content = array(
'htmlAttribs' => array(
'xmlns' => 'http://www.w3.org/1999/xhtml',
'class' => 'no-js',
),
'head' => array(
'keywords' => '',
'description' => '',
'meta' => [],
'base' => '',
'link' => [],
'nonCriticalStylesheet' => [],
'criticalStylesheet' => [],
'script' => [],
'inlineScript' => [],
'readyFunctions' => [],
'initFunctions' => [],
),
'bodyAttribs' => [],
'bodyTemplate' => null,
'menu' => null,
'ctrlMenu' => null,
'ITEMS' => array(),
);
protected $_googleFontsUrl;
protected $_titleFormat = '[{title}][{separator}Page {pageNumber}]{separator}{siteName}';
protected $_titleSeparator = ' :: ';
protected $_titleParts = [];
protected $_pageNumber;
protected $_siteName;
protected $_resourcesIgnoredAttribs = array(
'skipPacking', // якщо стилю чи скрипту в атрибутах передати 'skipPacking' => true, то Qs_Packer такі ресурси мерджити не буде
);
protected $_defaultGroupName = 'ITEMS';
protected $_groupName;
protected $_smartyPlugins = array(
'block' => array(),
);
protected $_templateRootPath;
protected $_outFilters = array();
protected $_templateDefines = array(
'BASE_URL', 'BASE_URL_LANGUAGE', 'CURRENT_PAGE', 'CURRENT_PAGE_FINAL', 'PARENT_PAGE', 'PARENT_PAGE_FINAL',
'BASE_PATH', 'CURRENT_LANGUAGE', 'SITE_LIVE', 'DEFAULT_LANGUAGE', 'NOINDEX_BEGIN', 'NOINDEX_END',
'SITE_REVISION', 'VISITOR_TRACKING'
);
protected $_scriptDefines = array(
'BASE_URL', 'BASE_URL_LANGUAGE', 'CURRENT_PAGE', 'CURRENT_PAGE_FINAL', 'SITE_LIVE', 'PARENT_PAGE',
'PARENT_PAGE_FINAL', 'CURRENT_LANGUAGE', 'DEFAULT_LANGUAGE', 'DEBUG', 'SITE_REVISION', 'OPTIMIZE_RESOURCES',
'USE_PACKED_RESOURCES', 'CURRENCY_TITLE', 'CURRENCY_CODE'
);
protected $_view;
protected $_authClassName;
protected $_authAdapterClassName;
/**
* @var Qs_Auth
*/
protected $_auth;
/**
* @var Qs_Auth_Adapter_DbTable
*/
protected $_authAdapter;
protected $_hasAuthentication = false;
protected $_options = array();
protected $_optimized = false;
/**
* @var Qs_Lock_RoleObj
*/
protected $_lockObj;
public function __construct($options = array())
{
$this->setBase(Qs_Constant::get('BASE_URL') . '/');
$this->setOptions($options);
Qs_Options::setConstructorOptions($this);
$this->_init();
}
protected function _init()
{
/** @var $viewRenderer Zend_Controller_Action_Helper_ViewRenderer */
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if (null == $viewRenderer->view) {
$viewRenderer->setView(Qs_View::getInstance());
}
$this->_initMessages();
if ($this->_hasAuthentication) {
$this->authenticate();
}
return $this;
}
protected function _initMessages()
{
if (Qs_Request::isXmlHttpRequest()) {
// Don't remove messages in Ajax requests
return $this;
}
$session = new Qs_Session_Namespace(Qs_Constant::get('CURRENT_PAGE'));
if (isset($session->message)) {
$this->displayMessage($session->message);
unset($session->message);
}
if (isset($session->error)) {
$this->displayError($session->error);
unset($session->error);
}
if (isset($session->attention)) {
$this->displayAttention($session->attention);
unset($session->attention);
}
return $this;
}
public function setAuthentication($value)
{
$this->_hasAuthentication = (bool) $value;
return $this;
}
public function getAuthentication()
{
return (bool) $this->_hasAuthentication;
}
public function setOptions($options)
{
if (isset($options['options'])) {
unset($options['options']);
}
foreach ($options as $key => $value) {
$this->setOption($key, $value);
}
return $this;
}
public function getOptions()
{
return $this->_options;
}
public function setOption($name, $value)
{
$method = 'set' . ucfirst($name);
if (method_exists($this, $method)) {
$this->$method($value);
} else {
$this->_options[$name] = $value;
}
return $this;
}
public function getOption($name)
{
if (array_key_exists($name, $this->_options)) {
return $this->_options[$name];
}
return false;
}
/**
* @return mixed
*/
public function getGoogleFontsUrl()
{
return $this->_googleFontsUrl;
}
/**
* @param mixed $googleFontsUrl
* @return $this
*/
public function setGoogleFontsUrl($googleFontsUrl)
{
$this->_googleFontsUrl = $googleFontsUrl;
return $this;
}
public function setDescription($description)
{
$this->_content['head']['description'] = $description;
return $this;
}
public function appendHeader($append)
{
$this->setHeader($this->getHeader() . $append);
return $this;
}
public function setHeader($header)
{
$this->assign('header', $header);
return $this;
}
public function getHeader()
{
return $this->getTemplateVariable('header');
}
public function getTemplateVariables()
{
return $this->_content;
}
public function getTemplateVariable($name)
{
if (array_key_exists($name, $this->_content)) {
return $this->_content[$name];
}
return null;
}
public function setKeywords($keywords)
{
$this->_content['head']['keywords'] = $keywords;
return $this;
}
public function getView()
{
if (null === $this->_view) {
$this->_view = Qs_View::getInstance();
}
return $this->_view;
}
public function clearCriticalStylesheets()
{
return $this->_clearStylesheets(true);
}
public function clearNonCriticalStylesheets()
{
return $this->_clearStylesheets(false);
}
public function clearAllStylesheets()
{
$this->clearCriticalStylesheets();
$this->clearNonCriticalStylesheets();
return $this;
}
protected function _clearStylesheets($critical)
{
$this->_content['head'][$critical ? 'criticalStylesheet' : 'nonCriticalStylesheet'] = array();
return $this;
}
public function clearInlineScripts()
{
$this->_content['head']['inlineScript'] = array();
return $this;
}
public function clearInitFunctions()
{
$this->_content['head']['initFunctions'] = array();
return $this;
}
public function clearScripts()
{
$this->_content['head']['script'] = array();
return $this;
}
protected function _setStylesheets(array $list, $critical)
{
$this->_clearStylesheets($critical);
$this->_addStylesheets($list, $critical);
return $this;
}
public function addCriticalStylesheets(array $list)
{
return $this->_addStylesheets($list, true);
}
public function addNonCriticalStylesheets(array $list)
{
return $this->_addStylesheets($list, false);
}
protected function _addStylesheets(array $list, $critical)
{
foreach ($list as $options) {
if (is_array($options)) {
if ($critical) {
call_user_func_array(array($this, 'addCriticalStylesheet'), $options);
} else {
call_user_func_array(array($this, 'addNonCriticalStylesheet'), $options);
}
} else {
$this->_addStylesheet($options, [], $critical);
}
}
return $this;
}
public function setCriticalStylesheets(array $list)
{
return $this->_setStylesheets($list, true);
}
public function setNonCriticalStylesheets(array $list)
{
return $this->_setStylesheets($list, false);
}
public function addCriticalStylesheet($href, $attribs = array())
{
return $this->_addStylesheet($href, $attribs, true);
}
public function addNonCriticalStylesheet($href, $attribs = array())
{
return $this->_addStylesheet($href, $attribs, false);
}
public function _addStylesheet($href, $_attribs = array(), $critical)
{
$attribs = array(
'href' => $href,
'media' => 'all',
'type' => 'text/css',
'rel' => 'stylesheet',
);
if (strncmp($href, 'css/', 4) == 0) {
$key = substr($href, 4);
$key = str_replace('.css', '', $key);
} else {
$key = $href;
}
$section = $critical ? 'criticalStylesheet' : 'nonCriticalStylesheet';
if (isset($this->_content['head'][$section][$key])) {
return $this;
}
if ($critical && isset($this->_content['head']['nonCriticalStylesheet'][$key])) {
unset($this->_content['head']['nonCriticalStylesheet'][$key]);
}
$this->_content['head'][$section][$key] = array_merge($attribs, $_attribs);
return $this;
}
public function getStylesheetRenderType()
{
return $this->_stylesheetRenderType;
}
public function setStylesheetRenderType($type)
{
$this->_stylesheetRenderType = $type;
return $this;
}
public function addLink($href, $attribs = [])
{
$this->_content['head']['link'][] = array_merge(compact('href'), $attribs);
return $this;
}
public function setScripts(array $list)
{
$this->clearScripts();
$this->addScripts($list);
return $this;
}
public function addScripts(array $list)
{
foreach ($list as $options) {
if (is_array($options)) {
call_user_func_array(array($this, 'addScript'), $options);
} else {
$this->addScript($options);
}
}
return $this;
}
public function addScript($src, $_attribs = array(), $name = null)
{
$attribs = array(
'src' => $src, // Tag