/** * Simple initialisation method * */ public function init() { if (self::$cs) { Sobi::Error('config', SPLang::e('CRITICAL_SECTION_VIOLATED'), SPC::ERROR, 500, __LINE__, __CLASS__); } /* define critical section to avoid infinite loops */ self::$cs = true; $nameField = self::key('entry.name_field'); if ($nameField) { $fc = SPLoader::loadModel('field'); $field = new $fc(); $field->init($nameField); $this->set('name_field_nid', $field->get('nid'), 'entry'); $this->set('name_field_id', $field->get('fid'), 'entry'); } if (defined('SOBIPRO_ADM')) { if (self::key('language.adm_domain')) { SPLang::registerDomain(self::key('language.adm_domain')); } } else { if (self::key('language.domain')) { SPLang::registerDomain(self::key('language.domain')); } } /* set allowed request attributes and tags */ SPRequest::setTagsAllowed($this->key('html.allowed_tags_array')); SPRequest::setAttributesAllowed($this->key('html.allowed_attributes_array')); $this->_store['general']['root'] = SOBI_ROOT; $this->_store['general']['path'] = SOBI_PATH; $this->_store['general']['cms'] = SOBI_CMS; $this->_store['general']['live_path'] = SOBI_LIVE_PATH; /* leave critical section */ self::$cs = false; }
/** * @param string $task */ function __construct($task) { SPLoader::loadClass('base.exception'); set_error_handler('SPExceptionHandler'); $this->_err = ini_set('display_errors', 'on'); $this->_mem = memory_get_usage(); $this->_time = microtime(); $this->_task = $task; /* load all needed classes */ SPLoader::loadClass('base.factory'); SPLoader::loadClass('base.object'); SPLoader::loadClass('base.const'); SPLoader::loadClass('base.filter'); SPLoader::loadClass('base.request'); SPLoader::loadClass('sobi'); SPLoader::loadClass('base.config'); /* authorise access */ $this->checkAccess(); /* initialise mainframe interface to CMS */ $this->_mainframe =& SPFactory::mainframe(); /* get sid if any */ $this->_sid = SPRequest::sid(); /* determine section */ $this->getSection(); /* initialise config */ $this->createConfig(); ini_set('display_errors', Sobi::Cfg('debug.display_errors', false)); $this->_deb = error_reporting(Sobi::Cfg('debug.level', 0)); /* trigger plugin */ Sobi::Trigger('AdminStart'); /* initialise translator and load language files */ SPLoader::loadClass('cms.base.lang'); SPLang::setLang(Sobi::Lang()); try { SPLang::registerDomain('admin'); } catch (SPException $x) { Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } /* load admin html files */ SPFactory::header()->initBase(true); /** @noinspection PhpParamsInspection */ if ($this->_section) { $sectionName = SPLang::translateObject($this->_section, 'name', 'section'); SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value'])); } if ($this->_section && !Sobi::Cfg('section.template')) { SPFactory::config()->set('template', SPC::DEFAULT_TEMPLATE, 'section'); } /* check if it wasn't plugin custom task */ if (!Sobi::Trigger('custom', 'task', array($this, SPRequest::task()))) { /* if not, start to route */ try { $this->route(); } catch (SPException $x) { Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } } return true; }
/** * @param string $task * @return \SobiProCtrl */ function __construct($task) { $this->_mem = memory_get_usage(); $this->_time = microtime(true); SPLoader::loadClass('base.exception'); set_error_handler('SPExceptionHandler'); $this->_err = ini_set('display_errors', 'on'); $this->_task = $task; /* load all needed classes */ SPLoader::loadClass('base.const'); SPLoader::loadClass('base.factory'); SPLoader::loadClass('base.object'); SPLoader::loadClass('base.filter'); SPLoader::loadClass('base.request'); SPLoader::loadClass('sobi'); SPLoader::loadClass('base.config'); SPLoader::loadClass('cms.base.lang'); /* get sid if any */ $this->_sid = SPRequest::sid(); /* determine section */ $access = $this->getSection(); /* initialise mainframe interface to CMS */ $this->_mainframe = SPFactory::mainframe(); /* initialise config */ $this->createConfig(); ini_set('display_errors', Sobi::Cfg('debug.display_errors', false)); $this->_deb = error_reporting(Sobi::Cfg('debug.level', 0)); /* trigger plugin */ Sobi::Trigger('Start'); /* initialise translator and load language files */ SPLang::setLang(Sobi::Lang(false)); try { SPLang::registerDomain('site'); } catch (SPException $x) { Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__); } if (!$access) { if (Sobi::Cfg('redirects.section_enabled', false)) { $redirect = Sobi::Cfg('redirects.section_url', null); $msg = Sobi::Cfg('redirects.section_msg', SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task())); $msgtype = Sobi::Cfg('redirects.section_msgtype', 'message'); Sobi::Redirect(Sobi::Url($redirect), Sobi::Txt($msg), $msgtype, true); } else { SPFactory::mainframe()->runAway('You have no permission to access this site', 403, null, true); } } /* load css and js files */ SPFactory::header()->initBase(); $sectionName = SPLang::translateObject($this->_section, 'name', 'section'); if ($this->_section) { SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value'])); } $start = array($this->_mem, $this->_time); SPFactory::registry()->set('start', $start); /* check if it wasn't plugin custom task */ if (!Sobi::Trigger('custom', 'task', array(&$this, SPRequest::task()))) { /* if not, start to route */ try { $this->route(); } catch (SPException $x) { if (defined('SOBI_TESTS')) { Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__); } else { SPFactory::mainframe()->setRedirect(Sobi::Reg('live_site'), SPLang::e('PAGE_NOT_FOUND'), SPC::ERROR_MSG, true); } } } return true; }