/**
  * Action for displaying a static page
  */
 public function indexAction()
 {
     try {
         $this->getHelper("viewRenderer")->setNoRender(true);
         $file = BASE_PATH . "/static-files/" . $this->_getParam('file');
         if (file_exists($file)) {
             ob_start();
             include $file;
             $output = ob_get_contents();
             ob_end_clean();
             $this->getResponse()->appendBody($output);
             // Get Header information
             $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();
         } else {
             throw new \Exception();
         }
     } 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");
     }
 }
 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();
 }
 /**
  * Action for showing a list of top books
  */
 public function topsAction()
 {
     // Get all books
     $books = BookSvc::getInstance()->getTopsPageTops();
     // Get tags for combo
     $this->view->tags = TagSvc::getInstance()->getTagsForBooks($books);
     // Get tag id
     $tid = $this->_getParam('tid', -1);
     $tagLabel = null;
     if ($tid > 0) {
         $books = $this->filterBooks($books, $tid);
         $tagLabel = $this->getTagLabel($tid);
     }
     $this->setPageList($books);
     $description = __("Cette sélection des meilleurs livres est le résultat d'un classement effectué sur tous les livres présents chez Cherbouquin sur la base de la note que vous et les autres membres avez attribuée. L'idée de ce top est que vous puissiez y trouver l'inspiration pour vos prochaines lectures.", "s1b");
     $title = __("Tops des livres", "s1b");
     $this->view->title = $title;
     $this->view->description = $description;
     // Get Header information (title, meta desc, keywords)
     $headerInformation = HeaderInformationSvc::getInstance()->getForTopsPage($this->getPageNumber(), $tagLabel);
     $this->view->metaDescription = $headerInformation->getDescription();
     $this->view->tagTitle = $headerInformation->getTitle();
     $this->view->metaKeywords = $headerInformation->getKeywords();
     $this->view->action = $this->view->url(array(), 'topsBooks');
     $this->render("list");
 }
 /**
  * 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();
 }
 /**
  * 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");
     }
 }