/**
  * 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();
     }
     if (!$context->language->defined()) {
         $languageId = $context->publication->default_language->number;
     } else {
         $languageId = $context->language->number;
     }
     $contextBox = new ContextBox(null, $context->article->number);
     $p_parameters['context_box'] = $contextBox->getId();
     $p_parameters['article'] = $context->article->number;
     $BoxArticlesList = ContextBoxArticle::GetList($p_parameters, $this->m_order, $p_start, $p_limit, $p_count);
     $preview = $context->preview;
     $metaBoxArticlesList = array();
     foreach ($BoxArticlesList as $articleNo) {
         $article = new MetaArticle($languageId, $articleNo);
         if ($article->defined() && ($preview || $article->is_published)) {
             $metaBoxArticlesList[] = $article;
         }
     }
     return $metaBoxArticlesList;
 }
Exemple #2
0
 /**
  * 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)
 {
     $doctrine = Zend_Registry::get('container')->getService('doctrine');
     if (!$doctrine) {
         return false;
     }
     $repo = $doctrine->getManager()->getRepository('Newscoop\\Entity\\Playlist');
     /* @var $repo \Newscoop\Entity\Repository\PlaylistRepository */
     // get playlist
     if (isset($p_parameters['name']) && trim($p_parameters['name'])) {
         $playlist = current($repo->findBy(array("name" => $p_parameters['name'])));
     }
     if (isset($p_parameters['id']) && trim($p_parameters['id']) != "") {
         $playlist = $repo->find($p_parameters['id']);
     }
     if (!$playlist instanceof \Newscoop\Entity\Playlist) {
         return array();
     }
     $length = null;
     if (isset($p_parameters['length']) && trim($p_parameters['length']) != "") {
         $length = $p_parameters['length'];
     }
     $start = null;
     if (isset($p_parameters['start']) && trim($p_parameters['start']) != "") {
         $start = $p_parameters['start'];
     }
     $context = CampTemplate::singleton()->context();
     $langRepo = $doctrine->getManager()->getRepository('Newscoop\\Entity\\Language');
     /* @var $langRepo \Newscoop\Entity\Repository\LanguageRepository */
     $languageId = $context->language->number;
     $lang = $langRepo->find($context->language->number);
     $preview = $context->preview;
     $articlesList = $repo->articles($playlist, $lang, false, $length, $start, !$preview);
     $metaArticlesList = array();
     foreach ($articlesList as $article) {
         $metaArticle = new MetaArticle($lang->getId(), $article['articleId']);
         if ($metaArticle->defined() && ($metaArticle->is_published || $preview && $metaArticle->section->defined() && $metaArticle->issue->defined())) {
             $metaArticlesList[] = $metaArticle;
         }
     }
     $p_count = $repo->articlesCount($playlist, $lang, !$preview);
     return $metaArticlesList;
 }
Exemple #3
0
 /**
  * Handler for the article change event.
  *
  * @param MetaArticle $p_oldArticle
  * @param MetaArticle $p_newArticle
  */
 private function setArticleHandler(MetaArticle $p_oldArticle, MetaArticle $p_newArticle)
 {
     static $articleHandlerRunning = false;
     if (!$this->m_readonlyProperties['preview'] && (!$p_newArticle->is_published || !$p_newArticle->issue->is_published) && $p_newArticle->defined()) {
         return;
     }
     if ($articleHandlerRunning || $p_newArticle->same_as($p_oldArticle)) {
         return;
     }
     $articleHandlerRunning = true;
     if ($p_newArticle->defined() && !$this->getSection()->same_as($p_newArticle->section)) {
         $this->setSectionHandler($this->getSection(), $p_newArticle->section);
     }
     unset($this->m_objects['subtitle']);
     unset($this->m_objects['image']);
     unset($this->m_objects['attachment']);
     unset($this->m_objects['comment']);
     unset($this->m_objects['location']);
     $this->m_readonlyProperties['url']->article = $p_newArticle;
     $formParameters = $this->m_readonlyProperties['url']->form_parameters;
     foreach ($formParameters as $parameter) {
         if (strncmp($parameter['name'], 'st-', strlen('st-')) == 0) {
             $this->m_readonlyProperties['url']->reset_parameter($parameter['name']);
         }
     }
     $this->m_objects['article'] = $p_newArticle;
     $articleHandlerRunning = false;
 }
 /**
  * Sets the URL values
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void|PEAR_Error
  */
 private function setURL(Zend_Controller_Request_Abstract $request)
 {
     $this->setQueryVar('acid', null);
     $this->m_publication = $this->_getPublication();
     $controller = $request->getParam('controller');
     if ($controller != 'index') {
         if ($controller == 'legacy' && $request->getParam('language') == false) {
             $publication_service = \Zend_Registry::get('container')->getService('newscoop.publication_service');
             $language = $publication_service->getPublication()->getLanguage()->getCode();
         }
         if ($request->getParam('language') !== false) {
             $language = $request->getParam('language');
         } else {
             $language = $controller;
         }
     } else {
         $language = $request->getParam('language');
     }
     if ($request->getParam('webcode')) {
         if (!empty($language)) {
             $webcodeLanguageId = Language::GetLanguageIdByCode($language);
         } else {
             $webcodeLanguageId = $this->m_publication->default_language->number;
         }
         $webcode = trim(trim($request->getParam('webcode'), '@+'));
         $article = Zend_Registry::get('container')->getService('webcode')->findArticleByWebcode($webcode);
         $article_no = null;
         if ($article) {
             $article_no = $article->getNumber();
             $webcodeLanguageId = $article->getLanguageId();
         }
         $metaArticle = new MetaArticle($webcodeLanguageId, $article_no);
         $this->m_article = $metaArticle;
         if ($metaArticle->defined()) {
             $this->m_language = $this->m_article->language;
             $this->m_publication = $this->m_article->publication;
         } else {
             $this->m_language = $this->_getLanguage($metaArticle->language, $this->m_publication);
         }
         $this->m_issue = $this->m_article->issue;
         $this->m_section = $this->m_article->section;
     } else {
         $this->m_language = $this->_getLanguage($language, $this->m_publication);
         $this->m_issue = $this->_getIssue($request->getParam('issue'), $this->m_language, $this->m_publication);
         $this->m_section = $this->_getSection($request->getParam('section'), $this->m_issue, $this->m_language, $this->m_publication);
         $this->m_article = $this->_getArticle($request->getParam('articleNo'), $this->m_language);
     }
     $this->m_template = $this->_getTemplate();
 }