**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*
2013-11-22 23:08:09 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* COPS (Calibre OPDS PHP Server) class file
|
|
|
|
*
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
* @author At Libitum <eljarec@yahoo.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once('base.php');
|
|
|
|
|
|
|
|
class Publisher extends Base {
|
|
|
|
const ALL_PUBLISHERS_ID = "cops:publishers";
|
|
|
|
|
|
|
|
public $id;
|
|
|
|
public $name;
|
|
|
|
|
|
|
|
public function __construct($pid, $pname) {
|
|
|
|
$this->id = $pid;
|
|
|
|
$this->name = $pname;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUri () {
|
|
|
|
return "?page=".parent::PAGE_PUBLISHER_DETAIL."&id=$this->id";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEntryId () {
|
|
|
|
return self::ALL_PUBLISHERS_ID.":".$this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getCount() {
|
|
|
|
$nPublishers = parent::getDb ()->query('select count(*) from publishers')->fetchColumn();
|
|
|
|
if ($nPublishers == 0) return NULL;
|
2013-12-19 09:24:02 +02:00
|
|
|
$entry = new Entry (localize("publishers.title"), self::ALL_PUBLISHERS_ID,
|
|
|
|
str_format (localize("publishers.alphabetical", $nPublishers), $nPublishers), "text",
|
**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*
2013-11-22 23:08:09 +02:00
|
|
|
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_PUBLISHERS)));
|
|
|
|
return $entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getPublisherByBookId ($bookId) {
|
|
|
|
$result = parent::getDb ()->prepare('select publishers.id as id, name
|
|
|
|
from books_publishers_link, publishers
|
|
|
|
where publishers.id = publisher and book = ?');
|
|
|
|
$result->execute (array ($bookId));
|
|
|
|
if ($post = $result->fetchObject ()) {
|
|
|
|
return new Publisher ($post->id, $post->name);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getPublisherById ($publisherId) {
|
|
|
|
$result = parent::getDb ()->prepare('select id, name
|
|
|
|
from publishers where id = ?');
|
|
|
|
$result->execute (array ($publisherId));
|
|
|
|
if ($post = $result->fetchObject ()) {
|
|
|
|
return new Publisher ($post->id, $post->name);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getAllPublishers() {
|
|
|
|
$result = parent::getDb ()->query('select publishers.id as id, publishers.name as name, count(*) as count
|
|
|
|
from publishers, books_publishers_link
|
|
|
|
where publishers.id = publisher
|
|
|
|
group by publishers.id, publishers.name
|
|
|
|
order by publishers.name');
|
|
|
|
$entryArray = array();
|
|
|
|
|
|
|
|
while ($post = $result->fetchObject ())
|
|
|
|
{
|
|
|
|
$publisher = new Publisher ($post->id, $post->name);
|
|
|
|
array_push ($entryArray, new Entry ($publisher->name, $publisher->getEntryId (),
|
|
|
|
str_format (localize("bookword", $post->count), $post->count), "text",
|
|
|
|
array ( new LinkNavigation ($publisher->getUri ()))));
|
|
|
|
}
|
|
|
|
return $entryArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getAllPublishersByQuery($query) {
|
2014-05-12 22:36:31 +03:00
|
|
|
$columns = "publishers.id as id, publishers.name as name, count(*) as count";
|
|
|
|
$sql = 'select {0} from publishers, books_publishers_link
|
|
|
|
where publishers.id = publisher and upper (publishers.name) like ?
|
**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*
2013-11-22 23:08:09 +02:00
|
|
|
group by publishers.id, publishers.name
|
2014-05-12 22:36:31 +03:00
|
|
|
order by publishers.name';
|
2014-05-16 16:09:18 +03:00
|
|
|
list (, $result) = parent::executeQuery ($sql, $columns, "", array ('%' . $query . '%'), -1);
|
**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*
2013-11-22 23:08:09 +02:00
|
|
|
$entryArray = array();
|
|
|
|
|
|
|
|
while ($post = $result->fetchObject ())
|
|
|
|
{
|
|
|
|
$publisher = new Publisher ($post->id, $post->name);
|
|
|
|
array_push ($entryArray, new Entry ($publisher->name, $publisher->getEntryId (),
|
|
|
|
str_format (localize("bookword", $post->count), $post->count), "text",
|
|
|
|
array ( new LinkNavigation ($publisher->getUri ()))));
|
|
|
|
}
|
|
|
|
return $entryArray;
|
|
|
|
}
|
|
|
|
}
|