2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
|
|
|
|
2020-06-29 05:31:21 +12:00
|
|
|
use Utopia\App;
|
2020-07-15 06:55:44 +12:00
|
|
|
use Utopia\Config\Config;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-30 23:09:28 +12:00
|
|
|
App::init(function ($utopia, $request, $response, $layout) {
|
|
|
|
/** @var Utopia\App $utopia */
|
|
|
|
/** @var Utopia\Request $request */
|
2020-08-06 18:51:49 +12:00
|
|
|
/** @var Appwrite\Utopia\Response $response */
|
2020-06-30 23:09:28 +12:00
|
|
|
/** @var Utopia\View $layout */
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2020-06-25 08:26:34 +12:00
|
|
|
/* AJAX check */
|
|
|
|
if (!empty($request->getQuery('version', ''))) {
|
|
|
|
$layout->setPath(__DIR__.'/../../views/layouts/empty.phtml');
|
|
|
|
}
|
2020-06-26 08:36:58 +12:00
|
|
|
|
2020-06-25 08:26:34 +12:00
|
|
|
$layout
|
|
|
|
->setParam('title', APP_NAME)
|
2020-06-30 23:09:28 +12:00
|
|
|
->setParam('protocol', $request->getProtocol())
|
2020-07-03 09:48:02 +12:00
|
|
|
->setParam('domain', $request->getHostname())
|
2020-06-29 08:45:36 +12:00
|
|
|
->setParam('home', App::getEnv('_APP_HOME'))
|
|
|
|
->setParam('setup', App::getEnv('_APP_SETUP'))
|
2020-06-25 08:26:34 +12:00
|
|
|
->setParam('class', 'unknown')
|
|
|
|
->setParam('icon', '/images/favicon.png')
|
|
|
|
->setParam('roles', [
|
|
|
|
['type' => 'owner', 'label' => 'Owner'],
|
|
|
|
['type' => 'developer', 'label' => 'Developer'],
|
|
|
|
['type' => 'admin', 'label' => 'Admin'],
|
|
|
|
])
|
2020-07-15 06:55:44 +12:00
|
|
|
->setParam('environments', Config::getParam('environments'))
|
|
|
|
->setParam('mode', App::getMode())
|
2020-06-25 08:26:34 +12:00
|
|
|
;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
|
|
|
$time = (60 * 60 * 24 * 45); // 45 days cache
|
|
|
|
|
|
|
|
$response
|
2019-09-07 05:10:41 +12:00
|
|
|
->addHeader('Cache-Control', 'public, max-age='.$time)
|
2020-06-20 23:20:49 +12:00
|
|
|
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time).' GMT') // 45 days cache
|
2019-05-09 18:54:39 +12:00
|
|
|
->addHeader('X-UA-Compatible', 'IE=Edge'); // Deny IE browsers from going into quirks mode
|
|
|
|
|
|
|
|
$route = $utopia->match($request);
|
|
|
|
$scope = $route->getLabel('scope', '');
|
|
|
|
$layout
|
2020-06-30 23:09:28 +12:00
|
|
|
->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN'))
|
2020-06-30 09:43:34 +12:00
|
|
|
->setParam('isDev', App::isDevelopment())
|
2019-05-09 18:54:39 +12:00
|
|
|
->setParam('class', $scope)
|
|
|
|
;
|
2020-06-30 23:09:28 +12:00
|
|
|
}, ['utopia', 'request', 'response', 'layout'], 'web');
|