/** * Constructor * * @param string $p_content */ public function __construct($p_content, MetaArticle $p_parent, $p_fieldName, $p_articleName, $p_subtitleNumber = null, $p_headerFormatStart = null, $p_headerFormatEnd = null) { $this->m_subtitleNumber = $p_subtitleNumber; $this->m_subtitles = MetaSubtitle::ReadSubtitles($p_content, $p_fieldName, $p_articleName, $p_headerFormatStart, $p_headerFormatEnd); $this->m_sutitlesNames = array(); foreach ($this->m_subtitles as $subtitle) { $this->m_sutitlesNames[] = $subtitle->name; } $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheKeyArticle = $cacheService->getCacheKey(array('Article', $p_parent->language->number, $p_parent->number), 'article'); if ($cacheService->contains($cacheKeyArticle)) { $this->m_parent_article = $cacheService->fetch($cacheKeyArticle); } else { $this->m_parent_article = new Article($p_parent->language->number, $p_parent->number); $cacheService->save($cacheKeyArticle, $this->m_parent_article); } $this->m_fieldName = $p_fieldName; $cacheKey = $cacheService->getCacheKey(array('ArticleTypeField', $p_parent->type_name, $p_fieldName), 'article_type'); if ($cacheService->contains($cacheKey)) { $this->m_articleTypeField = $cacheService->fetch($cacheKey); } else { $articleTypeField = new ArticleTypeField($p_parent->type_name, $p_fieldName); $cacheService->save($cacheKey, $articleTypeField); $this->m_articleTypeField = $articleTypeField; } }
/** * Constructor * * @param string $p_content */ public function __construct($p_content, MetaArticle $p_parent, $p_fieldName, $p_articleName, $p_subtitleNumber = null, $p_headerFormatStart = null, $p_headerFormatEnd = null) { $this->m_subtitleNumber = $p_subtitleNumber; $this->m_subtitles = MetaSubtitle::ReadSubtitles($p_content, $p_fieldName, $p_articleName, $p_headerFormatStart, $p_headerFormatEnd); $this->m_sutitlesNames = array(); foreach ($this->m_subtitles as $subtitle) { $this->m_sutitlesNames[] = $subtitle->name; } $this->m_parent_article = new Article($p_parent->language->number, $p_parent->number); $this->m_fieldName = $p_fieldName; $this->m_articleTypeField = new ArticleTypeField($p_parent->type_name, $p_fieldName); }
/** * Creates the list of objects. Sets the parameter $p_hasNextElements to * true if this list is limited and elements still exist in the original * list (from which this was truncated) after the last element of this * list. * * @param int $p_start * @param int $p_limit * @param array $p_parameters * @param int &$p_count * @return array */ protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count) { $context = CampTemplate::singleton()->context(); if (!$context->article->defined) { return array(); } $articleData = new ArticleData($context->article->type_name, $context->article->number, $context->language->number); $customFields = $articleData->getUserDefinedColumns(); $fieldValue = null; foreach ($customFields as $customField) { if (strtolower($customField->getPrintName()) == strtolower($p_parameters['field_name'])) { $p_parameters['field_name'] = $customField->getPrintName(); $fieldValue = $articleData->getProperty('F' . $p_parameters['field_name']); break; } } if (is_null($fieldValue)) { return array(); } $subtitles = MetaSubtitle::ReadSubtitles($fieldValue, $p_parameters['field_name'], $context->article->name); $p_count = count($subtitles); return $p_limit !== 0 ? array_slice($subtitles, $p_start, $p_limit) : array_slice($subtitles, $p_start); }