Merge branch 'PHRAS-1734_PORT_PHRAS-1589' into PHRAS-1744_PORT_PHRAS-1578_1579_1621_1675_1404_1336

# Conflicts:
#	resources/locales/messages.de.xlf
#	resources/locales/messages.en.xlf
#	resources/locales/messages.fr.xlf
#	resources/locales/messages.nl.xlf
#	resources/locales/validators.de.xlf
#	resources/locales/validators.en.xlf
#	resources/locales/validators.fr.xlf
#	resources/locales/validators.nl.xlf
#	resources/www/admin/styles/main.scss
This commit is contained in:
Mike Ng
2018-01-09 11:00:03 +04:00
80 changed files with 4636 additions and 2193 deletions

View File

@@ -176,6 +176,7 @@ class Install extends Command
private function getDBConn(InputInterface $input, OutputInterface $output, Connection $abConn, DialogHelper $dialog)
{
$dbConn = $template = $info = null;
$templates = $this->container['phraseanet.structure-template']->getAvailable();
if (!$input->getOption('databox')) {
do {
$retry = false;
@@ -196,8 +197,9 @@ class Install extends Command
$output->writeln("\n\t<info>Data-Box : Connection successful !</info>\n");
do {
$template = $dialog->ask($output, 'Choose a language template for metadata structure, available are fr (french) and en (english) (en) : ', 'en');
} while (!in_array($template, ['en', 'fr']));
$template = $dialog->ask($output, "Choose a language template for metadata structure, available are {$templates->__toString()} : ", 'en');
}
while (!in_array($template, array_keys($templates->getTemplates())));
$output->writeln("\n\tLanguage selected is <info>'$template'</info>\n");
} catch (\Exception $e) {

View File

@@ -38,7 +38,12 @@ class SetupController extends Controller
public function submitGlobalsAction(Request $request)
{
$form = $this->registryFormManipulator->createForm();
if (null !== $this->configuration->get('registry')) {
$form = $this->registryFormManipulator->createForm($this->configuration);
}
else {
$form = $this->registryFormManipulator->createForm();
}
if ('POST' === $request->getMethod()) {
$form->submit($request->request->all());

View File

@@ -12,8 +12,14 @@ namespace Alchemy\Phrasea\Controller\Admin;
use Alchemy\Phrasea\Controller\Controller;
use Alchemy\Phrasea\Databox\SubdefGroup;
use Alchemy\Phrasea\Media\Subdef\Subdef;
use Alchemy\Phrasea\Media\Type\Type;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Alchemy\Phrasea\Media\Subdef\Image;
use Alchemy\Phrasea\Media\Subdef\Video;
use Alchemy\Phrasea\Media\Subdef\Audio;
use Alchemy\Phrasea\Media\Subdef\Gif;
class SubdefsController extends Controller
{
@@ -23,10 +29,14 @@ class SubdefsController extends Controller
*/
function indexAction($sbas_id) {
$databox = $this->findDataboxById((int) $sbas_id);
$config = $this->getConfiguration();
$subviews_mapping = $this->getSubviewsMapping();
return $this->render('admin/subdefs.html.twig', [
'databox' => $databox,
'subdefs' => $databox->get_subdef_structure(),
'databox' => $databox,
'subdefs' => $databox->get_subdef_structure(),
'config' => $config,
'subviews_mapping' => $subviews_mapping
]);
}
@@ -43,7 +53,7 @@ class SubdefsController extends Controller
$databox = $this->findDataboxById((int) $sbas_id);
$add_subdef = ['class' => null, 'name' => null, 'group' => null];
$add_subdef = ['class' => null, 'name' => null, 'group' => null, 'mediaType' => null, 'presets' => null];
foreach ($add_subdef as $k => $v) {
if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') {
unset($add_subdef[$k]);
@@ -58,7 +68,8 @@ class SubdefsController extends Controller
$name = $delete_subef[1];
$subdefs = $databox->get_subdef_structure();
$subdefs->delete_subdef($group, $name);
} elseif (count($add_subdef) === 3) {
}
elseif (count($add_subdef) === 5) {
$subdefs = $databox->get_subdef_structure();
$group = $add_subdef['group'];
@@ -66,13 +77,85 @@ class SubdefsController extends Controller
$unicode = $this->app['unicode'];
$name = $unicode->remove_nonazAZ09($add_subdef['name'], false);
$class = $add_subdef['class'];
$preset = $add_subdef['presets'];
$mediatype = $add_subdef['mediaType'];
$subdefs->add_subdef($group, $name, $class, $mediatype, $preset);
if ($preset !== "Choose") {
$options = [];
$config = $this->getConfiguration();
//On applique directement les valeurs du preset à la sous def
switch ($mediatype) {
case Subdef::TYPE_IMAGE :
$options["path"] = "";
$options["meta"] = true;
$options["mediatype"] = $mediatype;
$options[Image::OPTION_SIZE] = $config["image"]["definitions"][$preset][Image::OPTION_SIZE];
$options["dpi"] = $config["image"]["definitions"][$preset][Image::OPTION_RESOLUTION];
$options[Image::OPTION_STRIP] = $config["image"]["definitions"][$preset][Image::OPTION_STRIP];
$options[Image::OPTION_FLATTEN] = $config["image"]["definitions"][$preset][Image::OPTION_FLATTEN];
$options[Image::OPTION_QUALITY] = $config["image"]["definitions"][$preset][Image::OPTION_QUALITY];
$options[Image::OPTION_ICODEC] = $config["image"]["definitions"][$preset][Image::OPTION_ICODEC];
foreach ($config["image"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
$options[Subdef::OPTION_DEVICE][] = $devices;
}
break;
case Subdef::TYPE_VIDEO :
$options["path"] = "";
$options["meta"] = true;
$options["mediatype"] = $mediatype;
$options[Video::OPTION_AUDIOBITRATE] = $config["video"]["definitions"][$preset][Video::OPTION_AUDIOBITRATE];
$options[Video::OPTION_AUDIOSAMPLERATE] = $config["video"]["definitions"][$preset][Video::OPTION_AUDIOSAMPLERATE];
$options[Video::OPTION_BITRATE] = $config["video"]["definitions"][$preset][Video::OPTION_BITRATE];
$options[Video::OPTION_GOPSIZE] = $config["video"]["definitions"][$preset][Video::OPTION_GOPSIZE];
$options[Video::OPTION_SIZE] = $config["video"]["definitions"][$preset][Video::OPTION_SIZE];
$options[Video::OPTION_FRAMERATE] = $config["video"]["definitions"][$preset][Video::OPTION_FRAMERATE];
$options[Video::OPTION_VCODEC] = $config["video"]["definitions"][$preset][Video::OPTION_VCODEC];
$options[Video::OPTION_ACODEC] = $config["video"]["definitions"][$preset][Video::OPTION_ACODEC];
foreach ($config["video"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
$options[Subdef::OPTION_DEVICE][] = $devices;
}
break;
case Subdef::TYPE_FLEXPAPER :
$options["path"] = "";
$options["meta"] = true;
$options["mediatype"] = $mediatype;
foreach ($config["document"]["definitions"][$preset]["devices"] as $devices) {
$options["devices"][] = $devices;
}
break;
case Subdef::TYPE_ANIMATION :
$options["path"] = "";
$options["meta"] = true;
$options["mediatype"] = $mediatype;
$options[Gif::OPTION_SIZE] = $config["gif"]["definitions"][$preset][Gif::OPTION_SIZE];
$options[Gif::OPTION_DELAY] = $config["gif"]["definitions"][$preset][Gif::OPTION_DELAY];
foreach ($config["gif"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
$options[Subdef::OPTION_DEVICE][] = $devices;
}
break;
case Subdef::TYPE_AUDIO :
$options["path"] = "";
$options["meta"] = true;
$options["mediatype"] = $mediatype;
$options[Audio::OPTION_AUDIOBITRATE] = $config["audio"]["definitions"][$preset][Audio::OPTION_AUDIOBITRATE];
$options[Audio::OPTION_AUDIOSAMPLERATE] = $config["audio"]["definitions"][$preset][Audio::OPTION_AUDIOSAMPLERATE];
$options[Audio::OPTION_ACODEC] = $config["audio"]["definitions"][$preset][Audio::OPTION_ACODEC];
foreach ($config["audio"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
$options[Subdef::OPTION_DEVICE][] = $devices;
}
break;
}
$subdefs->set_subdef($group, $name, $class, false, $options, [], true, $preset);
}
$subdefs->add_subdef($group, $name, $class);
} else {
$subdefs = $databox->get_subdef_structure();
$this->updateSubdefGroups($subdefs, $request);
foreach ($Parmsubdefs as $post_sub) {
$options = [];
@@ -81,6 +164,7 @@ class SubdefsController extends Controller
$group = $post_sub_ex[0];
$name = $post_sub_ex[1];
$preset = $request->request->get($post_sub . '_presets');
$class = $request->request->get($post_sub . '_class');
$downloadable = $request->request->get($post_sub . '_downloadable');
$orderable = $request->request->get($post_sub . '_orderable');
@@ -96,7 +180,6 @@ class SubdefsController extends Controller
$options[$def] = $parm_loc;
}
$mediatype = $request->request->get($post_sub . '_mediatype');
$media = $request->request->get($post_sub . '_' . $mediatype, []);
@@ -110,8 +193,7 @@ class SubdefsController extends Controller
}
$labels = $request->request->get($post_sub . '_label', []);
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable);
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable, $preset);
}
}
@@ -121,35 +203,359 @@ class SubdefsController extends Controller
}
/**
* Update Databox subdefsStructure DOM according to defined groups.
*
* @param \databox_subdefsStructure $subdefs
* @param Request $request
* @return array
*/
private function updateSubdefGroups(\databox_subdefsStructure $subdefs, Request $request)
protected function getSubviewsMapping()
{
$subdefsGroups = $request->request->get('subdefsgroups', []);
$changedGroups = [];
$mapping = [
Type::TYPE_IMAGE => [Subdef::TYPE_IMAGE],
Type::TYPE_VIDEO => [Subdef::TYPE_IMAGE, Subdef::TYPE_VIDEO, Subdef::TYPE_ANIMATION],
Type::TYPE_AUDIO => [Subdef::TYPE_IMAGE, Subdef::TYPE_AUDIO],
Type::TYPE_DOCUMENT => [Subdef::TYPE_IMAGE, Subdef::TYPE_FLEXPAPER],
Type::TYPE_FLASH => [Subdef::TYPE_IMAGE]
];
/** @var SubdefGroup $subdefsGroup */
foreach ($subdefs as $groupName => $subdefsGroup) {
$documentOrderable = isset($subdefsGroups[$groupName]['document_orderable'])
? \p4field::isyes($subdefsGroups[$groupName]['document_orderable'])
: false;
return $mapping;
}
if ($subdefsGroup->isDocumentOrderable() !== $documentOrderable) {
if ($documentOrderable) {
$subdefsGroup->allowDocumentOrdering();
} else {
$subdefsGroup->disallowDocumentOrdering();
}
/**
* @return array
*/
protected function getConfiguration()
{
$config = [
Subdef::TYPE_IMAGE => [
"definitions" => [
"JPG" => null,
"160px JPG" => [
Image::OPTION_SIZE => "160",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "jpeg",
Subdef::OPTION_DEVICE => ["all"]
],
"320 px JPG (thumbnail Phraseanet)" => [
Image::OPTION_SIZE => "320",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "jpeg",
Subdef::OPTION_DEVICE => ["all"]
],
"640px JPG" => [
Image::OPTION_SIZE => "640",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "jpeg",
Subdef::OPTION_DEVICE => ["all"]
],
"1280px JPG (preview Phraseanet)" => [
Image::OPTION_SIZE => "1280",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "jpeg",
Subdef::OPTION_DEVICE => ["all"]
],
"2560px JPG" => [
Image::OPTION_SIZE => "2560",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "jpeg",
Subdef::OPTION_DEVICE => ["all"]
],
"PNG" => null,
"160px PNG 8 bits" => [
Image::OPTION_SIZE => "160",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "png",
Subdef::OPTION_DEVICE => ["all"]
],
"320px PNG 8 bits" => [
Image::OPTION_SIZE => "320",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "png",
Subdef::OPTION_DEVICE => ["all"]
],
"640px PNG 8 bits" => [
Image::OPTION_SIZE => "640",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "png",
Subdef::OPTION_DEVICE => ["all"]
],
"1280px PNG 8 bits" => [
Image::OPTION_SIZE => "1280",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "png",
Subdef::OPTION_DEVICE => ["all"]
],
"2560px PNG 8 bits" => [
Image::OPTION_SIZE => "2560",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "png",
Subdef::OPTION_DEVICE => ["all"]
],
"TIFF" => null,
"1280 TIFF" => [
Image::OPTION_SIZE => "1280",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "tiff",
Subdef::OPTION_DEVICE => ["all"]
],
"2560px TIFF" => [
Image::OPTION_SIZE => "2560",
Image::OPTION_RESOLUTION => "75",
Image::OPTION_STRIP => "yes",
Image::OPTION_FLATTEN => "yes",
Image::OPTION_QUALITY => "75",
Image::OPTION_ICODEC => "tiff",
Subdef::OPTION_DEVICE => ["all"]
],
],
"form" => [
Image::OPTION_SIZE => "slide",
Image::OPTION_RESOLUTION => "slide",
Image::OPTION_STRIP => "radio",
Image::OPTION_FLATTEN => "radio",
Image::OPTION_QUALITY => "slide",
Image::OPTION_ICODEC => "select",
Subdef::OPTION_DEVICE => "checkbox",
],
],
Subdef::TYPE_VIDEO => [
"definitions" => [
"video codec H264" => null,
"144P H264 128 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "128",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "256",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libx264",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"240P H264 256 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "256",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "426",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libx264",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"360P H264 576 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "576",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "480",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libtheora",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"480P H264 750 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "750",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "854",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libx264",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"720P H264 1492 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "1492",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "1280",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libx264",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"1080P H264 2420 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "2420",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "1920",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libx264",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"video codec libvpx" => null,
"144P webm 128 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "128",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "256",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libvpx",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"240P webm 256 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "256",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "426",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libvpx",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"360P webm 576 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "576",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "480",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libvpx",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"480P webm 750 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "750",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "854",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libvpx",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"720P webm 1492 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "1492",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "1280",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libvpx",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
"1080P webm 2420 kbps ACC 128kbps" => [
Video::OPTION_AUDIOBITRATE => "128",
Video::OPTION_AUDIOSAMPLERATE => "44100",
Video::OPTION_BITRATE => "2420",
Video::OPTION_GOPSIZE => "25",
Video::OPTION_SIZE => "1920",
Video::OPTION_FRAMERATE => "25",
Video::OPTION_VCODEC => "libvpx",
Video::OPTION_ACODEC => "libfaac",
Subdef::OPTION_DEVICE => ["all"]
],
],
"form" => [
Video::OPTION_AUDIOBITRATE => "slide",
Video::OPTION_AUDIOSAMPLERATE => "select",
Video::OPTION_BITRATE => "slide",
Video::OPTION_GOPSIZE => "slide",
Video::OPTION_SIZE => "slide",
Video::OPTION_FRAMERATE => "slide",
Video::OPTION_VCODEC => "select",
Video::OPTION_ACODEC => "select",
Subdef::OPTION_DEVICE => "checkbox",
],
],
Subdef::TYPE_ANIMATION => [
"definitions" => [
"256 px fast 200 ms" => [
Gif::OPTION_SIZE => "256",
Gif::OPTION_DELAY => "200",
Subdef::OPTION_DEVICE => ["all"]
],
"256 px very fast 120 ms" => [
Gif::OPTION_SIZE => "256",
Gif::OPTION_DELAY => "120",
Subdef::OPTION_DEVICE => ["all"]
],
"320 px fast 200 ms" => [
Gif::OPTION_SIZE => "320",
Gif::OPTION_DELAY => "200",
Subdef::OPTION_DEVICE => ["all"]
],
],
"form" => [
Gif::OPTION_SIZE => "slide",
Gif::OPTION_DELAY => "slide",
Subdef::OPTION_DEVICE => "checkbox",
],
],
Subdef::TYPE_AUDIO => [
"definitions" => [
"Low AAC 96 kbit/s" => [
Audio::OPTION_AUDIOBITRATE => "100",
Audio::OPTION_AUDIOSAMPLERATE => "8000",
Audio::OPTION_ACODEC => "libmp3lame",
Subdef::OPTION_DEVICE => ["all"]
],
"Normal AAC 128 kbit/s" => [
Audio::OPTION_AUDIOBITRATE => "180",
Audio::OPTION_AUDIOSAMPLERATE => "44100",
Audio::OPTION_ACODEC => "libmp3lame",
Subdef::OPTION_DEVICE => ["all"]
],
"High AAC 320 kbit/s" => [
Audio::OPTION_AUDIOBITRATE => "230",
Audio::OPTION_AUDIOSAMPLERATE => "50000",
Audio::OPTION_ACODEC => "libmp3lame",
Subdef::OPTION_DEVICE => ["all"]
],
],
"form" => [
Audio::OPTION_AUDIOBITRATE => "slide",
Audio::OPTION_AUDIOSAMPLERATE => "select",
Audio::OPTION_ACODEC => "select",
Subdef::OPTION_DEVICE => "checkbox",
],
],
Subdef::TYPE_FLEXPAPER => [
"definitions" => [
],
"form" => [],
],
];
$changedGroups[] = $subdefsGroup;
}
}
if ($changedGroups) {
$subdefs->updateSubdefGroups($changedGroups);
}
return $config;
}
}

View File

@@ -376,6 +376,7 @@ class V1Controller extends Controller
'password' => $conf->get(['registry', 'email', 'smtp-password']),
],
],
'custom-links' => $conf->get(['registry', 'custom-links']),
'ftp' => [
'active' => $conf->get(['registry', 'ftp', 'ftp-enabled']),
'activeForUser' => $conf->get(['registry', 'ftp', 'ftp-user-access']),

View File

@@ -168,11 +168,11 @@ class ExportController extends Controller
$request->request->get('businessfields')
);
$separator = preg_split('//', ' ;,', -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$separator = '/\\' . implode('|\\', $separator) . '/';
$list['export_name'] = sprintf("%s.zip", $download->getExportName());
$list['email'] = implode(';', preg_split($separator, $request->request->get("destmail", "")));
$separator = '/\ |\;|\,/';
// add PREG_SPLIT_NO_EMPTY to only return non-empty values
$list['email'] = implode(';', preg_split($separator, $request->request->get("destmail", ""), -1, PREG_SPLIT_NO_EMPTY));
$destMails = [];
//get destination mails

View File

@@ -36,6 +36,32 @@ class MoveCollectionController extends Controller
} else {
// is able to move:
$success = true;
/** @var DisplaySettingService $settings */
$settings = $this->app['settings'];
$userOrderSetting = $settings->getUserSetting($this->app->getAuthenticatedUser(), 'order_collection_by');
// a temporary array to sort the collections
$aName = [];
list($ukey, $uorder) = ["order", SORT_ASC]; // default ORDER_BY_ADMIN
switch ($userOrderSetting) {
case $settings::ORDER_ALPHA_ASC :
list($ukey, $uorder) = ["name", SORT_ASC];
break;
case $settings::ORDER_ALPHA_DESC :
list($ukey, $uorder) = ["name", SORT_DESC];
break;
}
foreach ($collections as $key => $row) {
if ($ukey == "order") {
$aName[$key] = $row->get_ord();
}
else {
$aName[$key] = $row->get_name();
}
}
// sort the collections
array_multisort($aName, $uorder, SORT_REGULAR, $collections);
$parameters = [
'records' => $records,
'message' => '',

View File

@@ -23,44 +23,71 @@ class ShareController extends Controller
*/
public function shareRecord($base_id, $record_id)
{
$outputVars = [
'isAvailable' => false,
'preview' => [
'permalinkUrl' => '',
'permaviewUrl' => '',
'embedUrl' => '',
'width' => '',
'height' => ''
]
];
$record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id);
if (!$this->getAclForUser()->has_access_to_subdef($record, 'preview')) {
$this->app->abort(403);
}
//get list of subdefs
$subdefs = $record->get_subdefs();
$preview = $record->get_preview();
$databoxSubdefs = $record->getDatabox()->get_subdef_structure()->getSubdefGroup($record->getType());
$acl = $this->getAclForUser();
$subdefList = [];
$defaultKey = null;
foreach ($subdefs as $subdef) {
$subdefName = $subdef->get_name();
if ($subdefName == 'document') {
if (!$acl->has_right_on_base($record->getBaseId(), \ACL::CANDWNLDHD)) {
continue;
}
$label = $this->app->trans('prod::tools: document');
}
elseif ($databoxSubdefs->hasSubdef($subdefName)) {
if (!$acl->has_access_to_subdef($record, $subdefName)) {
continue;
}
$label = $databoxSubdefs->getSubdef($subdefName)->get_label($this->app['locale']);
}
else {
// this subdef does no exists anymore in databox structure ?
continue; // don't publish it
}
$value = $subdef->get_name();
$preview = $record->get_subdef($value);
$defaultKey = $value; // will set a default option if neither preview,thumbnail or document is present
if (null !== $previewLink = $preview->get_permalink()) {
$permalinkUrl = $previewLink->get_url();
$permaviewUrl = $previewLink->get_page();
$previewWidth = $preview->get_width();
$previewHeight = $preview->get_height();
$embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]);
$outputVars = [
'isAvailable' => true,
'preview' => [
if (($previewLink = $preview->get_permalink()) !== null) {
$permalinkUrl = $previewLink->get_url()->__toString();
$permaviewUrl = $previewLink->get_page();
$previewWidth = $preview->get_width();
$previewHeight = $preview->get_height();
$embedUrl = $this->app->url('alchemy_embed_view', ['url' => (string)$permalinkUrl]);
$previewData = [
'label' => $label,
'permalinkUrl' => $permalinkUrl,
'permaviewUrl' => $permaviewUrl,
'embedUrl' => $embedUrl,
'width' => $previewWidth,
'height' => $previewHeight
]
];
'embedUrl' => $embedUrl,
'width' => $previewWidth,
'height' => $previewHeight
];
$subdefList[$value] = $previewData;
}
}
// candidates as best default selected option
foreach (["preview", "thumbnail", "document"] as $k) {
if (array_key_exists($k, $subdefList)) {
$defaultKey = $k;
break;
}
}
// if no subdef was sharable, subdefList is empty and defaultKey is null
// the twig MUST handle that
$outputVars = [
'isAvailable' => !empty($subdefList),
'subdefList' => $subdefList,
'defaultKey' => $defaultKey
];
return $this->renderResponse('prod/Share/record.html.twig', $outputVars);
}
}

View File

@@ -243,20 +243,45 @@ class UploadController extends Controller
{
$collections = [];
foreach ($acl->get_granted_base([\ACL::CANADDRECORD]) as $collection) {
$databox = $collection->get_databox();
if ( ! isset($collections[$databox->get_sbas_id()])) {
$collections[$databox->get_sbas_id()] = [
'databox' => $databox,
'databox_collections' => []
];
foreach ($acl->get_granted_sbas() as $databox) {
$sbasId = $databox->get_sbas_id();
foreach ($acl->get_granted_base([\ACL::CANADDRECORD], [$sbasId]) as $collection) {
$databox = $collection->get_databox();
if (!isset($collections[$sbasId])) {
$collections[$databox->get_sbas_id()] = [
'databox' => $databox,
'databox_collections' => []
];
}
$collections[$databox->get_sbas_id()]['databox_collections'][] = $collection;
/** @var DisplaySettingService $settings */
$settings = $this->app['settings'];
$userOrderSetting = $settings->getUserSetting($this->app->getAuthenticatedUser(), 'order_collection_by');
// a temporary array to sort the collections
$aName = [];
list($ukey, $uorder) = ["order", SORT_ASC]; // default ORDER_BY_ADMIN
switch ($userOrderSetting) {
case $settings::ORDER_ALPHA_ASC :
list($ukey, $uorder) = ["name", SORT_ASC];
break;
case $settings::ORDER_ALPHA_DESC :
list($ukey, $uorder) = ["name", SORT_DESC];
break;
}
foreach ($collections[$databox->get_sbas_id()]['databox_collections'] as $key => $row) {
if ($ukey == "order") {
$aName[$key] = $row->get_ord();
}
else {
$aName[$key] = $row->get_name();
}
}
// sort the collections
array_multisort($aName, $uorder, SORT_REGULAR, $collections[$databox->get_sbas_id()]['databox_collections']);
}
$collections[$databox->get_sbas_id()]['databox_collections'][] = $collection;
}
return $collections;
}
/**

View File

@@ -77,7 +77,7 @@ class SetupController extends Controller
return $this->render('/setup/step2.html.twig', [
'locale' => $this->app['locale'],
'available_locales' => Application::getAvailableLanguages(),
'available_templates' => ['en', 'fr'],
'available_templates' => $this->app['phraseanet.structure-template']->getAvailable()->getTemplates(),
'warnings' => $warnings,
'error' => $request->query->get('error'),
'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/',

View File

@@ -47,10 +47,22 @@ class Share implements ControllerProviderInterface, ServiceProviderInterface
$controllers->get('/record/{base_id}/{record_id}/', 'controller.prod.share:shareRecord')
->before(function (Request $request) use ($app, $firewall) {
$firewall->requireRightOnSbas(
\phrasea::sbasFromBas($app, $request->attributes->get('base_id')),
\ACL::BAS_CHUPUB
);
$socialTools = $app['conf']->get(['registry', 'actions', 'social-tools']);
if ($socialTools === "all") {
return;
}
elseif ($socialTools === "none") {
$app->abort(403, 'social tools disabled');
}
elseif ($socialTools === "publishers") {
$firewall->requireRightOnSbas(
\phrasea::sbasFromBas($app, $request->attributes->get('base_id')),
\ACL::BAS_CHUPUB
);
}
else {
throw new \Exception("bad value \"" . $socialTools . "\" for social tools");
}
})
->bind('share_record');

View File

@@ -15,6 +15,10 @@ use Alchemy\Phrasea\Model\Entities\User;
class DisplaySettingService
{
const ORDER_ALPHA_ASC = "ORDER_ALPHA_ASC";
const ORDER_ALPHA_DESC = "ORDER_ALPHA_DESC";
const ORDER_BY_ADMIN = "ORDER_BY_ADMIN";
/**
* The default user settings.
*
@@ -34,6 +38,7 @@ class DisplaySettingService
'client_basket_status' => '1',
'css' => '000000',
'start_page_query' => '',
'order_collection_by' => self::ORDER_BY_ADMIN,
'start_page' => 'QUERY',
'rollover_thumbnail' => 'caption',
'technical_display' => '1',

View File

@@ -110,7 +110,7 @@ class RegistryFormManipulator
'thumb-substitution' => true,
'anonymous-report' => false,
],
'actions' => [
'actions' => [
'download-max-size' => 120,
'validation-reminder-days' => 2,
'validation-expiration-days' => 10,
@@ -123,7 +123,7 @@ class RegistryFormManipulator
'force-push-authentication' => false,
'enable-feed-notification' => true,
],
'ftp' => [
'ftp' => [
'ftp-enabled' => false,
'ftp-user-access' => false,
],
@@ -131,23 +131,23 @@ class RegistryFormManipulator
'auto-select-collections' => true,
'auto-register-enabled' => false,
],
'maintenance' => [
'maintenance' => [
'message' => 'The application is down for maintenance',
'enabled' => false,
],
'api-clients' => [
'api-clients' => [
'api-enabled' => true,
'navigator-enabled' => true,
'office-enabled' => true,
],
'webservices' => [
'webservices' => [
'google-charts-enabled' => true,
'geonames-server' => 'http://geonames.alchemyasp.com/',
'captchas-enabled' => false,
'recaptcha-public-key' => '',
'recaptcha-private-key' => '',
],
'executables' => [
'executables' => [
'h264-streaming-enabled' => false,
'auth-token-directory' => null,
'auth-token-directory-path' => null,
@@ -162,7 +162,7 @@ class RegistryFormManipulator
'default-query' => '',
'default-query-type' => 0,
],
'email' => [
'email' => [
'emitter-email' => 'phraseanet@example.com',
'prefix' => null,
'smtp-enabled' => false,
@@ -173,6 +173,22 @@ class RegistryFormManipulator
'smtp-user' => null,
'smtp-password' => isset($config['email']['smtp-password']) ? $config['email']['smtp-password'] : null,
],
'custom-links' => [
[
'linkName' => 'Phraseanet store',
'linkLanguage' => 'fr',
'linkUrl' => 'https://alchemy.odoo.com/shop',
'linkLocation' => 'help-menu',
'linkOrder' => '1',
],
[
'linkName' => 'Phraseanet store',
'linkLanguage' => 'en',
'linkUrl' => 'https://alchemy.odoo.com/en_US/shop',
'linkLocation' => 'help-menu',
'linkOrder' => '1',
],
]
];
}
}

View File

@@ -0,0 +1,109 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Core\Configuration;
use Alchemy\Phrasea\Application;
/**
* Class StructureTemplate
* @package Alchemy\Phrasea\Core\Configuration
*/
class StructureTemplate
{
const TEMPLATE_EXTENSION = 'xml';
private $templates;
public function __construct(Application $app)
{
$this->app = $app;
}
/**
* @return $this
* @throws \Exception
*/
public function getAvailable()
{
$templateList = new \DirectoryIterator($this->app['root.path'] . '/lib/conf.d/data_templates');
if (empty($templateList)) {
throw new \Exception('No available structure template');
}
$templates = [];
$abbreviationLength = 2;
foreach ($templateList as $template) {
if ($template->isDot()
|| !$template->isFile()
|| $template->getExtension() !== self::TEMPLATE_EXTENSION
) {
continue;
}
$name = $template->getFilename();
$abbreviation = strtolower(substr($name, 0, $abbreviationLength));
if (array_key_exists($abbreviation, $templates)) {
$abbreviation = strtolower(substr($name, 0, ++$abbreviationLength));
}
$templates[$abbreviation] = $template->getBasename('.' . self::TEMPLATE_EXTENSION);
}
$this->templates = $templates;
return $this;
}
/**
* @return string
*/
public function __toString()
{
if (!$this->templates) {
return '';
}
$templateToString = '';
$cpt = 1;
$templateLength = count($this->templates);
foreach ($this->templates as $key => $value) {
if (($templateLength - 1) == $cpt) {
$separator = ' and ';
}
elseif (end($this->templates) == $value) {
$separator = '';
}
else {
$separator = ', ';
}
$templateToString .= $key . ' (' . $value . ')' . $separator;
$cpt++;
}
return $templateToString;
}
/**
* @param $template
* @return mixed
* @throws \Exception
*/
public function getTemplateName($template = 'en')
{
if (!array_key_exists($template, $this->templates)) {
throw new \Exception('Not found template : ' . $template);
}
return $this->templates[$template];
}
/**
* @return mixed
*/
public function getTemplates()
{
return $this->templates;
}
}

View File

@@ -11,6 +11,8 @@
namespace Alchemy\Phrasea\Core\Provider;
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration\StructureTemplate;
use Alchemy\Phrasea\Core\Configuration\AccessRestriction;
use Alchemy\Phrasea\Core\Configuration\Configuration;
use Alchemy\Phrasea\Core\Configuration\DisplaySettingService;
@@ -71,6 +73,10 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
$app['conf.restrictions'] = $app->share(function (SilexApplication $app) {
return new AccessRestriction($app['conf'], $app->getApplicationBox(), $app['monolog']);
});
$app['phraseanet.structure-template'] = $app->share(function (Application $app) {
return new StructureTemplate($app);
});
}
/**

View File

@@ -0,0 +1,49 @@
<?php
namespace Alchemy\Phrasea\Databox\Subdef;
class SubdefPreset
{
/**
* @var string
*/
private $mediaType;
/**
* @var string
*/
private $label;
/**
* @var array
*/
private $definitions;
/**
* @param string $mediaType
* @param array $definitions
*/
public function __construct($mediaType, array $definitions)
{
foreach ($definitions as $definition) {
if (!$definition instanceof Subdef) {
}
}
$this->mediaType = (string)$mediaType;
$this->definitions = $definitions;
}
/**
* @return string
*/
public function getMediaType()
{
return $this->label;
}
/**
* @return array
*/
public function getDefinitions()
{
return $this->definitions;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Alchemy\Phrasea\Databox\Subdef;
class SubdefPresetProvider
{
private $presets = [];
/**
* @param string $type Type of media for which to get presets
* @return SubdefPreset[]
*/
public function getPresets($type)
{
if (!isset($this->presets[$type])) {
throw new \InvalidArgumentException('Invalid type');
}
return $this->presets[$type];
}
}

View File

@@ -0,0 +1,94 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Form\Configuration;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class CustomLinkFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('linkName', 'text', [
'label' => false,
'attr' => [
'placeholder' => 'setup::custom-link:name-link',
'required' => true,
'maxlength' => "30"
]
]);
$builder->add('linkLanguage', 'choice', [
'label' => false,
'attr' => [
'required' => true
],
'choices' => [
'' => 'setup::custom-link:select-language',
'all' => 'All',
'fr' => 'FR',
'en' => 'EN',
'es' => 'ES',
'ar' => 'AR',
'de' => 'DE',
'du' => 'DU'
]
]);
$builder->add('linkUrl', 'url', [
'label' => false,
'attr' => [
'placeholder' => 'setup::custom-link:placeholder-link-url',
'required' => true
]
]);
$builder->add('linkLocation', 'choice', [
'label' => false,
'attr' => [
'required' => true
],
'choices' => [
'' => 'setup::custom-link:location',
'help-menu' => 'setup::custom-link:help-menu',
'navigation-bar' => 'setup::custom-link:navigation-bar',
]
]);
$builder->add('linkOrder', 'integer', [
'label' => false,
]);
$builder->add('linkBold', 'checkbox', [
'label' => false,
]);
$builder->add('linkColor', 'choice', [
'label' => false,
'choices' => [
'' => '#ad0800',
'#ad0800' => '#ad0800',
'#f06006' => '#f06006',
'#f5842b' => '#f5842b',
'#ffc322' => '#ffc322',
'#f4ea5b' => '#f4ea5b',
'#b8d84e' => '#b8d84e',
'#5aa53b' => '#5aa53b',
'#a1d0d0' => '#a1d0d0',
'#4497d5' => '#4497d5',
'#3567c6' => '#3567c6',
'#b151ee' => '#b151ee',
'#c875ea' => '#c875ea',
'#e46990' => '#e46990',
'#ffccd7' => '#ffccd7'
]
]);
}
public function getName()
{
return null;
}
}

View File

@@ -15,6 +15,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
class MainConfigurationFormType extends AbstractType
{
@@ -62,12 +63,19 @@ class MainConfigurationFormType extends AbstractType
$builder->add('email', new EmailFormType(), [
'label' => 'Emails',
]);
$builder->add('custom-links', CollectionType::class, [
'entry_type' => CustomLinkFormType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true,
]);
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults([
'required' => false,
'required' => false,
'allow_extra_fields' => true
]);
}

View File

@@ -46,10 +46,34 @@ class Prod extends Helper
$selected = $saveSettings ? ((isset($searchSet['bases']) && isset($searchSet['bases'][$sbasId])) ? (in_array($coll->get_base_id(), $searchSet['bases'][$sbasId])) : true) : true;
$bases[$sbasId]['collections'][] = array(
'selected' => $selected,
'base_id' => $coll->get_base_id()
'base_id' => $coll->get_base_id(),
'name' => $coll->get_name(),
'order' => $coll->get_ord()
);
}
/** @var DisplaySettingService $settings */
$settings = $this->app['settings'];
$userOrderSetting = $settings->getUserSetting($this->app->getAuthenticatedUser(), 'order_collection_by');
// a temporary array to sort the collections
$aName = [];
list($ukey, $uorder) = ["order", SORT_ASC]; // default ORDER_BY_ADMIN
switch ($userOrderSetting) {
case $settings::ORDER_ALPHA_ASC :
list($ukey, $uorder) = ["name", SORT_ASC];
break;
case $settings::ORDER_ALPHA_DESC :
list($ukey, $uorder) = ["name", SORT_DESC];
break;
}
foreach ($bases[$sbasId]['collections'] as $key => $row) {
$aName[$key] = $row[$ukey];
}
// sort the collections
array_multisort($aName, $uorder, SORT_REGULAR, $bases[$sbasId]['collections']);
foreach ($databox->get_meta_structure() as $fieldMeta) {
if (!$fieldMeta->is_indexable()) {
continue;

View File

@@ -15,6 +15,8 @@ use MediaAlchemyst\Specification\SpecificationInterface;
interface Subdef
{
const OPTION_DEVICE = 'devices';
const TYPE_IMAGE = 'image';
const TYPE_ANIMATION = 'gif';
const TYPE_VIDEO = 'video';

View File

@@ -53,7 +53,7 @@ class Installer
private function createDB(Connection $dbConn = null, $template, User $admin)
{
$template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $template . '-simple.xml');
$template = new \SplFileInfo(__DIR__ . '/../../../conf.d/data_templates/' . $this->app['phraseanet.structure-template']->getAvailable()->getTemplateName($template) . '.xml');
$databox = \databox::create($this->app, $dbConn, $template);
$this->app->getAclForUser($admin)

View File

@@ -7,40 +7,18 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Media\Subdef\Image;
use Alchemy\Phrasea\Media\Subdef\Audio;
use Alchemy\Phrasea\Media\Subdef\Video;
use Alchemy\Phrasea\Media\Subdef\FlexPaper;
use Alchemy\Phrasea\Media\Subdef\Gif;
use Alchemy\Phrasea\Media\Subdef\Image;
use Alchemy\Phrasea\Media\Subdef\Unknown;
use Alchemy\Phrasea\Media\Subdef\Subdef as SubdefSpecs;
use Alchemy\Phrasea\Media\Subdef\Video;
use Alchemy\Phrasea\Media\Type\Type as SubdefType;
use MediaAlchemyst\Specification\SpecificationInterface;
use Symfony\Component\Translation\TranslatorInterface;
class databox_subdef
{
const CLASS_THUMBNAIL = 'thumbnail';
const CLASS_PREVIEW = 'preview';
const CLASS_DOCUMENT = 'document';
const DEVICE_ALL = 'all';
const DEVICE_HANDHELD = 'handheld';
const DEVICE_PRINT = 'print';
const DEVICE_PROJECTION = 'projection';
const DEVICE_SCREEN = 'screen';
const DEVICE_TV = 'tv';
protected static $mediaTypeToSubdefTypes = [
SubdefType::TYPE_AUDIO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO],
SubdefType::TYPE_DOCUMENT => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER],
SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE],
SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE],
SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION],
SubdefType::TYPE_UNKNOWN => [SubdefSpecs::TYPE_IMAGE]
];
/**
* The class type of the subdef
* Is null or one of the CLASS_* constants
@@ -51,52 +29,61 @@ class databox_subdef
protected $devices = [];
protected $name;
protected $path;
protected $preset;
protected $subdef_group;
protected $labels = [];
protected $downloadable;
protected $translator;
/**
* @var bool
*/
private $requiresMetadataUpdate;
protected $downloadable;
protected $translator;
protected static $mediaTypeToSubdefTypes = [
SubdefType::TYPE_AUDIO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO],
SubdefType::TYPE_DOCUMENT => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER],
SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE],
SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE],
SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION],
SubdefType::TYPE_UNKNOWN => [SubdefSpecs::TYPE_IMAGE],
];
const CLASS_THUMBNAIL = 'thumbnail';
const CLASS_PREVIEW = 'preview';
const CLASS_DOCUMENT = 'document';
const DEVICE_ALL = 'all';
const DEVICE_HANDHELD = 'handheld';
const DEVICE_PRINT = 'print';
const DEVICE_PROJECTION = 'projection';
const DEVICE_SCREEN = 'screen';
const DEVICE_TV = 'tv';
/**
* @var bool
*/
private $orderable;
/**
*
* @param SubdefType $type
* @param SimpleXMLElement $sd
* @param TranslatorInterface $translator
*
* @return databox_subdef
*/
public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator)
{
$this->subdef_group = $type;
$this->class = (string) $sd->attributes()->class;
$this->class = (string)$sd->attributes()->class;
$this->translator = $translator;
foreach ($sd->devices as $device) {
$this->devices[] = (string) $device;
$this->devices[] = (string)$device;
}
$this->name = strtolower($sd->attributes()->name);
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
$this->orderable = isset($sd->attributes()->orderable) ? p4field::isyes($sd->attributes()->orderable) : true;
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
$this->requiresMetadataUpdate = p4field::isyes((string) $sd->meta);
$this->preset = $sd->attributes()->presets;
$this->requiresMetadataUpdate = p4field::isyes((string)$sd->meta);
foreach ($sd->label as $label) {
$lang = trim((string) $label->attributes()->lang);
$lang = trim((string)$label->attributes()->lang);
if ($lang) {
$this->labels[$lang] = (string) $label;
$this->labels[$lang] = (string)$label;
}
}
switch ((string) $sd->mediatype) {
switch ((string)$sd->mediatype) {
default:
case SubdefSpecs::TYPE_IMAGE:
$this->subdef_type = $this->buildImageSubdef($sd);
@@ -118,7 +105,6 @@ class databox_subdef
break;
}
}
/**
* Build Image Subdef object depending the SimpleXMLElement
*
@@ -128,7 +114,6 @@ class databox_subdef
protected function buildImageSubdef(SimpleXMLElement $sd)
{
$image = new Image($this->translator);
if ($sd->icodec) {
$image->setOptionValue(Image::OPTION_ICODEC, (string) $sd->icodec);
}
@@ -147,10 +132,8 @@ class databox_subdef
if ($sd->flatten) {
$image->setOptionValue(Image::OPTION_FLATTEN, p4field::isyes($sd->flatten));
}
return $image;
}
/**
* Build Audio Subdef object depending the SimpleXMLElement
*
@@ -160,7 +143,6 @@ class databox_subdef
protected function buildAudioSubdef(SimpleXMLElement $sd)
{
$audio = new Audio($this->translator);
if ($sd->acodec) {
$audio->setOptionValue(Audio::OPTION_ACODEC, (string) $sd->acodec);
}
@@ -170,10 +152,8 @@ class databox_subdef
if ($sd->audiosamplerate) {
$audio->setOptionValue(Audio::OPTION_AUDIOSAMPLERATE, (int) $sd->audiosamplerate);
}
return $audio;
}
/**
* Build Video Subdef object depending the SimpleXMLElement
*
@@ -183,7 +163,6 @@ class databox_subdef
protected function buildVideoSubdef(SimpleXMLElement $sd)
{
$video = new Video($this->translator);
if ($sd->size) {
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
}
@@ -208,10 +187,8 @@ class databox_subdef
if ($sd->GOPsize) {
$video->setOptionValue(Video::OPTION_GOPSIZE, (int) $sd->GOPsize);
}
return $video;
}
/**
* Build GIF Subdef object depending the SimpleXMLElement
*
@@ -221,17 +198,14 @@ class databox_subdef
protected function buildGifSubdef(SimpleXMLElement $sd)
{
$gif = new Gif($this->translator);
if ($sd->size) {
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
}
if ($sd->delay) {
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
}
return $gif;
}
/**
* Build Flexpaper Subdef object depending the SimpleXMLElement
*
@@ -242,8 +216,8 @@ class databox_subdef
{
return new FlexPaper($this->translator);
}
/**
*
* @return string
*/
public function get_class()
@@ -252,6 +226,16 @@ class databox_subdef
}
/**
*
* @return string
*/
public function get_preset()
{
return $this->preset;
}
/**
*
* @return string
*/
public function get_path()
@@ -262,7 +246,7 @@ class databox_subdef
/**
* The devices matching this subdefinition
*
* @return array
* @return Array
*/
public function getDevices()
{
@@ -272,7 +256,7 @@ class databox_subdef
/**
* The current SubdefType the subdef converts documents
*
* @return \Alchemy\Phrasea\Media\Subdef\Subdef
* @return Alchemy\Phrasea\Media\Subdef\Subdef
*/
public function getSubdefType()
{
@@ -292,7 +276,7 @@ class databox_subdef
/**
* An associative label ; keys are i18n languages
*
* @return array
* @return Array
*/
public function get_labels()
{
@@ -306,21 +290,12 @@ class databox_subdef
} elseif (isset($this->labels[$code])) {
return $this->labels[$code];
}
return null;
}
/**
* The name of the subdef
* boolean
*
* @return string
*/
public function get_name()
{
return $this->name;
}
/**
* @return bool
*/
public function isDownloadable()
@@ -344,7 +319,6 @@ class databox_subdef
public function getAvailableSubdefTypes()
{
$subdefTypes = [];
$availableDevices = [
self::DEVICE_ALL,
self::DEVICE_HANDHELD,
@@ -353,11 +327,8 @@ class databox_subdef
self::DEVICE_SCREEN,
self::DEVICE_TV,
];
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
if ($subdefType == $this->subdef_type->getType()) {
$mediatype_obj = $this->subdef_type;
} else {
@@ -385,13 +356,11 @@ class databox_subdef
break;
}
}
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi($this->translator->trans('Target Device'), 'devices', $availableDevices, $this->devices));
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi($this->translator->trans('Target Device'),
'devices', $availableDevices, $this->devices));
$subdefTypes[] = $mediatype_obj;
}
}
return $subdefTypes;
}
@@ -405,6 +374,16 @@ class databox_subdef
return $this->requiresMetadataUpdate;
}
/**
* The name of the subdef
*
* @return string
*/
public function get_name()
{
return $this->name;
}
/**
* Get the MediaAlchemyst specs for the current subdef
*
@@ -424,4 +403,4 @@ class databox_subdef
{
return $this->subdef_type->getOptions();
}
}
}

View File

@@ -9,8 +9,8 @@
*/
use Alchemy\Phrasea\Databox\SubdefGroup;
use Alchemy\Phrasea\Media\MediaTypeFactory;
use Assert\Assertion;
use Alchemy\Phrasea\Media\MediaTypeFactory;
use Symfony\Component\Translation\TranslatorInterface;
class databox_subdefsStructure implements IteratorAggregate, Countable
@@ -185,15 +185,19 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
* @param string $groupname
* @param string $name
* @param string $class
* @param string $mediatype
* @param string $preset
* @return databox_subdefsStructure
*/
public function add_subdef($groupname, $name, $class)
public function add_subdef($groupname, $name, $class, $mediatype, $preset)
{
$dom_struct = $this->databox->get_dom_structure();
$subdef = $dom_struct->createElement('subdef');
$subdef->setAttribute('class', $class);
$subdef->setAttribute('name', mb_strtolower($name));
$subdef->setAttribute('presets', $preset);
$subdef->setAttribute('mediaType', $mediatype);
$dom_xp = $this->databox->get_xpath_structure();
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
@@ -216,25 +220,6 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
return $this;
}
/**
* @param SubdefGroup[] $groups
*/
public function updateSubdefGroups($groups)
{
Assertion::allIsInstanceOf($groups, SubdefGroup::class);
$dom_xp = $this->databox->get_xpath_structure();
foreach ($groups as $group) {
$nodes = $dom_xp->query('//record/subdefs/subdefgroup[@name="' . $group->getName() . '"]');
/** @var DOMElement $node */
foreach ($nodes as $node) {
$node->setAttribute('document_orderable', ($group->isDocumentOrderable() ? 'true' : 'false'));
}
}
}
/**
* @param string $group
* @param string $name
@@ -242,11 +227,12 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
* @param boolean $downloadable
* @param array $options
* @param array $labels
* @param bool $orderable
* @param boolean $orderable
* @param string $preset
* @return databox_subdefsStructure
* @throws Exception
*/
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true)
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true, $preset = "Custom")
{
$dom_struct = $this->databox->get_dom_structure();
@@ -255,6 +241,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
$subdef->setAttribute('name', mb_strtolower($name));
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
$subdef->setAttribute('orderable', ($orderable ? 'true' : 'false'));
$subdef->setAttribute('presets', $preset);
foreach ($labels as $code => $label) {
$child = $dom_struct->createElement('label');

View File

@@ -431,6 +431,7 @@ class record_preview extends record_adapter
$nbDays--; // because 0 is included
for ($d=$nbDays; $d>=0; $d--) {
$datetime = new DateTime('-' . $d . ' days');
$datetime->modify('+1 day');
$date = date_format($datetime, 'Y-m-d');
if($d == $nbDays) {
$this->statistics['from'] = $date;