From a108adfa236d55d172589d1aeaa01d8b642c0b9f Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Wed, 27 Jul 2016 14:32:37 -0400 Subject: [PATCH] Finish moving get_cached_image method to Util class --- app/views/header.php | 45 +------------------ app/views/main-menu.php | 44 ++++++++++++++++++ src/Aviat/AnimeClient/Command/CacheImages.php | 10 ++--- src/Aviat/AnimeClient/Controller.php | 7 ++- .../AnimeClient/Model/AnimeCollection.php | 8 +++- 5 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 app/views/main-menu.php diff --git a/app/views/header.php b/app/views/header.php index 5ec53689..d5dd4835 100644 --- a/app/views/header.php +++ b/app/views/header.php @@ -1,4 +1,3 @@ - @@ -12,49 +11,7 @@
-

- - - - get('whose_list') ?>'s List - - get("show_{$url_type}_collection")): ?> - [ Collection] - - [ List] - - - get('whose_list') ?>'s Collection - - [Anime List] - [Manga List] - - - is_authenticated()): ?> -   - - - -   - - - is_authenticated()): ?> - Logout - - [get('whose_list') ?>'s Login] - - -

- + +

+ + + + get('whose_list') ?>'s List + + get("show_{$url_type}_collection")): ?> + [ Collection] + + [ List] + + + get('whose_list') ?>'s Collection + + [Anime List] + [Manga List] + + + is_authenticated()): ?> +   + + + +   + + + is_authenticated()): ?> + Logout + + [get('whose_list') ?>'s Login] + + +

+ \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Command/CacheImages.php b/src/Aviat/AnimeClient/Command/CacheImages.php index 599ef928..34e68843 100644 --- a/src/Aviat/AnimeClient/Command/CacheImages.php +++ b/src/Aviat/AnimeClient/Command/CacheImages.php @@ -13,7 +13,7 @@ namespace Aviat\AnimeClient\Command; -use Aviat\AnimeClient\Model; +use Aviat\AnimeClient\Util; /** * Generates thumbnail image cache so that cover images load faster */ @@ -21,7 +21,7 @@ class CacheImages extends BaseCommand { protected $mangaModel; protected $animeModel; - protected $model; + protected $util; /* * Convert manga images @@ -37,7 +37,7 @@ class CacheImages extends BaseCommand { $current = 0; foreach($manga_list as $item) { - $this->model->get_cached_image($item['poster_image'], $item['id'], 'manga'); + $this->util->get_cached_image($item['poster_image'], $item['id'], 'manga'); $current++; echo "Cached {$current} of {$total} manga images. \n"; @@ -57,7 +57,7 @@ class CacheImages extends BaseCommand { $current = 0; foreach($raw_list as $item) { - $this->model->get_cached_image($item['anime']['cover_image'], $item['anime']['slug'], 'anime'); + $this->util->get_cached_image($item['anime']['cover_image'], $item['anime']['slug'], 'anime'); $current++; echo "Cached {$current} of {$total} anime images. \n"; @@ -75,7 +75,7 @@ class CacheImages extends BaseCommand { public function execute(array $args, array $options = array()) { $this->setContainer($this->setupContainer()); - $this->model = new Model($this->container); + $this->util = new Util($this->container); $this->animeModel = $this->container->get('anime-model'); $this->mangaModel = $this->container->get('manga-model'); diff --git a/src/Aviat/AnimeClient/Controller.php b/src/Aviat/AnimeClient/Controller.php index 88f262eb..f558ee5b 100644 --- a/src/Aviat/AnimeClient/Controller.php +++ b/src/Aviat/AnimeClient/Controller.php @@ -21,7 +21,6 @@ use Aviat\Ion\View\JsonView; * Controller base, defines output methods * * @property Response object $response - * @property Config object $config */ class Controller { @@ -35,7 +34,7 @@ class Controller { /** * The global configuration object - * @var object $config + * @var Aviat\Ion\ConfigInterface $config */ protected $config; @@ -148,7 +147,7 @@ class Controller { return; } - $anime_client = $this->container->get('anime-client'); + $util = $this->container->get('util'); $double_form_page = $server_params['HTTP_REFERER'] == $this->request->getUri(); // Don't attempt to set the redirect url if @@ -161,7 +160,7 @@ class Controller { if (is_null($url)) { - $url = ($anime_client->is_view_page()) + $url = ($util->is_view_page()) ? $this->request->url->get() : $server_params['HTTP_REFERER']; } diff --git a/src/Aviat/AnimeClient/Model/AnimeCollection.php b/src/Aviat/AnimeClient/Model/AnimeCollection.php index 7b426344..2f54be93 100644 --- a/src/Aviat/AnimeClient/Model/AnimeCollection.php +++ b/src/Aviat/AnimeClient/Model/AnimeCollection.php @@ -129,6 +129,8 @@ class AnimeCollection extends Collection { { $anime = (object)$this->anime_model->get_anime($data['id']); + $util = $this->container->get('util'); + $this->db->set([ 'hummingbird_id' => $data['id'], 'slug' => $anime->slug, @@ -137,7 +139,7 @@ class AnimeCollection extends Collection { 'show_type' => $anime->show_type, 'age_rating' => $anime->age_rating, 'cover_image' => basename( - $this->get_cached_image($anime->cover_image, $anime->slug, 'anime') + $util->get_cached_image($anime->cover_image, $anime->slug, 'anime') ), 'episode_count' => $anime->episode_count, 'episode_length' => $anime->episode_length, @@ -222,6 +224,8 @@ class AnimeCollection extends Collection { foreach ($anime as $item) { + $util = $this->container->get('util'); + $this->db->set([ 'hummingbird_id' => $item->id, 'slug' => $item->slug, @@ -230,7 +234,7 @@ class AnimeCollection extends Collection { 'show_type' => $item->show_type, 'age_rating' => $item->age_rating, 'cover_image' => basename( - $this->get_cached_image($item->cover_image, $item->slug, 'anime') + $util->get_cached_image($item->cover_image, $item->slug, 'anime') ), 'episode_count' => $item->episode_count, 'episode_length' => $item->episode_length