/** * 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"); } }
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(); } }
/** * 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"); } }
/** * 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"); } }