Files
scummvm-web/include/Pages/ScreenshotsPage.php
Mataniko 4471b291a1 WEB: Convert all models to not be static objects
This is a first step towards moving to a dependency injection model.
2020-09-27 22:08:07 -04:00

75 lines
2.0 KiB
PHP

<?php
namespace ScummVM\Pages;
use ScummVM\Controller;
use ScummVM\Models\ScreenshotsModel;
class ScreenshotsPage extends Controller
{
private $screenshotsModel;
private $template_category;
/* Constructor. */
public function __construct()
{
parent::__construct();
$this->screenshotsModel = new ScreenshotsModel();
}
/* Display the index page. */
public function index($args)
{
$category = $args['category'];
$game = $args['game'];
$this->addJSFiles(
array(
'baguetteBox.min.js'
)
);
if (!empty($category)) {
return $this->getCategory($category, $game);
}
$screenshot = $this->screenshotsModel->getGroupedScreenshots();
$random_shot = $this->screenshotsModel->getRandomScreenshot();
$this->template = 'pages/screenshots.tpl';
return $this->renderPage(
array(
'title' => $this->getConfigVars('screenshotsTitle'),
'content_title' => $this->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshot,
'random_shot' => $random_shot,
)
);
}
/* Display the selected category. */
public function getCategory($category, $game)
{
if (empty($game)) {
$screenshots = $this->screenshotsModel->getCategoryScreenshots($category);
} else {
$screenshots = array(
'category' => $category,
'games' => array($this->screenshotsModel->getTargetScreenshots($game))
);
}
$this->template = 'pages/screenshots_category.tpl';
return $this->renderPage(
array(
'title' => $this->getConfigVars('screenshotsTitle'),
'content_title' => $this->getConfigVars('screenshotsContentTitle'),
'screenshots' => $screenshots,
'category' => $category,
'game' => $game,
)
);
}
}