More fixes and cleanup for version 4.1 #21

Merged
timw4mail merged 18 commits from develop into master 2019-05-08 12:40:32 -04:00
3 changed files with 16 additions and 23 deletions
Showing only changes of commit 84ca0a9481 - Show all commits

View File

@ -14,13 +14,13 @@
<tr>
<td class="align-right"><label for="title">Title</label></td>
<td class="align-left">
<input type="text" name="title" value="<?= $item['title'] ?>" />
<input type="text" id="title" name="title" value="<?= $item['title'] ?>" />
</td>
</tr>
<tr>
<td class="align-right"><label for="title">Alternate Title</label></td>
<td class="align-right"><label for="alternate_title">Alternate Title</label></td>
<td class="align-left">
<input type="text" name="alternate_title" value="<?= $item['alternate_title'] ?>"/>
<input type="text" id="alternate_title" name="alternate_title" value="<?= $item['alternate_title'] ?>"/>
</td>
</tr>
<tr>
@ -28,7 +28,7 @@
<td class="align-left">
<select name="media_id" id="media_id">
<?php foreach($media_items as $id => $name): ?>
<option <?= $item['media_id'] === $id ? 'selected="selected"' : '' ?> value="<?= $id ?>"><?= $name ?></option>
<option <?= $item['media_id'] === (string)$id ? 'selected="selected"' : '' ?> value="<?= $id ?>"><?= $name ?></option>
<?php endforeach ?>
</select>
</td>

View File

@ -89,21 +89,6 @@ final class AnimeCollection extends Collection {
return $output;
}
/**
* Get item from collection for editing
*
* @param string $id
* @return array
*/
public function getCollectionEntry($id): array
{
$query = $this->db->from('anime_set')
->where('hummingbird_id', $id)
->get();
return $query->fetch(PDO::FETCH_ASSOC);
}
/**
* Get full collection from the database
*
@ -151,7 +136,16 @@ final class AnimeCollection extends Collection {
*/
public function add($data): void
{
$anime = (object)$this->animeModel->getAnimeById($data['id']);
$id = $data['id'];
// Check that the anime doesn't already exist
$existing = $this->get($id);
if ($existing === FALSE)
{
return;
}
$anime = (object)$this->animeModel->getAnimeById($id);
$this->db->set([
'hummingbird_id' => $data['id'],
'slug' => $anime->slug,
@ -216,9 +210,9 @@ final class AnimeCollection extends Collection {
* Get the details of a collection item
*
* @param int $kitsuId
* @return array
* @return array | false
*/
public function get($kitsuId): array
public function get($kitsuId)
{
$query = $this->db->from('anime_set')
->where('hummingbird_id', $kitsuId)

View File

@ -17,7 +17,6 @@
namespace Aviat\AnimeClient\Model;
use Aviat\Ion\Di\ContainerInterface;
use PDO;
use PDOException;
/**