_template = 'pages/screenshots.tpl'; $this->_template_category = 'pages/screenshots_category.tpl'; $this->_template_viewer = 'screenshots_viewer.tpl'; } /* Display the index page. */ public function index() { $category = $_GET['cat']; $game = $_GET['game']; $json = $_POST['json']; if (!empty($json)) { return $this->getAllJSON(); } else if (!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; } } ?>