/**
  * The default action - show a chronicle detail page
  */
 public function indexAction()
 {
     try {
         // Get chronicle id from request
         $chronicleId = $this->getParam("cid");
         // Get chronicle page
         $chroniclePage = ChroniclePageSvc::getInstance()->get($chronicleId);
         if ($chroniclePage) {
             // Check chronicle validity
             if (!$chroniclePage->getChronicle()->getIs_validated()) {
                 Flash::addItem(__("La chronique que vous souhaitez consulter n'existe pas.", "s1b"));
                 HTTPHelper::redirectToReferer();
             }
             // Increment chronicle nb views
             $this->incrementChronicleNbViews($chroniclePage->getChronicle()->getId());
             // Add main chronicle view model to model view
             $chronicleView = new ChronicleDetail($this->getRequest(), $chroniclePage->getChronicleViewModel());
             $this->view->chronicle = $chronicleView->get();
             // Get similar chronicles (with same tag or with similar keywords) and add it to model view
             $similarChronicles = $chroniclePage->getSimilarChronicles();
             if ($similarChronicles && count($similarChronicles) > 0) {
                 $otherChoniclesSameTypeView = new OtherChroniclesSameType($similarChronicles);
                 $this->view->otherChoniclesSameType = $otherChoniclesSameTypeView->get();
             }
             // Get same author chronicles and add it to model view
             if ($chroniclePage->getSameAuthorChronicles()) {
                 $authorChroniclesView = new ChroniclesBlock($chroniclePage->getSameAuthorChronicles(), __("<strong>Chroniques</strong> du même auteur", "s1b"));
                 // Add author chronicles to model
                 $this->view->authorChroniclesView = $authorChroniclesView->get();
             }
             // Get press reviews
             if ($chroniclePage->getPressReviews()) {
                 $pressReviewsView = new BookPressReviews($chroniclePage->getPressReviews());
                 $this->view->pressReviewsView = $pressReviewsView->get();
             }
             // Get reviews and add it to model view
             if ($chroniclePage->getUserBooksReviews()) {
                 $paginatedList = new PaginatedList($chroniclePage->getUserBooksReviews(), 5);
                 $reviewsView = new BookReviews($paginatedList, $chroniclePage->getChronicle()->getBook()->getId());
                 $this->view->reviews = $reviewsView->get();
             }
             // Get video press review and add it to view model
             if ($chroniclePage->getVideoPressReview()) {
                 $this->view->videoUrl = $chroniclePage->getVideoPressReview()->getLink();
             }
             //
             // Add common items to model view
             $this->addCommonItemsToModelView();
             // Set SEO information
             $headerInformation = HeaderInformationSvc::getInstance()->getForChroniclePage($chroniclePage);
             $this->view->tagTitle = $headerInformation->getTitle();
             $this->view->metaDescription = $headerInformation->getDescription();
             $this->view->metaKeywords = $headerInformation->getKeywords();
             $this->view->urlCanonical = $headerInformation->getUrlCanonical();
             $this->view->pageImage = $headerInformation->getPageImage();
         } else {
             Flash::addItem(__("La chronique que vous souhaitez consulter n'existe pas.", "s1b"));
             HTTPHelper::redirectToReferer();
         }
     } catch (\Exception $e) {
         Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $e->getTraceAsString()));
         $this->forward("error", "error", "default");
     }
 }
示例#2
0
 /**
  * Action showing a book description
  */
 public function indexAction()
 {
     try {
         $globalContext = new \Sb\Context\Model\Context();
         $bookId = $this->_getParam('bid');
         if (!$bookId) {
             $this->getResponse()->setHttpResponseCode(404);
             $this->forward("error", "error", "default");
             return;
         }
         // Get book page
         /* @var $bookPage BookPage */
         $bookPage = BookPageSvc::getInstance()->get($bookId);
         if (!$bookPage) {
             $this->getResponse()->setHttpResponseCode(404);
             $this->forward("error", "error", "default");
             return;
         }
         // Add and js files
         $this->view->placeholder('footer')->append("<script src=\"" . $globalContext->getBaseUrl() . 'Resources/js/waterwheel-carousel/jquery.waterwheelCarousel.min.js' . "\"></script>\n");
         $this->view->placeholder('footer')->append("<script>\$(function () {initCoverFlip('sameAuthorBooks', 30)});</script>\n");
         // Get book view and add it to view model
         $bookView = new BookView($bookPage->getBook(), true, true, true, $bookPage->getBooksAlsoLiked(), $bookPage->getBooksWithSameTags(), $bookPage->getReviewedUserBooks(), false, true);
         $this->view->bookView = $bookView;
         // Get book buttonbar and add it to view model
         $buttonsBar = new ButtonsBar(false);
         $this->view->buttonsBar = $buttonsBar;
         // Get Books with same contributors and add it to view model
         $this->view->sameAuthorBooks = $bookPage->getBooksWithSameAuthor();
         // We pass ASIN code to be used by amazon url builder widget
         $this->view->bookAsin = $bookPage->getBook()->getASIN();
         // Get fnac buy link and add it to view model
         $this->view->buyOnFnacLink = null;
         if ($bookPage->getBook()->getISBN13()) {
             $this->view->buyOnFnacLink = 'http://clic.reussissonsensemble.fr/click.asp?ref=751772&site=14485&type=text&tnb=3&diurl=http%3A%2F%2Feultech.fnac.com%2Fdynclick%2Ffnac%2F%3Feseg-name%3DaffilieID%26eseg-item%3D%24ref%24%26eaf-publisher%3DAFFILINET%26eaf-name%3Dg%3Fn%3Frique%26eaf-creative%3D%24affmt%24%26eaf-creativetype%3D%24affmn%24%26eurl%3Dhttp%253A%252F%252Frecherche.fnac.com%252FSearchResult%252FResultList.aspx%253FSCat%253D0%2525211%2526Search%253D' . $bookPage->getBook()->getISBN13() . '%2526Origin%253Daffilinet%2524ref%2524';
         }
         // Get social network bar and add it to view model
         $socialBar = new SocialNetworksBar($bookPage->getBook()->getLargeImageUrl(), $bookPage->getBook()->getTitle(), $this->getRequest());
         $this->view->socialBar = $socialBar->get();
         // Get ad and add it to view model
         $ad = new Ad("bibliotheque", "1223994660");
         $this->view->ad = $ad;
         // Get Header Information and add it to view model
         $headerInformation = HeaderInformationSvc::getInstance()->get($bookPage->getBook());
         $this->view->tagTitle = $headerInformation->getTitle();
         $this->view->metaDescription = $headerInformation->getDescription();
         $this->view->metaKeywords = $headerInformation->getKeywords();
         $this->view->urlCanonical = $headerInformation->getUrlCanonical();
         $this->view->pageImage = $headerInformation->getPageImage();
         // Get last read userbooks for the book and add it to view model
         $this->view->lastlyReadUserbooks = $bookPage->getLastlyReadUserbooks();
         if (count($this->view->lastlyReadUserbooks) > 1) {
             $this->view->placeholder('footer')->append("<script src=\"" . $globalContext->getBaseUrl() . 'Resources/js/simple-carousel/simple.carousel.js' . "\"></script>\n");
             $this->view->placeholder('footer')->append("<script>\$(function() {initCarousel('carousel-lastUsersWhoReadThatBook', 298, 85)});</script>\n");
         }
         // Get chronicles and add it to view model
         $this->view->chronicles = $this->getChronicleView($bookPage->getRelatedChronicles());
         // Get video press review associated to book
         $this->view->placeholder('footer')->append("<script src=\"" . $globalContext->getBaseUrl() . 'Resources/js/waterwheel-carousel/jquery.waterwheelCarousel.min.js' . "\"></script>\n");
         $this->view->placeholder('footer')->append("<script>\$(function () {initCoverFlip('sameAuthorBooks', 30)});</script>\n");
         $video = $bookPage->getVideoPressReview();
         if ($video) {
             $this->view->videoUrl = $video->getLink();
         }
         //
         // Get book press reviews
         $bookPressReviews = $bookPage->getPressReviews();
         if ($bookPressReviews) {
             $bookPressReviewsView = new BookPressReviews($bookPressReviews);
             $this->view->pressReviews = $bookPressReviewsView->get();
         }
     } catch (\Exception $exc) {
         Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", TRACE : %s\"", get_class(), __FUNCTION__, $exc->getTraceAsString()));
         $this->forward("error", "error", "default");
     }
 }