/** * 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; }
/** * Remove the context box for the given article. * @param int $articleNumber * @return void */ public static function OnArticleDelete($articleNumber) { global $g_ado_db; $articleNumber = (int) $articleNumber; if ($articleNumber < 1) { return; } $queryStr = 'SELECT * FROM context_boxes' . " WHERE fk_article_no = '{$articleNumber}'"; $boxes = $g_ado_db->GetAll($queryStr); foreach ($boxes as $box) { ContextBoxArticle::OnContextBoxDelete($box['id']); } $queryStr = 'DELETE FROM context_boxes' . " WHERE fk_article_no = '{$articleNumber}'"; $g_ado_db->Execute($queryStr); }
$args = array_merge($_REQUEST, $f_params); $argsStr = camp_implode_keys_and_values($args, "=", "&"); $argsStr .= '&f_language_selected=' . (int) camp_session_get('f_language_selected', 0); foreach ($flatArticleCodes as $articleCode) { $argsStr .= '&f_article_code[]=' . $articleCode; } return returnJson(0, '', 0, '', $Campsite['WEBSITE_URL'] . "/admin/articles/multi_autopublish.php?" . $argsStr); break; case 'context_box_update': $contextContent = prepareContextBoxItems($f_params); $articleObj = new Article($f_language_selected, $contextContent['f_article_id']); if ($articleObj->userCanModify($g_user)) { $contextBoxObj = new ContextBox(null, $contextContent['f_article_id']); $contextId = $contextBoxObj->getId(); $relatedItems = array_filter($contextContent['f_related_items'], 'is_numeric'); ContextBoxArticle::saveList($contextId, $relatedItems); $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('boxarticles'); } return json_encode(array(200)); break; case 'context_box_preview_article': $return = array(); foreach ($_REQUEST['args'] as $arg) { if (is_array($arg) && isset($arg['langId'])) { $f_language_selected = $arg['langId']; } } $articleId = $f_params['articleId']; if (!is_numeric($articleId)) { $articleIdArray = explode('_', $articleId);
/** * 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; }