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(); }
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(); }
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(); }
public function get() { $baseTpl = "components/newsReader"; $tpl = new \Sb\Templates\Template($baseTpl); $tpl->setVariables(array("pressReviews" => $this->pressReviews)); return $tpl->output(); }
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(); }
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(); }
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(); }
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 ""; } }
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(); }
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(); }
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(); }
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(); }
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 ""; } }
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() { $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(); }
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() { $lineIdx = 0; $userBooks = $this->shownResults; $booksTemplates = array(); if ($userBooks) { $i = 0; foreach ($userBooks as $userBook) { $i++; $addSep = true; if ($i == 1) { $addSep = false; } //$book = new \Sb\Db\Model\Book; $book = $userBook->getBook(); // Get row template $rowTpl = new \Sb\Templates\Template("bookList/bookTableRow"); $pictos = \Sb\Helpers\UserBookHelper::getStatusPictos($userBook, $this->friendLibrary); $rowTpl->set("pictos", $pictos); $cssClass = $lineIdx % 2 ? "lineA" : "lineB"; $rowTpl->set("cssClass", $cssClass); $img = ""; if ($book->getSmallImageUrl()) { $img = sprintf("<img src = '%s' class = 'image-thumb-small'/>", $book->getSmallImageUrl()); } else { $img = sprintf("<img src = '%s' border = '0' class = 'image-thumb-small'/>", $this->defImg); } $rowTpl->set("img", $img); $rowTpl->set("title", $book->getTitle()); if ($book->getPublisher()) { $rowTpl->set("publicationInfo", $book->getPublicationInfo()); } else { $rowTpl->set("publicationInfo", ""); } $rowTpl->set("author", $book->getOrderableContributors()); $status = ""; if ($userBook->getReadingState()) { $status = $userBook->getReadingState()->getLabel(); } $readingStateSvc = \Sb\Db\Service\ReadingStateSvc::getInstance(); $readState = $readingStateSvc->getReadSate(); if ($userBook->getReadingState() && $userBook->getReadingState()->getId() == $readState->getId()) { if ($userBook->getReadingDate()) { $status = sprintf(__("%s le %s", "s1b"), $status, $userBook->getReadingDate()->format(__("d/m/Y", "s1b"))); } } $rowTpl->set("status", $status); $rating = $userBook->getRating(); if ($rating || $rating == 0) { $ratingCssClass = "rating-" . $rating; $rowTpl->set("ratingCssClass", "stars " . $ratingCssClass); } else { $rowTpl->set("ratingCssClass", ""); } if ($userBook->getIsBlowOfHeart()) { $rowTpl->set("bohCssClass", "boh"); } else { $rowTpl->set("bohCssClass", ""); } $editLink = HTTPHelper::Link(Urls::USER_BOOK_EDIT, array("ubid" => $userBook->getId())); $deleteLink = HTTPHelper::Link(Urls::USER_BOOK_DELETE, array("ubid" => $userBook->getId())); $viewLink = HTTPHelper::Link($book->getLink()); // Showing "Borrow this book" link only if: // - friend ownes the book // - book is not lent $borrowLink = null; if ($this->friendLibrary && $userBook->getIsOwned() && !$userBook->getActiveLending()) { $borrowLink = \Sb\Helpers\HTTPHelper::Link(Urls::USER_BOOK_BORROW, array("ubid" => $userBook->getId())); } $rowTpl->setVariables(array("addSep" => $addSep, "friendLibrary" => $this->friendLibrary, "editLink" => $editLink, "deleteLink" => $deleteLink, "viewLink" => $viewLink, "borrowLink" => $borrowLink, "bookId" => $book->getId())); $booksTemplates[] = $rowTpl; $lineIdx++; unset($addSep); unset($book); unset($rowTpl); unset($pictos); unset($cssClass); unset($img); unset($status); unset($rating); unset($ratingCssClass); unset($editLink); unset($deleteLink); unset($viewLink); unset($borrowLink); unset($userBook); } } $bookListTpl = new \Sb\Templates\Template("bookList/bookTable"); if ($booksTemplates) { // Get row header template $headerTpl = new \Sb\Templates\Template("bookList/bookTableHeader"); // Assignation des classe pour afficher le petit picto indiquant le sens de tri if ($this->listOptions) { if ($this->listOptions->getSorting()) { if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_AUTHOR) { $headerTpl->set("titlesortingdirection", ""); $headerTpl->set("ratingsortingdirection", ""); $headerTpl->set("authorsortingdirection", $this->listOptions->getSorting()->getDirection()); $headerTpl->set("statesortingdirection", ""); } if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_RATING) { $headerTpl->set("titlesortingdirection", ""); $headerTpl->set("ratingsortingdirection", $this->listOptions->getSorting()->getDirection()); $headerTpl->set("authorsortingdirection", ""); $headerTpl->set("statesortingdirection", ""); } if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_TITLE) { $headerTpl->set("titlesortingdirection", $this->listOptions->getSorting()->getDirection()); $headerTpl->set("ratingsortingdirection", ""); $headerTpl->set("authorsortingdirection", ""); $headerTpl->set("statesortingdirection", ""); } if ($this->listOptions->getSorting()->getField() == \Sb\Helpers\BooksHelper::SORTING_FIELD_STATE) { $headerTpl->set("titlesortingdirection", ""); $headerTpl->set("ratingsortingdirection", ""); $headerTpl->set("authorsortingdirection", ""); $headerTpl->set("statesortingdirection", $this->listOptions->getSorting()->getDirection()); } } } $headerTpl->setVariables(array("friendLibrary" => $this->friendLibrary)); $bookListTpl->set("tableHeader", $headerTpl->output()); $booksToShow = \Sb\Templates\Template::merge($booksTemplates); $bookListTpl->set("booksToShow", $booksToShow); $links = $this->pagerLinks; $bookListTpl->set("links", $links['all']); $bookListTpl->set("first", $this->firstItemIdx); $bookListTpl->set("last", $this->lastItemIdx); $bookListTpl->set("nbItemsTot", $this->nbItemsTot); $listSearchDefValue = __("Un titre, un auteur, ISBN dans ma bibliothèque", "s1b"); $bookListTpl->set("listSearchDefValue", $listSearchDefValue); if ($this->searchValue) { $bookListTpl->set("listSearchValue", $this->searchValue); } else { $bookListTpl->set("listSearchValue", $listSearchDefValue); } $key = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "key", null); $bookListTpl->set("key", $key); $selectedAuthorLetter = null; $selectedTitleLetter = null; $filtertype = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filtertype", null); if ($filtertype == \Sb\Lists\FilteringType::AUTHOR_FIRST_LETTER) { $selectedAuthorLetter = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filter", null); } elseif ($filtertype == \Sb\Lists\FilteringType::TITLE_FIRST_LETTER) { $selectedTitleLetter = \Sb\Helpers\ArrayHelper::getSafeFromArray($_GET, "filter", null); } $bookListTpl->setVariables(array("authorsFirstLetters" => $this->authorsFirstLetters, "titlesFirstLetters" => $this->titlesFirstLetters, "selectedTitleLetter" => $selectedTitleLetter, "selectedAuthorLetter" => $selectedAuthorLetter, "emptyList" => false)); } else { $bookListTpl->setVariables(array("emptyList" => true)); } return $bookListTpl->output(); }
public function get() { $tpl = new \Sb\Templates\Template("components/contentSearch"); $tpl->setVariables(array("action" => $this->action, "tags" => $this->tags, "selectedTagId" => $this->selectedTagId, "searchLabel" => $this->searchLabel, "pageKey" => $this->pageKey, "searchTerm" => $this->searchTerm, "initUrl" => $this->initUrl)); return $tpl->output(); }
public function get() { $tpl = new \Sb\Templates\Template("lastReviews"); $tpl->setVariables(array("lastReviews" => $this->lastReviews, "defaultImage" => $this->defImg, "title" => $this->title)); return $tpl->output(); }
public function get() { $tpl = new \Sb\Templates\Template("sameAuthorBooks"); $tpl->setVariables(array("books" => $this->books)); return $tpl->output(); }
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(); }
public function get() { $tpl = new \Sb\Templates\Template("userEvents"); $tpl->setVariables(array("events" => $this->userEvents, "showOwner" => $this->showOwner)); return $tpl->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(); }
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(); }
public function get() { $tpl = new \Sb\Templates\Template("components/friendsPageNavigation"); $tpl->setVariables(array("activeItem" => $this->activeItem)); return $tpl->output(); }