diff --git a/author.php b/author.php index 9c19021..28d38e4 100644 --- a/author.php +++ b/author.php @@ -19,9 +19,10 @@ class Author extends Base { public $name; public $sort; - public function __construct($pid, $pname) { + public function __construct($pid, $pname, $psort) { $this->id = $pid; $this->name = $pname; + $this->sort = $psort; } public function getUri () { @@ -72,7 +73,7 @@ order by substr (upper (sort), 1, 1)'); $entryArray = array(); 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 (), str_format (localize("bookword", $post->count), $post->count), "text", array ( new LinkNavigation ($author->getUri ())))); @@ -81,20 +82,20 @@ order by substr (upper (sort), 1, 1)'); } 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)); - return new Author ($authorId, $result->fetchColumn ()); + $post = $result->fetchObject (); + return new Author ($post->id, $post->name, $post->sort); } public static function getAuthorByBookId ($bookId) { - $result = parent::getDb ()->prepare('select authors.id as id, authors.sort as sort -from authors, books_authors_link + $result = parent::getDb ()->prepare('select ' . self::AUTHOR_COLUMNS . ' from authors, books_authors_link where author = authors.id and book = ?'); $result->execute (array ($bookId)); $authorArray = array (); 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; } diff --git a/book.php b/book.php index a78930e..1ac4691 100644 --- a/book.php +++ b/book.php @@ -142,6 +142,10 @@ class Book extends Base { 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 () { if (is_null ($this->publisher)) { $this->publisher = Publisher::getPublisherByBookId ($this->id); diff --git a/data.php b/data.php index 3d8da77..30d34d5 100644 --- a/data.php +++ b/data.php @@ -91,7 +91,7 @@ class Data extends Base { } public function getUpdatedFilename () { - return $this->book->getAuthorsName () . " - " . $this->book->title; + return $this->book->getAuthorsSort () . " - " . $this->book->title; } public function getUpdatedFilenameEpub () { diff --git a/test/bookTest.php b/test/bookTest.php index 441fbd4..8defd10 100644 --- a/test/bookTest.php +++ b/test/bookTest.php @@ -184,7 +184,7 @@ class BookTest extends PHPUnit_Framework_TestCase $this->assertEquals ("The Return of Sherlock Holmes", $book->getTitle ()); $this->assertEquals ("urn:uuid:87ddbdeb-1e27-4d06-b79b-4b2a3bfc6a5f", $book->getEntryId ()); $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 ('

The Return of Sherlock Holmes is a collection of 13 Sherlock Holmes stories, originally published in 1903-1904, by Arthur Conan Doyle.
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.
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.

', $book->getComment (false)); $this->assertEquals ("English", $book->getLanguages ()); diff --git a/test/pageTest.php b/test/pageTest.php index 98894fc..1413bc5 100644 --- a/test/pageTest.php +++ b/test/pageTest.php @@ -254,7 +254,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertEquals ("Doyle, Arthur Conan", $currentPage->title); + $this->assertEquals ("Arthur Conan Doyle", $currentPage->title); $this->assertEquals (4, $currentPage->getMaxPage ()); $this->assertCount (2, $currentPage->entryArray); $this->assertTrue ($currentPage->ContainsBook ()); @@ -268,7 +268,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertEquals ("Doyle, Arthur Conan", $currentPage->title); + $this->assertEquals ("Arthur Conan Doyle", $currentPage->title); $this->assertEquals (2, $currentPage->getMaxPage ()); $this->assertCount (3, $currentPage->entryArray); $this->assertTrue ($currentPage->ContainsBook ()); @@ -281,7 +281,7 @@ class PageTest extends PHPUnit_Framework_TestCase $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent (); - $this->assertEquals ("Doyle, Arthur Conan", $currentPage->title); + $this->assertEquals ("Arthur Conan Doyle", $currentPage->title); $this->assertCount (8, $currentPage->entryArray); $this->assertTrue ($currentPage->ContainsBook ()); $this->assertFalse ($currentPage->IsPaginated ());