Inheritance: implements Newscoop\Search\DocumentInterface
示例#1
0
 /**
  * Get article webcode
  *
  * @param Newscoop\Entity\Article $article
  * @return string
  */
 public function getArticleWebcode(Entity\Article $article)
 {
     if (!$article->hasWebcode()) {
         $this->setArticleWebcode($article);
     }
     return $article->getWebcode();
 }
 /**
  * @param \Doctrine\ORM\EntityManager                                           $em
  * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface            $templating
  * @param \Newscoop\Entity\Article                                              $article
  * @param \Newscoop\ArticlesBundle\Entity\Repository\EditorialCommentRepository $repository
  */
 public function let($die, $em, $templating, $article, $repository, Registry $doctrine)
 {
     $doctrine->getManager()->willReturn($em);
     $em->getRepository(Argument::exact('Newscoop\\ArticlesBundle\\Entity\\EditorialComment'))->willReturn($repository);
     $repository->getAllByArticleNumber(Argument::any(), Argument::any())->willReturn(Argument::any());
     $article->getNumber()->willReturn(1);
     $this->beConstructedWith($em, $templating);
 }
示例#3
0
 /**
  * @param Newscoop\Subscription\Subscription $subscription
  * @param int $article
  */
 public function __construct(Subscription $subscription, ArticleEntity $article)
 {
     $this->subscription = $subscription;
     $this->subscription->addArticle($this);
     $this->article = $article;
     $this->articleNumber = $article->getNumber();
     $this->noticeSent = 'N';
     $this->paidDays = 0;
 }
 /**
  * Add new related article to related articles container
  *
  * @param Article $article
  * @param Article $articleToAdd
  * @param integer $position
  *
  * @return boolean
  */
 public function addArticle($article, $articleToAdd, $position = false)
 {
     $relatedArticles = $this->findRelatedArticlesBox($article);
     $relatedArticle = $this->em->getRepository('Newscoop\\Entity\\RelatedArticle')->getRelatedArticle($relatedArticles, $articleToAdd->getNumber())->getOneOrNullResult();
     if ($relatedArticle) {
         $this->positionRelateArticle($relatedArticles, $relatedArticle, $position);
         return true;
     }
     $relatedArticle = new RelatedArticle($relatedArticles->getId(), $articleToAdd->getNumber());
     $this->em->persist($relatedArticle);
     $this->em->flush();
     $this->positionRelateArticle($relatedArticles, $relatedArticle, $position);
     return true;
 }
 public function let(EntityManager $em, Article $article, Article $articleToRemove, Article $articleToAdd, RelatedArticles $relatedArticles, RelatedArticle $relatedArticle, RelatedArticleRepository $relatedArticleRepository, RelatedArticlesRepository $relatedArticlesRepository, AbstractQuery $query, AbstractQuery $getRelatedArticleQuery, AbstractQuery $getAllArticlesQuery, \Doctrine\DBAL\Connection $connection)
 {
     $article->getNumber()->willReturn(1);
     $articleToRemove->getNumber()->willReturn(2);
     $articleToAdd->getNumber()->willReturn(2);
     $em->persist(Argument::any())->willReturn(true);
     $em->flush(Argument::any())->willReturn(true);
     $em->remove(Argument::any())->willReturn(true);
     $em->getConnection()->willReturn($connection);
     $em->getRepository('Newscoop\\Entity\\RelatedArticle')->willReturn($relatedArticleRepository);
     $em->getRepository('Newscoop\\Entity\\RelatedArticles')->willReturn($relatedArticlesRepository);
     $relatedArticlesRepository->getRelatedArticles(Argument::type('integer'))->willReturn($query);
     $relatedArticleRepository->getAllArticles(Argument::type('\\Newscoop\\Entity\\RelatedArticles'))->willReturn($getAllArticlesQuery);
     $getAllArticlesQuery->getResult()->willReturn(array());
     $relatedArticleRepository->getRelatedArticle(Argument::type('\\Newscoop\\Entity\\RelatedArticles'), Argument::type('integer'))->willReturn($query);
     $relatedArticleRepository->getRelatedArticle(Argument::type('integer'))->willReturn($getRelatedArticleQuery);
     $getRelatedArticleQuery->getOneOrNullResult()->willReturn($relatedArticle);
     $relatedArticle->getOrder()->willReturn(Argument::type('integer'));
     $this->beConstructedWith($em);
 }
 public function let(TraceableEventDispatcher $dispatcher, EntityManager $em, Article $article, Language $language)
 {
     $article->getNumber()->willReturn(10);
     $article->getName()->willReturn("test article");
     $article->getPublicationId()->willReturn(2);
     $article->getLanguageId()->willReturn(1);
     $article->getIssueId()->willReturn(20);
     $article->getSectionId()->willReturn(30);
     $em->getReference('Newscoop\\Entity\\Language', 1)->willReturn($language);
     $language->getCode()->willReturn('en');
     $this->beConstructedWith($dispatcher, $em);
 }
示例#7
0
 /**
  * Render actions
  *
  * @param array $actions
  * @return void
  */
 public function linkArticle(Article $p_article)
 {
     $params = array('f_publication_id' => $p_article->getPublicationId(), 'f_issue_number' => $p_article->getIssueId(), 'f_section_number' => $p_article->getSectionId(), 'f_article_number' => $p_article->getId(), 'f_language_id' => $p_article->getLanguageId(), 'f_language_selected' => $p_article->getLanguageId());
     return http_build_query($params);
 }
示例#8
0
 /**
  * Removes Topic from Article.
  *
  * @param Article $article the Article to deattach topic
  *
  * @return Topic
  */
 public function removeArticleTopic(Article $article)
 {
     if (!$this->articles->contains($article)) {
         $article->removeTopic($this);
         $this->articles->removeElement($article);
     }
     return $this;
 }
示例#9
0
 private function getLogArray(Topic $topic, Article $article)
 {
     return array('title' => $topic->getTitle(), 'id' => array('Title' => $article->getName(), 'Number' => $article->getNumber(), 'IdLanguage' => $article->getLanguageId()), 'diff' => array('id' => $topic->getId(), 'title' => $topic->getTitle()));
 }
示例#10
0
 /**
  * Remove author with type from article
  *
  * @param Article       $article
  * @param Author        $author
  * @param ArticleAuthor $authorType
  *
  * @return ArticleAuthor
  */
 public function removeAuthorFromArticle(Article $article, Author $author, AuthorType $authorType)
 {
     $articleAuthor = $this->em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthor($article->getNumber(), $article->getLanguageCode(), $author->getId(), $authorType->getId())->getOneOrNullResult();
     if (!$articleAuthor) {
         throw new ResourcesConflictException("Author with this type is not attached to article", 409);
     }
     $this->em->remove($articleAuthor);
     $this->em->flush();
     $articleAuthors = $this->em->getRepository('Newscoop\\Entity\\ArticleAuthor')->getArticleAuthors($article->getNumber(), $article->getLanguageCode())->getResult();
     $this->reorderAuthors($this->em, $articleAuthors);
 }
 public function getArticleAuthors()
 {
     $this->__load();
     return parent::getArticleAuthors();
 }
示例#12
0
 /**
  * Get section short name
  *
  * @param Newscoop\Entity\Article $article
  * @return string
  */
 public function getSectionShortName(Article $article)
 {
     $issue = $this->em->getRepository('Newscoop\\Entity\\Issue')->findOneBy(array('number' => $article->getIssueId(), 'publication' => $article->getPublicationId(), 'language' => $article->getLanguageId()));
     if (!$issue) {
         return null;
     }
     $section = $this->em->getRepository('Newscoop\\Entity\\Section')->findOneBy(array('number' => $article->getSectionId(), 'publication' => $article->getPublicationId(), 'language' => $article->getLanguageId(), 'issue' => $issue ? $issue->getId() : null));
     return $section ? $section->getShortName() : null;
 }
示例#13
0
 /**
  * Send comment notification
  *
  * @param Newscoop\Entity\Comment $comment
  * @param Newscoop\Entity\Article $article
  * @param array                   $authors
  * @param Newscoop\Entity\User    $user
  *
  * @return void
  */
 public function sendCommentNotification(Comment $comment, Article $article, array $authors, User $user = null)
 {
     $publicationService = $this->container->get('newscoop_newscoop.publication_service');
     $templatesService = $this->container->get('newscoop.templates.service');
     $placeholdersService = $this->container->get('newscoop.placeholders.service');
     $preferencesService = $this->container->get('preferences');
     $translator = $this->container->get('translator');
     $emails = array_unique(array_filter(array_map(function ($author) {
         return $author->getEmail();
     }, $authors)));
     $publication = $publicationService->getPublication();
     $moderatorTo = $this->getModeratorEmailIfModerationEnabled($publication, $user);
     $moderatorTo ? $emails['moderator'] = $moderatorTo : null;
     $moderatorFrom = $publication->getModeratorFrom();
     if (empty($emails)) {
         return;
     }
     $smarty = $templatesService->getSmarty();
     $uri = \CampSite::GetURIInstance();
     if ($user) {
         $smarty->assign('username', $user->getUsername());
     } else {
         $smarty->assign('username', $translator->trans('anonymous'));
     }
     $smarty->assign('comment', $comment);
     $smarty->assign('article', new \MetaArticle($article->getLanguageId(), $article->getNumber()));
     $smarty->assign('publication', $uri->getBase());
     $smarty->assign('site', $uri->getBase());
     $smarty->assign('articleLink', \ShortURL::GetURI($article->getPublicationId(), $article->getLanguageId(), $article->getIssueId(), $article->getSectionId(), $article->getNumber()));
     $message = $templatesService->fetchTemplate("email_comment-notify.tpl");
     $this->send($placeholdersService->get('subject'), $message, $emails, $moderatorFrom ?: $preferencesService->EmailFromAddress);
 }
示例#14
0
 /**
  * Get article switches
  *
  * @param Newscoop\Entity\Article $article
  * @return array
  */
 public function getArticleSwitches($article)
 {
     $switches = array();
     foreach ($this->switches as $switch) {
         try {
             if ($article->getData($switch)) {
                 $switches[] = $switch;
             }
         } catch (\Exception $e) {
             /*just ignore if switch don't exists*/
         }
     }
 }
示例#15
0
 /**
  * Update Article static properties
  *
  * @param Article $article
  * @param array   $attributes
  *
  * @return Article
  */
 private function updateArticleMeta($article, $attributes)
 {
     $article->setName($attributes['name']);
     $article->setCommentsEnabled($attributes['comments_enabled']);
     $article->setCommentsLocked($attributes['comments_locked']);
     $article->setOnFrontPage($attributes['onFrontPage']);
     $article->setOnSection($attributes['onSection']);
     $article->setKeywords($attributes['keywords']);
     return $article;
 }
 /**
  * Set authors for article, if author doesn't exist it gets created
  *
  * @param \Newscoop\Entity\Article                       $article Article
  * @param \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry   Entity
  */
 protected function setArticleAuthors(\Newscoop\Entity\Article $article, \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry)
 {
     $repository = $this->em->getRepository('\\Newscoop\\Entity\\Author');
     $doctrineCollection = new \Doctrine\Common\Collections\ArrayCollection();
     $authors = $entry->getAuthors();
     if (count($authors) > 0) {
         foreach ($authors as $author) {
             $authorEntity = $repository->findBy(array('first_name' => $author['firstname'], 'last_name' => $author['lastname']));
             if ($authorEntity === null) {
                 $authorEntity = new \Newscoop\Entity\Author($author['firstname'], $author['lastname']);
             }
             $doctrineCollection->add($authorEntity);
         }
         $article->setArticleAuthors($doctrineCollection);
     }
 }
示例#17
0
 /**
  * Update Article static properties
  *
  * @param Article $article
  * @param array   $attributes
  *
  * @return Article
  */
 private function updateArticleMeta($article, $attributes)
 {
     if (array_key_exists('name', $attributes)) {
         $article->setName($attributes['name']);
     }
     if (array_key_exists('comments_enabled', $attributes)) {
         $article->setCommentsEnabled($attributes['comments_enabled']);
     }
     if (array_key_exists('comments_locked', $attributes)) {
         $article->setCommentsLocked($attributes['comments_locked']);
     }
     if (array_key_exists('onFrontPage', $attributes)) {
         $article->setOnFrontPage($attributes['onFrontPage']);
     }
     if (array_key_exists('onSection', $attributes)) {
         $article->setOnSection($attributes['onSection']);
     }
     if (array_key_exists('keywords', $attributes)) {
         $article->setKeywords($attributes['keywords'] ? $attributes['keywords'] : '');
     }
     return $article;
 }
 private function createArticleLegacyPreviewUrl(Article $article)
 {
     $params = array('f_publication_id' => $article->getPublicationId(), 'f_issue_number' => $article->getIssueId(), 'f_section_number' => $article->getSectionId(), 'f_article_number' => $article->getNumber(), 'f_language_id' => $article->getLanguageId(), 'f_language_selected' => $article->getLanguageId());
     return '/admin/articles/get.php?' . http_build_query($params);
 }
示例#19
0
 public function removeAttachmentFormArticle(Article $article, Attachment $attachment)
 {
     $article->getAttachments()->removeElement($attachment);
     $this->em->flush();
 }