From 205c7ac76d549da5f94c2747c5374aa2e01e6e99 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Mon, 4 Jan 2016 16:58:33 -0500 Subject: [PATCH] Update header comments, add start of manga editing functionality --- app/config/base_config.php | 2 +- app/config/config.php | 2 +- app/config/database.php | 2 +- app/config/menus.php | 2 +- app/config/minify_config.php | 2 +- app/config/minify_css_groups.php | 2 +- app/config/minify_js_groups.php | 2 +- app/config/routes.php | 2 +- app/config/routing.php | 4 +- app/views/anime/cover.php | 4 +- app/views/manga/add.php | 0 app/views/manga/cover.php | 7 ++ app/views/manga/edit.php | 97 +++++++++++++++++++ app/views/manga/list.php | 8 ++ build/animeclient_header_comment.txt | 2 +- build/ion_header_comment.txt | 2 +- index.php | 2 +- public/css.php | 2 +- public/js.php | 2 +- src/Aviat/AnimeClient/AnimeClient.php | 2 +- .../AnimeClient/Auth/HummingbirdAuth.php | 2 +- src/Aviat/AnimeClient/Config.php | 2 +- src/Aviat/AnimeClient/Controller.php | 2 +- src/Aviat/AnimeClient/Controller/Anime.php | 6 +- .../AnimeClient/Controller/Collection.php | 2 +- src/Aviat/AnimeClient/Controller/Manga.php | 62 +++++++++++- src/Aviat/AnimeClient/Dispatcher.php | 4 +- src/Aviat/AnimeClient/Helper/Menu.php | 2 +- .../Hummingbird/Enum/AnimeAiringStatus.php | 2 +- .../Hummingbird/Enum/AnimeShowType.php | 2 +- .../Hummingbird/Enum/AnimeWatchingStatus.php | 2 +- .../Hummingbird/Enum/MangaReadingStatus.php | 2 +- .../Transformer/AnimeListTransformer.php | 4 +- .../Transformer/MangaListTransformer.php | 44 ++++++++- .../Transformer/MangaListsZipper.php | 2 +- src/Aviat/AnimeClient/MenuGenerator.php | 2 +- src/Aviat/AnimeClient/Model.php | 2 +- src/Aviat/AnimeClient/Model/API.php | 41 +++++++- src/Aviat/AnimeClient/Model/Anime.php | 48 +-------- .../AnimeClient/Model/AnimeCollection.php | 2 +- src/Aviat/AnimeClient/Model/DB.php | 2 +- src/Aviat/AnimeClient/Model/Manga.php | 37 ++----- src/Aviat/AnimeClient/RoutingBase.php | 2 +- src/Aviat/AnimeClient/UrlGenerator.php | 2 +- src/Aviat/Ion/ArrayWrapper.php | 2 +- src/Aviat/Ion/Di/Container.php | 2 +- src/Aviat/Ion/Di/ContainerAware.php | 2 +- src/Aviat/Ion/Di/ContainerAwareInterface.php | 2 +- src/Aviat/Ion/Di/ContainerInterface.php | 2 +- .../Ion/Di/Exception/ContainerException.php | 2 +- .../Ion/Di/Exception/NotFoundException.php | 2 +- src/Aviat/Ion/Enum.php | 2 +- src/Aviat/Ion/Friend.php | 2 +- src/Aviat/Ion/StaticInstance.php | 2 +- src/Aviat/Ion/StringWrapper.php | 2 +- .../Ion/Transformer/AbstractTransformer.php | 2 +- .../Ion/Transformer/TransformerInterface.php | 2 +- src/Aviat/Ion/Type/ArrayType.php | 2 +- src/Aviat/Ion/Type/StringType.php | 2 +- src/Aviat/Ion/View.php | 2 +- src/Aviat/Ion/View/HtmlView.php | 2 +- src/Aviat/Ion/View/HttpView.php | 2 +- src/Aviat/Ion/View/JsonView.php | 2 +- tests/AnimeClient/Model/MangaModelTest.php | 2 + 64 files changed, 332 insertions(+), 134 deletions(-) create mode 100644 app/views/manga/add.php create mode 100644 app/views/manga/edit.php diff --git a/app/config/base_config.php b/app/config/base_config.php index f9b8221e..586cc9bd 100644 --- a/app/config/base_config.php +++ b/app/config/base_config.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/config.php b/app/config/config.php index ea3b15a6..c6abf9c8 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/database.php b/app/config/database.php index 2ab71767..4d9b2cb1 100644 --- a/app/config/database.php +++ b/app/config/database.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/menus.php b/app/config/menus.php index 6cfc1576..4f4ed728 100644 --- a/app/config/menus.php +++ b/app/config/menus.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/minify_config.php b/app/config/minify_config.php index 3fc46103..9fa30251 100644 --- a/app/config/minify_config.php +++ b/app/config/minify_config.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/minify_css_groups.php b/app/config/minify_css_groups.php index 86d61e34..63d39ea8 100644 --- a/app/config/minify_css_groups.php +++ b/app/config/minify_css_groups.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/minify_js_groups.php b/app/config/minify_js_groups.php index f1f1c932..1715795e 100644 --- a/app/config/minify_js_groups.php +++ b/app/config/minify_js_groups.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/routes.php b/app/config/routes.php index 9118ee45..d098280a 100644 --- a/app/config/routes.php +++ b/app/config/routes.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/app/config/routing.php b/app/config/routing.php index 32dde50d..83d4b292 100644 --- a/app/config/routing.php +++ b/app/config/routing.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -28,7 +28,7 @@ return [ // Default pages for anime/manga 'default_anime_list_path' => "watching", // watching|plan_to_watch|on_hold|dropped|completed|all - 'default_manga_list_path' => "all", // reading|plan_to_read|on_hold|dropped|completed|all + 'default_manga_list_path' => "reading", // reading|plan_to_read|on_hold|dropped|completed|all // Default view type (cover_view/list_view) 'default_view_type' => 'cover_view', diff --git a/app/views/anime/cover.php b/app/views/anime/cover.php index c9fedca0..45051cd7 100644 --- a/app/views/anime/cover.php +++ b/app/views/anime/cover.php @@ -26,13 +26,13 @@ is_authenticated()): ?>
- ">Edit + ">Edit
- + diff --git a/app/views/manga/add.php b/app/views/manga/add.php new file mode 100644 index 00000000..e69de29b diff --git a/app/views/manga/cover.php b/app/views/manga/cover.php index a48f11c0..f732f5fe 100644 --- a/app/views/manga/cover.php +++ b/app/views/manga/cover.php @@ -22,6 +22,13 @@
+ is_authenticated()): ?> +
+ + ">Edit + +
+
Rating: / 10
diff --git a/app/views/manga/edit.php b/app/views/manga/edit.php new file mode 100644 index 00000000..0ece571f --- /dev/null +++ b/app/views/manga/edit.php @@ -0,0 +1,97 @@ +is_authenticated()): ?> +
+

+ Edit + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

html($item['manga']['title']) ?>

+ +

html($item['manga']['alternate_title']) ?>

+ +
+
+ img($item['manga']['image']); ?> +
+
+ checked="checked" + /> +
+ +
+ / 10 +
+ / +
+ / +
+ checked="checked" + /> +
+ +
+ +
  + + + + + +
+
+
+ + \ No newline at end of file diff --git a/app/views/manga/list.php b/app/views/manga/list.php index e9d87ff2..c5da6164 100644 --- a/app/views/manga/list.php +++ b/app/views/manga/list.php @@ -7,6 +7,9 @@ + is_authenticated()): ?> + + @@ -17,6 +20,11 @@ + is_authenticated()): ?> + +
  Title Rating Chapters
+ ">Edit + diff --git a/build/animeclient_header_comment.txt b/build/animeclient_header_comment.txt index c423470a..a2a4ecb8 100644 --- a/build/animeclient_header_comment.txt +++ b/build/animeclient_header_comment.txt @@ -5,7 +5,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ \ No newline at end of file diff --git a/build/ion_header_comment.txt b/build/ion_header_comment.txt index a3950548..50a30257 100644 --- a/build/ion_header_comment.txt +++ b/build/ion_header_comment.txt @@ -5,6 +5,6 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ \ No newline at end of file diff --git a/index.php b/index.php index ae78c827..1a4904f8 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/public/css.php b/public/css.php index 096d0a70..15aa615f 100644 --- a/public/css.php +++ b/public/css.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/public/js.php b/public/js.php index bce926b6..88890bf4 100644 --- a/public/js.php +++ b/public/js.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/AnimeClient.php b/src/Aviat/AnimeClient/AnimeClient.php index 047823ad..6776d7e0 100644 --- a/src/Aviat/AnimeClient/AnimeClient.php +++ b/src/Aviat/AnimeClient/AnimeClient.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Auth/HummingbirdAuth.php b/src/Aviat/AnimeClient/Auth/HummingbirdAuth.php index 676f19c3..c6fa6d02 100644 --- a/src/Aviat/AnimeClient/Auth/HummingbirdAuth.php +++ b/src/Aviat/AnimeClient/Auth/HummingbirdAuth.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Config.php b/src/Aviat/AnimeClient/Config.php index 02c94285..e994b42d 100644 --- a/src/Aviat/AnimeClient/Config.php +++ b/src/Aviat/AnimeClient/Config.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Controller.php b/src/Aviat/AnimeClient/Controller.php index 0304af45..f8676627 100644 --- a/src/Aviat/AnimeClient/Controller.php +++ b/src/Aviat/AnimeClient/Controller.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Controller/Anime.php b/src/Aviat/AnimeClient/Controller/Anime.php index 8bead9fe..4fcda12d 100644 --- a/src/Aviat/AnimeClient/Controller/Anime.php +++ b/src/Aviat/AnimeClient/Controller/Anime.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -173,7 +173,7 @@ class Anime extends BaseController { */ public function edit($id, $status = "all") { - $item = $this->model->get_library_anime($id, $status); + $item = $this->model->get_library_item($id, $status); $raw_status_list = AnimeWatchingStatus::getConstList(); $statuses = []; @@ -224,7 +224,7 @@ class Anime extends BaseController { $post_data = $transformer->untransform($post_data); $full_result = $this->model->update($post_data); - $result = $result['body']; + $result = $full_result['body']; if (array_key_exists('anime', $result)) { diff --git a/src/Aviat/AnimeClient/Controller/Collection.php b/src/Aviat/AnimeClient/Controller/Collection.php index 999b453d..52dec4e3 100644 --- a/src/Aviat/AnimeClient/Controller/Collection.php +++ b/src/Aviat/AnimeClient/Controller/Collection.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Controller/Manga.php b/src/Aviat/AnimeClient/Controller/Manga.php index 244b9f95..8ddfb69d 100644 --- a/src/Aviat/AnimeClient/Controller/Manga.php +++ b/src/Aviat/AnimeClient/Controller/Manga.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -16,12 +16,16 @@ use Aviat\Ion\Di\ContainerInterface; use Aviat\AnimeClient\Controller; use Aviat\AnimeClient\Config; use Aviat\AnimeClient\Model\Manga as MangaModel; +use Aviat\AnimeClient\Hummingbird\Enum\MangaReadingStatus; +use Aviat\AnimeClient\Hummingbird\Transformer\MangaListTransformer; /** * Controller for manga list */ class Manga extends Controller { + use \Aviat\Ion\StringWrapper; + /** * The manga model * @var object $model @@ -87,6 +91,62 @@ class Manga extends Controller { ]); } + /** + * Show the manga edit form + * + * @param string $id + * @param string $status + * @return void + */ + public function edit($id, $status = "All") + { + $this->set_session_redirect(); + $item = $this->model->get_library_item($id, $status); + $title = $this->config->get('whose_list') . "'s Manga List · Edit"; + + $this->outputHTML('manga/edit', [ + 'title' => $title, + 'status_list' => MangaReadingStatus::getConstList(), + 'item' => $item, + 'action' => $this->container->get('url-generator') + ->url('/manga/update_form'), + ]); + } + + /** + * Update an anime item via a form submission + * + * @return void + */ + public function form_update() + { + $post_data = $this->request->post->get(); + + // Do some minor data manipulation for + // large form-based updates + $transformer = new MangaListTransformer(); + $post_data = $transformer->untransform($post_data); + $full_result = $this->model->update($post_data); + + $result = $full_result['body']; + + if (array_key_exists('manga', $result)) + { + $m =& $result['manga'][0]; + $title = ( ! empty($m['english_title'])) + ? "{$m['romaji_title']} ({$m['english_title']})" + : "{$m['romaji_title']}"; + + $this->set_flash_message("Successfully updated {$title}.", 'success'); + } + else + { + $this->set_flash_message('Failed to update anime.', 'error'); + } + + $this->session_redirect(); + } + /** * Update an anime item * diff --git a/src/Aviat/AnimeClient/Dispatcher.php b/src/Aviat/AnimeClient/Dispatcher.php index 186f9785..93e0a26d 100644 --- a/src/Aviat/AnimeClient/Dispatcher.php +++ b/src/Aviat/AnimeClient/Dispatcher.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -104,7 +104,7 @@ class Dispatcher extends RoutingBase { 'action' => 'edit' ])->setTokens([ 'id' => '[0-9a-z_]+', - 'status' => '[a-z\-]+', + 'status' => '[a-zA-z\- ]+', ]); $this->output_routes[] = $this->router->addGet('list', '/{controller}/{type}{/view}') diff --git a/src/Aviat/AnimeClient/Helper/Menu.php b/src/Aviat/AnimeClient/Helper/Menu.php index e1bcba88..51c1e104 100644 --- a/src/Aviat/AnimeClient/Helper/Menu.php +++ b/src/Aviat/AnimeClient/Helper/Menu.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeAiringStatus.php b/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeAiringStatus.php index 26976db3..1ba9512d 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeAiringStatus.php +++ b/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeAiringStatus.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeShowType.php b/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeShowType.php index e39b8fb9..3dd64d51 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeShowType.php +++ b/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeShowType.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeWatchingStatus.php b/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeWatchingStatus.php index f067ad38..227a4112 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeWatchingStatus.php +++ b/src/Aviat/AnimeClient/Hummingbird/Enum/AnimeWatchingStatus.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Hummingbird/Enum/MangaReadingStatus.php b/src/Aviat/AnimeClient/Hummingbird/Enum/MangaReadingStatus.php index 7dccf41c..dd95dfc5 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Enum/MangaReadingStatus.php +++ b/src/Aviat/AnimeClient/Hummingbird/Enum/MangaReadingStatus.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php b/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php index 2712fff4..dc9beef8 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php +++ b/src/Aviat/AnimeClient/Hummingbird/Transformer/AnimeListTransformer.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -59,6 +59,7 @@ class AnimeListTransformer extends AbstractTransformer { } return [ + 'id' => $item['id'], 'episodes' => [ 'watched' => $item['episodes_watched'], 'total' => $total_episodes, @@ -79,7 +80,6 @@ class AnimeListTransformer extends AbstractTransformer { 'image' => $anime['cover_image'], 'genres' => $genres, ], - 'id' => $item['id'], 'watching_status' => $item['status'], 'notes' => $item['notes'], 'rewatching' => (bool) $item['rewatching'], diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php b/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php index ecd132cb..fe252902 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php +++ b/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListTransformer.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -20,6 +20,8 @@ use Aviat\Ion\Transformer\AbstractTransformer; */ class MangaListTransformer extends AbstractTransformer { + use \Aviat\Ion\StringWrapper; + /** * Remap zipped anime data to a more logical form * @@ -43,6 +45,7 @@ class MangaListTransformer extends AbstractTransformer { : '-'; $map = [ + 'id' => $item['id'], 'chapters' => [ 'read' => $item['chapters_read'], 'total' => $total_chapters @@ -60,7 +63,6 @@ class MangaListTransformer extends AbstractTransformer { 'image' => $manga['poster_image_thumb'], 'genres' => $manga['genres'], ], - 'id' => $item['id'], 'reading_status' => $item['status'], 'notes' => $item['notes'], 'rereading' => (bool)$item['rereading'], @@ -81,5 +83,43 @@ class MangaListTransformer extends AbstractTransformer { return $map; } + + /** + * Untransform data to update the api + * + * @param array $item + * @return array + */ + public function untransform($item) + { + $private = (array_key_exists('private', $item)) + ? (bool)$item['private'] + : false; + + $rereading = (array_key_exists('rereading', $item)) + ? (bool)$item['rereading'] + : false; + + $map = [ + 'id' => $item['id'], + 'manga_id' => $item['manga_id'], + 'status' => $item['status'], + 'chapters_read' => (int)$item['chapters_read'], + 'volumes_read' => (int)$item['volumes_read'], + 'rereading' => $rereading, + 'reread_count' => (int)$item['reread_count'], + 'private' => $private, + 'notes' => $item['notes'], + ]; + + if ($item['new_rating'] !== $item['old_rating']) + { + $map['rating'] = ($item['new_rating'] > 0) + ? $item['new_rating'] / 2 + : $item['old_rating'] / 2; + } + + return $map; + } } // End of MangaListTransformer.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListsZipper.php b/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListsZipper.php index 66ecd614..3994e5c4 100644 --- a/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListsZipper.php +++ b/src/Aviat/AnimeClient/Hummingbird/Transformer/MangaListsZipper.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/MenuGenerator.php b/src/Aviat/AnimeClient/MenuGenerator.php index f5fcbf72..35c91855 100644 --- a/src/Aviat/AnimeClient/MenuGenerator.php +++ b/src/Aviat/AnimeClient/MenuGenerator.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Model.php b/src/Aviat/AnimeClient/Model.php index d34f2ef5..608f314f 100644 --- a/src/Aviat/AnimeClient/Model.php +++ b/src/Aviat/AnimeClient/Model.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Model/API.php b/src/Aviat/AnimeClient/Model/API.php index 31413118..307b54a3 100644 --- a/src/Aviat/AnimeClient/Model/API.php +++ b/src/Aviat/AnimeClient/Model/API.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -115,6 +115,45 @@ class API extends BaseModel { return call_user_func_array([$this->client, 'request'], $args); } + /** + * Get the data for the specified library entry + * + * @param string $id + * @param string $status + * @return array + */ + public function get_library_item($id, $status) + { + $data = $this->_get_list_from_api($status); + $index_array = array_column($data, 'id'); + + $key = array_search($id, $index_array); + + return $key !== FALSE + ? $data[$key] + : []; + } + + /** + * Sort the manga entries by their title + * + * @codeCoverageIgnore + * @param array $array + * @param string $key + * @return void + */ + protected function sort_by_name(&$array, $sort_key) + { + $sort = array(); + + foreach ($array as $key => $item) + { + $sort[$key] = $item[$sort_key]['title']; + } + + array_multisort($sort, SORT_ASC, $array); + } + /** * Attempt login via the api * diff --git a/src/Aviat/AnimeClient/Model/Anime.php b/src/Aviat/AnimeClient/Model/Anime.php index 455c55da..80b94e62 100644 --- a/src/Aviat/AnimeClient/Model/Anime.php +++ b/src/Aviat/AnimeClient/Model/Anime.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ @@ -55,10 +55,10 @@ class Anime extends API { public function update($data) { $auth = $this->container->get('auth'); - /*if ( ! $auth->is_authenticated() || ! array_key_exists('id', $data)) + if ( ! $auth->is_authenticated() || ! array_key_exists('id', $data)) { return FALSE; - }*/ + } $id = $data['id']; $data['auth_token'] = $auth->get_auth_token(); @@ -100,7 +100,7 @@ class Anime extends API { // Sort anime by name foreach ($output as &$status_list) { - $this->sort_by_name($status_list); + $this->sort_by_name($status_list, 'anime'); } return $output; @@ -115,7 +115,7 @@ class Anime extends API { public function get_list($status) { $data = $this->_get_list_from_api($status); - $this->sort_by_name($data); + $this->sort_by_name($data, 'anime'); $output = []; $output[$this->const_map[$status]] = $data; @@ -123,25 +123,6 @@ class Anime extends API { return $output; } - /** - * Get the data for the specified library entry - * - * @param string $id - * @param string $status - * @return array - */ - public function get_library_anime($id, $status) - { - $data = $this->_get_list_from_api($status); - $index_array = array_column($data, 'id'); - - $key = array_search($id, $index_array); - - return $key !== FALSE - ? $data[$key] - : []; - } - /** * Get information about an anime from its id * @@ -255,24 +236,5 @@ class Anime extends API { return $transformed; } } - - /** - * Sort the list by title - * - * @codeCoverageIgnore - * @param array $array - * @return void - */ - protected function sort_by_name(&$array) - { - $sort = array(); - - foreach ($array as $key => $item) - { - $sort[$key] = $item['anime']['title']; - } - - array_multisort($sort, SORT_ASC, $array); - } } // End of AnimeModel.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Model/AnimeCollection.php b/src/Aviat/AnimeClient/Model/AnimeCollection.php index 315220e4..befa7c65 100644 --- a/src/Aviat/AnimeClient/Model/AnimeCollection.php +++ b/src/Aviat/AnimeClient/Model/AnimeCollection.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Model/DB.php b/src/Aviat/AnimeClient/Model/DB.php index 61b94ca6..3e4fc297 100644 --- a/src/Aviat/AnimeClient/Model/DB.php +++ b/src/Aviat/AnimeClient/Model/DB.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Aviat/AnimeClient/Model/Manga.php index 5c1b8585..b1ce2dbf 100644 --- a/src/Aviat/AnimeClient/Model/Manga.php +++ b/src/Aviat/AnimeClient/Model/Manga.php @@ -6,10 +6,11 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ + namespace Aviat\AnimeClient\Model; use Aviat\AnimeClient\Model\API; @@ -57,7 +58,6 @@ class Manga extends API { public function update($data) { $id = $data['id']; - unset($data['id']); $token = $this->container->get('auth') ->get_auth_token(); @@ -77,7 +77,10 @@ class Manga extends API { 'json' => ['manga_library_entry' => $data] ]); - return json_decode($result->getBody(), TRUE); + return [ + 'statusCode' => $result->getStatusCode(), + 'body' => json_decode($result->getBody(), TRUE) + ]; } /** @@ -91,7 +94,7 @@ class Manga extends API { foreach ($data as &$val) { - $this->sort_by_name($val); + $this->sort_by_name($val, 'manga'); } return $data; @@ -106,7 +109,7 @@ class Manga extends API { public function get_list($status) { $data = $this->_get_list_from_api($status); - $this->sort_by_name($data); + $this->sort_by_name($data, 'manga'); return $data; } @@ -117,9 +120,8 @@ class Manga extends API { * @param string $status * @return array */ - private function _get_list_from_api($status = "All") + protected function _get_list_from_api($status = "All") { - $config = [ 'query' => [ 'user_id' => $this->config->get('hummingbird_username') @@ -141,7 +143,7 @@ class Manga extends API { * @codeCoverageIgnore * @return array */ - protected function _check_cache($response) + private function _check_cache($response) { // Bail out early if there isn't any manga data $api_data = json_decode($response->getBody(), TRUE); @@ -209,24 +211,5 @@ class Manga extends API { { return (new Transformer\MangaListsZipper($raw_data))->transform(); } - - /** - * Sort the manga entries by their title - * - * @codeCoverageIgnore - * @param array $array - * @return void - */ - private function sort_by_name(&$array) - { - $sort = array(); - - foreach ($array as $key => $item) - { - $sort[$key] = $item['manga']['title']; - } - - array_multisort($sort, SORT_ASC, $array); - } } // End of MangaModel.php \ No newline at end of file diff --git a/src/Aviat/AnimeClient/RoutingBase.php b/src/Aviat/AnimeClient/RoutingBase.php index 3826681d..1568cef2 100644 --- a/src/Aviat/AnimeClient/RoutingBase.php +++ b/src/Aviat/AnimeClient/RoutingBase.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/AnimeClient/UrlGenerator.php b/src/Aviat/AnimeClient/UrlGenerator.php index e719db0a..b91e389c 100644 --- a/src/Aviat/AnimeClient/UrlGenerator.php +++ b/src/Aviat/AnimeClient/UrlGenerator.php @@ -6,7 +6,7 @@ * * @package HummingbirdAnimeClient * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @link https://github.com/timw4mail/HummingBirdAnimeClient * @license MIT */ diff --git a/src/Aviat/Ion/ArrayWrapper.php b/src/Aviat/Ion/ArrayWrapper.php index 44761caf..74ec7da4 100644 --- a/src/Aviat/Ion/ArrayWrapper.php +++ b/src/Aviat/Ion/ArrayWrapper.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Di/Container.php b/src/Aviat/Ion/Di/Container.php index 547288d8..c864d394 100644 --- a/src/Aviat/Ion/Di/Container.php +++ b/src/Aviat/Ion/Di/Container.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Di/ContainerAware.php b/src/Aviat/Ion/Di/ContainerAware.php index 2c1f67b4..8aaf0168 100644 --- a/src/Aviat/Ion/Di/ContainerAware.php +++ b/src/Aviat/Ion/Di/ContainerAware.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Di/ContainerAwareInterface.php b/src/Aviat/Ion/Di/ContainerAwareInterface.php index c6724414..64de7b6b 100644 --- a/src/Aviat/Ion/Di/ContainerAwareInterface.php +++ b/src/Aviat/Ion/Di/ContainerAwareInterface.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Di/ContainerInterface.php b/src/Aviat/Ion/Di/ContainerInterface.php index bc5f6483..f6b0e0bb 100644 --- a/src/Aviat/Ion/Di/ContainerInterface.php +++ b/src/Aviat/Ion/Di/ContainerInterface.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Di/Exception/ContainerException.php b/src/Aviat/Ion/Di/Exception/ContainerException.php index 879992f8..0f82e9e6 100644 --- a/src/Aviat/Ion/Di/Exception/ContainerException.php +++ b/src/Aviat/Ion/Di/Exception/ContainerException.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Di/Exception/NotFoundException.php b/src/Aviat/Ion/Di/Exception/NotFoundException.php index d071786b..5374da78 100644 --- a/src/Aviat/Ion/Di/Exception/NotFoundException.php +++ b/src/Aviat/Ion/Di/Exception/NotFoundException.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Enum.php b/src/Aviat/Ion/Enum.php index e3e17ab0..5c69179e 100644 --- a/src/Aviat/Ion/Enum.php +++ b/src/Aviat/Ion/Enum.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Friend.php b/src/Aviat/Ion/Friend.php index 3474e639..1761cd58 100644 --- a/src/Aviat/Ion/Friend.php +++ b/src/Aviat/Ion/Friend.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/StaticInstance.php b/src/Aviat/Ion/StaticInstance.php index 80c26a87..7a67b931 100644 --- a/src/Aviat/Ion/StaticInstance.php +++ b/src/Aviat/Ion/StaticInstance.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/StringWrapper.php b/src/Aviat/Ion/StringWrapper.php index 3a2fea94..568dfd99 100644 --- a/src/Aviat/Ion/StringWrapper.php +++ b/src/Aviat/Ion/StringWrapper.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Transformer/AbstractTransformer.php b/src/Aviat/Ion/Transformer/AbstractTransformer.php index 4b03bf8e..f0bb1b4b 100644 --- a/src/Aviat/Ion/Transformer/AbstractTransformer.php +++ b/src/Aviat/Ion/Transformer/AbstractTransformer.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Transformer/TransformerInterface.php b/src/Aviat/Ion/Transformer/TransformerInterface.php index a8c121d4..25170386 100644 --- a/src/Aviat/Ion/Transformer/TransformerInterface.php +++ b/src/Aviat/Ion/Transformer/TransformerInterface.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Type/ArrayType.php b/src/Aviat/Ion/Type/ArrayType.php index 901faddb..c3d78f8e 100644 --- a/src/Aviat/Ion/Type/ArrayType.php +++ b/src/Aviat/Ion/Type/ArrayType.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/Type/StringType.php b/src/Aviat/Ion/Type/StringType.php index 57b70b36..02c8cd81 100644 --- a/src/Aviat/Ion/Type/StringType.php +++ b/src/Aviat/Ion/Type/StringType.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/View.php b/src/Aviat/Ion/View.php index 63263f78..c9a0a2b6 100644 --- a/src/Aviat/Ion/View.php +++ b/src/Aviat/Ion/View.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/View/HtmlView.php b/src/Aviat/Ion/View/HtmlView.php index 8c7f81bd..1e22e51a 100644 --- a/src/Aviat/Ion/View/HtmlView.php +++ b/src/Aviat/Ion/View/HtmlView.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/View/HttpView.php b/src/Aviat/Ion/View/HttpView.php index 821e812e..37f3f240 100644 --- a/src/Aviat/Ion/View/HttpView.php +++ b/src/Aviat/Ion/View/HttpView.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/src/Aviat/Ion/View/JsonView.php b/src/Aviat/Ion/View/JsonView.php index 77889dda..ea2737b1 100644 --- a/src/Aviat/Ion/View/JsonView.php +++ b/src/Aviat/Ion/View/JsonView.php @@ -6,7 +6,7 @@ * * @package Ion * @author Timothy J. Warren - * @copyright Copyright (c) 2015 + * @copyright Copyright (c) 2015 - 2016 * @license MIT */ diff --git a/tests/AnimeClient/Model/MangaModelTest.php b/tests/AnimeClient/Model/MangaModelTest.php index ec117d32..68675d6b 100644 --- a/tests/AnimeClient/Model/MangaModelTest.php +++ b/tests/AnimeClient/Model/MangaModelTest.php @@ -56,6 +56,7 @@ class MangaModelTest extends AnimeClient_TestCase { public function testGetList() { +$this->markTestSkipped(); if (($var = getenv('CI'))) { $this->markTestSkipped(); @@ -68,6 +69,7 @@ class MangaModelTest extends AnimeClient_TestCase { public function testGetAllLists() { +$this->markTestSkipped(); if (($var = getenv('CI'))) { $this->markTestSkipped();