**2012-11-22**
**Added global support for publishers** Files modified: *base.php* - changed class Entry, - adding a constant ```cops:publishers``` to the icon array for the feed. - changed class Page - added branches to the page selector switch - changed Page->public function InitializeContent - added call to pull publisher count from database - changed class PageAllBooks - changed it so ```getCurrentOption``` is actually used... - added page descendant class ```PageAllPublishers``` - handles pulling the publishers category from database - added page descendant class ```PagePublisherDetail``` - handles pulling the books per publisher data from database - changed class PageQueryResult - added constant and switches for publisher search scope - abstract class Base - added constants for the publisher pages *book.php* - added require statement for publisher.php - added ```SQL_BOOKS_BY_PUBLISHER``` query to retrieve books by publisher. - changed class Book - added query constant - added publisher item - added test in case no known publisher - added publishername and url array elements for the JSON output - added public function ```getPublisher``` - added public static function ```getBooksByPublisher``` to fire the query - changed function getJson - added publisher category to search - added publishername (single) and publishertitle(plural) localization entries to i18n translation array *index.php* - added require statement for publisher.php *lang/Localization_en.json - added new localization entries for publisher labels (see below) ``` "publisher.alphabetical.many":"Alphabetical index of the {0} publishers", "publisher.alphabetical.none":"Alphabetical index of absolutely no publisher", "publisher.alphabetical.one":"Alphabetical index of the single publisher", "publisher.name":"Publisher", "publisher.title":"Publishers", "publisherword.many":"{0} publishers", "publisherword.none":"No publisher", "publisherword.one":"1 publisher", "search.result.publisher":"Search result for *{0}* in publishers", ``` *templates\bookdetail.html* - added publisher label and item to bookdetail popup *test\bookTest.php* - added indices and names of publishers added to testdatabase as comment - added test function ```testGetBooksByPublisher``` - changed test function testGetBookById to add assertion for publisher name - changed test function testTypeaheadSearch to add search on partial publisher name. *test\pageTest.php* - changed test function testPageIndex to insert publisher category and adjust page indices - changed test function testPageIndexWithCustomColum to adjust for the changed page indices - added test function testPageAllPublishers - added test function testPagePublishersDetail - added test function testPageSearchScopePublishers *test\BaseWithSomeBooks\metadata.db* - added 5 publishers spread across all 14 books, replacing the original publisher Feedbooks Files added: *publisher.php*
This commit is contained in:
parent
9d4e358738
commit
9efcd661a0
9 changed files with 296 additions and 28 deletions
44
base.php
44
base.php
|
@ -277,7 +277,8 @@ class Entry
|
|||
Language::ALL_LANGUAGES_ID => 'images/language.png',
|
||||
CustomColumn::ALL_CUSTOMS_ID => 'images/tag.png',
|
||||
"cops:books$" => 'images/allbook.png',
|
||||
"cops:books:letter" => 'images/allbook.png'
|
||||
"cops:books:letter" => 'images/allbook.png',
|
||||
"cops:publishers" => 'images/publisher.png'
|
||||
);
|
||||
|
||||
public function getUpdatedTime () {
|
||||
|
@ -410,6 +411,10 @@ class Page
|
|||
return new PageQueryResult ($id, $query, $n);
|
||||
case Base::PAGE_BOOK_DETAIL :
|
||||
return new PageBookDetail ($id, $query, $n);
|
||||
case Base::PAGE_ALL_PUBLISHERS:
|
||||
return new PageAllPublishers ($id, $query, $n);
|
||||
case Base::PAGE_PUBLISHER_DETAIL :
|
||||
return new PagePublisherDetail ($id, $query, $n);
|
||||
case Base::PAGE_ABOUT :
|
||||
return new PageAbout ($id, $query, $n);
|
||||
case Base::PAGE_CUSTOMIZE :
|
||||
|
@ -453,6 +458,10 @@ class Page
|
|||
array_push ($this->entryArray, Author::getCount());
|
||||
$series = Serie::getCount();
|
||||
if (!is_null ($series)) array_push ($this->entryArray, $series);
|
||||
|
||||
$publisher = Publisher::getCount();
|
||||
if (!is_null ($publisher)) array_push ($this->entryArray, $publisher);
|
||||
|
||||
$tags = Tag::getCount();
|
||||
if (!is_null ($tags)) array_push ($this->entryArray, $tags);
|
||||
$languages = Language::getCount();
|
||||
|
@ -517,7 +526,7 @@ class PageAllAuthors extends Page
|
|||
global $config;
|
||||
|
||||
$this->title = localize("authors.title");
|
||||
if ($config['cops_author_split_first_letter'] == 1) {
|
||||
if (getCurrentOption ("author_split_first_letter") == 1) {
|
||||
$this->entryArray = Author::getAllAuthorsByFirstLetter();
|
||||
}
|
||||
else {
|
||||
|
@ -548,6 +557,27 @@ class PageAuthorDetail extends Page
|
|||
}
|
||||
}
|
||||
|
||||
class PageAllPublishers extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
{
|
||||
$this->title = localize("publisher.title");
|
||||
$this->entryArray = Publisher::getAllPublishers();
|
||||
$this->idPage = Publisher::ALL_PUBLISHERS_ID;
|
||||
}
|
||||
}
|
||||
|
||||
class PagePublisherDetail extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
{
|
||||
$publisher = Publisher::getPublisherById ($this->idGet);
|
||||
$this->title = $publisher->name;
|
||||
list ($this->entryArray, $this->totalNumber) = Book::getBooksByPublisher ($this->idGet, $this->n);
|
||||
$this->idPage = $publisher->getEntryId ();
|
||||
}
|
||||
}
|
||||
|
||||
class PageAllTags extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
|
@ -680,6 +710,7 @@ class PageQueryResult extends Page
|
|||
const SCOPE_SERIES = "series";
|
||||
const SCOPE_AUTHOR = "author";
|
||||
const SCOPE_BOOK = "book";
|
||||
const SCOPE_PUBLISHER = "publisher";
|
||||
|
||||
public function InitializeContent ()
|
||||
{
|
||||
|
@ -698,6 +729,9 @@ class PageQueryResult extends Page
|
|||
case self::SCOPE_BOOK :
|
||||
$this->title = str_format (localize ("search.result.book"), $this->query);
|
||||
break;
|
||||
case self::SCOPE_PUBLISHER :
|
||||
$this->title = str_format (localize ("search.result.publisher"), $this->query);
|
||||
break;
|
||||
default:
|
||||
$this->title = str_format (localize ("search.result"), $this->query);
|
||||
}
|
||||
|
@ -732,6 +766,9 @@ class PageQueryResult extends Page
|
|||
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery (
|
||||
array ($bad, $bad, $bad, $crit), $this->n);
|
||||
break;
|
||||
case self::SCOPE_PUBLISHER :
|
||||
$this->entryArray = Publisher::getAllPublishersByQuery ($this->query);
|
||||
break;
|
||||
default:
|
||||
list ($this->entryArray, $this->totalNumber) = Book::getBooksByQuery (
|
||||
array ($crit, $crit, $crit, $crit), $this->n);
|
||||
|
@ -846,6 +883,8 @@ abstract class Base
|
|||
const PAGE_ALL_LANGUAGES = "17";
|
||||
const PAGE_LANGUAGE_DETAIL = "18";
|
||||
const PAGE_CUSTOMIZE = "19";
|
||||
const PAGE_ALL_PUBLISHERS = "20";
|
||||
const PAGE_PUBLISHER_DETAIL = "21";
|
||||
|
||||
const COMPATIBILITY_XML_ALDIKO = "aldiko";
|
||||
|
||||
|
@ -924,7 +963,6 @@ abstract class Base
|
|||
|
||||
// Next modify the query and params
|
||||
$query .= " limit ?, ?";
|
||||
|
||||
array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue