mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Split Tooltip into provider/controller
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
namespace Alchemy\Phrasea;
|
||||
|
||||
use Alchemy\Geonames\GeonamesServiceProvider;
|
||||
use Alchemy\Phrasea\ControllerProvider\Prod\Tooltip;
|
||||
use Alchemy\Phrasea\ControllerProvider\Prod\Upload;
|
||||
use Alchemy\Phrasea\ControllerProvider\Prod\UsrLists;
|
||||
use Alchemy\Phrasea\ControllerProvider\Prod\WorkZone;
|
||||
@@ -314,6 +313,7 @@ class Application extends SilexApplication
|
||||
'Alchemy\Phrasea\ControllerProvider\Prod\Share' => [],
|
||||
'Alchemy\Phrasea\ControllerProvider\Prod\Story' => [],
|
||||
'Alchemy\Phrasea\ControllerProvider\Prod\Tools' => [],
|
||||
'Alchemy\Phrasea\ControllerProvider\Prod\Tooltip' => [],
|
||||
'Alchemy\Phrasea\ControllerProvider\Prod\TOU' => [],
|
||||
'Alchemy\Phrasea\ControllerProvider\Datafiles' => [],
|
||||
'Alchemy\Phrasea\ControllerProvider\Lightbox' => [],
|
||||
@@ -627,7 +627,6 @@ class Application extends SilexApplication
|
||||
|
||||
$this->mount('/prod/WorkZone', new WorkZone());
|
||||
$this->mount('/prod/lists', new UsrLists());
|
||||
$this->mount('/prod/tooltip', new Tooltip());
|
||||
$this->mount('/prod/upload/', new Upload());
|
||||
|
||||
$this->mount('/user/preferences/', new Preferences());
|
||||
@@ -680,6 +679,7 @@ class Application extends SilexApplication
|
||||
'/prod/share/' => 'Alchemy\Phrasea\ControllerProvider\Prod\Share',
|
||||
'/prod/story' => 'Alchemy\Phrasea\ControllerProvider\Prod\Story',
|
||||
'/prod/tools/' => 'Alchemy\Phrasea\ControllerProvider\Prod\Tools',
|
||||
'/prod/tooltip' => 'Alchemy\Phrasea\ControllerProvider\Prod\Tooltip',
|
||||
'/prod/TOU/' => 'Alchemy\Phrasea\ControllerProvider\Prod\TOU',
|
||||
'/prod/' => 'Alchemy\Phrasea\ControllerProvider\Prod\Root',
|
||||
'/setup' => 'Alchemy\Phrasea\ControllerProvider\Setup',
|
||||
|
124
lib/Alchemy/Phrasea/Controller/Prod/TooltipController.php
Normal file
124
lib/Alchemy/Phrasea/Controller/Prod/TooltipController.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2015 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 Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Controller\Controller;
|
||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
|
||||
class TooltipController extends Controller
|
||||
{
|
||||
public function displayBasket(Application $app, Basket $basket)
|
||||
{
|
||||
return $app['twig']->render('prod/Tooltip/Basket.html.twig', ['basket' => $basket]);
|
||||
}
|
||||
|
||||
public function displayStory(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
return $app['twig']->render('prod/Tooltip/Story.html.twig', ['Story' => $Story]);
|
||||
}
|
||||
|
||||
public function displayUserBadge(Application $app, $usr_id)
|
||||
{
|
||||
$user = $app['repo.users']->find($usr_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/User.html.twig'
|
||||
, ['user' => $user]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayPreview(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
return $app['twig']->render('prod/Tooltip/Preview.html.twig', [
|
||||
'record' => new \record_adapter($app, $sbas_id, $record_id),
|
||||
'not_wrapped' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function displayCaption(Application $app, $sbas_id, $record_id, $context)
|
||||
{
|
||||
$number = (int) $app['request']->get('number');
|
||||
$record = new \record_adapter($app, $sbas_id, $record_id, $number);
|
||||
|
||||
$search_engine = $search_engine_options = null;
|
||||
|
||||
if ($context == 'answer') {
|
||||
try {
|
||||
$search_engine_options = SearchEngineOptions::hydrate($app, $app['request']->request->get('options_serial'));
|
||||
$search_engine = $app['phraseanet.SE'];
|
||||
} catch (\Exception $e) {
|
||||
$search_engine = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/Caption.html.twig'
|
||||
, [
|
||||
'record' => $record,
|
||||
'view' => $context,
|
||||
'highlight' => $app['request']->request->get('query'),
|
||||
'searchEngine' => $search_engine,
|
||||
'searchOptions' => $search_engine_options,
|
||||
]);
|
||||
}
|
||||
|
||||
public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
$record = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
try {
|
||||
$document = $record->get_subdef('document');
|
||||
} catch (\Exception $e) {
|
||||
$document = null;
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/TechnicalDatas.html.twig'
|
||||
, ['record' => $record, 'document' => $document]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayFieldInfos(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($app, $databox, $field_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/DataboxField.html.twig'
|
||||
, ['field' => $field]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayDCESInfos(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($app, $databox, $field_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/DCESFieldInfo.html.twig'
|
||||
, ['field' => $field]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayMetaRestrictions(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($app, $databox, $field_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/DataboxFieldRestrictions.html.twig'
|
||||
, ['field' => $field]
|
||||
);
|
||||
}
|
||||
}
|
@@ -11,20 +11,32 @@
|
||||
|
||||
namespace Alchemy\Phrasea\ControllerProvider\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Alchemy\Phrasea\Controller\Prod\TooltipController;
|
||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||
use Alchemy\Phrasea\Model\Entities\Basket;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ServiceProviderInterface;
|
||||
|
||||
class Tooltip implements ControllerProviderInterface
|
||||
class Tooltip implements ControllerProviderInterface, ServiceProviderInterface
|
||||
{
|
||||
use ControllerProviderTrait;
|
||||
|
||||
public function register(Application $app)
|
||||
{
|
||||
$app['controller.prod.tooltip'] = $app->share(function (PhraseaApplication $app) {
|
||||
return (new TooltipController($app))
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
public function boot(Application $app)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$app['controller.prod.tooltip'] = $this;
|
||||
|
||||
$controllers = $this->createAuthenticatedCollection($app);
|
||||
|
||||
$controllers->post('/basket/{basket}/', 'controller.prod.tooltip:displayBasket')
|
||||
@@ -74,110 +86,4 @@ class Tooltip implements ControllerProviderInterface
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
||||
public function displayBasket(Application $app, Basket $basket)
|
||||
{
|
||||
return $app['twig']->render('prod/Tooltip/Basket.html.twig', ['basket' => $basket]);
|
||||
}
|
||||
|
||||
public function displayStory(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
return $app['twig']->render('prod/Tooltip/Story.html.twig', ['Story' => $Story]);
|
||||
}
|
||||
|
||||
public function displayUserBadge(Application $app, $usr_id)
|
||||
{
|
||||
$user = $app['repo.users']->find($usr_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/User.html.twig'
|
||||
, ['user' => $user]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayPreview(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
return $app['twig']->render('prod/Tooltip/Preview.html.twig', [
|
||||
'record' => new \record_adapter($app, $sbas_id, $record_id),
|
||||
'not_wrapped' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function displayCaption(Application $app, $sbas_id, $record_id, $context)
|
||||
{
|
||||
$number = (int) $app['request']->get('number');
|
||||
$record = new \record_adapter($app, $sbas_id, $record_id, $number);
|
||||
|
||||
$search_engine = $search_engine_options = null;
|
||||
|
||||
if ($context == 'answer') {
|
||||
try {
|
||||
$search_engine_options = SearchEngineOptions::hydrate($app, $app['request']->request->get('options_serial'));
|
||||
$search_engine = $app['phraseanet.SE'];
|
||||
} catch (\Exception $e) {
|
||||
$search_engine = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/Caption.html.twig'
|
||||
, [
|
||||
'record' => $record,
|
||||
'view' => $context,
|
||||
'highlight' => $app['request']->request->get('query'),
|
||||
'searchEngine' => $search_engine,
|
||||
'searchOptions' => $search_engine_options,
|
||||
]);
|
||||
}
|
||||
|
||||
public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)
|
||||
{
|
||||
$record = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
try {
|
||||
$document = $record->get_subdef('document');
|
||||
} catch (\Exception $e) {
|
||||
$document = null;
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/TechnicalDatas.html.twig'
|
||||
, ['record' => $record, 'document' => $document]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayFieldInfos(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($app, $databox, $field_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/DataboxField.html.twig'
|
||||
, ['field' => $field]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayDCESInfos(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($app, $databox, $field_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/DCESFieldInfo.html.twig'
|
||||
, ['field' => $field]
|
||||
);
|
||||
}
|
||||
|
||||
public function displayMetaRestrictions(Application $app, $sbas_id, $field_id)
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$field = \databox_field::get_instance($app, $databox, $field_id);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/DataboxFieldRestrictions.html.twig'
|
||||
, ['field' => $field]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user