Update header comments, add start of manga editing functionality

This commit is contained in:
Timothy Warren 2016-01-04 16:58:33 -05:00
parent 6b9be7e4d0
commit e9e16dd2b1
64 changed files with 332 additions and 134 deletions

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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',

View File

@ -26,13 +26,13 @@
<?php if ($auth->is_authenticated()): ?>
<div class="row">
<span class="edit">
<a class="bracketed" title="Edit information about this anime" href="<?= $urlGenerator->url("anime/edit/{$item['id']}/{$item['watching_status']}", "anime") ?>">Edit</a>
<a class="bracketed" title="Edit information about this anime" href="<?= $urlGenerator->url("anime/edit/{$item['id']}/{$item['watching_status']}") ?>">Edit</a>
</span>
</div>
<?php endif ?>
<?php if ($item['private'] || $item['rewatching']): ?>
<div class="row">
<?php foreach(['private', 'rewatching'] as $attr): ?>
<?php foreach(['private', 'rereading'] as $attr): ?>
<?php if($item[$attr]): ?>
<span class="item-<?= $attr ?>"><?= ucfirst($attr) ?></span>
<?php endif ?>

0
app/views/manga/add.php Normal file
View File

View File

@ -22,6 +22,13 @@
</a>
</div>
<div class="table">
<?php if ($auth->is_authenticated()): ?>
<div class="row">
<span class="edit">
<a class="bracketed" title="Edit information about this manga" href="<?= $urlGenerator->url("manga/edit/{$item['id']}/{$name}") ?>">Edit</a>
</span>
</div>
<?php endif ?>
<div class="row">
<div class="user_rating">Rating: <?= $item['user_rating'] ?> / 10</div>
</div>

97
app/views/manga/edit.php Normal file
View File

@ -0,0 +1,97 @@
<?php if ($auth->is_authenticated()): ?>
<main>
<h1>
Edit <?= $item['manga']['title'] ?>
<?= ($item['manga']['alternate_title'] != "") ? "({$item['manga']['alternate_title']})" : ""; ?>
</h1>
<form action="<?= $action ?>" method="post">
<table class="form">
<thead>
<tr>
<th>
<h3><?= $escape->html($item['manga']['title']) ?></h3>
<?php if($item['manga']['alternate_title'] != ""): ?>
<h4><?= $escape->html($item['manga']['alternate_title']) ?></h4>
<?php endif ?>
</th>
<th>
<article class="media">
<?= $helper->img($item['manga']['image']); ?>
</article>
</th>
</tr>
</thead>
<tbody>
<tr>
<td><label for="private">Is Private?</label></td>
<td>
<input type="checkbox" name="private" id="private"
<?php if($item['private']): ?>checked="checked"<?php endif ?>
/>
</td>
</tr>
<tr>
<td><label for="status">Reading Status</label></td>
<td>
<select name="status" id="status">
<?php foreach($status_list as $status): ?>
<option <?php if($item['reading_status'] === $status): ?>selected="selected"<?php endif ?>
value="<?= $status ?>"><?= $status ?></option>
<?php endforeach ?>
</select>
</td>
</tr>
<tr>
<td><label for="series_rating">Rating</label></td>
<td>
<input type="number" min="0" max="10" maxlength="2" name="new_rating" value="<?= $item['user_rating'] ?>" id="series_rating" size="2" /> / 10
</td>
</tr>
<tr>
<td><label for="chapters_read">Chapters Read</label></td>
<td>
<input type="number" min="0" name="chapters_read" id="chapters_read" value="<?= $item['chapters']['read'] ?>" /> / <?= $item['chapters']['total'] ?>
</td>
</tr>
<tr>
<td><label for="volumes_read">Volumes Read</label></td>
<td>
<input type="number" min="0" name="volumes_read" id="volumes_read" value="<?= $item['volumes']['read'] ?>" /> / <?= $item['volumes']['total'] ?>
</td>
</tr>
<tr>
<td><label for="rereading_flag">Rereading?</label></td>
<td>
<input type="checkbox" name="reareading" id="rereading_flag"
<?php if($item['rereading'] === TRUE): ?>checked="checked"<?php endif ?>
/>
</td>
</tr>
<tr>
<td><label for="reread_count">Reread Count</label></td>
<td>
<input type="number" min="0" id="reread_count" name="reread_count" value="<?= $item['reread'] ?>" />
</td>
</tr>
<tr>
<td><label for="notes">Notes</label></td>
<td>
<textarea name="notes" id="notes"><?= $escape->html($item['notes']) ?></textarea>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="hidden" value="<?= $item['id'] ?>" name="id" />
<input type="hidden" value="<?= $item['manga']['slug'] ?>" name="manga_id" />
<input type="hidden" value="<?= $item['user_rating'] ?>" name="old_rating" />
<input type="hidden" value="true" name="edit" />
<button type="submit">Submit</button>
</td>
</tr>
</tbody>
</table>
</form>
</main>
<script src="<?= $urlGenerator->asset_url('js.php?g=edit') ?>"></script>
<?php endif ?>

View File

@ -7,6 +7,9 @@
<table>
<thead>
<tr>
<?php if ($auth->is_authenticated()): ?>
<th>&nbsp;</th>
<?php endif ?>
<th>Title</th>
<th>Rating</th>
<th>Chapters</th>
@ -17,6 +20,11 @@
<tbody>
<?php foreach($items as $item): ?>
<tr id="manga-<?= $item['id'] ?>">
<?php if($auth->is_authenticated()): ?>
<td>
<a class="bracketed" href="<?= $urlGenerator->url("manga/edit/{$item['id']}/{$name}") ?>">Edit</a>
</td>
<?php endif ?>
<td class="align_left">
<a href="<?= $item['manga']['url'] ?>">
<?= $item['manga']['title'] ?>

View File

@ -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
*/

View File

@ -5,6 +5,6 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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))
{

View File

@ -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
*/

View File

@ -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 &middot; 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
*

View File

@ -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}')

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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'],

View File

@ -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

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*

View File

@ -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

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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

View File

@ -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
*/

View File

@ -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
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/

View File

@ -6,7 +6,7 @@
*
* @package Ion
* @author Timothy J. Warren
* @copyright Copyright (c) 2015
* @copyright Copyright (c) 2015 - 2016
* @license MIT
*/