コード例 #1
0
 public function displayAddingChoiceAction()
 {
     try {
         $globalContext = new \Sb\Context\Model\Context();
         if ($globalContext->getIsShowingFriendLibrary()) {
             Flash::addItem(__("Vous ne pouvez pas ajouter un livre à la bibliothèque d'un ami.", "s1b"));
         }
         // Récupération du Book depuis le cache
         $book = ZendFileCache::getInstance()->load(Constants::BOOK_TO_ADD_PREFIX . session_id());
         // If id is known, getting the book from db to have all associated members and userbooks to show the potential reviews
         $booksAlsoLiked = null;
         $booksWithSameTags = null;
         $reviewdUserBooks = null;
         if ($book->getId()) {
             $book = BookDao::getInstance()->get($book->getId());
             $bookPage = BookPageSvc::getInstance()->get($book->getId());
             $booksAlsoLiked = $bookPage->getBooksAlsoLiked();
             $booksWithSameTags = $bookPage->getBooksWithSameTags();
             $reviewdUserBooks = $bookPage->getReviewedUserBooks();
         }
         $bookView = new BookView($book, true, true, true, $booksAlsoLiked, $booksWithSameTags, $reviewdUserBooks);
         $this->view->book = $bookView->get();
         $buttonsBar = new ButtonsBar(false);
         $this->view->buttonsBar = $buttonsBar->get();
         $this->view->referer = HTTPHelper::getReferer();
     } 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");
     }
 }