Пример #1
0
 /**
  * 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");
 }
Пример #2
0
 /**
  * Homepage controller
  * @global type $globalContext
  */
 public function indexAction()
 {
     try {
         $globalContext = new \Sb\Context\Model\Context();
         $config = new Sb\Config\Model\Config();
         $this->view->placeholder('footer')->append("<script type=\"text/javascript\" src=\"" . BASE_URL . 'Resources/js/pressReviews.js?v=' . VERSION . "\"></script>");
         $this->view->placeholder('footer')->append("<script type=\"text/javascript\" src=\"" . BASE_URL . 'Resources/js/newsReader.js?v=' . VERSION . "\"></script>");
         $this->view->placeholder('footer')->append("<script type=\"text/javascript\" src=\"" . BASE_URL . 'Resources/js/content.js?v=' . VERSION . "\"></script>");
         $this->view->tagTitle = sprintf(__("%s : livre et littérature - tops | coups de cœur | critiques", "s1b"), \Sb\Entity\Constants::SITENAME);
         $this->view->metaDescription = __("Créez votre bibliothèque, partagez vos livres et coups de cœur avec la communauté de lecteurs et offrez le bon livre sans risque de doublon", "s1b");
         $this->view->metaKeywords = "BD|bibliotheque|commentaires|communaute|lecteurs|critiques|livres|emprunt|littérature|livre|notice|partage|policier|polar|prêt|recommandation|roman|thriller";
         $this->view->subscribeLink = HTTPHelper::Link(Urls::SUBSCRIBE);
         if ($config->getIsProduction()) {
             $facebookFrame = new FacebookFrame();
             $this->view->faceBookFrame = $facebookFrame->get();
             $ad = new Ad("user_login", "0457389056");
             $this->view->ad = $ad->get();
             $twitter = new TwitterWidget(TwitterSvc::getInstance($config));
             $this->view->twitter = $twitter->get();
             $googlePlus = new GooglePlus();
             $this->view->googlePlus = $googlePlus->get();
         }
         $this->view->placeholder('footer')->append("<script src=\"" . $globalContext->getBaseUrl() . 'Resources/js/simple-carousel/simple.carousel.js' . "\"></script>");
         $this->view->placeholder('footer')->append("<script>\$(function() {initCarousel('carousel-items', 980, 340)});</script>");
         // Getting wish list search widget
         $wishListSearchWidget = new WishListSearchWidget();
         $this->view->wishListSearchWidget = $wishListSearchWidget->get();
         // Set chronicles (last one, last from any groups except bloggers and bookstore, last from bloggers, last from bookstores)
         $this->setViewChronicles();
         // Getting last rated books cover flip
         $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('lastRatedBooks', 30)});</script>\n");
         $lastRatedBooks = BookSvc::getInstance()->getLastRatedBookForHomePage();
         $lastRatedCoverFlip = new BookCoverFlip($lastRatedBooks, __("Derniers livres notés", "s1b"), "lastRatedBooks", "");
         $this->view->lastRatedCoverFlip = $lastRatedCoverFlip->get();
         //             // Get last reviews
         //             $lastReviews = UserEventSvc::getInstance()->getLastEventsOfType(EventTypes::USERBOOK_REVIEW_CHANGE);
         //             $lastReviewsView = new LastReviews($lastReviews, __("Dernières critiques postées", "s1b"));
         //             $this->view->lastReviews = $lastReviewsView->get();
         // Press reviews subscription widget
         $pressReviewsSubscriptionWidget = new PressReviewsSubscriptionWidget();
         $this->view->pressReviewsSubscriptionWidget = $pressReviewsSubscriptionWidget->get();
         // Newsreader
         $pressReviews = $this->getNewsReaderPressReviews();
         if ($pressReviews) {
             $newsReader = new NewsReader($pressReviews);
             $this->view->newsReader = $newsReader->get();
         }
     } 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");
     }
 }
Пример #3
0
 public function get($bookId)
 {
     try {
         $key = self::BOOK_PAGE . "_id_" . $bookId;
         $result = $this->getData($key);
         if ($result === false) {
             $result = new BookPage();
             /* @var Book $book */
             $book = BookDao::getInstance()->get($bookId);
             if (!$book) {
                 return null;
             }
             $result->setBook($book);
             $booksAlsoLiked = BookSvc::getInstance()->getBooksAlsoLiked($bookId, false);
             $result->setBooksAlsoLiked($booksAlsoLiked);
             $booksWithSameAuthor = BookSvc::getInstance()->getBooksWithSameContributors($bookId, false);
             $result->setBooksWithSameAuthor($booksWithSameAuthor);
             $booksWithSameTags = BookSvc::getInstance()->getBooksWithSameTags($bookId, false);
             $result->setBooksWithSameTags($booksWithSameTags);
             $lastlyReadUserbooks = UserBookSvc::getInstance()->getLastlyReadUserbookByBookId($bookId, 5, false);
             $result->setLastlyReadUserbooks($lastlyReadUserbooks);
             $reviewedUserBooks = $this->getReviewedUserBooks($book->getNotDeletedUserBooks());
             $result->setReviewedUserBooks($reviewedUserBooks);
             $pressReviews = $this->getBookPressReviews($book);
             $result->setPressReviews($pressReviews);
             $relatedChronicles = $this->getChroniclesRelativeToBook($book);
             $result->setRelatedChronicles($relatedChronicles);
             $criteria = array("type" => array(false, "=", PressReviewTypes::VIDEO), "book" => array(true, "=", $book), "is_validated" => array(false, "=", 1));
             $videoPressReviews = PressReviewSvc::getInstance()->getList($criteria, 1, false);
             if ($videoPressReviews) {
                 $video = $videoPressReviews[0];
                 $result->setVideoPressReview($video);
             }
             $this->setData($key, $result);
         }
         return $result;
     } catch (\Exception $e) {
         $this->logException(get_class(), __FUNCTION__, $e);
     }
 }
 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();
 }
Пример #5
0
 public function profileAction()
 {
     $globalContext = new \Sb\Context\Model\Context();
     // Users profile are only accessible for connected users
     AuthentificationSvc::getInstance()->checkUserIsConnected();
     $noUser = true;
     $friendId = $this->_getParam("uid");
     if ($friendId) {
         $friend = UserDao::getInstance()->get($friendId);
         $this->view->friend = $friend;
         if ($friend) {
             $noUser = false;
             if ($friend->getId() == $globalContext->getConnectedUser()->getId()) {
                 Flash::addItem(__("Il s'agit de votre profil!", "s1b"));
                 HTTPHelper::redirectToReferer();
             } else {
                 $requestingUser = $globalContext->getConnectedUser();
                 if (SecurityHelper::IsUserAccessible($friend, $requestingUser)) {
                     $this->view->friendSetting = $friend->getSetting();
                     $this->view->isFriend = UserSvc::getInstance()->areUsersFriends($globalContext->getConnectedUser(), $friend);
                     // getting currently reading or lastly read books
                     $currentlyReading = UserBookDao::getInstance()->getReadingNow($friend->getId());
                     $lastlyReads = UserBookDao::getInstance()->getListLastlyRead($friend->getId());
                     if ($currentlyReading && $lastlyReads) {
                         $this->view->currentlyReadingOrLastlyReadBooks = array_merge(array($currentlyReading), $lastlyReads);
                     } elseif ($lastlyReads) {
                         $this->view->currentlyReadingOrLastlyReadBooks = $lastlyReads;
                     } elseif ($currentlyReading) {
                         $this->view->currentlyReadingOrLastlyReadBooks = array($currentlyReading);
                     }
                     // Getting friend currently reading user books
                     $this->view->allCurrentlyReadingUserBooks = UserBookDao::getInstance()->getCurrentlyReadingsNow($friend->getId());
                     if (count($this->view->allCurrentlyReadingUserBooks) > 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-currentreadings', 298, 190)});</script>\n");
                     }
                     // Getting friend last boh books
                     $bohUserBooks = UserBookDao::getInstance()->getListUserBOH($friend->getId());
                     $this->view->bohBooks = array_map(array($this, "getBook"), $bohUserBooks);
                     // Getting books friend could like
                     $this->view->booksHeCouldLikes = BookSvc::getInstance()->getBooksUserCouldLike($friend->getId());
                     if ($this->view->booksHeCouldLikes && count($this->view->booksHeCouldLikes) > 0) {
                         $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('bookUserCouldLike', 90)});</script>\n");
                     }
                     // Getting friend's friends last reviews
                     $this->view->friendLastReviews = UserEventSvc::getInstance()->getUserLastEventsOfType($friend->getId(), EventTypes::USERBOOK_REVIEW_CHANGE);
                     // Getting friend last friends added events
                     $this->view->friendLastFriendsAddedEvents = UserEventSvc::getInstance()->getUserLastEventsOfType($friend->getId(), EventTypes::USER_ADD_FRIEND);
                     if (count($this->view->friendLastFriendsAddedEvents) > 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-friendlastfriends', 298, 85)});</script>\n");
                     }
                     // Getting friend last events
                     $this->view->friendLastEvents = UserEventSvc::getInstance()->getUserLastEventsOfType($friend->getId(), null, 15);
                     $this->view->placeholder('footer')->append("<script>\n\n                            toInit.push(\"attachUserEventsExpandCollapse()\");\n\n                            function attachUserEventsExpandCollapse() {_attachExpandCollapseBehavior(\"js_userLastEvents\", \"userEvent\", \"Voir moins d'activités\", \"Voir plus d'activités\");}\n\n                        </script>\n");
                 } else {
                     Flash::addItem(__("Vous ne pouvez pas accéder à ce profil.", "s1b"));
                     HTTPHelper::redirectToReferer();
                 }
             }
         }
     }
     if ($noUser) {
         Flash::addItem(__("Cet utilisateur n'existe pas.", "s1b"));
         HTTPHelper::redirectToReferer();
     }
 }
Пример #6
0
 /**
  * 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();
 }
Пример #7
0
 /**
  * Show member home page action
  * @global type $globalContextMe
  */
 public function indexAction()
 {
     try {
         $globalContext = new \Sb\Context\Model\Context();
         $globalConfig = new Sb\Config\Model\Config();
         /* @var $connectedUser User */
         $connectedUser = $globalContext->getConnectedUser();
         // Getting friends boh
         $blowOfHeartFriendsBooks = BookDao::getInstance()->getListBOHFriends($connectedUser->getId());
         $this->view->isShowingFriendsBOH = false;
         if (!$blowOfHeartFriendsBooks || count($blowOfHeartFriendsBooks) < 5) {
             // Setting class property with array of friend boh books ids to use it in "notInArray" function below
             $this->blowOfHeartFriendsBooksId = array_map(array(&$this, "getId"), $blowOfHeartFriendsBooks);
             // Getting all users boh
             $blowOfHeartBooks = BookSvc::getInstance()->getBOHForUserHomePage();
             $blowOfHeartBooks = array_filter($blowOfHeartBooks, array(&$this, "notInArray"));
             // Merging 2 arrays
             if ($blowOfHeartFriendsBooks && $blowOfHeartBooks) {
                 $blowOfHeartBooks = array_merge($blowOfHeartFriendsBooks, $blowOfHeartBooks);
             }
             $blowOfHeartBooks = array_slice($blowOfHeartBooks, 0, 5);
         } else {
             $this->view->isShowingFriendsBOH = true;
             $blowOfHeartBooks = $blowOfHeartFriendsBooks;
         }
         $this->view->blowOfHeartBooks = $blowOfHeartBooks;
         // Getting friends user events
         $this->view->userEvents = UserEventDao::getInstance()->getListUserFriendsUserEvents($connectedUser->getId());
         // Getting top books
         $this->view->topsBooks = BookSvc::getInstance()->getTopsUserHomePage();
         // Getting last review by friends
         $lastReviews = UserEventSvc::getInstance()->getFriendsLastEventsOfType($connectedUser->getId(), EventTypes::USERBOOK_REVIEW_CHANGE);
         $this->view->lastReviews = $lastReviews;
         $this->view->lastReviewsView = new LastReviews($lastReviews, __("<strong>Dernières critiques postées par vos amis</strong>", "s1b"));
         // Getting User Reading Widget
         $allCurrentlyReadingUserBooks = UserBookDao::getInstance()->getCurrentlyReadingsNow($connectedUser->getId());
         $userReading = new UserReadingWidget($connectedUser, $allCurrentlyReadingUserBooks, true);
         // If more than one book as 'being read', we need to set the javascript carousel
         if (count($allCurrentlyReadingUserBooks) > 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-currentreadings', 270, 210)});</script>\n");
         }
         $this->view->userReading = $userReading;
         // Getting user wished books widget
         $userWishedBooks = new UserWishedBooksWidget($connectedUser, true);
         $this->view->userWishedBooks = $userWishedBooks;
         // Getting wish list search widget
         $this->view->wishListSearchWidget = new WishListSearchWidget();
         // Getting the ad (second paramters is not used anymore)
         $this->view->ad = new Ad("user_homepage", "6697829998");
         // Getting twitter widget
         $this->view->twitter = new TwitterWidget(TwitterSvc::getInstance($globalConfig));
         // Getting facebook frame
         $this->view->facebookFrame = new FacebookFrame();
         // Get create chronicle links widget
         if ($connectedUser->getIs_partner() && $connectedUser->getGroupusers()) {
             $createChroniclesLink = new CreateChroniclesLinks($connectedUser->getGroupusers());
             $this->view->createChroniclesLinkView = $createChroniclesLink->get();
         }
     } 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");
     }
 }