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\Databox\SubdefGroup;
|
||||
use Alchemy\Phrasea\Media\Subdef\Subdef;
|
||||
use Alchemy\Phrasea\Media\Type\Type;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
use Alchemy\Phrasea\Media\Subdef\Video;
|
||||
use Alchemy\Phrasea\Media\Subdef\Audio;
|
||||
use Alchemy\Phrasea\Media\Subdef\Gif;
|
||||
|
||||
class SubdefsController extends Controller
|
||||
{
|
||||
@@ -23,10 +29,14 @@ class SubdefsController extends Controller
|
||||
*/
|
||||
function indexAction($sbas_id) {
|
||||
$databox = $this->findDataboxById((int) $sbas_id);
|
||||
$config = $this->getConfiguration();
|
||||
$subviews_mapping = $this->getSubviewsMapping();
|
||||
|
||||
return $this->render('admin/subdefs.html.twig', [
|
||||
'databox' => $databox,
|
||||
'subdefs' => $databox->get_subdef_structure(),
|
||||
'config' => $config,
|
||||
'subviews_mapping' => $subviews_mapping
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -43,7 +53,7 @@ class SubdefsController extends Controller
|
||||
|
||||
$databox = $this->findDataboxById((int) $sbas_id);
|
||||
|
||||
$add_subdef = ['class' => null, 'name' => null, 'group' => null];
|
||||
$add_subdef = ['class' => null, 'name' => null, 'group' => null, 'mediaType' => null, 'presets' => null];
|
||||
foreach ($add_subdef as $k => $v) {
|
||||
if (!isset($toadd_subdef[$k]) || trim($toadd_subdef[$k]) === '') {
|
||||
unset($add_subdef[$k]);
|
||||
@@ -58,7 +68,7 @@ class SubdefsController extends Controller
|
||||
$name = $delete_subef[1];
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
$subdefs->delete_subdef($group, $name);
|
||||
} elseif (count($add_subdef) === 3) {
|
||||
} elseif (count($add_subdef) === 5) {
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
|
||||
$group = $add_subdef['group'];
|
||||
@@ -66,11 +76,84 @@ class SubdefsController extends Controller
|
||||
$unicode = $this->app['unicode'];
|
||||
$name = $unicode->remove_nonazAZ09($add_subdef['name'], false);
|
||||
$class = $add_subdef['class'];
|
||||
$preset = $add_subdef['presets'];
|
||||
$mediatype = $add_subdef['mediaType'];
|
||||
|
||||
$subdefs->add_subdef($group, $name, $class, $mediatype, $preset);
|
||||
|
||||
if ($preset !== "Choose") {
|
||||
$options = [];
|
||||
|
||||
$config = $this->getConfiguration();
|
||||
|
||||
//On applique directement les valeurs du preset à la sous def
|
||||
switch($mediatype) {
|
||||
case Subdef::TYPE_IMAGE :
|
||||
$options["path"] = "";
|
||||
$options["meta"] = true;
|
||||
$options["mediatype"] = $mediatype;
|
||||
$options[Image::OPTION_SIZE] = $config["image"]["definitions"][$preset][Image::OPTION_SIZE];
|
||||
$options["dpi"] = $config["image"]["definitions"][$preset][Image::OPTION_RESOLUTION];
|
||||
$options[Image::OPTION_STRIP] = $config["image"]["definitions"][$preset][Image::OPTION_STRIP];
|
||||
$options[Image::OPTION_FLATTEN] = $config["image"]["definitions"][$preset][Image::OPTION_FLATTEN];
|
||||
$options[Image::OPTION_QUALITY] = $config["image"]["definitions"][$preset][Image::OPTION_QUALITY];
|
||||
$options[Image::OPTION_ICODEC] = $config["image"]["definitions"][$preset][Image::OPTION_ICODEC];
|
||||
foreach($config["image"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
|
||||
$options[Subdef::OPTION_DEVICE][] = $devices;
|
||||
}
|
||||
break;
|
||||
case Subdef::TYPE_VIDEO :
|
||||
$options["path"] = "";
|
||||
$options["meta"] = true;
|
||||
$options["mediatype"] = $mediatype;
|
||||
$options[Video::OPTION_AUDIOBITRATE] = $config["video"]["definitions"][$preset][Video::OPTION_AUDIOBITRATE];
|
||||
$options[Video::OPTION_AUDIOSAMPLERATE] = $config["video"]["definitions"][$preset][Video::OPTION_AUDIOSAMPLERATE];
|
||||
$options[Video::OPTION_BITRATE] = $config["video"]["definitions"][$preset][Video::OPTION_BITRATE];
|
||||
$options[Video::OPTION_GOPSIZE] = $config["video"]["definitions"][$preset][Video::OPTION_GOPSIZE];
|
||||
$options[Video::OPTION_SIZE] = $config["video"]["definitions"][$preset][Video::OPTION_SIZE];
|
||||
$options[Video::OPTION_FRAMERATE] = $config["video"]["definitions"][$preset][Video::OPTION_FRAMERATE];
|
||||
$options[Video::OPTION_VCODEC] = $config["video"]["definitions"][$preset][Video::OPTION_VCODEC];
|
||||
$options[Video::OPTION_ACODEC] = $config["video"]["definitions"][$preset][Video::OPTION_ACODEC];
|
||||
foreach($config["video"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
|
||||
$options[Subdef::OPTION_DEVICE][] = $devices;
|
||||
}
|
||||
break;
|
||||
case Subdef::TYPE_FLEXPAPER :
|
||||
$options["path"] = "";
|
||||
$options["meta"] = true;
|
||||
$options["mediatype"] = $mediatype;
|
||||
foreach($config["document"]["definitions"][$preset]["devices"] as $devices) {
|
||||
$options["devices"][] = $devices;
|
||||
}
|
||||
break;
|
||||
case Subdef::TYPE_ANIMATION :
|
||||
$options["path"] = "";
|
||||
$options["meta"] = true;
|
||||
$options["mediatype"] = $mediatype;
|
||||
$options[Gif::OPTION_SIZE] = $config["gif"]["definitions"][$preset][Gif::OPTION_SIZE];
|
||||
$options[Gif::OPTION_DELAY] = $config["gif"]["definitions"][$preset][Gif::OPTION_DELAY];
|
||||
foreach($config["gif"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
|
||||
$options[Subdef::OPTION_DEVICE][] = $devices;
|
||||
}
|
||||
break;
|
||||
case Subdef::TYPE_AUDIO :
|
||||
$options["path"] = "";
|
||||
$options["meta"] = true;
|
||||
$options["mediatype"] = $mediatype;
|
||||
$options[Audio::OPTION_AUDIOBITRATE] = $config["audio"]["definitions"][$preset][Audio::OPTION_AUDIOBITRATE];
|
||||
$options[Audio::OPTION_AUDIOSAMPLERATE] = $config["audio"]["definitions"][$preset][Audio::OPTION_AUDIOSAMPLERATE];
|
||||
$options[Audio::OPTION_ACODEC] = $config["audio"]["definitions"][$preset][Audio::OPTION_ACODEC];
|
||||
foreach($config["audio"]["definitions"][$preset][Subdef::OPTION_DEVICE] as $devices) {
|
||||
$options[Subdef::OPTION_DEVICE][] = $devices;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$subdefs->set_subdef($group, $name, $class, false, $options, [], $preset);
|
||||
}
|
||||
|
||||
$subdefs->add_subdef($group, $name, $class);
|
||||
} else {
|
||||
$subdefs = $databox->get_subdef_structure();
|
||||
|
||||
$this->updateSubdefGroups($subdefs, $request);
|
||||
|
||||
foreach ($Parmsubdefs as $post_sub) {
|
||||
@@ -81,6 +164,7 @@ class SubdefsController extends Controller
|
||||
$group = $post_sub_ex[0];
|
||||
$name = $post_sub_ex[1];
|
||||
|
||||
$preset = $request->request->get($post_sub . '_presets');
|
||||
$class = $request->request->get($post_sub . '_class');
|
||||
$downloadable = $request->request->get($post_sub . '_downloadable');
|
||||
$orderable = $request->request->get($post_sub . '_orderable');
|
||||
@@ -96,7 +180,6 @@ class SubdefsController extends Controller
|
||||
|
||||
$options[$def] = $parm_loc;
|
||||
}
|
||||
|
||||
$mediatype = $request->request->get($post_sub . '_mediatype');
|
||||
$media = $request->request->get($post_sub . '_' . $mediatype, []);
|
||||
|
||||
@@ -110,8 +193,7 @@ class SubdefsController extends Controller
|
||||
}
|
||||
|
||||
$labels = $request->request->get($post_sub . '_label', []);
|
||||
|
||||
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable);
|
||||
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset, $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.
|
||||
*
|
||||
* @param \databox_subdefsStructure $subdefs
|
||||
* @param Request $request
|
||||
*/
|
||||
private function updateSubdefGroups(\databox_subdefsStructure $subdefs, Request $request)
|
||||
protected function updateSubdefGroups(\databox_subdefsStructure $subdefs, Request $request)
|
||||
{
|
||||
$subdefsGroups = $request->request->get('subdefsgroups', []);
|
||||
$changedGroups = [];
|
||||
|
||||
/** @var SubdefGroup $subdefsGroup */
|
||||
foreach ($subdefs as $groupName => $subdefsGroup) {
|
||||
$documentOrderable = isset($subdefsGroups[$groupName]['document_orderable'])
|
||||
? \p4field::isyes($subdefsGroups[$groupName]['document_orderable'])
|
||||
: false;
|
||||
|
||||
if ($subdefsGroup->isDocumentOrderable() !== $documentOrderable) {
|
||||
if ($documentOrderable) {
|
||||
$subdefsGroup->allowDocumentOrdering();
|
||||
} else {
|
||||
$subdefsGroup->disallowDocumentOrdering();
|
||||
}
|
||||
|
||||
$changedGroups[] = $subdefsGroup;
|
||||
}
|
||||
}
|
||||
|
||||
if ($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
|
||||
{
|
||||
const OPTION_DEVICE = 'devices';
|
||||
|
||||
const TYPE_IMAGE = 'image';
|
||||
const TYPE_ANIMATION = 'gif';
|
||||
const TYPE_VIDEO = 'video';
|
||||
|
@@ -7,40 +7,18 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
use Alchemy\Phrasea\Media\Subdef\Audio;
|
||||
use Alchemy\Phrasea\Media\Subdef\Video;
|
||||
use Alchemy\Phrasea\Media\Subdef\FlexPaper;
|
||||
use Alchemy\Phrasea\Media\Subdef\Gif;
|
||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
use Alchemy\Phrasea\Media\Subdef\Unknown;
|
||||
use Alchemy\Phrasea\Media\Subdef\Subdef as SubdefSpecs;
|
||||
use Alchemy\Phrasea\Media\Subdef\Video;
|
||||
use Alchemy\Phrasea\Media\Type\Type as SubdefType;
|
||||
use MediaAlchemyst\Specification\SpecificationInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class databox_subdef
|
||||
{
|
||||
const CLASS_THUMBNAIL = 'thumbnail';
|
||||
const CLASS_PREVIEW = 'preview';
|
||||
const CLASS_DOCUMENT = 'document';
|
||||
|
||||
const DEVICE_ALL = 'all';
|
||||
const DEVICE_HANDHELD = 'handheld';
|
||||
const DEVICE_PRINT = 'print';
|
||||
const DEVICE_PROJECTION = 'projection';
|
||||
const DEVICE_SCREEN = 'screen';
|
||||
const DEVICE_TV = 'tv';
|
||||
|
||||
protected static $mediaTypeToSubdefTypes = [
|
||||
SubdefType::TYPE_AUDIO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO],
|
||||
SubdefType::TYPE_DOCUMENT => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER],
|
||||
SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE],
|
||||
SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE],
|
||||
SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION],
|
||||
SubdefType::TYPE_UNKNOWN => [SubdefSpecs::TYPE_IMAGE]
|
||||
];
|
||||
|
||||
/**
|
||||
* The class type of the subdef
|
||||
* Is null or one of the CLASS_* constants
|
||||
@@ -51,51 +29,60 @@ class databox_subdef
|
||||
protected $devices = [];
|
||||
protected $name;
|
||||
protected $path;
|
||||
protected $preset;
|
||||
protected $subdef_group;
|
||||
protected $labels = [];
|
||||
protected $downloadable;
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $requiresMetadataUpdate;
|
||||
protected $downloadable;
|
||||
protected $translator;
|
||||
protected static $mediaTypeToSubdefTypes = [
|
||||
SubdefType::TYPE_AUDIO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_AUDIO],
|
||||
SubdefType::TYPE_DOCUMENT => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER],
|
||||
SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE],
|
||||
SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE],
|
||||
SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION],
|
||||
SubdefType::TYPE_UNKNOWN => [SubdefSpecs::TYPE_IMAGE],
|
||||
];
|
||||
const CLASS_THUMBNAIL = 'thumbnail';
|
||||
const CLASS_PREVIEW = 'preview';
|
||||
const CLASS_DOCUMENT = 'document';
|
||||
const DEVICE_ALL = 'all';
|
||||
const DEVICE_HANDHELD = 'handheld';
|
||||
const DEVICE_PRINT = 'print';
|
||||
const DEVICE_PROJECTION = 'projection';
|
||||
const DEVICE_SCREEN = 'screen';
|
||||
const DEVICE_TV = 'tv';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $orderable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SubdefType $type
|
||||
* @param SimpleXMLElement $sd
|
||||
* @param TranslatorInterface $translator
|
||||
*
|
||||
* @return databox_subdef
|
||||
*/
|
||||
public function __construct(SubdefType $type, SimpleXMLElement $sd, TranslatorInterface $translator)
|
||||
{
|
||||
$this->subdef_group = $type;
|
||||
$this->class = (string)$sd->attributes()->class;
|
||||
$this->translator = $translator;
|
||||
|
||||
foreach ($sd->devices as $device) {
|
||||
$this->devices[] = (string)$device;
|
||||
}
|
||||
|
||||
$this->name = strtolower($sd->attributes()->name);
|
||||
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
|
||||
$this->orderable = isset($sd->attributes()->orderable) ? p4field::isyes($sd->attributes()->orderable) : true;
|
||||
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
|
||||
|
||||
$this->preset = $sd->attributes()->presets;
|
||||
$this->requiresMetadataUpdate = p4field::isyes((string)$sd->meta);
|
||||
|
||||
foreach ($sd->label as $label) {
|
||||
$lang = trim((string)$label->attributes()->lang);
|
||||
|
||||
if ($lang) {
|
||||
$this->labels[$lang] = (string)$label;
|
||||
}
|
||||
}
|
||||
|
||||
switch ((string)$sd->mediatype) {
|
||||
default:
|
||||
case SubdefSpecs::TYPE_IMAGE:
|
||||
@@ -118,7 +105,6 @@ class databox_subdef
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Image Subdef object depending the SimpleXMLElement
|
||||
*
|
||||
@@ -128,7 +114,6 @@ class databox_subdef
|
||||
protected function buildImageSubdef(SimpleXMLElement $sd)
|
||||
{
|
||||
$image = new Image($this->translator);
|
||||
|
||||
if ($sd->icodec) {
|
||||
$image->setOptionValue(Image::OPTION_ICODEC, (string) $sd->icodec);
|
||||
}
|
||||
@@ -147,10 +132,8 @@ class databox_subdef
|
||||
if ($sd->flatten) {
|
||||
$image->setOptionValue(Image::OPTION_FLATTEN, p4field::isyes($sd->flatten));
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Audio Subdef object depending the SimpleXMLElement
|
||||
*
|
||||
@@ -160,7 +143,6 @@ class databox_subdef
|
||||
protected function buildAudioSubdef(SimpleXMLElement $sd)
|
||||
{
|
||||
$audio = new Audio($this->translator);
|
||||
|
||||
if ($sd->acodec) {
|
||||
$audio->setOptionValue(Audio::OPTION_ACODEC, (string) $sd->acodec);
|
||||
}
|
||||
@@ -170,10 +152,8 @@ class databox_subdef
|
||||
if ($sd->audiosamplerate) {
|
||||
$audio->setOptionValue(Audio::OPTION_AUDIOSAMPLERATE, (int) $sd->audiosamplerate);
|
||||
}
|
||||
|
||||
return $audio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Video Subdef object depending the SimpleXMLElement
|
||||
*
|
||||
@@ -183,7 +163,6 @@ class databox_subdef
|
||||
protected function buildVideoSubdef(SimpleXMLElement $sd)
|
||||
{
|
||||
$video = new Video($this->translator);
|
||||
|
||||
if ($sd->size) {
|
||||
$video->setOptionValue(Video::OPTION_SIZE, (int) $sd->size);
|
||||
}
|
||||
@@ -208,10 +187,8 @@ class databox_subdef
|
||||
if ($sd->GOPsize) {
|
||||
$video->setOptionValue(Video::OPTION_GOPSIZE, (int) $sd->GOPsize);
|
||||
}
|
||||
|
||||
return $video;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build GIF Subdef object depending the SimpleXMLElement
|
||||
*
|
||||
@@ -221,17 +198,14 @@ class databox_subdef
|
||||
protected function buildGifSubdef(SimpleXMLElement $sd)
|
||||
{
|
||||
$gif = new Gif($this->translator);
|
||||
|
||||
if ($sd->size) {
|
||||
$gif->setOptionValue(Gif::OPTION_SIZE, (int) $sd->size);
|
||||
}
|
||||
if ($sd->delay) {
|
||||
$gif->setOptionValue(Gif::OPTION_DELAY, (int) $sd->delay);
|
||||
}
|
||||
|
||||
return $gif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Flexpaper Subdef object depending the SimpleXMLElement
|
||||
*
|
||||
@@ -242,8 +216,8 @@ class databox_subdef
|
||||
{
|
||||
return new FlexPaper($this->translator);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_class()
|
||||
@@ -252,6 +226,16 @@ class databox_subdef
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_preset()
|
||||
{
|
||||
return $this->preset;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_path()
|
||||
@@ -262,7 +246,7 @@ class databox_subdef
|
||||
/**
|
||||
* The devices matching this subdefinition
|
||||
*
|
||||
* @return array
|
||||
* @return Array
|
||||
*/
|
||||
public function getDevices()
|
||||
{
|
||||
@@ -272,7 +256,7 @@ class databox_subdef
|
||||
/**
|
||||
* The current SubdefType the subdef converts documents
|
||||
*
|
||||
* @return \Alchemy\Phrasea\Media\Subdef\Subdef
|
||||
* @return Alchemy\Phrasea\Media\Subdef\Subdef
|
||||
*/
|
||||
public function getSubdefType()
|
||||
{
|
||||
@@ -292,7 +276,7 @@ class databox_subdef
|
||||
/**
|
||||
* An associative label ; keys are i18n languages
|
||||
*
|
||||
* @return array
|
||||
* @return Array
|
||||
*/
|
||||
public function get_labels()
|
||||
{
|
||||
@@ -306,36 +290,19 @@ class databox_subdef
|
||||
} elseif (isset($this->labels[$code])) {
|
||||
return $this->labels[$code];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the subdef
|
||||
* boolean
|
||||
*
|
||||
* @return string
|
||||
* @return type
|
||||
*/
|
||||
public function get_name()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDownloadable()
|
||||
public function is_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
|
||||
*
|
||||
@@ -344,7 +311,6 @@ class databox_subdef
|
||||
public function getAvailableSubdefTypes()
|
||||
{
|
||||
$subdefTypes = [];
|
||||
|
||||
$availableDevices = [
|
||||
self::DEVICE_ALL,
|
||||
self::DEVICE_HANDHELD,
|
||||
@@ -353,11 +319,8 @@ class databox_subdef
|
||||
self::DEVICE_SCREEN,
|
||||
self::DEVICE_TV,
|
||||
];
|
||||
|
||||
if (isset(self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()])) {
|
||||
|
||||
foreach (self::$mediaTypeToSubdefTypes[$this->subdef_group->getType()] as $subdefType) {
|
||||
|
||||
if ($subdefType == $this->subdef_type->getType()) {
|
||||
$mediatype_obj = $this->subdef_type;
|
||||
} else {
|
||||
@@ -385,13 +348,11 @@ class databox_subdef
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi($this->translator->trans('Target Device'), 'devices', $availableDevices, $this->devices));
|
||||
|
||||
$mediatype_obj->registerOption(new \Alchemy\Phrasea\Media\Subdef\OptionType\Multi($this->translator->trans('Target Device'),
|
||||
'devices', $availableDevices, $this->devices));
|
||||
$subdefTypes[] = $mediatype_obj;
|
||||
}
|
||||
}
|
||||
|
||||
return $subdefTypes;
|
||||
}
|
||||
|
||||
@@ -405,6 +366,16 @@ class databox_subdef
|
||||
return $this->requiresMetadataUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the subdef
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MediaAlchemyst specs for the current subdef
|
||||
*
|
||||
|
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Databox\SubdefGroup;
|
||||
use Alchemy\Phrasea\Media\MediaTypeFactory;
|
||||
use Assert\Assertion;
|
||||
use Alchemy\Phrasea\Media\MediaTypeFactory;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
|
||||
class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
@@ -185,15 +185,19 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
* @param string $groupname
|
||||
* @param string $name
|
||||
* @param string $class
|
||||
* @param string $mediatype
|
||||
* @param string $preset
|
||||
* @return databox_subdefsStructure
|
||||
*/
|
||||
public function add_subdef($groupname, $name, $class)
|
||||
public function add_subdef($groupname, $name, $class, $mediatype, $preset)
|
||||
{
|
||||
$dom_struct = $this->databox->get_dom_structure();
|
||||
|
||||
$subdef = $dom_struct->createElement('subdef');
|
||||
$subdef->setAttribute('class', $class);
|
||||
$subdef->setAttribute('name', mb_strtolower($name));
|
||||
$subdef->setAttribute('presets', $preset);
|
||||
$subdef->setAttribute('mediaType', $mediatype);
|
||||
|
||||
$dom_xp = $this->databox->get_xpath_structure();
|
||||
$query = '//record/subdefs/subdefgroup[@name="' . $groupname . '"]';
|
||||
@@ -234,19 +238,18 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $group
|
||||
* @param string $name
|
||||
* @param string $class
|
||||
* @param string $preset
|
||||
* @param boolean $downloadable
|
||||
* @param array $options
|
||||
* @param array $labels
|
||||
* @param bool $orderable
|
||||
* @return databox_subdefsStructure
|
||||
* @throws Exception
|
||||
*/
|
||||
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true)
|
||||
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset = "Custom")
|
||||
{
|
||||
$dom_struct = $this->databox->get_dom_structure();
|
||||
|
||||
@@ -254,7 +257,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
$subdef->setAttribute('class', $class);
|
||||
$subdef->setAttribute('name', mb_strtolower($name));
|
||||
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
||||
$subdef->setAttribute('orderable', ($orderable ? 'true' : 'false'));
|
||||
$subdef->setAttribute('presets', $preset);
|
||||
|
||||
foreach ($labels as $code => $label) {
|
||||
$child = $dom_struct->createElement('label');
|
||||
|
@@ -336,6 +336,99 @@ div.switch_right.unchecked {
|
||||
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 './fields';
|
||||
@import './tables';
|
@@ -24,19 +24,176 @@
|
||||
$('.path_testable:visible, .url_testable:visible').trigger('keyup');
|
||||
}
|
||||
});
|
||||
|
||||
$(".toggle").on("click", function() {
|
||||
var box = $(this).data("toggle");
|
||||
$(box).toggle("500");
|
||||
});
|
||||
|
||||
function select_mediatype(name, selector)
|
||||
{
|
||||
$('.'+name).hide();
|
||||
$('#box'+name+$(selector).val()).show();
|
||||
$("input, select").one("change", activeSubmit);
|
||||
});
|
||||
|
||||
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" ),
|
||||
allFields = $( [] ).add( name ).add(accessclass),
|
||||
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 ) {
|
||||
@@ -60,14 +217,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function get_current_group()
|
||||
{
|
||||
return $('.ui-tabs-nav .ui-state-active a').html();
|
||||
}
|
||||
function checkPresence( mediaType, o ) {
|
||||
|
||||
function checkPresence( o ) {
|
||||
|
||||
var el = $('input[name="subdefs[]"][value="'+get_current_group()+'_'+o.val()+'"]');
|
||||
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" );
|
||||
@@ -96,8 +248,8 @@
|
||||
|
||||
$( "#dialog-form" ).dialog({
|
||||
autoOpen: false,
|
||||
height: 250,
|
||||
width: 350,
|
||||
height: 420,
|
||||
width: 300,
|
||||
modal: true,
|
||||
buttons: {
|
||||
"Create a Subdef": function() {
|
||||
@@ -107,14 +259,14 @@
|
||||
|
||||
bValid = bValid && checkLength( name, "subdef name", 3, 16 );
|
||||
bValid = bValid && checkSpecialChar( name );
|
||||
bValid = bValid && checkPresence( name );
|
||||
|
||||
|
||||
bValid = bValid && checkPresence( subviewType.val(), name );
|
||||
|
||||
if ( bValid ) {
|
||||
$('input[name="add_subdef[group]"]').val(get_current_group());
|
||||
$('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();
|
||||
}
|
||||
@@ -190,6 +342,23 @@
|
||||
<option value="preview" selected="selected">{{ 'preview' | trans }}</option>
|
||||
<option value="thumbnail">{{ 'tout le monde' | trans }}</option>
|
||||
</select>
|
||||
<label for="subviewType">{{ 'subviewType' | trans }}</label>
|
||||
<select name="subviewType" id="subviewType" onchange="subview_type(this)">
|
||||
<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>
|
||||
@@ -201,11 +370,11 @@
|
||||
<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 %}
|
||||
<div id="{{subdefgroup}}">
|
||||
<div>
|
||||
<table cellspacing="0" cellpading="0" border="0" style="width:500px;">
|
||||
<table cellspacing="0" cellpadding="0" border="0" style="width:500px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:120px;">
|
||||
@@ -225,32 +394,14 @@
|
||||
{% for subdefname , subdef in subdeflist %}
|
||||
<div>
|
||||
<input type="hidden" name="subdefs[]" value="{{subdefgroup}}_{{subdefname}}"/>
|
||||
<table cellspacing="0" cellpading="0" border="0" style="width:500px;">
|
||||
<h2 class="subdefName">{{subdefname}}</h2><button class="subdef_deleter btn btn-danger btn-mini">{{ 'boutton::supprimer' | trans }}</button>
|
||||
<input type="hidden" name="subdef" value="{{subdefgroup}}_{{subdefname}}"/>
|
||||
<br />
|
||||
<table class="subdefTab" cellspacing="0" cellpading="0" border="0" style="display:inline-block;">
|
||||
<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>
|
||||
<td>{{ language }}</td>
|
||||
<td><input type="text" name="{{subdefgroup}}_{{subdefname}}_label[{{ code }}]" value="{{ subdef.get_label(code, false) }}" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
<td>{{ 'Telechargeable' | trans }}</td>
|
||||
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.isDownloadable() %}checked="checked"{% endif %} value="1" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{ 'subdef.orderable' | trans }}</td>
|
||||
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_orderable" {% if subdef.isOrderable() %}checked="checked"{% endif %} value="1" /></td>
|
||||
<td style="width:100px;line-height: 0.9rem;">{{ 'Telechargeable' | trans }}</td>
|
||||
<td style="width:300px;"><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.is_downloadable() %}checked="checked"{% endif %} value="1" /></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -267,6 +418,39 @@
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'mediatype' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<select onchange="select_mediatype('{{subdefgroup}}', '{{subdefname}}', this);" name="{{subdefgroup}}_{{subdefname}}_mediatype">
|
||||
<option>{{ 'Choisir' | trans }}</option>
|
||||
{% for subdefType in subdef.getAvailableSubdefTypes() %}
|
||||
<option value="{{ subdefType.getType() }}" {% if subdef.getSubdefType.getType() == subdefType.getType() %}selected="selected"{% endif %}>{{ subdefType.getType() }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'Presets' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<select onchange="populate_values('{{subdefgroup}}', '{{subdefname}}');" name="{{subdefgroup}}_{{subdefname}}_presets">
|
||||
<option value="custom">{{ 'Custom' | trans }}</option>
|
||||
{% set defType = subdef.getSubdefType.getType() %}
|
||||
{% for key, pressets in config[defType].definitions %}
|
||||
{% if pressets == null %}
|
||||
<option disabled="disabled">{{ key }}</option>
|
||||
{% else %}
|
||||
<option value="{{ key }}" {% if subdef.get_preset() == key %}selected="selected"{% endif %}>{{ key }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Path
|
||||
@@ -285,23 +469,23 @@
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{ 'mediatype' | trans }}
|
||||
</td>
|
||||
<td>
|
||||
<select onchange="select_mediatype('{{subdefgroup}}{{subdefname}}', this);" name="{{subdefgroup}}_{{subdefname}}_mediatype">
|
||||
<option>{{ 'Choisir' | trans }}</option>
|
||||
{% for subdefType in subdef.getAvailableSubdefTypes() %}
|
||||
<option value="{{ subdefType.getType() }}" {% if subdef.getSubdefType.getType() == subdefType.getType() %}selected="selected"{% endif %}>{{ subdefType.getType() }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</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() %}
|
||||
@@ -324,6 +508,9 @@
|
||||
{% if option.getStep() is not empty %}step : {{ option.getStep() }},{% endif %}
|
||||
slide: function( event, ui ) {
|
||||
$( "#slidervalue{{subdefgroup}}{{subdefname}}{{ subdefType.getType() }}{{ option.getName() }}" ).val( ui.value );
|
||||
jQuery('[name={{subdefgroup}}_{{subdefname}}_presets]').val("custom");
|
||||
if(jQuery(".subviews-submit").attr("disabled"))
|
||||
activeSubmit();
|
||||
},
|
||||
create: function (event, ui) {
|
||||
{# add no-ajax class to slider link to prevent page load in IE7 #}
|
||||
@@ -366,6 +553,12 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script>
|
||||
{% set defType = subdef.getSubdefType.getType() %}
|
||||
jQuery('#box{{subdefgroup}}{{subdefname}}{{ defType }} input, #box{{subdefgroup}}{{subdefname}}{{ defType }} select').change(function(){
|
||||
jQuery('[name={{subdefgroup}}_{{subdefname}}_presets]').val("custom");
|
||||
});
|
||||
</script>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -373,10 +566,9 @@
|
||||
<input type="hidden" name="delete_subdef" id="delete_subdef" value=""/>
|
||||
<input type="hidden" name="add_subdef[group]" value=""/>
|
||||
<input type="hidden" name="add_subdef[name]" value=""/>
|
||||
<input type="hidden" name="add_subdef[mediaType]" value=""/>
|
||||
<input type="hidden" name="add_subdef[class]" value=""/>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">{{ 'boutton::valider' | trans }}</button>
|
||||
</div>
|
||||
<input type="hidden" name="add_subdef[presets]" value=""/>
|
||||
</form>
|
||||
|
||||
<div style="display:none;">
|
||||
|
@@ -3,7 +3,6 @@
|
||||
namespace Alchemy\Tests\Phrasea\Controller\Admin;
|
||||
|
||||
use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
* @group legacy
|
||||
@@ -13,9 +12,7 @@ use Alchemy\Phrasea\Media\Subdef\Image;
|
||||
class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
{
|
||||
protected $client;
|
||||
|
||||
protected $databox_id;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -24,12 +21,10 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
$databox = array_shift($databoxes);
|
||||
$this->databox_id = $databox->get_sbas_id();
|
||||
}
|
||||
|
||||
public function getSubdefName()
|
||||
{
|
||||
return 'testname' . time() . mt_rand(10000, 99999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default route test
|
||||
*/
|
||||
@@ -38,7 +33,6 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
self::$DI['client']->request("GET", "/admin/subdefs/" . $this->databox_id . "/");
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdef()
|
||||
{
|
||||
$name = $this->getSubdefName();
|
||||
@@ -48,32 +42,28 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'group' => 'image'
|
||||
]]);
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
|
||||
$app = $this->getApplication();
|
||||
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
||||
$subdefs->delete_subdef('image', $name);
|
||||
}
|
||||
|
||||
public function testPostRouteDeleteSubdef()
|
||||
{
|
||||
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
||||
$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]);
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
try {
|
||||
$subdefs->get_subdef("image", $name);
|
||||
$this->fail("should raise an exception");
|
||||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testPostRouteAddSubdefWithNoParams()
|
||||
{
|
||||
$subdefs = $this->getApplication()->findDataboxById($this->databox_id)->get_subdef_structure();
|
||||
$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 . "/"
|
||||
, ['subdefs' => [
|
||||
'image_' . $name
|
||||
@@ -88,23 +78,18 @@ class SubdefsTest extends \PhraseanetAuthenticatedWebTestCase
|
||||
'quality' => 90,
|
||||
]]
|
||||
);
|
||||
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isRedirect());
|
||||
$app = $this->getApplication();
|
||||
$subdefs = new \databox_subdefsStructure($app->findDataboxById($this->databox_id), $app['translator']);
|
||||
$subdef = $subdefs->get_subdef("image", $name);
|
||||
|
||||
$this->assertFalse($subdef->isDownloadable());
|
||||
|
||||
/* @var $subdef \databox_subdef */
|
||||
$this->assertFalse($subdef->is_downloadable());
|
||||
$options = $subdef->getOptions();
|
||||
|
||||
$this->assertTrue(is_array($options));
|
||||
|
||||
$this->assertEquals(400, $options[Image::OPTION_SIZE]->getValue());
|
||||
$this->assertEquals(83, $options[Image::OPTION_RESOLUTION]->getValue());
|
||||
$this->assertEquals(90, $options[Image::OPTION_QUALITY]->getValue());
|
||||
$this->assertFalse($options[Image::OPTION_STRIP]->getValue());
|
||||
|
||||
$subdefs->delete_subdef("image", $name);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user