/** * 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; }
public static function OnArticleCopy($origArticle, $destArticle) { global $g_ado_db; $contextBox = new ContextBox(null, $destArticle); $sql = 'SELECT ca.fk_article_no as article_number FROM context_boxes cb, context_articles ca WHERE cb.id = ca.fk_context_id AND cb.fk_article_no = ' . $origArticle; $rows = $g_ado_db->GetAll($sql); foreach ($rows as $row) { $sql = 'INSERT IGNORE INTO context_articles (fk_context_id, fk_article_no) ' . 'VALUES (' . $contextBox->getId() . ', ' . $row['article_number'] . ')'; $g_ado_db->Execute($sql); } }
$return['date'] = $articleObj->getCreationDate(); if (!array_key_exists('body', $return)) { $return['date'] = $articleObj->getCreationDate(); } $return['code'] = 200; return $return; break; case 'context_box_load_list': $return = array(); $items = array(); $articleId = $f_params['articleId']; if (!is_numeric($articleId)) { $articleIdArray = explode('_', $articleId); $articleId = $articleIdArray[1]; } $contextBoxObj = new ContextBox(null, $articleId); $contextId = $contextBoxObj->getId(); $contextArticleIds = $contextBoxObj->getArticlesList(); foreach ($contextArticleIds as $contextArticleId) { $articleObj = new Article($f_language_selected, $contextArticleId); $item['title'] = $articleObj->getTitle(); $item['articleId'] = 'article_' . $contextArticleId; $item['date'] = $articleObj->getCreationDate(); $item['status'] = $articleObj->getWorkflowDisplayString(); $items[] = $item; } $return['items'] = $items; $return['code'] = 200; return $return; break; }
/** * Delete article from database. This will * only delete one specific translation of the article. * * @return boolean */ public function delete() { // It is an optimization to put these here because in most cases // you dont need these files. require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleImage.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleTopic.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleIndex.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticleAttachment.php'; require_once $GLOBALS['g_campsiteDir'] . '/classes/ArticlePublish.php'; // Delete scheduled publishing ArticlePublish::OnArticleDelete($this->m_data['Number'], $this->m_data['IdLanguage']); $translator = \Zend_Registry::get('container')->getService('translator'); // Delete Article Comments // @todo change this with DOCTRINE2 CASCADE DELETE $em = Zend_Registry::get('container')->getService('em'); $repository = $em->getRepository('Newscoop\\Entity\\Comment'); $repository->deleteArticle($this->m_data['Number'], $this->m_data['IdLanguage']); $repository = $em->getRepository('Newscoop\\Entity\\ArticleDatetime'); $repository->deleteByArticle($this->m_data['Number']); $em->flush(); // is this the last translation? if (count($this->getLanguages()) <= 1) { // Delete image pointers ArticleImage::OnArticleDelete($this->m_data['Number']); // Delete topics pointers ArticleTopic::OnArticleDelete($this->m_data['Number']); // Delete file pointers ArticleAttachment::OnArticleDelete($this->m_data['Number']); // Delete related articles ContextBox::OnArticleDelete($this->m_data['Number']); ContextBoxArticle::OnArticleDelete($this->m_data['Number']); // Delete the article from playlists $em = Zend_Registry::get('container')->getService('em'); $repository = $em->getRepository('Newscoop\\Entity\\PlaylistArticle'); $repository->deleteArticle($this->m_data['Number']); $em->flush(); // Delete indexes ArticleIndex::OnArticleDelete($this->getPublicationId(), $this->getIssueNumber(), $this->getSectionNumber(), $this->getLanguageId(), $this->getArticleNumber()); } // geo-map processing // is this the last translation? if (count($this->getLanguages()) <= 1) { // unlink the article-map pointers Geo_Map::OnArticleDelete($this->m_data['Number']); } else { // removing non-last translation of the map poi contents Geo_Map::OnLanguageDelete($this->m_data['Number'], $this->m_data['IdLanguage']); } // Delete row from article type table. $articleData = new ArticleData($this->m_data['Type'], $this->m_data['Number'], $this->m_data['IdLanguage']); $articleData->delete(); $tmpObj = clone $this; // for log $tmpData = $this->m_data; $tmpData['languageName'] = $this->getLanguageName(); // Delete row from Articles table. $deleted = parent::delete(); if ($deleted) { $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('article'); Log::ArticleMessage($tmpObj, $translator->trans('Article deleted.', array(), 'api'), null, 32); } $this->m_cacheUpdate = true; return $deleted; }