Add Custom columns through config. Only tested in HTML catalog for now

re #32
This commit is contained in:
Sébastien Lucas 2013-01-19 07:08:47 +01:00
parent a96888c76a
commit f4675dec52
5 changed files with 71 additions and 6 deletions

View file

@ -137,12 +137,13 @@ class Entry
private static $updated = NULL;
public static $icons = array(
Author::ALL_AUTHORS_ID => 'images/author.png',
Serie::ALL_SERIES_ID => 'images/serie.png',
Book::ALL_RECENT_BOOKS_ID => 'images/recent.png',
Tag::ALL_TAGS_ID => 'images/tag.png',
"calibre:books$" => 'images/allbook.png',
"calibre:books:letter" => 'images/allbook.png'
Author::ALL_AUTHORS_ID => 'images/author.png',
Serie::ALL_SERIES_ID => 'images/serie.png',
Book::ALL_RECENT_BOOKS_ID => 'images/recent.png',
Tag::ALL_TAGS_ID => 'images/tag.png',
CustomColumn::ALL_CUSTOMS_ID => 'images/tag.png',
"calibre:books$" => 'images/allbook.png',
"calibre:books:letter" => 'images/allbook.png'
);
public function getUpdatedTime () {
@ -228,6 +229,10 @@ class Page
return new PageAllTags ($id, $query, $n);
case Base::PAGE_TAG_DETAIL :
return new PageTagDetail ($id, $query, $n);
case Base::PAGE_ALL_CUSTOMS :
return new PageAllCustoms ($id, $query, $n);
case Base::PAGE_CUSTOM_DETAIL :
return new PageCustomDetail ($id, $query, $n);
case Base::PAGE_ALL_SERIES :
return new PageAllSeries ($id, $query, $n);
case Base::PAGE_ALL_BOOKS :
@ -266,6 +271,12 @@ class Page
array_push ($this->entryArray, Author::getCount());
array_push ($this->entryArray, Serie::getCount());
array_push ($this->entryArray, Tag::getCount());
foreach ($config['cops_calibre_custom_column'] as $lookup) {
$customId = CustomColumn::getCustomId ($lookup);
if (!is_null ($customId)) {
array_push ($this->entryArray, CustomColumn::getCount($customId));
}
}
$this->entryArray = array_merge ($this->entryArray, Book::getCount());
}
@ -364,6 +375,29 @@ class PageAllTags extends Page
}
}
class PageCustomDetail extends Page
{
public function InitializeContent ()
{
$customId = getURLParam ("custom", NULL);
$custom = CustomColumn::getCustomById ($customId, $this->idGet);
$this->idPage = $custom->getEntryId ();
$this->title = $custom->name;
list ($this->entryArray, $this->totalNumber) = Book::getBooksByCustom ($customId, $this->idGet, $this->n);
}
}
class PageAllCustoms extends Page
{
public function InitializeContent ()
{
$customId = getURLParam ("custom", NULL);
$this->title = CustomColumn::getAllTitle ($customId);
$this->entryArray = CustomColumn::getAllCustoms($customId);
$this->idPage = CustomColumn::getAllCustomsId ($customId);
}
}
class PageTagDetail extends Page
{
public function InitializeContent ()
@ -465,6 +499,8 @@ abstract class Base
const PAGE_ALL_TAGS = "11";
const PAGE_TAG_DETAIL = "12";
const PAGE_BOOK_DETAIL = "13";
const PAGE_ALL_CUSTOMS = "14";
const PAGE_CUSTOM_DETAIL = "15";
const COMPATIBILITY_XML_ALDIKO = "aldiko";