mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
Merge pull request #409 from romainneutron/subdef-labels
[3.8] Add localized labels in subdef editing
This commit is contained in:
@@ -115,7 +115,9 @@ class Subdefs implements ControllerProviderInterface
|
|||||||
$options[$option] = $value;
|
$options[$option] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$subdefs->set_subdef($group, $name, $class, $downloadable, $options);
|
$labels = $request->request->get($post_sub . '_label', array());
|
||||||
|
|
||||||
|
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -166,6 +166,17 @@ class databox_subdef
|
|||||||
return $this->labels;
|
return $this->labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_label($code, $substitute = true)
|
||||||
|
{
|
||||||
|
if (!isset($this->labels[$code]) && $substitute) {
|
||||||
|
return $this->get_name();
|
||||||
|
} elseif (isset($this->labels[$code])) {
|
||||||
|
return $this->labels[$code];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* boolean
|
* boolean
|
||||||
*
|
*
|
||||||
|
@@ -220,7 +220,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
* @param Array $options
|
* @param Array $options
|
||||||
* @return databox_subdefsStructure
|
* @return databox_subdefsStructure
|
||||||
*/
|
*/
|
||||||
public function set_subdef($group, $name, $class, $downloadable, $options)
|
public function set_subdef($group, $name, $class, $downloadable, $options, $labels)
|
||||||
{
|
{
|
||||||
$dom_struct = $this->databox->get_dom_structure();
|
$dom_struct = $this->databox->get_dom_structure();
|
||||||
|
|
||||||
@@ -229,6 +229,14 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
$subdef->setAttribute('name', mb_strtolower($name));
|
$subdef->setAttribute('name', mb_strtolower($name));
|
||||||
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
||||||
|
|
||||||
|
foreach ($labels as $code => $label) {
|
||||||
|
$child = $dom_struct->createElement('label');
|
||||||
|
$labelElement = $child->appendChild($dom_struct->createTextNode($label));
|
||||||
|
$lang = $child->appendChild($dom_struct->createAttribute('lang'));
|
||||||
|
$lang->value = $code;
|
||||||
|
$subdef->appendChild($child);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($options as $option => $value) {
|
foreach ($options as $option => $value) {
|
||||||
|
|
||||||
if (is_scalar($value)) {
|
if (is_scalar($value)) {
|
||||||
|
@@ -115,7 +115,7 @@ class patch_370a6 implements patchInterface
|
|||||||
$options['meta'] = $subdef->meta_writeable() ? 'yes' : 'no';
|
$options['meta'] = $subdef->meta_writeable() ? 'yes' : 'no';
|
||||||
$options['devices'] = array(databox_subdef::DEVICE_SCREEN);
|
$options['devices'] = array(databox_subdef::DEVICE_SCREEN);
|
||||||
|
|
||||||
$root->set_subdef($groupname, $subdef->get_name(), $subdef->get_class(), $subdef->is_downloadable(), $options);
|
$root->set_subdef($groupname, $subdef->get_name(), $subdef->get_class(), $subdef->is_downloadable(), $options, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addMobileSubdefVideo($root, $baseSubdef, $groupname)
|
protected function addMobileSubdefVideo($root, $baseSubdef, $groupname)
|
||||||
@@ -151,9 +151,9 @@ class patch_370a6 implements patchInterface
|
|||||||
$newSubdefOptionsX264['acodec'] = 'libvo_aacenc';
|
$newSubdefOptionsX264['acodec'] = 'libvo_aacenc';
|
||||||
$newSubdefOptionsX264['vcodec'] = 'libx264';
|
$newSubdefOptionsX264['vcodec'] = 'libx264';
|
||||||
|
|
||||||
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM);
|
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM, array());
|
||||||
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg);
|
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg, array());
|
||||||
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_X264', $baseSubdef->get_class(), false, $newSubdefOptionsX264);
|
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile_X264', $baseSubdef->get_class(), false, $newSubdefOptionsX264, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addMobileSubdefImage($root, $baseSubdef, $groupname)
|
protected function addMobileSubdefImage($root, $baseSubdef, $groupname)
|
||||||
@@ -170,7 +170,7 @@ class patch_370a6 implements patchInterface
|
|||||||
|
|
||||||
$optionMobile['devices'] = array(databox_subdef::DEVICE_HANDHELD);
|
$optionMobile['devices'] = array(databox_subdef::DEVICE_HANDHELD);
|
||||||
|
|
||||||
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile', $baseSubdef->get_class(), false, $optionMobile);
|
$root->set_subdef($groupname, $baseSubdef->get_name() . '_mobile', $baseSubdef->get_class(), false, $optionMobile, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addHtml5Video($root, $baseSubdef, $groupname)
|
protected function addHtml5Video($root, $baseSubdef, $groupname)
|
||||||
@@ -192,7 +192,7 @@ class patch_370a6 implements patchInterface
|
|||||||
$newSubdefOptionsOgg['vcodec'] = 'libtheora';
|
$newSubdefOptionsOgg['vcodec'] = 'libtheora';
|
||||||
$newSubdefOptionsOgg['acodec'] = 'libvorbis';
|
$newSubdefOptionsOgg['acodec'] = 'libvorbis';
|
||||||
|
|
||||||
$root->set_subdef($groupname, $baseSubdef->get_name() . '_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM);
|
$root->set_subdef($groupname, $baseSubdef->get_name() . '_webM', $baseSubdef->get_class(), false, $newSubdefOptionsWebM, array());
|
||||||
$root->set_subdef($groupname, $baseSubdef->get_name() . '_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg);
|
$root->set_subdef($groupname, $baseSubdef->get_name() . '_OGG', $baseSubdef->get_class(), false, $newSubdefOptionsOgg, array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -213,6 +213,14 @@
|
|||||||
<td style="width:250px;"></td>
|
<td style="width:250px;"></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
{% for code, language in app['locales.I18n.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>
|
<tr>
|
||||||
<td>{% trans 'Telechargeable' %}</td>
|
<td>{% trans 'Telechargeable' %}</td>
|
||||||
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.is_downloadable() %}checked="checked"{% endif %} value="1" /></td>
|
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.is_downloadable() %}checked="checked"{% endif %} value="1" /></td>
|
||||||
|
Reference in New Issue
Block a user