Properly use author name or author sort. fix #130
This commit is contained in:
parent
f50e925c3d
commit
65b6931b13
15
author.php
15
author.php
|
@ -19,9 +19,10 @@ class Author extends Base {
|
||||||
public $name;
|
public $name;
|
||||||
public $sort;
|
public $sort;
|
||||||
|
|
||||||
public function __construct($pid, $pname) {
|
public function __construct($pid, $pname, $psort) {
|
||||||
$this->id = $pid;
|
$this->id = $pid;
|
||||||
$this->name = $pname;
|
$this->name = $pname;
|
||||||
|
$this->sort = $psort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUri () {
|
public function getUri () {
|
||||||
|
@ -72,7 +73,7 @@ order by substr (upper (sort), 1, 1)');
|
||||||
$entryArray = array();
|
$entryArray = array();
|
||||||
while ($post = $result->fetchObject ())
|
while ($post = $result->fetchObject ())
|
||||||
{
|
{
|
||||||
$author = new Author ($post->id, $post->sort);
|
$author = new Author ($post->id, $post->name, $post->sort);
|
||||||
array_push ($entryArray, new Entry ($post->sort, $author->getEntryId (),
|
array_push ($entryArray, new Entry ($post->sort, $author->getEntryId (),
|
||||||
str_format (localize("bookword", $post->count), $post->count), "text",
|
str_format (localize("bookword", $post->count), $post->count), "text",
|
||||||
array ( new LinkNavigation ($author->getUri ()))));
|
array ( new LinkNavigation ($author->getUri ()))));
|
||||||
|
@ -81,20 +82,20 @@ order by substr (upper (sort), 1, 1)');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAuthorById ($authorId) {
|
public static function getAuthorById ($authorId) {
|
||||||
$result = parent::getDb ()->prepare('select sort from authors where id = ?');
|
$result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors where id = ?');
|
||||||
$result->execute (array ($authorId));
|
$result->execute (array ($authorId));
|
||||||
return new Author ($authorId, $result->fetchColumn ());
|
$post = $result->fetchObject ();
|
||||||
|
return new Author ($post->id, $post->name, $post->sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAuthorByBookId ($bookId) {
|
public static function getAuthorByBookId ($bookId) {
|
||||||
$result = parent::getDb ()->prepare('select authors.id as id, authors.sort as sort
|
$result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors, books_authors_link
|
||||||
from authors, books_authors_link
|
|
||||||
where author = authors.id
|
where author = authors.id
|
||||||
and book = ?');
|
and book = ?');
|
||||||
$result->execute (array ($bookId));
|
$result->execute (array ($bookId));
|
||||||
$authorArray = array ();
|
$authorArray = array ();
|
||||||
while ($post = $result->fetchObject ()) {
|
while ($post = $result->fetchObject ()) {
|
||||||
array_push ($authorArray, new Author ($post->id, $post->sort));
|
array_push ($authorArray, new Author ($post->id, $post->name, $post->sort));
|
||||||
}
|
}
|
||||||
return $authorArray;
|
return $authorArray;
|
||||||
}
|
}
|
||||||
|
|
4
book.php
4
book.php
|
@ -142,6 +142,10 @@ class Book extends Base {
|
||||||
return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
|
return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAuthorsSort () {
|
||||||
|
return implode (", ", array_map (function ($author) { return $author->sort; }, $this->getAuthors ()));
|
||||||
|
}
|
||||||
|
|
||||||
public function getPublisher () {
|
public function getPublisher () {
|
||||||
if (is_null ($this->publisher)) {
|
if (is_null ($this->publisher)) {
|
||||||
$this->publisher = Publisher::getPublisherByBookId ($this->id);
|
$this->publisher = Publisher::getPublisherByBookId ($this->id);
|
||||||
|
|
2
data.php
2
data.php
|
@ -91,7 +91,7 @@ class Data extends Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdatedFilename () {
|
public function getUpdatedFilename () {
|
||||||
return $this->book->getAuthorsName () . " - " . $this->book->title;
|
return $this->book->getAuthorsSort () . " - " . $this->book->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdatedFilenameEpub () {
|
public function getUpdatedFilenameEpub () {
|
||||||
|
|
|
@ -184,7 +184,7 @@ class BookTest extends PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals ("The Return of Sherlock Holmes", $book->getTitle ());
|
$this->assertEquals ("The Return of Sherlock Holmes", $book->getTitle ());
|
||||||
$this->assertEquals ("urn:uuid:87ddbdeb-1e27-4d06-b79b-4b2a3bfc6a5f", $book->getEntryId ());
|
$this->assertEquals ("urn:uuid:87ddbdeb-1e27-4d06-b79b-4b2a3bfc6a5f", $book->getEntryId ());
|
||||||
$this->assertEquals ("index.php?page=13&id=2", $book->getDetailUrl ());
|
$this->assertEquals ("index.php?page=13&id=2", $book->getDetailUrl ());
|
||||||
$this->assertEquals ("Doyle, Arthur Conan", $book->getAuthorsName ());
|
$this->assertEquals ("Arthur Conan Doyle", $book->getAuthorsName ());
|
||||||
$this->assertEquals ("Fiction, Mystery & Detective, Short Stories", $book->getTagsName ());
|
$this->assertEquals ("Fiction, Mystery & Detective, Short Stories", $book->getTagsName ());
|
||||||
$this->assertEquals ('<p class="description">The Return of Sherlock Holmes is a collection of 13 Sherlock Holmes stories, originally published in 1903-1904, by Arthur Conan Doyle.<br />The book was first published on March 7, 1905 by Georges Newnes, Ltd and in a Colonial edition by Longmans. 30,000 copies were made of the initial print run. The US edition by McClure, Phillips & Co. added another 28,000 to the run.<br />This was the first Holmes collection since 1893, when Holmes had "died" in "The Adventure of the Final Problem". Having published The Hound of the Baskervilles in 1901–1902 (although setting it before Holmes\' death) Doyle came under intense pressure to revive his famous character.</p>', $book->getComment (false));
|
$this->assertEquals ('<p class="description">The Return of Sherlock Holmes is a collection of 13 Sherlock Holmes stories, originally published in 1903-1904, by Arthur Conan Doyle.<br />The book was first published on March 7, 1905 by Georges Newnes, Ltd and in a Colonial edition by Longmans. 30,000 copies were made of the initial print run. The US edition by McClure, Phillips & Co. added another 28,000 to the run.<br />This was the first Holmes collection since 1893, when Holmes had "died" in "The Adventure of the Final Problem". Having published The Hound of the Baskervilles in 1901–1902 (although setting it before Holmes\' death) Doyle came under intense pressure to revive his famous character.</p>', $book->getComment (false));
|
||||||
$this->assertEquals ("English", $book->getLanguages ());
|
$this->assertEquals ("English", $book->getLanguages ());
|
||||||
|
|
|
@ -254,7 +254,7 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||||
$currentPage->InitializeContent ();
|
$currentPage->InitializeContent ();
|
||||||
|
|
||||||
$this->assertEquals ("Doyle, Arthur Conan", $currentPage->title);
|
$this->assertEquals ("Arthur Conan Doyle", $currentPage->title);
|
||||||
$this->assertEquals (4, $currentPage->getMaxPage ());
|
$this->assertEquals (4, $currentPage->getMaxPage ());
|
||||||
$this->assertCount (2, $currentPage->entryArray);
|
$this->assertCount (2, $currentPage->entryArray);
|
||||||
$this->assertTrue ($currentPage->ContainsBook ());
|
$this->assertTrue ($currentPage->ContainsBook ());
|
||||||
|
@ -268,7 +268,7 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||||
$currentPage->InitializeContent ();
|
$currentPage->InitializeContent ();
|
||||||
|
|
||||||
$this->assertEquals ("Doyle, Arthur Conan", $currentPage->title);
|
$this->assertEquals ("Arthur Conan Doyle", $currentPage->title);
|
||||||
$this->assertEquals (2, $currentPage->getMaxPage ());
|
$this->assertEquals (2, $currentPage->getMaxPage ());
|
||||||
$this->assertCount (3, $currentPage->entryArray);
|
$this->assertCount (3, $currentPage->entryArray);
|
||||||
$this->assertTrue ($currentPage->ContainsBook ());
|
$this->assertTrue ($currentPage->ContainsBook ());
|
||||||
|
@ -281,7 +281,7 @@ class PageTest extends PHPUnit_Framework_TestCase
|
||||||
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
$currentPage = Page::getPage ($page, $qid, $query, $n);
|
||||||
$currentPage->InitializeContent ();
|
$currentPage->InitializeContent ();
|
||||||
|
|
||||||
$this->assertEquals ("Doyle, Arthur Conan", $currentPage->title);
|
$this->assertEquals ("Arthur Conan Doyle", $currentPage->title);
|
||||||
$this->assertCount (8, $currentPage->entryArray);
|
$this->assertCount (8, $currentPage->entryArray);
|
||||||
$this->assertTrue ($currentPage->ContainsBook ());
|
$this->assertTrue ($currentPage->ContainsBook ());
|
||||||
$this->assertFalse ($currentPage->IsPaginated ());
|
$this->assertFalse ($currentPage->IsPaginated ());
|
||||||
|
|
Loading…
Reference in a new issue