CampContext::__construct PHP Method

__construct() final public method

Class constructor
final public __construct ( )
    public final function __construct()
    {
        global $Campsite, $controller;
        if (!is_null($this->m_properties)) {
            return;
        }
        $this->login_action = (object) array('is_error' => false, 'error_message' => '');
        self::$m_nullMetaArticle = new MetaArticle();
        self::$m_nullMetaSection = new MetaSection();
        // LEGACY PLUGINS
        // register plugin objects and listobjects
        foreach (CampPlugin::GetPluginsInfo(true) as $info) {
            if (is_array($info['template_engine']['objecttypes'])) {
                foreach ($info['template_engine']['objecttypes'] as $objecttype) {
                    $this->registerObjectType($objecttype);
                }
            }
            if (is_array($info['template_engine']['listobjects'])) {
                foreach ($info['template_engine']['listobjects'] as $listobject) {
                    $this->registerListObject($listobject);
                }
            }
        }
        // Register new plugins system list objects
        $pluginsService = \Zend_Registry::get('container')->get('newscoop.plugins.service');
        $collectedData = $pluginsService->collectListObjects();
        $this->m_listObjects = array_merge($collectedData['listObjects'], $this->m_listObjects);
        CampContext::$m_objectTypes = array_merge($collectedData['objectTypes'], CampContext::$m_objectTypes);
        $this->m_properties['htmlencoding'] = false;
        $this->m_properties['subs_by_type'] = null;
        $this->m_readonlyProperties['version'] = $Campsite['VERSION'];
        $this->m_readonlyProperties['current_list'] = null;
        $this->m_readonlyProperties['lists'] = array();
        $this->m_readonlyProperties['prev_list_empty'] = null;
        $this->m_readonlyProperties['default_url'] = new MetaURL();
        $this->m_readonlyProperties['url'] = new MetaURL();
        if (!$this->m_readonlyProperties['default_url']->is_valid) {
            if (!$this->m_readonlyProperties['url']->language->defined) {
                $this->m_readonlyProperties['url']->language = $this->m_readonlyProperties['url']->publication->default_language;
                $this->m_readonlyProperties['default_url'] = $this->m_readonlyProperties['url'];
            }
        }
        $this->m_objects['user'] = $this->m_readonlyProperties['url']->user;
        $this->m_readonlyProperties['preview'] = $this->m_readonlyProperties['url']->preview;
        if (!$this->m_readonlyProperties['preview']) {
            if (!$this->m_readonlyProperties['url']->article->is_published) {
                $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
                $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
            }
            if (!$this->m_readonlyProperties['url']->issue->is_published) {
                $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle;
                $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle;
                $this->m_readonlyProperties['default_url']->section = self::$m_nullMetaSection;
                $this->m_readonlyProperties['url']->section = self::$m_nullMetaSection;
                $this->m_readonlyProperties['default_url']->issue = new MetaIssue();
                $this->m_readonlyProperties['url']->issue = new MetaIssue();
            }
        }
        $this->m_objects['publication'] = $this->m_readonlyProperties['url']->publication;
        $this->m_objects['language'] = $this->m_readonlyProperties['url']->language;
        $this->m_objects['issue'] = $this->m_readonlyProperties['url']->issue;
        $this->m_objects['section'] = $this->m_readonlyProperties['url']->section;
        $this->m_objects['article'] = $this->m_readonlyProperties['url']->article;
        $this->m_objects['template'] = $this->m_readonlyProperties['url']->template;
        if (is_numeric($this->m_readonlyProperties['url']->get_parameter('tpid'))) {
            $this->m_objects['topic'] = new MetaTopic($this->m_readonlyProperties['url']->get_parameter('tpid'), $this->m_readonlyProperties['url']->language->code);
        }
        $this->m_readonlyProperties['default_template'] = $this->m_objects['template'];
        $this->m_readonlyProperties['default_language'] = $this->m_objects['language'];
        $this->m_readonlyProperties['default_publication'] = $this->m_objects['publication'];
        $this->m_readonlyProperties['default_issue'] = $this->m_objects['issue'];
        $this->m_readonlyProperties['default_section'] = $this->m_objects['section'];
        $this->m_readonlyProperties['default_article'] = $this->m_objects['article'];
        $this->m_readonlyProperties['default_topic'] = $this->topic;
        if (!is_null($commentId = CampRequest::GetVar('acid'))) {
            $this->m_objects['comment'] = new MetaComment($commentId);
        }
        $this->m_readonlyProperties['request_action'] = MetaAction::CreateAction(CampRequest::GetInput(CampRequest::GetMethod()));
        $requestActionName = $this->m_readonlyProperties['request_action']->name;
        $runAction = true;
        if ($requestActionName == 'submit_comment' && $pluginsService->isInstalled('terwey/plugin-newscoop-comments')) {
            $runAction = false;
        }
        if ($requestActionName != 'default' && $runAction) {
            $this->m_readonlyProperties['request_action']->takeAction($this);
        }
        foreach (MetaAction::ReadAvailableActions() as $actionName => $actionAttributes) {
            $propertyName = $actionName . '_action';
            if ($requestActionName == $actionName) {
                $this->m_readonlyProperties[$propertyName] =& $this->m_readonlyProperties['request_action'];
            } else {
                $this->m_readonlyProperties[$propertyName] = MetaAction::DefaultAction();
            }
        }
        // Initialize the default comment attribute at the end, after the
        // submit comment action had run.
        $this->m_readonlyProperties['default_comment'] = $this->comment;
        // add browser info
        $this->m_readonlyProperties['browser'] = new Browser();
        // initialize plugins
        foreach (CampPlugin::GetPluginsInfo(true) as $info) {
            if (function_exists($info['template_engine']['init'])) {
                $plugin_init = $info['template_engine']['init'];
                $plugin_init($this);
            }
        }
        // initialize geo-map holders
        $this->m_properties['map_dynamic_constraints'] = null;
        $this->m_properties['map_dynamic_areas'] = null;
        $this->m_properties['map_dynamic_max_points'] = 0;
        $this->m_properties['map_dynamic_tot_points'] = 0;
        $this->m_properties['map_dynamic_points_raw'] = null;
        $this->m_properties['map_dynamic_points_objects'] = null;
        $this->m_properties['map_dynamic_meta_article_objects'] = null;
        $this->m_properties['map_dynamic_map_label'] = "";
        $this->m_properties['map_dynamic_id_counter'] = 0;
        $this->m_properties['map_common_header_set'] = false;
        $flashMessenger = new \Newscoop\Controller\Helper\FlashMessenger();
        $this->flash_messages = $flashMessenger->getMessages();
    }