mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
PHRAS-1719 Add presets selection on subdef admin page
This commit is contained in:
@@ -12,8 +12,14 @@ namespace Alchemy\Phrasea\Controller\Admin;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\Databox\SubdefGroup;
|
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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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
|
class SubdefsController extends Controller
|
||||||
{
|
{
|
||||||
@@ -23,10 +29,14 @@ class SubdefsController extends Controller
|
|||||||
*/
|
*/
|
||||||
function indexAction($sbas_id) {
|
function indexAction($sbas_id) {
|
||||||
$databox = $this->findDataboxById((int) $sbas_id);
|
$databox = $this->findDataboxById((int) $sbas_id);
|
||||||
|
$config = $this->getConfiguration();
|
||||||
|
$subviews_mapping = $this->getSubviewsMapping();
|
||||||
|
|
||||||
return $this->render('admin/subdefs.html.twig', [
|
return $this->render('admin/subdefs.html.twig', [
|
||||||
'databox' => $databox,
|
'databox' => $databox,
|
||||||
'subdefs' => $databox->get_subdef_structure(),
|
'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);
|
$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) {
|
foreach ($add_subdef as $k => $v) {
|
||||||
if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') {
|
if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') {
|
||||||
unset($add_subdef[$k]);
|
unset($add_subdef[$k]);
|
||||||
@@ -58,7 +68,7 @@ class SubdefsController extends Controller
|
|||||||
$name = $delete_subef[1];
|
$name = $delete_subef[1];
|
||||||
$subdefs = $databox->get_subdef_structure();
|
$subdefs = $databox->get_subdef_structure();
|
||||||
$subdefs->delete_subdef($group, $name);
|
$subdefs->delete_subdef($group, $name);
|
||||||
} elseif (count($add_subdef) === 3) {
|
} elseif (count($add_subdef) === 5) {
|
||||||
$subdefs = $databox->get_subdef_structure();
|
$subdefs = $databox->get_subdef_structure();
|
||||||
|
|
||||||
$group = $add_subdef['group'];
|
$group = $add_subdef['group'];
|
||||||
@@ -66,11 +76,84 @@ class SubdefsController extends Controller
|
|||||||
$unicode = $this->app['unicode'];
|
$unicode = $this->app['unicode'];
|
||||||
$name = $unicode->remove_nonazAZ09($add_subdef['name'], false);
|
$name = $unicode->remove_nonazAZ09($add_subdef['name'], false);
|
||||||
$class = $add_subdef['class'];
|
$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, [], $preset);
|
||||||
|
}
|
||||||
|
|
||||||
$subdefs->add_subdef($group, $name, $class);
|
|
||||||
} else {
|
} else {
|
||||||
$subdefs = $databox->get_subdef_structure();
|
$subdefs = $databox->get_subdef_structure();
|
||||||
|
|
||||||
$this->updateSubdefGroups($subdefs, $request);
|
$this->updateSubdefGroups($subdefs, $request);
|
||||||
|
|
||||||
foreach ($Parmsubdefs as $post_sub) {
|
foreach ($Parmsubdefs as $post_sub) {
|
||||||
@@ -81,6 +164,7 @@ class SubdefsController extends Controller
|
|||||||
$group = $post_sub_ex[0];
|
$group = $post_sub_ex[0];
|
||||||
$name = $post_sub_ex[1];
|
$name = $post_sub_ex[1];
|
||||||
|
|
||||||
|
$preset = $request->request->get($post_sub . '_presets');
|
||||||
$class = $request->request->get($post_sub . '_class');
|
$class = $request->request->get($post_sub . '_class');
|
||||||
$downloadable = $request->request->get($post_sub . '_downloadable');
|
$downloadable = $request->request->get($post_sub . '_downloadable');
|
||||||
$orderable = $request->request->get($post_sub . '_orderable');
|
$orderable = $request->request->get($post_sub . '_orderable');
|
||||||
@@ -96,7 +180,6 @@ class SubdefsController extends Controller
|
|||||||
|
|
||||||
$options[$def] = $parm_loc;
|
$options[$def] = $parm_loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mediatype = $request->request->get($post_sub . '_mediatype');
|
$mediatype = $request->request->get($post_sub . '_mediatype');
|
||||||
$media = $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', []);
|
$labels = $request->request->get($post_sub . '_label', []);
|
||||||
|
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset, $orderable);
|
||||||
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,36 +202,389 @@ class SubdefsController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getSubviewsMapping()
|
||||||
|
{
|
||||||
|
$mapping = array(
|
||||||
|
Type::TYPE_IMAGE => array(Subdef::TYPE_IMAGE),
|
||||||
|
Type::TYPE_VIDEO => array(Subdef::TYPE_IMAGE, Subdef::TYPE_VIDEO, Subdef::TYPE_ANIMATION),
|
||||||
|
Type::TYPE_AUDIO => array(Subdef::TYPE_IMAGE, Subdef::TYPE_AUDIO),
|
||||||
|
Type::TYPE_DOCUMENT => array(Subdef::TYPE_IMAGE, Subdef::TYPE_FLEXPAPER),
|
||||||
|
Type::TYPE_FLASH => array(Subdef::TYPE_IMAGE)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $mapping;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Databox subdefsStructure DOM according to defined groups.
|
* Update Databox subdefsStructure DOM according to defined groups.
|
||||||
*
|
*
|
||||||
* @param \databox_subdefsStructure $subdefs
|
* @param \databox_subdefsStructure $subdefs
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*/
|
*/
|
||||||
private function updateSubdefGroups(\databox_subdefsStructure $subdefs, Request $request)
|
protected function updateSubdefGroups(\databox_subdefsStructure $subdefs, Request $request)
|
||||||
{
|
{
|
||||||
$subdefsGroups = $request->request->get('subdefsgroups', []);
|
$subdefsGroups = $request->request->get('subdefsgroups', []);
|
||||||
$changedGroups = [];
|
$changedGroups = [];
|
||||||
|
|
||||||
/** @var SubdefGroup $subdefsGroup */
|
/** @var SubdefGroup $subdefsGroup */
|
||||||
foreach ($subdefs as $groupName => $subdefsGroup) {
|
foreach ($subdefs as $groupName => $subdefsGroup) {
|
||||||
$documentOrderable = isset($subdefsGroups[$groupName]['document_orderable'])
|
$documentOrderable = isset($subdefsGroups[$groupName]['document_orderable'])
|
||||||
? \p4field::isyes($subdefsGroups[$groupName]['document_orderable'])
|
? \p4field::isyes($subdefsGroups[$groupName]['document_orderable'])
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
if ($subdefsGroup->isDocumentOrderable() !== $documentOrderable) {
|
if ($subdefsGroup->isDocumentOrderable() !== $documentOrderable) {
|
||||||
if ($documentOrderable) {
|
if ($documentOrderable) {
|
||||||
$subdefsGroup->allowDocumentOrdering();
|
$subdefsGroup->allowDocumentOrdering();
|
||||||
} else {
|
} else {
|
||||||
$subdefsGroup->disallowDocumentOrdering();
|
$subdefsGroup->disallowDocumentOrdering();
|
||||||
}
|
}
|
||||||
|
|
||||||
$changedGroups[] = $subdefsGroup;
|
$changedGroups[] = $subdefsGroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($changedGroups) {
|
if ($changedGroups) {
|
||||||
$subdefs->updateSubdefGroups($changedGroups);
|
$subdefs->updateSubdefGroups($changedGroups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getConfiguration()
|
||||||
|
{
|
||||||
|
$config = array(
|
||||||
|
Subdef::TYPE_IMAGE => array(
|
||||||
|
"definitions" => array(
|
||||||
|
"JPG" => null,
|
||||||
|
"160px JPG" => array(
|
||||||
|
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)" => array(
|
||||||
|
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" => array(
|
||||||
|
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)" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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 => array(
|
||||||
|
"definitions" => array(
|
||||||
|
"video codec H264" => null,
|
||||||
|
"144P H264 128 kbps ACC 128kbps" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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" => array(
|
||||||
|
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 => array(
|
||||||
|
"definitions" => array(
|
||||||
|
"256 px fast 200 ms" => array(
|
||||||
|
Gif::OPTION_SIZE => "256",
|
||||||
|
Gif::OPTION_DELAY => "200",
|
||||||
|
Subdef::OPTION_DEVICE => ["all"]
|
||||||
|
),
|
||||||
|
"256 px very fast 120 ms" => array(
|
||||||
|
Gif::OPTION_SIZE => "256",
|
||||||
|
Gif::OPTION_DELAY => "120",
|
||||||
|
Subdef::OPTION_DEVICE => ["all"]
|
||||||
|
),
|
||||||
|
"320 px fast 200 ms" => array(
|
||||||
|
Gif::OPTION_SIZE => "320",
|
||||||
|
Gif::OPTION_DELAY => "200",
|
||||||
|
Subdef::OPTION_DEVICE => ["all"]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"form" => array(
|
||||||
|
Gif::OPTION_SIZE => "slide",
|
||||||
|
Gif::OPTION_DELAY => "slide",
|
||||||
|
Subdef::OPTION_DEVICE => "checkbox",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Subdef::TYPE_AUDIO => array(
|
||||||
|
"definitions" => array(
|
||||||
|
"Low AAC 96 kbit/s" => array(
|
||||||
|
Audio::OPTION_AUDIOBITRATE => "100",
|
||||||
|
Audio::OPTION_AUDIOSAMPLERATE => "8000",
|
||||||
|
Audio::OPTION_ACODEC => "libmp3lame",
|
||||||
|
Subdef::OPTION_DEVICE => ["all"]
|
||||||
|
),
|
||||||
|
"Normal AAC 128 kbit/s" => array(
|
||||||
|
Audio::OPTION_AUDIOBITRATE => "180",
|
||||||
|
Audio::OPTION_AUDIOSAMPLERATE => "44100",
|
||||||
|
Audio::OPTION_ACODEC => "libmp3lame",
|
||||||
|
Subdef::OPTION_DEVICE => ["all"]
|
||||||
|
),
|
||||||
|
"High AAC 320 kbit/s" => array(
|
||||||
|
Audio::OPTION_AUDIOBITRATE => "230",
|
||||||
|
Audio::OPTION_AUDIOSAMPLERATE => "50000",
|
||||||
|
Audio::OPTION_ACODEC => "libmp3lame",
|
||||||
|
Subdef::OPTION_DEVICE => ["all"]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"form" => array(
|
||||||
|
Audio::OPTION_AUDIOBITRATE => "slide",
|
||||||
|
Audio::OPTION_AUDIOSAMPLERATE => "select",
|
||||||
|
Audio::OPTION_ACODEC => "select",
|
||||||
|
Subdef::OPTION_DEVICE => "checkbox",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Subdef::TYPE_FLEXPAPER => array(
|
||||||
|
"definitions" => array(
|
||||||
|
),
|
||||||
|
"form" => array(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
46
lib/Alchemy/Phrasea/Databox/Subdef/SubdefPreset.php
Normal file
46
lib/Alchemy/Phrasea/Databox/Subdef/SubdefPreset.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
19
lib/Alchemy/Phrasea/Databox/Subdef/SubdefPresetProvider.php
Normal file
19
lib/Alchemy/Phrasea/Databox/Subdef/SubdefPresetProvider.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?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];
|
||||||
|
}
|
||||||
|
}
|
@@ -15,6 +15,8 @@ use MediaAlchemyst\Specification\SpecificationInterface;
|
|||||||
|
|
||||||
interface Subdef
|
interface Subdef
|
||||||
{
|
{
|
||||||
|
const OPTION_DEVICE = 'devices';
|
||||||
|
|
||||||
const TYPE_IMAGE = 'image';
|
const TYPE_IMAGE = 'image';
|
||||||
const TYPE_ANIMATION = 'gif';
|
const TYPE_ANIMATION = 'gif';
|
||||||
const TYPE_VIDEO = 'video';
|
const TYPE_VIDEO = 'video';
|
||||||
|
@@ -7,40 +7,18 @@
|
|||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* 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\Audio;
|
||||||
|
use Alchemy\Phrasea\Media\Subdef\Video;
|
||||||
use Alchemy\Phrasea\Media\Subdef\FlexPaper;
|
use Alchemy\Phrasea\Media\Subdef\FlexPaper;
|
||||||
use Alchemy\Phrasea\Media\Subdef\Gif;
|
use Alchemy\Phrasea\Media\Subdef\Gif;
|
||||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
|
||||||
use Alchemy\Phrasea\Media\Subdef\Unknown;
|
use Alchemy\Phrasea\Media\Subdef\Unknown;
|
||||||
use Alchemy\Phrasea\Media\Subdef\Subdef as SubdefSpecs;
|
use Alchemy\Phrasea\Media\Subdef\Subdef as SubdefSpecs;
|
||||||
use Alchemy\Phrasea\Media\Subdef\Video;
|
|
||||||
use Alchemy\Phrasea\Media\Type\Type as SubdefType;
|
use Alchemy\Phrasea\Media\Type\Type as SubdefType;
|
||||||
use MediaAlchemyst\Specification\SpecificationInterface;
|
use MediaAlchemyst\Specification\SpecificationInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class databox_subdef
|
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
|
* The class type of the subdef
|
||||||
* Is null or one of the CLASS_* constants
|
* Is null or one of the CLASS_* constants
|
||||||
@@ -51,52 +29,61 @@ class databox_subdef
|
|||||||
protected $devices = [];
|
protected $devices = [];
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $path;
|
protected $path;
|
||||||
|
protected $preset;
|
||||||
protected $subdef_group;
|
protected $subdef_group;
|
||||||
protected $labels = [];
|
protected $labels = [];
|
||||||
protected $downloadable;
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $requiresMetadataUpdate;
|
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 SubdefType $type
|
||||||
* @param SimpleXMLElement $sd
|
* @param SimpleXMLElement $sd
|
||||||
* @param TranslatorInterface $translator
|
*
|
||||||
|
* @return databox_subdef
|
||||||
*/
|
*/
|
||||||
public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator)
|
public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$this->subdef_group = $type;
|
$this->subdef_group = $type;
|
||||||
$this->class = (string) $sd->attributes()->class;
|
$this->class = (string)$sd->attributes()->class;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
|
||||||
foreach ($sd->devices as $device) {
|
foreach ($sd->devices as $device) {
|
||||||
$this->devices[] = (string) $device;
|
$this->devices[] = (string)$device;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->name = strtolower($sd->attributes()->name);
|
$this->name = strtolower($sd->attributes()->name);
|
||||||
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
|
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
|
||||||
$this->orderable = isset($sd->attributes()->orderable) ? p4field::isyes($sd->attributes()->orderable) : true;
|
$this->orderable = isset($sd->attributes()->orderable) ? p4field::isyes($sd->attributes()->orderable) : true;
|
||||||
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
|
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
|
||||||
|
$this->preset = $sd->attributes()->presets;
|
||||||
$this->requiresMetadataUpdate = p4field::isyes((string) $sd->meta);
|
$this->requiresMetadataUpdate = p4field::isyes((string)$sd->meta);
|
||||||
|
|
||||||
foreach ($sd->label as $label) {
|
foreach ($sd->label as $label) {
|
||||||
$lang = trim((string) $label->attributes()->lang);
|
$lang = trim((string)$label->attributes()->lang);
|
||||||
|
|
||||||
if ($lang) {
|
if ($lang) {
|
||||||
$this->labels[$lang] = (string) $label;
|
$this->labels[$lang] = (string)$label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switch ((string)$sd->mediatype) {
|
||||||
switch ((string) $sd->mediatype) {
|
|
||||||
default:
|
default:
|
||||||
case SubdefSpecs::TYPE_IMAGE:
|
case SubdefSpecs::TYPE_IMAGE:
|
||||||
$this->subdef_type = $this->buildImageSubdef($sd);
|
$this->subdef_type = $this->buildImageSubdef($sd);
|
||||||
@@ -118,7 +105,6 @@ class databox_subdef
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Image Subdef object depending the SimpleXMLElement
|
* Build Image Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
@@ -128,7 +114,6 @@ class databox_subdef
|
|||||||
protected function buildImageSubdef(SimpleXMLElement $sd)
|
protected function buildImageSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
$image = new Image($this->translator);
|
$image = new Image($this->translator);
|
||||||
|
|
||||||
if ($sd->icodec) {
|
if ($sd->icodec) {
|
||||||
$image->setOptionValue(Image::OPTION_ICODEC, (string) $sd->icodec);
|
$image->setOptionValue(Image::OPTION_ICODEC, (string) $sd->icodec);
|
||||||
}
|
}
|
||||||
@@ -147,10 +132,8 @@ class databox_subdef
|
|||||||
if ($sd->flatten) {
|
if ($sd->flatten) {
|
||||||
$image->setOptionValue(Image::OPTION_FLATTEN, p4field::isyes($sd->flatten));
|
$image->setOptionValue(Image::OPTION_FLATTEN, p4field::isyes($sd->flatten));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Audio Subdef object depending the SimpleXMLElement
|
* Build Audio Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
@@ -160,7 +143,6 @@ class databox_subdef
|
|||||||
protected function buildAudioSubdef(SimpleXMLElement $sd)
|
protected function buildAudioSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
$audio = new Audio($this->translator);
|
$audio = new Audio($this->translator);
|
||||||
|
|
||||||
if ($sd->acodec) {
|
if ($sd->acodec) {
|
||||||
$audio->setOptionValue(Audio::OPTION_ACODEC, (string) $sd->acodec);
|
$audio->setOptionValue(Audio::OPTION_ACODEC, (string) $sd->acodec);
|
||||||
}
|
}
|
||||||
@@ -170,10 +152,8 @@ class databox_subdef
|
|||||||
if ($sd->audiosamplerate) {
|
if ($sd->audiosamplerate) {
|
||||||
$audio->setOptionValue(Audio::OPTION_AUDIOSAMPLERATE, (int) $sd->audiosamplerate);
|
$audio->setOptionValue(Audio::OPTION_AUDIOSAMPLERATE, (int) $sd->audiosamplerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $audio;
|
return $audio;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Video Subdef object depending the SimpleXMLElement
|
* Build Video Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
@@ -183,7 +163,6 @@ class databox_subdef
|
|||||||
protected function buildVideoSubdef(SimpleXMLElement $sd)
|
protected function buildVideoSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
$video = new Video($this->translator);
|
$video = new Video($this->translator);
|
||||||
|
|
||||||
if ($sd->size) {
|
if ($sd->size) {
|
||||||
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
|
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
|
||||||
}
|
}
|
||||||
@@ -208,10 +187,8 @@ class databox_subdef
|
|||||||
if ($sd->GOPsize) {
|
if ($sd->GOPsize) {
|
||||||
$video->setOptionValue(Video::OPTION_GOPSIZE, (int) $sd->GOPsize);
|
$video->setOptionValue(Video::OPTION_GOPSIZE, (int) $sd->GOPsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $video;
|
return $video;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build GIF Subdef object depending the SimpleXMLElement
|
* Build GIF Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
@@ -221,17 +198,14 @@ class databox_subdef
|
|||||||
protected function buildGifSubdef(SimpleXMLElement $sd)
|
protected function buildGifSubdef(SimpleXMLElement $sd)
|
||||||
{
|
{
|
||||||
$gif = new Gif($this->translator);
|
$gif = new Gif($this->translator);
|
||||||
|
|
||||||
if ($sd->size) {
|
if ($sd->size) {
|
||||||
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
|
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
|
||||||
}
|
}
|
||||||
if ($sd->delay) {
|
if ($sd->delay) {
|
||||||
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
|
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $gif;
|
return $gif;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Flexpaper Subdef object depending the SimpleXMLElement
|
* Build Flexpaper Subdef object depending the SimpleXMLElement
|
||||||
*
|
*
|
||||||
@@ -242,8 +216,8 @@ class databox_subdef
|
|||||||
{
|
{
|
||||||
return new FlexPaper($this->translator);
|
return new FlexPaper($this->translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_class()
|
public function get_class()
|
||||||
@@ -252,6 +226,16 @@ class databox_subdef
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_preset()
|
||||||
|
{
|
||||||
|
return $this->preset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_path()
|
public function get_path()
|
||||||
@@ -262,7 +246,7 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* The devices matching this subdefinition
|
* The devices matching this subdefinition
|
||||||
*
|
*
|
||||||
* @return array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
public function getDevices()
|
public function getDevices()
|
||||||
{
|
{
|
||||||
@@ -272,7 +256,7 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* The current SubdefType the subdef converts documents
|
* The current SubdefType the subdef converts documents
|
||||||
*
|
*
|
||||||
* @return \Alchemy\Phrasea\Media\Subdef\Subdef
|
* @return Alchemy\Phrasea\Media\Subdef\Subdef
|
||||||
*/
|
*/
|
||||||
public function getSubdefType()
|
public function getSubdefType()
|
||||||
{
|
{
|
||||||
@@ -292,7 +276,7 @@ class databox_subdef
|
|||||||
/**
|
/**
|
||||||
* An associative label ; keys are i18n languages
|
* An associative label ; keys are i18n languages
|
||||||
*
|
*
|
||||||
* @return array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
public function get_labels()
|
public function get_labels()
|
||||||
{
|
{
|
||||||
@@ -306,36 +290,19 @@ class databox_subdef
|
|||||||
} elseif (isset($this->labels[$code])) {
|
} elseif (isset($this->labels[$code])) {
|
||||||
return $this->labels[$code];
|
return $this->labels[$code];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the subdef
|
* boolean
|
||||||
*
|
*
|
||||||
* @return string
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_name()
|
public function is_downloadable()
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isDownloadable()
|
|
||||||
{
|
{
|
||||||
return $this->downloadable;
|
return $this->downloadable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isOrderable()
|
|
||||||
{
|
|
||||||
return $this->orderable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of Alchemy\Phrasea\Media\Subdef\Subdef available for the current Media Type
|
* Get an array of Alchemy\Phrasea\Media\Subdef\Subdef available for the current Media Type
|
||||||
*
|
*
|
||||||
@@ -344,7 +311,6 @@ class databox_subdef
|
|||||||
public function getAvailableSubdefTypes()
|
public function getAvailableSubdefTypes()
|
||||||
{
|
{
|
||||||
$subdefTypes = [];
|
$subdefTypes = [];
|
||||||
|
|
||||||
$availableDevices = [
|
$availableDevices = [
|
||||||
self::DEVICE_ALL,
|
self::DEVICE_ALL,
|
||||||
self::DEVICE_HANDHELD,
|
self::DEVICE_HANDHELD,
|
||||||
@@ -353,11 +319,8 @@ class databox_subdef
|
|||||||
self::DEVICE_SCREEN,
|
self::DEVICE_SCREEN,
|
||||||
self::DEVICE_TV,
|
self::DEVICE_TV,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
|
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
|
||||||
|
|
||||||
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
|
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
|
||||||
|
|
||||||
if ($subdefType == $this->subdef_type->getType()) {
|
if ($subdefType == $this->subdef_type->getType()) {
|
||||||
$mediatype_obj = $this->subdef_type;
|
$mediatype_obj = $this->subdef_type;
|
||||||
} else {
|
} else {
|
||||||
@@ -385,13 +348,11 @@ class databox_subdef
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi($this->translator->trans('Target Device'),
|
||||||
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi($this->translator->trans('Target Device'), 'devices', $availableDevices, $this->devices));
|
'devices', $availableDevices, $this->devices));
|
||||||
|
|
||||||
$subdefTypes[] = $mediatype_obj;
|
$subdefTypes[] = $mediatype_obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $subdefTypes;
|
return $subdefTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,6 +366,16 @@ class databox_subdef
|
|||||||
return $this->requiresMetadataUpdate;
|
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
|
* Get the MediaAlchemyst specs for the current subdef
|
||||||
*
|
*
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Alchemy\Phrasea\Databox\SubdefGroup;
|
use Alchemy\Phrasea\Databox\SubdefGroup;
|
||||||
use Alchemy\Phrasea\Media\MediaTypeFactory;
|
|
||||||
use Assert\Assertion;
|
use Assert\Assertion;
|
||||||
|
use Alchemy\Phrasea\Media\MediaTypeFactory;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class databox_subdefsStructure implements IteratorAggregate, Countable
|
class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||||
@@ -185,15 +185,19 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
* @param string $groupname
|
* @param string $groupname
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $class
|
* @param string $class
|
||||||
|
* @param string $mediatype
|
||||||
|
* @param string $preset
|
||||||
* @return databox_subdefsStructure
|
* @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();
|
$dom_struct = $this->databox->get_dom_structure();
|
||||||
|
|
||||||
$subdef = $dom_struct->createElement('subdef');
|
$subdef = $dom_struct->createElement('subdef');
|
||||||
$subdef->setAttribute('class', $class);
|
$subdef->setAttribute('class', $class);
|
||||||
$subdef->setAttribute('name', mb_strtolower($name));
|
$subdef->setAttribute('name', mb_strtolower($name));
|
||||||
|
$subdef->setAttribute('presets', $preset);
|
||||||
|
$subdef->setAttribute('mediaType', $mediatype);
|
||||||
|
|
||||||
$dom_xp = $this->databox->get_xpath_structure();
|
$dom_xp = $this->databox->get_xpath_structure();
|
||||||
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
|
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
|
||||||
@@ -234,19 +238,18 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $group
|
* @param string $group
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $class
|
* @param string $class
|
||||||
|
* @param string $preset
|
||||||
* @param boolean $downloadable
|
* @param boolean $downloadable
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @param array $labels
|
* @param array $labels
|
||||||
* @param bool $orderable
|
|
||||||
* @return databox_subdefsStructure
|
* @return databox_subdefsStructure
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true)
|
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset = "Custom")
|
||||||
{
|
{
|
||||||
$dom_struct = $this->databox->get_dom_structure();
|
$dom_struct = $this->databox->get_dom_structure();
|
||||||
|
|
||||||
@@ -254,7 +257,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
$subdef->setAttribute('class', $class);
|
$subdef->setAttribute('class', $class);
|
||||||
$subdef->setAttribute('name', mb_strtolower($name));
|
$subdef->setAttribute('name', mb_strtolower($name));
|
||||||
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
||||||
$subdef->setAttribute('orderable', ($orderable ? 'true' : 'false'));
|
$subdef->setAttribute('presets', $preset);
|
||||||
|
|
||||||
foreach ($labels as $code => $label) {
|
foreach ($labels as $code => $label) {
|
||||||
$child = $dom_struct->createElement('label');
|
$child = $dom_struct->createElement('label');
|
||||||
|
@@ -336,6 +336,99 @@ div.switch_right.unchecked {
|
|||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alert .close {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subdefs [id^="box"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subdefs .subviews-submit {
|
||||||
|
position: fixed;
|
||||||
|
top: 75px;
|
||||||
|
right: 40px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
h2.subdefName {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reload, .loader, .status {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.langTab {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.langTab h3{
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 13px;
|
||||||
|
margin: 4px 0;
|
||||||
|
line-height: 11px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle{
|
||||||
|
display: block;
|
||||||
|
margin: 15px 0;
|
||||||
|
color: #08c;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.subdefTab input, .langTab input{
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
label[for="elasticsearch_settings_highlight"] {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
input[id="elasticsearch_settings_highlight"] {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#downbutton {
|
||||||
|
margin: 1rem 0;
|
||||||
|
}
|
||||||
|
#upbutton {
|
||||||
|
width: 100%;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#upbutton i {
|
||||||
|
position: relative;
|
||||||
|
left: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#downbutton i {
|
||||||
|
position: relative;
|
||||||
|
left: -5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-horizontal .controls + div {
|
||||||
|
margin-left: 180px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ui-dialog .ui-dialog-content {
|
||||||
|
position: relative;
|
||||||
|
border: 0;
|
||||||
|
padding: .5em 1em;
|
||||||
|
background: none;
|
||||||
|
margin-bottom: 7rem;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 1150px) {
|
||||||
|
.langTab{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@import './databases';
|
@import './databases';
|
||||||
@import './fields';
|
@import './fields';
|
||||||
@import './tables';
|
@import './tables';
|
@@ -15,372 +15,564 @@
|
|||||||
{#<script type="text/javascript" src="/assets/vendors/jquery/jquery{% if not app.debug %}.min{% endif %}.js"></script>
|
{#<script type="text/javascript" src="/assets/vendors/jquery/jquery{% if not app.debug %}.min{% endif %}.js"></script>
|
||||||
<script type="text/javascript" src="/assets/vendors/jquery-ui/jquery-ui{% if not app.debug %}.min{% endif %}.js"></script>
|
<script type="text/javascript" src="/assets/vendors/jquery-ui/jquery-ui{% if not app.debug %}.min{% endif %}.js"></script>
|
||||||
<script type="text/javascript" src="/assets/vendors/jquery-test-paths/jquery.test-paths{% if not app.debug %}.min{% endif %}.js"></script>#}
|
<script type="text/javascript" src="/assets/vendors/jquery-test-paths/jquery.test-paths{% if not app.debug %}.min{% endif %}.js"></script>#}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.path_testable').path_file_test();
|
$('.path_testable').path_file_test();
|
||||||
$('.url_testable').url_test();
|
$('.url_testable').url_test();
|
||||||
$('.tabs').tabs({
|
$('.tabs').tabs({
|
||||||
beforeActivate:function(event, ui){
|
beforeActivate:function(event, ui){
|
||||||
$('.path_testable:visible, .url_testable:visible').trigger('keyup');
|
$('.path_testable:visible, .url_testable:visible').trigger('keyup');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
function select_mediatype(name, selector)
|
$(".toggle").on("click", function() {
|
||||||
{
|
var box = $(this).data("toggle");
|
||||||
$('.'+name).hide();
|
$(box).toggle("500");
|
||||||
$('#box'+name+$(selector).val()).show();
|
});
|
||||||
}
|
|
||||||
$(function() {
|
|
||||||
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
|
|
||||||
$( "#dialog:ui-dialog" ).dialog( "destroy" );
|
|
||||||
|
|
||||||
var name = $( "#name" ), accessclass = $( "#accessclass" ),
|
$("input, select").one("change", activeSubmit);
|
||||||
allFields = $( [] ).add( name ).add(accessclass),
|
|
||||||
tips = $( ".validateTips" );
|
|
||||||
|
|
||||||
function updateTips( t ) {
|
|
||||||
tips
|
|
||||||
.text( t )
|
|
||||||
.addClass( "ui-state-highlight" );
|
|
||||||
setTimeout(function() {
|
|
||||||
tips.removeClass( "ui-state-highlight", 1500 );
|
|
||||||
}, 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkLength( o, n, min, max ) {
|
|
||||||
if ( o.val().length > max || o.val().length < min ) {
|
|
||||||
o.addClass( "ui-state-error" );
|
|
||||||
updateTips( "Length of " + n + " must be between " +
|
|
||||||
min + " and " + max + "." );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_current_group()
|
|
||||||
{
|
|
||||||
return $('.ui-tabs-nav .ui-state-active a').html();
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkPresence( o ) {
|
|
||||||
|
|
||||||
var el = $('input[name="subdefs[]"][value="'+get_current_group()+'_'+o.val()+'"]');
|
|
||||||
if ( el.length !== 0 ) {
|
|
||||||
o.addClass( "ui-state-error" );
|
|
||||||
updateTips( "SubdefName should be unique per group" );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkSpecialChar( o )
|
|
||||||
{
|
|
||||||
var ok = true;
|
|
||||||
var reg = new RegExp("[A-Za-z0-9-]+","g");
|
|
||||||
|
|
||||||
if(o.val().match(reg)[0].length !== o.val().length)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
o.addClass( "ui-state-error" );
|
|
||||||
updateTips( "Special characters (except minus) or espaces are not authorized" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$( "#dialog-form" ).dialog({
|
|
||||||
autoOpen: false,
|
|
||||||
height: 250,
|
|
||||||
width: 350,
|
|
||||||
modal: true,
|
|
||||||
buttons: {
|
|
||||||
"Create a Subdef": function() {
|
|
||||||
var bValid = true;
|
|
||||||
|
|
||||||
allFields.removeClass( "ui-state-error" );
|
|
||||||
|
|
||||||
bValid = bValid && checkLength( name, "subdef name", 3, 16 );
|
|
||||||
bValid = bValid && checkSpecialChar( name );
|
|
||||||
bValid = bValid && checkPresence( name );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( bValid ) {
|
|
||||||
$('input[name="add_subdef[group]"]').val(get_current_group());
|
|
||||||
$('input[name="add_subdef[name]"]').val(name.val());
|
|
||||||
$('input[name="add_subdef[class]"]').val(accessclass.val());
|
|
||||||
$( this ).dialog( "close" );
|
|
||||||
$('form.subdefs').submit();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Cancel: function() {
|
|
||||||
$( this ).dialog( "close" );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
close: function() {
|
|
||||||
allFields.val( "" ).removeClass( "ui-state-error" );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$( "#create-subdef" )
|
|
||||||
// .button()
|
|
||||||
.click(function() {
|
|
||||||
$( "#dialog-form" ).dialog( "open" );
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.subdef_deleter')
|
|
||||||
// .button()
|
|
||||||
.click(function(){
|
|
||||||
delete_subdef($(this).next('input[name="subdef"]').val());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
function delete_subdef(name)
|
|
||||||
{
|
|
||||||
$( "#dialog-delete-subdef" ).dialog({
|
|
||||||
resizable: false,
|
|
||||||
height:140,
|
|
||||||
modal: true,
|
|
||||||
buttons: {
|
|
||||||
"Delete subdef": function() {
|
|
||||||
$('#delete_subdef').val(name);
|
|
||||||
$( this ).dialog( "destroy" );
|
|
||||||
$('form.subdefs').submit();
|
|
||||||
},
|
|
||||||
Cancel: function() {
|
|
||||||
$( this ).dialog( "destroy" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
});
|
function activeSubmit() {
|
||||||
|
$(".subviews-submit").removeAttr("disabled");
|
||||||
|
$("input, select").off("change", activeSubmit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillCheckbox(section, name, defType, fieldname, values) {
|
||||||
|
|
||||||
|
$("[name='"+section+"_"+name+"_"+defType+"["+fieldname+"][]']").each(function(){
|
||||||
|
$(this).removeAttr("checked");
|
||||||
|
|
||||||
|
for(var key in values){
|
||||||
|
if($(this).val() == values[key])
|
||||||
|
$(this).prop("checked", "true");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function fillRadio(section, name, defType, fieldname, value) {
|
||||||
|
$("[name='"+section+"_"+name+"_"+defType+"["+fieldname+"]'][value='"+value+"']").prop( "checked", true );
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillSelect(section, name, defType, fieldname, value) {
|
||||||
|
$("[name='"+section+"_"+name+"_"+defType+"["+fieldname+"]']").val(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillSlide(section, name, defType, fieldname, value) {
|
||||||
|
$("#slider"+section+name+defType+fieldname).slider({value:value});
|
||||||
|
$("#slidervalue"+section+name+defType+fieldname).val(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function populate_values(section, name) {
|
||||||
|
|
||||||
|
var config = JSON.parse('{{ config |json_encode|raw }}'),
|
||||||
|
i = 0,
|
||||||
|
defType = $('[name="'+section+'_'+name+'_mediatype"]').val(),
|
||||||
|
preset = $('[name="'+section+'_'+name+'_presets"]').val(),
|
||||||
|
optionValue = $('[name="'+section+'_'+name+'_presets"] option:selected').attr("value");
|
||||||
|
|
||||||
|
if(typeof optionValue === 'undefined'){
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var input in config[defType].form) {
|
||||||
|
if(config[defType].form[input] == "slide"){
|
||||||
|
fillSlide(section, name, defType, input, config[defType].definitions[preset][input]);
|
||||||
|
}
|
||||||
|
if(config[defType].form[input] == "radio"){
|
||||||
|
fillRadio(section, name, defType, input, config[defType].definitions[preset][input]);
|
||||||
|
}
|
||||||
|
if(config[defType].form[input] == "select"){
|
||||||
|
fillSelect(section, name, defType, input, config[defType].definitions[preset][input]);
|
||||||
|
}
|
||||||
|
if(config[defType].form[input] == "checkbox"){
|
||||||
|
fillCheckbox(section, name, defType, input, config[defType].definitions[preset][input]);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function select_mediatype(type, name, selector)
|
||||||
|
{
|
||||||
|
var config = JSON.parse('{{ config |json_encode|raw }}'),
|
||||||
|
inputPresets = '[name="'+type+'_'+name+'_presets"]',
|
||||||
|
defType = $(selector).val();
|
||||||
|
|
||||||
|
|
||||||
|
$('.'+type+name).hide();
|
||||||
|
|
||||||
|
$('[data-toggle^="#box'+type+name+'"]').hide();
|
||||||
|
$('[data-toggle="#box'+type+name+defType+'"]').show();
|
||||||
|
|
||||||
|
$('#box'+type+name+$(selector).val()).show();
|
||||||
|
|
||||||
|
if(defType == 'flexpaper'){
|
||||||
|
$(inputPresets).closest("tr").hide();
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
$(inputPresets).closest("tr").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$(inputPresets)
|
||||||
|
.find('option')
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.append($("<option value='custom'></option>").text('{{ 'Custom' | trans }}'));
|
||||||
|
|
||||||
|
if(typeof config[defType] === 'undefined'){
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var key in config[defType].definitions) {
|
||||||
|
if (config[defType].definitions[key] == null){
|
||||||
|
$(inputPresets).append($("<option></option>")
|
||||||
|
.attr("disabled", "disabled")
|
||||||
|
.text(key)
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$(inputPresets).append($("<option></option>")
|
||||||
|
.attr("value", key)
|
||||||
|
.text(key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function subview_type(selector) {
|
||||||
|
var mapping = JSON.parse('{{ subviews_mapping |json_encode|raw }}'),
|
||||||
|
subviewType = $(selector).val();
|
||||||
|
|
||||||
|
$("#mediaType")
|
||||||
|
.find('option')
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.append($("<option></option>").text('{{ 'Choisir' | trans }}'));
|
||||||
|
|
||||||
|
for (var key in mapping[subviewType]) {
|
||||||
|
$("#mediaType").append($('<option></option>')
|
||||||
|
.attr("value", mapping[subviewType][key])
|
||||||
|
.text(mapping[subviewType][key])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function media_type(selector){
|
||||||
|
var config = JSON.parse('{{ config |json_encode|raw }}'),
|
||||||
|
defType = $(selector).val();
|
||||||
|
|
||||||
|
$("#presets")
|
||||||
|
.find('option')
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.append($("<option></option>").text('{{ 'Choisir' | trans }}'));
|
||||||
|
|
||||||
|
if(typeof config[defType] === 'undefined'){
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var key in config[defType].definitions) {
|
||||||
|
if (config[defType].definitions[key] == null){
|
||||||
|
$("#presets").append($("<option></option>")
|
||||||
|
.attr("disabled", "disabled")
|
||||||
|
.text(key)
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$("#presets").append($('<option></option>')
|
||||||
|
.attr("value", key)
|
||||||
|
.text(key)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
|
||||||
|
$( "#dialog:ui-dialog" ).dialog( "destroy" );
|
||||||
|
|
||||||
|
var name = $( "#name" ), accessclass = $( "#accessclass" ), subviewType =$( "#subviewType" ) , mediaType = $( "#mediaType" ), presets = $( "#presets" ),
|
||||||
|
allFields = $( [] ).add( name ).add(accessclass).add(subviewType).add(mediaType).add(presets),
|
||||||
|
tips = $( ".validateTips" );
|
||||||
|
|
||||||
|
function updateTips( t ) {
|
||||||
|
tips
|
||||||
|
.text( t )
|
||||||
|
.addClass( "ui-state-highlight" );
|
||||||
|
setTimeout(function() {
|
||||||
|
tips.removeClass( "ui-state-highlight", 1500 );
|
||||||
|
}, 500 );
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkLength( o, n, min, max ) {
|
||||||
|
if ( o.val().length > max || o.val().length < min ) {
|
||||||
|
o.addClass( "ui-state-error" );
|
||||||
|
updateTips( "Length of " + n + " must be between " +
|
||||||
|
min + " and " + max + "." );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPresence( mediaType, o ) {
|
||||||
|
|
||||||
|
var el = $('input[name="subdefs[]"][value="'+mediaType+'_'+o.val()+'"]');
|
||||||
|
if ( el.length !== 0 ) {
|
||||||
|
o.addClass( "ui-state-error" );
|
||||||
|
updateTips( "SubdefName should be unique per group" );
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSpecialChar( o )
|
||||||
|
{
|
||||||
|
var ok = true;
|
||||||
|
var reg = new RegExp("[A-Za-z0-9-]+","g");
|
||||||
|
|
||||||
|
if(o.val().match(reg)[0].length !== o.val().length)
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
o.addClass( "ui-state-error" );
|
||||||
|
updateTips( "Special characters (except minus) or espaces are not authorized" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$( "#dialog-form" ).dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
height: 420,
|
||||||
|
width: 300,
|
||||||
|
modal: true,
|
||||||
|
buttons: {
|
||||||
|
"Create a Subdef": function() {
|
||||||
|
var bValid = true;
|
||||||
|
|
||||||
|
allFields.removeClass( "ui-state-error" );
|
||||||
|
|
||||||
|
bValid = bValid && checkLength( name, "subdef name", 3, 16 );
|
||||||
|
bValid = bValid && checkSpecialChar( name );
|
||||||
|
bValid = bValid && checkPresence( subviewType.val(), name );
|
||||||
|
|
||||||
|
if ( bValid ) {
|
||||||
|
$('input[name="add_subdef[group]"]').val(subviewType.val());
|
||||||
|
$('input[name="add_subdef[name]"]').val(name.val());
|
||||||
|
$('input[name="add_subdef[mediaType]"]').val(mediaType.val());
|
||||||
|
$('input[name="add_subdef[class]"]').val(accessclass.val());
|
||||||
|
$('input[name="add_subdef[presets]"]').val(presets.val());
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
$('form.subdefs').submit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close: function() {
|
||||||
|
allFields.val( "" ).removeClass( "ui-state-error" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$( "#create-subdef" )
|
||||||
|
// .button()
|
||||||
|
.click(function() {
|
||||||
|
$( "#dialog-form" ).dialog( "open" );
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.subdef_deleter')
|
||||||
|
// .button()
|
||||||
|
.click(function(){
|
||||||
|
delete_subdef($(this).next('input[name="subdef"]').val());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
function delete_subdef(name)
|
||||||
|
{
|
||||||
|
$( "#dialog-delete-subdef" ).dialog({
|
||||||
|
resizable: false,
|
||||||
|
height:140,
|
||||||
|
modal: true,
|
||||||
|
buttons: {
|
||||||
|
"Delete subdef": function() {
|
||||||
|
$('#delete_subdef').val(name);
|
||||||
|
$( this ).dialog( "destroy" );
|
||||||
|
$('form.subdefs').submit();
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "destroy" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p>
|
|
||||||
<button id="create-subdef" class="btn btn-success">{{ 'Create new subdef' | trans }}</button>
|
|
||||||
</p>
|
|
||||||
<div id="dialog-delete-subdef" title="{{ 'Delete the subdef ?' | trans }}" style="display:none;">
|
|
||||||
<p>
|
<p>
|
||||||
<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
|
<button id="create-subdef" class="btn btn-success">{{ 'Create new subdef' | trans }}</button>
|
||||||
{{ 'These subdef will be permanently deleted and cannot be recovered. Are you sure?' | trans }}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<div id="dialog-delete-subdef" title="{{ 'Delete the subdef ?' | trans }}" style="display:none;">
|
||||||
|
<p>
|
||||||
|
<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
|
||||||
|
{{ 'These subdef will be permanently deleted and cannot be recovered. Are you sure?' | trans }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="dialog-form" title="Create new subdef">
|
<div id="dialog-form" title="Create new subdef">
|
||||||
<p class="validateTips"></p>
|
<p class="validateTips"></p>
|
||||||
<form>
|
<form>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="name">{{ 'Subdef name' | trans }}</label>
|
<label for="name">{{ 'Subdef name' | trans }}</label>
|
||||||
<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" value=""/><br/>
|
<input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" value=""/><br/>
|
||||||
<label for="accessclass">{{ 'classe d\'acces' | trans }}</label>
|
<label for="accessclass">{{ 'classe d\'acces' | trans }}</label>
|
||||||
<select name="accessclass" id="accessclass">
|
<select name="accessclass" id="accessclass">
|
||||||
<option value="document">{{ 'document' | trans }}</option>
|
<option value="document">{{ 'document' | trans }}</option>
|
||||||
<option value="preview" selected="selected">{{ 'preview' | trans }}</option>
|
<option value="preview" selected="selected">{{ 'preview' | trans }}</option>
|
||||||
<option value="thumbnail">{{ 'tout le monde' | trans }}</option>
|
<option value="thumbnail">{{ 'tout le monde' | trans }}</option>
|
||||||
</select>
|
</select>
|
||||||
</fieldset>
|
<label for="subviewType">{{ 'subviewType' | trans }}</label>
|
||||||
</form>
|
<select name="subviewType" id="subviewType" onchange="subview_type(this)">
|
||||||
</div>
|
<option>{{ 'Choisir' | trans }}</option>
|
||||||
|
<option value="image">{{ 'image' | trans }}</option>
|
||||||
|
<option value="video">{{ 'video' | trans }}</option>
|
||||||
|
<option value="audio">{{ 'audio' | trans }}</option>
|
||||||
|
<option value="document">{{ 'document' | trans }}</option>
|
||||||
|
<option value="flash">{{ 'flash' | trans }}</option>
|
||||||
|
</select>
|
||||||
|
<label for="mediaType">{{ 'mediatype' | trans }}</label>
|
||||||
|
<select name="mediaType" id="mediaType" onchange="media_type(this)">
|
||||||
|
<option>{{ 'Choisir' | trans }}</option>
|
||||||
|
</select>
|
||||||
|
<label for="presets">{{ 'Presets' | trans }}</label>
|
||||||
|
<select name="presets" id="presets">
|
||||||
|
<option>{{ 'Choisir' | trans }}</option>
|
||||||
|
</select>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form method="post" action="{{ path('admin_subdefs_subdef_update', { 'sbas_id' : databox.get_sbas_id }) }}" target="_self" class="subdefs">
|
<form method="post" action="{{ path('admin_subdefs_subdef_update', { 'sbas_id' : databox.get_sbas_id }) }}" target="_self" class="subdefs">
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
|
{% for subdefgroup, subdeflist in subdefs %}
|
||||||
|
<li><a class="no-ajax" href="#{{subdefgroup}}">{{subdefgroup}}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
<button type="submit" disabled="disabled" class="btn btn-primary subviews-submit">{{ 'boutton::valider' | trans }}</button>
|
||||||
{% for subdefgroup, subdeflist in subdefs %}
|
{% for subdefgroup, subdeflist in subdefs %}
|
||||||
<li><a class="no-ajax" href="#{{subdefgroup}}">{{subdefgroup}}</a></li>
|
<div id="{{subdefgroup}}">
|
||||||
{% endfor %}
|
<div>
|
||||||
</ul>
|
<table cellspacing="0" cellpadding="0" border="0" style="width:500px;">
|
||||||
|
<tbody>
|
||||||
{% for subdefgroup, subdeflist in subdefs %}
|
|
||||||
<div id="{{subdefgroup}}">
|
|
||||||
<div>
|
|
||||||
<table cellspacing="0" cellpading="0" border="0" style="width:500px;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="width:120px;">
|
|
||||||
<h2>{{ 'subdef.document' | trans }}</h2>
|
|
||||||
</td>
|
|
||||||
<td style="width:250px;"></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>{{ 'subdef.orderable' | trans }}</td>
|
|
||||||
<td><input type="checkbox" name="subdefsgroups[{{ subdefgroup }}][document_orderable]" {% if subdeflist.isDocumentOrderable() %}checked="checked" {% endif %}value="1"/></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
{% for subdefname , subdef in subdeflist %}
|
|
||||||
<div>
|
|
||||||
<input type="hidden" name="subdefs[]" value="{{subdefgroup}}_{{subdefname}}"/>
|
|
||||||
<table cellspacing="0" cellpading="0" border="0" style="width:500px;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="width:120px;">
|
|
||||||
<h2>{{subdefname}}</h2><button class="subdef_deleter btn btn-danger btn-mini">{{ 'boutton::supprimer' | trans }}</button>
|
|
||||||
<input type="hidden" name="subdef" value="{{subdefgroup}}_{{subdefname}}"/>
|
|
||||||
</td>
|
|
||||||
<td style="width:250px;"></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
{% for code, language in app['locales.available'] %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ language }}</td>
|
<td style="width:120px;">
|
||||||
<td><input type="text" name="{{subdefgroup}}_{{subdefname}}_label[{{ code }}]" value="{{ subdef.get_label(code, false) }}" /></td>
|
<h2>{{ 'subdef.document' | trans }}</h2>
|
||||||
|
</td>
|
||||||
|
<td style="width:250px;"></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
<tr>
|
||||||
<tr>
|
<td>{{ 'subdef.orderable' | trans }}</td>
|
||||||
<td>{{ 'Telechargeable' | trans }}</td>
|
<td><input type="checkbox" name="subdefsgroups[{{ subdefgroup }}][document_orderable]" {% if subdeflist.isDocumentOrderable() %}checked="checked" {% endif %}value="1"/></td>
|
||||||
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.isDownloadable() %}checked="checked"{% endif %} value="1" /></td>
|
<td></td>
|
||||||
<td></td>
|
</tr>
|
||||||
</tr>
|
</tbody>
|
||||||
<tr>
|
</table>
|
||||||
<td>{{ 'subdef.orderable' | trans }}</td>
|
</div>
|
||||||
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_orderable" {% if subdef.isOrderable() %}checked="checked"{% endif %} value="1" /></td>
|
{% for subdefname , subdef in subdeflist %}
|
||||||
<td></td>
|
<div>
|
||||||
</tr>
|
<input type="hidden" name="subdefs[]" value="{{subdefgroup}}_{{subdefname}}"/>
|
||||||
<tr>
|
<h2 class="subdefName">{{subdefname}}</h2><button class="subdef_deleter btn btn-danger btn-mini">{{ 'boutton::supprimer' | trans }}</button>
|
||||||
<td>
|
<input type="hidden" name="subdef" value="{{subdefgroup}}_{{subdefname}}"/>
|
||||||
{{ 'classe' | trans }}
|
<br />
|
||||||
</td>
|
<table class="subdefTab" cellspacing="0" cellpading="0" border="0" style="display:inline-block;">
|
||||||
<td>
|
<tbody>
|
||||||
<select name="{{subdefgroup}}_{{subdefname}}_class">
|
<tr>
|
||||||
<option>{{ 'classe' | trans }}</option>
|
<td style="width:100px;line-height: 0.9rem;">{{ 'Telechargeable' | trans }}</td>
|
||||||
<option value="document" {% if subdef.get_class() == "document" %}selected="selected"{% endif %}>{{ 'document' | trans }}</option>
|
<td style="width:300px;"><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.is_downloadable() %}checked="checked"{% endif %} value="1" /></td>
|
||||||
<option value="preview" {% if subdef.get_class() == "preview" %}selected="selected"{% endif %}>{{ 'preview' | trans }}</option>
|
<td></td>
|
||||||
<option value="thumbnail" {% if subdef.get_class() == "thumbnail" %}selected="selected"{% endif %}>{{ 'tout le monde' | trans }}</option>
|
</tr>
|
||||||
</select>
|
<tr>
|
||||||
</td>
|
<td>
|
||||||
<td></td>
|
{{ 'classe' | trans }}
|
||||||
</tr>
|
</td>
|
||||||
<tr>
|
<td>
|
||||||
<td>
|
<select name="{{subdefgroup}}_{{subdefname}}_class">
|
||||||
Path
|
<option>{{ 'classe' | trans }}</option>
|
||||||
</td>
|
<option value="document" {% if subdef.get_class() == "document" %}selected="selected"{% endif %}>{{ 'document' | trans }}</option>
|
||||||
<td>
|
<option value="preview" {% if subdef.get_class() == "preview" %}selected="selected"{% endif %}>{{ 'preview' | trans }}</option>
|
||||||
<input class="path_testable test_writeable" type="text" value="{{subdef.get_path()}}" name="{{subdefgroup}}_{{subdefname}}_path"/>
|
<option value="thumbnail" {% if subdef.get_class() == "thumbnail" %}selected="selected"{% endif %}>{{ 'tout le monde' | trans }}</option>
|
||||||
</td>
|
</select>
|
||||||
<td></td>
|
</td>
|
||||||
</tr>
|
<td></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td>
|
<tr>
|
||||||
{{ 'Write Metas' | trans }}
|
<td>
|
||||||
</td>
|
{{ 'mediatype' | trans }}
|
||||||
<td>
|
</td>
|
||||||
<input type="checkbox" value="yes" {% if subdef.isMetadataUpdateRequired() %}checked="checked"{% endif %} name="{{subdefgroup}}_{{subdefname}}_meta"/>
|
<td>
|
||||||
</td>
|
<select onchange="select_mediatype('{{subdefgroup}}', '{{subdefname}}', this);" name="{{subdefgroup}}_{{subdefname}}_mediatype">
|
||||||
<td></td>
|
<option>{{ 'Choisir' | trans }}</option>
|
||||||
</tr>
|
{% for subdefType in subdef.getAvailableSubdefTypes() %}
|
||||||
<tr>
|
<option value="{{ subdefType.getType() }}" {% if subdef.getSubdefType.getType() == subdefType.getType() %}selected="selected"{% endif %}>{{ subdefType.getType() }}</option>
|
||||||
<td>
|
{% endfor %}
|
||||||
{{ 'mediatype' | trans }}
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td></td>
|
||||||
<select onchange="select_mediatype('{{subdefgroup}}{{subdefname}}', this);" name="{{subdefgroup}}_{{subdefname}}_mediatype">
|
</tr>
|
||||||
<option>{{ 'Choisir' | trans }}</option>
|
<tr>
|
||||||
{% for subdefType in subdef.getAvailableSubdefTypes() %}
|
<td>
|
||||||
<option value="{{ subdefType.getType() }}" {% if subdef.getSubdefType.getType() == subdefType.getType() %}selected="selected"{% endif %}>{{ subdefType.getType() }}</option>
|
{{ 'Presets' | trans }}
|
||||||
{% endfor %}
|
</td>
|
||||||
</select>
|
<td>
|
||||||
</td>
|
<select onchange="populate_values('{{subdefgroup}}', '{{subdefname}}');" name="{{subdefgroup}}_{{subdefname}}_presets">
|
||||||
<td></td>
|
<option value="custom">{{ 'Custom' | trans }}</option>
|
||||||
</tr>
|
{% set defType = subdef.getSubdefType.getType() %}
|
||||||
</tbody>
|
{% for key, pressets in config[defType].definitions %}
|
||||||
</table>
|
{% if pressets == null %}
|
||||||
{% for subdefType in subdef.getAvailableSubdefTypes() %}
|
<option disabled="disabled">{{ key }}</option>
|
||||||
<div id="box{{subdefgroup}}{{subdefname}}{{ subdefType.getType() }}" class="{{subdefgroup}}{{subdefname}}" {% if subdef.getSubdefType.getType() != subdefType.getType() %}style="display:none;"{% endif %}>
|
{% else %}
|
||||||
<table cellspacing="0" cellpading="0" border="0" style="width:500px;">
|
<option value="{{ key }}" {% if subdef.get_preset() == key %}selected="selected"{% endif %}>{{ key }}</option>
|
||||||
{% for option in subdefType.getOptions() %}
|
{% endif %}
|
||||||
{% set varname = subdefgroup~'_'~subdefname~'_'~subdefType.getType()~'['~ option.getName() ~']' %}
|
{% endfor %}
|
||||||
<tr>
|
</select>
|
||||||
<td style="width:120px;">
|
</td>
|
||||||
{{option.getDisplayName()}}
|
<td></td>
|
||||||
</td>
|
</tr>
|
||||||
<td style="width:250px;">
|
<tr>
|
||||||
{% set extradata = '' %}
|
<td>
|
||||||
{% if option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_RANGE') %}
|
Path
|
||||||
<div style="width:250px;" id="slider{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}"></div>
|
</td>
|
||||||
<script type="text/javascript">
|
<td>
|
||||||
|
<input class="path_testable test_writeable" type="text" value="{{subdef.get_path()}}" name="{{subdefgroup}}_{{subdefname}}_path"/>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ 'Write Metas' | trans }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" value="yes" {% if subdef.isMetadataUpdateRequired() %}checked="checked"{% endif %} name="{{subdefgroup}}_{{subdefname}}_meta"/>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table cellspacing="0" class="langTab" cellpading="0" border="0">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><h3>Labels</h3></td>
|
||||||
|
</tr>
|
||||||
|
{% for code, language in app['locales.available'] %}
|
||||||
|
<tr>
|
||||||
|
<td style="width:100px;">{{ language }}</td>
|
||||||
|
<td style="width:300px;"><input type="text" name="{{subdefgroup}}_{{subdefname}}_label[{{ code }}]" value="{{ subdef.get_label(code, false) }}" /></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% for subdefType in subdef.getAvailableSubdefTypes() %}
|
||||||
|
<span class="toggle" data-toggle="#box{{subdefgroup}}{{subdefname}}{{ subdefType.getType() }}" {% if subdef.getSubdefType.getType() != subdefType.getType() %}style="display:none;"{% endif %}>
|
||||||
|
{{ 'Advanced settings' | trans }}
|
||||||
|
</span>
|
||||||
|
<div id="box{{subdefgroup}}{{subdefname}}{{ subdefType.getType() }}" class="{{subdefgroup}}{{subdefname}}" {% if subdef.getSubdefType.getType() != subdefType.getType() %}style="display:none;"{% endif %}>
|
||||||
|
<table cellspacing="0" cellpading="0" border="0" style="width:500px;">
|
||||||
|
{% for option in subdefType.getOptions() %}
|
||||||
|
{% set varname = subdefgroup~'_'~subdefname~'_'~subdefType.getType()~'['~ option.getName() ~']' %}
|
||||||
|
<tr>
|
||||||
|
<td style="width:120px;">
|
||||||
|
{{option.getDisplayName()}}
|
||||||
|
</td>
|
||||||
|
<td style="width:250px;">
|
||||||
|
{% set extradata = '' %}
|
||||||
|
{% if option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_RANGE') %}
|
||||||
|
<div style="width:250px;" id="slider{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
$('#slider{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}')
|
$('#slider{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}')
|
||||||
.slider({
|
.slider({
|
||||||
value:{{ option.getValue }},
|
value:{{ option.getValue }},
|
||||||
min: {{ option.getMinValue() }},
|
min: {{ option.getMinValue() }},
|
||||||
max: {{ option.getMaxValue() }},
|
max: {{ option.getMaxValue() }},
|
||||||
{% if option.getStep() is not empty %}step : {{ option.getStep() }},{% endif %}
|
{% if option.getStep() is not empty %}step : {{ option.getStep() }},{% endif %}
|
||||||
slide: function( event, ui ) {
|
slide: function( event, ui ) {
|
||||||
$( "#slidervalue{{subdefgroup}}{{subdefname}}{{ subdefType.getType() }}{{ option.getName() }}" ).val( ui.value );
|
$( "#slidervalue{{subdefgroup}}{{subdefname}}{{ subdefType.getType() }}{{ option.getName() }}" ).val( ui.value );
|
||||||
},
|
jQuery('[name={{subdefgroup}}_{{subdefname}}_presets]').val("custom");
|
||||||
create: function (event, ui) {
|
if(jQuery(".subviews-submit").attr("disabled"))
|
||||||
{# add no-ajax class to slider link to prevent page load in IE7 #}
|
activeSubmit();
|
||||||
$("a.ui-slider-handle", event.target).addClass("no-ajax");
|
},
|
||||||
}
|
create: function (event, ui) {
|
||||||
});
|
{# add no-ajax class to slider link to prevent page load in IE7 #}
|
||||||
|
$("a.ui-slider-handle", event.target).addClass("no-ajax");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#slidervalue{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}').on('change', function(){
|
$('#slidervalue{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}').on('change', function(){
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
$('#slider{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}').slider( "option", "value", $this.val() );
|
$('#slider{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}').slider( "option", "value", $this.val() );
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_ENUM') %}
|
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_ENUM') %}
|
||||||
<select name="{{varname}}">
|
<select name="{{varname}}">
|
||||||
<option value="">{{ 'Choisir' | trans }}</option>
|
<option value="">{{ 'Choisir' | trans }}</option>
|
||||||
{% for pot_value in option.getAvailableValues() %}
|
{% for pot_value in option.getAvailableValues() %}
|
||||||
<option value="{{ pot_value }}" {% if pot_value == option.getValue() %}selected="selected"{% endif %}>{{ pot_value }}</option>
|
<option value="{{ pot_value }}" {% if pot_value == option.getValue() %}selected="selected"{% endif %}>{{ pot_value }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_BOOLEAN') %}
|
||||||
|
<input name="{{varname}}" type="radio" value="yes" {% if option.getValue() %}checked="checked"{% endif %} /> {{ 'yes' | trans }}
|
||||||
|
<input name="{{varname}}" type="radio" value="no" {% if option.getValue() is empty %}checked="checked"{% endif %}/> {{ 'no' | trans }}
|
||||||
|
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_MULTI') %}
|
||||||
|
{% for pot_value, selected in option.Value(true) %}
|
||||||
|
<label class="checkbox inline">
|
||||||
|
<input type="checkbox" name="{{varname}}[]" value="{{ pot_value }}" {% if selected %}checked="checked"{% endif %}/>{{ pot_value }}
|
||||||
|
</label>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if option.type == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_RANGE') %}
|
||||||
|
<input style="width:35px;" value="{{option.value}}" id="slidervalue{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}" name="{{varname}}" />
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</table>
|
||||||
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_BOOLEAN') %}
|
</div>
|
||||||
<input name="{{varname}}" type="radio" value="yes" {% if option.getValue() %}checked="checked"{% endif %} /> {{ 'yes' | trans }}
|
{% endfor %}
|
||||||
<input name="{{varname}}" type="radio" value="no" {% if option.getValue() is empty %}checked="checked"{% endif %}/> {{ 'no' | trans }}
|
</div>
|
||||||
{% elseif option.getType() == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_MULTI') %}
|
<script>
|
||||||
{% for pot_value, selected in option.Value(true) %}
|
{% set defType = subdef.getSubdefType.getType() %}
|
||||||
<label class="checkbox inline">
|
jQuery('#box{{subdefgroup}}{{subdefname}}{{ defType }} input, #box{{subdefgroup}}{{subdefname}}{{ defType }} select').change(function(){
|
||||||
<input type="checkbox" name="{{varname}}[]" value="{{ pot_value }}" {% if selected %}checked="checked"{% endif %}/>{{ pot_value }}
|
jQuery('[name={{subdefgroup}}_{{subdefname}}_presets]').val("custom");
|
||||||
</label>
|
});
|
||||||
{% endfor %}
|
</script>
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% if option.type == constant('\\Alchemy\\Phrasea\\Media\\Subdef\\OptionType\\OptionType::TYPE_RANGE') %}
|
|
||||||
<input style="width:35px;" value="{{option.value}}" id="slidervalue{{subdefgroup}}{{subdefname}}{{subdefType.getType()}}{{ option.getName() }}" name="{{varname}}" />
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
<input type="hidden" name="delete_subdef" id="delete_subdef" value=""/>
|
||||||
</div>
|
<input type="hidden" name="add_subdef[group]" value=""/>
|
||||||
<input type="hidden" name="delete_subdef" id="delete_subdef" value=""/>
|
<input type="hidden" name="add_subdef[name]" value=""/>
|
||||||
<input type="hidden" name="add_subdef[group]" value=""/>
|
<input type="hidden" name="add_subdef[mediaType]" value=""/>
|
||||||
<input type="hidden" name="add_subdef[name]" value=""/>
|
<input type="hidden" name="add_subdef[class]" value=""/>
|
||||||
<input type="hidden" name="add_subdef[class]" value=""/>
|
<input type="hidden" name="add_subdef[presets]" value=""/>
|
||||||
<div class="form-actions">
|
</form>
|
||||||
<button type="submit" class="btn btn-primary">{{ 'boutton::valider' | trans }}</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<div style="display:none;">
|
<div style="display:none;">
|
||||||
<div id="image_template">
|
<div id="image_template">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
use Alchemy\Phrasea\Media\Subdef\Image;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group functional
|
* @group functional
|
||||||
* @group legacy
|
* @group legacy
|
||||||
@@ -13,9 +12,7 @@ use Alchemy\Phrasea\Media\Subdef\Image;
|
|||||||
class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||||
{
|
{
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
||||||
protected $databox_id;
|
protected $databox_id;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -24,12 +21,10 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
$databox = array_shift($databoxes);
|
$databox = array_shift($databoxes);
|
||||||
$this->databox_id = $databox->get_sbas_id();
|
$this->databox_id = $databox->get_sbas_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubdefName()
|
public function getSubdefName()
|
||||||
{
|
{
|
||||||
return 'testname' . time() . mt_rand(10000, 99999);
|
return 'testname' . time() . mt_rand(10000, 99999);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default route test
|
* Default route test
|
||||||
*/
|
*/
|
||||||
@@ -38,73 +33,63 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
|||||||
self::$DI['client']->request("GET", "/admin/subdefs/" . $this->databox_id . "/");
|
self::$DI['client']->request("GET", "/admin/subdefs/" . $this->databox_id . "/");
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPostRouteAddSubdef()
|
public function testPostRouteAddSubdef()
|
||||||
{
|
{
|
||||||
$name = $this->getSubdefName();
|
$name = $this->getSubdefName();
|
||||||
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/", ['add_subdef' => [
|
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/", ['add_subdef' => [
|
||||||
'class' => 'thumbnail',
|
'class' => 'thumbnail',
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'group' => 'image'
|
'group' => 'image'
|
||||||
]]);
|
]]);
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||||
|
|
||||||
$app = $this->getApplication();
|
$app = $this->getApplication();
|
||||||
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
||||||
$subdefs->delete_subdef('image', $name);
|
$subdefs->delete_subdef('image', $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPostRouteDeleteSubdef()
|
public function testPostRouteDeleteSubdef()
|
||||||
{
|
{
|
||||||
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
||||||
$name = $this->getSubdefName();
|
$name = $this->getSubdefName();
|
||||||
$subdefs->add_subdef("image", $name, "thumbnail");
|
$subdefs->add_subdef("image", $name, "thumbnail", "image", "1280px JPG (preview Phraseanet)");
|
||||||
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/", ['delete_subdef' => 'image_' . $name]);
|
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/", ['delete_subdef' => 'image_' . $name]);
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||||
try {
|
try {
|
||||||
$subdefs->get_subdef("image", $name);
|
$subdefs->get_subdef("image", $name);
|
||||||
$this->fail("should raise an exception");
|
$this->fail("should raise an exception");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPostRouteAddSubdefWithNoParams()
|
public function testPostRouteAddSubdefWithNoParams()
|
||||||
{
|
{
|
||||||
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
||||||
$name = $this->getSubdefName();
|
$name = $this->getSubdefName();
|
||||||
$subdefs->add_subdef("image", $name, "thumbnail");
|
$subdefs->add_subdef("image", $name, "thumbnail", "image", "1280px JPG (preview Phraseanet)");
|
||||||
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/"
|
self::$DI['client']->request("POST", "/admin/subdefs/" . $this->databox_id . "/"
|
||||||
, ['subdefs' => [
|
, ['subdefs' => [
|
||||||
'image_' . $name
|
'image_' . $name
|
||||||
]
|
]
|
||||||
, 'image_' . $name . '_class' => 'thumbnail'
|
, 'image_' . $name . '_class' => 'thumbnail'
|
||||||
, 'image_' . $name . '_downloadable' => 0
|
, 'image_' . $name . '_downloadable' => 0
|
||||||
, 'image_' . $name . '_mediatype' => 'image'
|
, 'image_' . $name . '_mediatype' => 'image'
|
||||||
, 'image_' . $name . '_image' => [
|
, 'image_' . $name . '_image' => [
|
||||||
'size' => 400,
|
'size' => 400,
|
||||||
'resolution' => 83,
|
'resolution' => 83,
|
||||||
'strip' => 0,
|
'strip' => 0,
|
||||||
'quality' => 90,
|
'quality' => 90,
|
||||||
]]
|
]]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||||
$app = $this->getApplication();
|
$app = $this->getApplication();
|
||||||
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
||||||
$subdef = $subdefs->get_subdef("image", $name);
|
$subdef = $subdefs->get_subdef("image", $name);
|
||||||
|
/* @var $subdef \databox_subdef */
|
||||||
$this->assertFalse($subdef->isDownloadable());
|
$this->assertFalse($subdef->is_downloadable());
|
||||||
|
|
||||||
$options = $subdef->getOptions();
|
$options = $subdef->getOptions();
|
||||||
|
|
||||||
$this->assertTrue(is_array($options));
|
$this->assertTrue(is_array($options));
|
||||||
|
|
||||||
$this->assertEquals(400, $options[Image::OPTION_SIZE]->getValue());
|
$this->assertEquals(400, $options[Image::OPTION_SIZE]->getValue());
|
||||||
$this->assertEquals(83, $options[Image::OPTION_RESOLUTION]->getValue());
|
$this->assertEquals(83, $options[Image::OPTION_RESOLUTION]->getValue());
|
||||||
$this->assertEquals(90, $options[Image::OPTION_QUALITY]->getValue());
|
$this->assertEquals(90, $options[Image::OPTION_QUALITY]->getValue());
|
||||||
$this->assertFalse($options[Image::OPTION_STRIP]->getValue());
|
$this->assertFalse($options[Image::OPTION_STRIP]->getValue());
|
||||||
|
|
||||||
$subdefs->delete_subdef("image", $name);
|
$subdefs->delete_subdef("image", $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user