private function addCommonListItemsToModelView($pageNumber, $tagId, $searchTerm, $pressReviews, $pressReviewTypeId)
 {
     if (!$pageNumber) {
         $pageNumber = 1;
     }
     //
     // Add press review list to model view
     $pressReviewsPaginated = $this->getPressReviewsPaginated($pressReviews, $pageNumber, $pressReviewTypeId == PressReviewTypes::ARTICLE ? 10 : 5);
     $pagesPressReviews = $pressReviewsPaginated->getItems();
     $this->view->pressReviews = $pagesPressReviews;
     // Get tags and add it to model view
     $tags = TagSvc::getInstance()->getTagsForPressReviews();
     // Add reinit url to model view
     switch ($pressReviewTypeId) {
         case PressReviewTypes::ARTICLE:
             $initUrl = $this->view->url(array(), 'articlePressReviews');
             $searchLabel = __("Rechercher un article", "s1b");
             break;
         case PressReviewTypes::VIDEO:
             $initUrl = $this->view->url(array(), 'videoPressReviews');
             $searchLabel = __("Rechercher une vidéo", "s1b");
             break;
     }
     // Get search content form and add it to model view
     $contentSearch = new ContentSearch("/default/press-review/search", $tags, $tagId, $searchLabel, $pressReviewTypeId, $searchTerm, $initUrl);
     $this->view->contentSearch = $contentSearch->get();
     // Get press review subscription module and add it to view model
     $pressReviewSubscriptionWidget = new PressReviewsSubscriptionWidget();
     $this->view->pressReviewSubscriptionWidget = $pressReviewSubscriptionWidget->get();
     // Add navigation bar to view model
     $this->view->navigationBar = $pressReviewsPaginated->getNavigationBar();
     // Get ad and add it to view model
     $ad = new Ad("", "");
     $this->view->ad = $ad->get();
     // Get chronicles for right column widget and add to view model
     $chroniclesTitle = "";
     $chronicles = null;
     if ($tagId) {
         $chroniclesTitle = __("<strong>Chroniques</strong> dans la même catégorie", "s1b");
         $chronicles = ChronicleSvc::getInstance()->getChroniclesWithTags(array($tagId), 5);
     } else {
         $chroniclesTitle = __("Dernières chroniques", "s1b");
         $chronicles = ChronicleSvc::getInstance()->getLastChronicles(5);
     }
     if (count($chronicles) > 0) {
         $chronicleAdapter = new ChronicleListAdapter();
         $chronicleAdapter->setChronicles($chronicles);
         $chroniclesView = new ChroniclesBlock($chronicleAdapter->getAsChronicleViewModelLightList(), $chroniclesTitle);
         $this->view->chroniclesView = $chroniclesView->get();
     }
     // Get books with press reviews for right column
     $this->view->placeholder('footer')->append("<script src=\"" . BASE_URL . 'Resources/js/waterwheel-carousel/jquery.waterwheelCarousel.min.js' . "\"></script>\n");
     $this->view->placeholder('footer')->append("<script>\$(function () {initCoverFlip('booksWithPressReviews', 30)});</script>\n");
     $books = BookSvc::getInstance()->getListWithPressReviews(15);
     $booksCoverFlip = new BookCoverFlip($books, __("Les livres dont parlent <strong>les médias</strong>", "s1b"), "booksWithPressReviews", "");
     $this->view->booksCoverFlip = $booksCoverFlip->get();
     // Add SEO (title, meta description and keywords)
     $routeName = Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName();
     $headerInformation = HeaderInformationSvc::getInstance()->getByRouteName($routeName);
     $this->view->tagTitle = $headerInformation->getTitle();
     $this->view->metaDescription = $headerInformation->getDescription();
     $this->view->metaKeywords = $headerInformation->getKeywords();
 }
示例#2
0
 /**
  * Get a chronicle as ChronicleViewModel object for chronicle detail page
  * @param int $nbSimilarChronicles the number of similar chronicles to return , if not passed (null), then no similar chronicles will be returned
  * @param int $nbSameAuthorChronicles number of same author chronicles to return
  * @param int $nbPressReviews number of press reviews to return
  * @param boolean flag to tell to use cache or not
  * @return \Sb\Model\ChronicleViewModel a chronicle as a ChronicleViewModel object
  */
 public function getAsChronicleViewModel($nbSimilarChronicles = null, $nbSameAuthorChronicles = null, $nbPressReviews = null, $useCache = true)
 {
     /* @var $chronicle ChronicleViewModel */
     $chronicleViewModel = new ChronicleViewModel();
     // Set common members
     $this->setChronicleViewModelLight($chronicleViewModel);
     $chronicleViewModel->setText($this->chronicle->getText());
     $chronicleViewModel->setUserName($this->chronicle->getUser()->getUserName());
     $chronicleViewModel->setUserProfileLink(HTTPHelper::Link(Urls::USER_PROFILE, array("uid" => $this->chronicle->getUser()->getId())));
     $chronicleViewModel->setUserImage(UserHelper::getMediumImageTag($this->chronicle->getUser(), __("image chroniqueur", "s1b")));
     $chronicleViewModel->setSource($this->chronicle->getSource());
     // Set book
     $chronicleViewModel->setChronicleHasBook(false);
     if ($this->chronicle->getBook()) {
         $chronicleViewModel->setChronicleHasBook(true);
         $chronicleViewModel->setBook($this->chronicle->getBook());
     }
     // Set link info
     $chronicleViewModel->setLinkCss("chr-link-other");
     $chronicleViewModel->setLinkText(__("En savoir plus", "s1b"));
     switch ($this->chronicle->getLink_type()) {
         case ChronicleLinkType::IMAGE:
             $chronicleViewModel->setLinkCss("chr-link-image");
             $chronicleViewModel->setLinkText(__("Voir la photo", "s1b"));
             break;
         case ChronicleLinkType::PODCAST:
             $chronicleViewModel->setLinkCss("chr-link-podcast");
             $chronicleViewModel->setLinkText(__("Ecouter le podcast", "s1b"));
             break;
         case ChronicleLinkType::PRESS:
             $chronicleViewModel->setLinkCss("chr-link-press");
             $chronicleViewModel->setLinkText(__("Lire l'article", "s1b"));
             break;
         case ChronicleLinkType::URL:
             $chronicleViewModel->setLinkCss("chr-link-url");
             $chronicleViewModel->setLinkText(__("En savoir plus", "s1b"));
             break;
         case ChronicleLinkType::VIDEO:
             $chronicleViewModel->setLinkCss("chr-link-video");
             $linkText = __("Regarder la video", "s1b");
             break;
     }
     // Set type label
     $chronicleViewModel->setTypeLabel(ChronicleHelper::getTypeLabel($this->chronicle->getType_id()));
     // Set similar chronicles or same author chronicles
     if ($nbSimilarChronicles || $nbSameAuthorChronicles) {
         $chroniclesAdapter = new ChronicleListAdapter();
         // Set the similar chronicles
         if ($nbSimilarChronicles) {
             $chroniclesAdapter->setChronicles($this->getSimilarChronicles($nbSimilarChronicles, $useCache));
             $chronicleViewModel->setSimilarChronicles($chroniclesAdapter->getAsChronicleViewModelList());
         }
         // Set the same author chronicles
         if ($nbSameAuthorChronicles) {
             $chroniclesAdapter->setChronicles($this->getSameAuthorChronicles($nbSameAuthorChronicles, $useCache));
             $chronicleViewModel->setSameAuthorChronicles($chroniclesAdapter->getAsChronicleViewModelList());
         }
     }
     // Set press reviews
     if ($nbPressReviews) {
         $pressReviews = null;
         // Get press review with same tag
         if ($this->chronicle->getTag()) {
             $pressReviews = PressReviewSvc::getInstance()->getList(array("tag" => array(true, "=", $this->chronicle->getTag()), "is_validated" => array(false, "=", 1)), $nbPressReviews, $useCache);
         }
         // Get press review with same keywords
         if ((!$pressReviews || count($pressReviews) < $nbPressReviews) && $this->chronicle->getKeywords()) {
             $keyWords = explode(",", $this->chronicle->getKeywords());
             foreach ($keyWords as $keyWord) {
                 // Get press review with same keywords
                 $criteria = array("keywords" => array(false, "LIKE", $keyWord));
                 $pressReviewsWithKeywords = PressReviewSvc::getInstance()->getList($criteria, $nbPressReviews, $useCache);
                 if ($pressReviewsWithKeywords) {
                     if (!$pressReviews) {
                         $pressReviews = $pressReviewsWithKeywords;
                     } else {
                         $pressReviews = EntityHelper::mergeEntities($pressReviews, $pressReviewsWithKeywords);
                     }
                     if (count($pressReviews) >= $nbPressReviews) {
                         break;
                     }
                 }
             }
             if ($pressReviews) {
                 $pressReviews = array_slice($pressReviews, 0, $nbPressReviews);
             }
         }
         $chronicleViewModel->setPressReviews($pressReviews);
     }
     return $chronicleViewModel;
 }
 /**
  * Add common item to view model for list actions
  * @param String $key the page key (last chronicles, bloggers, bookstores)
  * @param Array of ChronicleModelView $chronicles the array of ChronicleViewModel to display
  * @param int $pageNumber the page number
  * @param String $navigationParamName the page navigation param name
  */
 private function addCommonListItemsToModelView($key, $chronicles, $pageNumber, $tagId, $searchTerm, $initUrl)
 {
     switch ($key) {
         case self::PAGE_KEY_ANY_GROUPS:
             $title = __("Dernières chroniques", "s1b");
             break;
         case self::PAGE_KEY_BLOGGERS:
             $title = __("En direct des blogs", "s1b");
             break;
         case self::PAGE_KEY_BOOKSTORES:
             $title = __("Le mot des libraires", "s1b");
             break;
     }
     // Add title list to model view
     $this->view->title = $title;
     // Get tags and add it to model view
     $tags = TagSvc::getInstance()->getTagsForChronicles();
     $this->view->tags = $tags;
     // Get search content form and add it to model view
     $contentSearch = new ContentSearch("/default/chronicle/search", $tags, $tagId, __("Rechercher une chronique", "s1b"), $key, $searchTerm, $initUrl);
     $this->view->contentSearch = $contentSearch->get();
     if (!$pageNumber) {
         $pageNumber = 1;
     }
     $chroniclesPaginated = new PaginatedList($chronicles, 5, $this->navigationParamName, $pageNumber);
     $chroniclesPage = $chroniclesPaginated->getItems();
     $chroniclesAdapter = new ChronicleListAdapter();
     $chroniclesAdapter->setChronicles($chroniclesPage);
     // Get as a chronicle view model list with 2 similar chronicles
     $chronicleDetailViewModelList = $chroniclesAdapter->getAsChronicleViewModelList(2);
     // Add chronicleDetailViewModel list to model view
     $this->view->chronicleDetailViewModelList = $chronicleDetailViewModelList;
     // Add navigation bar to view model
     $this->view->navigationBar = $chroniclesPaginated->getNavigationBar();
     // Add more seen chronicles to model view
     $nbMoreSeenChronicles = 5;
     $orderArray = array("nb_views", "DESC");
     switch ($key) {
         case self::PAGE_KEY_ANY_GROUPS:
             $moreSeenChronicles = ChronicleSvc::getInstance()->getLastChronicles($nbMoreSeenChronicles, null, GroupTypes::BLOGGER . "," . GroupTypes::BOOK_STORE, true, null, $orderArray);
             break;
         case self::PAGE_KEY_BLOGGERS:
             $moreSeenChronicles = ChronicleSvc::getInstance()->getLastChronicles($nbMoreSeenChronicles, GroupTypes::BLOGGER, null, true, null, $orderArray);
             break;
         case self::PAGE_KEY_BOOKSTORES:
             $moreSeenChronicles = ChronicleSvc::getInstance()->getLastChronicles($nbMoreSeenChronicles, GroupTypes::BOOK_STORE, null, true, null, $orderArray);
             break;
     }
     if ($moreSeenChronicles) {
         $chroniclesAdapter->setChronicles($moreSeenChronicles);
         $moreSeenChroniclesView = new ChroniclesBlock($chroniclesAdapter->getAsChronicleViewModelLightList(), __("<strong>Chroniques</strong> les plus en vues", "s1b"));
         $this->view->moreSeenChronicles = $moreSeenChroniclesView->get();
     }
     // Get books with press reviews
     $this->view->placeholder('footer')->append("<script src=\"" . BASE_URL . 'Resources/js/waterwheel-carousel/jquery.waterwheelCarousel.min.js' . "\"></script>\n");
     $this->view->placeholder('footer')->append("<script>\$(function () {initCoverFlip('booksWithPressReviews', 30)});</script>\n");
     $books = BookSvc::getInstance()->getListWithPressReviews(15);
     $booksCoverFlip = new BookCoverFlip($books, __("Les livres dont parlent <strong>les médias</strong>", "s1b"), "booksWithPressReviews", "");
     $this->view->booksCoverFlip = $booksCoverFlip->get();
     // Add SEO (title, meta description and keywords)
     $routeName = Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName();
     $headerInformation = HeaderInformationSvc::getInstance()->getByRouteName($routeName);
     $this->view->tagTitle = $headerInformation->getTitle();
     $this->view->metaDescription = $headerInformation->getDescription();
     $this->view->metaKeywords = $headerInformation->getKeywords();
 }
示例#4
0
 private function getChronicleView(ChronicleListAdapter $chronicleListAdapter, $chronicles, $title, $typeCSS, $link, $textLink)
 {
     // Getting list of view model
     $chronicleListAdapter->setChronicles($chronicles);
     $anyGroupTypeChronicesAsViewModel = $chronicleListAdapter->getAsChronicleViewModelLightList();
     // Get chronicles view
     $chroniclesView = new PushedChronicles($anyGroupTypeChronicesAsViewModel, $link, $title, $typeCSS, $textLink);
     return $chroniclesView->get();
 }
示例#5
0
 private function getChronicleView($chronicles)
 {
     $chronicleListAdapter = new ChronicleListAdapter();
     // Getting list of view model
     $chronicleListAdapter->setChronicles($chronicles);
     $chroniclesAsViewModel = $chronicleListAdapter->getAsChronicleViewModelLightList();
     // Get chronicles view
     $link = $this->view->url(array(), 'chroniclesLastAnyType');
     $chroniclesView = new PushedChronicles($chroniclesAsViewModel, $link);
     return $chroniclesView->get();
 }