Conflicts:

	lib/Alchemy/Phrasea/Controller/Prod/Records.php
	templates/web/prod/Share/record.html.twig
This commit is contained in:
Nicolas Le Goff
2012-10-12 19:55:55 +02:00
parent 34e2fdba99
commit 45c3e564df
12 changed files with 551 additions and 409 deletions

View File

@@ -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);

View File

@@ -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
));

View File

@@ -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);

View File

@@ -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();
});
/**

View File

@@ -0,0 +1,182 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Controller\Prod\Records;
use Alchemy\Phrasea\Controller\RecordsRequest;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Deletion implements ControllerProviderInterface
{
/**
* {@inheritDoc}
*/
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->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);
}
}

View File

@@ -87,7 +87,7 @@ class Notifications implements ControllerProviderInterface
$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()));
}

View File

@@ -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));
}
/**

View File

@@ -1,79 +1,76 @@
{% set preview = record.get_preview()%}
{% set permalink = preview.get_permalink() %}
{% if preview is iterable %}
<p>{% trans 'No preview available.' %}</p>
{% elseif permalink is none %}
{% elseif preview.get_permalink() is none %}
<p>{% trans 'No permalink available.' %}</p>
{% else %}
{% set type = record.get_type() %}
{% set url = permalink.get_url() %}
<div id="tabs">
<ul>
<li>
<a href="#share">{% trans 'reponses:: partager' %}</a>
</li>
</ul>
<div id="share">
{% set url = preview.get_permalink().get_url() %}
<div class="boxCloser" onclick="parent.hideDwnl();">{% trans 'boutton::fermer' %} ?></div>
<div id="tweet">
<div style="margin-left:20px;padding:10px 0 5px;"><a href="http://www.twitter.com/home/?status={{ url|url_encode }}view/" target="_blank"><img src="/skins/icons/twitter.ico" title="share this on twitter" style="vertical-align:middle;padding:0 5px;"/> Send to Twitter</a></div>
<div style="margin-left:20px;padding:5px 0 10px;"><a href="http://www.facebook.com/sharer.php?u={{ url|url_encode }}view/" target="_blank"><img src="/skins/icons/facebook.ico" title="share on facebook" style="vertical-align:middle;padding:0 5px;"/> Send to Facebook</a></div>
</div>
<div id="embed" style="text-align:center;padding:10px 0;">
<div style="text-align:left;margin-left:20px;padding:10px 0;">URL : </div>
{% if url is not empty %}
<input style="width:90%;" readonly="true" type="text" value="{{ url|url_encode }}view/" onfocus="this.focus();this.select();" onclick="this.focus();this.select();" />
<div style="text-align:left;margin-left:20px;padding:10px 0;">Embed :</div>
<textarea onfocus="this.focus();this.select();" onclick="this.focus();this.select();" style="width:90%;height:50px;" readonly="true" >
{% if type == 'video' %}
<object width="100%" height="100%" type="application/x-shockwave-flash" data="{{ app['phraseanet.registry'].get('GV_ServerName')}}include/jslibs/flowplayer/flowplayer-3.2.12.swf">
<param value="true" name="allowfullscreen">
<param value="always" name="allowscriptaccess">
<param value="high" name="quality">
<param value="false" name="cachebusting">
<param value="#000000" name="bgcolor">
<param value="config={&quot;clip&quot;:{&quot;url&quot;:&quot;{{ url|url_encode }}&quot;},&quot;playlist&quot;:[{&quot;url&quot;:&quot;{{ url|url_encode }}&quot;}]}" name="flashvars">
</object>
{% elseif type == 'document' %}
<object width="600" height="500" type="application/x-shockwave-flash" data="{{app['phraseanet.registry'].get('GV_ServerName')}}include/FlexPaper_flash/FlexPaperViewer.swf" style="visibility: visible; width: 600px; height: 500px; top: 0px;">
<param name="menu" value="false">
<param name="flashvars" value="SwfFile={{ url|url_encode }}&amp;Scale=0.6&amp;ZoomTransition=easeOut&amp;ZoomTime=0.5&amp;ZoomInterval=0.1&amp;FitPageOnLoad=true&amp;FitWidthOnLoad=true&amp;PrintEnabled=false&amp;FullScreenAsMaxWindow=false&amp;localeChain={{ app['locale'] }}">
<param name="allowFullScreen" value="true">
<param name="wmode" value="transparent">
</object>
{% elseif type == 'audio' %}
<object width="290" height="24" data="{{ app['phraseanet.registry'].get('GV_ServerName') }}include/jslibs/audio-player/player.swf" type="application/x-shockwave-flash">
<param value="{{ app['phraseanet.registry'].get('GV_ServerName') }}include/jslibs/audio-player/player.swf" name="movie"/>
<param value="playerID=1&amp;autostart=yes&amp;soundFile={{ url|url_encode }}" name="FlashVars"/>
<param value="high" name="quality"/>
<param value="false" name="menu"/>
</object>
{% else %}
<a href="{{ url|url_encode }}view/"><img src="{{ url|url_encode }}" title="" /></a>
{% endif %}
</textarea>
</div>
{% else %}
<div><{% trans 'Aucune URL disponible' %}</div>
{% endif %}
{% if url is not empty %}
<div id="tabs">
<ul>
<li>
<a href="#share">{% trans 'reponses:: partager' %}</a>
</li>
</ul>
<div id="share">
<div id="tweet">
<div style="margin-left:20px;padding:10px 0 5px;"><a href="http://www.twitter.com/home/?status={{ url|url_encode }}view/" target="_blank"><img src="/skins/icons/twitter.ico" title="share this on twitter" style="vertical-align:middle;padding:0 5px;"/> Send to Twitter</a></div>
<div style="margin-left:20px;padding:5px 0 10px;"><a href="http://www.facebook.com/sharer.php?u={{ url|url_encode }}view/" target="_blank"><img src="/skins/icons/facebook.ico" title="share on facebook" style="vertical-align:middle;padding:0 5px;"/> Send to Facebook</a></div>
</div>
<div id="embed" style="text-align:center;padding:10px 0;">
<div style="text-align:left;margin-left:20px;padding:10px 0;">URL : </div>
<div style="text-align:center;padding:20px 0;">
<input class="input-button" type="button" value="{% trans 'boutton::fermer' %}" onclick="parent.hideDwnl();" />
<input style="width:90%;" readonly="true" type="text" value="{{ url|url_encode }}view/" onfocus="this.focus();this.select();" onclick="this.focus();this.select();" />
<div style="text-align:left;margin-left:20px;padding:10px 0;">Embed :</div>
<textarea onfocus="this.focus();this.select();" onclick="this.focus();this.select();" style="width:90%;height:50px;" readonly="true" >
{% if type == 'video' %}
<object width="100%" height="100%" type="application/x-shockwave-flash" data="{{ app['phraseanet.registry'].get('GV_ServerName')}}include/jslibs/flowplayer/flowplayer-3.2.12.swf">
<param value="true" name="allowfullscreen">
<param value="always" name="allowscriptaccess">
<param value="high" name="quality">
<param value="false" name="cachebusting">
<param value="#000000" name="bgcolor">
<param value="config={&quot;clip&quot;:{&quot;url&quot;:&quot;{{ url|url_encode }}&quot;},&quot;playlist&quot;:[{&quot;url&quot;:&quot;{{ url|url_encode }}&quot;}]}" name="flashvars">
</object>
{% elseif type == 'document' %}
<object width="600" height="500" type="application/x-shockwave-flash" data="{{app['phraseanet.registry'].get('GV_ServerName')}}include/FlexPaper_flash/FlexPaperViewer.swf" style="visibility: visible; width: 600px; height: 500px; top: 0px;">
<param name="menu" value="false">
<param name="flashvars" value="SwfFile={{ url|url_encode }}&amp;Scale=0.6&amp;ZoomTransition=easeOut&amp;ZoomTime=0.5&amp;ZoomInterval=0.1&amp;FitPageOnLoad=true&amp;FitWidthOnLoad=true&amp;PrintEnabled=false&amp;FullScreenAsMaxWindow=false&amp;localeChain={{ app['locale'] }}">
<param name="allowFullScreen" value="true">
<param name="wmode" value="transparent">
</object>
{% elseif type == 'audio' %}
<object width="290" height="24" data="{{ app['phraseanet.registry'].get('GV_ServerName') }}include/jslibs/audio-player/player.swf" type="application/x-shockwave-flash">
<param value="{{ app['phraseanet.registry'].get('GV_ServerName') }}include/jslibs/audio-player/player.swf" name="movie"/>
<param value="playerID=1&amp;autostart=yes&amp;soundFile={{ url|url_encode }}" name="FlashVars"/>
<param value="high" name="quality"/>
<param value="false" name="menu"/>
</object>
{% else %}
<a href="{{ url|url_encode }}view/"><img src="{{ url|url_encode }}" title="" /></a>
{% endif %}
</textarea>
</div>
<div style="text-align:center;padding:20px 0;">
<input class="input-button" type="button" value="{% trans 'boutton::fermer' %}" />
</div>
</div>
</div>
</div>
<script language="javascript">
$(document).ready(function(){
$('#tabs').tabs();
$('input.ui-state-default').hover(
function(){$(this).addClass('ui-state-hover')},
function(){$(this).removeClass('ui-state-hover')}
);
});
</script>
<script language="javascript">
$(document).ready(function(){
$('#tabs').tabs();
$('input.ui-state-default').hover(
function(){$(this).addClass('ui-state-hover')},
function(){$(this).removeClass('ui-state-hover')}
);
});
</script>
{% else %}
<div><{% trans 'Aucune URL disponible' %}</div>
{% endif %}
{% endif %}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;
})
);
}

View File

@@ -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){