Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * Create an Article object from XML
  *
  * @param SimpleXMLElement $xml simpleXML element containing a single article XML
  *
  * @static
  *
  * @return phpOpenNOS\Model\Article
  */
 public static function fromXML(\SimpleXMLElement $xml)
 {
     $article = new Article();
     $article->setId((int) $xml->id);
     $article->setTitle((string) $xml->title);
     $article->setDescription((string) $xml->description);
     $article->setPublished((string) $xml->published);
     $article->setLastUpdate((string) $xml->last_update);
     $article->setThumbnailXS((string) $xml->thumbnail_xs);
     $article->setThumbnailS((string) $xml->thumbnail_s);
     $article->setThumbnailM((string) $xml->thumbnail_m);
     $article->setLink((string) $xml->link);
     $keywords = array();
     foreach ($xml->keywords->keyword as $keyword) {
         $keywords[] = (string) $keyword;
     }
     $article->setKeywords($keywords);
     return $article;
 }
Example #3
0
	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());
	}
 /**
  * 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;
 }
Example #5
0
        // Links the author to the article
        $articleAuthorObj = new ArticleAuthor($articleObj->getArticleNumber(),
                                              $articleObj->getLanguageId(),
                                              $authorObj->getId(), $author_type);
        if (!$articleAuthorObj->exists()) {
            $articleAuthorObj->create();
        }
        $i++;
    }
}

// Update the article.
$articleObj->setOnFrontPage(!empty($f_on_front_page));
$articleObj->setOnSectionPage(!empty($f_on_section_page));
$articleObj->setIsPublic(!empty($f_is_public));
$articleObj->setKeywords($f_keywords);
$articleObj->setTitle($f_article_title);
$articleObj->setIsIndexed(false);
if (!empty($f_comment_status)) {
    if ($f_comment_status == "enabled" || $f_comment_status == "locked") {
        $commentsEnabled = true;
    } else {
        $commentsEnabled = false;
    }
    // If status has changed, then you need to show/hide all the comments
    // as appropriate.
    if ($articleObj->commentsEnabled() != $commentsEnabled) {
	    $articleObj->setCommentsEnabled($commentsEnabled);
		$comments = ArticleComment::GetArticleComments($f_article_number, $f_language_selected);
		if ($comments) {
			foreach ($comments as $comment) {
Example #6
0
            $authorData = Author::ReadName($authorName);
            if ($isAuthorFromCreator) {
                $authorData['email'] = $g_user->getEmail();
            }
            $authorObj->create($authorData);
        }
        if ($authorObj->exists()) {
            $articleObj->setAuthor($authorObj);
            $articleFields['author'] = true;
        }
        // Updates the publish date
        $articlePublishDate = (string) $article->publish_date;
        $articleObj->setPublishDate($articlePublishDate);
        // Updates the article
        if (isset($article->keywords) && !empty($article->keywords)) {
            $articleObj->setKeywords((string) $article->keywords);
        }
        $articleFields['keywords'] = true;
        foreach ($xmlArticle as $articleFieldName => $articleFieldValue) {
            if (!array_key_exists($articleFieldName, $articleFields)) {
                $errorMessages[$articleCount][] = '"' . $articleFieldName . '" field in XML file ' . 'was not loaded into database as there is not any ' . 'article type field matching it.<br />';
            }
        }
    }
    camp_html_add_msg($translator->trans("\$1 articles successfully imported.", array('$1' => $articleCount), 'articles'), "ok");
}
// Gets all issues
$allIssues = array();
if ($f_publication_id > 0) {
    $allIssues = Issue::GetIssues($f_publication_id, $f_article_language_id, null, null, null, false, array("LIMIT" => 300, "ORDER BY" => array("Number" => "DESC")), true);
    // Automatically selects the issue if there is only one
Example #7
0
 /**
  * Publish text item
  *
  * @param Newscoop\News\NewsItem $item
  * @return Article
  */
 private function publishText(NewsItem $item)
 {
     $issueNumber = $this->settings->getPublicationId() ? \Issue::GetCurrentIssue($this->settings->getPublicationId())->getIssueNumber() : null;
     $type = $this->getArticleType($this->settings->getArticleTypeName());
     $article = new \Article($this->findLanguageId($item->getContentMeta()->getLanguage()));
     $article->create($type->getTypeName(), $item->getContentMeta()->getHeadline(), $this->settings->getPublicationId(), $issueNumber, $this->settings->getSectionNumber());
     $article->setKeywords($item->getContentMeta()->getSlugline());
     $article->setCreationDate($item->getItemMeta()->getFirstCreated()->format(self::DATE_FORMAT));
     $article->setPublishDate(null);
     $article->setProperty('time_updated', date_create('now')->format(self::DATE_FORMAT));
     $this->setArticleData($article, $item);
     $article->commit();
     return $article;
 }