Example #1
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());
	}
     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) {
         $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
         if ($articleObj->userCanModify($g_user)) {
             $articleObj->setOnFrontPage(!$articleObj->onFrontPage());
         }
     }
     camp_html_add_msg(getGS("\$1 toggled.", """ . getGS("On Front Page") . """), "ok");
     break;
 case "toggle_section_page":
     foreach ($articleCodes as $articleCode) {
         $articleObj = new Article($articleCode['language_id'], $articleCode['article_id']);
         if ($articleObj->userCanModify($g_user)) {
             $articleObj->setOnSectionPage(!$articleObj->onSectionPage());
         }
     }
     camp_html_add_msg(getGS("\$1 toggled.", """ . getGS("On Section Page") . """), "ok");
     break;
 case "toggle_comments":
     foreach ($articleCodes as $articleCode) {
Example #3
0
 /**
  * Process item
  * @param Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     $articleLinkParams = '?f_publication_id=' . $article->getPublicationId() . '&f_issue_number=' . $article->getIssueNumber() . '&f_section_number=' . $article->getSectionNumber() . '&f_article_number=' . $article->getArticleNumber() . '&f_language_id=' . $article->getLanguageId() . '&f_language_selected=' . $article->getLanguageId();
     $articleLinkParamsTranslate = $articleLinkParams . '&f_action=translate&f_action_workflow=' . $article->getWorkflowStatus() . '&f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
     $articleLink = $Campsite['WEBSITE_URL'] . '/admin/articles/edit.php' . $articleLinkParams;
     $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $articleLinkParams;
     $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . getGS('Preview') . '">' . getGS('Preview') . '</a>';
     $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
     $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . getGS('Translate') . '">' . getGS('Translate') . '</a>';
     $lockInfo = '';
     $lockHighlight = false;
     $timeDiff = camp_time_diff_str($article->getLockTime());
     if ($article->isLocked() && $timeDiff['days'] <= 0) {
         $lockUser = new User($article->getLockedByUser());
         if ($timeDiff['hours'] > 0) {
             $lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['hours'], $timeDiff['minutes']);
         } else {
             $lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['minutes']);
         }
         if ($article->getLockedByUser() != $g_user->getUserId()) {
             $lockHighlight = true;
         }
     }
     $tmpUser = new User($article->getCreatorId());
     $tmpArticleType = new ArticleType($article->getType());
     $tmpAuthor = new Author();
     $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
     foreach ((array) $articleAuthors as $author) {
         if (strtolower($author->getAuthorType()->getName()) == 'author') {
             $tmpAuthor = $author;
             break;
         }
     }
     if (!$tmpAuthor->exists() && isset($articleAuthors[0])) {
         $tmpAuthor = $articleAuthors[0];
     }
     $onFrontPage = $article->onFrontPage() ? getGS('Yes') : getGS('No');
     $onSectionPage = $article->onSectionPage() ? getGS('Yes') : getGS('No');
     $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true);
     $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true);
     $commentsNo = '';
     if ($article->commentsEnabled()) {
         global $controller;
         $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment');
         $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId());
         $params = array('sFilter' => $filter);
         $commentsNo = $repositoryComments->getCount($params);
     } else {
         $commentsNo = 'No';
     }
     // get language code
     $language = new Language($article->getLanguageId());
     return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, getGS('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != NULL ? getGS('Yes') : getGS('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
 }