**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*
		
	
			
		
			
				
	
	
		
			136 lines
		
	
	
		
			No EOL
		
	
	
		
			6.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			136 lines
		
	
	
		
			No EOL
		
	
	
		
			6.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * COPS (Calibre OPDS PHP Server) HTML main script
 | |
|  *
 | |
|  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 | |
|  * @author     Sébastien Lucas <sebastien@slucas.fr>
 | |
|  *
 | |
|  */
 | |
|  
 | |
|     require_once ("config.php");
 | |
|     require_once ("base.php");
 | |
|     require_once ("author.php");
 | |
|     require_once ("publisher.php");
 | |
|     require_once ("serie.php");
 | |
|     require_once ("tag.php");
 | |
|     require_once ("language.php");
 | |
|     require_once ("customcolumn.php");
 | |
|     require_once ("book.php");
 | |
|     require_once ("resources/doT-php/doT.php");
 | |
|     
 | |
|     // If we detect that an OPDS reader try to connect try to redirect to feed.php
 | |
|     if (preg_match("/(MantanoReader|FBReader|Stanza|Aldiko|Moon+ Reader)/", $_SERVER['HTTP_USER_AGENT'])) {
 | |
|         header("location: feed.php");
 | |
|         exit ();
 | |
|     }
 | |
|     
 | |
|     header ("Content-Type:text/html;charset=utf-8");
 | |
|     $page = getURLParam ("page", Base::PAGE_INDEX);
 | |
|     $query = getURLParam ("query");
 | |
|     $qid = getURLParam ("id");
 | |
|     $n = getURLParam ("n", "1");
 | |
|     $database = GetUrlParam (DB);
 | |
| ?><!DOCTYPE html>
 | |
| <html xmlns="http://www.w3.org/1999/xhtml">
 | |
| <head>
 | |
|     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | |
|     <meta name="apple-mobile-web-app-capable" content="yes" />
 | |
|     <meta name="apple-mobile-web-app-status-bar-style" content="default" />
 | |
|     <link rel="apple-touch-icon" href="./icons/icon57.png" />
 | |
|     <link rel="apple-touch-icon" sizes="72x72" href="./icons/icon72.png" />
 | |
|     <link rel="apple-touch-icon" sizes="114x114" href="./icons/icon114.png" />
 | |
|     <link rel="apple-touch-icon" sizes="144x144" href="./icons/icon144.png" />
 | |
|     
 | |
|     <title>COPS</title>
 | |
| 
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jQuery/jquery-1.10.2.min.js") ?>"></script>
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jquery-cookie/jquery.cookies.js") ?>"></script>
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("js/jquery.sortElements.js") ?>"></script>
 | |
| <?php if (!useServerSideRendering ()) { ?>
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/Magnific-Popup/jquery.magnific-popup.min.js") ?>"></script>
 | |
|     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/Magnific-Popup/magnific-popup.css") ?>" media="screen" />
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/doT/doT.min.js") ?>"></script>
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/lru/lru.js") ?>"></script>
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/typeahead/typeahead.js") ?>"></script>
 | |
| <?php } ?>
 | |
|     <script type="text/javascript" src="<?php echo getUrlWithVersion("util.js") ?>"></script>
 | |
|     <link rel="related" href="<?php echo $config['cops_full_url'] ?>feed.php" type="application/atom+xml;profile=opds-catalog" title="<?php echo $config['cops_title_default']; ?>" /> 
 | |
|     <link rel="icon" type="image/vnd.microsoft.icon" href="<?php echo $config['cops_icon']; ?>" />
 | |
|     <link rel='stylesheet' type='text/css' href='https://fonts.googleapis.com/css?family=Open+Sans:400,300italic,800,300,400italic,600,600italic,700,700italic,800italic&subset=latin,cyrillic' />
 | |
|     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
 | |
|     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
 | |
|     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
 | |
| <?php if (!useServerSideRendering ()) { ?>
 | |
|     <script type="text/javascript">
 | |
|     
 | |
|         $(document).ready(function() {
 | |
|             // Handler for .ready() called.
 | |
|             
 | |
|             var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
 | |
|             
 | |
|             $.when($.get('templates/default/header.html'),
 | |
|                    $.get('templates/default/footer.html'),
 | |
|                    $.get('templates/default/bookdetail.html'),
 | |
|                    $.get('templates/default/main.html'),
 | |
|                    $.get('templates/default/page.html'),
 | |
|                    $.get('templates/default/suggestion.html'),
 | |
|                    $.getJSON(url)).done(function(header, footer, bookdetail, main, page, suggestion, data){
 | |
|                 templateBookDetail = doT.template (bookdetail [0]);
 | |
|                 
 | |
|                 var defMain = {
 | |
|                     bookdetail: bookdetail [0]
 | |
|                 };
 | |
|                 
 | |
|                 templateMain = doT.template (main [0], undefined, defMain);
 | |
|                 
 | |
|                 var defPage = {
 | |
|                     header: header [0],
 | |
|                     footer: footer [0],
 | |
|                     main  : main [0],
 | |
|                     bookdetail: bookdetail [0]
 | |
|                 };
 | |
|                 
 | |
|                 templatePage = doT.template (page [0], undefined, defPage);
 | |
|                 
 | |
|                 templateSuggestion = doT.template (suggestion [0]);
 | |
|                 
 | |
|                 currentData = data [0];
 | |
|                 
 | |
|                 updatePage (data [0]);
 | |
|                 cache.put (url, data [0]);
 | |
|                 history.replaceState(url, "", window.location);
 | |
|                 handleLinks ();
 | |
|             });
 | |
|             
 | |
|         });
 | |
|         
 | |
|         
 | |
| 
 | |
|     </script>
 | |
| <?php } ?>
 | |
| </head>
 | |
| <body>
 | |
| <?php
 | |
| if (useServerSideRendering ()) {
 | |
|     // Get the templates
 | |
|     $header = file_get_contents('templates/default/header.html');
 | |
|     $footer = file_get_contents('templates/default/footer.html');
 | |
|     $main = file_get_contents('templates/default/main.html');
 | |
|     $bookdetail = file_get_contents('templates/default/bookdetail.html');
 | |
|     $page = file_get_contents('templates/default/page.html');
 | |
| 
 | |
|     // Get the data
 | |
|     $data = getJson (true);
 | |
| 
 | |
|     // Generate the function for the template
 | |
|     $template = new doT ();
 | |
|     $dot = $template->template ($page, array ("bookdetail" => $bookdetail,
 | |
|                                               "header" => $header,
 | |
|                                               "footer" => $footer,
 | |
|                                               "main" => $main));
 | |
|     // Execute the template
 | |
|     echo $dot ($data);
 | |
| }
 | |
| ?>
 | |
| </body>
 | |
| </html>
 |