diff --git a/base.php b/base.php
index 4482f5f..bb6ef36 100644
--- a/base.php
+++ b/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";
diff --git a/book.php b/book.php
index 0098439..e77c8e5 100644
--- a/book.php
+++ b/book.php
@@ -10,7 +10,8 @@ require_once('base.php');
require_once('serie.php');
require_once('author.php');
require_once('tag.php');
-require_once ("customcolumn.php");
+require_once('language.php');
+require_once("customcolumn.php");
require_once('data.php');
require_once('resources/php-epub-meta/epub.php');
@@ -26,6 +27,8 @@ define ('SQL_BOOKS_BY_SERIE', "select {0} from books_series_link, books " . SQL_
where books_series_link.book = books.id and series = ? {1} order by series_index");
define ('SQL_BOOKS_BY_TAG', "select {0} from books_tags_link, books " . SQL_BOOKS_LEFT_JOIN . "
where books_tags_link.book = books.id and tag = ? {1} order by sort");
+define ('SQL_BOOKS_BY_LANGUAGE', "select {0} from books_languages_link, books " . SQL_BOOKS_LEFT_JOIN . "
+ where books_languages_link.book = books.id and lang_code = ? {1} order by sort");
define ('SQL_BOOKS_BY_CUSTOM', "select {0} from {2}, books " . SQL_BOOKS_LEFT_JOIN . "
where {2}.book = books.id and {2}.{3} = ? {1} order by sort");
define ('SQL_BOOKS_QUERY', "select {0} from books " . SQL_BOOKS_LEFT_JOIN . "
@@ -44,6 +47,7 @@ class Book extends Base {
const SQL_BOOKS_BY_AUTHOR = SQL_BOOKS_BY_AUTHOR;
const SQL_BOOKS_BY_SERIE = SQL_BOOKS_BY_SERIE;
const SQL_BOOKS_BY_TAG = SQL_BOOKS_BY_TAG;
+ const SQL_BOOKS_BY_LANGUAGE = SQL_BOOKS_BY_LANGUAGE;
const SQL_BOOKS_BY_CUSTOM = SQL_BOOKS_BY_CUSTOM;
const SQL_BOOKS_QUERY = SQL_BOOKS_QUERY;
const SQL_BOOKS_RECENT = SQL_BOOKS_RECENT;
@@ -63,6 +67,7 @@ class Book extends Base {
public $authors = NULL;
public $serie = NULL;
public $tags = NULL;
+ public $languages = NULL;
public $format = array ();
@@ -160,7 +165,7 @@ class Book extends Base {
$result->execute (array ($this->id));
while ($post = $result->fetchObject ())
{
- array_push ($lang, $post->lang_code);
+ array_push ($lang, localize("languages.".$post->lang_code));
}
return implode (", ", $lang);
}
@@ -408,6 +413,10 @@ class Book extends Base {
return self::getEntryArray (self::SQL_BOOKS_BY_TAG, array ($tagId), $n);
}
+ public static function getBooksByLanguage($languageId, $n) {
+ return self::getEntryArray (self::SQL_BOOKS_BY_LANGUAGE, array ($languageId), $n);
+ }
+
public static function getBooksByCustom($customId, $id, $n) {
$query = str_format (self::SQL_BOOKS_BY_CUSTOM, "{0}", "{1}", CustomColumn::getTableLinkName ($customId), CustomColumn::getTableLinkColumn ($customId));
return self::getEntryArray ($query, array ($id), $n);
@@ -484,4 +493,4 @@ order by substr (upper (sort), 1, 1)");
}
}
-?>
\ No newline at end of file
+?>
diff --git a/index.php b/index.php
index 681455a..cf4ce9f 100644
--- a/index.php
+++ b/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,7 +174,8 @@
-
+
+