From 1fa5695a9fd5b2cd79116cfca93d4c1ce998de08 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 21 Aug 2018 17:09:42 -0400 Subject: [PATCH] Anime Collection improvements * Allow editing title and alternate title * Show list of genres on list view of collection --- app/views/anime/cover-item.php | 84 ++++++++++++++++++++++++++++++ app/views/anime/cover.php | 75 +------------------------- app/views/collection/edit.php | 24 +++++---- app/views/collection/list-item.php | 1 + app/views/collection/list.php | 1 + src/Model/AnimeCollection.php | 31 ++++++++++- 6 files changed, 130 insertions(+), 86 deletions(-) create mode 100644 app/views/anime/cover-item.php diff --git a/app/views/anime/cover-item.php b/app/views/anime/cover-item.php new file mode 100644 index 00000000..3f8060ae --- /dev/null +++ b/app/views/anime/cover-item.php @@ -0,0 +1,84 @@ +
+ isAuthenticated()): ?> + + + " alt=""/> + +
+ +
+ + + + + +
+ + + 0): ?> +
+
Rewatched time(s)
+
+ + + 0): ?> +
+ + + +
+ + + isAuthenticated()): ?> +
+ + Edit + +
+ + +
+
Rating: / 10
+
Episodes: + / + +
+
+
+
html($item['anime']['show_type']) ?>
+
html($item['airing']['status']) ?>
+
html($item['anime']['age_rating']) ?>
+
+
+
\ No newline at end of file diff --git a/app/views/anime/cover.php b/app/views/anime/cover.php index 3607cdf6..60e08632 100644 --- a/app/views/anime/cover.php +++ b/app/views/anime/cover.php @@ -17,80 +17,7 @@
isAuthenticated()) continue; ?> -
- isAuthenticated()): ?> - - - " alt="" /> - -
- -
- - - - - -
- - - 0): ?> -
-
Rewatched time(s)
-
- - - 0): ?> -
- - - -
- - - isAuthenticated()): ?> -
- - Edit - -
- - -
-
Rating: / 10
-
Episodes: - / - -
-
-
-
html($item['anime']['show_type']) ?>
-
html($item['airing']['status']) ?>
-
html($item['anime']['age_rating']) ?>
-
-
-
+
diff --git a/app/views/collection/edit.php b/app/views/collection/edit.php index bf40de8c..33d21282 100644 --- a/app/views/collection/edit.php +++ b/app/views/collection/edit.php @@ -3,24 +3,26 @@

Edit Anime Collection Item

- - - - - - + + + + + + + + + \ No newline at end of file diff --git a/app/views/collection/list.php b/app/views/collection/list.php index a69ae61c..e0a1ab9a 100644 --- a/app/views/collection/list.php +++ b/app/views/collection/list.php @@ -24,6 +24,7 @@ + diff --git a/src/Model/AnimeCollection.php b/src/Model/AnimeCollection.php index ba578f0d..72833968 100644 --- a/src/Model/AnimeCollection.php +++ b/src/Model/AnimeCollection.php @@ -121,9 +121,20 @@ final class AnimeCollection extends Collection { ->join('media', 'media.id=a.media_id', 'inner') ->order_by('media') ->order_by('title') + ->group_by('a.hummingbird_id') ->get(); - return $query->fetchAll(PDO::FETCH_ASSOC); + // Add genres associated with each item + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + $genres = $this->getGenresForList(); + + foreach($rows as &$row) + { + $row['genres'] = $genres[$row['hummingbird_id']]; + sort($row['genres']); + } + + return $rows; } /** @@ -210,6 +221,24 @@ final class AnimeCollection extends Collection { return $query->fetch(PDO::FETCH_ASSOC); } + private function getGenresForList(): array + { + $query = $this->db->select('hummingbird_id, genre') + ->from('genres g') + ->join('genre_anime_set_link gasl', 'gasl.genre_id=g.id') + ->get(); + + $rows = $query->fetchAll(PDO::FETCH_ASSOC); + $output = []; + + foreach($rows as $row) + { + $output[$row['hummingbird_id']][] = $row['genre']; + } + + return $output; + } + /** * Update genre information for selected anime *