Inheritance: extends MetaDbObject
Exemplo n.º 1
1
 /**
  * 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;
 }
Exemplo n.º 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;
 }
 /**
  * Returns the content of the given subtitles of the article body field.
  *
  * @param array $p_subtitles
  * @return string
  */
 private function getContent(array $p_subtitles = array())
 {
     global $Campsite;
     $printAll = count($p_subtitles) == 0;
     $content = '';
     foreach ($this->m_subtitles as $index => $subtitle) {
         if (!$printAll && array_search($index, $p_subtitles) === false) {
             continue;
         }
         $content .= $index > 0 ? $subtitle->formatted_name : '';
         $content .= $subtitle->content;
     }
     if ($this->m_articleTypeField->isContent()) {
         $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
         $cacheKeyObjectType = $cacheService->getCacheKey(array('ObjectType', 'article'), 'ObjectType');
         if ($cacheService->contains($cacheKeyObjectType)) {
             $objectType = $cacheService->fetch($cacheKeyObjectType);
         } else {
             $objectType = new ObjectType('article');
             $cacheService->save($cacheKeyObjectType, $objectType);
         }
         $requestObjectId = $this->m_parent_article->getProperty('object_id');
         $updateArticle = empty($requestObjectId);
         try {
             if ($updateArticle) {
                 $requestObject = new RequestObject($requestObjectId);
                 if (!$requestObject->exists()) {
                     $requestObject->create(array('object_type_id' => $objectType->getObjectTypeId()));
                     $requestObjectId = $requestObject->getObjectId();
                 }
                 $this->m_parent_article->setProperty('object_id', $requestObjectId);
             }
             // statistics shall be only gathered if the site admin set it on (and not for editor previews)
             $context = CampTemplate::singleton()->context();
             $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service');
             if ($preferencesService->CollectStatistics == 'Y' && !$context->preview) {
                 $stat_web_url = $Campsite['WEBSITE_URL'];
                 if ('/' != $stat_web_url[strlen($stat_web_url) - 1]) {
                     $stat_web_url .= '/';
                 }
                 $article_number = $this->m_parent_article->getProperty('Number');
                 $language_obj = new MetaLanguage($this->m_parent_article->getProperty('IdLanguage'));
                 $language_code = $language_obj->Code;
                 $name_spec = '_' . $article_number . '_' . $language_code;
                 $object_type_id = $objectType->getObjectTypeId();
                 $content .= Statistics::JavaScriptTrigger(array('name_spec' => $name_spec, 'object_type_id' => $object_type_id, 'request_object_id' => $requestObjectId));
             }
         } catch (Exception $ex) {
             $content .= "<p><strong><font color=\"red\">INTERNAL ERROR! " . $ex->getMessage() . "</font></strong></p>\n";
             // do something
         }
     }
     return $content;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
0
    } else {
        $contentType = 'content';
        $isContentField = 'false';
        $setContentField = 'true';
    }
    if ($field->showInEditor()) {
        $editorType = 'not displayed in editor';
        $showInEditor = 'true';
        $setShowInEditor = 'false';
    } else {
        $editorType = 'displayed in editor';
        $showInEditor = 'false';
        $setShowInEditor = 'true';
    }
    $fieldName = $field->getPrintName();
    $article = new MetaArticle();
    if ($article->has_property($fieldName) || method_exists($article, $fieldName)) {
        $duplicateFieldName = true;
        $duplicateFieldsCount++;
    } else {
        $duplicateFieldName = false;
    }
    ?>



<TR <?php 
    if ($color) {
        $color = 0;
        ?>
class="list_row_even"<?php 
Exemplo n.º 6
0
 /**
  * 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();
 }