Labelize collections

This commit is contained in:
Romain Neutron
2013-05-30 20:00:14 +02:00
parent 55a6469aa4
commit c084f20f85
37 changed files with 301 additions and 61 deletions

View File

@@ -529,7 +529,7 @@ class Application extends SilexApplication
$twig->addFilter('get_collection_logo', new \Twig_Filter_Function('collection::getLogo'));
$twig->addFilter('floor', new \Twig_Filter_Function('floor'));
$twig->addFilter('min', new \Twig_Filter_Function('min'));
$twig->addFilter('bas_names', new \Twig_Filter_Function('phrasea::bas_names'));
$twig->addFilter('bas_labels', new \Twig_Filter_Function('phrasea::bas_labels'));
$twig->addFilter('sbas_names', new \Twig_Filter_Function('phrasea::sbas_names'));
$twig->addFilter('sbas_from_bas', new \Twig_Filter_Function('phrasea::sbasFromBas'));
$twig->addFilter('key_exists', new \Twig_Filter_Function('array_key_exists'));

View File

@@ -66,7 +66,7 @@ class RecordAdd extends Command
$dialog = $this->getHelperSet()->get('dialog');
do {
$continue = strtolower($dialog->ask($output, sprintf("Will add record <info>%s</info> (%s) on collection <info>%s</info>\n<question>Continue ? (y/N)</question>", $file, $media->getType(), $collection->get_name()), 'N'));
$continue = strtolower($dialog->ask($output, sprintf("Will add record <info>%s</info> (%s) on collection <info>%s</info>\n<question>Continue ? (y/N)</question>", $file, $media->getType(), $collection->get_label($this->container['locale.I18n'])), 'N'));
} while ( ! in_array($continue, array('y', 'n')));
if (strtolower($continue) !== 'y') {
@@ -116,7 +116,7 @@ class RecordAdd extends Command
if ($elementCreated instanceof \record_adapter) {
$output->writeln(
sprintf(
"Record id <info>%d</info> on collection `%s` (databox `%s`) has been created", $elementCreated->get_record_id(), $elementCreated->get_collection()->get_name(), $elementCreated->get_databox()->get_viewname()
"Record id <info>%d</info> on collection `%s` (databox `%s`) has been created", $elementCreated->get_record_id(), $elementCreated->get_collection()->get_label($this->container['locale.I18n']), $elementCreated->get_databox()->get_viewname()
)
);
$this->container['phraseanet.SE']->addRecord($elementCreated);

View File

@@ -183,6 +183,10 @@ class Collection implements ControllerProviderInterface
->assert('bas_id', '\d+')
->bind('admin_collection_rename');
$controllers->post('/{bas_id}/labels/', $this->call('labels'))
->assert('bas_id', '\d+')
->bind('admin_collection_labels');
/**
* Empty a collection
*
@@ -888,6 +892,40 @@ class Collection implements ControllerProviderInterface
return $app->redirect('/admin/collection/' . $collection->get_base_id() . '/?success=' . (int) $success . '&reload-tree=1');
}
public function labels(Application $app, Request $request, $bas_id)
{
if (null === $labels = $request->request->get('labels')) {
$app->abort(400, _('Missing labels parameter'));
}
if (false === is_array($labels)) {
$app->abort(400, _('Invalid labels parameter'));
}
$collection = \collection::get_from_base_id($app, $bas_id);
$success = true;
try {
foreach ($app['locales.I18n.available'] as $code => $language) {
if (!isset($labels[$code])) {
continue;
}
$value = $labels[$code] ?: null;
$collection->set_label($code, $value);
}
} catch (\Exception $e) {
$success = false;
}
if ('json' === $app['request']->getRequestFormat()) {
return $app->json(array(
'success' => $success,
'msg' => $success ? _('Successful update') : _('An error occured')
));
}
return $app->redirect('/admin/collection/' . $collection->get_base_id() . '/?success=' . (int) $success . '&reload-tree=1');
}
/**
* Set public presentation watermark
*

View File

@@ -538,9 +538,9 @@ class Users implements ControllerProviderInterface
if (\Swift_Validate::email($row['usr_mail'])) {
foreach ($bases as $bas => $isok) {
if ($isok) {
$accept .= '<li>' . \phrasea::bas_names($bas, $app) . "</li>\n";
$accept .= '<li>' . \phrasea::bas_labels($bas, $app) . "</li>\n";
} else {
$deny .= '<li>' . \phrasea::bas_names($bas, $app) . "</li>\n";
$deny .= '<li>' . \phrasea::bas_labels($bas, $app) . "</li>\n";
}
}
if (($accept != '' || $deny != '')) {

View File

@@ -77,7 +77,7 @@ class MoveCollection implements ControllerProviderInterface
}
if (!$app['authentication']->getUser()->ACL()->has_right_on_base($request->request->get('base_id'), 'canaddrecord')) {
$datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_names($move->getBaseIdDestination(), $app));
$datas['message'] = sprintf(_("You do not have the permission to move records to %s"), \phrasea::bas_labels($move->getBaseIdDestination(), $app));
return $app->json($datas);
}

View File

@@ -249,7 +249,7 @@ class PDF
$y = $this->pdf->GetY();
$t = \phrasea::bas_names($rec->get_base_id(), $this->app);
$t = \phrasea::bas_labels($rec->get_base_id(), $this->app);
$this->pdf->SetFont(PhraseaPDF::FONT, '', 10);
$this->pdf->SetFillColor(220, 220, 220);
$this->pdf->SetLeftMargin($lmargin);
@@ -354,7 +354,7 @@ class PDF
}
if ($vn == "" || $vn == "1") {
$RIGHT_TEXT = \phrasea::bas_names($rec->get_base_id(), $this->app);
$RIGHT_TEXT = \phrasea::bas_labels($rec->get_base_id(), $this->app);
} elseif ($vn == "2") {
$RIGHT_IMG = $this->app['phraseanet.registry']->get('GV_RootPath') . "config/minilogos/" . $rec->get_base_id();
}

View File

@@ -666,7 +666,7 @@ class API_V1_adapter extends API_V1_Abstract
$collection = \collection::get_from_base_id($this->app, $request->get('base_id'));
if (!$app['authentication']->getUser()->ACL()->has_right_on_base($request->get('base_id'), 'canaddrecord')) {
throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_name()));
throw new API_V1_exception_forbidden(sprintf('You do not have access to collection %s', $collection->get_label($this->app['locale.I18n'])));
}
$media = $app['mediavorus']->guess($file->getPathname());
@@ -2019,7 +2019,7 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array(
'base_id' => $collection->get_base_id(),
'collection_id' => $collection->get_coll_id(),
'name' => $collection->get_name(),
'name' => $collection->get_label($this->app['locale.I18n']),
'record_amount' => $collection->get_record_amount(),
);

View File

@@ -11,6 +11,8 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -25,6 +27,7 @@ class collection implements cache_cacheableInterface
protected $name;
protected $prefs;
protected $pub_wm;
protected $labels = array();
private static $_logos = array();
private static $_stamps = array();
private static $_watermarks = array();
@@ -61,6 +64,7 @@ class collection implements cache_cacheableInterface
$this->pub_wm = $datas['pub_wm'];
$this->name = $datas['name'];
$this->prefs = $datas['prefs'];
$this->labels = $datas['labels'];
return $this;
} catch (Exception $e) {
@@ -68,7 +72,9 @@ class collection implements cache_cacheableInterface
}
$connbas = $this->databox->get_connection();
$sql = 'SELECT asciiname, prefs, pub_wm, coll_id
$sql = 'SELECT
asciiname, prefs, pub_wm, coll_id,
label_en, label_fr, label_de, label_nl
FROM coll WHERE coll_id = :coll_id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':coll_id' => $this->coll_id));
@@ -81,6 +87,12 @@ class collection implements cache_cacheableInterface
$this->pub_wm = $row['pub_wm'];
$this->name = $row['asciiname'];
$this->prefs = $row['prefs'];
$this->labels = array(
'fr' => $row['label_fr'],
'en' => $row['label_en'],
'de' => $row['label_de'],
'nl' => $row['label_nl'],
);
$conn = connection::getPDOConnection($this->app);
@@ -108,6 +120,7 @@ class collection implements cache_cacheableInterface
, 'pub_wm' => $this->pub_wm
, 'name' => $this->name
, 'prefs' => $this->prefs
, 'labels' => $this->labels
);
$this->set_data_to_cache($datas);
@@ -225,6 +238,40 @@ class collection implements cache_cacheableInterface
return $this;
}
public function set_label($code, $label)
{
if (!array_key_exists($code, $this->labels)) {
throw new InvalidArgumentException(sprintf('Code %s is not defined', $code));
}
$sql = "UPDATE coll SET label_$code = :label
WHERE coll_id = :coll_id";
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':label' => $label, ':coll_id' => $this->get_coll_id()));
$stmt->closeCursor();
$this->labels[$code] = $label;
$this->delete_data_from_cache();
phrasea::reset_baseDatas($this->databox->get_appbox());
return $this;
}
public function get_label($code, $substitute = true)
{
if (!array_key_exists($code, $this->labels)) {
throw new InvalidArgumentException(sprintf('Code %s is not defined', $code));
}
if ($substitute) {
return isset($this->labels[$code]) ? $this->labels[$code] : $this->name;
} else {
return $this->labels[$code];
}
}
public function get_record_amount()
{
$sql = "SELECT COUNT(record_id) AS n FROM record WHERE coll_id = :coll_id";
@@ -602,12 +649,12 @@ class collection implements cache_cacheableInterface
if ( ! isset(self::$_logos[$base_id_key])) {
if (is_file($app['phraseanet.registry']->get('GV_RootPath') . 'config/minilogos/' . $base_id)) {
$name = phrasea::bas_names($base_id, $app);
$name = phrasea::bas_labels($base_id, $app);
self::$_logos[$base_id_key] = '<img title="' . $name
. '" src="' . $app['phraseanet.registry']->get('GV_STATIC_URL')
. '/custom/minilogos/' . $base_id . '" />';
} elseif ($printname) {
self::$_logos[$base_id_key] = phrasea::bas_names($base_id, $app);
self::$_logos[$base_id_key] = phrasea::bas_labels($base_id, $app);
}
}

View File

@@ -86,7 +86,7 @@ function giveMeBases(Application $app, $usr = null)
$inscriptions[$sbas_id]['CollsNonactif'] = null;
foreach ($databox->get_collections() as $key => $coll) {
$collname[$key] = $coll->get_name();
$collname[$key] = $coll->get_label($app['locale.I18n']);
$basname[$key] = $coll->get_coll_id();
}
$sbpcgu = '';
@@ -138,7 +138,7 @@ function giveMeBases(Application $app, $usr = null)
$cguSpec = true;
} else {
if ( ! isset($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()]))
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_name();
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_label($app['locale.I18n']);
}
}
}
@@ -158,9 +158,9 @@ function giveMeBases(Application $app, $usr = null)
elseif ($usrerRegis[$databox->get_dbname()][$collection->get_coll_id()] === true)
$inscriptions[$sbas_id]['CollsRegistered'][$collection->get_coll_id()] = $lacgu;
} elseif (! $cguSpec && $collInscript) {//ne va pas.. si l'inscriptio na la coll est explicitement non autorise, je refuse'
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_name();
$inscriptions[$sbas_id]['Colls'][$collection->get_coll_id()] = $collection->get_label($app['locale.I18n']);
} elseif ($cguSpec) {
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['name'] = $collection->get_name();
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['name'] = $collection->get_label($app['locale.I18n']);
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['CGU'] = $cguColl;
$inscriptions[$sbas_id]['CollsCGU'][$collection->get_coll_id()]['CGUrelease'] = $cguCollRelease;
}
@@ -190,7 +190,7 @@ function giveMeBaseUsr(Application $app, $usr, $lng)
if ($baseInsc['CollsRegistered']) {
foreach ($baseInsc['CollsRegistered'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces authorise sur la collection ') . phrasea::bas_names($base_id, $app);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces authorise sur la collection ') . phrasea::bas_labels($base_id, $app);
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
@@ -200,7 +200,7 @@ function giveMeBaseUsr(Application $app, $usr, $lng)
if ($baseInsc['CollsRefuse']) {
foreach ($baseInsc['CollsRefuse'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces refuse sur la collection ') . phrasea::bas_names($base_id, $app) . '</span>';
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces refuse sur la collection ') . phrasea::bas_labels($base_id, $app) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
@@ -210,7 +210,7 @@ function giveMeBaseUsr(Application $app, $usr, $lng)
if ($baseInsc['CollsWait']) {
foreach ($baseInsc['CollsWait'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:orange;">' . _('login::register: en attente d\'acces sur') . ' ' . phrasea::bas_names($base_id, $app) . '</span>';
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:orange;">' . _('login::register: en attente d\'acces sur') . ' ' . phrasea::bas_labels($base_id, $app) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
@@ -220,7 +220,7 @@ function giveMeBaseUsr(Application $app, $usr, $lng)
if ($baseInsc['CollsIntime']) {
foreach ($baseInsc['CollsIntime'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces temporaire sur') . phrasea::bas_names($base_id, $app) . '</span>';
$out .= '<tr><td colspan="3" style="text-align:center;">' . _('login::register: acces temporaire sur') . phrasea::bas_labels($base_id, $app) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
@@ -230,7 +230,7 @@ function giveMeBaseUsr(Application $app, $usr, $lng)
if ($baseInsc['CollsOuttime']) {
foreach ($baseInsc['CollsOuttime'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces temporaire termine sur ') . phrasea::bas_names($base_id, $app) . '</span>';
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces temporaire termine sur ') . phrasea::bas_labels($base_id, $app) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';
@@ -240,7 +240,7 @@ function giveMeBaseUsr(Application $app, $usr, $lng)
if ($baseInsc['CollsNonactif']) {
foreach ($baseInsc['CollsNonactif'] as $collId => $isTrue) {
$base_id = phrasea::baseFromColl($sbasId, $collId, $app);
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces supendu sur') . phrasea::bas_names($base_id, $app) . '</span>';
$out .= '<tr><td colspan="3" style="text-align:center;"><span style="color:red;">' . _('login::register: acces supendu sur') . phrasea::bas_labels($base_id, $app) . '</span>';
if (trim($isTrue) != '')
$out .= ' <a class="inscriptlink" href="/include/cguUtils.php?action=PRINT&bas=' . $sbasId . '&col=' . $collId . '">' . _('login::register::CGU: lire les CGU') . '</a>';
$out .= '</td></tr>';

View File

@@ -254,7 +254,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
'base_id' => $base_id,
'sbas_id' => $sbas_id,
'coll_id' => $collection->get_base_id(),
'name' => $collection->get_name()
'name' => $collection->get_label($this->app['locale.I18n'])
);
}

View File

@@ -79,7 +79,7 @@ class module_report_download extends module_report
foreach ($rs as $row) {
$value = $row['val'];
if ($field == 'coll_id') {
$caption = phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app);
$caption = phrasea::bas_labels(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app);
} elseif ($field == 'ddate')
$caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
elseif ($field == 'size')
@@ -167,7 +167,7 @@ class module_report_download extends module_report
private function formatCollId($value)
{
return phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app);
return phrasea::bas_labels(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app);
}
public static function getNbDl(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)

View File

@@ -17,13 +17,13 @@ class phrasea
private static $_sbas_names = false;
private static $_coll2bas = false;
private static $_bas2coll = false;
private static $_bas_names = false;
private static $_bas_labels = false;
private static $_sbas_params = false;
const CACHE_BAS_2_SBAS = 'bas_2_sbas';
const CACHE_COLL_2_BAS = 'coll_2_bas';
const CACHE_BAS_2_COLL = 'bas_2_coll';
const CACHE_BAS_NAMES = 'bas_names';
const CACHE_BAS_LABELS = 'bas_labels';
const CACHE_SBAS_NAMES = 'sbas_names';
const CACHE_SBAS_FROM_BAS = 'sbas_from_bas';
const CACHE_SBAS_PARAMS = 'sbas_params';
@@ -181,12 +181,12 @@ class phrasea
public static function reset_baseDatas(appbox $appbox)
{
self::$_coll2bas = self::$_bas2coll = self::$_bas_names = self::$_bas2sbas = null;
self::$_coll2bas = self::$_bas2coll = self::$_bas_labels = self::$_bas2sbas = null;
$appbox->delete_data_from_cache(
array(
self::CACHE_BAS_2_COLL
, self::CACHE_BAS_2_COLL
, self::CACHE_BAS_NAMES
, self::CACHE_BAS_LABELS
, self::CACHE_SBAS_FROM_BAS
)
);
@@ -249,23 +249,32 @@ class phrasea
return isset(self::$_sbas_names[$sbas_id]) ? self::$_sbas_names[$sbas_id] : 'Unknown base';
}
public static function bas_names($base_id, Application $app)
public static function bas_labels($base_id, Application $app)
{
if (!self::$_bas_names) {
if (!self::$_bas_labels) {
try {
self::$_bas_names = $app['phraseanet.appbox']->get_data_from_cache(self::CACHE_BAS_NAMES);
self::$_bas_labels = $app['phraseanet.appbox']->get_data_from_cache(self::CACHE_BAS_LABELS);
} catch (Exception $e) {
foreach ($app['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
self::$_bas_names[$collection->get_base_id()] = $collection->get_name();
self::$_bas_labels[$collection->get_base_id()] = array(
'fr' => $collection->get_label('fr'),
'en' => $collection->get_label('en'),
'de' => $collection->get_label('de'),
'nl' => $collection->get_label('nl'),
);
}
}
$app['phraseanet.appbox']->set_data_to_cache(self::$_bas_names, self::CACHE_BAS_NAMES);
$app['phraseanet.appbox']->set_data_to_cache(self::$_bas_labels, self::CACHE_BAS_LABELS);
}
}
return isset(self::$_bas_names[$base_id]) ? self::$_bas_names[$base_id] : 'Unknown collection';
if (isset(self::$_bas_labels[$base_id]) && isset(self::$_bas_labels[$base_id][$app['locale.I18n']])) {
return self::$_bas_labels[$base_id][$app['locale.I18n']];
}
return 'Unknown collection';
}
public static function scheduler_key(Application $app, $renew = false)

View File

@@ -354,7 +354,7 @@ class recordutils_image extends recordutils
$builder->getProcess()->run();
} elseif ($app['phraseanet.registry']->get('convert_binary')) {
$collname = phrasea::bas_names($base_id, $app);
$collname = phrasea::bas_labels($base_id, $app);
$tailleimg = @getimagesize($pathIn);
$max = ($tailleimg[0] > $tailleimg[1] ? $tailleimg[0] : $tailleimg[1]);

View File

@@ -219,7 +219,7 @@ class task_period_archive extends task_abstract
<?php
foreach ($this->dependencyContainer['phraseanet.appbox']->get_databoxes() as $databox) {
foreach ($databox->get_collections() as $collection) {
print("<option value=\"" . $collection->get_base_id() . "\">" . $databox->get_viewname() . " / " . $collection->get_name() . "</option>");
print("<option value=\"" . $collection->get_base_id() . "\">" . $databox->get_viewname() . " / " . $collection->get_label($this->dependencyContainer['locale.I18n']) . "</option>");
}
}
?>

View File

@@ -616,12 +616,12 @@ class task_period_ftp extends task_appboxAbstract
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $row["base_id"]), $this->dependencyContainer)
, phrasea::bas_names($row['base_id'], $this->dependencyContainer), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
, phrasea::bas_labels($row['base_id'], $this->dependencyContainer), $row['subdef']) . ' : ' . _('Transfert OK') . '</li>';
} else {
$transferts[] =
'<li>' . sprintf(_('task::ftp:Record %1$s - %2$s de la base (%3$s - %4$s) - %5$s')
, $row["record_id"], $row["filename"]
, phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $row["base_id"]), $this->dependencyContainer), phrasea::bas_names($row['base_id'], $this->dependencyContainer)
, phrasea::sbas_names(phrasea::sbasFromBas($this->dependencyContainer, $row["base_id"]), $this->dependencyContainer), phrasea::bas_labels($row['base_id'], $this->dependencyContainer)
, $row['subdef']) . ' : ' . _('Transfert Annule') . '</li>';
$transfert_status = _('task::ftp:Certains documents n\'ont pas pu etre tranferes');
}

View File

@@ -4333,6 +4333,38 @@
<default></default>
<comment></comment>
</field>
<field>
<name>label_en</name>
<type>char(50)</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>label_fr</name>
<type>char(50)</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>label_de</name>
<type>char(50)</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>label_nl</name>
<type>char(50)</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field>
<name>prefs</name>
<type>text</type>

View File

@@ -8,7 +8,7 @@
<div class="page-header">
<h1>
{% trans 'phraseanet:: collection' %} {{ collection.get_name() }}
{% trans 'phraseanet:: collection' %} {{ collection.get_label(app['locale.I18n']) }}
</h1>
</div>
@@ -91,6 +91,33 @@
</form>
</div>
<div class="well well-small action-block">
<form class="form-inline" method="post" action="{{ path('admin_collection_labels', { 'bas_id' : bas_id }) }}" style="margin:0;">
<div class="input-append">
<div class="row">
{% for code, language in app['locales.I18n.available'] %}
<div class="span2">
<h6>{{ language }}</h6>
</div>
{% endfor %}
</div>
<div class="row">
{% for code, language in app['locales.I18n.available'] %}
<div class="span2">
<input name="labels[{{ code }}]" value="{{ collection.get_label(code, false) }}" class="span2" type="text">
</div>
{% endfor %}
<div class="span2">
<button class="btn" type="submit">
<img src="/skins/icons/edit_0.gif" />
{% trans 'Set labels' %}
</button>
</div>
</div>
</div>
</form>
</div>
<div class="well well-small btn-group">
<form style="display:inline; margin:0;" method="post" action="/admin/collection/{{ bas_id }}/{{ collection.is_active() ? 'disabled' : 'enable' }}/">
<button class="btn confirm" data-confirm-msg="{{ collection.is_active() ? 'admin::base:collection: etes vous sur darreter la publication de cette collection'|trans : 'admin::base:collection: etes vous sur de publier cette collection ?'|trans }}">

View File

@@ -36,7 +36,7 @@
<select id="othcollsel" name="othcollsel" disabled>
<option>{% trans "choisir" %}</option>
{% for baseId, collection in app['authentication'].getUser().ACL().get_granted_base(["canadmin"]) %}
<option value="{{ baseId }}">{{ collection.get_name() }}</option>
<option value="{{ baseId }}">{{ collection.get_label(app['locale.I18n']) }}</option>
{% endfor %}
</select>
{% endif %}

View File

@@ -1,5 +1,5 @@
<div class="header">
<h1>{{ collection.get_name() }} <small>{% trans "Details" %}</small></h1>
<h1>{{ collection.get_label(app['locale.I18n']) }} <small>{% trans "Details" %}</small></h1>
</div>
<table class="table table-bordered">

View File

@@ -51,7 +51,7 @@
</td>
<td style="text-align:center;height:30px;font-size:12px; border:0px;background-position: 0px 0px;background-repeat: repeat-x" nowrap>
{% trans 'admin::sugval: Valeurs suggerees/Preferences de la collection' %} {{ app['request'].attributes.get('bas_id')|bas_names(app) }}
{% trans 'admin::sugval: Valeurs suggerees/Preferences de la collection' %} {{ app['request'].attributes.get('bas_id')|bas_labels(app) }}
</td>
<td style="height:30px;width:20px;font-size:12px;border:0px; text-align:right">

View File

@@ -185,7 +185,7 @@
{% for baseId in databox.get_activable_colls() %}
<li>
<form class='form-inline' method="post" action="{{ path('admin_collection_enable', {'bas_id': baseId}) }}">
{{ baseId|bas_names(app) }}
{{ baseId|bas_labels(app) }}
<a href="#" class="btn btn-mini submiter">{% trans "Activer" %}></a>
</form>
</li>

View File

@@ -353,7 +353,7 @@
{% endif %}
<tr>
<td style="overflow:hidden;white-space:nowrap;">
{{rights['base_id']|bas_names(app)}}
{{rights['base_id']|bas_labels(app)}}
</td>
<td class="users_col case_right_access" title="{% trans 'Access' %}">
{{_self.format_checkbox(app['authentication'].getUser(), rights, 'access', users, 'base')}}

View File

@@ -3,7 +3,7 @@
Base {{ collection.get_databox().get_viewname() }}
</div>
<div>
Collection {{base_id|bas_names(app)}}
Collection {{base_id|bas_labels(app)}}
</div>
<form>
<table style="table-layout:fixed; width:280px;position:relative;left:10px;" width="280px">

View File

@@ -42,7 +42,7 @@
{% trans %}Base {{base}}{% endtrans %}
</div>
<div>
{% set collection = base_id|bas_names(app) %}
{% set collection = base_id|bas_labels(app) %}
{% trans %}Collection {{collection}}{% endtrans %}
</div>
<form>

View File

@@ -4,7 +4,7 @@
{% trans %}Base {{base}}{% endtrans %}
</div>
<div>
{% set collection = base_id|bas_names(app) %}
{% set collection = base_id|bas_labels(app) %}
{% trans %}Collection {{collection}}{% endtrans %}
</div>
<form>

View File

@@ -202,7 +202,7 @@
<input name="watermark[]" value="{{ row['usr_id'] }}_{{ basId }}" onclick="checkAdd(this)" id="{{ 'watermark_' ~ row['usr_id'] ~ '_' ~ basId }}" class="{{ 'disabler_' ~ row['usr_id'] ~ '_' ~ basId }} watermark_checker tipInfoUsr {{ 'checker_' ~ row['usr_id'] }}" title="{% trans 'admin:: watermarquer les documents' %}" type="checkbox"/>
</td>
<td>
{{ basId| bas_names(app) }}
{{ basId| bas_labels(app) }}
</td>
</tr>
{% endfor %}
@@ -223,7 +223,7 @@
<span class="tipInfoUsr" title="{% trans 'admin:: watermarquer les documents' %}">W</span>
</button>
<button class="btn btn-warning" disabled style="height:30px;">
{{ basId| bas_names(app) }}
{{ basId| bas_labels(app) }}
</button>
</div>
{% endfor %}

View File

@@ -3,7 +3,7 @@
<label>{% trans 'Collection' %}</label>
<select name="base_id">
{% for collection in app['authentication'].getUser().ACL().get_granted_base(['canaddrecord']) %}
<option value="{{ collection.get_base_id() }}">{{ collection.get_databox().get_viewname() }} / {{ collection.get_name() }}</option>
<option value="{{ collection.get_base_id() }}">{{ collection.get_databox().get_viewname() }} / {{ collection.get_label(app['locale.I18n']) }}</option>
{% endfor %}
</select>

View File

@@ -46,7 +46,7 @@
{% for file in list["files"] %}
{% set size = 0 %}
<tr valign="middle">
<td>{{ app|sbas_from_bas(file['base_id'])|sbas_names(app) }} {{ file['base_id']|bas_names(app) }}</td>
<td>{{ app|sbas_from_bas(file['base_id'])|sbas_names(app) }} {{ file['base_id']|bas_labels(app) }}</td>
<td>{{ file['original_name'] }}</td>
<td>
{% if file['subdefs'] is iterable and file['subdefs']|length > 0 %}

View File

@@ -34,7 +34,7 @@
<br/>
<select name="base_id">
{% for collection in collections %}
<option value="{{ collection.get_base_id() }}">{{ collection.get_name() }}</option>
<option value="{{ collection.get_base_id() }}">{{ collection.get_label(app['locale.I18n']) }}</option>
{% endfor %}
</select>
<br/>

View File

@@ -30,7 +30,7 @@
<td>
<label style="line-height: 18px;" onclick="infoSbas($('#ck_{{base_id}}_{{unique_id}}'),{{sbas_id}}, false, event); return false;"
for="ck_{{base_id}}_{{unique_id}}" class="ck_{{base_id}} {% if collection["selected"] %}selected{% endif %} checkbox">
{{base_id|get_collection_logo(app)|raw}} {{base_id|bas_names(app)}}
{{base_id|get_collection_logo(app)|raw}} {{base_id|bas_labels(app)}}
</label>
</td>
</tr>

View File

@@ -23,7 +23,7 @@
{% trans 'report::Edition des meta-donnees' %}
{% elseif action == 'collection' %}
{% set dest = done['final']|join(', ') %}
{% set coll_name = dest|bas_names(app) %}
{% set coll_name = dest|bas_labels(app) %}
{% trans %}report::Changement de collection vers : {{coll_name}}{% endtrans %}
{% elseif action == 'status' %}
{% trans 'report::Edition des status' %}

View File

@@ -264,7 +264,7 @@
{% endtrans %}
</p>
{% endif %}
<p>{% trans "Collection" %} : <span class="info">{{ file.getCollection(app).get_name() }}</span></p>
<p>{% trans "Collection" %} : <span class="info">{{ file.getCollection(app).get_label(app['locale.I18n']) }}</span></p>
</div>
<div class="caption">
{% for check in file.getChecks() %}

View File

@@ -54,7 +54,7 @@
{% for sbasId, availableCollections in collections %}
<optgroup label="{{ availableCollections['databox'].get_viewname() }}" class="select-label">
{% for collection in availableCollections['databox_collections'] %}
<option value="{{ collection.get_base_id() }}" class="select-row">{{ collection.get_name() }}</option>
<option value="{{ collection.get_base_id() }}" class="select-row">{{ collection.get_label(app['locale.I18n']) }}</option>
{% endfor %}
</optgroup>
{% endfor %}

View File

@@ -59,7 +59,7 @@
{% for sbasId, availableCollections in collections %}
<optgroup label="{{ availableCollections['databox'].get_viewname() }}" class="select-label">
{% for collection in availableCollections['databox_collections'] %}
<option value="{{ collection.get_base_id() }}" class="select-row">{{ collection.get_name() }}</option>
<option value="{{ collection.get_base_id() }}" class="select-row">{{ collection.get_label(app['locale.I18n']) }}</option>
{% endfor %}
</optgroup>
{% endfor %}

View File

@@ -353,6 +353,26 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabelsNotJson()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
self::$DI['client']->request('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', array(
'labels' => array(
'en' => 'english label',
'fr' => 'french label',
'ru' => 'russian label',
)
));
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
*/
@@ -365,6 +385,18 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabelsUnauthorizedException()
{
$this->setAdmin(false);
self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/labels/');
$this->assertForbiddenResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
*/
@@ -376,6 +408,17 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabelsBadRequestMissingArguments()
{
$this->setAdmin(true);
$this->XMLHTTPRequest('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/labels/');
$this->assertXMLHTTPBadJsonResponse(self::$DI['client']->getResponse());
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::rename
*/
@@ -396,6 +439,35 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$collection->delete();
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::labels
*/
public function testPostLabels()
{
$this->setAdmin(true);
$collection = $this->createOneCollection();
$this->XMLHTTPRequest('POST', '/admin/collection/' . $collection->get_base_id() . '/labels/', array(
'labels' => array(
'nl' => 'netherlands label',
'de' => 'german label',
'fr' => 'label français',
'en' => 'label à l\'anglaise',
'ru' => 'label à la russe',
)
));
$json = $this->getJson(self::$DI['client']->getResponse());
$this->assertTrue($json->success);
$this->assertEquals($collection->get_label('de'), 'german label');
$this->assertEquals($collection->get_label('nl'), 'netherlands label');
$this->assertEquals($collection->get_label('fr'), 'label français');
$this->assertEquals($collection->get_label('en'), 'label à l\'anglaise');
$collection->unmount_collection(self::$DI['app']);
$collection->delete();
}
/**
* @covers Alchemy\Phrasea\Controller\Admin\Bas::emptyCollection
*/

View File

@@ -18,7 +18,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
foreach ($feeds->get_feeds() as $feed) {
$this->assertRegExp('/\/admin\/publications\/feed\/' . $feed->get_id() . '/', $pageContent);
if ($feed->get_collection() != null)
$this->assertRegExp('/' . $feed->get_collection()->get_name() . '/', $pageContent);
$this->assertRegExp('/' . $feed->get_collection()->get_label(self::$DI['app']['locale.I18n']) . '/', $pageContent);
if ($feed->is_owner(self::$DI['user']))
$this->assertEquals(1, $crawler->filterXPath("//form[@action='/admin/publications/feed/" . $feed->get_id() . "/delete/']")->count());
}

View File

@@ -130,6 +130,21 @@ class collectionTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals('babababe bi bo bu', self::$object->get_name());
}
public function testSet_label()
{
self::$object->set_name('pretty name');
self::$object->set_label('fr', 'french label');
self::$object->set_label('en', 'english label');
self::$object->set_label('nl', null);
self::$object->set_label('de', null);
$this->assertEquals('french label', self::$object->get_label('fr'));
$this->assertEquals('english label', self::$object->get_label('en'));
$this->assertEquals('pretty name', self::$object->get_label('nl'));
$this->assertEquals('pretty name', self::$object->get_label('de'));
$this->assertNull(self::$object->get_label('nl', false));
$this->assertNull(self::$object->get_label('de', false));
}
public function testGet_record_details()
{
$file = new File(self::$DI['app'], self::$DI['app']['mediavorus']->guess(__DIR__ . '/../files/cestlafete.jpg'), self::$object);