mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-06-20 05:45:49 +00:00
99 lines
2.8 KiB
PHP
99 lines
2.8 KiB
PHP
<?php
|
|
namespace ScummVM\Pages;
|
|
|
|
use ScummVM\Controller;
|
|
use ScummVM\Models\ScreenshotsModel;
|
|
|
|
class ScreenshotsPage extends Controller
|
|
{
|
|
|
|
private $template_category;
|
|
|
|
/* Constructor. */
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->template = 'pages/screenshots.tpl';
|
|
$this->template_category = 'pages/screenshots_category.tpl';
|
|
}
|
|
|
|
/* Display the index page. */
|
|
public function index()
|
|
{
|
|
$category = $_GET['cat'];
|
|
$game = $_GET['game'];
|
|
$json = $_POST['json'];
|
|
|
|
if (!empty($json)) {
|
|
return $this->getAllJSON();
|
|
} elseif (!empty($category)) {
|
|
return $this->getCategory($category, $game);
|
|
}
|
|
|
|
$this->addJSFiles(array(
|
|
'baguetteBox.min.js'
|
|
));
|
|
|
|
$screenshot = ScreenshotsModel::getAllScreenshots();
|
|
$random_shot = ScreenshotsModel::getRandomScreenshot();
|
|
|
|
global $Smarty;
|
|
|
|
return $this->renderPage(
|
|
array(
|
|
'title' => $Smarty->getConfigVars('screenshotsTitle'),
|
|
'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
|
|
'screenshots' => $screenshot,
|
|
'random_shot' => $random_shot,
|
|
),
|
|
$this->template
|
|
);
|
|
}
|
|
|
|
/* Display the selected category. */
|
|
public function getCategory($category, $game)
|
|
{
|
|
$this->addJSFiles(array(
|
|
'baguetteBox.min.js'
|
|
));
|
|
|
|
if (empty($game)) {
|
|
$screenshots = ScreenshotsModel::getCategoryScreenshots($category);
|
|
} else {
|
|
$screenshots = array(
|
|
'category' => $category,
|
|
'games' => array(ScreenshotsModel::getTargetScreenshots($game))
|
|
);
|
|
}
|
|
|
|
global $Smarty;
|
|
|
|
return $this->renderPage(
|
|
array(
|
|
'title' => $Smarty->getConfigVars('screenshotsTitle'),
|
|
'content_title' => $Smarty->getConfigVars('screenshotsContentTitle'),
|
|
'screenshots' => $screenshots,
|
|
'category' => $category,
|
|
'game' => $game,
|
|
),
|
|
$this->template_category
|
|
);
|
|
}
|
|
|
|
/* Get a list with all screenshot filenames/captions as a JSON list. */
|
|
public function getAllJSON()
|
|
{
|
|
$sshots = array();
|
|
foreach (ScreenshotsModel::getAllScreenshots() as $category) {
|
|
foreach ($category['games'] as $screenshot) {
|
|
foreach ($screenshot->getFiles() as $files) {
|
|
$files['filename'] = DIR_SCREENSHOTS . "/{$files['filename']}-full.png";
|
|
$sshots[] = array_values($files);
|
|
}
|
|
}
|
|
}
|
|
print json_encode($sshots);
|
|
return true;
|
|
}
|
|
}
|