Version 5.1 - All the GraphQL #32
@ -20,7 +20,7 @@
|
||||
<log type="coverage-clover" target="logs/clover.xml"/>
|
||||
<log type="coverage-crap4j" target="logs/crap4j.xml"/>
|
||||
<log type="coverage-xml" target="logs/coverage" />
|
||||
<log type="junit" target="logs/junit.xml" logIncompleteSkipped="false"/>
|
||||
<log type="junit" target="logs/junit.xml" />
|
||||
</logging>
|
||||
<php>
|
||||
<server name="HTTP_USER_AGENT" value="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0" />
|
||||
|
@ -72,7 +72,7 @@ final class AnimeListTransformer extends AbstractTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
$streamingLinks = (array_key_exists('streamingLinks', $anime['relationships']))
|
||||
$streamingLinks = array_key_exists('streamingLinks', $anime['relationships'])
|
||||
? Kitsu::parseListItemStreamingLinks($included, $animeId)
|
||||
: [];
|
||||
|
||||
|
@ -79,11 +79,7 @@ class Controller {
|
||||
* Common data to be sent to views
|
||||
* @var array
|
||||
*/
|
||||
protected $baseData = [
|
||||
'url_type' => 'anime',
|
||||
'other_type' => 'manga',
|
||||
'menu_name' => ''
|
||||
];
|
||||
protected $baseData = [];
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
@ -95,46 +91,29 @@ class Controller {
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->setContainer($container);
|
||||
|
||||
$auraUrlGenerator = $container->get('aura-router')->getGenerator();
|
||||
$session = $container->get('session');
|
||||
$urlGenerator = $container->get('url-generator');
|
||||
|
||||
$this->cache = $container->get('cache');
|
||||
$this->config = $container->get('config');
|
||||
$this->request = $container->get('request');
|
||||
$this->response = $container->get('response');
|
||||
|
||||
$this->baseData = array_merge($this->baseData, [
|
||||
'url' => $auraUrlGenerator,
|
||||
'urlGenerator' => $urlGenerator,
|
||||
'auth' => $container->get('auth'),
|
||||
'config' => $this->config
|
||||
]);
|
||||
|
||||
$this->session = $session->getSegment(SESSION_SEGMENT);
|
||||
$this->url = $auraUrlGenerator;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
|
||||
$session = $container->get('session');
|
||||
$this->session = $session->getSegment(SESSION_SEGMENT);
|
||||
|
||||
// Set a 'previous' flash value for better redirects
|
||||
$serverParams = $this->request->getServerParams();
|
||||
if (array_key_exists('HTTP_REFERER', $serverParams) && false === stripos($serverParams['HTTP_REFERER'], 'login'))
|
||||
{
|
||||
$this->session->setFlash('previous', $serverParams['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
// Set a message box if available
|
||||
$this->baseData['message'] = $this->session->getFlash('message');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the previous page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirectToPrevious(): void
|
||||
{
|
||||
$previous = $this->session->getFlash('previous');
|
||||
$this->redirect($previous, 303);
|
||||
$this->baseData = [
|
||||
'auth' => $container->get('auth'),
|
||||
'config' => $this->config,
|
||||
'menu_name' => '',
|
||||
'message' => $this->session->getFlash('message'), // Get message box data if it exists
|
||||
'other_type' => 'manga',
|
||||
'url' => $auraUrlGenerator,
|
||||
'url_type' => 'anime',
|
||||
'urlGenerator' => $urlGenerator,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +138,7 @@ class Controller {
|
||||
|
||||
// Don't attempt to set the redirect url if
|
||||
// the page is one of the form type pages,
|
||||
// and the previous page is also a form type page_segments
|
||||
// and the previous page is also a form type
|
||||
if ($doubleFormPage || $isLoginPage)
|
||||
{
|
||||
return;
|
||||
@ -178,6 +157,8 @@ class Controller {
|
||||
/**
|
||||
* Redirect to the url previously set in the session
|
||||
*
|
||||
* If one is not set, redirect to default url
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws \Aviat\Ion\Di\Exception\ContainerException
|
||||
* @throws \Aviat\Ion\Di\Exception\NotFoundException
|
||||
@ -185,16 +166,10 @@ class Controller {
|
||||
*/
|
||||
public function sessionRedirect(): void
|
||||
{
|
||||
$target = $this->session->get('redirect_url');
|
||||
if (empty($target))
|
||||
{
|
||||
$this->notFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->redirect($target, 303);
|
||||
$this->session->set('redirect_url', NULL);
|
||||
}
|
||||
$target = $this->session->get('redirect_url') ?? '/';
|
||||
|
||||
$this->redirect($target, 303);
|
||||
$this->session->set('redirect_url', NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,7 +193,7 @@ class Controller {
|
||||
}
|
||||
|
||||
$route = $router->getRoute();
|
||||
$data['route_path'] = $route ? $router->getRoute()->path : '';
|
||||
$data['route_path'] = $route !== FALSE ? $route->path : '';
|
||||
|
||||
|
||||
$templatePath = _dir($this->config->get('view_path'), "{$template}.php");
|
||||
@ -275,7 +250,7 @@ class Controller {
|
||||
public function notFound(
|
||||
string $title = 'Sorry, page not found',
|
||||
string $message = 'Page Not Found'
|
||||
): void
|
||||
): void
|
||||
{
|
||||
$this->outputHTML('404', [
|
||||
'title' => $title,
|
||||
@ -408,7 +383,6 @@ class Controller {
|
||||
(new JsonView($this->container))
|
||||
->setStatusCode($code)
|
||||
->setOutput($data);
|
||||
// ->send();
|
||||
exit();
|
||||
}
|
||||
|
||||
@ -421,8 +395,8 @@ class Controller {
|
||||
*/
|
||||
protected function redirect(string $url, int $code): void
|
||||
{
|
||||
$http = new HttpView($this->container);
|
||||
$http->redirect($url, $code);
|
||||
(new HttpView($this->container))->redirect($url, $code);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
// End of BaseController.php
|
@ -28,6 +28,7 @@ use Aviat\Ion\Json;
|
||||
* Controller for Anime-related pages
|
||||
*/
|
||||
final class Anime extends BaseController {
|
||||
|
||||
/**
|
||||
* The anime list model
|
||||
* @var \Aviat\AnimeClient\Model\Anime $model
|
||||
@ -49,12 +50,9 @@ final class Anime extends BaseController {
|
||||
|
||||
$this->baseData = array_merge($this->baseData, [
|
||||
'menu_name' => 'anime_list',
|
||||
'url_type' => 'anime',
|
||||
'other_type' => 'manga',
|
||||
'config' => $this->config,
|
||||
'url_type' => 'anime',
|
||||
]);
|
||||
|
||||
$this->cache = $container->get('cache');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,9 +56,8 @@ final class AnimeCollection extends BaseController {
|
||||
$this->baseData = array_merge($this->baseData, [
|
||||
'collection_type' => 'anime',
|
||||
'menu_name' => 'collection',
|
||||
'url_type' => 'anime',
|
||||
'other_type' => 'manga',
|
||||
'config' => $this->config,
|
||||
'url_type' => 'anime',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,6 @@ final class Images extends BaseController {
|
||||
|
||||
$data = wait($response->getBody());
|
||||
|
||||
|
||||
|
||||
[$origWidth] = getimagesizefromstring($data);
|
||||
$gdImg = imagecreatefromstring($data);
|
||||
$resizedImg = imagescale($gdImg, $width ?? $origWidth);
|
||||
|
@ -29,8 +29,6 @@ use Aviat\Ion\{Json, StringWrapper};
|
||||
*/
|
||||
final class Manga extends Controller {
|
||||
|
||||
use StringWrapper;
|
||||
|
||||
/**
|
||||
* The manga model
|
||||
* @var MangaModel $model
|
||||
@ -51,9 +49,8 @@ final class Manga extends Controller {
|
||||
$this->model = $container->get('manga-model');
|
||||
$this->baseData = array_merge($this->baseData, [
|
||||
'menu_name' => 'manga_list',
|
||||
'config' => $this->config,
|
||||
'other_type' => 'anime',
|
||||
'url_type' => 'manga',
|
||||
'other_type' => 'anime'
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,8 @@ final class MangaCollection extends BaseController {
|
||||
$this->baseData = array_merge($this->baseData, [
|
||||
'collection_type' => 'manga',
|
||||
'menu_name' => 'manga-collection',
|
||||
'url_type' => 'manga',
|
||||
'other_type' => 'anime',
|
||||
'config' => $this->config,
|
||||
'url_type' => 'manga',
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ use Aviat\Ion\Di\ContainerInterface;
|
||||
* Controller for user settings
|
||||
*/
|
||||
final class Settings extends BaseController {
|
||||
|
||||
/**
|
||||
* @var \Aviat\AnimeClient\API\Anilist\Model
|
||||
*/
|
||||
@ -144,13 +145,9 @@ final class Settings extends BaseController {
|
||||
|
||||
$saved = $this->settingsModel->saveSettingsFile($newSettings);
|
||||
|
||||
if ($saved)
|
||||
{
|
||||
$this->setFlashMessage('Linked Anilist Account', 'success');
|
||||
} else
|
||||
{
|
||||
$this->setFlashMessage('Error Linking Anilist Account', 'error');
|
||||
}
|
||||
$saved
|
||||
? $this->setFlashMessage('Linked Anilist Account', 'success')
|
||||
: $this->setFlashMessage('Error Linking Anilist Account', 'error');
|
||||
|
||||
$this->redirect($this->url->generate('settings'), 303);
|
||||
}
|
||||
|
@ -20,14 +20,14 @@ use Aviat\AnimeClient\FormGenerator;
|
||||
use Aviat\Ion\Di\ContainerAware;
|
||||
|
||||
/**
|
||||
* MenuGenerator helper wrapper
|
||||
* FormGenerator helper wrapper
|
||||
*/
|
||||
final class Form {
|
||||
|
||||
use ContainerAware;
|
||||
|
||||
/**
|
||||
* Create the html for the selected menu
|
||||
* Create the html for the specified form
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $form
|
||||
@ -38,4 +38,3 @@ final class Form {
|
||||
return (new FormGenerator($this->container))->generate($name, $form);
|
||||
}
|
||||
}
|
||||
// End of Menu.php
|
Loading…
Reference in New Issue
Block a user