Merged Language Feature.
This commit is contained in:
parent
49f59438b0
commit
f4e365ce96
30
base.php
30
base.php
|
@ -235,6 +235,7 @@ class Entry
|
|||
Serie::ALL_SERIES_ID => 'images/serie.png',
|
||||
Book::ALL_RECENT_BOOKS_ID => 'images/recent.png',
|
||||
Tag::ALL_TAGS_ID => 'images/tag.png',
|
||||
Language::ALL_LANGUAGES_ID => 'images/language.png',
|
||||
CustomColumn::ALL_CUSTOMS_ID => 'images/tag.png',
|
||||
"calibre:books$" => 'images/allbook.png',
|
||||
"calibre:books:letter" => 'images/allbook.png'
|
||||
|
@ -325,6 +326,10 @@ class Page
|
|||
return new PageAllTags ($id, $query, $n);
|
||||
case Base::PAGE_TAG_DETAIL :
|
||||
return new PageTagDetail ($id, $query, $n);
|
||||
case Base::PAGE_ALL_LANGUAGES :
|
||||
return new PageAllLanguages ($id, $query, $n);
|
||||
case Base::PAGE_LANGUAGE_DETAIL :
|
||||
return new PageLanguageDetail ($id, $query, $n);
|
||||
case Base::PAGE_ALL_CUSTOMS :
|
||||
return new PageAllCustoms ($id, $query, $n);
|
||||
case Base::PAGE_CUSTOM_DETAIL :
|
||||
|
@ -381,6 +386,8 @@ class Page
|
|||
if (!is_null ($series)) array_push ($this->entryArray, $series);
|
||||
$tags = Tag::getCount();
|
||||
if (!is_null ($tags)) array_push ($this->entryArray, $tags);
|
||||
$languages = Language::getCount();
|
||||
if (!is_null ($languages)) array_push ($this->entryArray, $languages);
|
||||
foreach ($config['cops_calibre_custom_column'] as $lookup) {
|
||||
$customId = CustomColumn::getCustomId ($lookup);
|
||||
if (!is_null ($customId)) {
|
||||
|
@ -488,6 +495,16 @@ class PageAllTags extends Page
|
|||
}
|
||||
}
|
||||
|
||||
class PageAllLanguages extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
{
|
||||
$this->title = localize("languages.title");
|
||||
$this->entryArray = Language::getAllLanguages();
|
||||
$this->idPage = Language::ALL_LANGUAGES_ID;
|
||||
}
|
||||
}
|
||||
|
||||
class PageCustomDetail extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
|
@ -522,6 +539,17 @@ class PageTagDetail extends Page
|
|||
}
|
||||
}
|
||||
|
||||
class PageLanguageDetail extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
{
|
||||
$language = Language::getLanguageById ($this->idGet);
|
||||
$this->idPage = $language->getEntryId ();
|
||||
$this->title = $language->name;
|
||||
list ($this->entryArray, $this->totalNumber) = Book::getBooksByLanguage ($this->idGet, $this->n);
|
||||
}
|
||||
}
|
||||
|
||||
class PageAllSeries extends Page
|
||||
{
|
||||
public function InitializeContent ()
|
||||
|
@ -648,6 +676,8 @@ abstract class Base
|
|||
const PAGE_ALL_CUSTOMS = "14";
|
||||
const PAGE_CUSTOM_DETAIL = "15";
|
||||
const PAGE_ABOUT = "16";
|
||||
const PAGE_ALL_LANGUAGES = "17";
|
||||
const PAGE_LANGUAGE_DETAIL = "18";
|
||||
|
||||
const COMPATIBILITY_XML_ALDIKO = "aldiko";
|
||||
|
||||
|
|
10
index.php
10
index.php
|
@ -12,6 +12,7 @@
|
|||
require_once ("author.php");
|
||||
require_once ("serie.php");
|
||||
require_once ("tag.php");
|
||||
require_once ("language.php");
|
||||
require_once ("customcolumn.php");
|
||||
require_once ("book.php");
|
||||
|
||||
|
@ -173,6 +174,7 @@
|
|||
<option value="sa"><?php echo localize("authors.title") ?></option>
|
||||
<option value="ss"><?php echo localize("series.title") ?></option>
|
||||
<option value="sp"><?php echo localize("content.published") ?></option>
|
||||
<option value="sl"><?php echo localize("language.title") ?></option>
|
||||
</select>
|
||||
<select id="sortorder">
|
||||
<option value="asc"><?php echo localize("search.sortorder.asc") ?></option>
|
||||
|
@ -254,6 +256,14 @@
|
|||
<h4><?php echo localize("tags.title") . " : </h4>" . htmlspecialchars ($tags) ?><br />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$languages = $entry->book->getLanguages ();
|
||||
if (!empty ($languages)) {
|
||||
?>
|
||||
<h4><?php echo localize("languages.title") . " : </h4>" . htmlspecialchars ($languages) ?><br />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$serie = $entry->book->getSerie ();
|
||||
|
|
|
@ -54,6 +54,15 @@
|
|||
"bookentry.download":"Download this ebook as {0}",
|
||||
"bookentry.rated":"{0} {1}",
|
||||
"bookentry.fullentrylink":"Full entry",
|
||||
"language.title":"Language",
|
||||
"languages.title":"Language",
|
||||
"languages.categorized":"Categorized index of the {0} languages",
|
||||
"languages.categorized.single":"Categorized index of the single language - very useful indeed ;)",
|
||||
"languages.alphabetical.many":"Alphabetical index of the {0} languages",
|
||||
"languages.alphabetical.one":"Alphabetical index of the single language - very useful indeed ;)",
|
||||
"languages.alphabetical.none":"Alphabetical index of absolutely no language - very useful indeed ;)",
|
||||
"languages.ron":"Romanian",
|
||||
"languages.eng":"English",
|
||||
"tags.title":"Tags",
|
||||
"tags.categorized":"Categorized index of the {0} tags",
|
||||
"tags.categorized.single":"Categorized index of the single tag - very useful indeed ;)",
|
||||
|
|
66
language.php
Normal file
66
language.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* COPS (Calibre OPDS PHP Server) class file
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Senioru <bla>
|
||||
*/
|
||||
|
||||
require_once('base.php');
|
||||
|
||||
class language extends Base {
|
||||
const ALL_LANGUAGES_ID = "calibre:languages";
|
||||
|
||||
public $id;
|
||||
public $lang_code;
|
||||
|
||||
public function __construct($pid, $plang_code) {
|
||||
$this->id = $pid;
|
||||
$this->lang_code = $plang_code;
|
||||
}
|
||||
|
||||
public function getUri () {
|
||||
return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id";
|
||||
}
|
||||
|
||||
public function getEntryId () {
|
||||
return self::ALL_LANGUAGES_ID.":".$this->id;
|
||||
}
|
||||
|
||||
public static function getCount() {
|
||||
$nLanguages = parent::getDb ()->query('select count(*) from languages')->fetchColumn();
|
||||
$entry = new Entry (localize("languages.title"), self::ALL_LANGUAGES_ID,
|
||||
str_format (localize("languages.alphabetical", $nLanguages), $nLanguages), "text non",
|
||||
array ( new LinkNavigation ("?page=".parent::PAGE_ALL_LANGUAGES)));
|
||||
return $entry;
|
||||
}
|
||||
|
||||
public static function getLanguageById ($languageId) {
|
||||
$result = parent::getDb ()->prepare('select id, lang_code from languages where id = ?');
|
||||
$result->execute (array ($languageId));
|
||||
if ($post = $result->fetchObject ()) {
|
||||
return new Language ($post->id, $post->lang_code);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getAllLanguages() {
|
||||
$result = parent::getDb ()->query('select languages.id as id, books_languages_link.lang_code as lang_code, count(*) as count
|
||||
from languages, books_languages_link
|
||||
where languages.id = books_languages_link.lang_code
|
||||
group by languages.id, books_languages_link.lang_code
|
||||
order by languages.lang_code');
|
||||
$entryArray = array();
|
||||
while ($post = $result->fetchObject ())
|
||||
{
|
||||
$language = new Language ($post->id, $post->lang_code);
|
||||
array_push ($entryArray, new Entry ($language->lang_code, $language->getEntryId (),
|
||||
str_format (localize("bookword", $post->count), $post->count), "text non",
|
||||
array ( new LinkNavigation ($language->getUri ()))));
|
||||
}
|
||||
return $entryArray;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue