Exemplo n.º 1
0
$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) {
				$comment->setStatus($commentsEnabled?PHORUM_STATUS_APPROVED:PHORUM_STATUS_HIDDEN);
			}
		}
    }
    $articleObj->setCommentsLocked($f_comment_status == "locked");
}

// Make sure that the time stamp is updated.
$articleObj->setProperty('time_updated', 'NOW()', true, true);

// Verify creation date is in the correct format.
// If not, dont change it.
if (preg_match("/\d{4}-\d{2}-\d{2}/", $f_creation_date)) {
Exemplo n.º 2
0
 protected function getCommentCount() {
     return ArticleComment::GetArticleComments($this->m_dbObject->getArticleNumber(),
     $this->m_dbObject->getLanguageId(), 'approved', true, false);
 }
Exemplo n.º 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();
		$articleLink = $Campsite['WEBSITE_URL'].'/admin/articles/edit.php' . $articleLinkParams;
		$previewLink = $Campsite['WEBSITE_URL'].'/admin/articles/preview.php' . $articleLinkParams;

		$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()) {
			$commentsNo = (int) ArticleComment::GetArticleComments($article->getArticleNumber(), $article->getLanguageId(), null, true);
		} 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'), $article->getName() . " ({$article->getLanguageName()})",
		$article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : '')),
		$tmpArticleType->getDisplayName(),
		$tmpUser->getRealName(),
		$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(),
		);
	}