MetaAction::ReadAvailableActions PHP Method

ReadAvailableActions() public static method

Searches for classes that process actions. Returns an array of action names.
public static ReadAvailableActions ( ) : array
return array
    public static function ReadAvailableActions()
    {
        if (is_array(MetaAction::$m_availableActions)) {
            return MetaAction::$m_availableActions;
        }
        if (self::FetchActionsFromCache()) {
            return self::$m_availableActions;
        }
        $actions = array();
        $basePaths = array('.');
        foreach (CampPlugin::GetEnabled() as $CampPlugin) {
            $basePaths[] = $CampPlugin->getBasePath();
        }
        foreach ($basePaths as $basePath) {
            $directoryPath = $GLOBALS['g_campsiteDir'] . '/' . $basePath . '/template_engine/metaclasses';
            $actionIncludeFiles = glob(realpath($directoryPath) . '/MetaAction*.php');
            foreach ((array) $actionIncludeFiles as $includeFile) {
                if (preg_match('/MetaAction([^.]+)\\.php/', $includeFile, $matches) == 0 || strtolower($matches[1]) == 'request') {
                    continue;
                }
                require_once $includeFile;
                $actionName = $matches[1];
                if (class_exists('MetaAction' . $actionName)) {
                    $actions[self::TranslateProperty($actionName)] = array('name' => $actionName, 'file' => "{$directoryPath}/MetaAction{$actionName}.php");
                }
            }
        }
        self::$m_availableActions = $actions;
        self::StoreActionsInCache();
        return self::$m_availableActions;
    }

Usage Example

Beispiel #1
0
 /**
  * Class constructor
  */
 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['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();
 }
All Usage Examples Of MetaAction::ReadAvailableActions