GetAuthorsByArticle() public static method

Get all the authors that wrote this article.
public static GetAuthorsByArticle ( integer $p_articleNumber, integer $p_languageId = NULL ) : array
$p_articleNumber integer
$p_languageId integer
return array $returnArray An array of Author objects
 /**
  * Update
  *
  * @param GenericEvent $event
  * @return void
  */
 public function update(GenericEvent $event)
 {
     $comment = $this->commentService->find($event['id']);
     $article = new \Article($comment->getLanguage()->getId(), $comment->getThread()->getNumber());
     $authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread()->getNumber(), $comment->getLanguage()->getId());
     $this->emailService->sendCommentNotification($comment, $article, $authors, $this->userService->getCurrentUser());
 }
 /**
  * Update
  *
  * @param GenericEvent $event
  *
  * @return void
  */
 public function update(GenericEvent $event)
 {
     $comment = $this->commentService->find($event['id']);
     $article = $this->em->getRepository('Newscoop\\Entity\\Article')->getArticle($comment->getThread(), $comment->getLanguage()->getId())->getSingleResult();
     try {
         $user = $this->userService->getCurrentUser();
     } catch (AuthenticationException $e) {
         $user = null;
     }
     $authors = \ArticleAuthor::GetAuthorsByArticle($comment->getThread(), $comment->getLanguage()->getId());
     $this->emailService->sendCommentNotification($comment, $article, $authors, $user);
 }
Example #3
0
    ?>
    close(1);
});
<?php 
}
?>



<?php 
$allAuthors = array();
if ($userIsBlogger) {
    $blogInfo = $blogService->getBlogInfo($g_user);
    $allAuthors = array_map(function ($author) {
        return $author->getName();
    }, ArticleAuthor::GetAuthorsByArticle($blogInfo->getArticleNumber(), $blogInfo->getLanguageId()));
    $quoteStringFn = create_function('&$value, $key', '$value = json_encode((string) $value);');
    array_walk($allAuthors, $quoteStringFn);
    ?>
var authorsList = [<?php 
    echo implode(",\n", $allAuthors);
    ?>
];

$(".aauthor").autocomplete({ source: authorsList });

<?php 
} else {
    ?>
// authors autocomplete
$(".aauthor").live('focus', function() {
Example #4
0
 /**
  * Test if author is blog author
  *
  * @param Author $author
  * @param Article $blogInfo
  * @return bool
  */
 public function isBlogAuthor(\Author $author, \Article $blogInfo)
 {
     return in_array($author->getId(), array_map(function ($blogAuthor) {
         return $blogAuthor->getId();
     }, \ArticleAuthor::GetAuthorsByArticle($blogInfo->getArticleNumber(), $blogInfo->getLanguageId())));
 }
Example #5
0
    protected function getAuthors()
    {
        $authors = ArticleAuthor::GetAuthorsByArticle($this->m_dbObject->getProperty('Number'),
            $this->m_dbObject->getProperty('IdLanguage'));
        if (!is_array($authors)) {
            $authors = array();
        }

        $metaAuthors = array();
        foreach($authors as $author) {
            $metaAuthors[] = new MetaAuthor($author->getId(), $author->getType());
        }
        return $metaAuthors;
    }
      function  addAuthor(){
          var rnumber=Math.floor(Math.random()*9876)
          $('#authorContainer ul').append('<li id="author_li' + rnumber + '"><div class="left-floated"><div style="margin-top:1px"><select name="f_article_author_type[]" id="article_author_type' + rnumber + '" class="input_select aaselect" onchange="" style="width:130px;height:100%;margin-bottom:2px;float:none"><?php echo drawComboContent(); ?></select></div></div><div class="position-helper"><input type="text" name="f_article_author[]" id="f_article_author' + rnumber + '" size="45" class="input_text aauthor" value="" autocomplete="off" /><a class="ui-state-default icon-button no-text" href="#" id="removeauthor' + rnumber + '" onclick="deleteAuthor(\'' + rnumber + '\');"><span class="ui-icon ui-icon-closethick"></span></a></div></li>');
      }

      function deleteAuthor(id, empty){
          $('#f_article_author' + id).remove();
          $('#article_author_type' + id).remove();
          $('#removeauthor' + id).remove();
          $('#author_li' + id).remove();
          $('#article-main').addClass('changed');
      }
      </script>
      <?php
      // Get the list of authors
      $authors = ArticleAuthor::GetAuthorsByArticle($articleObj->getArticleNumber(), $articleObj->getLanguageId());
      if ($inEditMode) {
      ?>
      <div id="authorAutoComplete">
      <ul>
        <li>
          <label><?php putGS('Authors'); ?></label>
          <div id="authorContainer">
          <ul>
      <?php
          if (!empty($authors)) {
              $i = 0;
              foreach ((array) $authors as $author) {
      ?>
            <li id="<?php p('author_li'.$i); ?>">
              <div class="left-floated">
Example #7
0
 /**
  * Process item
  * @param  Article $article
  * @return array
  */
 public function processItem($article)
 {
     global $g_user, $Campsite;
     $translator = \Zend_Registry::get('container')->getService('translator');
     $editorService = \Zend_Registry::get('container')->getService('newscoop.editor');
     $articleLink = $editorService->getLink($article);
     $articleLinkParams = $editorService->getLinkParameters($article);
     $articleLinkParamsTranslate = $articleLinkParams . '&amp;f_action=translate&amp;f_action_workflow=' . $article->getWorkflowStatus() . '&amp;f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
     $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $editorService->getLinkParameters($article);
     $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . $translator->trans('Preview') . '">' . $translator->trans('Preview') . '</a>';
     $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
     $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . $translator->trans('Translate') . '">' . $translator->trans('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 = $translator->trans('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['hours'], '$4' => $timeDiff['minutes']), 'articles');
         } else {
             $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['minutes']), 'articles');
         }
         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() ? $translator->trans('Yes') : $translator->trans('No');
     $onSectionPage = $article->onSectionPage() ? $translator->trans('Yes') : $translator->trans('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, $translator->trans('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 ? $translator->trans('Yes') : $translator->trans('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
 }
Example #8
0
	/**
	 * Process item
	 * @param Article $article
	 * @return array
	 */
	public function processItem(Article $article)
	{
		global $g_user, $Campsite;

		$articleLinkParams = '?f_publication_id=' . $article->getPublicationId()
		. '&amp;f_issue_number=' . $article->getIssueNumber() . '&amp;f_section_number=' . $article->getSectionNumber()
		. '&amp;f_article_number=' . $article->getArticleNumber() . '&amp;f_language_id=' . $article->getLanguageId()
		. '&amp;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(),
		);
	}
Example #9
0
 /**
  * Test article authors
  */
 private function checkAuthors($count, \Article $article, Feed $feed)
 {
     $authors = \ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId());
     $this->assertEquals(1, count($authors), 'Authors count fails.');
     $this->assertEquals($feed->getTitle(), $authors[0]->getName());
 }