diff --git a/lib/Alchemy/Phrasea/Application/Root.php b/lib/Alchemy/Phrasea/Application/Root.php index 19c06ac839..d985ae8e64 100644 --- a/lib/Alchemy/Phrasea/Application/Root.php +++ b/lib/Alchemy/Phrasea/Application/Root.php @@ -65,175 +65,175 @@ use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; return call_user_func(function($environment = null) { - $app = new PhraseaApplication($environment); + $app = new PhraseaApplication($environment); - $app->before(function () use ($app) { - $app['firewall']->requireSetup(); - }); + $app->before(function () use ($app) { + $app['firewall']->requireSetup(); + }); - $app->before(function(Request $request) use ($app) { - if ($request->cookies->has('persistent') && !$app->isAuthenticated()) { - try { - $auth = new \Session_Authentication_PersistentCookie($app, $request->cookies->get('persistent')); - $app->openAccount($auth, $auth->getSessionId()); - } catch (\Exception $e) { + $app->before(function(Request $request) use ($app) { + if ($request->cookies->has('persistent') && !$app->isAuthenticated()) { + try { + $auth = new \Session_Authentication_PersistentCookie($app, $request->cookies->get('persistent')); + $app->openAccount($auth, $auth->getSessionId()); + } catch (\Exception $e) { - } } - }); + } + }); - $app->get('/', function(PhraseaApplication $app) { - if ($app['browser']->isMobile()) { - return $app->redirect("/login/?redirect=lightbox"); - } elseif ($app['browser']->isNewGeneration()) { - return $app->redirect("/login/?redirect=prod"); + $app->get('/', function(PhraseaApplication $app) { + if ($app['browser']->isMobile()) { + return $app->redirect("/login/?redirect=lightbox"); + } elseif ($app['browser']->isNewGeneration()) { + return $app->redirect("/login/?redirect=prod"); + } else { + return $app->redirect("/login/?redirect=client"); + } + }); + + $app->get('/robots.txt', function(PhraseaApplication $app) { + + if ($app['phraseanet.registry']->get('GV_allow_search_engine') === true) { + $buffer = "User-Agent: *\n" . "Allow: /\n"; + } else { + $buffer = "User-Agent: *\n" . "Disallow: /\n"; + } + + return new Response($buffer, 200, array('Content-Type' => 'text/plain')); + })->bind('robots'); + + $app->mount('/feeds/', new RSSFeeds()); + $app->mount('/account/', new Account()); + $app->mount('/login/', new Login()); + $app->mount('/developers/', new Developers()); + $app->mount('/lightbox/', new Lightbox()); + + $app->mount('/datafiles/', new Datafiles()); + $app->mount('/permalink/', new Permalink()); + + $app->mount('/admin/', new Root()); + $app->mount('/admin/dashboard', new Dashboard()); + $app->mount('/admin/collection', new Collection()); + $app->mount('/admin/databox', new Databox()); + $app->mount('/admin/databoxes', new Databoxes()); + $app->mount('/admin/setup', new Setup()); + $app->mount('/admin/sphinx', new Sphinx()); + $app->mount('/admin/connected-users', new ConnectedUsers()); + $app->mount('/admin/publications', new Publications()); + $app->mount('/admin/users', new Users()); + $app->mount('/admin/fields', new Fields()); + $app->mount('/admin/task-manager', new TaskManager()); + $app->mount('/admin/subdefs', new Subdefs()); + $app->mount('/admin/description', new Description()); + $app->mount('/admin/tests/connection', new ConnectionTest()); + $app->mount('/admin/tests/pathurl', new PathFileTest()); + + $app->mount('/prod/query/', new Query()); + $app->mount('/prod/order/', new Order()); + $app->mount('/prod/baskets', new Basket()); + $app->mount('/prod/story', new Story()); + $app->mount('/prod/WorkZone', new WorkZone()); + $app->mount('/prod/lists', new UsrLists()); + $app->mount('/prod/MustacheLoader', new MustacheLoader()); + $app->mount('/prod/records/edit', new Edit()); + $app->mount('/prod/records/property', new Property()); + $app->mount('/prod/records/movecollection', new MoveCollection()); + $app->mount('/prod/bridge/', new Bridge()); + $app->mount('/prod/push/', new Push()); + $app->mount('/prod/printer/', new Printer()); + $app->mount('/prod/share/', new Share()); + $app->mount('/prod/export/', new Export()); + $app->mount('/prod/TOU/', new TOU()); + $app->mount('/prod/feeds', new Feed()); + $app->mount('/prod/tooltip', new Tooltip()); + $app->mount('/prod/language', new Language()); + $app->mount('/prod/tools/', new Tools()); + $app->mount('/prod/lazaret/', new Lazaret()); + $app->mount('/prod/upload/', new Upload()); + $app->mount('/prod/share/', new Share()); + $app->mount('/prod/', new Prod()); + + $app->mount('/user/preferences/', new Preferences()); + $app->mount('/user/notifications/', new Notifications()); + + $app->error(function(\Exception $e) use ($app) { + $request = $app['request']; + + if ($e instanceof \Bridge_Exception) { + $params = array( + 'message' => $e->getMessage() + , 'file' => $e->getFile() + , 'line' => $e->getLine() + , 'r_method' => $request->getMethod() + , 'r_action' => $request->getRequestUri() + , 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all()) + ); + + if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) { + $params = array_merge($params, array('account' => $app['current_account'])); + + $response = new Response($app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, array('X-Status-Code' => 200)); + } elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) { + $params = array_merge($params, array('account' => $app['current_account'])); + + $response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); + } elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) { + $params = array_merge($params, array('account' => $app['current_account'])); + + $response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); + } elseif ($e instanceof \Bridge_Exception_ApiDisabled) { + $params = array_merge($params, array('api' => $e->get_api())); + + $response = new Response($app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, array('X-Status-Code' => 200)); } else { - return $app->redirect("/login/?redirect=client"); - } - }); - - $app->get('/robots.txt', function(PhraseaApplication $app) { - - if ($app['phraseanet.registry']->get('GV_allow_search_engine') === true) { - $buffer = "User-Agent: *\n" . "Allow: /\n"; - } else { - $buffer = "User-Agent: *\n" . "Disallow: /\n"; + $response = new Response($app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, array('X-Status-Code' => 200)); } - return new Response($buffer, 200, array('Content-Type' => 'text/plain')); - })->bind('robots'); + $response->headers->set('Phrasea-StatusCode', 200); - $app->mount('/feeds/', new RSSFeeds()); - $app->mount('/account/', new Account()); - $app->mount('/login/', new Login()); - $app->mount('/developers/', new Developers()); - $app->mount('/lightbox/', new Lightbox()); + return $response; + } - $app->mount('/datafiles/', new Datafiles()); - $app->mount('/permalink/', new Permalink()); + if ($request->getRequestFormat() == 'json') { + $datas = array( + 'success' => false + , 'message' => $e->getMessage() + ); - $app->mount('/admin/', new Root()); - $app->mount('/admin/dashboard', new Dashboard()); - $app->mount('/admin/collection', new Collection()); - $app->mount('/admin/databox', new Databox()); - $app->mount('/admin/databoxes', new Databoxes()); - $app->mount('/admin/setup', new Setup()); - $app->mount('/admin/sphinx', new Sphinx()); - $app->mount('/admin/connected-users', new ConnectedUsers()); - $app->mount('/admin/publications', new Publications()); - $app->mount('/admin/users', new Users()); - $app->mount('/admin/fields', new Fields()); - $app->mount('/admin/task-manager', new TaskManager()); - $app->mount('/admin/subdefs', new Subdefs()); - $app->mount('/admin/description', new Description()); - $app->mount('/admin/tests/connection', new ConnectionTest()); - $app->mount('/admin/tests/pathurl', new PathFileTest()); + return $app->json($datas, 200, array('X-Status-Code' => 200)); + } - $app->mount('/prod/query/', new Query()); - $app->mount('/prod/order/', new Order()); - $app->mount('/prod/baskets', new Basket()); - $app->mount('/prod/story', new Story()); - $app->mount('/prod/WorkZone', new WorkZone()); - $app->mount('/prod/lists', new UsrLists()); - $app->mount('/prod/MustacheLoader', new MustacheLoader()); - $app->mount('/prod/records/edit', new Edit()); - $app->mount('/prod/records/property', new Property()); - $app->mount('/prod/records/movecollection', new MoveCollection()); - $app->mount('/prod/bridge/', new Bridge()); - $app->mount('/prod/push/', new Push()); - $app->mount('/prod/printer/', new Printer()); - $app->mount('/prod/share/', new Share()); - $app->mount('/prod/export/', new Export()); - $app->mount('/prod/TOU/', new TOU()); - $app->mount('/prod/feeds', new Feed()); - $app->mount('/prod/tooltip', new Tooltip()); - $app->mount('/prod/language', new Language()); - $app->mount('/prod/tools/', new Tools()); - $app->mount('/prod/lazaret/', new Lazaret()); - $app->mount('/prod/upload/', new Upload()); - $app->mount('/prod/share/', new Share()); - $app->mount('/prod/', new Prod()); + if ($e instanceof HttpExceptionInterface) { + $headers = $e->getHeaders(); - $app->mount('/user/preferences/', new Preferences()); - $app->mount('/user/notifications/', new Notifications()); - - $app->error(function(\Exception $e) use ($app) { - $request = $app['request']; - - if ($e instanceof \Bridge_Exception) { - $params = array( - 'message' => $e->getMessage() - , 'file' => $e->getFile() - , 'line' => $e->getLine() - , 'r_method' => $request->getMethod() - , 'r_action' => $request->getRequestUri() - , 'r_parameters' => ($request->getMethod() == 'GET' ? array() : $request->request->all()) - ); - - if ($e instanceof \Bridge_Exception_ApiConnectorNotConfigured) { - $params = array_merge($params, array('account' => $app['current_account'])); - - $response = new Response($app['twig']->render('/prod/actions/Bridge/notconfigured.html.twig', $params), 200, array('X-Status-Code' => 200)); - } elseif ($e instanceof \Bridge_Exception_ApiConnectorNotConnected) { - $params = array_merge($params, array('account' => $app['current_account'])); - - $response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); - } elseif ($e instanceof \Bridge_Exception_ApiConnectorAccessTokenFailed) { - $params = array_merge($params, array('account' => $app['current_account'])); - - $response = new Response($app['twig']->render('/prod/actions/Bridge/disconnected.html.twig', $params), 200, array('X-Status-Code' => 200)); - } elseif ($e instanceof \Bridge_Exception_ApiDisabled) { - $params = array_merge($params, array('api' => $e->get_api())); - - $response = new Response($app['twig']->render('/prod/actions/Bridge/deactivated.html.twig', $params), 200, array('X-Status-Code' => 200)); - } else { - $response = new Response($app['twig']->render('/prod/actions/Bridge/error.html.twig', $params), 200, array('X-Status-Code' => 200)); - } - - $response->headers->set('Phrasea-StatusCode', 200); - - return $response; + if (isset($headers['X-Phraseanet-Redirect'])) { + return new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, array('X-Status-Code' => 302)); } + } - if ($request->getRequestFormat() == 'json') { - $datas = array( - 'success' => false - , 'message' => $e->getMessage() - ); + if ($e instanceof \Exception_BadRequest) { + return new Response('Bad Request', 400, array('X-Status-Code' => 400)); + } + if ($e instanceof \Exception_Forbidden) { + return new Response('Forbidden', 403, array('X-Status-Code' => 403)); + } - return $app->json($datas, 200, array('X-Status-Code' => 200)); - } + if ($e instanceof \Exception_Session_NotAuthenticated) { + $code = 403; + $message = 'Forbidden'; + } elseif ($e instanceof \Exception_NotAllowed) { + $code = 403; + $message = 'Forbidden'; + } elseif ($e instanceof \Exception_NotFound) { + $code = 404; + $message = 'Not Found'; + } else { + throw $e; + } - if ($e instanceof HttpExceptionInterface) { - $headers = $e->getHeaders(); + return new Response($message, $code, array('X-Status-Code' => $code)); + }); - if (isset($headers['X-Phraseanet-Redirect'])) { - return new RedirectResponse($headers['X-Phraseanet-Redirect'], 302, array('X-Status-Code' => 302)); - } - } - - if ($e instanceof \Exception_BadRequest) { - return new Response('Bad Request', 400, array('X-Status-Code' => 400)); - } - if ($e instanceof \Exception_Forbidden) { - return new Response('Forbidden', 403, array('X-Status-Code' => 403)); - } - - if ($e instanceof \Exception_Session_NotAuthenticated) { - $code = 403; - $message = 'Forbidden'; - } elseif ($e instanceof \Exception_NotAllowed) { - $code = 403; - $message = 'Forbidden'; - } elseif ($e instanceof \Exception_NotFound) { - $code = 404; - $message = 'Not Found'; - } else { - throw $e; - } - - return new Response($message, $code, array('X-Status-Code' => $code)); - }); - - return $app; - }, isset($environment) ? $environment : null); + return $app; +}, isset($environment) ? $environment : null); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index 5ab679fd20..530b8b685d 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -200,7 +200,7 @@ class Export implements ControllerProviderInterface return $app->json(array( 'success' => false, - 'message' => _('Something went wrong') . $e->getMessage() + 'message' => _('Something went wrong') )); } } @@ -219,11 +219,14 @@ class Export implements ControllerProviderInterface session_write_close(); ignore_user_abort(true); + $lst = $request->request->get('lst', ''); + $ssttid = $request->request->get('ssttid', ''); + //prepare export - $download = new \set_export($app, $request->get('lst', ''), $request->get('ssttid', '')); - $list = $download->prepare_export($app['phraseanet.user'], $app['filesystem'], $request->get('obj'), $request->get("type") == "title" ? : false, $request->get('businessfields')); + $download = new \set_export($app, $lst, $ssttid); + $list = $download->prepare_export($app['phraseanet.user'], $app['filesystem'], $request->request->get('obj'), $request->request->get("type") == "title" ? : false, $request->request->get('businessfields')); $list['export_name'] = sprintf("%s.zip", $download->getExportName()); - $list['email'] = $request->get("destmail", ""); + $list['email'] = $request->request->get("destmail", ""); $destMails = array(); //get destination mails @@ -233,8 +236,8 @@ class Export implements ControllerProviderInterface } else { $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( 'usr_id' => $app['phraseanet.user']->get_id(), - 'lst' => $request->get('lst', ''), - 'ssttid' => $request->get('ssttid', ''), + 'lst' => $lst, + 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => \eventsmanager_notify_downloadmailfail::MAIL_NO_VALID )); @@ -260,7 +263,7 @@ class Export implements ControllerProviderInterface //send mails foreach ($destMails as $key => $mail) { - if (\mail::send_documents($app, trim($mail), $url, $from, $endDateObject, $request->get('textmail'), $request->get('reading_confirm') == '1' ? : false)) { + if (\mail::send_documents($app, trim($mail), $url, $from, $endDateObject, $request->request->get('textmail'), $request->request->get('reading_confirm') == '1' ? : false)) { unset($remaingEmails[$key]); } } @@ -270,8 +273,8 @@ class Export implements ControllerProviderInterface foreach ($remaingEmails as $mail) { $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( 'usr_id' => $app['phraseanet.user']->get_id(), - 'lst' => $request->get('lst', ''), - 'ssttid' => $request->get('ssttid', ''), + 'lst' => $lst, + 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => \eventsmanager_notify_downloadmailfail::MAIL_FAIL )); @@ -281,8 +284,8 @@ class Export implements ControllerProviderInterface foreach ($destMails as $mail) { $app['events-manager']->trigger('__EXPORT_MAIL_FAIL__', array( 'usr_id' => $app['phraseanet.user']->get_id(), - 'lst' => $request->get('lst', ''), - 'ssttid' => $request->get('ssttid', ''), + 'lst' => $lst, + 'ssttid' => $ssttid, 'dest' => $mail, 'reason' => 0 )); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 9155a8cbe7..97464cf85e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -101,7 +101,7 @@ class Query implements ControllerProviderInterface $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($app['phraseanet.user']->ACL()->get_granted_base()); if ($app['phraseanet.user']->ACL()->has_right('modifyrecord')) { $options->set_business_fields(array()); @@ -279,7 +279,7 @@ class Query implements ControllerProviderInterface $searchEngine->set_options($options); } - $pos = $request->request->get('pos'); + $pos = (int) $request->request->get('pos'); $query = $request->request->get('query', ''); $record = new \record_preview($app, 'RESULT', $pos, '', '', $searchEngine, $query); diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Record/Property.php b/lib/Alchemy/Phrasea/Controller/Prod/Record/Property.php index 8669f14da8..d536553f89 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Record/Property.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Record/Property.php @@ -34,10 +34,7 @@ class Property implements ControllerProviderInterface $controllers = $app['controllers_factory']; $controllers->before(function(Request $request) use ($app) { - $response = $app['firewall']->requireNotGuest(); - if ($response instanceof Response) { - return $response; - } + $app['firewall']->requireNotGuest(); }); /** diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Records.php b/lib/Alchemy/Phrasea/Controller/Prod/Records.php new file mode 100644 index 0000000000..ad2e4ced10 --- /dev/null +++ b/lib/Alchemy/Phrasea/Controller/Prod/Records.php @@ -0,0 +1,182 @@ +before(function(Request $request) use ($app) { + $response = $app['firewall']->requireNotGuest(); + if ($response instanceof Response) { + return $response; + } + }); + + /** + * Delete a record or a list of records + * + * name : record_delete + * + * description : Delete a record or a list of records + * + * method : POST + * + * parameters : none + * + * return : JSON Response + */ + $controllers->post('/', $this->call('deleteRecord')) + ->bind('record_delete'); + + /** + * Verify if I can delete records + * + * name : record_what_can_i_delete + * + * description : Save CSS preferences + * + * method : POST + * + * parameters : none + * + * return : JSON Response + */ + $controllers->get('/', $this->call('whatCanIDelete')) + ->bind('record_what_can_i_delete'); + + /** + * Renew a record URL + * + * name : record_renew_url + * + * description : Renew a record URL + * + * method : POST + * + * parameters : none + * + * return : JSON Response + */ + $controllers->post('/renew-url/', $this->call('renewUrl')) + ->bind('record_renew_url'); + + return $controllers; + } + + /** + * Delete a record or a list of records + * + * @param Application $app + * @param Request $request + * @return HtmlResponse + */ + public function deleteRecord(Application $app, Request $request) + { + $records = RecordsRequest::fromRequest($app, $request, !!$app->request->get('del_children'), array( + 'candeleterecord' + )); + + $basketElementsRepository = $app['EM']->getRepository('\Entities\BasketElement'); + $deleted = array(); + + foreach ($records as $record) { + try { + $basketElements = $basketElementsRepository->findElementsByRecord($record); + + foreach ($basketElements as $element) { + $app['EM']->remove($element); + $deleted[] = $element->getRecord($app)->get_serialize_key(); + } + + $record->delete(); + $deleted[] = $record->get_serialize_key(); + } catch (\Exception $e) { + + } + } + + $app['EM']->flush(); + + return $app->json($deleted); + } + + /** + * Delete a record or a list of records + * + * @param Application $app + * @param Request $request + * @return JsonResponse + */ + public function whatICanDelete(Application $app, Request $request) + { + $records = RecordsRequest::fromRequest($app, $request, !!$app->request->get('del_children'), array( + 'candeleterecord' + )); + + return $app['twig']->render('prod/actions/delete_records_confirm.html.twig', array( + 'lst' => explode(';', $records->serializedList()), + 'groupings' => $records->stories()->count(), + )); + } + + /** + * Renew url list of records + * + * @param Application $app + * @param Request $request + * @param integer $databox_id + * @param integer $record_id + * @return JsonResponse + */ + public function renewUrl(Application $app, Request $request) + { + $records = RecordsRequest::fromRequest($app, $request, !!$app->request->get('renew_children_url')); + + $renewed = array(); + foreach ($records as $record) { + $renewed[] = array( + $record->get_serialized_key() => $record->get_preview()->renew_url(), + ); + }; + + return $app->json($renewed); + } + + /** + * Prefix the method to call with the controller class name + * + * @param string $method The method to call + * @return string + */ + private function call($method) + { + return sprintf('%s::%s', __CLASS__, $method); + } +} diff --git a/lib/Alchemy/Phrasea/Controller/User/Notifications.php b/lib/Alchemy/Phrasea/Controller/User/Notifications.php index 4fce2b5a37..923b337612 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Notifications.php +++ b/lib/Alchemy/Phrasea/Controller/User/Notifications.php @@ -82,12 +82,12 @@ class Notifications implements ControllerProviderInterface if (!$request->isXmlHttpRequest()) { $app->abort(400); } - + try { $app['events-manager']->read(explode('_', (string) $request->request->get('notifications')), $app['phraseanet.user']->get_id()); return $app->json(array('success' => true, 'message' => '')); - } catch (Exception $e) { + } catch (\Exception $e) { return $app->json(array('success' => false, 'message' => $e->getMessage())); } diff --git a/lib/Alchemy/Phrasea/Controller/User/Preferences.php b/lib/Alchemy/Phrasea/Controller/User/Preferences.php index f98efbfd9d..f3ec8371d4 100644 --- a/lib/Alchemy/Phrasea/Controller/User/Preferences.php +++ b/lib/Alchemy/Phrasea/Controller/User/Preferences.php @@ -16,11 +16,6 @@ use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; -/** - * - * @license http://opensource.org/licenses/gpl-3.0 GPLv3 - * @link www.phraseanet.com - */ class Preferences implements ControllerProviderInterface { @@ -85,13 +80,15 @@ class Preferences implements ControllerProviderInterface $prop = $request->request->get('prop'); $value = $request->request->get('value'); $success = false; + $msg = _('Error while saving preference'); if ($prop && $value) { $app['session']->set('pref.' . $prop, $value); $success = true; + $msg = _('Preference saved !'); } - return new JsonResponse(array('success' => $success)); + return new JsonResponse(array('success' => $success, 'message' => $msg)); } /** diff --git a/templates/web/prod/Share/record.html.twig b/templates/web/prod/Share/record.html.twig index 9442eb2744..72c0f988bc 100644 --- a/templates/web/prod/Share/record.html.twig +++ b/templates/web/prod/Share/record.html.twig @@ -1,79 +1,76 @@ {% set preview = record.get_preview()%} -{% set permalink = preview.get_permalink() %} {% if preview is iterable %}

{% trans 'No preview available.' %}

-{% elseif permalink is none %} +{% elseif preview.get_permalink() is none %}

{% trans 'No permalink available.' %}

{% else %} {% set type = record.get_type() %} - {% set url = permalink.get_url() %} -
- -
+ {% set url = preview.get_permalink().get_url() %} -
{% trans 'boutton::fermer' %} ?>
- -
-
URL :
- {% if url is not empty %} - -
Embed :
- -
- {% else %} -
<{% trans 'Aucune URL disponible' %}
- {% endif %} + {% if url is not empty %} +
+ +
+ +
+
URL :
-
- + +
Embed :
+ +
+
+ +
-
- + + {% else %} +
<{% trans 'Aucune URL disponible' %}
+ {% endif %} {% endif %} diff --git a/tests/Alchemy/Phrasea/Controller/Prod/QueryTest.php b/tests/Alchemy/Phrasea/Controller/Prod/QueryTest.php index cbb9863ffc..5a9009f6ff 100644 --- a/tests/Alchemy/Phrasea/Controller/Prod/QueryTest.php +++ b/tests/Alchemy/Phrasea/Controller/Prod/QueryTest.php @@ -14,11 +14,11 @@ class QueryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract */ public function testQueryAnswerTrain() { - $this->markTestSkipped('Unable to create phrasea session'); +// $this->markTestSkipped('Unable to create phrasea session'); //populate phrasea_session - $auth = new \Session_Authentication_None(self::$DI['user']); - self::$DI['app']->openAccount($auth); +// $auth = new \Session_Authentication_None(self::$DI['user']); +// self::$DI['app']->openAccount($auth); $query = new Query(); $options = new \searchEngine_options(); diff --git a/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php b/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php index b273b134f7..2d0df8aba7 100644 --- a/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php +++ b/tests/Alchemy/Phrasea/Controller/Root/RSSFeedTest.php @@ -273,7 +273,6 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract public function testGetFeedFormat() { - $this->markTestSkipped(''); $feeds = Feed_Collection::load_public_feeds(self::$DI['app']); $all_feeds = $feeds->get_feeds(); $feed = array_shift($all_feeds); diff --git a/tests/PhraseanetPHPUnitAbstract.class.inc b/tests/PhraseanetPHPUnitAbstract.class.inc index 38ae9b3d1e..8965c79c5c 100644 --- a/tests/PhraseanetPHPUnitAbstract.class.inc +++ b/tests/PhraseanetPHPUnitAbstract.class.inc @@ -109,36 +109,36 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase self::$DI['app'] = self::$DI->share(function($DI) { - $environment = 'test'; - $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php'; + $environment = 'test'; + $app = require __DIR__ . '/../lib/Alchemy/Phrasea/Application/Root.php'; - $app['debug'] = true; + $app['debug'] = true; - if (!$DI['app.use-exception-handler']) { - unset($app['exception_handler']); - } + if (!$DI['app.use-exception-handler']) { + unset($app['exception_handler']); + } - $app['EM'] = $app->share($app->extend('EM', function($em) { - @unlink('/tmp/db.sqlite'); - copy(__DIR__ . '/db-ref.sqlite', '/tmp/db.sqlite'); + $app['EM'] = $app->share($app->extend('EM', function($em) { + @unlink('/tmp/db.sqlite'); + copy(__DIR__ . '/db-ref.sqlite', '/tmp/db.sqlite'); - return $em; - })); + return $em; + })); - $app['browser'] = $app->share($app->extend('browser', function($browser) { + $app['browser'] = $app->share($app->extend('browser', function($browser) { - $browser->setUserAgent(PhraseanetPHPUnitAbstract::USER_AGENT_FIREFOX8MAC); - return $browser; - })); + $browser->setUserAgent(PhraseanetPHPUnitAbstract::USER_AGENT_FIREFOX8MAC); + return $browser; + })); - return $app; - }); + return $app; + }); self::$DI['client'] = self::$DI->share(function($DI) { - return new Client($DI['app'], array()); - }); + return new Client($DI['app'], array()); + }); } public function tearDown() @@ -177,8 +177,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $executor = new Doctrine\Common\DataFixtures\Executor\ORMExecutor(self::$DI['app']['EM'], $purger); $executor->execute($fixtureLoader->getFixtures(), $append); self::$DI['client'] = self::$DI->share(function($DI) { - return new Client($DI['app'], array()); - }); + return new Client($DI['app'], array()); + }); } /** @@ -203,8 +203,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $app->register(new \Silex\Provider\TwigServiceProvider()); $app->setupTwig(); self::$DI['client'] = self::$DI->share(function($DI) use($app) { - return new Client($app, array()); - }); + return new Client($app, array()); + }); } /** @@ -549,50 +549,50 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase private static function createSetOfUserTests(Application $application) { self::$DI['user'] = self::$DI->share(function ($DI) use ($application) { - $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit'); + $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit'); - if (!$usr_id) { - $user = User_Adapter::create($application, 'test_phpunit', random::generatePassword(), 'noone@example.com', false); - $usr_id = $user->get_id(); - } + if (!$usr_id) { + $user = User_Adapter::create($application, 'test_phpunit', random::generatePassword(), 'noone@example.com', false); + $usr_id = $user->get_id(); + } - $user = User_Adapter::getInstance($usr_id, $application); + $user = User_Adapter::getInstance($usr_id, $application); - return $user; - }); + return $user; + }); self::$DI['user_notAdmin'] = self::$DI->share(function () use ($application) { - $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_not_admin'); + $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_not_admin'); - if (!$usr_id) { - $user = User_Adapter::create($application, 'test_phpunit_not_admin', random::generatePassword(), 'noone_not_admin@example.com', false); - $usr_id = $user->get_id(); - } + if (!$usr_id) { + $user = User_Adapter::create($application, 'test_phpunit_not_admin', random::generatePassword(), 'noone_not_admin@example.com', false); + $usr_id = $user->get_id(); + } - return User_Adapter::getInstance($usr_id, $application); - }); + return User_Adapter::getInstance($usr_id, $application); + }); self::$DI['user_alt1'] = self::$DI->share(function () use ($application) { - $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt1'); + $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt1'); - if (!$usr_id) { - $user = User_Adapter::create($application, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false); - $usr_id = $user->get_id(); - } + if (!$usr_id) { + $user = User_Adapter::create($application, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false); + $usr_id = $user->get_id(); + } - return User_Adapter::getInstance($usr_id, $application); - }); + return User_Adapter::getInstance($usr_id, $application); + }); self::$DI['user_alt2'] = self::$DI->share(function () use ($application) { - $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt2'); + $usr_id = User_Adapter::get_usr_id_from_login($application, 'test_phpunit_alt2'); - if (!$usr_id) { - $user = User_Adapter::create($application, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false); - $usr_id = $user->get_id(); - } + if (!$usr_id) { + $user = User_Adapter::create($application, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false); + $usr_id = $user->get_id(); + } - return User_Adapter::getInstance($usr_id, $application); - }); + return User_Adapter::getInstance($usr_id, $application); + }); } /** @@ -683,41 +683,40 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase self::$DI['collection'] = $coll; self::$DI['collection_no_access'] = self::$DI->share(function($DI) use ($application, $databox, $collection_no_acces) { - if (!$collection_no_acces instanceof collection) { - $collection_no_acces = collection::create($application, $databox, $application['phraseanet.appbox'], 'BIBOO', $DI['user']); - } + if (!$collection_no_acces instanceof collection) { + $collection_no_acces = collection::create($application, $databox, $application['phraseanet.appbox'], 'BIBOO', $DI['user']); + } - $DI['user'] = $DI->share( - $DI->extend('user', function ($user, $DI) use ($collection_no_acces) { - $user->ACL()->revoke_access_from_bases(array($collection_no_acces->get_base_id())); - $DI['client'] = new Client($DI['app'], array()); - return $user; - }) - ); + $DI['user'] = $DI->share( + $DI->extend('user', function ($user, $DI) use ($collection_no_acces) { + $user->ACL()->revoke_access_from_bases(array($collection_no_acces->get_base_id())); + $DI['client'] = new Client($DI['app'], array()); + return $user; + }) + ); - $DI['user']; + $DI['user']; - return $collection_no_acces; - }); + return $collection_no_acces; + }); self::$DI['collection_no_access_by_status'] = self::$DI->share(function($DI) use ($application, $databox, $collection_no_acces_by_status) { - if (!$collection_no_acces_by_status instanceof collection) { - $collection_no_acces_by_status = collection::create($application, $databox, $application['phraseanet.appbox'], 'BIBOONOACCESBYSTATUS', $DI['user']); - } + if (!$collection_no_acces_by_status instanceof collection) { + $collection_no_acces_by_status = collection::create($application, $databox, $application['phraseanet.appbox'], 'BIBOONOACCESBYSTATUS', $DI['user']); + } - $DI['user'] = $DI->share( - $DI->extend('user', function ($user, $DI) use ($collection_no_acces_by_status) { - $user->ACL()->set_masks_on_base($collection_no_acces_by_status->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); - $DI['client'] = new Client($DI['app'], array()); - return $user; - }) - ); + $DI['user'] = $DI->share( + $DI->extend('user', function ($user, $DI) use ($collection_no_acces_by_status) { + $user->ACL()->set_masks_on_base($collection_no_acces_by_status->get_base_id(), '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000', '0000000000000000000000000000000000000000000000000001000000000000'); + $DI['client'] = new Client($DI['app'], array()); + return $user; + }) + ); - $DI['user']; - - return $collection_no_acces_by_status; - }); + $DI['user']; + return $collection_no_acces_by_status; + }); return; } @@ -734,74 +733,75 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase self::$recordsInitialized = array(); $resolvePathfile = function($i) { - $finder = new Symfony\Component\Finder\Finder(); + $finder = new Symfony\Component\Finder\Finder(); - $name = $i < 10 ? 'test00' . $i . '.*' : 'test0' . $i . '.*'; + $name = $i < 10 ? 'test00' . $i . '.*' : 'test0' . $i . '.*'; - $finder->name($name)->in(__DIR__ . '/testfiles/'); + $finder->name($name)->in(__DIR__ . '/testfiles/'); - foreach ($finder as $file) { - return $file; - } + foreach ($finder as $file) { + return $file; + } - throw new Exception(sprintf('File %d not found', $i)); - }; + throw new Exception(sprintf('File %d not found', $i)); + }; foreach (range(1, 24) as $i) { self::$DI['record_' . $i] = self::$DI->share(function($DI) use ($logger, $resolvePathfile, $i) { - PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i; + PhraseanetPHPUnitAbstract::$recordsInitialized[] = $i; - $file = new File($DI['app'], $DI['app']['mediavorus']->guess($resolvePathfile($i)->getPathname()), $DI['collection']); + $file = new File($DI['app'], $DI['app']['mediavorus']->guess($resolvePathfile($i)->getPathname()), $DI['collection']); - $record = record_adapter::createFromFile($file, $DI['app']); + $record = record_adapter::createFromFile($file, $DI['app']); - $record->generate_subdefs($record->get_databox(), $DI['app']); + $record->generate_subdefs($record->get_databox(), $DI['app']); - return $record; - }); + return $record; + }); } + foreach (range(1, 2) as $i) { self::$DI['record_story_' . $i] = self::$DI->share(function($DI) use ($i) { - PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'story_' . $i; + PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'story_' . $i; - return record_adapter::createStory($DI['app'], $DI['collection']); - }); + return record_adapter::createStory($DI['app'], $DI['collection']); + }); } self::$DI['record_no_access'] = self::$DI->share(function($DI) { - PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access'; + PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access'; - $file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']); + $file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']); - return \record_adapter::createFromFile($file, $DI['app']); - }); + return \record_adapter::createFromFile($file, $DI['app']); + }); self::$DI['record_no_access_by_status'] = self::$DI->share(function($DI) { - PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access_by_status'; + PhraseanetPHPUnitAbstract::$recordsInitialized[] = 'no_access_by_status'; - $file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']); + $file = new File($DI['app'], $DI['app']['mediavorus']->guess(__DIR__ . '/testfiles/cestlafete.jpg'), $DI['collection_no_access']); - return \record_adapter::createFromFile($file, $DI['app']); - }); + return \record_adapter::createFromFile($file, $DI['app']); + }); self::$DI['user'] = self::$DI->share( self::$DI->extend('user', function ($user, $DI) use ($app) { - PhraseanetPHPUnitAbstract::giveRightsToUser($app, $user); - $user->ACL()->set_admin(true); - return $user; - }) + PhraseanetPHPUnitAbstract::giveRightsToUser($app, $user); + $user->ACL()->set_admin(true); + return $user; + }) ); self::$DI['user_notAdmin'] = self::$DI->share( self::$DI->extend('user_notAdmin', function ($user, $DI) use ($app) { - PhraseanetPHPUnitAbstract::giveRightsToUser($app, $user); - $user->ACL()->set_admin(false); - return $user; - }) + PhraseanetPHPUnitAbstract::giveRightsToUser($app, $user); + $user->ACL()->set_admin(false); + return $user; + }) ); } diff --git a/www/prod/page0.js b/www/prod/page0.js index f5517f46f2..b062fb05ba 100644 --- a/www/prod/page0.js +++ b/www/prod/page0.js @@ -1703,31 +1703,6 @@ function chgCollThis(datas) }); } -//function chgStatusThis(url) -//{ -// url = "docfunction.php?"+url; -// $('#MODALDL').attr('src','about:blank'); -// $('#MODALDL').attr('src',url); -// -// -// var t = (bodySize.y - 400) / 2; -// var l = (bodySize.x - 550) / 2; -// -// $('#MODALDL').css({ -// 'display': 'block', -// 'opacity': 0, -// 'width': '550px', -// 'position': 'absolute', -// 'top': t, -// 'left': l, -// 'height': '400px' -// }).fadeTo(500, 1); -// -// showOverlay(2); -// $('#tooltip').hide(); -//} - - function pushThis(sstt_id, lst, story) { $dialog = p4.Dialog.Create({ @@ -1735,21 +1710,16 @@ function pushThis(sstt_id, lst, story) title:'Push' }); - $.post("/prod/push/sendform/" - , { - lst : lst, - ssel : sstt_id, - story : story - } - , function(data){ - $dialog.setContent(data); - return; - } - ); - + $.post("/prod/push/sendform/", { + lst : lst, + ssel : sstt_id, + story : story + }, function(data){ + $dialog.setContent(data); + return; + }); } - function feedbackThis(sstt_id, lst, story) { /* disable push closeonescape as an over dialog may exist (add user) */ @@ -1758,17 +1728,14 @@ function feedbackThis(sstt_id, lst, story) title:'Feedback' }); - $.post("/prod/push/validateform/" - , { - lst : lst, - ssel : sstt_id, - story : story - } - , function(data){ - $dialog.setContent(data); - return; - } - ); + $.post("/prod/push/validateform/", { + lst : lst, + ssel : sstt_id, + story : story + }, function(data){ + $dialog.setContent(data); + return; + }); } function toolREFACTOR(datas){