コード例 #1
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();
 }
コード例 #2
0
 private function showTableSummary($title, $books, \Sb\Context\Model\Context $context)
 {
     $tplRows = array();
     $idx = 0;
     foreach ($books as $book) {
         $idx++;
         $tplRow = new \Sb\Templates\Template("import/tableRow");
         $tplRow->set("isbn", $book->getISBN10());
         $tplRow->set("title", $book->getTitle());
         $tplRow->set("index", $idx);
         $tplRows[] = $tplRow;
     }
     $rows = \Sb\Templates\Template::merge($tplRows);
     $tpl = new \Sb\Templates\Template("import/table");
     $tpl->set("rows", $rows);
     $tpl->set("tableTitle", $title);
     return $tpl->output();
 }
コード例 #3
0
ファイル: BookSearch.php プロジェクト: berliozd/cherbouquin
 /**
  * @return mixed|string
  */
 public function get()
 {
     $lineIdx = 0;
     foreach (array_values($this->shownResults) as $book) {
         $lineIdx++;
         $addSep = true;
         if ($lineIdx == 1) {
             $addSep = false;
         }
         $bk = $book;
         $language = urlencode($bk->getLanguage());
         if ($bk->getImageUrl()) {
             $imgSrc = $bk->getImageUrl();
         } else {
             $imgSrc = $this->defImg;
         }
         // Utilisation de urlencode à la place htmlspecialchars car ce dernier pose des pbs qd la valeur est ensuite passée en post
         $title = $bk->getTitle();
         $titleEsc = urlencode($bk->getTitle());
         // encodé
         $author = $bk->getOrderableContributors();
         $authorEsc = urlencode($bk->getOrderableContributors());
         // encodé
         $id = $bk->getId();
         $isbn10 = $bk->getISBN10();
         $isbn13 = $bk->getISBN13();
         $asin = $bk->getASIN();
         $desc = StringHelper::tronque($bk->getDescription(), 350);
         $descEsc = urlencode($bk->getDescription());
         // encodé
         $smallImg = $bk->getSmallImageUrl();
         $img = $bk->getImageUrl();
         $largeImg = $bk->getLargeImageUrl();
         $pubEsc = "";
         $pubInfo = "";
         if ($bk->getPublisher()) {
             $pubEsc = urlencode($bk->getPublisher()->getName());
             // encodé
             $pubInfo = $bk->getPublicationInfo();
         }
         $pubDtStr = "";
         if ($book->getPublishingDate()) {
             $pubDtStr = $book->getPublishingDate()->format("Y-m-d H:i:s");
         }
         $amazonUrl = $book->getAmazonUrl();
         $nbOfPages = $book->getNb_of_pages();
         $cssClass = $lineIdx % 2 ? "lineA" : "lineB";
         $viewBookLink = null;
         $bookInDB = false;
         if ($bk->getId()) {
             $viewBookLink = HTTPHelper::Link($bk->getLink());
             $bookInDB = true;
         }
         $resultTpl = new Template('searchBook/resultRow');
         $resultTpl->setVariables(array('addSep' => $addSep, 'viewBookLink' => $viewBookLink, 'bookInDB' => $bookInDB, 'cssClass' => $cssClass . ' ' . ($bookInDB ? 'indb' : ''), 'title' => $title, 'publisher' => $pubInfo, 'author' => $author, 'id' => $id, 'isbn10' => $isbn10, 'isbn13' => $isbn13, 'asin' => $asin, 'titleEsc' => $titleEsc, 'descEsc' => $descEsc, 'desc' => $desc, 'smallImg' => $smallImg, 'img' => $img, 'largeImg' => $largeImg, 'imgSrc' => $imgSrc, 'authorEsc' => $authorEsc, 'pubEsc' => $pubEsc, 'pubDtStr' => $pubDtStr, 'amazonUrl' => $amazonUrl, 'language' => $language, 'nbOfPages' => $nbOfPages));
         $resultTplArr[] = $resultTpl;
     }
     $results = Template::merge($resultTplArr);
     $resultsTpl = new Template('searchBook/results');
     $resultsTpl->set("resultRows", $results);
     $links = $this->pagerLinks;
     $resultsTpl->set("links", $links['all']);
     $resultsTpl->set("first", $this->firstItemIdx);
     $resultsTpl->set("last", $this->lastItemIdx);
     $resultsTpl->set("nbItemsTot", $this->nbItemsTot);
     return $resultsTpl->output();
 }
コード例 #4
0
ファイル: BookTable.php プロジェクト: berliozd/cherbouquin
 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();
 }