]>
git.agnieray.net Git - galette.git/blob - galette/includes/routes/plugins.routes.php
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
10 * Copyright © 2015 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 2015 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.9dev 2015-10-28
40 function() use ($authenticate, $app) {
41 $container = $this->getContainer();
42 $modules = $container->plugins
->getModules();
44 //Global route to access plugin resources (CSS, JS, images, ...)
46 '/{plugin}/res/{path:.*}',
47 function($request, $response, $args) {
48 $plugin = $args['plugin'];
49 $path = $args['path'];
50 $ext = pathinfo($args['path'])['extension'];
52 'js' => 'text/javascript',
56 'jpeg' => 'image/jpg',
59 if (strpos($path, '../') === false && isset($auth_ext[$ext])) {
60 $file = $this->plugins
->getFile(
65 $response = $response->withHeader('Content-type', $auth_ext[$ext]);
67 $body = $response->getBody();
68 $body->write(file_get_contents($file));
73 _T("Invalid extension!")
77 )->setName('plugin_res');
79 //Declare configured routes for each plugin
80 foreach ($modules as $module_id => $module) {
81 $container['Plugin ' . $module['name']] = function($c) use ($module_id) {
86 '/' . $module['route'],
87 function() use ($module, $module_id, $authenticate) {
88 //Plugin home: give information
91 function($request, $response) use ($module) {
93 'page_title' => $module['name'],
94 'name' => $module['name'],
95 'version' => $module['version'],
96 'date' => $module['date'],
97 'author' => $module['author']
99 if ($this->login
->isAdmin()) {
100 $params['module'] = $module;
110 )->setName($module['route'] . 'Info')->add($authenticate);
112 $f = $module['root'] . '/_routes.php';