コード例 #1
0
ファイル: ButtonsBar.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $referer = HTTPHelper::getReferer();
     $tpl = new \Sb\Templates\Template("book/buttonsBar");
     $tpl->setVariables(array("buttonText" => $this->buttonText, "addButton" => $this->addButton, "referer" => $referer));
     return $tpl->output();
 }
コード例 #2
0
ファイル: NewsReader.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $baseTpl = "components/newsReader";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $tpl->setVariables(array("pressReviews" => $this->pressReviews));
     return $tpl->output();
 }
コード例 #3
0
 public function get()
 {
     $baseTpl = "components/readingWhatForm";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $tpl->setVariables(array("coverImage" => $this->getContext()->getBaseUrl() . "Resources/images/nocover.png"));
     return $tpl->output();
 }
コード例 #4
0
 public function get()
 {
     $baseTpl = "book/bookForm/lending";
     // Préparation de l'historique des prêts
     // ----------------------------------------------
     $activeLending = null;
     $lendingLines = array();
     foreach ($this->lendings as $lending) {
         // Si le prêt est encore actif, la ligne n'est pas affichée dans l'historique
         if ($lending->getState() != \Sb\Lending\Model\LendingState::IN_ACTIVE) {
             $activeLending = $lending;
         } else {
             $lendingLineTpl = new \Sb\Templates\Template($baseTpl . "/inActiveLendingLine");
             $lendingLineTpl->set("borrowerName", $lending->getBorrower_userbook()->getUser()->getFirstName() . " " . $lending->getBorrower_userbook()->getUser()->getLastName());
             $lendingLineTpl->set("startDate", $lending->getStartDate()->format(__("d/m/Y", "s1b")));
             $lendingLineTpl->set("endDate", $lending->getEndDate()->format(__("d/m/Y", "s1b")));
             $lendingLines[] = $lendingLineTpl;
         }
     }
     $lendingsHisto = new \Sb\Templates\Template($baseTpl . "/lendingsHisto");
     // Si les lignes d'historiques en sont pas nulles, affichage sous forme de liste
     if ($lendingLines) {
         $lendingLinesTpl = \Sb\Templates\Template::merge($lendingLines);
         $lendingsHisto->set("histo", "<ul>" . $lendingLinesTpl . "</ul>");
     } else {
         // Sinon affichage d'un libellé "vide" ou "aucun"
         $lendingsHisto->set("histo", __("aucun", "s1b"));
     }
     return $lendingsHisto->output();
 }
コード例 #5
0
ファイル: UserProfile.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $tpl = new \Sb\Templates\Template("userProfile");
     // Set variables
     $tpl->setVariables(array("user" => $this->user, "userSettings" => $this->userSettings, "addStatus" => $this->addStatus, "addLinks" => $this->addLinks, "isOtherUser" => $this->isOtherUser));
     return $tpl->output();
 }
コード例 #6
0
 public function get()
 {
     $tpl = new \Sb\Templates\Template("otherUserProfile");
     // Set variables
     $tpl->setVariables(array("user" => $this->user, "userSettings" => $this->userSettings, "isFriend" => $this->isFriend));
     return $tpl->output();
 }
コード例 #7
0
ファイル: BookReviews.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $baseTpl = "book/bookReviews/reviews";
     $tplReviews = new \Sb\Templates\Template($baseTpl);
     $connectedUser = $this->getContext()->getConnectedUser();
     $tplReviews->setVariables(array("bookId" => $this->bookId, "userBooks" => $this->paginatedList->getItems(), "connectedUser" => $connectedUser, "navigation" => $this->paginatedList->getNavigationBar(), "firstItemIdx" => $this->paginatedList->getFirstPage(), "lastItemIdx" => $this->paginatedList->getLastPage(), "nbItemsTot" => $this->paginatedList->getTotalPages(), "pageNumber" => $this->pageNumber));
     return $tplReviews->output();
 }
コード例 #8
0
 public function get()
 {
     if ($this->getConfig()->getIsProduction()) {
         $tpl = new \Sb\Templates\Template("components/facebookFrame");
         return $tpl->output();
     } else {
         return "";
     }
 }
コード例 #9
0
ファイル: GooglePlus.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     // Renders the google plus only on production
     if ($this->getConfig()->getIsProduction()) {
         $tpl = new \Sb\Templates\Template("components/googlePlus");
         return $tpl->output();
     } else {
         return "";
     }
 }
コード例 #10
0
 public function get()
 {
     $baseTpl = "lastUsersWhoReadThatBook";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $params = array();
     $params["defImage"] = $this->defImg;
     $params["userbooks"] = $this->userbooks;
     $tpl->setVariables($params);
     return $tpl->output();
 }
コード例 #11
0
 public function get()
 {
     $baseTpl = "components/friendsWidget";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $user = $this->getContext()->getConnectedUser();
     $nbFriends = count($user->getAcceptedFriends());
     $nbPendingFriendRequests = count($user->getPendingFriendShips());
     $params = array("nbFriends" => $nbFriends, "nbPendingFriendRequests" => $nbPendingFriendRequests);
     $tpl->setVariables($params);
     return $tpl->output();
 }
コード例 #12
0
ファイル: Ad.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     // Renders the ads only on production
     if ($this->getConfig()->getIsProduction()) {
         $tpl = new \Sb\Templates\Template("components/ad");
         $tpl->setVariables(array("label" => $this->label, "code" => $this->code));
         return $tpl->output();
     } else {
         return "";
     }
 }
コード例 #13
0
 public function get()
 {
     $baseTpl = "components/mailboxWidget";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $user = $this->getContext()->getConnectedUser();
     $nbMessagesToRead = count($user->getUnReadReceivedMessages());
     $nbPendingRequests = count($user->getPendingFriendShips());
     $params = array("nbPendingRequests" => $nbPendingRequests, "nbMessagesToRead" => $nbMessagesToRead);
     $tpl->setVariables($params);
     return $tpl->output();
 }
コード例 #14
0
 public function get()
 {
     $baseTpl = "otherUserLastFriends";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $params = array();
     $params["defImage"] = $this->defImg;
     $params["otherUserFriendsAddedEvents"] = $this->otherUserFriendsAddedEvents;
     $params["otherUser"] = $this->otherUser;
     $tpl->setVariables($params);
     return $tpl->output();
 }
コード例 #15
0
 public function get()
 {
     $baseTpl = "components/userReading";
     $tpl = new \Sb\Templates\Template($baseTpl);
     $params = array();
     $params["defImage"] = $this->getContext()->getDefaultImage();
     $params["currentlyReadingUserBooks"] = $this->currentlyReadingUserBooks;
     $params["isCurrentConnectedUser"] = $this->isCurrentConnectedUser;
     $params["user"] = $this->user;
     $tpl->setVariables($params);
     return $tpl->output();
 }
コード例 #16
0
 public function get()
 {
     if ($this->getConfig()->getIsProduction()) {
         $content = $this->twitterSvc->getContent();
         $user_image = "https://pbs.twimg.com/profile_images/2583277032/yxdfpkrxzfqs5et4s5vt.png";
         $user = "******";
         /* Nom d'utilisateur sur Twitter */
         $tpl = new \Sb\Templates\Template("components/twitterWidget");
         $tpl->setVariables(array("content" => $content, "user" => $user, "user_image" => $user_image));
         return $tpl->output();
     } else {
         return "";
     }
 }
コード例 #17
0
ファイル: PushedBooks.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     if ($this->books) {
         $templatesBooks = "";
         foreach ($this->books as $book) {
             $pushedBookView = new \Sb\View\PushedBook($book, $this->boh);
             $templatesBooks .= $pushedBookView->get();
         }
         $nbBooks = count($this->books);
         if ($nbBooks <= $this->nbBooksShownByDefault) {
             $bottomLink = "";
         } else {
             $tplBottomLink = new \Sb\Templates\Template("components/seeMore");
             $bottomLink = $tplBottomLink->output();
         }
         return $templatesBooks . $bottomLink;
     } else {
         return "";
     }
 }
コード例 #18
0
 public function get()
 {
     $user = $this->getContext()->getConnectedUSer();
     $nbMessagesToRead = count($user->getUnReadReceivedMessages());
     $nbPendingFriendRequests = count($user->getPendingFriendShips());
     $tpl = new \Sb\Templates\Template("components/userNavigation");
     $statusCssClass = "";
     $userStatus = "";
     if ($user && $user->getSetting()) {
         if ($user->getSetting()->getDisplayProfile() == \Sb\Entity\UserDataVisibility::FRIENDS) {
             $userStatus = "Mes amis";
             $statusCssClass = "profile-picto-small-myfriends";
         } elseif ($user->getSetting()->getDisplayProfile() == "s1b_members") {
             $userStatus = "Public";
             $statusCssClass = "profile-picto-small-public";
         } elseif ($user->getSetting()->getDisplayProfile() == \Sb\Entity\UserDataVisibility::NO_ONE) {
             $userStatus = "Privé";
             $statusCssClass = "profile-picto-small-private";
         }
     }
     $tpl->setVariables(array("user" => $user, "userStatus" => $userStatus, "statusCssClass" => $statusCssClass, "nbMessagesToRead" => $nbMessagesToRead, "nbPendingFriendRequests" => $nbPendingFriendRequests));
     return $tpl->output();
 }
コード例 #19
0
ファイル: PushedBook.php プロジェクト: berliozd/cherbouquin
 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();
 }
コード例 #20
0
 public function get()
 {
     if ($this->userBooks) {
         $templatesBooks = "";
         foreach ($this->userBooks as $userBookExt) {
             $pushedBookView = new \Sb\View\PushedUserBook($this->showingConnectedUserBook, $userBookExt);
             $templatesBooks .= $pushedBookView->get();
         }
         $tpl = new \Sb\Templates\Template("pushedBooks");
         $tpl->set("books", $templatesBooks);
         \Sb\Trace\Trace::addItem("Nb books in total : " . count($this->userBooks));
         \Sb\Trace\Trace::addItem("Nb books shown by default : " . $this->nbBooksShownByDefault);
         $nbBooks = count($this->userBooks);
         if ($nbBooks <= $this->nbBooksShownByDefault) {
             $tpl->set("bottomLink", "");
         } else {
             $tplBottomLink = new \Sb\Templates\Template("components/seeMore");
             $tpl->set("bottomLink", $tplBottomLink->output());
         }
         return $tpl->output();
     } else {
         return "";
     }
 }
コード例 #21
0
 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();
 }
コード例 #22
0
ファイル: MailHelper.php プロジェクト: berliozd/cherbouquin
 public static function lendingRequestEmailBody($password, $login, $bookTitle)
 {
     $bodyTpl = new \Sb\Templates\Template('email/lendingRequest');
     $bodyTpl->set("url", \Sb\Helpers\HTTPHelper::Link(""));
     $bodyTpl->set("password", $password);
     $bodyTpl->set("login", $login);
     $bodyTpl->set("title", $bookTitle);
     $body = $bodyTpl->output();
     return $body;
 }
コード例 #23
0
ファイル: BookList.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     // Préparation du template
     $booksTpl = new \Sb\Templates\Template("bookList");
     $booksTpl->set("bookList", $this->booksTableView->get());
     $booksTpl->set("listTitle", __("Tous", "s1b"));
     $booksTpl->set("listCssClass", $this->cssClass);
     $booksTpl->set("key", $this->key);
     // affichage du template
     return $booksTpl->output();
 }
コード例 #24
0
ファイル: Lending.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $tpl = new \Sb\Templates\Template("book/bookForm/lending");
     // display lendings histo
     if ($this->userBook->getLendings()) {
         $lendingView = new \Sb\View\LendingsHisto($this->userBook->getLendings(), $this->userBook, $this->connectedUserId);
         $tpl->set("lendingsHisto", $lendingView->get());
     } else {
         $tpl->set("lendingsHisto", "");
     }
     // display borrowings histo
     if ($this->userBook->getBorrowings()) {
         $borrowingView = new \Sb\View\BorrowingsHisto($this->userBook->getBorrowings(), $this->userBook, $this->connectedUserId);
         $tpl->set("borrowingsHisto", $borrowingView->get());
     } else {
         $tpl->set("borrowingsHisto", $borrowingView->get());
     }
     // display form
     $lendingForm = new \Sb\View\LendingForm($this->userBook->getLendings(), $this->userBook->getBorrowings(), $this->userBook, $this->connectedUserId);
     $tpl->set("lendingForm", $lendingForm->get());
     return $tpl->output();
 }
コード例 #25
0
ファイル: Book.php プロジェクト: berliozd/cherbouquin
 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();
 }
コード例 #26
0
 public function get()
 {
     $tpl = new \Sb\Templates\Template("components/friendsPageNavigation");
     $tpl->setVariables(array("activeItem" => $this->activeItem));
     return $tpl->output();
 }
コード例 #27
0
ファイル: LoginForm.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $baseTpl = "components/loginForm";
     $tpl = new \Sb\Templates\Template($baseTpl);
     return $tpl->output();
 }
コード例 #28
0
ファイル: UserBook.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $baseTpl = "book/bookForm/userBook";
     $readingStateSvc = \Sb\Db\Service\ReadingStateSvc::getInstance();
     $readingStates = $readingStateSvc->getReadingStates();
     $readingStateOptions = "";
     if ($readingStates) {
         foreach ($readingStates as $readingState) {
             $selected = "";
             if ($this->userBook->getReadingState() && $readingState->getId() == $this->userBook->getReadingState()->getId()) {
                 $selected = "selected";
             }
             $readingStateOptions .= "<option value='" . $readingState->getId() . "' {$selected}>" . $readingState->getLabel() . "</option>";
         }
     }
     $readState = $readingStateSvc->getReadSate();
     $tpl = new \Sb\Templates\Template($baseTpl);
     $tpl->set("id", $this->userBook->getId());
     if ($this->userBook->getUser()) {
         $tpl->set("userid", $this->userBook->getUser()->getId());
     } else {
         $tpl->set("userid", "");
     }
     if ($this->userBook->getBook()) {
         $tpl->set("bookid", $this->userBook->getBook()->getId());
     } else {
         $tpl->set("bookid", "");
     }
     if ($this->addMode) {
         $tpl->set("pictos", "");
     } else {
         $tpl->set("pictos", \Sb\Helpers\UserBookHelper::getStatusPictos($this->userBook));
     }
     $tpl->set("readingStateOptions", $readingStateOptions);
     $tpl->set("review", $this->userBook->getReview());
     $rating = $this->userBook->getRating();
     if (isset($rating)) {
         $ratingCssClass = "rating-" . $rating;
     } else {
         $ratingCssClass = "no-rating";
     }
     $tpl->set("ratingCssClass", $ratingCssClass);
     $tpl->set("rating", $rating);
     if ($this->userBook->getReadingState()) {
         $tpl->set("displayReadingDateBlock", $this->userBook->getReadingState()->getId() != \Sb\Entity\ReadingStates::READ ? "noDisplay" : "");
         $displayNbPagesRead = $this->userBook->getReadingState()->getId() != \Sb\Entity\ReadingStates::READING ? "noDisplay" : "";
     } else {
         $tpl->set("displayReadingDateBlock", "noDisplay");
         $displayNbPagesRead = "noDisplay";
     }
     // Getting book total nb of pages
     $nb_of_pages = $this->userBook->getBook()->getNb_of_pages();
     if ($this->userBook->getNb_of_pages()) {
         $nb_of_pages = $this->userBook->getNb_of_pages();
     }
     // Gettign nb of pages read
     $nb_of_pages_read = $this->userBook->getNb_of_pages_read();
     $tpl->set("isBlowOfHeartChecked", $this->userBook->getIsBlowOfHeart() ? "checked" : "");
     if ($this->addMode) {
         $tpl->set("borrow", sprintf("<a href=\"%s\">%s</a>", "", __("Emprunter ce livre", "s1b")));
     } else {
         $tpl->set("borrow", __("", ""));
     }
     $borrowerName = "";
     $lenderName = "";
     $oneActiveLending = false;
     $oneActiveBorrowing = false;
     $lending = $this->userBook->getActiveLending();
     if ($lending) {
         $oneActiveLending = true;
         $borrowerName = $lending->getBorrower_userbook()->getUser()->getFirstName() . " " . $lending->getBorrower_userbook()->getUser()->getLastName();
     }
     $borrowing = $this->userBook->getActiveBorrowing();
     if ($borrowing) {
         $oneActiveBorrowing = true;
         if ($borrowing->getUserBook()) {
             $lenderName = $borrowing->getUserBook()->getUser()->getFirstName() . " " . $borrowing->getUserBook()->getUser()->getLastName();
         } elseif ($borrowing->getGuest()) {
             $lenderName = sprintf(__("%s (invité)", "s1b"), $borrowing->getGuest()->getName());
         }
     }
     $showLending = true;
     if ($this->addMode || !$this->userBook->getIsOwned() && !$oneActiveBorrowing) {
         $showLending = false;
     }
     $tpl->set("editLendingText", __("Prêtez ce livre", "s1b"));
     if (!$oneActiveBorrowing && !$oneActiveLending) {
         $tpl->set("lendingLabel", "");
     } else {
         if ($oneActiveLending) {
             $tpl->set("lendingLabel", sprintf(__("Vous prêtez actuellement ce livre à %s", "s1b"), $borrowerName));
             $tpl->set("editLendingText", __("Détail", "s1b"));
         } else {
             if ($oneActiveBorrowing) {
                 $tpl->set("lendingLabel", sprintf(__("Vous empruntez actuellement ce livre à %s.", "s1b"), $lenderName));
                 $tpl->set("editLendingText", __("Détail", "s1b"));
             } else {
                 $tpl->set("lendingLabel", "");
             }
         }
     }
     $tpl->set("isOwned", $this->userBook->getIsOwned() ? "checked" : "");
     $tpl->set("isWished", $this->userBook->getIsWished() ? "checked" : "");
     $tpl->set("editLendingLink", \Sb\Helpers\HTTPHelper::Link(\Sb\Entity\Urls::LENDING_EDIT, array("ubid" => $this->userBook->getId())));
     $tpl->set("readingDate", $this->userBook->getReadingDate() ? $this->userBook->getReadingDate()->format(__("d/m/Y", "s1b")) : "");
     $tpl->set("hyperlink", $this->userBook->getHyperlink());
     $script = "";
     if ($readState) {
         $script = sprintf("<script>var share1bookAddABookJs = {readstate : \"%s\"}</script>", $readState->getId());
     }
     // Get all the tags
     $labelCol = $this->getTagLabelCol();
     $tags = \Sb\Db\Service\TagSvc::getInstance()->getAllTags($labelCol);
     if (!$this->addMode) {
         // Get the tags assigned to the userbook
         $this->userBookTags = $this->userBook->getTags();
         $tagsExt = array_map(array($this, "isChecked"), $tags);
     }
     $tpl->setVariables(array("addMode" => $this->addMode, "showLending" => $showLending, "tags" => $tags, "tagsExt" => $tagsExt, "nb_of_pages" => $nb_of_pages, "nb_of_pages_read" => $nb_of_pages_read, "displayNbPagesRead" => $displayNbPagesRead));
     return $tpl->output();
 }
コード例 #29
0
ファイル: UserEvent.php プロジェクト: berliozd/cherbouquin
 public function get()
 {
     $globalContext = new \Sb\Context\Model\Context();
     $tplEvent = new \Sb\Templates\Template("userEvents/userEvent");
     $friend = $this->userEvent->getUser();
     $friendImg = UserHelper::getSmallImageTag($friend);
     if ($friendImg == "") {
         $friendImg = UserHelper::getSmallImageTag($friend);
     }
     $friendName = $friend->getUserName();
     $friendProfileLink = HTTPHelper::Link(Urls::USER_PROFILE, array("uid" => $friend->getId()));
     $userBookRelated = false;
     $friendRelated = false;
     // used for cases of new friend event
     $additionalContent = "";
     $friendId = null;
     $friendFriendImg = null;
     $friendFriendProfileLink = null;
     switch ($this->userEvent->getType_id()) {
         case EventTypes::USERBOOK_ADD:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a ajouté un livre.", $friendProfileLink, $friendName);
             $userBookRelated = true;
             break;
         case EventTypes::USERBOOK_RATING_CHANGE:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $newRating = $this->userEvent->getNew_value();
             $resume = sprintf("<div class=\"ue-rating-label\"><a href=\"%s\" class=\"link\">%s</a> a noté.</div> <div class=\"rating rating-" . $newRating . "\"></div>", $friendProfileLink, $friendName);
             $userBookRelated = true;
             break;
         case EventTypes::USERBOOK_BLOWOFHEART_CHANGE:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $isBoh = $this->userEvent->getNew_value();
             $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a supprimé son coup de coeur.", $friendProfileLink, $friendName);
             if ($isBoh) {
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a marqué comme coup de coeur.", $friendProfileLink, $friendName);
             }
             $userBookRelated = true;
             break;
         case EventTypes::USERBOOK_REVIEW_CHANGE:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $oldReview = $this->userEvent->getOld_value();
             $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a modifié son commentaire.", $friendProfileLink, $friendName);
             if ($oldReview == "") {
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a ajouté un commentaire.", $friendProfileLink, $friendName);
             }
             $additionalContent = StringHelper::tronque(strip_tags($this->userEvent->getNew_value()), 120);
             $userBookRelated = true;
             break;
         case EventTypes::USERBOOK_HYPERLINK_CHANGE:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $oldHyperLink = $this->userEvent->getOld_value();
             $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a modifié son lien hypertexte.", $friendProfileLink, $friendName);
             if ($oldHyperLink == "") {
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a ajouté un lien hypertexte.", $friendProfileLink, $friendName);
             }
             $hyperLink = "http://" . $this->userEvent->getNew_value();
             $truncatedHyperLink = \Sb\Helpers\StringHelper::tronque($hyperLink, 100);
             $additionalContent = sprintf(__("<a href=\"%s\" target=\"_blank\" class=\"hyperlink link\" >%s</a>", "s1b"), $hyperLink, $truncatedHyperLink);
             $userBookRelated = true;
             break;
         case EventTypes::USERBOOK_READINGSTATE_CHANGE:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $newReadingSateId = $this->userEvent->getNew_value();
             switch ($newReadingSateId) {
                 case ReadingStates::NOTREAD:
                     $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a marqué non lu.", $friendProfileLink, $friendName);
                     break;
                 case ReadingStates::READING:
                     $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> lit actuellement.", $friendProfileLink, $friendName);
                     break;
                 case ReadingStates::READ:
                     $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a lu.", $friendProfileLink, $friendName);
                     break;
             }
             $userBookRelated = true;
             break;
         case EventTypes::USERBOOK_WISHEDSTATE_CHANGE:
             $userBook = \Sb\Db\Dao\UserBookDao::getInstance()->get($this->userEvent->getItem_id());
             $newWishedSateValue = $this->userEvent->getNew_value();
             $oldWishedSateValue = $this->userEvent->getOld_value();
             if ($newWishedSateValue) {
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a marqué comme souhaité.", $friendProfileLink, $friendName);
             } elseif ($oldWishedSateValue) {
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> ne souhaite plus.", $friendProfileLink, $friendName);
             }
             $userBookRelated = true;
             break;
         case EventTypes::USER_ADD_FRIEND:
             $friendNewFriendProfileLink = null;
             $newFriendId = $this->userEvent->getNew_value();
             if ($this->getContext()->getConnectedUser() && $newFriendId == $this->getContext()->getConnectedUser()->getId()) {
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> est ami avec moi.", $friendProfileLink, $friendName);
                 $friendFriendImg = UserHelper::getXSmallImageTag($this->getContext()->getConnectedUser());
             } else {
                 $friendNewFriend = UserDao::getInstance()->get($newFriendId);
                 $friendNewFriendProfileLink = HTTPHelper::Link(Urls::USER_PROFILE, array("uid" => $friendNewFriend->getId()));
                 $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> est ami avec <a class=\"link\" href=\"%s\">%s</a>.", $friendProfileLink, $friendName, $friendNewFriendProfileLink, $friendNewFriend->getUserName());
                 $friendFriendImg = UserHelper::getXSmallImageTag($friendNewFriend);
             }
             $friendId = $newFriendId;
             $friendFriendProfileLink = $friendNewFriendProfileLink;
             $friendRelated = true;
             break;
         case EventTypes::USER_BORROW_USERBOOK:
             $lendingId = $this->userEvent->getNew_value();
             $lending = LendingDao::getInstance()->get($lendingId);
             $userBookBorrowed = $lending->getUserBook();
             $userBook = $userBookBorrowed;
             $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a emprunté le livre à %s.", $friendProfileLink, $friendName, $userBookBorrowed->getUser()->getUserName());
             if ($this->getContext()->getConnectedUser()) {
                 if ($userBookBorrowed->getUser()->getId() == $this->getContext()->getConnectedUser()->getId()) {
                     $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> m'a emprunté le livre.", $friendProfileLink, $friendName);
                 }
             }
             $userBookRelated = true;
             break;
         case EventTypes::USER_LEND_USERBOOK:
             $lendingId = $this->userEvent->getNew_value();
             $lending = LendingDao::getInstance()->get($lendingId);
             $userBookLended = $lending->getBorrower_UserBook();
             $userBook = $userBookLended;
             $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> a prêté le livre à %s.", $friendProfileLink, $friendName, $userBookLended->getUser()->getUserName());
             if ($this->getContext()->getConnectedUser()) {
                 if ($userBookLended->getUser()->getId() == $this->getContext()->getConnectedUser()->getId()) {
                     $resume = sprintf("<a href=\"%s\" class=\"link\">%s</a> m'a prêté le livre.", $friendProfileLink, $friendName);
                 }
             }
             $userBookRelated = true;
             break;
         default:
             break;
     }
     $creationDate = $this->userEvent->getCreation_date()->format(__("d/m/Y à H:m", "s1b"));
     $bookImageUrl = null;
     $bookLink = null;
     $bookTitle = null;
     $bookAuthor = null;
     $bookId = null;
     $bookImgTag = null;
     if ($userBookRelated) {
         $bookImageUrl = $userBook->getBook()->getSmallImageUrl();
         $bookImgTag = BookHelper::getSmallImageTag($userBook->getBook(), $this->getContext()->getDefaultImage());
         $bookLink = HTTPHelper::Link($userBook->getBook()->getLink());
         $bookTitle = $userBook->getBook()->getTitle();
         $bookAuthor = $userBook->getBook()->getOrderableContributors();
         $bookId = $userBook->getBook()->getId();
     }
     $showAddButton = false;
     if ($globalContext->getConnectedUser()) {
         $showAddButton = true;
     }
     // Set variables
     $tplEvent->setVariables(array("friendImg" => $friendImg, "friendName" => $friendName, "resume" => $resume, "bookImageUrl" => $bookImageUrl, "bookImgTag" => $bookImgTag, "friendProfileLink" => $friendProfileLink, "friendId" => $friendId, "bookTitle" => $bookTitle, "bookId" => $bookId, "bookAuthor" => $bookAuthor, "creationDate" => $creationDate, "bookLink" => $bookLink, "additionalContent" => $additionalContent, "userBookRelated" => $userBookRelated, "userFriendRelated" => $friendRelated, "friendFriendImg" => $friendFriendImg, "friendFriendProfileLink" => $friendFriendProfileLink, "showOwner" => $this->showOwner, "showAddButton" => $showAddButton));
     return $tplEvent->output();
 }
コード例 #30
0
 public function get()
 {
     $tpl = new \Sb\Templates\Template("components/friendsSearchForm");
     return $tpl->output();
 }