mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Cleanup controllers
This commit is contained in:
@@ -34,7 +34,7 @@ class Basket implements ControllerProviderInterface
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireAuthentication();
|
||||
|
||||
if($response instanceof Response) {
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
|
@@ -41,394 +41,385 @@ class Bridge implements ControllerProviderInterface
|
||||
});
|
||||
|
||||
$app['require_connection'] = $app->protect(function(\Bridge_Account $account) use ($app) {
|
||||
$app['current_account'] = function() use ($account) {
|
||||
return $account;
|
||||
};
|
||||
$app['current_account'] = function() use ($account) {
|
||||
return $account;
|
||||
};
|
||||
|
||||
if (!$account->get_api()->get_connector()->is_configured())
|
||||
throw new \Bridge_Exception_ApiConnectorNotConfigured("Bridge API Connector is not configured");
|
||||
if (!$account->get_api()->get_connector()->is_connected())
|
||||
throw new \Bridge_Exception_ApiConnectorNotConnected("Bridge API Connector is not connected");
|
||||
if (!$account->get_api()->get_connector()->is_configured())
|
||||
throw new \Bridge_Exception_ApiConnectorNotConfigured("Bridge API Connector is not configured");
|
||||
if (!$account->get_api()->get_connector()->is_connected())
|
||||
throw new \Bridge_Exception_ApiConnectorNotConnected("Bridge API Connector is not connected");
|
||||
|
||||
return;
|
||||
});
|
||||
return;
|
||||
});
|
||||
|
||||
$controllers->post('/manager/'
|
||||
, function(Application $app) {
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$user = $app['phraseanet.user'];
|
||||
$controllers->post('/manager/', function(Application $app) {
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$params = array(
|
||||
'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $user)
|
||||
, 'available_apis' => \Bridge_Api::get_availables($app)
|
||||
, 'route' => $route
|
||||
, 'current_account_id' => ''
|
||||
);
|
||||
$params = array(
|
||||
'user_accounts' => \Bridge_Account::get_accounts_by_user($app, $user)
|
||||
, 'available_apis' => \Bridge_Api::get_availables($app)
|
||||
, 'route' => $route
|
||||
, 'current_account_id' => ''
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Bridge/index.html.twig', $params)
|
||||
);
|
||||
});
|
||||
return $app['twig']->render('prod/actions/Bridge/index.html.twig', $params);
|
||||
});
|
||||
|
||||
$controllers->get('/login/{api_name}/', function(Application $app, $api_name) {
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$connector = \Bridge_Api::get_connector_by_name($appbox->get_registry(), $api_name);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$connector = \Bridge_Api::get_connector_by_name($appbox->get_registry(), $api_name);
|
||||
|
||||
return $app->redirect($connector->get_auth_url());
|
||||
});
|
||||
return $app->redirect($connector->get_auth_url());
|
||||
});
|
||||
|
||||
$controllers->get('/callback/{api_name}/', function(Application $app, $api_name) {
|
||||
$error_message = '';
|
||||
$error_message = '';
|
||||
try {
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$user = $app['phraseanet.user'];
|
||||
$api = \Bridge_Api::get_by_api_name($app, $api_name);
|
||||
$connector = $api->get_connector();
|
||||
|
||||
$response = $connector->connect();
|
||||
|
||||
$user_id = $connector->get_user_id();
|
||||
|
||||
try {
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$user = $app['phraseanet.user'];
|
||||
$api = \Bridge_Api::get_by_api_name($app, $api_name);
|
||||
$connector = $api->get_connector();
|
||||
|
||||
$response = $connector->connect();
|
||||
|
||||
$user_id = $connector->get_user_id();
|
||||
|
||||
try {
|
||||
$account = \Bridge_Account::load_account_from_distant_id($app, $api, $user, $user_id);
|
||||
} catch (\Bridge_Exception_AccountNotFound $e) {
|
||||
$account = \Bridge_Account::create($app, $api, $user, $user_id, $connector->get_user_name());
|
||||
}
|
||||
$settings = $account->get_settings();
|
||||
|
||||
if (isset($response['auth_token']))
|
||||
$settings->set('auth_token', $response['auth_token']);
|
||||
if (isset($response['refresh_token']))
|
||||
$settings->set('refresh_token', $response['refresh_token']);
|
||||
|
||||
$connector->set_auth_settings($settings);
|
||||
|
||||
$connector->reconnect();
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
$account = \Bridge_Account::load_account_from_distant_id($app, $api, $user, $user_id);
|
||||
} catch (\Bridge_Exception_AccountNotFound $e) {
|
||||
$account = \Bridge_Account::create($app, $api, $user, $user_id, $connector->get_user_name());
|
||||
}
|
||||
$settings = $account->get_settings();
|
||||
|
||||
$params = array('error_message' => $error_message);
|
||||
if (isset($response['auth_token']))
|
||||
$settings->set('auth_token', $response['auth_token']);
|
||||
if (isset($response['refresh_token']))
|
||||
$settings->set('refresh_token', $response['refresh_token']);
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Bridge/callback.html.twig', $params));
|
||||
});
|
||||
$connector->set_auth_settings($settings);
|
||||
|
||||
$connector->reconnect();
|
||||
} catch (\Exception $e) {
|
||||
$error_message = $e->getMessage();
|
||||
}
|
||||
|
||||
$params = array('error_message' => $error_message);
|
||||
|
||||
return $app['twig']->render('prod/actions/Bridge/callback.html.twig', $params);
|
||||
});
|
||||
|
||||
$controllers->get('/adapter/{account_id}/logout/', function(Application $app, $account_id) {
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$app['require_connection']($account);
|
||||
$account->get_api()->get_connector()->disconnect();
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$app['require_connection']($account);
|
||||
$account->get_api()->get_connector()->disconnect();
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-elements/' . $account->get_api()->get_connector()->get_default_element_type() . '/');
|
||||
})->assert('account_id', '\d+');
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-elements/' . $account->get_api()->get_connector()->get_default_element_type() . '/');
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-records/', function(Application $app, $account_id) {
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
$quantity = 10;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$elements = \Bridge_Element::get_elements_by_account($app, $account, $offset_start, $quantity);
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
$quantity = 10;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$elements = \Bridge_Element::get_elements_by_account($app, $account, $offset_start, $quantity);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$app['require_connection']($account);
|
||||
|
||||
$params = array(
|
||||
'adapter_action' => 'load-records'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
$params = array(
|
||||
'adapter_action' => 'load-records'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params));
|
||||
})
|
||||
->assert('account_id', '\d+');
|
||||
return $app['twig']->render('prod/actions/Bridge/records_list.html.twig', $params);
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-elements/{type}/'
|
||||
, function($account_id, $type) use ($app) {
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$controllers->get('/adapter/{account_id}/load-elements/{type}/', function($account_id, $type) use ($app) {
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$app['require_connection']($account);
|
||||
|
||||
$elements = $account->get_api()->list_elements($type, $offset_start, $quantity);
|
||||
$elements = $account->get_api()->list_elements($type, $offset_start, $quantity);
|
||||
|
||||
$params = array(
|
||||
'action_type' => $type
|
||||
, 'adapter_action' => 'load-elements'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
$params = array(
|
||||
'action_type' => $type
|
||||
, 'adapter_action' => 'load-elements'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params));
|
||||
})
|
||||
->assert('account_id', '\d+');
|
||||
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/adapter/{account_id}/load-containers/{type}/'
|
||||
, function(Application $app, $account_id, $type) {
|
||||
$controllers->get('/adapter/{account_id}/load-containers/{type}/', function(Application $app, $account_id, $type) {
|
||||
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$page = max((int) $app['request']->query->get('page'), 0);
|
||||
$quantity = 5;
|
||||
$offset_start = max(($page - 1) * $quantity, 0);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$elements = $account->get_api()->list_containers($type, $offset_start, $quantity);
|
||||
$app['require_connection']($account);
|
||||
$elements = $account->get_api()->list_containers($type, $offset_start, $quantity);
|
||||
|
||||
$params = array(
|
||||
'action_type' => $type
|
||||
, 'adapter_action' => 'load-containers'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
$params = array(
|
||||
'action_type' => $type
|
||||
, 'adapter_action' => 'load-containers'
|
||||
, 'account' => $account
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params));
|
||||
})
|
||||
->assert('account_id', '\d+');
|
||||
return $app['twig']->render('prod/actions/Bridge/element_list.html.twig', $params);
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/action/{account_id}/{action}/{element_type}/'
|
||||
, function(Application $app, $account_id, $action, $element_type) {
|
||||
$controllers->get('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
|
||||
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
$request = $app['request'];
|
||||
$elements = $request->query->get('elements_list', array());
|
||||
$elements = is_array($elements) ? $elements : explode(';', $elements);
|
||||
$app['require_connection']($account);
|
||||
$request = $app['request'];
|
||||
$elements = $request->query->get('elements_list', array());
|
||||
$elements = is_array($elements) ? $elements : explode(';', $elements);
|
||||
|
||||
$destination = $request->query->get('destination');
|
||||
$route_params = array();
|
||||
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
|
||||
$destination = $request->query->get('destination');
|
||||
$route_params = array();
|
||||
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
|
||||
|
||||
switch ($action) {
|
||||
case 'createcontainer':
|
||||
break;
|
||||
switch ($action) {
|
||||
case 'createcontainer':
|
||||
break;
|
||||
|
||||
case 'modify':
|
||||
if (count($elements) != 1) {
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-elements/' . $element_type . '/?page=&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement'));
|
||||
case 'modify':
|
||||
if (count($elements) != 1) {
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-elements/' . $element_type . '/?page=&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement'));
|
||||
}
|
||||
foreach ($elements as $element_id) {
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_ELEMENT) {
|
||||
$route_params = array('element' => $account->get_api()->get_element_from_id($element_id, $element_type));
|
||||
}
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_CONTAINER) {
|
||||
$route_params = array('element' => $account->get_api()->get_container_from_id($element_id, $element_type));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'moveinto':
|
||||
|
||||
$route_params = array('containers' => $account->get_api()->list_containers($destination, 0, 0));
|
||||
break;
|
||||
|
||||
case 'deleteelement':
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception(_('Vous essayez de faire une action que je ne connais pas !'));
|
||||
break;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'account' => $account
|
||||
, 'destination' => $destination
|
||||
, 'element_type' => $element_type
|
||||
, 'action' => $action
|
||||
, 'constraint_errors' => null
|
||||
, 'adapter_action' => $action
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
|
||||
$params = array_merge($params, $route_params);
|
||||
|
||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||
|
||||
return $app['twig']->render($template, $params);
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->post('/action/{account_id}/{action}/{element_type}/', function(Application $app, $account_id, $action, $element_type) {
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
|
||||
$request = $app['request'];
|
||||
$elements = $request->request->get('elements_list', array());
|
||||
$elements = is_array($elements) ? $elements : explode(';', $elements);
|
||||
|
||||
$destination = $request->request->get('destination');
|
||||
|
||||
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
|
||||
$html = '';
|
||||
switch ($action) {
|
||||
case 'modify':
|
||||
if (count($elements) != 1) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list=' . implode(';', $elements) . '&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement'));
|
||||
}
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_ELEMENT) {
|
||||
$route_params = array('element' => $account->get_api()->get_element_from_id($element_id, $element_type));
|
||||
}
|
||||
if ($class === \Bridge_Api_Interface::OBJECT_CLASS_CONTAINER) {
|
||||
$route_params = array('element' => $account->get_api()->get_container_from_id($element_id, $element_type));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'moveinto':
|
||||
|
||||
$route_params = array('containers' => $account->get_api()->list_containers($destination, 0, 0));
|
||||
break;
|
||||
|
||||
case 'deleteelement':
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception(_('Vous essayez de faire une action que je ne connais pas !'));
|
||||
break;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'account' => $account
|
||||
, 'destination' => $destination
|
||||
, 'element_type' => $element_type
|
||||
, 'action' => $action
|
||||
, 'constraint_errors' => null
|
||||
, 'adapter_action' => $action
|
||||
, 'elements' => $elements
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
);
|
||||
|
||||
$params = array_merge($params, $route_params);
|
||||
|
||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||
|
||||
return new Response($app['twig']->render($template, $params));
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->post('/action/{account_id}/{action}/{element_type}/'
|
||||
, function(Application $app, $account_id, $action, $element_type) {
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $account_id);
|
||||
|
||||
$app['require_connection']($account);
|
||||
|
||||
$request = $app['request'];
|
||||
$elements = $request->request->get('elements_list', array());
|
||||
$elements = is_array($elements) ? $elements : explode(';', $elements);
|
||||
|
||||
$destination = $request->request->get('destination');
|
||||
|
||||
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
|
||||
$html = '';
|
||||
switch ($action) {
|
||||
case 'modify':
|
||||
if (count($elements) != 1) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list=' . implode(';', $elements) . '&error=' . _('Vous ne pouvez pas editer plusieurs elements simultanement'));
|
||||
}
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$errors = $account->get_api()->get_connector()->check_update_constraints($datas);
|
||||
}
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$params = array(
|
||||
'element' => $account->get_api()->get_element_from_id($element_id, $element_type)
|
||||
, 'account' => $account
|
||||
, 'destination' => $destination
|
||||
, 'element_type' => $element_type
|
||||
, 'action' => $action
|
||||
, 'elements' => $elements
|
||||
, 'adapter_action' => $action
|
||||
, 'error_message' => _('Request contains invalid datas')
|
||||
, 'constraint_errors' => $errors
|
||||
, 'notice_message' => $app['request']->request->get('notice')
|
||||
);
|
||||
|
||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||
|
||||
return new Response($app['twig']->render($template, $params));
|
||||
}
|
||||
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$account->get_api()->update_element($element_type, $element_id, $datas);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list[]=' . $element_id . '&error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$errors = $account->get_api()->get_connector()->check_update_constraints($datas);
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
|
||||
if (count($errors) > 0) {
|
||||
$params = array(
|
||||
'element' => $account->get_api()->get_element_from_id($element_id, $element_type)
|
||||
, 'account' => $account
|
||||
, 'destination' => $destination
|
||||
, 'element_type' => $element_type
|
||||
, 'action' => $action
|
||||
, 'elements' => $elements
|
||||
, 'adapter_action' => $action
|
||||
, 'error_message' => _('Request contains invalid datas')
|
||||
, 'constraint_errors' => $errors
|
||||
, 'notice_message' => $app['request']->request->get('notice')
|
||||
);
|
||||
|
||||
break;
|
||||
case 'createcontainer':
|
||||
try {
|
||||
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.html.twig';
|
||||
|
||||
$container_type = $request->request->get('f_container_type');
|
||||
|
||||
$account->get_api()->create_container($container_type, $app['request']);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
return $app['twig']->render($template, $params);
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
|
||||
|
||||
break;
|
||||
case 'moveinto':
|
||||
try {
|
||||
$container_id = $request->request->get('container_id');
|
||||
foreach ($elements as $element_id) {
|
||||
$account->get_api()->add_element_to_container($element_type, $element_id, $destination, $container_id);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
foreach ($elements as $element_id) {
|
||||
$datas = $account->get_api()->get_connector()->get_update_datas($app['request']);
|
||||
$account->get_api()->update_element($element_type, $element_id, $datas);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?elements_list[]=' . $element_id . '&error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-containers/' . $destination . '/?page=&update=success#anchor');
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
|
||||
|
||||
break;
|
||||
break;
|
||||
case 'createcontainer':
|
||||
try {
|
||||
|
||||
case 'deleteelement':
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
$account->get_api()->delete_object($element_type, $element_id);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . $e->getMessage());
|
||||
$container_type = $request->request->get('f_container_type');
|
||||
|
||||
$account->get_api()->create_container($container_type, $app['request']);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
|
||||
|
||||
break;
|
||||
case 'moveinto':
|
||||
try {
|
||||
$container_id = $request->request->get('container_id');
|
||||
foreach ($elements as $element_id) {
|
||||
$account->get_api()->add_element_to_container($element_type, $element_id, $destination, $container_id);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . ' : ' . $e->getMessage());
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/');
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Unknown action');
|
||||
break;
|
||||
}
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-containers/' . $destination . '/?page=&update=success#anchor');
|
||||
|
||||
return new Response($html);
|
||||
})->assert('account_id', '\d+');
|
||||
break;
|
||||
|
||||
case 'deleteelement':
|
||||
try {
|
||||
foreach ($elements as $element_id) {
|
||||
$account->get_api()->delete_object($element_type, $element_id);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $app->redirect('/prod/bridge/action/' . $account_id . '/' . $action . '/' . $element_type . '/?error=' . get_class($e) . $e->getMessage());
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account_id . '/load-' . $class . 's/' . $element_type . '/');
|
||||
break;
|
||||
default:
|
||||
throw new \Exception('Unknown action');
|
||||
break;
|
||||
}
|
||||
|
||||
return new Response($html);
|
||||
})->assert('account_id', '\d+');
|
||||
|
||||
$controllers->get('/upload/', function(Application $app) {
|
||||
$request = $app['request'];
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $request->query->get('account_id'));
|
||||
$app['require_connection']($account);
|
||||
$request = $app['request'];
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $request->query->get('account_id'));
|
||||
$app['require_connection']($account);
|
||||
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
|
||||
$route->grep_records($account->get_api()->acceptable_records());
|
||||
$route->grep_records($account->get_api()->acceptable_records());
|
||||
|
||||
$params = array(
|
||||
'route' => $route
|
||||
, 'account' => $account
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
, 'constraint_errors' => null
|
||||
, 'adapter_action' => 'upload'
|
||||
);
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params
|
||||
);
|
||||
});
|
||||
|
||||
$controllers->post('/upload/', function(Application $app) {
|
||||
$errors = array();
|
||||
$request = $app['request'];
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $request->request->get('account_id'));
|
||||
$app['require_connection']($account);
|
||||
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$route->grep_records($account->get_api()->acceptable_records());
|
||||
$connector = $account->get_api()->get_connector();
|
||||
|
||||
/**
|
||||
* check constraints
|
||||
*/
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$errors = array_merge($errors, $connector->check_upload_constraints($datas, $record));
|
||||
}
|
||||
|
||||
if (count($errors) > 0) {
|
||||
|
||||
$params = array(
|
||||
'route' => $route
|
||||
, 'account' => $account
|
||||
, 'error_message' => $app['request']->query->get('error')
|
||||
, 'notice_message' => $app['request']->query->get('notice')
|
||||
, 'constraint_errors' => null
|
||||
, 'error_message' => _('Request contains invalid datas')
|
||||
, 'constraint_errors' => $errors
|
||||
, 'notice_message' => $app['request']->request->get('notice')
|
||||
, 'adapter_action' => 'upload'
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render(
|
||||
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params
|
||||
));
|
||||
});
|
||||
return $app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params);
|
||||
}
|
||||
|
||||
$controllers->post('/upload/', function(Application $app) {
|
||||
$errors = array();
|
||||
$request = $app['request'];
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$account = \Bridge_Account::load_account($app, $request->request->get('account_id'));
|
||||
$app['require_connection']($account);
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$title = isset($datas["title"]) ? $datas["title"] : '';
|
||||
$default_type = $connector->get_default_element_type();
|
||||
\Bridge_Element::create($app, $account, $record, $title, \Bridge_Element::STATUS_PENDING, $default_type, $datas);
|
||||
}
|
||||
|
||||
$route = new RecordHelper\Bridge($app, $app['request']);
|
||||
$route->grep_records($account->get_api()->acceptable_records());
|
||||
$connector = $account->get_api()->get_connector();
|
||||
|
||||
/**
|
||||
* check constraints
|
||||
*/
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$errors = array_merge($errors, $connector->check_upload_constraints($datas, $record));
|
||||
}
|
||||
|
||||
if (count($errors) > 0) {
|
||||
|
||||
$params = array(
|
||||
'route' => $route
|
||||
, 'account' => $account
|
||||
, 'error_message' => _('Request contains invalid datas')
|
||||
, 'constraint_errors' => $errors
|
||||
, 'notice_message' => $app['request']->request->get('notice')
|
||||
, 'adapter_action' => 'upload'
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.html.twig', $params));
|
||||
}
|
||||
|
||||
foreach ($route->get_elements() as $record) {
|
||||
$datas = $connector->get_upload_datas($request, $record);
|
||||
$title = isset($datas["title"]) ? $datas["title"] : '';
|
||||
$default_type = $connector->get_default_element_type();
|
||||
\Bridge_Element::create($app, $account, $record, $title, \Bridge_Element::STATUS_PENDING, $default_type, $datas);
|
||||
}
|
||||
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . sprintf(_('%d elements en attente'), count($route->get_elements())));
|
||||
});
|
||||
return $app->redirect('/prod/bridge/adapter/' . $account->get_id() . '/load-records/?notice=' . sprintf(_('%d elements en attente'), count($route->get_elements())));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -43,377 +43,374 @@ class Edit implements ControllerProviderInterface
|
||||
|
||||
$controllers->post('/', function(Application $app, Request $request) {
|
||||
|
||||
$records = RecordsRequest::fromRequest($app, $request, true, array('canmodifrecord'));
|
||||
$records = RecordsRequest::fromRequest($app, $request, true, array('canmodifrecord'));
|
||||
|
||||
$thesaurus = $multipleDataboxes = false;
|
||||
$status = $ids = $elements = $suggValues =
|
||||
$fields = $JSFields = array();
|
||||
$thesaurus = $multipleDataboxes = false;
|
||||
$status = $ids = $elements = $suggValues =
|
||||
$fields = $JSFields = array();
|
||||
|
||||
$databox = null;
|
||||
$databox = null;
|
||||
|
||||
$multipleDataboxes = count($records->databoxes()) > 1;
|
||||
|
||||
if (!$multipleDataboxes) {
|
||||
$databoxes = $records->databoxes();
|
||||
$databox = array_pop($databoxes);
|
||||
|
||||
/**
|
||||
* generate javascript fields
|
||||
*/
|
||||
foreach ($databox->get_meta_structure() as $meta) {
|
||||
$fields[] = $meta;
|
||||
|
||||
$separator = $meta->get_separator();
|
||||
|
||||
$JSFields[$meta->get_id()] = array(
|
||||
'meta_struct_id' => $meta->get_id()
|
||||
, 'name' => $meta->get_name()
|
||||
, '_status' => 0
|
||||
, '_value' => ''
|
||||
, '_sgval' => array()
|
||||
, 'required' => $meta->is_required()
|
||||
, 'readonly' => $meta->is_readonly()
|
||||
, 'type' => $meta->get_type()
|
||||
, 'format' => ''
|
||||
, 'explain' => ''
|
||||
, 'tbranch' => $meta->get_tbranch()
|
||||
, 'maxLength' => $meta->get_tag()->getMaxLength()
|
||||
, 'minLength' => $meta->get_tag()->getMinLength()
|
||||
, 'multi' => $meta->is_multi()
|
||||
, 'separator' => $separator
|
||||
, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null
|
||||
, 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false
|
||||
);
|
||||
|
||||
if (trim($meta->get_tbranch()) !== '') {
|
||||
$thesaurus = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* generate javascript sugg values
|
||||
*/
|
||||
foreach ($records->collections() as $collection) {
|
||||
/* @var $record record_adapter */
|
||||
|
||||
$suggValues['b' . $collection->get_base_id()] = array();
|
||||
|
||||
if ($sxe = simplexml_load_string($collection->get_prefs())) {
|
||||
$z = $sxe->xpath('/baseprefs/sugestedValues');
|
||||
|
||||
if (!$z || !is_array($z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($z[0] as $ki => $vi) { // les champs
|
||||
$field = $databox->get_meta_structure()->get_element_by_name($ki);
|
||||
if (!$field || !$vi) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$suggValues['b' . $collection->get_base_id()][$field->get_id()] = array();
|
||||
|
||||
foreach ($vi->value as $oneValue) {
|
||||
$suggValues['b' . $collection->get_base_id()][$field->get_id()][] = (string) $oneValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($collection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* generate javascript status
|
||||
*/
|
||||
if ($app['phraseanet.user']->ACL()->has_right('changestatus')) {
|
||||
$dbstatus = \databox_status::getDisplayStatus($app);
|
||||
if (isset($dbstatus[$databox->get_sbas_id()])) {
|
||||
foreach ($dbstatus[$databox->get_sbas_id()] as $n => $statbit) {
|
||||
$status[$n] = array();
|
||||
$status[$n]['label0'] = $statbit['labeloff'];
|
||||
$status[$n]['label1'] = $statbit['labelon'];
|
||||
$status[$n]['img_off'] = $statbit['img_off'];
|
||||
$status[$n]['img_on'] = $statbit['img_on'];
|
||||
$status[$n]['_value'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generate javascript elements
|
||||
*/
|
||||
foreach ($databox->get_meta_structure() as $field) {
|
||||
$databox_fields[$field->get_id()] = array(
|
||||
'dirty' => false,
|
||||
'meta_struct_id' => $field->get_id(),
|
||||
'values' => array()
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($records as $record) {
|
||||
$indice = $record->get_number();
|
||||
$elements[$indice] = array(
|
||||
'bid' => $record->get_base_id(),
|
||||
'rid' => $record->get_record_id(),
|
||||
'sselcont_id' => null,
|
||||
'_selected' => false,
|
||||
'fields' => $databox_fields
|
||||
);
|
||||
|
||||
$elements[$indice]['statbits'] = array();
|
||||
if ($app['phraseanet.user']->ACL()->has_right_on_base($record->get_base_id(), 'chgstatus')) {
|
||||
foreach ($status as $n => $s) {
|
||||
$tmp_val = substr(strrev($record->get_status()), $n, 1);
|
||||
$elements[$indice]['statbits'][$n]['value'] = ($tmp_val == '1') ? '1' : '0';
|
||||
$elements[$indice]['statbits'][$n]['dirty'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$elements[$indice]['originalname'] = $record->get_original_name();
|
||||
|
||||
foreach ($record->get_caption()->get_fields(null, true) as $field) {
|
||||
$meta_struct_id = $field->get_meta_struct_id();
|
||||
if (!isset($JSFields[$meta_struct_id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
foreach ($field->get_values() as $value) {
|
||||
$type = $id = null;
|
||||
|
||||
if ($value->getVocabularyType()) {
|
||||
$type = $value->getVocabularyType()->getType();
|
||||
$id = $value->getVocabularyId();
|
||||
}
|
||||
|
||||
$values[$value->getId()] = array(
|
||||
'meta_id' => $value->getId(),
|
||||
'value' => $value->getValue(),
|
||||
'vocabularyId' => $id,
|
||||
'vocabularyType' => $type
|
||||
);
|
||||
}
|
||||
|
||||
$elements[$indice]['fields'][$meta_struct_id] = array(
|
||||
'dirty' => false,
|
||||
'meta_struct_id' => $meta_struct_id,
|
||||
'values' => $values
|
||||
);
|
||||
}
|
||||
|
||||
$elements[$indice]['subdefs'] = array();
|
||||
|
||||
$thumbnail = $record->get_thumbnail();
|
||||
|
||||
$elements[$indice]['subdefs']['thumbnail'] = array(
|
||||
'url' => $thumbnail->get_url()
|
||||
, 'w' => $thumbnail->get_width()
|
||||
, 'h' => $thumbnail->get_height()
|
||||
);
|
||||
|
||||
$elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', array('record' => $record));
|
||||
|
||||
$elements[$indice]['type'] = $record->get_type();
|
||||
}
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'multipleDataboxes' => $multipleDataboxes,
|
||||
'recordsRequest' => $records,
|
||||
'databox' => $databox,
|
||||
'JSonStatus' => json_encode($status),
|
||||
'JSonRecords' => json_encode($elements),
|
||||
'JSonFields' => json_encode($JSFields),
|
||||
'JSonIds' => json_encode(array_keys($elements)),
|
||||
'status' => $status,
|
||||
'fields' => $fields,
|
||||
'JSonSuggValues' => json_encode($suggValues),
|
||||
'thesaurus' => $thesaurus,
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/edit_default.html.twig', $params);
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->get('/vocabulary/{vocabulary}/', function(Application $app, Request $request, $vocabulary) {
|
||||
$datas = array('success' => false, 'message' => '', 'results' => array());
|
||||
|
||||
$sbas_id = (int) $request->query->get('sbas_id');
|
||||
|
||||
try {
|
||||
if ($sbas_id === 0) {
|
||||
throw new \Exception('Invalid sbas_id');
|
||||
}
|
||||
|
||||
$VC = VocabularyController::get($app, $vocabulary);
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
} catch (\Exception $e) {
|
||||
$datas['message'] = _('Vocabulary not found');
|
||||
|
||||
return $app->json($datas);
|
||||
}
|
||||
|
||||
$query = $request->query->get('query');
|
||||
|
||||
$results = $VC->find($query, $app['phraseanet.user'], $databox);
|
||||
|
||||
$list = array();
|
||||
|
||||
foreach ($results as $Term) {
|
||||
/* @var $Term \Alchemy\Phrasea\Vocabulary\Term */
|
||||
$list[] = array(
|
||||
'id' => $Term->getId(),
|
||||
'context' => $Term->getContext(),
|
||||
'value' => $Term->getValue(),
|
||||
);
|
||||
}
|
||||
|
||||
$datas['success'] = true;
|
||||
$datas['results'] = $list;
|
||||
|
||||
return $app->json($datas);
|
||||
}
|
||||
);
|
||||
|
||||
$controllers->post('/apply/', function(Application $app, Request $request) {
|
||||
|
||||
$records = RecordsRequest::fromRequest($app, $request, true, array('canmodifrecord'));
|
||||
|
||||
if (count($records->databoxes()) !== 1) {
|
||||
throw new \Exception('Unable to edit on multiple databoxes');
|
||||
}
|
||||
|
||||
if ($request->request->get('act_option') == 'SAVEGRP'
|
||||
&& $request->request->get('newrepresent')
|
||||
&& $records->isSingleStory()) {
|
||||
try {
|
||||
$reg_record = $records->singleStory();
|
||||
|
||||
$newsubdef_reg = new \record_adapter($app, $reg_record->get_sbas_id(), $request->request->get('newrepresent'));
|
||||
|
||||
if ($newsubdef_reg->get_type() !== 'image') {
|
||||
throw new \Exception('A reg image must come from image data');
|
||||
}
|
||||
|
||||
foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
|
||||
if (!in_array($name, array('thumbnail', 'preview'))) {
|
||||
continue;
|
||||
}
|
||||
$media = $app['mediavorus']->guess($value->get_pathfile());
|
||||
$reg_record->substitute_subdef($name, $media, $app);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($request->get('mds'))) {
|
||||
return;
|
||||
}
|
||||
$multipleDataboxes = count($records->databoxes()) > 1;
|
||||
|
||||
if (!$multipleDataboxes) {
|
||||
$databoxes = $records->databoxes();
|
||||
$databox = array_pop($databoxes);
|
||||
|
||||
$meta_struct = $databox->get_meta_structure();
|
||||
$write_edit_el = false;
|
||||
$date_obj = new \DateTime();
|
||||
foreach ($meta_struct->get_elements() as $meta_struct_el) {
|
||||
if ($meta_struct_el->get_tag() instanceof TfEditdate) {
|
||||
$write_edit_el = $meta_struct_el;
|
||||
/**
|
||||
* generate javascript fields
|
||||
*/
|
||||
foreach ($databox->get_meta_structure() as $meta) {
|
||||
$fields[] = $meta;
|
||||
|
||||
$separator = $meta->get_separator();
|
||||
|
||||
$JSFields[$meta->get_id()] = array(
|
||||
'meta_struct_id' => $meta->get_id()
|
||||
, 'name' => $meta->get_name()
|
||||
, '_status' => 0
|
||||
, '_value' => ''
|
||||
, '_sgval' => array()
|
||||
, 'required' => $meta->is_required()
|
||||
, 'readonly' => $meta->is_readonly()
|
||||
, 'type' => $meta->get_type()
|
||||
, 'format' => ''
|
||||
, 'explain' => ''
|
||||
, 'tbranch' => $meta->get_tbranch()
|
||||
, 'maxLength' => $meta->get_tag()->getMaxLength()
|
||||
, 'minLength' => $meta->get_tag()->getMinLength()
|
||||
, 'multi' => $meta->is_multi()
|
||||
, 'separator' => $separator
|
||||
, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null
|
||||
, 'vocabularyRestricted' => $meta->getVocabularyControl() ? $meta->isVocabularyRestricted() : false
|
||||
);
|
||||
|
||||
if (trim($meta->get_tbranch()) !== '') {
|
||||
$thesaurus = true;
|
||||
}
|
||||
}
|
||||
|
||||
$elements = $records->toArray();
|
||||
|
||||
foreach ($request->get('mds') as $rec) {
|
||||
try {
|
||||
$record = $databox->get_record($rec['record_id']);
|
||||
} catch (\Exception $e) {
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* generate javascript sugg values
|
||||
*/
|
||||
foreach ($records->collections() as $collection) {
|
||||
/* @var $record record_adapter */
|
||||
|
||||
$key = $record->get_serialize_key();
|
||||
$suggValues['b' . $collection->get_base_id()] = array();
|
||||
|
||||
if (!array_key_exists($key, $elements)) {
|
||||
continue;
|
||||
}
|
||||
if ($sxe = simplexml_load_string($collection->get_prefs())) {
|
||||
$z = $sxe->xpath('/baseprefs/sugestedValues');
|
||||
|
||||
$statbits = $rec['status'];
|
||||
$editDirty = $rec['edit'];
|
||||
|
||||
if ($editDirty == '0') {
|
||||
$editDirty = false;
|
||||
} else {
|
||||
$editDirty = true;
|
||||
}
|
||||
|
||||
if (is_array($rec['metadatas'])) {
|
||||
$record->set_metadatas($rec['metadatas']);
|
||||
}
|
||||
|
||||
/**
|
||||
* todo : this should not work
|
||||
*/
|
||||
if ($write_edit_el instanceof \databox_field) {
|
||||
$fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()), true);
|
||||
$field = array_pop($fields);
|
||||
|
||||
$meta_id = null;
|
||||
|
||||
if ($field && !$field->is_multi()) {
|
||||
$values = $field->get_values();
|
||||
$meta_id = array_pop($values)->getId();
|
||||
if (!$z || !is_array($z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$metas = array(
|
||||
array(
|
||||
'meta_struct_id' => $write_edit_el->get_id(),
|
||||
'meta_id' => $meta_id,
|
||||
'value' => $date_obj->format('Y-m-d h:i:s'),
|
||||
)
|
||||
foreach ($z[0] as $ki => $vi) { // les champs
|
||||
$field = $databox->get_meta_structure()->get_element_by_name($ki);
|
||||
if (!$field || !$vi) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$suggValues['b' . $collection->get_base_id()][$field->get_id()] = array();
|
||||
|
||||
foreach ($vi->value as $oneValue) {
|
||||
$suggValues['b' . $collection->get_base_id()][$field->get_id()][] = (string) $oneValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($collection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* generate javascript status
|
||||
*/
|
||||
if ($app['phraseanet.user']->ACL()->has_right('changestatus')) {
|
||||
$dbstatus = \databox_status::getDisplayStatus($app);
|
||||
if (isset($dbstatus[$databox->get_sbas_id()])) {
|
||||
foreach ($dbstatus[$databox->get_sbas_id()] as $n => $statbit) {
|
||||
$status[$n] = array();
|
||||
$status[$n]['label0'] = $statbit['labeloff'];
|
||||
$status[$n]['label1'] = $statbit['labelon'];
|
||||
$status[$n]['img_off'] = $statbit['img_off'];
|
||||
$status[$n]['img_on'] = $statbit['img_on'];
|
||||
$status[$n]['_value'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* generate javascript elements
|
||||
*/
|
||||
foreach ($databox->get_meta_structure() as $field) {
|
||||
$databox_fields[$field->get_id()] = array(
|
||||
'dirty' => false,
|
||||
'meta_struct_id' => $field->get_id(),
|
||||
'values' => array()
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($records as $record) {
|
||||
$indice = $record->get_number();
|
||||
$elements[$indice] = array(
|
||||
'bid' => $record->get_base_id(),
|
||||
'rid' => $record->get_record_id(),
|
||||
'sselcont_id' => null,
|
||||
'_selected' => false,
|
||||
'fields' => $databox_fields
|
||||
);
|
||||
|
||||
$elements[$indice]['statbits'] = array();
|
||||
if ($app['phraseanet.user']->ACL()->has_right_on_base($record->get_base_id(), 'chgstatus')) {
|
||||
foreach ($status as $n => $s) {
|
||||
$tmp_val = substr(strrev($record->get_status()), $n, 1);
|
||||
$elements[$indice]['statbits'][$n]['value'] = ($tmp_val == '1') ? '1' : '0';
|
||||
$elements[$indice]['statbits'][$n]['dirty'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$elements[$indice]['originalname'] = $record->get_original_name();
|
||||
|
||||
foreach ($record->get_caption()->get_fields(null, true) as $field) {
|
||||
$meta_struct_id = $field->get_meta_struct_id();
|
||||
if (!isset($JSFields[$meta_struct_id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values = array();
|
||||
foreach ($field->get_values() as $value) {
|
||||
$type = $id = null;
|
||||
|
||||
if ($value->getVocabularyType()) {
|
||||
$type = $value->getVocabularyType()->getType();
|
||||
$id = $value->getVocabularyId();
|
||||
}
|
||||
|
||||
$values[$value->getId()] = array(
|
||||
'meta_id' => $value->getId(),
|
||||
'value' => $value->getValue(),
|
||||
'vocabularyId' => $id,
|
||||
'vocabularyType' => $type
|
||||
);
|
||||
}
|
||||
|
||||
$elements[$indice]['fields'][$meta_struct_id] = array(
|
||||
'dirty' => false,
|
||||
'meta_struct_id' => $meta_struct_id,
|
||||
'values' => $values
|
||||
);
|
||||
|
||||
$record->set_metadatas($metas, true);
|
||||
}
|
||||
|
||||
$newstat = $record->get_status();
|
||||
$statbits = ltrim($statbits, 'x');
|
||||
if (!in_array($statbits, array('', 'null'))) {
|
||||
$mask_and = ltrim(str_replace(array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0');
|
||||
if ($mask_and != '') {
|
||||
$newstat = \databox_status::operation_and_not($app, $newstat, $mask_and);
|
||||
}
|
||||
$elements[$indice]['subdefs'] = array();
|
||||
|
||||
$mask_or = ltrim(str_replace('x', '0', $statbits), '0');
|
||||
$thumbnail = $record->get_thumbnail();
|
||||
|
||||
if ($mask_or != '') {
|
||||
$newstat = \databox_status::operation_or($app, $newstat, $mask_or);
|
||||
}
|
||||
$elements[$indice]['subdefs']['thumbnail'] = array(
|
||||
'url' => $thumbnail->get_url()
|
||||
, 'w' => $thumbnail->get_width()
|
||||
, 'h' => $thumbnail->get_height()
|
||||
);
|
||||
|
||||
$record->set_binary_status($newstat);
|
||||
}
|
||||
$elements[$indice]['preview'] = $app['twig']->render('common/preview.html.twig', array('record' => $record));
|
||||
|
||||
$record
|
||||
->get_collection()
|
||||
->reset_stamp($record->get_record_id())
|
||||
->write_metas();
|
||||
$elements[$indice]['type'] = $record->get_type();
|
||||
}
|
||||
}
|
||||
|
||||
if ($statbits != '') {
|
||||
$app['phraseanet.logger']($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_STATUS, '', '');
|
||||
}
|
||||
if ($editDirty) {
|
||||
$app['phraseanet.logger']($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_EDIT, '', '');
|
||||
}
|
||||
$params = array(
|
||||
'multipleDataboxes' => $multipleDataboxes,
|
||||
'recordsRequest' => $records,
|
||||
'databox' => $databox,
|
||||
'JSonStatus' => json_encode($status),
|
||||
'JSonRecords' => json_encode($elements),
|
||||
'JSonFields' => json_encode($JSFields),
|
||||
'JSonIds' => json_encode(array_keys($elements)),
|
||||
'status' => $status,
|
||||
'fields' => $fields,
|
||||
'JSonSuggValues' => json_encode($suggValues),
|
||||
'thesaurus' => $thesaurus,
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/edit_default.html.twig', $params);
|
||||
});
|
||||
|
||||
$controllers->get('/vocabulary/{vocabulary}/', function(Application $app, Request $request, $vocabulary) {
|
||||
$datas = array('success' => false, 'message' => '', 'results' => array());
|
||||
|
||||
$sbas_id = (int) $request->query->get('sbas_id');
|
||||
|
||||
try {
|
||||
if ($sbas_id === 0) {
|
||||
throw new \Exception('Invalid sbas_id');
|
||||
}
|
||||
|
||||
$VC = VocabularyController::get($app, $vocabulary);
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
} catch (\Exception $e) {
|
||||
$datas['message'] = _('Vocabulary not found');
|
||||
|
||||
|
||||
return $app['twig']->render('prod/actions/edit_default.html.twig', array('edit' => $editing, 'message' => ''));
|
||||
return $app->json($datas);
|
||||
}
|
||||
);
|
||||
|
||||
$query = $request->query->get('query');
|
||||
|
||||
$results = $VC->find($query, $app['phraseanet.user'], $databox);
|
||||
|
||||
$list = array();
|
||||
|
||||
foreach ($results as $Term) {
|
||||
/* @var $Term \Alchemy\Phrasea\Vocabulary\Term */
|
||||
$list[] = array(
|
||||
'id' => $Term->getId(),
|
||||
'context' => $Term->getContext(),
|
||||
'value' => $Term->getValue(),
|
||||
);
|
||||
}
|
||||
|
||||
$datas['success'] = true;
|
||||
$datas['results'] = $list;
|
||||
|
||||
return $app->json($datas);
|
||||
});
|
||||
|
||||
$controllers->post('/apply/', function(Application $app, Request $request) {
|
||||
|
||||
$records = RecordsRequest::fromRequest($app, $request, true, array('canmodifrecord'));
|
||||
|
||||
if (count($records->databoxes()) !== 1) {
|
||||
throw new \Exception('Unable to edit on multiple databoxes');
|
||||
}
|
||||
|
||||
if ($request->request->get('act_option') == 'SAVEGRP'
|
||||
&& $request->request->get('newrepresent')
|
||||
&& $records->isSingleStory()) {
|
||||
try {
|
||||
$reg_record = $records->singleStory();
|
||||
|
||||
$newsubdef_reg = new \record_adapter($app, $reg_record->get_sbas_id(), $request->request->get('newrepresent'));
|
||||
|
||||
if ($newsubdef_reg->get_type() !== 'image') {
|
||||
throw new \Exception('A reg image must come from image data');
|
||||
}
|
||||
|
||||
foreach ($newsubdef_reg->get_subdefs() as $name => $value) {
|
||||
if (!in_array($name, array('thumbnail', 'preview'))) {
|
||||
continue;
|
||||
}
|
||||
$media = $app['mediavorus']->guess($value->get_pathfile());
|
||||
$reg_record->substitute_subdef($name, $media, $app);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_array($request->get('mds'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$databoxes = $records->databoxes();
|
||||
$databox = array_pop($databoxes);
|
||||
|
||||
$meta_struct = $databox->get_meta_structure();
|
||||
$write_edit_el = false;
|
||||
$date_obj = new \DateTime();
|
||||
foreach ($meta_struct->get_elements() as $meta_struct_el) {
|
||||
if ($meta_struct_el->get_tag() instanceof TfEditdate) {
|
||||
$write_edit_el = $meta_struct_el;
|
||||
}
|
||||
}
|
||||
|
||||
$elements = $records->toArray();
|
||||
|
||||
foreach ($request->get('mds') as $rec) {
|
||||
try {
|
||||
$record = $databox->get_record($rec['record_id']);
|
||||
} catch (\Exception $e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = $record->get_serialize_key();
|
||||
|
||||
if (!array_key_exists($key, $elements)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$statbits = $rec['status'];
|
||||
$editDirty = $rec['edit'];
|
||||
|
||||
if ($editDirty == '0') {
|
||||
$editDirty = false;
|
||||
} else {
|
||||
$editDirty = true;
|
||||
}
|
||||
|
||||
if (is_array($rec['metadatas'])) {
|
||||
$record->set_metadatas($rec['metadatas']);
|
||||
}
|
||||
|
||||
/**
|
||||
* todo : this should not work
|
||||
*/
|
||||
if ($write_edit_el instanceof \databox_field) {
|
||||
$fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()), true);
|
||||
$field = array_pop($fields);
|
||||
|
||||
$meta_id = null;
|
||||
|
||||
if ($field && !$field->is_multi()) {
|
||||
$values = $field->get_values();
|
||||
$meta_id = array_pop($values)->getId();
|
||||
}
|
||||
|
||||
$metas = array(
|
||||
array(
|
||||
'meta_struct_id' => $write_edit_el->get_id(),
|
||||
'meta_id' => $meta_id,
|
||||
'value' => $date_obj->format('Y-m-d h:i:s'),
|
||||
)
|
||||
);
|
||||
|
||||
$record->set_metadatas($metas, true);
|
||||
}
|
||||
|
||||
$newstat = $record->get_status();
|
||||
$statbits = ltrim($statbits, 'x');
|
||||
if (!in_array($statbits, array('', 'null'))) {
|
||||
$mask_and = ltrim(str_replace(array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0');
|
||||
if ($mask_and != '') {
|
||||
$newstat = \databox_status::operation_and_not($app, $newstat, $mask_and);
|
||||
}
|
||||
|
||||
$mask_or = ltrim(str_replace('x', '0', $statbits), '0');
|
||||
|
||||
if ($mask_or != '') {
|
||||
$newstat = \databox_status::operation_or($app, $newstat, $mask_or);
|
||||
}
|
||||
|
||||
$record->set_binary_status($newstat);
|
||||
}
|
||||
|
||||
$record
|
||||
->get_collection()
|
||||
->reset_stamp($record->get_record_id())
|
||||
->write_metas();
|
||||
|
||||
if ($statbits != '') {
|
||||
$app['phraseanet.logger']($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_STATUS, '', '');
|
||||
}
|
||||
if ($editDirty) {
|
||||
$app['phraseanet.logger']($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_EDIT, '', '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $app['twig']->render('prod/actions/edit_default.html.twig', array('edit' => $editing, 'message' => ''));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -33,44 +33,64 @@ class Feed implements ControllerProviderInterface
|
||||
* I got a selection of docs, which publications are available forthese docs ?
|
||||
*/
|
||||
$controllers->post('/requestavailable/', function(Application $app, Request $request) {
|
||||
$user = $app['phraseanet.user'];
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
||||
$user = $app['phraseanet.user'];
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
||||
|
||||
return new Response($app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds)));
|
||||
});
|
||||
return $app['twig']->render('prod/actions/publish/publish.html.twig', array('publishing' => $publishing, 'feeds' => $feeds));
|
||||
});
|
||||
|
||||
/**
|
||||
* I've selected a publication for my ocs, let's publish them
|
||||
* I've selected a publication for my docs, let's publish them
|
||||
*/
|
||||
$controllers->post('/entry/create/', function(Application $app, Request $request) {
|
||||
try {
|
||||
$user = $app['phraseanet.user'];
|
||||
$feed = new \Feed_Adapter($app, $request->request->get('feed_id'));
|
||||
$publisher = \Feed_Publisher_Adapter::getPublisher($app['phraseanet.appbox'], $feed, $user);
|
||||
try {
|
||||
$user = $app['phraseanet.user'];
|
||||
$feed = new \Feed_Adapter($app, $request->request->get('feed_id'));
|
||||
$publisher = \Feed_Publisher_Adapter::getPublisher($app['phraseanet.appbox'], $feed, $user);
|
||||
|
||||
$title = $request->request->get('title');
|
||||
$subtitle = $request->request->get('subtitle');
|
||||
$author_name = $request->request->get('author_name');
|
||||
$author_mail = $request->request->get('author_mail');
|
||||
$title = $request->request->get('title');
|
||||
$subtitle = $request->request->get('subtitle');
|
||||
$author_name = $request->request->get('author_name');
|
||||
$author_mail = $request->request->get('author_mail');
|
||||
|
||||
$entry = \Feed_Entry_Adapter::create($app, $feed, $publisher, $title, $subtitle, $author_name, $author_mail);
|
||||
$entry = \Feed_Entry_Adapter::create($app, $feed, $publisher, $title, $subtitle, $author_name, $author_mail);
|
||||
|
||||
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
||||
$publishing = RecordsRequest::fromRequest($app, $request, true, array(), array('bas_chupub'));
|
||||
|
||||
foreach ($publishing as $record) {
|
||||
$item = \Feed_Entry_Item::create($app['phraseanet.appbox'], $entry, $record);
|
||||
}
|
||||
$datas = array('error' => false, 'message' => false);
|
||||
} catch (\Exception $e) {
|
||||
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage());
|
||||
foreach ($publishing as $record) {
|
||||
$item = \Feed_Entry_Item::create($app['phraseanet.appbox'], $entry, $record);
|
||||
}
|
||||
$datas = array('error' => false, 'message' => false);
|
||||
} catch (\Exception $e) {
|
||||
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage());
|
||||
}
|
||||
|
||||
return $app->json($datas);
|
||||
});
|
||||
return $app->json($datas);
|
||||
});
|
||||
|
||||
$controllers->get('/entry/{id}/edit/', function(Application $app, Request $request, $id) {
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()) {
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
|
||||
$datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', array('entry' => $entry, 'feeds' => $feeds));
|
||||
|
||||
return new Response($datas);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/entry/{id}/update/', function(Application $app, Request $request, $id) {
|
||||
$datas = array('error' => true, 'message' => '', 'datas' => '');
|
||||
try {
|
||||
$app['phraseanet.appbox']->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
@@ -79,182 +99,162 @@ class Feed implements ControllerProviderInterface
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
}
|
||||
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$title = $request->request->get('title');
|
||||
$subtitle = $request->request->get('subtitle');
|
||||
$author_name = $request->request->get('author_name');
|
||||
$author_mail = $request->request->get('author_mail');
|
||||
|
||||
$datas = $app['twig']->render('prod/actions/publish/publish_edit.html.twig', array('entry' => $entry, 'feeds' => $feeds));
|
||||
$entry->set_author_email($author_mail)
|
||||
->set_author_name($author_name)
|
||||
->set_title($title)
|
||||
->set_subtitle($subtitle);
|
||||
|
||||
return new Response($datas);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/entry/{id}/update/', function(Application $app, Request $request, $id) {
|
||||
$datas = array('error' => true, 'message' => '', 'datas' => '');
|
||||
try {
|
||||
$app['phraseanet.appbox']->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()) {
|
||||
throw new \Exception_UnauthorizedAction();
|
||||
$current_feed_id = $entry->get_feed()->get_id();
|
||||
$new_feed_id = $request->request->get('feed_id', $current_feed_id);
|
||||
if ($current_feed_id != $new_feed_id) {
|
||||
try {
|
||||
$new_feed = \Feed_Adapter::load_with_user($app, $user, $new_feed_id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
throw new \Exception_Forbidden('You have no access to this feed');
|
||||
}
|
||||
|
||||
$title = $request->request->get('title');
|
||||
$subtitle = $request->request->get('subtitle');
|
||||
$author_name = $request->request->get('author_name');
|
||||
$author_mail = $request->request->get('author_mail');
|
||||
|
||||
$entry->set_author_email($author_mail)
|
||||
->set_author_name($author_name)
|
||||
->set_title($title)
|
||||
->set_subtitle($subtitle);
|
||||
|
||||
$current_feed_id = $entry->get_feed()->get_id();
|
||||
$new_feed_id = $request->request->get('feed_id', $current_feed_id);
|
||||
if ($current_feed_id != $new_feed_id) {
|
||||
try {
|
||||
$new_feed = \Feed_Adapter::load_with_user($app, $user, $new_feed_id);
|
||||
} catch (\Exception_NotFound $e) {
|
||||
throw new \Exception_Forbidden('You have no access to this feed');
|
||||
}
|
||||
|
||||
if ( ! $new_feed->is_publisher($user)) {
|
||||
throw new \Exception_Forbidden('You are not publisher of this feed');
|
||||
}
|
||||
|
||||
$entry->set_feed($new_feed);
|
||||
if (!$new_feed->is_publisher($user)) {
|
||||
throw new \Exception_Forbidden('You are not publisher of this feed');
|
||||
}
|
||||
|
||||
$items = explode(';', $request->request->get('sorted_lst'));
|
||||
|
||||
foreach ($items as $item_sort) {
|
||||
$item_sort_datas = explode('_', $item_sort);
|
||||
if (count($item_sort_datas) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = new \Feed_Entry_Item($app['phraseanet.appbox'], $entry, $item_sort_datas[0]);
|
||||
|
||||
$item->set_ord($item_sort_datas[1]);
|
||||
}
|
||||
$app['phraseanet.appbox']->get_connection()->commit();
|
||||
|
||||
$entry = $app['twig']->render('prod/feeds/entry.html.twig', array('entry' => $entry));
|
||||
|
||||
$datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed not found');
|
||||
} catch (\Exception_Forbidden $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('You are not authorized to access this feed');
|
||||
} catch (\Exception $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
$entry->set_feed($new_feed);
|
||||
}
|
||||
|
||||
return $app->json($datas);
|
||||
})->assert('id', '\d+');
|
||||
$items = explode(';', $request->request->get('sorted_lst'));
|
||||
|
||||
foreach ($items as $item_sort) {
|
||||
$item_sort_datas = explode('_', $item_sort);
|
||||
if (count($item_sort_datas) != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = new \Feed_Entry_Item($app['phraseanet.appbox'], $entry, $item_sort_datas[0]);
|
||||
|
||||
$item->set_ord($item_sort_datas[1]);
|
||||
}
|
||||
$app['phraseanet.appbox']->get_connection()->commit();
|
||||
|
||||
$entry = $app['twig']->render('prod/feeds/entry.html.twig', array('entry' => $entry));
|
||||
|
||||
$datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
} catch (\Exception_NotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed not found');
|
||||
} catch (\Exception_Forbidden $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('You are not authorized to access this feed');
|
||||
} catch (\Exception $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $app->json($datas);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->post('/entry/{id}/delete/', function(Application $app, Request $request, $id) {
|
||||
$datas = array('error' => true, 'message' => '');
|
||||
try {
|
||||
$app['phraseanet.appbox']->get_connection()->beginTransaction();
|
||||
$datas = array('error' => true, 'message' => '');
|
||||
try {
|
||||
$app['phraseanet.appbox']->get_connection()->beginTransaction();
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
$entry = \Feed_Entry_Adapter::load_from_id($app, $id);
|
||||
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()
|
||||
&& $entry->get_feed()->is_owner($user) === false) {
|
||||
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
|
||||
}
|
||||
|
||||
$entry->delete();
|
||||
|
||||
$app['phraseanet.appbox']->get_connection()->commit();
|
||||
$datas = array('error' => false, 'message' => 'succes');
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
} catch (\Exception $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id()
|
||||
&& $entry->get_feed()->is_owner($user) === false) {
|
||||
throw new \Exception_UnauthorizedAction(_('Action Forbidden : You are not the publisher'));
|
||||
}
|
||||
|
||||
return $app->json($datas);
|
||||
})->assert('id', '\d+');
|
||||
$entry->delete();
|
||||
|
||||
$app['phraseanet.appbox']->get_connection()->commit();
|
||||
$datas = array('error' => false, 'message' => 'succes');
|
||||
} catch (\Exception_Feed_EntryNotFound $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = _('Feed entry not found');
|
||||
} catch (\Exception $e) {
|
||||
$app['phraseanet.appbox']->get_connection()->rollBack();
|
||||
$datas['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $app->json($datas);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
$request = $app['request'];
|
||||
$page = (int) $request->query->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
$request = $app['request'];
|
||||
$page = (int) $request->query->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
|
||||
$datas = $app['twig']->render('prod/feeds/feeds.html.twig'
|
||||
, array(
|
||||
'feeds' => $feeds
|
||||
, 'feed' => $feeds->get_aggregate()
|
||||
, 'page' => $page
|
||||
)
|
||||
);
|
||||
$datas = $app['twig']->render('prod/feeds/feeds.html.twig'
|
||||
, array(
|
||||
'feeds' => $feeds
|
||||
, 'feed' => $feeds->get_aggregate()
|
||||
, 'page' => $page
|
||||
)
|
||||
);
|
||||
|
||||
return new Response($datas);
|
||||
});
|
||||
return new Response($datas);
|
||||
});
|
||||
|
||||
$controllers->get('/feed/{id}/', function(Application $app, Request $request, $id) {
|
||||
$page = (int) $request->query->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
$page = (int) $request->query->get('page');
|
||||
$page = $page > 0 ? $page : 1;
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$feed = \Feed_Adapter::load_with_user($app, $user, $id);
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$feed = \Feed_Adapter::load_with_user($app, $user, $id);
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
|
||||
$datas = $app['twig']->render('prod/feeds/feeds.html.twig', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page));
|
||||
$datas = $app['twig']->render('prod/feeds/feeds.html.twig', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page));
|
||||
|
||||
return new Response($datas);
|
||||
})->assert('id', '\d+');
|
||||
return new Response($datas);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
$controllers->get('/subscribe/aggregated/', function(Application $app, Request $request) {
|
||||
$renew = ($request->query->get('renew') === 'true');
|
||||
$renew = ($request->query->get('renew') === 'true');
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$registry = $app['phraseanet.appbox']->get_registry();
|
||||
$feeds = \Feed_Collection::load_all($app, $user);
|
||||
$registry = $app['phraseanet.appbox']->get_registry();
|
||||
|
||||
$output = array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" readonly="readonly" class="input_select_copy" value="' . $feeds->get_aggregate()->get_user_link($registry, $user, \Feed_Adapter::FORMAT_RSS, null, $renew)->get_href() . '"/></div>',
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
);
|
||||
$output = array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" readonly="readonly" class="input_select_copy" value="' . $feeds->get_aggregate()->get_user_link($registry, $user, \Feed_Adapter::FORMAT_RSS, null, $renew)->get_href() . '"/></div>',
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
);
|
||||
|
||||
return $app->json($output);
|
||||
});
|
||||
return $app->json($output);
|
||||
});
|
||||
|
||||
$controllers->get('/subscribe/{id}/', function(Application $app, Request $request, $id) {
|
||||
$renew = ($request->query->get('renew') === 'true');
|
||||
$user = $app['phraseanet.user'];
|
||||
$feed = \Feed_Adapter::load_with_user($app, $user, $id);
|
||||
$registry = $app['phraseanet.appbox']->get_registry();
|
||||
$renew = ($request->query->get('renew') === 'true');
|
||||
$user = $app['phraseanet.user'];
|
||||
$feed = \Feed_Adapter::load_with_user($app, $user, $id);
|
||||
$registry = $app['phraseanet.appbox']->get_registry();
|
||||
|
||||
$output = array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" style="width:100%" value="' . $feed->get_user_link($registry, $user, \Feed_Adapter::FORMAT_RSS, null, $renew)->get_href() . '"/></div>',
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
);
|
||||
$output = array(
|
||||
'texte' => '<p>' . _('publication::Voici votre fil RSS personnel. Il vous permettra d\'etre tenu au courrant des publications.')
|
||||
. '</p><p>' . _('publications::Ne le partagez pas, il est strictement confidentiel') . '</p>
|
||||
<div><input type="text" style="width:100%" value="' . $feed->get_user_link($registry, $user, \Feed_Adapter::FORMAT_RSS, null, $renew)->get_href() . '"/></div>',
|
||||
'titre' => _('publications::votre rss personnel')
|
||||
);
|
||||
|
||||
return $app->json($output);
|
||||
})->assert('id', '\d+');
|
||||
return $app->json($output);
|
||||
})->assert('id', '\d+');
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -27,84 +27,84 @@ class Language implements ControllerProviderInterface
|
||||
$controller = $app['controllers_factory'];
|
||||
|
||||
$controller->get("/", function(Application $app) {
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$registry = $app['phraseanet.registry'];
|
||||
|
||||
$out = array();
|
||||
$out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.');
|
||||
$out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?');
|
||||
$out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique');
|
||||
$out['serverName'] = $registry->get('GV_ServerName');
|
||||
$out['serverTimeout'] = _('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible');
|
||||
$out['serverDisconnected'] = _('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier');
|
||||
$out['hideMessage'] = _('phraseanet::Ne plus afficher ce message');
|
||||
$out['confirmGroup'] = _('Supprimer egalement les documents rattaches a ces regroupements');
|
||||
$out['confirmDelete'] = _('reponses:: Ces enregistrements vont etre definitivement supprimes et ne pourront etre recuperes. Etes vous sur ?');
|
||||
$out['cancel'] = _('boutton::annuler');
|
||||
$out['deleteTitle'] = _('boutton::supprimer');
|
||||
$out['edit_hetero'] = _('prod::editing valeurs heterogenes, choisir \'remplacer\', \'ajouter\' ou \'annuler\'');
|
||||
$out['confirm_abandon'] = _('prod::editing::annulation: abandonner les modification ?');
|
||||
$out['loading'] = _('phraseanet::chargement');
|
||||
$out['valider'] = _('boutton::valider');
|
||||
$out['annuler'] = _('boutton::annuler');
|
||||
$out['create'] = _('boutton::creer');
|
||||
$out['rechercher'] = _('boutton::rechercher');
|
||||
$out['renewRss'] = _('boutton::renouveller');
|
||||
$out['candeletesome'] = _('Vous n\'avez pas les droits pour supprimer certains documents');
|
||||
$out['candeletedocuments'] = _('Vous n\'avez pas les droits pour supprimer ces documents');
|
||||
$out['needTitle'] = _('Vous devez donner un titre');
|
||||
$out['newPreset'] = _('Nouveau modele');
|
||||
$out['fermer'] = _('boutton::fermer');
|
||||
$out['feed_require_fields'] = _('Vous n\'avez pas rempli tous les champ requis');
|
||||
$out['feed_require_feed'] = _('Vous n\'avez pas selectionne de fil de publication');
|
||||
$out['removeTitle'] = _('panier::Supression d\'un element d\'un reportage');
|
||||
$out['confirmRemoveReg'] = _('panier::Attention, vous etes sur le point de supprimer un element du reportage. Merci de confirmer votre action.');
|
||||
$out['advsearch_title'] = _('phraseanet::recherche avancee');
|
||||
$out['bask_rename'] = _('panier:: renommer le panier');
|
||||
$out['reg_wrong_sbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre');
|
||||
$out['error'] = _('phraseanet:: Erreur');
|
||||
$out['warningDenyCgus'] = _('cgus :: Attention, si vous refuser les CGUs de cette base, vous n\'y aures plus acces');
|
||||
$out['cgusRelog'] = _('cgus :: Vous devez vous reauthentifier pour que vos parametres soient pris en compte.');
|
||||
$out['editDelMulti'] = _('edit:: Supprimer %s du champ dans les records selectionnes');
|
||||
$out['editAddMulti'] = _('edit:: Ajouter %s au champ courrant pour les records selectionnes');
|
||||
$out['editDelSimple'] = _('edit:: Supprimer %s du champ courrant');
|
||||
$out['editAddSimple'] = _('edit:: Ajouter %s au champ courrant');
|
||||
$out['cantDeletePublicOne'] = _('panier:: vous ne pouvez pas supprimer un panier public');
|
||||
$out['wrongsbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre');
|
||||
$out['max_record_selected'] = _('Vous ne pouvez pas selectionner plus de 800 enregistrements');
|
||||
$out['confirmRedirectAuth'] = _('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez');
|
||||
$out['error_test_publi'] = _('Erreur : soit les parametres sont incorrects, soit le serveur distant ne repond pas');
|
||||
$out['test_publi_ok'] = _('Les parametres sont corrects, le serveur distant est operationnel');
|
||||
$out['some_not_published'] = _('Certaines publications n\'ont pu etre effectuees, verifiez vos parametres');
|
||||
$out['error_not_published'] = _('Aucune publication effectuee, verifiez vos parametres');
|
||||
$out['warning_delete_publi'] = _('Attention, en supprimant ce preregalge, vous ne pourrez plus modifier ou supprimer de publications prealablement effectues avec celui-ci');
|
||||
$out['some_required_fields'] = _('edit::certains documents possedent des champs requis non remplis. Merci de les remplir pour valider votre editing');
|
||||
$out['nodocselected'] = _('Aucun document selectionne');
|
||||
$out['sureToRemoveList'] = _('Are you sure you want to delete this list ?');
|
||||
$out['newListName'] = _('New list name ?');
|
||||
$out['listNameCannotBeEmpty'] = _('List name can not be empty');
|
||||
$out['FeedBackName'] = _('Name');
|
||||
$out['FeedBackMessage'] = _('Message');
|
||||
$out['FeedBackDuration'] = _('Time for feedback (days)');
|
||||
$out['send'] = _('Send');
|
||||
$out['Recept'] = _('Accuse de reception');
|
||||
$out['nFieldsChanged'] = _('%d fields have been updated');
|
||||
$out['FeedBackNoUsersSelected'] = _('No users selected');
|
||||
$out['errorFileApi'] = _('An error occurred reading this file');
|
||||
$out['errorFileApiTooBig'] = _('This file is too big');
|
||||
$out['selectOneRecord'] = _('Please select one record');
|
||||
$out['onlyOneRecord'] = _('You can choose only one record');
|
||||
$out['errorAjaxRequest'] = _('An error occured, please retry');
|
||||
$out['fileBeingDownloaded'] = _('Some files are being downloaded');
|
||||
$out['warning'] = _('Attention');
|
||||
$out['browserFeatureSupport'] = _('This feature is not supported by your browser');
|
||||
$out['noActiveBasket'] = _('No active basket');
|
||||
$out['pushUserCanDownload'] = _('User can download HD');
|
||||
$out['feedbackCanContribute'] = _('User contribute to the feedback');
|
||||
$out['feedbackCanSeeOthers'] = _('User can see others choices');
|
||||
$out['forceSendDocument'] = _('Force sending of the document ?');
|
||||
$out = array();
|
||||
$out['thesaurusBasesChanged'] = _('prod::recherche: Attention : la liste des bases selectionnees pour la recherche a ete changee.');
|
||||
$out['confirmDel'] = _('paniers::Vous etes sur le point de supprimer ce panier. Cette action est irreversible. Souhaitez-vous continuer ?');
|
||||
$out['serverError'] = _('phraseanet::erreur: Une erreur est survenue, si ce probleme persiste, contactez le support technique');
|
||||
$out['serverName'] = $registry->get('GV_ServerName');
|
||||
$out['serverTimeout'] = _('phraseanet::erreur: La connection au serveur Phraseanet semble etre indisponible');
|
||||
$out['serverDisconnected'] = _('phraseanet::erreur: Votre session est fermee, veuillez vous re-authentifier');
|
||||
$out['hideMessage'] = _('phraseanet::Ne plus afficher ce message');
|
||||
$out['confirmGroup'] = _('Supprimer egalement les documents rattaches a ces regroupements');
|
||||
$out['confirmDelete'] = _('reponses:: Ces enregistrements vont etre definitivement supprimes et ne pourront etre recuperes. Etes vous sur ?');
|
||||
$out['cancel'] = _('boutton::annuler');
|
||||
$out['deleteTitle'] = _('boutton::supprimer');
|
||||
$out['edit_hetero'] = _('prod::editing valeurs heterogenes, choisir \'remplacer\', \'ajouter\' ou \'annuler\'');
|
||||
$out['confirm_abandon'] = _('prod::editing::annulation: abandonner les modification ?');
|
||||
$out['loading'] = _('phraseanet::chargement');
|
||||
$out['valider'] = _('boutton::valider');
|
||||
$out['annuler'] = _('boutton::annuler');
|
||||
$out['create'] = _('boutton::creer');
|
||||
$out['rechercher'] = _('boutton::rechercher');
|
||||
$out['renewRss'] = _('boutton::renouveller');
|
||||
$out['candeletesome'] = _('Vous n\'avez pas les droits pour supprimer certains documents');
|
||||
$out['candeletedocuments'] = _('Vous n\'avez pas les droits pour supprimer ces documents');
|
||||
$out['needTitle'] = _('Vous devez donner un titre');
|
||||
$out['newPreset'] = _('Nouveau modele');
|
||||
$out['fermer'] = _('boutton::fermer');
|
||||
$out['feed_require_fields'] = _('Vous n\'avez pas rempli tous les champ requis');
|
||||
$out['feed_require_feed'] = _('Vous n\'avez pas selectionne de fil de publication');
|
||||
$out['removeTitle'] = _('panier::Supression d\'un element d\'un reportage');
|
||||
$out['confirmRemoveReg'] = _('panier::Attention, vous etes sur le point de supprimer un element du reportage. Merci de confirmer votre action.');
|
||||
$out['advsearch_title'] = _('phraseanet::recherche avancee');
|
||||
$out['bask_rename'] = _('panier:: renommer le panier');
|
||||
$out['reg_wrong_sbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre');
|
||||
$out['error'] = _('phraseanet:: Erreur');
|
||||
$out['warningDenyCgus'] = _('cgus :: Attention, si vous refuser les CGUs de cette base, vous n\'y aures plus acces');
|
||||
$out['cgusRelog'] = _('cgus :: Vous devez vous reauthentifier pour que vos parametres soient pris en compte.');
|
||||
$out['editDelMulti'] = _('edit:: Supprimer %s du champ dans les records selectionnes');
|
||||
$out['editAddMulti'] = _('edit:: Ajouter %s au champ courrant pour les records selectionnes');
|
||||
$out['editDelSimple'] = _('edit:: Supprimer %s du champ courrant');
|
||||
$out['editAddSimple'] = _('edit:: Ajouter %s au champ courrant');
|
||||
$out['cantDeletePublicOne'] = _('panier:: vous ne pouvez pas supprimer un panier public');
|
||||
$out['wrongsbas'] = _('panier:: Un reportage ne peux recevoir que des elements provenants de la base ou il est enregistre');
|
||||
$out['max_record_selected'] = _('Vous ne pouvez pas selectionner plus de 800 enregistrements');
|
||||
$out['confirmRedirectAuth'] = _('invite:: Redirection vers la zone d\'authentification, cliquez sur OK pour continuer ou annulez');
|
||||
$out['error_test_publi'] = _('Erreur : soit les parametres sont incorrects, soit le serveur distant ne repond pas');
|
||||
$out['test_publi_ok'] = _('Les parametres sont corrects, le serveur distant est operationnel');
|
||||
$out['some_not_published'] = _('Certaines publications n\'ont pu etre effectuees, verifiez vos parametres');
|
||||
$out['error_not_published'] = _('Aucune publication effectuee, verifiez vos parametres');
|
||||
$out['warning_delete_publi'] = _('Attention, en supprimant ce preregalge, vous ne pourrez plus modifier ou supprimer de publications prealablement effectues avec celui-ci');
|
||||
$out['some_required_fields'] = _('edit::certains documents possedent des champs requis non remplis. Merci de les remplir pour valider votre editing');
|
||||
$out['nodocselected'] = _('Aucun document selectionne');
|
||||
$out['sureToRemoveList'] = _('Are you sure you want to delete this list ?');
|
||||
$out['newListName'] = _('New list name ?');
|
||||
$out['listNameCannotBeEmpty'] = _('List name can not be empty');
|
||||
$out['FeedBackName'] = _('Name');
|
||||
$out['FeedBackMessage'] = _('Message');
|
||||
$out['FeedBackDuration'] = _('Time for feedback (days)');
|
||||
$out['send'] = _('Send');
|
||||
$out['Recept'] = _('Accuse de reception');
|
||||
$out['nFieldsChanged'] = _('%d fields have been updated');
|
||||
$out['FeedBackNoUsersSelected'] = _('No users selected');
|
||||
$out['errorFileApi'] = _('An error occurred reading this file');
|
||||
$out['errorFileApiTooBig'] = _('This file is too big');
|
||||
$out['selectOneRecord'] = _('Please select one record');
|
||||
$out['onlyOneRecord'] = _('You can choose only one record');
|
||||
$out['errorAjaxRequest'] = _('An error occured, please retry');
|
||||
$out['fileBeingDownloaded'] = _('Some files are being downloaded');
|
||||
$out['warning'] = _('Attention');
|
||||
$out['browserFeatureSupport'] = _('This feature is not supported by your browser');
|
||||
$out['noActiveBasket'] = _('No active basket');
|
||||
$out['pushUserCanDownload'] = _('User can download HD');
|
||||
$out['feedbackCanContribute'] = _('User contribute to the feedback');
|
||||
$out['feedbackCanSeeOthers'] = _('User can see others choices');
|
||||
$out['forceSendDocument'] = _('Force sending of the document ?');
|
||||
|
||||
return $app->json($out);
|
||||
});
|
||||
return $app->json($out);
|
||||
});
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
@@ -183,11 +183,9 @@ class Lazaret implements ControllerProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
$html = $app['twig']->render(
|
||||
return $app['twig']->render(
|
||||
'prod/upload/lazaret.html.twig', array('lazaretFiles' => $lazaretFiles)
|
||||
);
|
||||
|
||||
return new Response($html);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +240,7 @@ class Lazaret implements ControllerProviderInterface
|
||||
$ret = array('success' => false, 'message' => '', 'result' => array());
|
||||
|
||||
//Optional parameter
|
||||
$keepAttributes = ! ! $request->request->get('keep_attributes', false);
|
||||
$keepAttributes = !!$request->request->get('keep_attributes', false);
|
||||
$attributesToKeep = $request->request->get('attributes', array());
|
||||
|
||||
//Mandatory parameter
|
||||
@@ -288,8 +286,8 @@ class Lazaret implements ControllerProviderInterface
|
||||
foreach ($lazaretFile->getAttributes() as $attr) {
|
||||
|
||||
//Check which ones to keep
|
||||
if ( ! ! count($attributesToKeep)) {
|
||||
if ( ! in_array($attr->getId(), $attributesToKeep)) {
|
||||
if (!!count($attributesToKeep)) {
|
||||
if (!in_array($attr->getId(), $attributesToKeep)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -460,7 +458,7 @@ class Lazaret implements ControllerProviderInterface
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! $found) {
|
||||
if (!$found) {
|
||||
$ret['message'] = _('The destination record provided is not allowed');
|
||||
|
||||
return $app->json($ret);
|
||||
@@ -514,11 +512,9 @@ class Lazaret implements ControllerProviderInterface
|
||||
|
||||
$lazaretThumbFileName = $app['phraseanet.registry']->get('GV_RootPath') . 'tmp/lazaret/' . $lazaretFile->getThumbFilename();
|
||||
|
||||
$response = \set_export::stream_file(
|
||||
return \set_export::stream_file(
|
||||
$app['phraseanet.registry'], $lazaretThumbFileName, $lazaretFile->getOriginalName(), 'image/jpeg', 'inline'
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -71,7 +71,7 @@ class MoveCollection implements ControllerProviderInterface
|
||||
return $app->json($datas);
|
||||
}
|
||||
|
||||
if ( ! $user->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) {
|
||||
if (!$user->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) {
|
||||
$datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination(), $app));
|
||||
return $app->json($datas);
|
||||
}
|
||||
|
@@ -28,20 +28,20 @@ class MustacheLoader implements ControllerProviderInterface
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
$template_name = $request->query->get('template');
|
||||
$template_name = $request->query->get('template');
|
||||
|
||||
if ( ! preg_match('/^[a-zA-Z0-9-_]+$/', $template_name)) {
|
||||
throw new \Exception_BadRequest('Wrong template name : ' . $template_name);
|
||||
}
|
||||
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');
|
||||
$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);
|
||||
}
|
||||
if (!file_exists($template_path)) {
|
||||
throw new \Exception_NotFound('Template does not exists : ' . $template_path);
|
||||
}
|
||||
|
||||
return new \Symfony\Component\HttpFoundation\Response(file_get_contents($template_path));
|
||||
});
|
||||
return new \Symfony\Component\HttpFoundation\Response(file_get_contents($template_path));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -153,24 +153,24 @@ class Order implements ControllerProviderInterface
|
||||
|
||||
foreach ($records as $key => $record) {
|
||||
if ($collectionHasOrderAdmins->containsKey($record->get_base_id())) {
|
||||
if ( ! $collectionHasOrderAdmins->get($record->get_base_id())) {
|
||||
if (!$collectionHasOrderAdmins->get($record->get_base_id())) {
|
||||
$records->remove($key);
|
||||
}
|
||||
}
|
||||
|
||||
$hasOneAdmin = ! ! count($query->on_base_ids(array($record->get_base_id()))
|
||||
$hasOneAdmin = !!count($query->on_base_ids(array($record->get_base_id()))
|
||||
->who_have_right(array('order_master'))
|
||||
->execute()->get_results());
|
||||
|
||||
$collectionHasOrderAdmins->set($record->get_base_id(), $hasOneAdmin);
|
||||
|
||||
if ( ! $hasOneAdmin) {
|
||||
if (!$hasOneAdmin) {
|
||||
$toRemove[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($toRemove as $key) {
|
||||
if($records->containsKey($key)) {
|
||||
if ($records->containsKey($key)) {
|
||||
$records->remove($key);
|
||||
}
|
||||
}
|
||||
@@ -200,15 +200,15 @@ class Order implements ControllerProviderInterface
|
||||
if ('json' === $app['request']->getRequestFormat()) {
|
||||
|
||||
return $app->json(array(
|
||||
'success' => $success,
|
||||
'msg' => $msg,
|
||||
));
|
||||
'success' => $success,
|
||||
'msg' => $msg,
|
||||
));
|
||||
}
|
||||
|
||||
return $app->redirect($app['url_generator']->generate('prod_orders', array(
|
||||
'success' => (int) $success,
|
||||
'action' => 'send'
|
||||
)));
|
||||
'success' => (int) $success,
|
||||
'action' => 'send'
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,13 +232,13 @@ class Order implements ControllerProviderInterface
|
||||
$total = \set_order::countTotalOrder($app['phraseanet.appbox'], $baseIds);
|
||||
|
||||
return $app['twig']->render('prod/orders/order_box.html.twig', array(
|
||||
'page' => $page,
|
||||
'perPage' => $perPage,
|
||||
'total' => $total,
|
||||
'previousPage' => $page < 2 ? false : ($page - 1),
|
||||
'nextPage' => $page >= ceil($total / $perPage) ? false : $page + 1,
|
||||
'orders' => new ArrayCollection($ordersList)
|
||||
));
|
||||
'page' => $page,
|
||||
'perPage' => $perPage,
|
||||
'total' => $total,
|
||||
'previousPage' => $page < 2 ? false : ($page - 1),
|
||||
'nextPage' => $page >= ceil($total / $perPage) ? false : $page + 1,
|
||||
'orders' => new ArrayCollection($ordersList)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,8 +258,8 @@ class Order implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app['twig']->render('prod/orders/order_item.html.twig', array(
|
||||
'order' => $order
|
||||
));
|
||||
'order' => $order
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +281,7 @@ class Order implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
try {
|
||||
$order->send_elements($app, $request->request->get('elements', array()), ! ! $request->request->get('force', false));
|
||||
$order->send_elements($app, $request->request->get('elements', array()), !!$request->request->get('force', false));
|
||||
$success = true;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -290,16 +290,16 @@ class Order implements ControllerProviderInterface
|
||||
if ('json' === $app['request']->getRequestFormat()) {
|
||||
|
||||
return $app->json(array(
|
||||
'success' => $success,
|
||||
'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'),
|
||||
'order_id' => $order_id
|
||||
));
|
||||
'success' => $success,
|
||||
'msg' => $success ? _('Order has been sent') : _('An error occured while sending, please retry or contact an admin if problem persists'),
|
||||
'order_id' => $order_id
|
||||
));
|
||||
}
|
||||
|
||||
return $app->redirect($app['url_generator']->generate('prod_orders', array(
|
||||
'success' => (int) $success,
|
||||
'action' => 'send'
|
||||
)));
|
||||
'success' => (int) $success,
|
||||
'action' => 'send'
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,16 +330,16 @@ class Order implements ControllerProviderInterface
|
||||
if ('json' === $app['request']->getRequestFormat()) {
|
||||
|
||||
return $app->json(array(
|
||||
'success' => $success,
|
||||
'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'),
|
||||
'order_id' => $order_id
|
||||
));
|
||||
'success' => $success,
|
||||
'msg' => $success ? _('Order has been denied') : _('An error occured while denying, please retry or contact an admin if problem persists'),
|
||||
'order_id' => $order_id
|
||||
));
|
||||
}
|
||||
|
||||
return $app->redirect($app['url_generator']->generate('prod_orders', array(
|
||||
'success' => (int) $success,
|
||||
'action' => 'send'
|
||||
)));
|
||||
'success' => (int) $success,
|
||||
'action' => 'send'
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,34 +37,33 @@ class Printer implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
$controllers->post('/print.pdf', function(Application $app) {
|
||||
$printer = new RecordHelper\Printer($app, $app['request']);
|
||||
$printer = new RecordHelper\Printer($app, $app['request']);
|
||||
|
||||
$request = $app['request'];
|
||||
$request = $app['request'];
|
||||
|
||||
$layout = $request->request->get('lay');
|
||||
$layout = $request->request->get('lay');
|
||||
|
||||
foreach ($printer->get_elements() as $record) {
|
||||
$app['phraseanet.logger']($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_PRINT, $layout, '');
|
||||
}
|
||||
$PDF = new PDFExport($app, $printer->get_elements(), $layout);
|
||||
|
||||
/**
|
||||
*
|
||||
* Header "Pragma: public" SHOULD be present.
|
||||
* In case it is not present, download on IE 8 and previous over HTTPS
|
||||
* will fail.
|
||||
*
|
||||
* @todo : merge this shitty fix with Response object.
|
||||
*
|
||||
*/
|
||||
if ( ! headers_sent()) {
|
||||
header("Pragma: public");
|
||||
}
|
||||
|
||||
return new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
|
||||
foreach ($printer->get_elements() as $record) {
|
||||
$app['phraseanet.logger']($record->get_databox())
|
||||
->log($record, \Session_Logger::EVENT_PRINT, $layout, '');
|
||||
}
|
||||
);
|
||||
$PDF = new PDFExport($app, $printer->get_elements(), $layout);
|
||||
|
||||
/**
|
||||
*
|
||||
* Header "Pragma: public" SHOULD be present.
|
||||
* In case it is not present, download on IE 8 and previous over HTTPS
|
||||
* will fail.
|
||||
*
|
||||
* @todo : merge this shitty fix with Response object.
|
||||
*
|
||||
*/
|
||||
if (!headers_sent()) {
|
||||
header("Pragma: public");
|
||||
}
|
||||
|
||||
return new Response($PDF->render(), 200, array('Content-Type' => 'application/pdf'));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,188 +30,188 @@ class Query implements ControllerProviderInterface
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireAuthentication();
|
||||
|
||||
if($response instanceof Response) {
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
|
||||
$controllers->post('/', function(Application $app, Request $request) {
|
||||
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$registry = $appbox->get_registry();
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$registry = $appbox->get_registry();
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$query = (string) $request->request->get('qry');
|
||||
$query = (string) $request->request->get('qry');
|
||||
|
||||
$mod = $user->getPrefs('view');
|
||||
$mod = $user->getPrefs('view');
|
||||
|
||||
$json = array();
|
||||
$json = array();
|
||||
|
||||
$options = new \searchEngine_options();
|
||||
$options = new \searchEngine_options();
|
||||
|
||||
$bas = is_array($request->request->get('bas')) ? $request->request->get('bas') : array_keys($user->ACL()->get_granted_base());
|
||||
$bas = is_array($request->request->get('bas')) ? $request->request->get('bas') : array_keys($user->ACL()->get_granted_base());
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
if ($user->ACL()->has_right('modifyrecord')) {
|
||||
$options->set_business_fields(array());
|
||||
/* @var $user \User_Adapter */
|
||||
if ($user->ACL()->has_right('modifyrecord')) {
|
||||
$options->set_business_fields(array());
|
||||
|
||||
$BF = array();
|
||||
$BF = array();
|
||||
|
||||
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection) {
|
||||
if (count($bas) === 0 || in_array($collection->get_base_id(), $bas)) {
|
||||
$BF[] = $collection->get_base_id();
|
||||
}
|
||||
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection) {
|
||||
if (count($bas) === 0 || in_array($collection->get_base_id(), $bas)) {
|
||||
$BF[] = $collection->get_base_id();
|
||||
}
|
||||
$options->set_business_fields($BF);
|
||||
} else {
|
||||
$options->set_business_fields(array());
|
||||
}
|
||||
$options->set_business_fields($BF);
|
||||
} else {
|
||||
$options->set_business_fields(array());
|
||||
}
|
||||
|
||||
$status = is_array($request->request->get('status')) ? $request->request->get('status') : array();
|
||||
$fields = is_array($request->request->get('fields')) ? $request->request->get('fields') : array();
|
||||
$status = is_array($request->request->get('status')) ? $request->request->get('status') : array();
|
||||
$fields = is_array($request->request->get('fields')) ? $request->request->get('fields') : array();
|
||||
|
||||
$options->set_fields($fields);
|
||||
$options->set_status($status);
|
||||
$options->set_bases($bas, $user->ACL());
|
||||
$options->set_fields($fields);
|
||||
$options->set_status($status);
|
||||
$options->set_bases($bas, $user->ACL());
|
||||
|
||||
$options->set_search_type($request->request->get('search_type'));
|
||||
$options->set_record_type($request->request->get('recordtype'));
|
||||
$options->set_min_date($request->request->get('datemin'));
|
||||
$options->set_max_date($request->request->get('datemax'));
|
||||
$options->set_date_fields(explode('|', $request->request->get('datefield')));
|
||||
$options->set_sort($request->request->get('sort'), $request->request->get('ord', PHRASEA_ORDER_DESC));
|
||||
$options->set_use_stemming($request->request->get('stemme'));
|
||||
$options->set_search_type($request->request->get('search_type'));
|
||||
$options->set_record_type($request->request->get('recordtype'));
|
||||
$options->set_min_date($request->request->get('datemin'));
|
||||
$options->set_max_date($request->request->get('datemax'));
|
||||
$options->set_date_fields(explode('|', $request->request->get('datefield')));
|
||||
$options->set_sort($request->request->get('sort'), $request->request->get('ord', PHRASEA_ORDER_DESC));
|
||||
$options->set_use_stemming($request->request->get('stemme'));
|
||||
|
||||
$form = serialize($options);
|
||||
$form = serialize($options);
|
||||
|
||||
$perPage = (int) $user->getPrefs('images_per_page');
|
||||
$perPage = (int) $user->getPrefs('images_per_page');
|
||||
|
||||
$search_engine = new \searchEngine_adapter($app);
|
||||
$search_engine->set_options($options);
|
||||
$search_engine = new \searchEngine_adapter($app);
|
||||
$search_engine->set_options($options);
|
||||
|
||||
$page = (int) $request->request->get('pag');
|
||||
$page = (int) $request->request->get('pag');
|
||||
|
||||
if ($page < 1) {
|
||||
$search_engine->set_is_first_page(true);
|
||||
$search_engine->reset_cache();
|
||||
$page = 1;
|
||||
}
|
||||
if ($page < 1) {
|
||||
$search_engine->set_is_first_page(true);
|
||||
$search_engine->reset_cache();
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$result = $search_engine->query_per_page($query, $page, $perPage);
|
||||
$result = $search_engine->query_per_page($query, $page, $perPage);
|
||||
|
||||
$proposals = $search_engine->is_first_page() ? $result->get_propositions() : false;
|
||||
$proposals = $search_engine->is_first_page() ? $result->get_propositions() : false;
|
||||
|
||||
$npages = $result->get_total_pages();
|
||||
$npages = $result->get_total_pages();
|
||||
|
||||
$page = $result->get_current_page();
|
||||
$page = $result->get_current_page();
|
||||
|
||||
$string = '';
|
||||
$string = '';
|
||||
|
||||
if ($npages > 1) {
|
||||
if ($npages > 1) {
|
||||
|
||||
$d2top = ($npages - $page);
|
||||
$d2bottom = $page;
|
||||
$d2top = ($npages - $page);
|
||||
$d2bottom = $page;
|
||||
|
||||
if (min($d2top, $d2bottom) < 4) {
|
||||
if ($d2bottom < 4) {
|
||||
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i ++ ) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||
else
|
||||
$string .= "<a onclick='gotopage(" . $i . ");return false;' class='btn btn-primary btn-mini'>" . $i . "</a>";
|
||||
}
|
||||
if ($npages > 4)
|
||||
$string .= "<a onclick='gotopage(" . ($npages) . ");return false;' class='btn btn-primary btn-mini'>>></a>";
|
||||
} else {
|
||||
$start = $npages - 4;
|
||||
if (($start) > 0)
|
||||
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
||||
else
|
||||
$start = 1;
|
||||
for ($i = ($start); $i <= $npages; $i ++ ) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||
else
|
||||
$string .= "<a onclick='gotopage(" . $i . ");return false;' class='btn btn-primary btn-mini'>" . $i . "</a>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
||||
|
||||
for ($i = ($page - 2); $i <= ($page + 2); $i ++ ) {
|
||||
if (min($d2top, $d2bottom) < 4) {
|
||||
if ($d2bottom < 4) {
|
||||
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i++) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||
else
|
||||
$string .= "<a onclick='gotopage(" . $i . ");return false;' class='btn btn-primary btn-mini'>" . $i . "</a>";
|
||||
}
|
||||
if ($npages > 4)
|
||||
$string .= "<a onclick='gotopage(" . ($npages) . ");return false;' class='btn btn-primary btn-mini'>>></a>";
|
||||
} else {
|
||||
$start = $npages - 4;
|
||||
if (($start) > 0)
|
||||
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
||||
else
|
||||
$start = 1;
|
||||
for ($i = ($start); $i <= $npages; $i++) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||
else
|
||||
$string .= "<a onclick='gotopage(" . $i . ");return false;' class='btn btn-primary btn-mini'>" . $i . "</a>";
|
||||
}
|
||||
|
||||
$string .= "<a onclick='gotopage(" . ($npages) . ");return false;' class='btn btn-primary btn-mini'>>></a>";
|
||||
}
|
||||
}
|
||||
$string .= '<div style="display:none;"><div id="NEXT_PAGE"></div><div id="PREV_PAGE"></div></div>';
|
||||
|
||||
$explain = "<div id=\"explainResults\" class=\"myexplain\">";
|
||||
|
||||
$explain .= "<img src=\"/skins/icons/answers.gif\" /><span><b>";
|
||||
|
||||
if ($result->get_count_total_results() != $result->get_count_available_results()) {
|
||||
$explain .= sprintf(_('reponses:: %d Resultats rappatries sur un total de %d trouves'), $result->get_count_available_results(), $result->get_count_total_results());
|
||||
} else {
|
||||
$explain .= sprintf(_('reponses:: %d Resultats'), $result->get_count_total_results());
|
||||
$string .= "<a onclick='gotopage(1);return false;' class='btn btn-primary btn-mini'><<</a>";
|
||||
|
||||
for ($i = ($page - 2); $i <= ($page + 2); $i++) {
|
||||
if ($i == $page)
|
||||
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" class="btn btn-mini" />';
|
||||
else
|
||||
$string .= "<a onclick='gotopage(" . $i . ");return false;' class='btn btn-primary btn-mini'>" . $i . "</a>";
|
||||
}
|
||||
|
||||
$string .= "<a onclick='gotopage(" . ($npages) . ");return false;' class='btn btn-primary btn-mini'>>></a>";
|
||||
}
|
||||
}
|
||||
$string .= '<div style="display:none;"><div id="NEXT_PAGE"></div><div id="PREV_PAGE"></div></div>';
|
||||
|
||||
$explain .= " </b></span>";
|
||||
$explain .= '<br><div>' . $result->get_query_time() . ' s</div>dans index ' . $result->get_search_indexes();
|
||||
$explain .= "</div>";
|
||||
$explain = "<div id=\"explainResults\" class=\"myexplain\">";
|
||||
|
||||
$infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '"', $explain) . '">' . sprintf(_('reponses:: %d reponses'), $result->get_count_total_results()) . '</a> | ' . sprintf(_('reponses:: %s documents selectionnes'), '<span id="nbrecsel"></span>');
|
||||
$explain .= "<img src=\"/skins/icons/answers.gif\" /><span><b>";
|
||||
|
||||
$json['infos'] = $infoResult;
|
||||
$json['navigation'] = $string;
|
||||
if ($result->get_count_total_results() != $result->get_count_available_results()) {
|
||||
$explain .= sprintf(_('reponses:: %d Resultats rappatries sur un total de %d trouves'), $result->get_count_available_results(), $result->get_count_total_results());
|
||||
} else {
|
||||
$explain .= sprintf(_('reponses:: %d Resultats'), $result->get_count_total_results());
|
||||
}
|
||||
|
||||
$prop = null;
|
||||
$explain .= " </b></span>";
|
||||
$explain .= '<br><div>' . $result->get_query_time() . ' s</div>dans index ' . $result->get_search_indexes();
|
||||
$explain .= "</div>";
|
||||
|
||||
if ($search_engine->is_first_page()) {
|
||||
$propals = $result->get_suggestions($app['locale.I18n']);
|
||||
if (count($propals) > 0) {
|
||||
foreach ($propals as $prop_array) {
|
||||
if ($prop_array['value'] !== $query && $prop_array['hits'] > $result->get_count_total_results()) {
|
||||
$prop = $prop_array['value'];
|
||||
break;
|
||||
}
|
||||
$infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '"', $explain) . '">' . sprintf(_('reponses:: %d reponses'), $result->get_count_total_results()) . '</a> | ' . sprintf(_('reponses:: %s documents selectionnes'), '<span id="nbrecsel"></span>');
|
||||
|
||||
$json['infos'] = $infoResult;
|
||||
$json['navigation'] = $string;
|
||||
|
||||
$prop = null;
|
||||
|
||||
if ($search_engine->is_first_page()) {
|
||||
$propals = $result->get_suggestions($app['locale.I18n']);
|
||||
if (count($propals) > 0) {
|
||||
foreach ($propals as $prop_array) {
|
||||
if ($prop_array['value'] !== $query && $prop_array['hits'] > $result->get_count_total_results()) {
|
||||
$prop = $prop_array['value'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($result->get_count_total_results() === 0) {
|
||||
$template = 'prod/results/help.html.twig';
|
||||
if ($result->get_count_total_results() === 0) {
|
||||
$template = 'prod/results/help.html.twig';
|
||||
} else {
|
||||
if ($mod == 'thumbs') {
|
||||
$template = 'prod/results/answergrid.html.twig';
|
||||
} else {
|
||||
if ($mod == 'thumbs') {
|
||||
$template = 'prod/results/answergrid.html.twig';
|
||||
} else {
|
||||
$template = 'prod/results/answerlist.html.twig';
|
||||
}
|
||||
$template = 'prod/results/answerlist.html.twig';
|
||||
}
|
||||
}
|
||||
|
||||
$json['results'] = $app['twig']->render($template, array(
|
||||
'results' => $result,
|
||||
'GV_social_tools' => $registry->get('GV_social_tools'),
|
||||
'highlight' => $search_engine->get_query(),
|
||||
'searchEngine' => $search_engine,
|
||||
'suggestions' => $prop
|
||||
)
|
||||
);
|
||||
$json['results'] = $app['twig']->render($template, array(
|
||||
'results' => $result,
|
||||
'GV_social_tools' => $registry->get('GV_social_tools'),
|
||||
'highlight' => $search_engine->get_query(),
|
||||
'searchEngine' => $search_engine,
|
||||
'suggestions' => $prop
|
||||
)
|
||||
);
|
||||
|
||||
$json['query'] = $query;
|
||||
$json['phrasea_props'] = $proposals;
|
||||
$json['total_answers'] = (int) $result->get_count_available_results();
|
||||
$json['next_page'] = ($page < $npages && $result->get_count_available_results() > 0) ? ($page + 1) : false;
|
||||
$json['prev_page'] = ($page > 1 && $result->get_count_available_results() > 0) ? ($page - 1) : false;
|
||||
$json['form'] = $form;
|
||||
$json['query'] = $query;
|
||||
$json['phrasea_props'] = $proposals;
|
||||
$json['total_answers'] = (int) $result->get_count_available_results();
|
||||
$json['next_page'] = ($page < $npages && $result->get_count_available_results() > 0) ? ($page + 1) : false;
|
||||
$json['prev_page'] = ($page > 1 && $result->get_count_available_results() > 0) ? ($page - 1) : false;
|
||||
$json['form'] = $form;
|
||||
|
||||
return $app->json($json);
|
||||
});
|
||||
return $app->json($json);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -33,113 +33,111 @@ class Root implements ControllerProviderInterface
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireAuthentication();
|
||||
|
||||
if($response instanceof Response) {
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
|
||||
$controllers->get('/', function(Application $app) {
|
||||
|
||||
\User_Adapter::updateClientInfos($app, 1);
|
||||
\User_Adapter::updateClientInfos($app, 1);
|
||||
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$user = $app['phraseanet.user'];
|
||||
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
$registry = $app['phraseanet.registry'];
|
||||
$user = $app['phraseanet.user'];
|
||||
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
|
||||
|
||||
$css = array();
|
||||
$cssfile = false;
|
||||
$css = array();
|
||||
$cssfile = false;
|
||||
|
||||
$finder = new Finder();
|
||||
$finder = new Finder();
|
||||
|
||||
$iterator = $finder
|
||||
->directories()
|
||||
->depth(0)
|
||||
->filter(function(\SplFileInfo $fileinfo) {
|
||||
return ctype_xdigit($fileinfo->getBasename());
|
||||
})
|
||||
->in($cssPath);
|
||||
$iterator = $finder
|
||||
->directories()
|
||||
->depth(0)
|
||||
->filter(function(\SplFileInfo $fileinfo) {
|
||||
return ctype_xdigit($fileinfo->getBasename());
|
||||
})
|
||||
->in($cssPath);
|
||||
|
||||
foreach ($iterator as $dir) {
|
||||
$baseName = $dir->getBaseName();
|
||||
$css[$baseName] = $baseName;
|
||||
foreach ($iterator as $dir) {
|
||||
$baseName = $dir->getBaseName();
|
||||
$css[$baseName] = $baseName;
|
||||
}
|
||||
|
||||
$cssfile = $user->getPrefs('css');
|
||||
|
||||
if (!$cssfile && isset($css['000000'])) {
|
||||
$cssfile = '000000';
|
||||
}
|
||||
|
||||
$user_feeds = \Feed_Collection::load_all($app, $user);
|
||||
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
||||
|
||||
$thjslist = "";
|
||||
|
||||
$queries_topics = '';
|
||||
|
||||
if ($registry->get('GV_client_render_topics') == 'popups') {
|
||||
$queries_topics = \queries::dropdown_topics($app['locale.I18n']);
|
||||
} elseif ($registry->get('GV_client_render_topics') == 'tree') {
|
||||
$queries_topics = \queries::tree_topics($app['locale.I18n']);
|
||||
}
|
||||
|
||||
$sbas = $bas2sbas = array();
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
$sbas_id = $databox->get_sbas_id();
|
||||
|
||||
$sbas['s' + $sbas_id] = array(
|
||||
'sbid' => $sbas_id,
|
||||
'seeker' => null);
|
||||
|
||||
foreach ($databox->get_collections() as $coll) {
|
||||
$bas2sbas['b' . $coll->get_base_id()] = array(
|
||||
'sbid' => $sbas_id,
|
||||
'ckobj' => array('checked' => false),
|
||||
'waschecked' => false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$cssfile = $user->getPrefs('css');
|
||||
|
||||
if (!$cssfile && isset($css['000000'])) {
|
||||
$cssfile = '000000';
|
||||
}
|
||||
|
||||
$user_feeds = \Feed_Collection::load_all($app, $user);
|
||||
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
||||
|
||||
$thjslist = "";
|
||||
|
||||
$queries_topics = '';
|
||||
|
||||
if ($registry->get('GV_client_render_topics') == 'popups') {
|
||||
$queries_topics = \queries::dropdown_topics($app['locale.I18n']);
|
||||
} elseif ($registry->get('GV_client_render_topics') == 'tree') {
|
||||
$queries_topics = \queries::tree_topics($app['locale.I18n']);
|
||||
}
|
||||
|
||||
$sbas = $bas2sbas = array();
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
$sbas_id = $databox->get_sbas_id();
|
||||
|
||||
$sbas['s' + $sbas_id] = array(
|
||||
'sbid' => $sbas_id,
|
||||
'seeker' => null);
|
||||
|
||||
foreach ($databox->get_collections() as $coll) {
|
||||
$bas2sbas['b' . $coll->get_base_id()] = array(
|
||||
'sbid' => $sbas_id,
|
||||
'ckobj' => array('checked' => false),
|
||||
'waschecked' => false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$out = $app['twig']->render('prod/index.html.twig', array(
|
||||
'module_name' => 'Production',
|
||||
'WorkZone' => new Helper\WorkZone($app, $app['request']),
|
||||
'module_prod' => new Helper\Prod($app, $app['request']),
|
||||
'cssfile' => $cssfile,
|
||||
'module' => 'prod',
|
||||
'events' => $app['events-manager'],
|
||||
'GV_defaultQuery_type' => $registry->get('GV_defaultQuery_type'),
|
||||
'GV_multiAndReport' => $registry->get('GV_multiAndReport'),
|
||||
'GV_thesaurus' => $registry->get('GV_thesaurus'),
|
||||
'cgus_agreement' => \databox_cgu::askAgreement($app),
|
||||
'css' => $css,
|
||||
'feeds' => $feeds,
|
||||
'GV_google_api' => $registry->get('GV_google_api'),
|
||||
'queries_topics' => $queries_topics,
|
||||
'search_status' => \databox_status::getSearchStatus($app),
|
||||
'queries_history' => \queries::history($app['phraseanet.appbox'], $app['phraseanet.user']->get_id()),
|
||||
'thesau_js_list' => $thjslist,
|
||||
'thesau_json_sbas' => json_encode($sbas),
|
||||
'thesau_json_bas2sbas' => json_encode($bas2sbas),
|
||||
'thesau_languages' => \User_Adapter::avLanguages(),
|
||||
));
|
||||
|
||||
return new Response($out);
|
||||
});
|
||||
return $app['twig']->render('prod/index.html.twig', array(
|
||||
'module_name' => 'Production',
|
||||
'WorkZone' => new Helper\WorkZone($app, $app['request']),
|
||||
'module_prod' => new Helper\Prod($app, $app['request']),
|
||||
'cssfile' => $cssfile,
|
||||
'module' => 'prod',
|
||||
'events' => $app['events-manager'],
|
||||
'GV_defaultQuery_type' => $registry->get('GV_defaultQuery_type'),
|
||||
'GV_multiAndReport' => $registry->get('GV_multiAndReport'),
|
||||
'GV_thesaurus' => $registry->get('GV_thesaurus'),
|
||||
'cgus_agreement' => \databox_cgu::askAgreement($app),
|
||||
'css' => $css,
|
||||
'feeds' => $feeds,
|
||||
'GV_google_api' => $registry->get('GV_google_api'),
|
||||
'queries_topics' => $queries_topics,
|
||||
'search_status' => \databox_status::getSearchStatus($app),
|
||||
'queries_history' => \queries::history($app['phraseanet.appbox'], $app['phraseanet.user']->get_id()),
|
||||
'thesau_js_list' => $thjslist,
|
||||
'thesau_json_sbas' => json_encode($sbas),
|
||||
'thesau_json_bas2sbas' => json_encode($bas2sbas),
|
||||
'thesau_languages' => \User_Adapter::avLanguages(),
|
||||
));
|
||||
});
|
||||
|
||||
$controllers->post('/multi-export/', function(Application $app, Request $request) {
|
||||
|
||||
$download = new \set_export($app, $request->request->get('lst', ''), (int) $request->request->get('ssel'), $request->request->get('story'));
|
||||
$download = new \set_export($app, $request->request->get('lst', ''), (int) $request->request->get('ssel'), $request->request->get('story'));
|
||||
|
||||
return $app['twig']->render('common/dialog_export.html.twig', array(
|
||||
'download' => $download,
|
||||
'ssttid' => (int) $request->request->get('ssel'),
|
||||
'lst' => $download->serialize_list(),
|
||||
'default_export_title' => $app['phraseanet.registry']->get('GV_default_export_title'),
|
||||
'choose_export_title' => $app['phraseanet.registry']->get('GV_choose_export_title')
|
||||
));
|
||||
});
|
||||
return $app['twig']->render('common/dialog_export.html.twig', array(
|
||||
'download' => $download,
|
||||
'ssttid' => (int) $request->request->get('ssel'),
|
||||
'lst' => $download->serialize_list(),
|
||||
'default_export_title' => $app['phraseanet.registry']->get('GV_default_export_title'),
|
||||
'choose_export_title' => $app['phraseanet.registry']->get('GV_choose_export_title')
|
||||
));
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -30,171 +30,166 @@ class Story implements ControllerProviderInterface
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->get('/create/', function(Application $app) {
|
||||
|
||||
return new Response($app['twig']->render('prod/Story/Create.html.twig', array()));
|
||||
});
|
||||
return $app['twig']->render('prod/Story/Create.html.twig', array());
|
||||
});
|
||||
|
||||
$controllers->post('/', function(Application $app, Request $request) {
|
||||
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
||||
$user = $app['phraseanet.user'];
|
||||
/* @var $request \Symfony\Component\HttpFoundation\Request */
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
|
||||
$collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
|
||||
throw new \Exception_Forbidden('You can not create a story on this collection');
|
||||
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
|
||||
throw new \Exception_Forbidden('You can not create a story on this collection');
|
||||
}
|
||||
|
||||
$Story = \record_adapter::createStory($app, $collection);
|
||||
|
||||
foreach (explode(';', $request->request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$Story = \record_adapter::createStory($app, $collection);
|
||||
$record = new \record_adapter($app, $sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
foreach (explode(';', $request->request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$record = new \record_adapter($app, $sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($Story->hasChild($record))
|
||||
continue;
|
||||
|
||||
$Story->appendChild($record);
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$metadatas = array();
|
||||
if ($Story->hasChild($record))
|
||||
continue;
|
||||
|
||||
foreach ($collection->get_databox()->get_meta_structure() as $meta) {
|
||||
if ($meta->get_thumbtitle()) {
|
||||
$value = $request->request->get('name');
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
$Story->appendChild($record);
|
||||
}
|
||||
|
||||
$metadatas[] = array(
|
||||
'meta_struct_id' => $meta->get_id()
|
||||
, 'meta_id' => null
|
||||
, 'value' => $value
|
||||
);
|
||||
$metadatas = array();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
||||
|
||||
$StoryWZ = new \Entities\StoryWZ();
|
||||
$StoryWZ->setUser($user);
|
||||
$StoryWZ->setRecord($Story);
|
||||
|
||||
$app['EM']->persist($StoryWZ);
|
||||
|
||||
$app['EM']->flush();
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => _('Story created')
|
||||
, 'WorkZone' => $StoryWZ->getId()
|
||||
, 'story' => array(
|
||||
'sbas_id' => $Story->get_sbas_id(),
|
||||
'record_id' => $Story->get_record_id(),
|
||||
)
|
||||
);
|
||||
|
||||
return $app->json($data);
|
||||
foreach ($collection->get_databox()->get_meta_structure() as $meta) {
|
||||
if ($meta->get_thumbtitle()) {
|
||||
$value = $request->request->get('name');
|
||||
} else {
|
||||
return $app->redirect(sprintf('/%d/', $StoryWZ->getId()));
|
||||
}
|
||||
});
|
||||
|
||||
$controllers->get('/{sbas_id}/{record_id}/', function(Application $app, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
$html = $app['twig']->render('prod/WorkZone/Story.html.twig', array('Story' => $Story));
|
||||
|
||||
return new Response($html);
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->post(
|
||||
'/{sbas_id}/{record_id}/addElements/'
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach (explode(';', $request->request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2)
|
||||
continue;
|
||||
|
||||
$record = new \record_adapter($app, $sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($Story->hasChild($record))
|
||||
continue;
|
||||
|
||||
$Story->appendChild($record);
|
||||
|
||||
$n++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => sprintf(_('%d records added'), $n)
|
||||
$metadatas[] = array(
|
||||
'meta_struct_id' => $meta->get_id()
|
||||
, 'meta_id' => null
|
||||
, 'value' => $value
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
return $app->json($data);
|
||||
} else {
|
||||
return $app->redirect('/');
|
||||
break;
|
||||
}
|
||||
|
||||
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
||||
|
||||
$StoryWZ = new \Entities\StoryWZ();
|
||||
$StoryWZ->setUser($user);
|
||||
$StoryWZ->setRecord($Story);
|
||||
|
||||
$app['EM']->persist($StoryWZ);
|
||||
|
||||
$app['EM']->flush();
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => _('Story created')
|
||||
, 'WorkZone' => $StoryWZ->getId()
|
||||
, 'story' => array(
|
||||
'sbas_id' => $Story->get_sbas_id(),
|
||||
'record_id' => $Story->get_record_id(),
|
||||
)
|
||||
);
|
||||
|
||||
return $app->json($data);
|
||||
} else {
|
||||
return $app->redirect(sprintf('/%d/', $StoryWZ->getId()));
|
||||
}
|
||||
});
|
||||
|
||||
$controllers->get('/{sbas_id}/{record_id}/', function(Application $app, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
$html = $app['twig']->render('prod/WorkZone/Story.html.twig', array('Story' => $Story));
|
||||
|
||||
return new Response($html);
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->post('/{sbas_id}/{record_id}/addElements/', function(Application $app, Request $request, $sbas_id, $record_id) {
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
|
||||
$n = 0;
|
||||
|
||||
foreach (explode(';', $request->request->get('lst')) as $sbas_rec) {
|
||||
$sbas_rec = explode('_', $sbas_rec);
|
||||
|
||||
if (count($sbas_rec) !== 2)
|
||||
continue;
|
||||
|
||||
$record = new \record_adapter($app, $sbas_rec[0], $sbas_rec[1]);
|
||||
|
||||
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||
&& !$user->ACL()->has_hd_grant($record)
|
||||
&& !$user->ACL()->has_preview_grant($record)) {
|
||||
continue;
|
||||
}
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$controllers->post(
|
||||
'/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/'
|
||||
, function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
if ($Story->hasChild($record))
|
||||
continue;
|
||||
|
||||
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
|
||||
$Story->appendChild($record);
|
||||
|
||||
$user = $app['phraseanet.user'];
|
||||
$n++;
|
||||
}
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => sprintf(_('%d records added'), $n)
|
||||
);
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
return $app->json($data);
|
||||
} else {
|
||||
return $app->redirect('/');
|
||||
}
|
||||
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
|
||||
|
||||
$Story->removeChild($record);
|
||||
$controllers->post('/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/', function(Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
|
||||
$Story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => _('Record removed from story')
|
||||
);
|
||||
$record = new \record_adapter($app, $child_sbas_id, $child_record_id);
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
return $app->json($data);
|
||||
} else {
|
||||
return $app->redirect('/');
|
||||
}
|
||||
})
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($Story->get_base_id(), 'canmodifrecord'))
|
||||
throw new \Exception_Forbidden('You can not add document to this Story');
|
||||
|
||||
/* @var $user \User_Adapter */
|
||||
|
||||
$Story->removeChild($record);
|
||||
|
||||
$data = array(
|
||||
'success' => true
|
||||
, 'message' => _('Record removed from story')
|
||||
);
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
return $app->json($data);
|
||||
} else {
|
||||
return $app->redirect('/');
|
||||
}
|
||||
})
|
||||
->assert('sbas_id', '\d+')
|
||||
->assert('record_id', '\d+')
|
||||
->assert('child_sbas_id', '\d+')
|
||||
@@ -204,64 +199,62 @@ class Story implements ControllerProviderInterface
|
||||
* Get the Basket reorder form
|
||||
*/
|
||||
$controllers->get('/{sbas_id}/{record_id}/reorder/', function(Application $app, $sbas_id, $record_id) {
|
||||
$story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
$story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
if (!$story->is_grouping()) {
|
||||
throw new \Exception('This is not a story');
|
||||
}
|
||||
if (!$story->is_grouping()) {
|
||||
throw new \Exception('This is not a story');
|
||||
}
|
||||
|
||||
return new Response(
|
||||
$app['twig']->render(
|
||||
'prod/Story/Reorder.html.twig'
|
||||
, array('story' => $story)
|
||||
)
|
||||
);
|
||||
})
|
||||
return new Response(
|
||||
$app['twig']->render(
|
||||
'prod/Story/Reorder.html.twig'
|
||||
, array('story' => $story)
|
||||
)
|
||||
);
|
||||
})
|
||||
->assert('sbas_id', '\d+')
|
||||
->assert('record_id', '\d+');
|
||||
|
||||
$controllers->post(
|
||||
'/{sbas_id}/{record_id}/reorder/'
|
||||
, function(Application $app, $sbas_id, $record_id) {
|
||||
$ret = array('success' => false, 'message' => _('An error occured'));
|
||||
try {
|
||||
$user = $app['phraseanet.user'];
|
||||
/* @var $user \User_Adapter */
|
||||
$controllers->post('/{sbas_id}/{record_id}/reorder/', function(Application $app, $sbas_id, $record_id) {
|
||||
$ret = array('success' => false, 'message' => _('An error occured'));
|
||||
try {
|
||||
$user = $app['phraseanet.user'];
|
||||
/* @var $user \User_Adapter */
|
||||
|
||||
$story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
$story = new \record_adapter($app, $sbas_id, $record_id);
|
||||
|
||||
if (!$story->is_grouping()) {
|
||||
throw new \Exception('This is not a story');
|
||||
}
|
||||
if (!$story->is_grouping()) {
|
||||
throw new \Exception('This is not a story');
|
||||
}
|
||||
|
||||
if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) {
|
||||
throw new ControllerException(_('You can not edit this story'));
|
||||
}
|
||||
if (!$user->ACL()->has_right_on_base($story->get_base_id(), 'canmodifrecord')) {
|
||||
throw new ControllerException(_('You can not edit this story'));
|
||||
}
|
||||
|
||||
$sql = 'UPDATE regroup SET ord = :ord
|
||||
WHERE rid_parent = :parent_id AND rid_child = :children_id';
|
||||
$stmt = $story->get_databox()->get_connection()->prepare($sql);
|
||||
$sql = 'UPDATE regroup SET ord = :ord
|
||||
WHERE rid_parent = :parent_id AND rid_child = :children_id';
|
||||
$stmt = $story->get_databox()->get_connection()->prepare($sql);
|
||||
|
||||
foreach ($app['request']->request->get('element') as $record_id => $ord) {
|
||||
$params = array(
|
||||
':ord' => $ord,
|
||||
':parent_id' => $story->get_record_id(),
|
||||
':children_id' => $record_id
|
||||
);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
foreach ($app['request']->request->get('element') as $record_id => $ord) {
|
||||
$params = array(
|
||||
':ord' => $ord,
|
||||
':parent_id' => $story->get_record_id(),
|
||||
':children_id' => $record_id
|
||||
);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
|
||||
$stmt->closeCursor();
|
||||
$stmt->closeCursor();
|
||||
|
||||
$ret = array('success' => true, 'message' => _('Story updated'));
|
||||
} catch (ControllerException $e) {
|
||||
$ret = array('success' => false, 'message' => $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
$ret = array('success' => true, 'message' => _('Story updated'));
|
||||
} catch (ControllerException $e) {
|
||||
$ret = array('success' => false, 'message' => $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $app->json($ret);
|
||||
})
|
||||
return $app->json($ret);
|
||||
})
|
||||
->assert('sbas_id', '\d+')
|
||||
->assert('record_id', '\d+');
|
||||
|
||||
|
@@ -28,27 +28,27 @@ class TOU implements ControllerProviderInterface
|
||||
$controllers = $app['controllers_factory'];
|
||||
|
||||
$controllers->post('/deny/{sbas_id}/', function(Application $app, Request $request, $sbas_id) {
|
||||
$ret = array('success' => false, 'message' => '');
|
||||
$ret = array('success' => false, 'message' => '');
|
||||
|
||||
try {
|
||||
$user = $app['phraseanet.user'];
|
||||
try {
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||
|
||||
$user->ACL()->revoke_access_from_bases(
|
||||
$user->ACL()->get_granted_base(array(), array($databox->get_sbas_id()))
|
||||
);
|
||||
$user->ACL()->revoke_unused_sbas_rights();
|
||||
$user->ACL()->revoke_access_from_bases(
|
||||
$user->ACL()->get_granted_base(array(), array($databox->get_sbas_id()))
|
||||
);
|
||||
$user->ACL()->revoke_unused_sbas_rights();
|
||||
|
||||
$app->closeAccount();
|
||||
$app->closeAccount();
|
||||
|
||||
$ret = array('success' => true, 'message' => '');
|
||||
} catch (\Exception $e) {
|
||||
$ret = array('success' => true, 'message' => '');
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $app->json($ret);
|
||||
});
|
||||
return $app->json($ret);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -32,132 +32,175 @@ class Tools implements ControllerProviderInterface
|
||||
|
||||
$controllers->get('/', function(Application $app, Request $request) {
|
||||
|
||||
$records = RecordsRequest::fromRequest($app, $request, false);
|
||||
$records = RecordsRequest::fromRequest($app, $request, false);
|
||||
|
||||
$metadatas = false;
|
||||
$record = null;
|
||||
$metadatas = false;
|
||||
$record = null;
|
||||
|
||||
if (count($records) == 1) {
|
||||
$record = $records->first();
|
||||
if (!$record->is_grouping()) {
|
||||
try {
|
||||
$reader = new \PHPExiftool\Reader();
|
||||
if (count($records) == 1) {
|
||||
$record = $records->first();
|
||||
if (!$record->is_grouping()) {
|
||||
try {
|
||||
$reader = new \PHPExiftool\Reader();
|
||||
|
||||
$metadatas = $reader
|
||||
->files($record->get_subdef('document')->get_pathfile())
|
||||
->first()->getMetadatas();
|
||||
unset($reader);
|
||||
} catch (\PHPExiftool\Exception\Exception $e) {
|
||||
$metadatas = $reader
|
||||
->files($record->get_subdef('document')->get_pathfile())
|
||||
->first()->getMetadatas();
|
||||
unset($reader);
|
||||
} catch (\PHPExiftool\Exception\Exception $e) {
|
||||
|
||||
} catch (\Exception_Media_SubdefNotFound $e) {
|
||||
} catch (\Exception_Media_SubdefNotFound $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$var = array(
|
||||
'helper' => $records,
|
||||
'selection' => $selection,
|
||||
'record' => $record,
|
||||
'metadatas' => $metadatas,
|
||||
);
|
||||
$var = array(
|
||||
'helper' => $records,
|
||||
'selection' => $selection,
|
||||
'record' => $record,
|
||||
'metadatas' => $metadatas,
|
||||
);
|
||||
|
||||
return $app['twig']->render('prod/actions/Tools/index.html.twig', $var);
|
||||
});
|
||||
return $app['twig']->render('prod/actions/Tools/index.html.twig', $var);
|
||||
});
|
||||
|
||||
$controllers->post('/rotate/', function(Application $app, Request $request) {
|
||||
$return = array('success' => true, 'errorMessage' => '');
|
||||
$return = array('success' => true, 'errorMessage' => '');
|
||||
|
||||
$records = RecordsRequest::fromRequest($app, $request, false);
|
||||
$records = RecordsRequest::fromRequest($app, $request, false);
|
||||
|
||||
$rotation = in_array($request->request->get('rotation'), array('-90', '90', '180')) ? $request->request->get('rotation', 90) : 90;
|
||||
$rotation = in_array($request->request->get('rotation'), array('-90', '90', '180')) ? $request->request->get('rotation', 90) : 90;
|
||||
|
||||
foreach ($records as $record) {
|
||||
foreach ($record->get_subdefs() as $name => $subdef) {
|
||||
if ($name == 'document')
|
||||
continue;
|
||||
foreach ($records as $record) {
|
||||
foreach ($record->get_subdefs() as $name => $subdef) {
|
||||
if ($name == 'document')
|
||||
continue;
|
||||
|
||||
try {
|
||||
$subdef->rotate($rotation, $app['media-alchemyst'], $app['mediavorus']);
|
||||
} catch (\Exception $e) {
|
||||
try {
|
||||
$subdef->rotate($rotation, $app['media-alchemyst'], $app['mediavorus']);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $app->json($return);
|
||||
});
|
||||
return $app->json($return);
|
||||
});
|
||||
|
||||
$controllers->post('/image/', function(Application $app, Request $request) {
|
||||
$return = array('success' => true);
|
||||
$return = array('success' => true);
|
||||
|
||||
$helper = new Helper\Record\Tools($app, $request);
|
||||
$helper = new Helper\Record\Tools($app, $request);
|
||||
|
||||
$selection = $helper->get_elements();
|
||||
$selection = $helper->get_elements();
|
||||
|
||||
foreach ($selection as $record) {
|
||||
foreach ($selection as $record) {
|
||||
|
||||
$substituted = false;
|
||||
foreach ($record->get_subdefs() as $subdef) {
|
||||
if ($subdef->is_substituted()) {
|
||||
$substituted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$substituted || $request->request->get('ForceThumbSubstit') == '1') {
|
||||
$record->rebuild_subdefs();
|
||||
$substituted = false;
|
||||
foreach ($record->get_subdefs() as $subdef) {
|
||||
if ($subdef->is_substituted()) {
|
||||
$substituted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $app->json($return);
|
||||
});
|
||||
if (!$substituted || $request->request->get('ForceThumbSubstit') == '1') {
|
||||
$record->rebuild_subdefs();
|
||||
}
|
||||
}
|
||||
|
||||
return $app->json($return);
|
||||
});
|
||||
|
||||
$controllers->post('/hddoc/', function(Application $app, Request $request) {
|
||||
$success = false;
|
||||
$errorMessage = "";
|
||||
$fileName = null;
|
||||
$success = false;
|
||||
$errorMessage = "";
|
||||
$fileName = null;
|
||||
|
||||
if ($file = $request->files->get('newHD')) {
|
||||
if ($file = $request->files->get('newHD')) {
|
||||
|
||||
if ($file->isValid()) {
|
||||
if ($file->isValid()) {
|
||||
|
||||
$fileName = $file->getClientOriginalName();
|
||||
$size = $file->getClientSize();
|
||||
$fileName = $file->getClientOriginalName();
|
||||
$size = $file->getClientSize();
|
||||
|
||||
$tempoFile = tempnam(sys_get_temp_dir(), 'substit');
|
||||
unlink($tempoFile);
|
||||
mkdir($tempoFile);
|
||||
$tempoFile = $tempoFile . DIRECTORY_SEPARATOR . $fileName;
|
||||
copy($file->getPathname(), $tempoFile);
|
||||
$tempoFile = tempnam(sys_get_temp_dir(), 'substit');
|
||||
unlink($tempoFile);
|
||||
mkdir($tempoFile);
|
||||
$tempoFile = $tempoFile . DIRECTORY_SEPARATOR . $fileName;
|
||||
copy($file->getPathname(), $tempoFile);
|
||||
|
||||
|
||||
try {
|
||||
$record = new \record_adapter(
|
||||
try {
|
||||
$record = new \record_adapter(
|
||||
$app,
|
||||
$request->request->get('sbas_id')
|
||||
, $request->request->get('record_id')
|
||||
);
|
||||
$request->request->get('sbas_id')
|
||||
, $request->request->get('record_id')
|
||||
);
|
||||
|
||||
$media = $app['mediavorus']->guess($tempoFile);
|
||||
$media = $app['mediavorus']->guess($tempoFile);
|
||||
|
||||
$record->substitute_subdef('document', $media, $app);
|
||||
$record->substitute_subdef('document', $media, $app);
|
||||
|
||||
if ((int) $request->request->get('ccfilename') === 1) {
|
||||
$record->set_original_name($fileName);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
if ((int) $request->request->get('ccfilename') === 1) {
|
||||
$record->set_original_name($fileName);
|
||||
}
|
||||
|
||||
unlink($tempoFile);
|
||||
rmdir(dirname($tempoFile));
|
||||
unlink($file->getPathname());
|
||||
} else {
|
||||
$errorMessage = _('file is not valid');
|
||||
$success = true;
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
|
||||
unlink($tempoFile);
|
||||
rmdir(dirname($tempoFile));
|
||||
unlink($file->getPathname());
|
||||
} else {
|
||||
$errorMessage = _('file is not valid');
|
||||
}
|
||||
}
|
||||
|
||||
$template = 'prod/actions/Tools/iframeUpload.html.twig';
|
||||
$var = array(
|
||||
'success' => $success
|
||||
, 'fileName' => $fileName
|
||||
, 'errorMessage' => $errorMessage
|
||||
);
|
||||
|
||||
return $app['twig']->render($template, $var);
|
||||
});
|
||||
|
||||
$controllers->post('/chgthumb/', function(Application $app, Request $request) {
|
||||
$success = false;
|
||||
$errorMessage = "";
|
||||
|
||||
if ($file = $request->files->get('newThumb')) {
|
||||
|
||||
$size = $file->getClientSize();
|
||||
$fileName = $file->getClientOriginalName();
|
||||
|
||||
if ($size && $fileName && $file->isValid()) {
|
||||
try {
|
||||
$rootPath = $app['phraseanet.registry']->get('GV_RootPath');
|
||||
$tmpFile = $rootPath . 'tmp/' . $fileName;
|
||||
rename($file->getPathname(), $tmpFile);
|
||||
|
||||
$record = new \record_adapter(
|
||||
$app,
|
||||
$request->request->get('sbas_id')
|
||||
, $request->request->get('record_id')
|
||||
);
|
||||
|
||||
$media = $app['mediavorus']->guess($tmpFile);
|
||||
|
||||
$record->substitute_subdef('thumbnail', $media, $app);
|
||||
|
||||
$success = true;
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$errorMessage = _('file is not valid');
|
||||
}
|
||||
|
||||
$template = 'prod/actions/Tools/iframeUpload.html.twig';
|
||||
@@ -167,106 +210,59 @@ class Tools implements ControllerProviderInterface
|
||||
, 'errorMessage' => $errorMessage
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render($template, $var));
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
});
|
||||
|
||||
$controllers->post('/chgthumb/', function(Application $app, Request $request) {
|
||||
$success = false;
|
||||
$errorMessage = "";
|
||||
|
||||
if ($file = $request->files->get('newThumb')) {
|
||||
|
||||
$size = $file->getClientSize();
|
||||
$fileName = $file->getClientOriginalName();
|
||||
|
||||
if ($size && $fileName && $file->isValid()) {
|
||||
try {
|
||||
$rootPath = $app['phraseanet.registry']->get('GV_RootPath');
|
||||
$tmpFile = $rootPath . 'tmp/' . $fileName;
|
||||
rename($file->getPathname(), $tmpFile);
|
||||
|
||||
$record = new \record_adapter(
|
||||
$app,
|
||||
$request->request->get('sbas_id')
|
||||
, $request->request->get('record_id')
|
||||
);
|
||||
|
||||
$media = $app['mediavorus']->guess($tmpFile);
|
||||
|
||||
$record->substitute_subdef('thumbnail', $media, $app);
|
||||
|
||||
$success = true;
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$errorMessage = _('file is not valid');
|
||||
}
|
||||
|
||||
$template = 'prod/actions/Tools/iframeUpload.html.twig';
|
||||
$var = array(
|
||||
'success' => $success
|
||||
, 'fileName' => $fileName
|
||||
, 'errorMessage' => $errorMessage
|
||||
);
|
||||
|
||||
return new Response($app['twig']->render($template, $var));
|
||||
}
|
||||
});
|
||||
return $app['twig']->render($template, $var);
|
||||
}
|
||||
});
|
||||
|
||||
$controllers->post('/thumb-extractor/confirm-box/', function(Application $app, Request $request) {
|
||||
$return = array('error' => false, 'datas' => '');
|
||||
$template = 'prod/actions/Tools/confirm.html.twig';
|
||||
$return = array('error' => false, 'datas' => '');
|
||||
$template = 'prod/actions/Tools/confirm.html.twig';
|
||||
|
||||
try {
|
||||
$record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id'));
|
||||
$var = array(
|
||||
'video_title' => $record->get_title()
|
||||
, 'image' => $request->request->get('image', '')
|
||||
);
|
||||
$return['datas'] = $app['twig']->render($template, $var);
|
||||
} catch (\Exception $e) {
|
||||
$return['datas'] = _('an error occured');
|
||||
$return['error'] = true;
|
||||
}
|
||||
try {
|
||||
$record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id'));
|
||||
$var = array(
|
||||
'video_title' => $record->get_title()
|
||||
, 'image' => $request->request->get('image', '')
|
||||
);
|
||||
$return['datas'] = $app['twig']->render($template, $var);
|
||||
} catch (\Exception $e) {
|
||||
$return['datas'] = _('an error occured');
|
||||
$return['error'] = true;
|
||||
}
|
||||
|
||||
return $app->json($return);
|
||||
});
|
||||
return $app->json($return);
|
||||
});
|
||||
|
||||
$controllers->post('/thumb-extractor/apply/', function(Application $app, Request $request) {
|
||||
$return = array('success' => false, 'message' => '');
|
||||
$return = array('success' => false, 'message' => '');
|
||||
|
||||
try {
|
||||
$record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id'));
|
||||
try {
|
||||
$record = new \record_adapter($app, $request->request->get('sbas_id'), $request->request->get('record_id'));
|
||||
|
||||
$dataUri = DataURI\Parser::parse($request->request->get('image', ''));
|
||||
$dataUri = DataURI\Parser::parse($request->request->get('image', ''));
|
||||
|
||||
$path = $app['phraseanet.registry']->get('GV_RootPath') . 'tmp';
|
||||
$path = $app['phraseanet.registry']->get('GV_RootPath') . 'tmp';
|
||||
|
||||
$name = sprintf('extractor_thumb_%s', $record->get_serialize_key());
|
||||
$name = sprintf('extractor_thumb_%s', $record->get_serialize_key());
|
||||
|
||||
$fileName = sprintf('%s/%s.png', $path, $name);
|
||||
$fileName = sprintf('%s/%s.png', $path, $name);
|
||||
|
||||
file_put_contents($fileName, $dataUri->getData());
|
||||
file_put_contents($fileName, $dataUri->getData());
|
||||
|
||||
$media = $app['mediavorus']->guess($fileName);
|
||||
$media = $app['mediavorus']->guess($fileName);
|
||||
|
||||
$record->substitute_subdef('thumbnail', $media, $app);
|
||||
$record->substitute_subdef('thumbnail', $media, $app);
|
||||
|
||||
unset($media);
|
||||
$app['filesystem']->remove($fileName);
|
||||
unset($media);
|
||||
$app['filesystem']->remove($fileName);
|
||||
|
||||
$return['success'] = true;
|
||||
} catch (\Exception $e) {
|
||||
$return['message'] = $e->getMessage();
|
||||
}
|
||||
$return['success'] = true;
|
||||
} catch (\Exception $e) {
|
||||
$return['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $app->json($return);
|
||||
});
|
||||
return $app->json($return);
|
||||
});
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ class Tooltip implements ControllerProviderInterface
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireAuthentication();
|
||||
|
||||
if($response instanceof Response) {
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
@@ -122,14 +122,13 @@ class Tooltip implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/Tooltip/Caption.html.twig'
|
||||
, array(
|
||||
'record' => $record,
|
||||
'view' => $context,
|
||||
'highlight' => $app['request']->request->get('query'),
|
||||
'searchEngine' => $search_engine,
|
||||
)
|
||||
);
|
||||
'prod/Tooltip/Caption.html.twig'
|
||||
, array(
|
||||
'record' => $record,
|
||||
'view' => $context,
|
||||
'highlight' => $app['request']->request->get('query'),
|
||||
'searchEngine' => $search_engine,
|
||||
));
|
||||
}
|
||||
|
||||
public function displayTechnicalDatas(Application $app, $sbas_id, $record_id)
|
||||
|
@@ -106,13 +106,12 @@ class Upload implements ControllerProviderInterface
|
||||
$maxFileSize = $this->getUploadMaxFileSize();
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/upload/upload-flash.html.twig', array(
|
||||
'sessionId' => session_id(),
|
||||
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
||||
'maxFileSize' => $maxFileSize,
|
||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||
)
|
||||
);
|
||||
'prod/upload/upload-flash.html.twig', array(
|
||||
'sessionId' => session_id(),
|
||||
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
||||
'maxFileSize' => $maxFileSize,
|
||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,12 +127,11 @@ class Upload implements ControllerProviderInterface
|
||||
$maxFileSize = $this->getUploadMaxFileSize();
|
||||
|
||||
return $app['twig']->render(
|
||||
'prod/upload/upload.html.twig', array(
|
||||
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
||||
'maxFileSize' => $maxFileSize,
|
||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||
)
|
||||
);
|
||||
'prod/upload/upload.html.twig', array(
|
||||
'collections' => $this->getGrantedCollections($app['phraseanet.user']),
|
||||
'maxFileSize' => $maxFileSize,
|
||||
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,17 +163,17 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
$base_id = $request->request->get('base_id');
|
||||
|
||||
if ( ! $base_id) {
|
||||
if (!$base_id) {
|
||||
throw new \Exception_BadRequest('Missing base_id parameter');
|
||||
}
|
||||
|
||||
if ( ! $app['phraseanet.user']->ACL()->has_right_on_base($base_id, 'canaddrecord')) {
|
||||
if (!$app['phraseanet.user']->ACL()->has_right_on_base($base_id, 'canaddrecord')) {
|
||||
throw new \Exception_Forbidden('User is not allowed to add record on this collection');
|
||||
}
|
||||
|
||||
$file = current($request->files->get('files'));
|
||||
|
||||
if ( ! $file->isValid()) {
|
||||
if (!$file->isValid()) {
|
||||
throw new \Exception_BadRequest('Uploaded file is invalid');
|
||||
}
|
||||
|
||||
@@ -215,7 +213,7 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
$callback = function($element, $visa, $code) use (&$reasons, &$elementCreated) {
|
||||
foreach ($visa->getResponses() as $response) {
|
||||
if ( ! $response->isOk()) {
|
||||
if (!$response->isOk()) {
|
||||
$reasons[] = $response->getMessage();
|
||||
}
|
||||
}
|
||||
@@ -229,7 +227,7 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
$app['filesystem']->rename($renamedFilename, $uploadedFilename);
|
||||
|
||||
if ( ! ! $forceBehavior) {
|
||||
if (!!$forceBehavior) {
|
||||
$reasons = array();
|
||||
}
|
||||
|
||||
@@ -293,7 +291,7 @@ class Upload implements ControllerProviderInterface
|
||||
|
||||
foreach ($user->ACL()->get_granted_base(array('canaddrecord')) as $collection) {
|
||||
$databox = $collection->get_databox();
|
||||
if ( ! isset($collections[$databox->get_sbas_id()])) {
|
||||
if (!isset($collections[$databox->get_sbas_id()])) {
|
||||
$collections[$databox->get_sbas_id()] = array(
|
||||
'databox' => $databox,
|
||||
'databox_collections' => array()
|
||||
|
@@ -30,7 +30,7 @@ class UserPreferences implements ControllerProviderInterface
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireAuthentication();
|
||||
|
||||
if($response instanceof Response) {
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
|
@@ -179,7 +179,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
);
|
||||
|
||||
try {
|
||||
if ( ! $list_name) {
|
||||
if (!$list_name) {
|
||||
throw new ControllerException(_('List name is required'));
|
||||
}
|
||||
|
||||
@@ -249,15 +249,15 @@ class UsrLists implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
return $app->json(array(
|
||||
'result' => array(
|
||||
'id' => $list->getId(),
|
||||
'name' => $list->getName(),
|
||||
'created' => $list->getCreated()->format(DATE_ATOM),
|
||||
'updated' => $list->getUpdated()->format(DATE_ATOM),
|
||||
'owners' => $owners,
|
||||
'users' => $entries
|
||||
)
|
||||
));
|
||||
'result' => array(
|
||||
'id' => $list->getId(),
|
||||
'name' => $list->getName(),
|
||||
'created' => $list->getCreated()->format(DATE_ATOM),
|
||||
'updated' => $list->getUpdated()->format(DATE_ATOM),
|
||||
'owners' => $owners,
|
||||
'users' => $entries
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public function updateList(Application $app, $list_id)
|
||||
@@ -272,7 +272,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
try {
|
||||
$list_name = $request->request->get('name');
|
||||
|
||||
if ( ! $list_name) {
|
||||
if (!$list_name) {
|
||||
throw new ControllerException(_('List name is required'));
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ class UsrLists implements ControllerProviderInterface
|
||||
$user = $app['phraseanet.user'];
|
||||
|
||||
try {
|
||||
if ( ! is_array($request->request->get('usr_ids'))) {
|
||||
if (!is_array($request->request->get('usr_ids'))) {
|
||||
throw new ControllerException('Invalid or missing parameter usr_ids');
|
||||
}
|
||||
|
||||
@@ -484,9 +484,9 @@ class UsrLists implements ControllerProviderInterface
|
||||
UsrListOwner::ROLE_ADMIN,
|
||||
);
|
||||
|
||||
if ( ! $app['request']->request->get('role'))
|
||||
if (!$app['request']->request->get('role'))
|
||||
throw new \Exception_BadRequest('Missing role parameter');
|
||||
elseif ( ! in_array($app['request']->request->get('role'), $availableRoles))
|
||||
elseif (!in_array($app['request']->request->get('role'), $availableRoles))
|
||||
throw new \Exception_BadRequest('Role is invalid');
|
||||
|
||||
try {
|
||||
|
@@ -32,7 +32,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
$controllers->before(function(Request $request) use ($app) {
|
||||
$response = $app['firewall']->requireAuthentication();
|
||||
|
||||
if($response instanceof Response) {
|
||||
if ($response instanceof Response) {
|
||||
return $response;
|
||||
}
|
||||
});
|
||||
@@ -121,7 +121,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
public function attachStories(Application $app, Request $request)
|
||||
{
|
||||
if ( ! $request->request->get('stories')) {
|
||||
if (!$request->request->get('stories')) {
|
||||
throw new \Exception_BadRequest();
|
||||
}
|
||||
|
||||
@@ -137,16 +137,16 @@ class WorkZone implements ControllerProviderInterface
|
||||
$element = explode('_', $element);
|
||||
$Story = new \record_adapter($app, $element[0], $element[1]);
|
||||
|
||||
if ( ! $Story->is_grouping()) {
|
||||
if (!$Story->is_grouping()) {
|
||||
throw new \Exception('You can only attach stories');
|
||||
}
|
||||
|
||||
if ( ! $user->ACL()->has_access_to_base($Story->get_base_id())) {
|
||||
if (!$user->ACL()->has_access_to_base($Story->get_base_id())) {
|
||||
throw new \Exception_Forbidden('You do not have access to this Story');
|
||||
}
|
||||
|
||||
if ($StoryWZRepo->findUserStory($app, $user, $Story)) {
|
||||
$alreadyFixed ++;
|
||||
$alreadyFixed++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
$StoryWZ->setRecord($Story);
|
||||
|
||||
$app['EM']->persist($StoryWZ);
|
||||
$done ++;
|
||||
$done++;
|
||||
}
|
||||
|
||||
$app['EM']->flush();
|
||||
@@ -190,9 +190,9 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
return $app->json(array(
|
||||
'success' => true
|
||||
, 'message' => $message
|
||||
));
|
||||
'success' => true
|
||||
, 'message' => $message
|
||||
));
|
||||
}
|
||||
|
||||
return $app->redirect('/{sbas_id}/{record_id}/');
|
||||
@@ -209,7 +209,7 @@ class WorkZone implements ControllerProviderInterface
|
||||
/* @var $repository \Repositories\StoryWZRepository */
|
||||
$StoryWZ = $repository->findUserStory($app, $user, $Story);
|
||||
|
||||
if ( ! $StoryWZ) {
|
||||
if (!$StoryWZ) {
|
||||
throw new \Exception_NotFound('Story not found');
|
||||
}
|
||||
|
||||
@@ -218,9 +218,9 @@ class WorkZone implements ControllerProviderInterface
|
||||
|
||||
if ($request->getRequestFormat() == 'json') {
|
||||
return $app->json(array(
|
||||
'success' => true
|
||||
, 'message' => _('Story detached from the WorkZone')
|
||||
));
|
||||
'success' => true
|
||||
, 'message' => _('Story detached from the WorkZone')
|
||||
));
|
||||
}
|
||||
|
||||
return $app->redirect('/');
|
||||
|
Reference in New Issue
Block a user