Пример #1
0
 /**
  * Get a HeaderInformation from a book object : used on book pages
  * @param \Sb\Service\Sb\Db\Model\Book $book a book object
  * @return \Sb\Model\HeaderInformation HeaderInformation object for book pages
  */
 public function get(Book $book)
 {
     try {
         $result = new HeaderInformation();
         // Set url canonical
         $result->setUrlCanonical(HTTPHelper::Link($book->getLink()));
         // Set title tag
         $publisherName = "";
         if ($book->getPublisher()) {
             $publisherName = $book->getPublisher()->getName();
         }
         //
         // Get if book is an ebook
         $bookIsEbook = !$book->getISBN10() && substr($book->getASIN(), 0, 1) == "B";
         // For tag title, maximum length recommended is 60
         $titlePrefix = "";
         if ($bookIsEbook) {
             $titlePrefix = "ebook ";
         }
         //
         $title = StringHelper::tronque(sprintf(__("%s de %s par %s", "s1b"), $book->getTitle(), $book->getOrderableContributors(), $publisherName), 60 - strlen("...") - strlen($titlePrefix));
         $title = $titlePrefix . $title;
         $result->setTitle($title);
         // Set description
         // For meta description, maximum length recommended is 160
         $descriptionSuffix = "";
         if ($bookIsEbook) {
             $descriptionSuffix = " | numérique";
         }
         //
         $description = StringHelper::tronque($book->getDescription(), 160 - strlen("...") - strlen($descriptionSuffix));
         $description .= $descriptionSuffix;
         // Remove double quotes
         $result->setDescription(str_replace("\"", "", $description));
         // Set keywords
         // Get 2 first tags for keywords
         $bookTags = TagSvc::getInstance()->getTagsForBooks(array($book));
         $tags = "";
         if ($bookTags && count($bookTags) > 0) {
             $firstTags = array_slice($bookTags, 0, 5);
             $firstTagNames = array_map(array(&$this, "getTagName"), $firstTags);
             $tags = implode(" | ", $firstTagNames);
         }
         $keywords = sprintf(__("%s | %s | %s", "s1b"), $book->getTitle(), $book->getOrderableContributors(), $publisherName);
         if ($tags != "") {
             $keywords = sprintf(__("%s | %s | %s | %s", "s1b"), $book->getTitle(), $book->getOrderableContributors(), $publisherName, $tags);
         }
         //
         // Remove double quotes
         $keywords = str_replace("\"", "", $keywords);
         $result->setKeywords($keywords);
         // Set page image
         $result->setPageImage($book->getImageUrl());
         return $result;
     } catch (\Exception $exc) {
         $this->logException(get_class(), __FUNCTION__, $exc);
     }
 }
Пример #2
0
 public static function recommandationBody(\Sb\Db\Model\Book $book)
 {
     $body = __("Découvrez", "s1b") . " " . "<a href='" . \Sb\Helpers\HTTPHelper::Link($book->getLink()) . "'>" . $book->getTitle() . "</a>" . " " . __("de", "s1b") . " " . $book->getOrderableContributors() . '<br/><br/>' . __("L'équipe", "s1b") . " " . \Sb\Entity\Constants::SITENAME . '<br/><br/>' . self::getProfileEditSettingLine();
     return $body;
 }
Пример #3
0
 /**
  * Return true if there is no book with same id in user userbooks and no book with same title in user userbooks
  * @param \Sb\Db\Model\UserBook $book
  * @return type
  */
 private function hasNot(Book $book)
 {
     return !in_array($book->getId(), $this->userUserbooksBookIds, true) && !in_array($book->getTitle(), $this->userUserbooksBookTitles, true);
 }
Пример #4
0
 public function getTitle()
 {
     $this->__load();
     return parent::getTitle();
 }
Пример #5
0
 public static function getLargeImageTag(Book $book, $defaultImg)
 {
     return ImageHelper::getLargeImageTag($book->getLargeImageUrl(), $book->getImageUrl(), $book->getTitle(), $defaultImg);
 }