CampSystem::GetIssueTemplate PHP Метод

GetIssueTemplate() публичный статический Метод

public static GetIssueTemplate ( $p_lngId, $p_pubId, $p_issNr )
    public static function GetIssueTemplate($p_lngId, $p_pubId, $p_issNr)
    {
        global $g_ado_db;
        $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
        $cacheKey = $cacheService->getCacheKey(array('GetIssueTemplate', $p_lngId, $p_pubId, $p_issNr), 'issue');
        if ($cacheService->contains($cacheKey)) {
            return $cacheService->fetch($cacheKey);
        } else {
            $resourceId = new ResourceId('template_engine/classes/CampSystem');
            $outputService = $resourceId->getService(IOutputService::NAME);
            if (!\Zend_Registry::isRegistered('webOutput')) {
                $cacheKeyWebOutput = $cacheService->getCacheKey(array('OutputService', 'Web'), 'outputservice');
                if ($cacheService->contains($cacheKeyWebOutput)) {
                    \Zend_Registry::set('webOutput', $cacheService->fetch($cacheKeyWebOutput));
                } else {
                    $webOutput = $outputService->findByName('Web');
                    $cacheService->save($cacheKeyWebOutput, $webOutput);
                    \Zend_Registry::set('webOutput', $webOutput);
                }
            }
            /* @var $templateSearchService ITemplateSearchService */
            $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME);
            $issueObj = new Issue($p_pubId, $p_lngId, $p_issNr);
            $data = $templateSearchService->getFrontPage($issueObj->getIssueId(), \Zend_Registry::get('webOutput'));
            if (empty($data)) {
                $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId);
            }
            $cacheService->save($cacheKey, $data);
            return $data;
        }
    }

Usage Example

Пример #1
0
    /**
     * Sets the URI path and query values based on given parameters.
     *
     * @param array $p_params
     *      An array of valid URL parameters
     * @param boolean $p_preview
     *      If true, will keep the preview parameters in the URL
     *
     * @return void
     */
    protected function buildURI(array &$p_params = array(), $p_preview = false)
    {
        if ($this->isValidCache()) {
            return;
        }

        $parameter = count($p_params) > 0 ? strtolower(array_shift($p_params)) : null;

        switch ($parameter) {
            case 'language':
                $this->m_buildPath = $this->buildPath(CampSystem::GetTemplate($this->m_language->number,
                $this->m_publication->identifier));
                $keepParams = CampURITemplatePath::$m_languageParameters;
                if ($p_preview) {
                    $keepParams = array_merge(CampURI::$m_previewParameters, $keepParams);
                }
                $this->m_buildQueryArray = $this->getQueryArray($keepParams);
                $p_params = array();
                break;
            case 'publication':
                $this->m_buildPath = $this->buildPath(CampSystem::GetTemplate($this->m_language->number,
                $this->m_publication->identifier));
                $keepParams = CampURITemplatePath::$m_languageParameters;
                if ($p_preview) {
                    $keepParams = array_merge(CampURI::$m_previewParameters, $keepParams);
                }
                $this->m_buildQueryArray = $this->getQueryArray($keepParams);
                $p_params = array();
                break;
            case 'issue':
                $this->m_buildPath = $this->buildPath(CampSystem::GetIssueTemplate($this->m_language->number,
                $this->m_publication->identifier, $this->m_issue->number));
                $keepParams = CampURITemplatePath::$m_issueParameters;
                if ($p_preview) {
                    $keepParams = array_merge(CampURI::$m_previewParameters, $keepParams);
                }
                $this->m_buildQueryArray = $this->getQueryArray($keepParams);
                $p_params = array();
                break;
            case 'section':
                $this->m_buildPath = $this->buildPath(CampSystem::GetSectionTemplate($this->m_language->number,
                $this->m_publication->identifier, $this->m_issue->number, $this->m_section->number));
                $keepParams = CampURITemplatePath::$m_sectionParameters;
                if ($p_preview) {
                    $keepParams = array_merge(CampURI::$m_previewParameters, $keepParams);
                }
                $this->m_buildQueryArray = $this->getQueryArray($keepParams);
                $p_params = array();
                break;
            case 'article':
                $this->m_buildPath = $this->buildPath(CampSystem::GetArticleTemplate($this->m_language->number,
                $this->m_publication->identifier, $this->m_issue->number, $this->m_section->number));
                $keepParams = CampURITemplatePath::$m_articleParameters;
                if ($p_preview) {
                    $keepParams = array_merge(CampURI::$m_previewParameters, $keepParams);
                }
                $this->m_buildQueryArray = $this->getQueryArray($keepParams);
                $p_params = array();
                break;
            case 'template':
                $option = isset($p_params[0]) ? array_shift($p_params) : null;
                if (!is_null($option) && $this->isValidTemplate($option)) {
                    $this->m_buildPath = $this->buildPath($option);
                }
                break;
            default:
                if (!empty($parameter)) {
                    array_unshift($p_params, $parameter);
                    $count = count($p_params);
                    parent::buildURI($p_params, $p_preview);
                    if (count($p_params) == $count) {
                        array_shift($p_params);
                    }
                }
        }

        if (count($p_params) > 0) {
            $this->buildURI($p_params);
        }

        if (is_null($this->m_buildPath)) {
        	$template = $this->getTemplate();
            if (empty($template)) {
                CampTemplate::singleton()->trigger_error('Invalid template in context');
                return;
            }
            $this->m_buildPath = $this->buildPath($template);
        }

        if (is_null($this->m_buildQuery)) {
            $this->m_buildQuery = CampURI::QueryArrayToString($this->m_buildQueryArray);
        }

        $this->validateCache(true);
    } // fn buildURI