diff --git a/JSON_renderer.php b/JSON_renderer.php index 763e5ea..d92a466 100644 --- a/JSON_renderer.php +++ b/JSON_renderer.php @@ -102,7 +102,7 @@ class JSONRenderer $out ["book"] = self::getBookContentArray ($entry->book); return $out; } - return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink () ); + return array ( "title" => $entry->title, "content" => $entry->content, "navlink" => $entry->getNavLink (), "number" => $entry->numberOfElement ); } public static function getContentArrayTypeahead ($page) { diff --git a/base.php b/base.php index 018276e..6aba04b 100644 --- a/base.php +++ b/base.php @@ -390,6 +390,7 @@ class Entry public $title; public $id; public $content; + public $numberOfElement; public $contentType; public $linkArray; public $localUpdated; @@ -427,7 +428,7 @@ class Entry return "#"; } - public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "") { + public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0) { global $config; $this->title = $ptitle; $this->id = $pid; @@ -435,6 +436,7 @@ class Entry $this->contentType = $pcontentType; $this->linkArray = $plinkArray; $this->className = $pclass; + $this->numberOfElement = $pcount; if ($config['cops_show_icons'] == 1) { @@ -571,7 +573,7 @@ class Page $nBooks = Book::getBookCount ($i); array_push ($this->entryArray, new Entry ($key, "cops:{$i}:catalog", str_format (localize ("bookword", $nBooks), $nBooks), "text", - array ( new LinkNavigation ("?" . DB . "={$i}")))); + array ( new LinkNavigation ("?" . DB . "={$i}")), "", $nBooks)); $i++; Base::clearDb (); } @@ -1260,7 +1262,7 @@ abstract class Base if ($count == 0) return NULL; $entry = new Entry (localize($table . ".title"), $id, str_format (localize($numberOfString, $count), $count), "text", - array ( new LinkNavigation ("?page=".$pageId))); + array ( new LinkNavigation ("?page=".$pageId)), "", $count); return $entry; } diff --git a/book.php b/book.php index f150155..344bf2e 100644 --- a/book.php +++ b/book.php @@ -438,13 +438,13 @@ class Book extends Base { $entry = new Entry (localize ("allbooks.title"), self::ALL_BOOKS_ID, str_format (localize ("allbooks.alphabetical", $nBooks), $nBooks), "text", - array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS))); + array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS)), "", $nBooks); array_push ($result, $entry); if ($config['cops_recentbooks_limit'] > 0) { $entry = new Entry (localize ("recent.title"), self::ALL_RECENT_BOOKS_ID, str_format (localize ("recent.list"), $config['cops_recentbooks_limit']), "text", - array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS))); + array ( new LinkNavigation ("?page=".parent::PAGE_ALL_RECENT_BOOKS)), "", $config['cops_recentbooks_limit']); array_push ($result, $entry); } return $result; diff --git a/customcolumn.php b/customcolumn.php index dc9769b..ace2c72 100644 --- a/customcolumn.php +++ b/customcolumn.php @@ -66,10 +66,10 @@ class CustomColumn extends Base { } public static function getCount($customId) { - $nCustoms = parent::getDb ()->query('select count(*) from ' . self::getTableName ($customId))->fetchColumn(); + $nCustoms = parent::executeQuerySingle ('select count(*) from ' . self::getTableName ($customId)); $entry = new Entry (self::getAllTitle ($customId), self::getAllCustomsId ($customId), str_format (localize("tags.alphabetical", $nCustoms), $nCustoms), "text", - array ( new LinkNavigation (self::getUriAllCustoms ($customId)))); + array ( new LinkNavigation (self::getUriAllCustoms ($customId))), "", $nCustoms); return $entry; } diff --git a/templates/bootstrap/main.html b/templates/bootstrap/main.html index 67d65bd..2c11f57 100644 --- a/templates/bootstrap/main.html +++ b/templates/bootstrap/main.html @@ -1,8 +1,4 @@ -{{? it.containsBook == 0}} -
-{{??}}
-{{?}} {{? it.page == 13 || it.page == 16}} {{? it.page == 13}} {{#def.bookdetail}} @@ -10,18 +6,21 @@ {{= it.fullhtml}} {{?}} {{??}} -{{? it.containsBook == 1}}
-{{??}} -
-{{?}} {{~it.entries:entry:i}} {{? it.containsBook == 0}} - - {{=htmlspecialchars (entry.title)}} - - {{=entry.content}} - +
+
+ +
+ {{=entry.number}} +
+
+
{{??}}
diff --git a/test/pageMultidatabaseTest.php b/test/pageMultidatabaseTest.php index dce34a9..764fa12 100644 --- a/test/pageMultidatabaseTest.php +++ b/test/pageMultidatabaseTest.php @@ -28,8 +28,10 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase $this->assertCount (2, $currentPage->entryArray); $this->assertEquals ("Some books", $currentPage->entryArray [0]->title); $this->assertEquals ("15 books", $currentPage->entryArray [0]->content); + $this->assertEquals (15, $currentPage->entryArray [0]->numberOfElement); $this->assertEquals ("One book", $currentPage->entryArray [1]->title); $this->assertEquals ("1 book", $currentPage->entryArray [1]->content); + $this->assertEquals (1, $currentPage->entryArray [1]->numberOfElement); $this->assertFalse ($currentPage->ContainsBook ()); } @@ -60,7 +62,7 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase $this->assertEquals ("1 book", $currentPage->entryArray [1]->content); $this->assertFalse ($currentPage->ContainsBook ()); } - + public function providerSearch () { return array ( diff --git a/test/pageTest.php b/test/pageTest.php index ef97134..325a5a0 100644 --- a/test/pageTest.php +++ b/test/pageTest.php @@ -26,20 +26,28 @@ class PageTest extends PHPUnit_Framework_TestCase $this->assertCount (8, $currentPage->entryArray); $this->assertEquals ("Authors", $currentPage->entryArray [0]->title); $this->assertEquals ("Alphabetical index of the 6 authors", $currentPage->entryArray [0]->content); + $this->assertEquals (6, $currentPage->entryArray [0]->numberOfElement); $this->assertEquals ("Series", $currentPage->entryArray [1]->title); $this->assertEquals ("Alphabetical index of the 4 series", $currentPage->entryArray [1]->content); + $this->assertEquals (4, $currentPage->entryArray [1]->numberOfElement); $this->assertEquals ("Publishers", $currentPage->entryArray [2]->title); $this->assertEquals ("Alphabetical index of the 6 publishers", $currentPage->entryArray [2]->content); + $this->assertEquals (6, $currentPage->entryArray [2]->numberOfElement); $this->assertEquals ("Tags", $currentPage->entryArray [3]->title); $this->assertEquals ("Alphabetical index of the 11 tags", $currentPage->entryArray [3]->content); + $this->assertEquals (11, $currentPage->entryArray [3]->numberOfElement); $this->assertEquals ("Ratings", $currentPage->entryArray [4]->title); $this->assertEquals ("3 ratings", $currentPage->entryArray [4]->content); + $this->assertEquals (3, $currentPage->entryArray [4]->numberOfElement); $this->assertEquals ("Languages", $currentPage->entryArray [5]->title); $this->assertEquals ("Alphabetical index of the 2 languages", $currentPage->entryArray [5]->content); + $this->assertEquals (2, $currentPage->entryArray [5]->numberOfElement); $this->assertEquals ("All books", $currentPage->entryArray [6]->title); $this->assertEquals ("Alphabetical index of the 15 books", $currentPage->entryArray [6]->content); + $this->assertEquals (15, $currentPage->entryArray [6]->numberOfElement); $this->assertEquals ("Recent additions", $currentPage->entryArray [7]->title); $this->assertEquals ("50 most recent books", $currentPage->entryArray [7]->content); + $this->assertEquals (50, $currentPage->entryArray [7]->numberOfElement); $this->assertFalse ($currentPage->ContainsBook ()); }