mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Add mustache loader
This commit is contained in:
@@ -43,6 +43,7 @@ return call_user_func(function()
|
|||||||
$app->mount('/story', new Controller\Story());
|
$app->mount('/story', new Controller\Story());
|
||||||
$app->mount('/WorkZone', new Controller\WorkZone());
|
$app->mount('/WorkZone', new Controller\WorkZone());
|
||||||
$app->mount('/lists', new Controller\UsrLists());
|
$app->mount('/lists', new Controller\UsrLists());
|
||||||
|
$app->mount('/MustacheLoader', new Controller\MustacheLoader());
|
||||||
$app->mount('/records/edit', new Controller\Edit());
|
$app->mount('/records/edit', new Controller\Edit());
|
||||||
$app->mount('/records/movecollection', new Controller\MoveCollection());
|
$app->mount('/records/movecollection', new Controller\MoveCollection());
|
||||||
$app->mount('/bridge/', new Controller\Bridge());
|
$app->mount('/bridge/', new Controller\Bridge());
|
||||||
|
54
lib/Alchemy/Phrasea/Controller/Prod/MustacheLoader.php
Normal file
54
lib/Alchemy/Phrasea/Controller/Prod/MustacheLoader.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2012 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Controller\Prod;
|
||||||
|
|
||||||
|
use Silex\Application,
|
||||||
|
Silex\ControllerProviderInterface,
|
||||||
|
Silex\ControllerCollection;
|
||||||
|
use Symfony\Component\HttpFoundation\Request,
|
||||||
|
Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class MustacheLoader implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
$controllers = new ControllerCollection();
|
||||||
|
|
||||||
|
$controllers->get('/', function(Application $app, Request $request)
|
||||||
|
{
|
||||||
|
$template_name = $request->get('template');
|
||||||
|
|
||||||
|
if (!preg_match('/[a-zA-Z0-9-_]+/', $template_name))
|
||||||
|
{
|
||||||
|
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template_path = realpath(__DIR__ . '/../../../../../templates/web/Mustache/Prod/' . $template_name . '.Mustache.html');
|
||||||
|
|
||||||
|
if (!file_exists($template_path))
|
||||||
|
{
|
||||||
|
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new \Symfony\Component\HttpFoundation\Response(include $template_path);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user