/** * Publish entry * * @param Newscoop\Entity\Ingest\Feed\Entry $entry * @param string $status * @return Article */ public function publish(Entry $entry, $status = 'Y') { $article = new \Article($this->getLanguage($entry->getLanguage())); $article->create($this->config['article_type'], $entry->getTitle(), $this->getPublication(), $this->getIssue(), $this->getSection($entry)); $article->setWorkflowStatus(strpos($entry->getTitle(), self::PROGRAM_TITLE) === 0 ? 'N' : $status); $article->setKeywords($entry->getCatchWord()); $article->setCommentsEnabled(TRUE); $this->setArticleData($article, $entry); $this->setArticleDates($article, $entry); $this->setArticleAuthors($article, $entry); $this->setArticleImages($article, $entry->getImages()); $entry->setArticleNumber($article->getArticleNumber()); $article->commit(); return $article; }
function test_article() { $article = new Article(9000001,9000002,9000003,9000004); // Test create $article->create("Unit Test Long Name", "Unit Test Short Name", "fastnews"); $this->assertTrue($article->exists()); // Test SET functions $article->setTitle("Unit Test New Title"); $article->setCreatorId(9000005); $article->setOnFrontPage(true); $article->setOnSection(true); $article->setWorkflowStatus('Y'); $article->setKeywords("Unit, Test"); $article->setIsIndexed(true); // Test GET functions $articleCopy = new Article(9000001, 9000002, 9000003, 9000004, $article->getArticleId()); $this->assertEquals(9000001, $articleCopy->getPublicationId()); $this->assertEquals(9000002, $articleCopy->getIssueNumber()); $this->assertEquals(9000003, $articleCopy->getSectionNumber()); $this->assertEquals(9000004, $articleCopy->getLanguageId()); $this->assertEquals(9000005, $articleCopy->getCreatorId()); $this->assertEquals("Unit Test New Title", $articleCopy->getTitle()); $this->assertEquals(true, $articleCopy->onFrontPage()); $this->assertEquals(true, $articleCopy->onSection()); $this->assertEquals('Y', $articleCopy->getWorkflowStatus()); $this->assertEquals("Unit, Test", $articleCopy->getKeywords()); $this->assertEquals(true, $articleCopy->isIndexed()); // Test DELETE functions $article->delete(); $this->assertFalse($article->exists()); }
if (count($conflictingArticles) > 0) { $conflictingArticle = array_pop($conflictingArticles); $conflictingArticleLink = camp_html_article_url($conflictingArticle, $conflictingArticle->getLanguageId(), "edit.php"); camp_html_add_msg($translator->trans("The article could not be submitted.", array(), 'articles') . " " . $translator->trans("You cannot have two articles in the same section with the same name. The article name you specified is already in use by the article '\$1'.", array('$1' => "<a href='{$conflictingArticleLink}'>" . $conflictingArticle->getName() . "</a>"), 'articles')); $args = $_REQUEST; unset($args["action_button"]); unset($args["f_article_code"]); $argsStr = camp_implode_keys_and_values($args, "=", "&"); foreach ($_REQUEST["f_article_code"] as $code) { $argsStr .= "&f_article_code[]={$code}"; } $backLink = "/{$ADMIN}/articles/duplicate.php?{$argsStr}"; camp_html_goto_page($backLink); } else { $tmpArticle->move($f_destination_publication_id, $f_destination_issue_number, $f_destination_section_number); $tmpArticle->setWorkflowStatus('S'); \Zend_Registry::get('container')->getService('dispatcher')->dispatch('article.submit', new \Newscoop\EventDispatcher\Events\GenericEvent($this, array('article' => $tmpArticle))); $tmpArticles[] = $tmpArticle; } } } $tmpArticle = camp_array_peek($tmpArticles); if ($f_mode == "single") { $url = camp_html_article_url($tmpArticle, $tmpArticle->getLanguageId(), "edit.php"); } else { $url = $destArticleIndexUrl; } ArticleIndex::RunIndexer(3, 10, true); camp_html_goto_page($url); } }
camp_html_add_msg(getGS("Article status set to '\$1'", getGS("New")), "ok"); break; case "workflow_submit": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); // A user who owns the article may submit it. if ($g_user->hasPermission("Publish") || $articleObj->userCanModify($g_user)) { $articleObj->setWorkflowStatus('S'); } } camp_html_add_msg(getGS("Article status set to '\$1'", getGS("Submitted")), "ok"); break; case "workflow_publish": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); $articleObj->setWorkflowStatus('Y'); } camp_html_add_msg(getGS("Article status set to '\$1'", getGS("Published")), "ok"); break; case "delete": foreach ($articleCodes as $articleCode) { $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']); $articleObj->delete(); } if ($f_article_offset > 15 && count($articleCodes) + $f_article_offset == $f_total_articles) { $f_article_offset -= $ArticlesPerPage; } camp_html_add_msg(getGS("Article(s) deleted."), "ok"); break; case "toggle_front_page": foreach ($articleCodes as $articleCode) {
/** * Creates an legacy Article based on a feed entry * * @param \NewscoopIngestPluginBundle\Entity\Feed\Entry $entry * * @return \Article Returns legacy article opbject */ protected function createLegacy(\Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry) { $feed = $entry->getFeed(); $publication = $feed->getPublication(); // Determine issue if ($feed->getIssue() === null) { $issue = $this->em->getRepository('\\Newscoop\\Entity\\Issue')->findOneBy(array('publication' => $publication, 'language' => $entry->getLanguage(), 'workflowStatus' => 'Y'), array('number' => 'DESC')); } else { $issue = $feed->getIssue(); } $articleType = $this->em->getRepository('\\Newscoop\\Entity\\ArticleType')->findOneByName('Newswire'); $article = new \Article($entry->getLanguage()->getId()); $createSuccess = $article->create($articleType->getName(), $entry->getTitle(), $publication->getId(), $issue->getNumber(), $entry->getSection()->getNumber()); $article->setWorkflowStatus('N'); $article->setKeywords(implode(',', $entry->getKeywords())); $article->setCommentsEnabled(1); // ArticleType data $this->setArticleDataLegacy($article, $entry); // Dates $article->setCreationDate($entry->getCreated()->format('Y-m-d H:i:s')); $article->setProperty('time_updated', $entry->getUpdated()->format('Y-m-d H:i:s')); // Author $this->setArticleAuthorsLegacy($article, $entry); $this->setArticleImagesLegacy($article, $entry); try { $entry->setArticleId($article->getArticleNumber()); $articleAdded = $article->commit(); $this->em->persist($entry); $this->em->flush(); } catch (\Exception $e) { throw new Exception('Could not publish article.'); } // Topics $this->setArticleTopics($article->getArticleNumber(), $entry->getFeed()->getTopics()); return $article; }
/** * Execute the action, and mark the action as completed. * @return void */ public function doAction() { $publishAction = $this->getPublishAction(); $frontPageAction = $this->getFrontPageAction(); $sectionPageAction = $this->getSectionPageAction(); $article = new Article($this->m_data['fk_language_id'], $this->m_data['fk_article_number']); if ($publishAction == 'P') { $article->setWorkflowStatus('Y'); } if ($publishAction == 'U') { $article->setWorkflowStatus('S'); } if ($frontPageAction == 'S') { $article->setOnFrontPage(true); } if ($frontPageAction == 'R') { $article->setOnFrontPage(false); } if ($sectionPageAction == 'S') { $article->setOnSectionPage(true); } if ($sectionPageAction == 'R') { $article->setOnSectionPage(false); } $this->setCompleted(); } // fn doAction
break; case 'Published': $f_value = 'Y'; break; case 'Submitted': $f_value = 'S'; break; } $access = false; // A publisher can change the status in any way he sees fit. // Someone who can change an article can submit/unsubmit articles. // A user who owns the article may submit it. if ($g_user->hasPermission('Publish') || $g_user->hasPermission('ChangeArticle') && $f_value != 'Y' || $articleObj->userCanModify($g_user) && $f_value == 'S') { $access = true; } // If the article is not yet categorized, force it to be before publication. if ($f_action_workflow == "Y" && ($articleObj->getPublicationId() == 0 || $articleObj->getIssueNumber() == 0 || $articleObj->getSectionNumber() == 0)) { //$args = $_REQUEST; //$argsStr = camp_implode_keys_and_values($_REQUEST, "=", "&"); //$argsStr .= "&f_article_code[]=".$f_article_number."_".$f_language_selected; //$argsStr .= "&f_mode=single&f_action=publish"; //camp_html_goto_page("/$ADMIN/articles/duplicate.php?".$argsStr); } $success = $articleObj->setWorkflowStatus($f_value); $message = $translator->trans("Article status set to \$1", array('$1' => $articleObj->getWorkflowDisplayString($f_value)), 'library'); } } if ($affectedArticles == 0 && $success) { $affectedArticles = 1; } return returnJson($affectedArticles, $message, $notAffectedArticles, $errorMessage, $hiperlink);