mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
Refactor record detailed view controller
Fix typo Fix Typo
This commit is contained in:
@@ -283,7 +283,7 @@ class Query implements ControllerProviderInterface
|
|||||||
$app->abort(400, 'Provided search engine options are not valid');
|
$app->abort(400, 'Provided search engine options are not valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pos = (int) $request->request->get('pos', 1);
|
$pos = (int) $request->request->get('pos', 0);
|
||||||
$query = $request->request->get('query', '');
|
$query = $request->request->get('query', '');
|
||||||
|
|
||||||
$record = new \record_preview($app, 'RESULT', $pos, '', '', $searchEngine, $query);
|
$record = new \record_preview($app, 'RESULT', $pos, '', '', $searchEngine, $query);
|
||||||
|
@@ -31,6 +31,23 @@ class Records implements ControllerProviderInterface
|
|||||||
$app['firewall']->requireNotGuest();
|
$app['firewall']->requireNotGuest();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the record detailed view
|
||||||
|
*
|
||||||
|
* name : record_details
|
||||||
|
*
|
||||||
|
* description : Get the detailed view for a specific record
|
||||||
|
*
|
||||||
|
* method : POST|GET
|
||||||
|
*
|
||||||
|
* parameters : none
|
||||||
|
*
|
||||||
|
* return : JSON Response
|
||||||
|
*/
|
||||||
|
$controllers->match('/', $this->call('getRecord'))
|
||||||
|
->bind('record_details')
|
||||||
|
->method('GET|POST');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a record or a list of records
|
* Delete a record or a list of records
|
||||||
*
|
*
|
||||||
@@ -82,12 +99,104 @@ class Records implements ControllerProviderInterface
|
|||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get record detailed view
|
||||||
|
*
|
||||||
|
* @param Application $app
|
||||||
|
* @param Request $request
|
||||||
|
* @param integer $sbas_id
|
||||||
|
* @param integer $record_id
|
||||||
|
* @return JsonResponse
|
||||||
|
*/
|
||||||
|
public function getRecord(Application $app, Request $request)
|
||||||
|
{
|
||||||
|
if(!$request->isXmlHttpRequest()){
|
||||||
|
$app->abort(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$searchEngine = null;
|
||||||
|
$train = '';
|
||||||
|
|
||||||
|
// Use $request->get as HTTP method can be POST or GET
|
||||||
|
if ('RESULT' == $env = strtoupper($request->get('env', ''))) {
|
||||||
|
if (null === $optionsSerial = $request->get('options_serial')) {
|
||||||
|
$app->abort(400, 'Search engine options are missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false !== $options = unserialize($optionsSerial)) {
|
||||||
|
$searchEngine = new \searchEngine_adapter($app);
|
||||||
|
$searchEngine->set_options($options);
|
||||||
|
} else {
|
||||||
|
$app->abort(400, 'Provided search engine options are not valid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos = (int) $request->get('pos', 0);
|
||||||
|
$query = $request->get('query', '');
|
||||||
|
$reloadTrain = !! $request->get('roll', false);
|
||||||
|
|
||||||
|
$record = new \record_preview(
|
||||||
|
$app,
|
||||||
|
$env,
|
||||||
|
$pos < 0 ? 0 : $pos,
|
||||||
|
$request->get('cont', ''),
|
||||||
|
$reloadTrain,
|
||||||
|
$searchEngine,
|
||||||
|
$query
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($record->is_from_reg()) {
|
||||||
|
$train = $app['twig']->render('prod/preview/reg_train.html.twig',
|
||||||
|
array('record' => $record)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($record->is_from_basket() && $reloadTrain) {
|
||||||
|
$train = $app['twig']->render('prod/preview/basket_train.html.twig',
|
||||||
|
array('record' => $record)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($record->is_from_feed()) {
|
||||||
|
$train = $app['twig']->render('prod/preview/feed_train.html.twig',
|
||||||
|
array('record' => $record)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->json(array(
|
||||||
|
"desc" => $app['twig']->render('prod/preview/caption.html.twig', array(
|
||||||
|
'record' => $record,
|
||||||
|
'highlight' => $query,
|
||||||
|
'searchEngine' => $searchEngine
|
||||||
|
)),
|
||||||
|
"html_preview" => $app['twig']->render('common/preview.html.twig', array(
|
||||||
|
'record' => $record
|
||||||
|
)),
|
||||||
|
"others" => $app['twig']->render('prod/preview/appears_in.html.twig', array(
|
||||||
|
'parents' => $record->get_grouping_parents(),
|
||||||
|
'baskets' => $record->get_container_baskets($app['EM'], $app['phraseanet.user'])
|
||||||
|
)),
|
||||||
|
"current" => $train,
|
||||||
|
"history" => $app['twig']->render('prod/preview/short_history.html.twig', array(
|
||||||
|
'record' => $record
|
||||||
|
)),
|
||||||
|
"popularity" => $app['twig']->render('prod/preview/popularity.html.twig', array(
|
||||||
|
'record' => $record
|
||||||
|
)),
|
||||||
|
"tools" => $app['twig']->render('prod/preview/tools.html.twig', array(
|
||||||
|
'record' => $record
|
||||||
|
)),
|
||||||
|
"pos" => $record->get_number(),
|
||||||
|
"title" => $record->get_title($query, $searchEngine)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a record or a list of records
|
* Delete a record or a list of records
|
||||||
*
|
*
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return HtmlResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function doDeleteRecords(Application $app, Request $request)
|
public function doDeleteRecords(Application $app, Request $request)
|
||||||
{
|
{
|
||||||
|
@@ -31,68 +31,6 @@ $parm = $request->get_parms('action', 'env', 'pos', 'cont', 'roll', 'mode', 'col
|
|||||||
switch ($parm['action']) {
|
switch ($parm['action']) {
|
||||||
case 'LANGUAGE':
|
case 'LANGUAGE':
|
||||||
$output = module_client::getLanguage($app, $lng);
|
$output = module_client::getLanguage($app, $lng);
|
||||||
break;
|
|
||||||
case 'PREVIEW':
|
|
||||||
|
|
||||||
$search_engine = null;
|
|
||||||
if ($parm['env'] == 'RESULT' && ($options = unserialize($parm['options_serial'])) !== false) {
|
|
||||||
$search_engine = new searchEngine_adapter($app);
|
|
||||||
$search_engine->set_options($options);
|
|
||||||
}
|
|
||||||
|
|
||||||
$record = new record_preview($app, $parm['env'], $parm['pos'], $parm['cont'], $parm['roll'], $search_engine, $parm['query']);
|
|
||||||
|
|
||||||
$train = '';
|
|
||||||
|
|
||||||
if ($record->is_from_reg()) {
|
|
||||||
$train = $app['twig']->render('prod/preview/reg_train.html.twig', array(
|
|
||||||
'record' => $record
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($record->is_from_basket() && $parm['roll']) {
|
|
||||||
$train = $app['twig']->render('prod/preview/basket_train.html.twig', array(
|
|
||||||
'record' => $record
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($record->is_from_feed()) {
|
|
||||||
$train = $app['twig']->render('prod/preview/feed_train.html.twig', array(
|
|
||||||
'record' => $record
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = p4string::jsonencode(
|
|
||||||
array(
|
|
||||||
"desc" => $app['twig']->render('prod/preview/caption.html.twig', array(
|
|
||||||
'record' => $record
|
|
||||||
, 'highlight' => $parm['query']
|
|
||||||
, 'searchEngine' => $search_engine
|
|
||||||
)
|
|
||||||
)
|
|
||||||
, "html_preview" => $app['twig']->render('common/preview.html.twig', array('record' => $record)
|
|
||||||
)
|
|
||||||
, "others" => $app['twig']->render('prod/preview/appears_in.html.twig', array(
|
|
||||||
'parents' => $record->get_grouping_parents(),
|
|
||||||
'baskets' => $record->get_container_baskets($app['EM'], $app['phraseanet.user'])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
, "current" => $train
|
|
||||||
, "history" => $app['twig']->render('prod/preview/short_history.html.twig', array('record' => $record)
|
|
||||||
)
|
|
||||||
, "popularity" => $app['twig']->render('prod/preview/popularity.html.twig', array('record' => $record)
|
|
||||||
)
|
|
||||||
, "tools" => $app['twig']->render('prod/preview/tools.html.twig', array('record' => $record)
|
|
||||||
)
|
|
||||||
, "pos" => $record->get_number()
|
|
||||||
, "title" => $record->get_title($parm['query'], $search_engine)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'HOME':
|
case 'HOME':
|
||||||
$output = phrasea::getHome($app, 'PUBLI', 'client');
|
$output = phrasea::getHome($app, 'PUBLI', 'client');
|
||||||
|
@@ -78,16 +78,15 @@ function openPreview(env, pos, contId, reload){
|
|||||||
|
|
||||||
prevAjax = $.ajax({
|
prevAjax = $.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/client/clientFeedBack.php",
|
url: "/prod/records/",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: {
|
data: {
|
||||||
action: "PREVIEW",
|
|
||||||
env: env,
|
env: env,
|
||||||
pos: pos,
|
pos: pos,
|
||||||
cont: contId,
|
cont: contId,
|
||||||
roll: roll,
|
roll: roll,
|
||||||
options_serial:options_serial,
|
options_serial:options_serial,
|
||||||
query:query
|
query:query
|
||||||
},
|
},
|
||||||
beforeSend: function(){
|
beforeSend: function(){
|
||||||
if (prevAjaxrunning)
|
if (prevAjaxrunning)
|
||||||
|
Reference in New Issue
Block a user