public function get() { $tplBook = new \Sb\Templates\Template("pushedBooks/pushedBook"); // préparation des champs pour le template // Prepare variables $avgRating = $this->book->getAverageRating(); $roundedRating = floor($avgRating); $ratingCss = "rating-" . $roundedRating; $viewBookLink = \Sb\Helpers\HTTPHelper::Link($this->book->getLink()); $img = \Sb\Helpers\BookHelper::getMediumImageTag($this->book, $this->defImg); $bookTitle = $this->book->getTitle(); $bookDescription = \Sb\Helpers\StringHelper::tronque($this->book->getDescription(), 250); $bookPublication = $this->book->getPublicationInfo(); $bookAuthors = ""; if ($this->book->getContributors()) { $bookAuthors = sprintf("Auteur(s) : %s", $this->book->getOrderableContributors()); } $nbRatings = $this->book->getNbRatedUserBooks(); $nbBlowOfHearts = $this->book->getNbOfBlowOfHearts(); // Set variables $tplBook->setVariables(array("averageRating" => round($avgRating, 2), "ratingCss" => $ratingCss, "isBlowOfHeart" => $this->boh, "nbBlowOfHearts" => $nbBlowOfHearts, "roundedRating" => $roundedRating, "bookTitle" => $bookTitle, "bookDescription" => $bookDescription, "bookPublication" => $bookPublication, "bookAuthors" => $bookAuthors, "viewBookLink" => $viewBookLink, "image" => $img, "nbRatings" => $nbRatings)); return $tplBook->output(); }
public function get() { $tplBook = new \Sb\Templates\Template("pushedUserBooks/pushedUserBook"); // Prepare variables $rating = $this->userBook->getRating(); $boh = $this->userBook->getIsBlowOfHeart(); $ratingCss = "rating-" . $rating; $viewBookLink = \Sb\Helpers\HTTPHelper::Link($this->book->getLink()); $img = \Sb\Helpers\BookHelper::getMediumImageTag($this->book, $this->defImg); $bookTitle = $this->book->getTitle(); $bookDescription = mb_substr($this->book->getDescription(), 0, 250, "utf-8") . "..."; $bookPublication = $this->book->getPublicationInfo(); if ($this->book->getContributors()) { $bookAuthors = sprintf(__("Auteur(s) : %s", "s1b"), $this->book->getOrderableContributors()); } if ($this->userBook->getReadingState()) { $readingStateLabel = $this->userBook->getReadingState()->getLabel(); } $isOwned = $this->userBook->getIsOwned(); $isWished = $this->userBook->getIsWished(); // Set variables $tplBook->setVariables(array("rating" => $rating, "ratingCss" => $ratingCss, "isBlowOfHeart" => $boh, "bookTitle" => $bookTitle, "bookDescription" => $bookDescription, "bookPublication" => $bookPublication, "bookAuthors" => $bookAuthors, "viewBookLink" => $viewBookLink, "image" => $img, "readingStateLabel" => $readingStateLabel, "isOwned" => $isOwned, "isWished" => $isWished, "showingConnectedUserBook" => $this->showingConnectedUserBook)); return $tplBook->output(); }
public function get() { $tpl = new \Sb\Templates\Template("book"); $isInLibrary = false; $averageRating = $this->book->getAverageRating(); $ratingCss = null; if ($averageRating) { $ratingCss = "rating-" . floor($averageRating); } $nbRatings = $this->book->getNbRatedUserBooks(); $rating = null; $isBlowOfHeart = null; $readingStateLabel = null; $lendingText = null; $lendingLink = null; $editBookLink = null; $recommandLink = null; $owned = null; $requestBorrowLink = null; // testing if book is view while a user is connected if ($this->getContext()->getConnectedUser()) { $isConnected = true; // testing if the connected user has the book and if some additionnal informations can be shown $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->getByBookIdAndUserId($this->getContext()->getConnectedUser()->getId(), $this->book->getId()); if ($userBook && !$userBook->getIs_deleted()) { $isInLibrary = true; $rating = $userBook->getRating(); $isBlowOfHeart = $userBook->getIsBlowOfHeart(); if ($userBook->getReadingState()) { $readingStateLabel = $userBook->getReadingState()->getLabel(); } if ($rating) { $ratingCss = "rating-" . $rating; } $lendingLink = ""; if ($userBook->getIsOwned()) { $lendingLink = HTTPHelper::Link(Urls::LENDING_EDIT, array("ubid" => $userBook->getId())); } $lendingText = __("Prêter à un ami", "s1b"); if ($userBook->getActiveLending()) { $lendingText = __("Prêt", "s1b"); } $editBookLink = HTTPHelper::Link(Urls::USER_BOOK_EDIT, array("ubid" => $userBook->getId())); $owned = $userBook->getIsOwned(); $requestBorrowLink = ""; $recommandLink = HTTPHelper::Link(Urls::USER_MAILBOX_RECOMMAND, array("id" => $this->book->getId())); } else { $requestBorrowLink = HTTPHelper::Link(\Sb\Entity\Urls::USER_BOOK_BORROW_FROM_FRIENDS, array("bid" => $this->book->getId())); } } else { $isConnected = false; } $image = \Sb\Helpers\BookHelper::getMediumImageTag($this->book, $this->defImg, true); $bookTitle = $this->book->getTitle(); $bookDescription = $this->book->getDescription(); $bookPublication = $this->book->getPublicationInfo(); $bookAuthors = $this->book->getOrderableContributors(); $titleEsc = ""; $authorEsc = ""; $isbn10 = ""; $isbn13 = ""; $asin = ""; $id = ""; $smallImg = ""; $img = ""; $largeImg = ""; $pubEsc = ""; $pubDtStr = ""; $amazonUrl = ""; $booksUsersAlsoLikedShelf = ""; $booksWithSameTagsShelf = ""; $descEsc = ""; if ($this->addHiddenFields) { $titleEsc = urlencode($this->book->getTitle()); // encodé $authorEsc = urlencode($this->book->getOrderableContributors()); // encodé $id = $this->book->getId(); $isbn10 = $this->book->getISBN10(); $isbn13 = $this->book->getISBN13(); $asin = $this->book->getASIN(); $descEsc = urlencode($this->book->getDescription()); // encodé $smallImg = $this->book->getSmallImageUrl(); $img = $this->book->getImageUrl(); $largeImg = $this->book->getLargeImageUrl(); if ($this->book->getPublisher()) { $pubEsc = urlencode($this->book->getPublisher()->getName()); } // encodé $pubDtStr = ""; if ($this->book->getPublishingDate()) { $pubDtStr = $this->book->getPublishingDate()->format("Y-m-d H:i:s"); } $amazonUrl = $this->book->getAmazonUrl(); } // book reviews $reviews = ""; $nbOfReviewsPerPage = 5; if ($this->reviewedUserBooks) { $paginatedList = new \Sb\Lists\PaginatedList($this->reviewedUserBooks, $nbOfReviewsPerPage); $reviewsView = new \Sb\View\BookReviews($paginatedList, $this->book->getId()); $reviews = $reviewsView->get(); } if ($this->addRecommendations) { // Books users also liked $booksUsersAlsoLikedShelf = ""; if ($this->booksAlsoLiked && count($this->booksAlsoLiked) > 0) { $booksUsersAlsoLikedShelfView = new BookShelf($this->booksAlsoLiked, __("<strong>Les membres</strong> qui ont lu ce livre <strong>ont aussi aimé</strong>", "s1b")); $booksUsersAlsoLikedShelf = $booksUsersAlsoLikedShelfView->get(); } // Books with same tags $booksWithSameTagsShelf = ""; if ($this->booksWithSameTags && count($this->booksWithSameTags) > 0) { $booksWithSameTagsShelfView = new BookShelf($this->booksWithSameTags, __("Les livres <strong>dans la même catégorie</strong>", "s1b")); $booksWithSameTagsShelf = $booksWithSameTagsShelfView->get(); } } $tpl->setVariables(array("isConnected" => $isConnected, "isInLibrary" => $isInLibrary, "rating" => $rating, "nbRatings" => $nbRatings, "averageRating" => $averageRating, "isBlowOfHeart" => $isBlowOfHeart, "readingStateLabel" => $readingStateLabel, "ratingCss" => $ratingCss, "lendingText" => $lendingText, "lendingLink" => $lendingLink, "editBookLink" => $editBookLink, "requestBorrowLink" => $requestBorrowLink, "recommandLink" => $recommandLink, "image" => $image, "bookTitle" => $bookTitle, "bookDescription" => $bookDescription, "bookPublication" => $bookPublication, "bookAuthors" => $bookAuthors, "owned" => $owned, "addReviews" => $this->addReviews, "addButtons" => $this->addButtons, "reviews" => $reviews, "addHiddenFields" => $this->addHiddenFields, "titleEsc" => $titleEsc, "authorEsc" => $authorEsc, "id" => $id, "isbn10" => $isbn10, "isbn13" => $isbn13, "asin" => $asin, "descEsc" => $descEsc, "smallImg" => $smallImg, "img" => $img, "largeImg" => $largeImg, "pubEsc" => $pubEsc, "pubDtStr" => $pubDtStr, "amazonUrl" => $amazonUrl, "isInForm" => $this->isInForm, "booksUsersAlsoLikedShelf" => $booksUsersAlsoLikedShelf, "booksWithSameTagsShelf" => $booksWithSameTagsShelf)); return $tpl->output(); }