V 3.5 RC 1

This commit is contained in:
Romain Neutron
2011-12-05 00:23:28 +01:00
parent 6f1ee368aa
commit 4c5b7eb658
5563 changed files with 466984 additions and 985416 deletions

View File

@@ -0,0 +1,491 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Controller_Prod_Records_Bridge implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = new ControllerCollection();
$appbox = appbox::get_instance();
$twig = new supertwig();
$app['require_connection'] = $app->protect(function(Bridge_Account $account) use ($app)
{
$app['current_account'] = function() use ($account)
{
return $account;
};
if (!$account->get_api()->get_connector()->is_configured())
throw new Bridge_Exception_ApiConnectorNotConfigured();
if (!$account->get_api()->get_connector()->is_connected())
throw new Bridge_Exception_ApiConnectorNotConnected ();
return;
});
$controllers->post('/manager/'
, function() use ($app, $twig)
{
$route = new module_prod_route_records_bridge($app['request']);
$appbox = appbox::get_instance();
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$params = array(
'user_accounts' => Bridge_Account::get_accounts_by_user($appbox, $user)
, 'available_apis' => Bridge_Api::get_availables($appbox)
, 'route' => $route
);
return new Response($twig->render('prod/actions/Bridge/index.twig', $params)
);
});
$controllers->get('/login/{api_name}/', function($api_name) use ($app, $twig)
{
$appbox = appbox::get_instance();
$connector = Bridge_Api::get_connector_by_name($appbox->get_registry(), $api_name);
return $app->redirect($connector->get_auth_url());
});
$controllers->get('/callback/{api_name}/', function($api_name) use ($app, $twig)
{
$error_message = '';
try
{
$appbox = appbox::get_instance();
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$api = Bridge_Api::get_by_api_name($appbox, $api_name);
$connector = $api->get_connector();
$response = $connector->connect();
$user_id = $connector->get_user_id();
try
{
$account = Bridge_Account::load_account_from_distant_id($appbox, $api, $user, $user_id);
}
catch (Bridge_Exception_AccountNotFound $e)
{
$account = Bridge_Account::create($appbox, $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();
}
$params = array('error_message' => $error_message);
return new Response($twig->render('prod/actions/Bridge/callback.twig', $params));
});
$controllers->get('/adapter/{account_id}/logout/'
, function($account_id) use ($app, $twig)
{
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $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() . '/');
});
$controllers->get('/adapter/{account_id}/load-records/'
, function($account_id) use ($app, $twig)
{
$page = max((int) $app['request']->get('page'), 0);
$quantity = 10;
$offset_start = max(($page - 1) * $quantity, 0);
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $account_id);
$elements = Bridge_Element::get_elements_by_account($appbox, $account, $offset_start, $quantity);
$app['require_connection']($account);
$params = array(
'adapter_action' => 'load-records'
, 'account' => $account
, 'elements' => $elements
, 'error_message' => $app['request']->get('error')
, 'notice_message' => $app['request']->get('notice')
);
$twig->addFilter(array('prettyDate' => 'phraseadate::getPrettyString'));
return new Response($twig->render('prod/actions/Bridge/records_list.twig', $params));
})
->assert('account_id', '\d+');
$controllers->get('/adapter/{account_id}/load-elements/{type}/'
, function($account_id, $type) use ($app, $twig)
{
$page = max((int) $app['request']->get('page'), 0);
$quantity = 5;
$offset_start = max(($page - 1) * $quantity, 0);
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $account_id);
$app['require_connection']($account);
$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']->get('error')
, 'notice_message' => $app['request']->get('notice')
);
$twig->addFilter(array('prettyDate' => 'phraseadate::getPrettyString'));
return new Response($twig->render('prod/actions/Bridge/element_list.twig', $params));
})
->assert('account_id', '\d+');
$controllers->get('/adapter/{account_id}/load-containers/{type}/'
, function($account_id, $type) use ($app, $twig)
{
$page = max((int) $app['request']->get('page'), 0);
$quantity = 5;
$offset_start = max(($page - 1) * $quantity, 0);
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $account_id);
$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']->get('error')
, 'notice_message' => $app['request']->get('notice')
);
$twig->addFilter(array('prettyDate' => 'phraseadate::getPrettyString'));
return new Response($twig->render('prod/actions/Bridge/element_list.twig', $params));
})
->assert('account_id', '\d+');
$controllers->get('/action/{account_id}/{action}/{element_type}/'
, function($account_id, $action, $element_type) use ($app, $twig)
{
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $account_id);
$app['require_connection']($account);
$request = $app['request'];
$elements = $request->get('elements_list', array());
$elements = is_array($elements) ? $elements : explode(';', $elements);
$destination = $request->get('destination');
$route_params = array();
$class = $account->get_api()->get_connector()->get_object_class_from_type($element_type);
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'));
}
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
, 'elements' => $elements
, 'error_message' => $app['request']->get('error')
, 'notice_message' => $app['request']->get('notice')
);
$params = array_merge($params, $route_params);
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.twig';
$html = $twig->render($template, $params);
return new Response($html);
})->assert('account_id', '\d+');
$controllers->post('/action/{account_id}/{action}/{element_type}/'
, function($account_id, $action, $element_type) use ($app, $twig)
{
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $account_id);
$app['require_connection']($account);
$request = $app['request'];
$elements = $request->get('elements_list', array());
$elements = is_array($elements) ? $elements : explode(';', $elements);
$destination = $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
, 'error_message' => _('Request contains invalid datas')
, 'constraint_errors' => $errors
, 'notice_message' => $app['request']->get('notice')
);
$template = 'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/' . $element_type . '_' . $action . ($destination ? '_' . $destination : '') . '.twig';
$html = $twig->render($template, $params);
return new Response($html);
}
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-' . $class . 's/' . $element_type . '/?page=&update=success#anchor');
break;
case 'createcontainer':
try
{
$container_type = $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->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-containers/' . $destination . '/?page=&update=success#anchor');
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() use ($app, $twig)
{
$request = $app['request'];
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $request->get('account_id'));
$app['require_connection']($account);
$route = new module_prod_route_records_bridge($request);
$route->grep_records($account->get_api()->acceptable_records());
$params = array(
'route' => $route
, 'account' => $account
, 'error_message' => $app['request']->get('error')
, 'notice_message' => $app['request']->get('notice')
);
$html = $twig->render(
'prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.twig', $params
);
return new Response($html);
});
$controllers->post('/upload/'
, function() use ($app, $twig)
{
$errors = array();
$request = $app['request'];
$appbox = appbox::get_instance();
$account = Bridge_Account::load_account($appbox, $request->get('account_id'));
$app['require_connection']($account);
$route = new module_prod_route_records_bridge($request);
$route->grep_records($account->get_api()->acceptable_records());
$connector = $account->get_api()->get_connector();
/**
* check constraints
*/
$errors = array();
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']->get('notice')
);
$html = $twig->render('prod/actions/Bridge/' . $account->get_api()->get_connector()->get_name() . '/upload.twig', $params);
return new Response($html);
//return $app->redirect('/prod/bridge/upload/?lst='.$request->get('lst').'&account_id='.$request->get('account_id').'&errors=' . sprintf(_('%d elements en erreur. %s'), count($errors), $error_msg));
}
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($appbox, $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 $controllers;
}
}

View File

@@ -0,0 +1,61 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
class Controller_Prod_Records_Edit implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = new ControllerCollection();
$controllers->post('/', function() use ($app)
{
$request = $app['request'];
$editing = new module_prod_route_records_edit($request);
$editing->propose_editing();
$template = 'prod/actions/edit_default.twig';
$twig = new supertwig();
$twig->addFilter(array('sbas_names' => 'phrasea::sbas_names'));
return $twig->render($template, array('edit' => $editing, 'message' => ''));
}
);
$controllers->post('/apply/', function() use ($app)
{
$request = $app['request'];
$editing = new module_prod_route_records_edit($request);
$editing->execute($request);
$template = 'prod/actions/edit_default.twig';
$twig = new supertwig();
$twig->addFilter(array('sbas_names' => 'phrasea::sbas_names'));
return $twig->render($template, array('edit' => $editing, 'message' => ''));
}
);
return $controllers;
}
}

View File

@@ -0,0 +1,334 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Controller_Prod_Records_Feed implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = new ControllerCollection();
$twig = new supertwig();
$appbox = appbox::get_instance();
/**
* I got a selection of docs, which publications are available forthese docs ?
*/
$controllers->post('/requestavailable/', function() use ($app, $appbox, $twig)
{
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feeds = Feed_Collection::load_all($appbox, $user);
$request = $app['request'];
$publishing = new module_prod_route_records_feed($request);
$datas = $twig->render('prod/actions/publish/publish.html', array('publishing' => $publishing, 'feeds' => $feeds));
return new Response($datas);
});
/**
* I've selected a publication for my ocs, let's publish them
*/
$controllers->post('/entry/create/', function() use ($app, $appbox, $twig)
{
try
{
$request = $app['request'];
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feed = new Feed_Adapter($appbox, $request->get('feed_id'));
$publisher = Feed_Publisher_Adapter::getPublisher($appbox, $feed, $user);
$title = $request->get('title');
$subtitle = $request->get('subtitle');
$author_name = $request->get('author_name');
$author_mail = $request->get('author_mail');
$entry = Feed_Entry_Adapter::create($appbox, $feed, $publisher, $title, $subtitle, $author_name, $author_mail);
$publishing = new module_prod_route_records_feed($request);
foreach ($publishing->get_elements() as $record)
{
$item = Feed_Entry_Item::create($appbox, $entry, $record);
}
$datas = array('error' => false, 'message' => false);
}
catch (Exception $e)
{
$datas = array('error' => true, 'message' => _('An error occured'), 'details' => $e->getMessage());
}
return new Response(p4string::jsonencode($datas), 200, array('Content-Type' => 'application/json'));
});
$controllers->get('/entry/{id}/edit/', function($id) use ($app, $appbox, $twig)
{
$request = $app['request'];
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$entry = Feed_Entry_Adapter::load_from_id($appbox, $id);
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
{
throw new Exception_UnauthorizedAction();
}
$feeds = Feed_Collection::load_all($appbox, $user);
$datas = $twig->render('prod/actions/publish/publish_edit.html', array('entry' => $entry, 'feeds' => $feeds));
return new Response($datas);
});
$controllers->post('/entry/{id}/update/', function($id) use ($app, $appbox, $twig)
{
$datas = array('error' => true, 'message' => '', 'datas' => '');
try
{
$appbox->get_connection()->beginTransaction();
$request = $app['request'];
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$entry = Feed_Entry_Adapter::load_from_id($appbox, $id);
if ($entry->get_publisher()->get_user()->get_id() !== $user->get_id())
{
throw new Exception_UnauthorizedAction();
}
$title = $request->get('title');
$subtitle = $request->get('subtitle');
$author_name = $request->get('author_name');
$author_mail = $request->get('author_mail');
$entry->set_author_email($author_mail)
->set_author_name($author_name)
->set_title($title)
->set_subtitle($subtitle);
$items = explode(';', $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($appbox, $entry, $item_sort_datas[0]);
$item->set_ord($item_sort_datas[1]);
}
$appbox->get_connection()->commit();
$twig->addFilter(
array(
'sbasFromBas' => 'phrasea::sbasFromBas'
, 'getPrettyDate' => 'phraseadate::getPrettyString'
, 'nl2br' => 'nl2br'
)
);
$entry = $twig->render('prod/feeds/entry.html', array('entry' => $entry));
$datas = array('error' => false, 'message' => 'succes', 'datas' => $entry);
}
catch (Exception_Feed_EntryNotFound $e)
{
$appbox->get_connection()->rollBack();
$datas['message'] = _('Feed entry not found');
}
catch (Exception $e)
{
$appbox->get_connection()->rollBack();
$datas['message'] = $e->getMessage();
}
return new Response(p4string::jsonencode($datas), 200, array('Content-Type' => 'application/json'));
});
$controllers->post('/entry/{id}/delete/', function($id) use ($app, $appbox, $twig)
{
$datas = array('error' => true, 'message' => '');
try
{
$appbox->get_connection()->beginTransaction();
$request = $app['request'];
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$entry = Feed_Entry_Adapter::load_from_id($appbox, $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();
$appbox->get_connection()->commit();
$datas = array('error' => false, 'message' => 'succes');
}
catch (Exception_Feed_EntryNotFound $e)
{
$appbox->get_connection()->rollBack();
$datas['message'] = _('Feed entry not found');
}
catch (Exception $e)
{
$appbox->get_connection()->rollBack();
$datas['message'] = $e->getMessage();
}
return new Response(p4string::jsonencode($datas), 200, array('Content-Type' => 'application/json'));
});
//$app->post('/entry/{id}/addelement/', function($id) use ($app, $appbox, $twig)
// {
//
// });
//
//$app->post('/element/{id}/update/', function($id) use ($app, $appbox, $twig)
// {
//
// });
//
//$app->post('/element/{id}/delete/', function($id) use ($app, $appbox, $twig)
// {
//
// });
//$app->get('/entry/{id}/', function($id) use ($app, $appbox, $twig)
// {
//
// });
$controllers->get('/', function() use ($app, $appbox, $twig)
{
$request = $app['request'];
$page = (int) $request->get('page');
$page = $page > 0 ? $page : 1;
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feeds = Feed_Collection::load_all($appbox, $user);
$twig->addFilter(
array(
'sbasFromBas' => 'phrasea::sbasFromBas'
, 'getPrettyDate' => 'phraseadate::getPrettyString'
, 'nl2br' => 'nl2br'
)
);
$datas = $twig->render('prod/feeds/feeds.html'
, array(
'feeds' => $feeds
, 'feed' => $feeds->get_aggregate()
, 'page' => $page
)
);
return new Response($datas);
});
$controllers->get('/feed/{id}/', function($id) use ($app, $appbox, $twig)
{
$request = $app['request'];
$page = (int) $request->get('page');
$page = $page > 0 ? $page : 1;
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feed = Feed_Adapter::load_with_user($appbox, $user, $id);
$feeds = Feed_Collection::load_all($appbox, $user);
$twig->addFilter(
array(
'sbasFromBas' => 'phrasea::sbasFromBas'
, 'getPrettyDate' => 'phraseadate::getPrettyString'
, 'nl2br' => 'nl2br'
)
);
$datas = $twig->render('prod/feeds/feeds.html', array('feed' => $feed, 'feeds' => $feeds, 'page' => $page));
return new Response($datas);
});
$controllers->get('/subscribe/aggregated/', function() use ($app, $appbox, $twig)
{
$request = $app['request'];
$renew = ($request->get('renew') === 'true');
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feeds = Feed_Collection::load_all($appbox, $user);
$registry = $appbox->get_registry();
$output = p4string::jsonencode(
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 new Response($output, 200, array('Content-Type' => 'application/json'));
});
$controllers->get('/subscribe/{id}/', function($id) use ($app, $appbox, $twig)
{
$request = $app['request'];
$renew = ($request->get('renew') === 'true');
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
$feed = Feed_Adapter::load_with_user($appbox, $user, $id);
$registry = $appbox->get_registry();
$output = p4string::jsonencode(
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 new Response($output, 200, array('Content-Type' => 'application/json'));
});
return $controllers;
}
}

View File

@@ -0,0 +1,60 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
class Controller_Prod_Records_MoveCollection implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = new ControllerCollection();
$controllers->post('/', function() use ($app)
{
$request = $app['request'];
$move = new module_prod_route_records_move($request);
$move->propose();
$template = 'prod/actions/collection_default.twig';
$twig = new supertwig();
$twig->addFilter(array('bas_names' => 'phrasea::bas_names'));
return $twig->render($template, array('action' => $move, 'message' => ''));
}
);
$controllers->post('/apply/', function() use ($app)
{
$request = $app['request'];
$move = new module_prod_route_records_move($request);
$move->execute($request);
$template = 'prod/actions/collection_submit.twig';
$twig = new supertwig();
$twig->addFilter(array('bas_names' => 'phrasea::bas_names'));
return $twig->render($template, array('action' => $move, 'message' => ''));
});
return $controllers;
}
}

View File

@@ -0,0 +1,177 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Controller_Prod_Records_Tooltip implements ControllerProviderInterface
{
public function connect(Application $app)
{
$controllers = new ControllerCollection();
$app['appbox'] = appbox::get_instance();
$twig = new supertwig();
$controllers->post('/basket/{ssel_id}/'
, function($ssel_id) use ($app)
{
$bask = basket_adapter::getInstance($app['appbox'], $ssel_id, $app['appbox']->get_session()->get_usr_id());
$isReg = false;
return new Response('<div style="margin:5px;width:280px;"><div><span style="font-weight:bold;font-size:14px;">' .
$bask->get_name() . '</span> </div>' .
($isReg ? ('<div style="text-align:right;">' . _('phraseanet::collection') . ' ' . phrasea::bas_names($bask->get_base_id()) . '</div>') : '')
. '<div style="margin:5px 0">' . nl2br($bask->get_description()) . '</div>' .
'<div style="margin:5px 0;text-align:right;font-style:italic;">' . sprintf(_('paniers: %d elements'), count($bask->get_elements())) .
' - ' . phraseadate::getPrettyString($bask->get_update_date()) . '</div><hr/>
<div style="position:relative;float:left;width:270px;">' . $bask->get_excerpt() . '</div>');
})->assert('ssel_id', '\d+');
$controllers->post('/preview/{sbas_id}/{record_id}/'
, function($sbas_id, $record_id) use ($app)
{
$record = new record_adapter($sbas_id, $record_id);
$twig = new supertwig();
return new Response($twig->render(
'common/preview.html'
, array(
'record' => $record
, 'not_wrapped' => true
)
)
);
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
$controllers->post('/caption/{sbas_id}/{record_id}/{view}/'
, function($sbas_id, $record_id, $view) use ($app)
{
$number = (int) $app['request']->get('number');
$record = new record_adapter($sbas_id, $record_id, $number);
$search_engine = null;
if (($search_engine_options = unserialize($app['request']->get('options_serial'))) !== false)
{
$search_engine = new searchEngine_adapter($app['appbox']->get_registry());
$search_engine->set_options($search_engine_options);
}
$twig = new supertwig();
$twig->addFilter(array('formatoctet' => 'p4string::format_octets'));
return new Response(
$twig->render(
'common/caption.html'
, array(
'record' => $record
, 'view' => $view
, 'highlight' => $app['request']->get('query')
, 'searchEngine' => $search_engine
)
)
);
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
$controllers->post('/tc_datas/{sbas_id}/{record_id}/'
, function($sbas_id, $record_id) use ($app)
{
$record = new record_adapter($sbas_id, $record_id);
$document = $record->get_subdef('document');
$twig = new supertwig();
$twig->addFilter(array('formatoctet' => 'p4string::format_octets'));
return new Response(
$twig->render(
'common/technical_datas.twig'
, array('record' => $record, 'document' => $document)
)
);
})->assert('sbas_id', '\d+')->assert('record_id', '\d+');
$controllers->post('/metas/FieldInfos/{sbas_id}/{field_id}/'
, function($sbas_id, $field_id) use ($app)
{
$databox = databox::get_instance((int) $sbas_id);
$field = databox_field::get_instance($databox, $field_id);
$twig = new supertwig();
return new Response(
$twig->render(
'common/databox_field.twig'
, array('field' => $field)
)
);
})->assert('sbas_id', '\d+')->assert('field_id', '\d+');
$controllers->post('/metas/DCESInfos/{sbas_id}/{field_id}/'
, function($sbas_id, $field_id) use ($app)
{
try
{
$databox = databox::get_instance((int) $sbas_id);
$field = databox_field::get_instance($databox, $field_id);
$twig = new supertwig();
return new Response(
$twig->render(
'common/databox_field_DCES.twig'
, array('field' => $field)
)
);
}
catch (Exception $e)
{
exit($e->getMessage());
}
})->assert('sbas_id', '\d+')->assert('field_id', '\d+');
$controllers->post('/metas/restrictionsInfos/{sbas_id}/{field_id}/'
, function($sbas_id, $field_id) use ($app)
{
$databox = databox::get_instance((int) $sbas_id);
$field = databox_field::get_instance($databox, $field_id);
$twig = new supertwig();
return new Response(
$twig->render(
'common/databox_field_restrictions.twig'
, array('field' => $field)
)
);
})->assert('sbas_id', '\d+')->assert('field_id', '\d+');
return $controllers;
}
}