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();
 }
 private function getSameAuthorChronicles($nbChroniclesToReturn, $useCache = true)
 {
     // Get same author chronicles and add it to model view
     $authorChronicles = ChronicleSvc::getInstance()->getAuthorChronicles($this->chronicle->getUser()->getId(), $useCache);
     if ($authorChronicles) {
         $authorChronicles = ChronicleHelper::getDifferentChronicles($this->chronicle, $authorChronicles, $nbChroniclesToReturn);
     }
     return $authorChronicles;
 }
Example #3
0
 private function getChroniclesRelativeToBook(Book $book)
 {
     $chronicles = null;
     // Get book userbook's tag
     $bookTags = TagSvc::getInstance()->getTagsForBooks(array($book), false);
     $bookTagIds = null;
     foreach ($bookTags as $bookTag) {
         /* @var $bookTag Tag */
         $bookTagIds[] = $bookTag->getId();
     }
     // Get 3 chronicles with same tags
     if ($bookTags && count($bookTags) > 0) {
         $chronicles = ChronicleSvc::getInstance()->getChroniclesWithTags($bookTagIds, 3, false);
     }
     //
     // Get last chronicles of any types and add them to previously set list of chronicles
     if (!$chronicles || count($chronicles) < 3) {
         $lastChronicles = ChronicleSvc::getInstance()->getLastChronicles(3);
         foreach ($lastChronicles as $lastChronicle) {
             $add = true;
             if ($chronicles) {
                 foreach ($chronicles as $chronicle) {
                     if ($chronicle->getId() == $lastChronicle->getId()) {
                         $add = false;
                         break;
                     }
                 }
             }
             if ($add) {
                 $chronicles[] = $lastChronicle;
             }
         }
     }
     if ($chronicles) {
         $chronicles = array_slice($chronicles, 0, 3);
     }
     return $chronicles;
 }
Example #4
0
 private function setViewChronicles()
 {
     // Getting chronicles
     $lastChronicles = ChronicleSvc::getInstance()->getLastAnyType();
     $lastChronicle = array_slice($lastChronicles, 0, 1);
     $lastChronicle = $lastChronicle[0];
     $chronicles = ChronicleSvc::getInstance()->getLastChronicles(13);
     // Init chronicle view model adapter
     $chronicleListAdapter = new ChronicleListAdapter();
     $chronicleView = new PushedChronicle($lastChronicle);
     $this->view->chronicle = $chronicleView->get();
     // Set chronicles from any groups except bloggers and bookstores
     if ($chronicles && count($chronicles) > 0) {
         // We take 12 first chronicles only and different from the last chronicle
         $chronicles = ChronicleHelper::getDifferentChronicles($lastChronicle, $chronicles, 12);
         // Set chronicles view
         $this->view->chronicles = $this->getChronicleView($chronicleListAdapter, $chronicles, __("Dernières <strong>chroniques</strong>", "s1b"), "last-chronicles", $this->view->url(array(), 'chroniclesLastAnyType'), __("Voir d'autres chroniques", "s1b"));
     }
 }
 /**
  * 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();
 }
 public function submitAction()
 {
     try {
         /* @var $globalContext \Sb\Context\Model\Context */
         $globalContext = new \Sb\Context\Model\Context();
         /* @var $user Sb\Db\Model\User */
         $user = $globalContext->getConnectedUser();
         // getting form data
         $userBookForm = new UserBookForm($_POST);
         // getting userbook in DB
         $userBook = UserBookDao::getInstance()->get($userBookForm->getId());
         // Getting the events related to the userbook changes
         $userEvents = UserEventSvc::getInstance()->prepareUserBookEvents($userBook, $userBookForm);
         // On vérifit la correspondance du user
         if ($user->getId() != $userBook->getUser()->getId()) {
             Flash::addItem(__("Le livre que vous souhaitez éditer ne correspond pas à l'utilisateur connecté.", "share1book"));
             HTTPHelper::redirectToLibrary();
         }
         // updating userbook members
         $userBook->setReview($userBookForm->getReview());
         $userBook->setIsBlowOfHeart($userBookForm->getIsBlowOfHeart());
         $userBook->setIsOwned($userBookForm->getIsOwned());
         $userBook->setIsWished($userBookForm->getIsWished());
         $userBook->setRating($userBookForm->getRating());
         $userBook->setNb_of_pages($userBookForm->getNb_of_pages());
         $userBook->setNb_of_pages_read($userBookForm->getNb_of_pages_read());
         $readingState = ReadingStateDao::getInstance()->get($userBookForm->getReadingStateId());
         if ($userBookForm->getReadingDate()) {
             $userBook->setReadingDate($userBookForm->getReadingDate());
         }
         $userBook->setReadingState($readingState);
         $userBook->setHyperlink($userBookForm->getHyperLink());
         if ($userBookForm->getTags()) {
             $tags = new \Doctrine\Common\Collections\ArrayCollection();
             foreach ($userBookForm->getTags() as $tagId) {
                 $tag = TagDao::getInstance()->get($tagId);
                 $tags->add($tag);
             }
             $userBook->setTags($tags);
         }
         // Mise à jour du UserBook
         if (UserBookDao::getInstance()->update($userBook)) {
             // persisting the userevent related to the userbook changes
             UserEventSvc::getInstance()->persistAll($userEvents);
             // Add review as chronicle
             if ($this->_reviewIsModified($userEvents) && $user->IsBlogger()) {
                 ChronicleSvc::getInstance()->addOrUpdateFromUserBook($userBook);
             }
             Flash::addItem(sprintf(__('Le livre "%s" a été mis à jour.', "s1b"), urldecode($userBook->getBook()->getTitle())));
         } else {
             Flash::addItem(__('Une erreur s\'est produite lors de la mise à jour de votre fiche de lecture', 's1b'));
         }
         $referer = ArrayHelper::getSafeFromArray($_POST, "referer", null);
         if ($referer) {
             HTTPHelper::redirectToUrl($referer);
         } else {
             HTTPHelper::redirectToLibrary();
         }
     } catch (\Exception $e) {
         Trace::addItem(sprintf("Une erreur s'est produite dans \"%s->%s\", MESSAGE : %s , TRACE : %s\"", get_class(), __FUNCTION__, $e->getMessage(), $e->getTraceAsString()));
         $this->forward("error", "error", "default");
     }
 }