3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Galette's instanciation and routes
10 * Copyright © 2012-2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2012-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
35 * @since 0.8.2dev 2014-11-10
40 use Galette\Core\Login
;
43 $time_start = microtime(true);
45 //define galette's root directory
46 if (!defined('GALETTE_ROOT')) {
47 define('GALETTE_ROOT', __DIR__
. '/../');
50 // define relative base path templating can use
51 if (!defined('GALETTE_BASE_PATH')) {
52 define('GALETTE_BASE_PATH', '../');
55 $needs_update = false;
57 require_once GALETTE_ROOT
. 'includes/galette.inc.php';
59 //Galette needs database update!
63 'templates.path' => GALETTE_ROOT
. 'templates/default/',
64 'mode' => 'NEED_UPDATE'
73 require_once GALETTE_ROOT
. 'includes/dependencies.php';
76 new \Galette\Middleware\
UpdateAndMaintenance(
78 \Galette\Middleware\UpdateAndMaintenance
::NEED_UPDATE
88 'determineRouteBeforeAppMiddleware' => true,
89 'displayErrorDetails' => (GALETTE_MODE
=== 'DEV'),
90 'addContentLengthHeader' => false,
94 'level' => \Monolog\Logger
::DEBUG
,
95 'path' => GALETTE_LOGS_PATH
. '/galette_slim.log',
97 //'routerCacheFile' => (GALETTE_MODE === 'DEV') ? false : GALETTE_CACHE_DIR . '/fastroute.cache' //disabled until properly handled
105 if (!defined('GALETTE_TIMEOUT')) {
106 //See php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
107 define('GALETTE_TIMEOUT', 0);
110 $plugins = new Galette\Core\
Plugins();
111 $plugins->autoload(GALETTE_PLUGINS_PATH
);
114 //since PREFIX_DB and NAME_DB are required to properly instanciate sessions,
115 // we have to check here if they're assigned
116 if ($installer ||
!defined('PREFIX_DB') ||
!defined('NAME_DB')) {
117 $session_name = 'install_' . str_replace('.', '_', GALETTE_VERSION
);
119 $session_name = PREFIX_DB
. '_' . NAME_DB
. '_' . str_replace('.', '_', GALETTE_VERSION
);
121 $session_name = 'galette_' . $session_name;
122 $session = new \RKA\
SessionMiddleware([
123 'name' => $session_name,
124 'lifetime' => GALETTE_TIMEOUT
129 // Set up dependencies
130 require GALETTE_ROOT
. '/includes/dependencies.php';
132 $smarty = $app->getContainer()->get('view')->getSmarty();
133 require_once GALETTE_ROOT
. 'includes/smarty.inc.php';
136 * Authentication middleware
138 $authenticate = new \Galette\Middleware\
Authenticate($container);
140 //Maintainance middleware
141 if ('MAINT' === GALETTE_MODE
&& !$container->get('login')->isSuperAdmin()) {
143 new \Galette\Middleware\
UpdateAndMaintenance(
145 \Galette\Middleware\UpdateAndMaintenance
::MAINTENANCE
151 * Trailing slash middleware
153 $app->add('\Galette\Middleware\TrailingSlash');
156 * Change language middleware
158 * Require determineRouteBeforeAppMiddleware to be on.
160 $app->add('\Galette\Middleware\Language');
162 //Telemetry update middleware
163 $app->add('\Galette\Middleware\Telemetry');
167 * This is important this one to be the last, so it'll be executed first.
169 $app->add('\Galette\Middleware\CheckAcls');
171 require_once GALETTE_ROOT
. 'includes/routes/main.routes.php';
172 require_once GALETTE_ROOT
. 'includes/routes/authentication.routes.php';
173 require_once GALETTE_ROOT
. 'includes/routes/management.routes.php';
174 require_once GALETTE_ROOT
. 'includes/routes/members.routes.php';
175 require_once GALETTE_ROOT
. 'includes/routes/groups.routes.php';
176 require_once GALETTE_ROOT
. 'includes/routes/contributions.routes.php';
177 require_once GALETTE_ROOT
. 'includes/routes/public_pages.routes.php';
178 require_once GALETTE_ROOT
. 'includes/routes/ajax.routes.php';
179 require_once GALETTE_ROOT
. 'includes/routes/plugins.routes.php';
183 if (isset($profiler)) {