Begin to reorganize a little book.php. Still a mess.
This commit is contained in:
parent
fe7ec53487
commit
3f5dd74361
72
book.php
72
book.php
|
@ -115,6 +115,18 @@ class Book extends Base {
|
||||||
return "?page=".parent::PAGE_BOOK_DETAIL."&id=$this->id";
|
return "?page=".parent::PAGE_BOOK_DETAIL."&id=$this->id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDetailUrl ($permalink = false) {
|
||||||
|
$urlParam = $this->getUri ();
|
||||||
|
if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
|
||||||
|
return 'index.php' . $urlParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle () {
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Json export */
|
||||||
|
|
||||||
public function getContentArray () {
|
public function getContentArray () {
|
||||||
global $config;
|
global $config;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -166,6 +178,7 @@ class Book extends Base {
|
||||||
"seriesurl" => $su);
|
"seriesurl" => $su);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFullContentArray () {
|
public function getFullContentArray () {
|
||||||
global $config;
|
global $config;
|
||||||
$out = $this->getContentArray ();
|
$out = $this->getContentArray ();
|
||||||
|
@ -196,15 +209,9 @@ class Book extends Base {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDetailUrl ($permalink = false) {
|
/* End of Json export */
|
||||||
$urlParam = $this->getUri ();
|
|
||||||
if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
|
|
||||||
return 'index.php' . $urlParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle () {
|
/* Other class (author, series, tag, ...) initialization and accessors */
|
||||||
return $this->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAuthors () {
|
public function getAuthors () {
|
||||||
if (is_null ($this->authors)) {
|
if (is_null ($this->authors)) {
|
||||||
|
@ -213,25 +220,6 @@ class Book extends Base {
|
||||||
return $this->authors;
|
return $this->authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFilterString () {
|
|
||||||
$filter = getURLParam ("tag", NULL);
|
|
||||||
if (empty ($filter)) return "";
|
|
||||||
|
|
||||||
$exists = true;
|
|
||||||
if (preg_match ("/^!(.*)$/", $filter, $matches)) {
|
|
||||||
$exists = false;
|
|
||||||
$filter = $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = "exists (select null from books_tags_link, tags where books_tags_link.book = books.id and books_tags_link.tag = tags.id and tags.name = '" . $filter . "')";
|
|
||||||
|
|
||||||
if (!$exists) {
|
|
||||||
$result = "not " . $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "and " . $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAuthorsName () {
|
public function getAuthorsName () {
|
||||||
return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
|
return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
|
||||||
}
|
}
|
||||||
|
@ -283,6 +271,10 @@ class Book extends Base {
|
||||||
return $this->tags;
|
return $this->tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTagsName () {
|
||||||
|
return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ()));
|
||||||
|
}
|
||||||
|
|
||||||
public function getDatas ()
|
public function getDatas ()
|
||||||
{
|
{
|
||||||
if (is_null ($this->datas)) {
|
if (is_null ($this->datas)) {
|
||||||
|
@ -300,6 +292,27 @@ class Book extends Base {
|
||||||
return $this->datas;
|
return $this->datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* End of other class (author, series, tag, ...) initialization and accessors */
|
||||||
|
|
||||||
|
public static function getFilterString () {
|
||||||
|
$filter = getURLParam ("tag", NULL);
|
||||||
|
if (empty ($filter)) return "";
|
||||||
|
|
||||||
|
$exists = true;
|
||||||
|
if (preg_match ("/^!(.*)$/", $filter, $matches)) {
|
||||||
|
$exists = false;
|
||||||
|
$filter = $matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = "exists (select null from books_tags_link, tags where books_tags_link.book = books.id and books_tags_link.tag = tags.id and tags.name = '" . $filter . "')";
|
||||||
|
|
||||||
|
if (!$exists) {
|
||||||
|
$result = "not " . $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "and " . $result;
|
||||||
|
}
|
||||||
|
|
||||||
public function GetMostInterestingDataToSendToKindle ()
|
public function GetMostInterestingDataToSendToKindle ()
|
||||||
{
|
{
|
||||||
$bestFormatForKindle = array ("EPUB", "PDF", "MOBI");
|
$bestFormatForKindle = array ("EPUB", "PDF", "MOBI");
|
||||||
|
@ -325,11 +338,6 @@ class Book extends Base {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getTagsName () {
|
|
||||||
return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRating () {
|
public function getRating () {
|
||||||
if (is_null ($this->rating) || $this->rating == 0) {
|
if (is_null ($this->rating) || $this->rating == 0) {
|
||||||
return "";
|
return "";
|
||||||
|
|
Loading…
Reference in a new issue