oddluck f7590e79da Add 'TriviaTime/' from commit 'ae216897cd9c45259853c3f84eae826f344482aa'
git-subtree-dir: TriviaTime
git-subtree-mainline: 3551587ecdefc75e34b8b2a87d91a466bdf4c764
git-subtree-split: ae216897cd9c45259853c3f84eae826f344482aa
2019-02-14 13:32:21 -05:00

41 lines
1.2 KiB
PHP

<?php
class IndexController extends Controller
{
public function indexAction() {
$container = $this->container;
$storage = $container->getStorage();
$errorsQ = array();
$resultQ = array();
try {
$resultQ = $storage->getRecentAskedQuestions();
} catch(StorageSchemaException $e) {
$errorsQ[] = "Error: Database schema is not queryable";
} catch(StorageConnectionException $e) {
$errorsQ[] = "Error: Database is not available";
}
$errorsA = array();
$resultA = array();
try {
$resultA = $storage->getRecentActivities();
} catch(StorageSchemaException $e) {
$errorsA[] = "Error: Database schema is not queryable";
} catch(StorageConnectionException $e) {
$errorsA[] = "Error: Database is not available";
}
$storage->close();
$values = array();
$values['resultQuestions'] = $resultQ;
$values['errorsQuestions'] = $errorsQ;
$values['resultActivities'] = $resultA;
$values['errorsActivities'] = $errorsA;
$container->setTitle('Home');
$container->render('home.html.php', $values);
}
}