mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
Remove \databox_field::set_multi
This commit is contained in:
@@ -179,7 +179,6 @@ class Description implements ControllerProviderInterface
|
||||
$field->set_name($request->get('name_' . $id));
|
||||
$field->set_thumbtitle($request->get('thumbtitle_' . $id));
|
||||
$field->set_tag(\databox_field::loadClassFromTagName($request->get('src_' . $id)));
|
||||
$field->set_multi($request->get('multi_' . $id));
|
||||
$field->set_business($request->get('business_' . $id));
|
||||
$field->set_indexable($request->get('indexable_' . $id));
|
||||
$field->set_required($request->get('required_' . $id));
|
||||
@@ -215,7 +214,7 @@ class Description implements ControllerProviderInterface
|
||||
}
|
||||
|
||||
if ($request->get('newfield')) {
|
||||
$field = \databox_field::create($databox, $request->get('newfield'));
|
||||
$field = \databox_field::create($databox, $request->get('newfield'), $request->get('newfield_multi'));
|
||||
}
|
||||
|
||||
if (is_array($request->get('todelete_ids'))) {
|
||||
|
@@ -337,74 +337,6 @@ class caption_field implements cache_cacheableInterface
|
||||
return;
|
||||
}
|
||||
|
||||
protected static function merge_metadatas(databox_field $databox_field, record_adapter $record)
|
||||
{
|
||||
$sql = 'SELECT record_id, id, value FROM metadatas
|
||||
WHERE meta_struct_id = :meta_struct_id
|
||||
AND record_id = :record_id';
|
||||
|
||||
$params = array(
|
||||
':meta_struct_id' => $databox_field->get_id(),
|
||||
':record_id' => $record->get_record_id()
|
||||
);
|
||||
|
||||
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
unset($stmt);
|
||||
|
||||
$values = $current_metadatas = array();
|
||||
|
||||
foreach ($rs as $row) {
|
||||
$current_metadatas[] = array(
|
||||
'meta_id' => $row['id']
|
||||
, 'meta_struct_id' => $databox_field->get_id()
|
||||
, 'value' => ''
|
||||
);
|
||||
|
||||
$values[] = $row['value'];
|
||||
}
|
||||
|
||||
try {
|
||||
$record = $databox_field->get_databox()->get_record($record->get_record_id());
|
||||
$record->set_metadatas($current_metadatas);
|
||||
$record->set_metadatas(array(array(
|
||||
'meta_id' => null
|
||||
, 'meta_struct_id' => $databox_field->get_id()
|
||||
, 'value' => implode(' ; ', $values)
|
||||
)));
|
||||
|
||||
unset($record);
|
||||
} catch (Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static function merge_all_metadatas(databox_field $databox_field)
|
||||
{
|
||||
$sql = 'SELECT distinct record_id FROM metadatas
|
||||
WHERE meta_struct_id = :meta_struct_id ';
|
||||
|
||||
$params = array(
|
||||
':meta_struct_id' => $databox_field->get_id()
|
||||
);
|
||||
|
||||
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
unset($stmt);
|
||||
|
||||
foreach ($rs as $row) {
|
||||
self::merge_metadatas($databox_field, $databox_field->get_databox()->get_record($row['record_id']));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public static function delete_all_metadatas(databox_field $databox_field)
|
||||
{
|
||||
$sql = 'SELECT count(id) as count_id FROM metadatas
|
||||
|
@@ -858,7 +858,7 @@ class databox extends base
|
||||
)
|
||||
) ? $type : databox_field::TYPE_STRING;
|
||||
|
||||
$meta_struct_field = databox_field::create($this, $fname);
|
||||
$meta_struct_field = databox_field::create($this, $fname, false);
|
||||
$meta_struct_field
|
||||
->set_readonly(isset($field['readonly']) ? $field['readonly'] : 0)
|
||||
->set_indexable(isset($field['index']) ? $field['index'] : '1')
|
||||
@@ -867,7 +867,6 @@ class databox extends base
|
||||
->set_type($type)
|
||||
->set_tbranch(isset($field['tbranch']) ? $field['tbranch'] : '')
|
||||
->set_thumbtitle(isset($field['thumbtitle']) ? $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
|
||||
->set_multi(isset($field['multi']) ? $field['multi'] : 0)
|
||||
->set_report(isset($field['report']) ? $field['report'] : '1')
|
||||
->save();
|
||||
|
||||
|
@@ -104,7 +104,6 @@ class databox_field implements cache_cacheableInterface
|
||||
*/
|
||||
protected $Business;
|
||||
protected $renamed = false;
|
||||
protected $metaToMerge = false;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -365,11 +364,6 @@ class databox_field implements cache_cacheableInterface
|
||||
$this->renamed = false;
|
||||
}
|
||||
|
||||
if ($this->metaToMerge) {
|
||||
caption_field::merge_all_metadatas($this);
|
||||
$this->metaToMerge = false;
|
||||
}
|
||||
|
||||
$dom_struct = $this->databox->get_dom_structure();
|
||||
$xp_struct = $this->databox->get_xpath_structure();
|
||||
|
||||
@@ -595,26 +589,6 @@ class databox_field implements cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $bool
|
||||
* @return databox_field
|
||||
*/
|
||||
public function set_multi($multi)
|
||||
{
|
||||
$multi = ! ! $multi;
|
||||
|
||||
if ($this->multi !== $multi && ! $multi) {
|
||||
$this->metaToMerge = true;
|
||||
}
|
||||
|
||||
$this->multi = $multi;
|
||||
|
||||
$this->set_separator(';');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $bool
|
||||
@@ -804,7 +778,7 @@ class databox_field implements cache_cacheableInterface
|
||||
return $this->on_error;
|
||||
}
|
||||
|
||||
public static function create(databox $databox, $name)
|
||||
public static function create(databox $databox, $name, $multi)
|
||||
{
|
||||
$sorter = 0;
|
||||
|
||||
@@ -822,7 +796,7 @@ class databox_field implements cache_cacheableInterface
|
||||
`thumbtitle`, `multi`, `business`,
|
||||
`report`, `sorter`)
|
||||
VALUES (null, :name, '', 0, 1, 'string', '',
|
||||
null, 0,
|
||||
null, :multi,
|
||||
0, 1, :sorter)";
|
||||
|
||||
$name = self::generateName($name);
|
||||
@@ -831,8 +805,10 @@ class databox_field implements cache_cacheableInterface
|
||||
throw new \Exception_InvalidArgument();
|
||||
}
|
||||
|
||||
$multi = $multi ? 1 : 0;
|
||||
|
||||
$stmt = $databox->get_connection()->prepare($sql);
|
||||
$stmt->execute(array(':name' => $name, ':sorter' => $sorter));
|
||||
$stmt->execute(array(':name' => $name, ':sorter' => $sorter, ':multi' => $multi));
|
||||
$id = $databox->get_connection()->lastInsertId();
|
||||
$stmt->closeCursor();
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
{% set disabled = 'disabled="disabled"' %}
|
||||
{% endif %}
|
||||
<select class="metafield_{{ selected_field.get_id() }} dces_selector" {{ disabled }} name="dces_{{ selected_field.get_id() }}">
|
||||
<option>{% trans 'choisir' %}</option>
|
||||
<option value="">{% trans 'choisir' %}</option>
|
||||
{% for field in available_dc_sources %}
|
||||
<option value="{{ field.get_label() }}" {% if selected_field.get_dces_element() != null and selected_field.get_dces_element().get_label() == field.get_label() %}selected="selected"{% endif %}>
|
||||
DC:{{ field.get_label() }}
|
||||
@@ -22,203 +22,6 @@
|
||||
<option value="ar" {% if title == 'ar' %}selected="selected"{% endif %}>{% trans 'Arabe' %}</option>
|
||||
{% endmacro %}
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=include/jslibs/yui2.8/build/reset/reset.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css,include/jslibs/jquery-treeview/jquery.treeview.css,skins/common/main.css,skins/admin/admincolor.css" />
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-1.7.1.js"></script>
|
||||
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.17/js/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/include/jquery.tooltip.js"></script>
|
||||
<style>
|
||||
body{
|
||||
font-size:12px;
|
||||
}
|
||||
.ui-autocomplete {
|
||||
max-height: 200px;
|
||||
max-width: 400px;
|
||||
overflow-y: auto;
|
||||
/* prevent horizontal scrollbar */
|
||||
overflow-x: hidden;
|
||||
/* add padding to account for vertical scrollbar */
|
||||
padding-right: 20px;
|
||||
}
|
||||
/** IE 6 doesn't support max-height
|
||||
* we use height instead, but this forces the menu to always be this tall
|
||||
*/
|
||||
* html .ui-autocomplete {
|
||||
height: 200px;
|
||||
}
|
||||
.ui-autocomplete-loading { background: white url('/skins/icons/ui-anim_basic_16x16.gif') right center no-repeat; }
|
||||
.alertTips{
|
||||
cursor:help;
|
||||
}
|
||||
.alert{
|
||||
vertical-align: baseline;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
$( "#field_chooser" ).autocomplete({
|
||||
source: "/admin/description/metadatas/search/",
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
$('#current_field_label').val(ui.item.value);
|
||||
}
|
||||
});
|
||||
|
||||
var buttons = {};
|
||||
var dialog = $('#field_changer');
|
||||
buttons['{% trans 'boutton::annuler' %}'] = function(){
|
||||
$('#field_changer').dialog('close');
|
||||
};
|
||||
|
||||
$('#tag_remover').bind('click', function(){
|
||||
$('#current_field_label').val('');
|
||||
});
|
||||
|
||||
buttons['{% trans 'boutton::valider' %}'] = function(){
|
||||
var field_id = $('input[name="field_id"]', dialog).val();
|
||||
$('#field_changer').dialog('close');
|
||||
|
||||
$('#display_value_'+field_id).empty().append($('#current_field_label').val());
|
||||
$('input[name="src_'+field_id+'"]').val($('#current_field_label').val());
|
||||
$('input[name="src_'+field_id+'"]').trigger('change');
|
||||
$('.metafield_'+field_id).removeAttr('disabled');
|
||||
};
|
||||
$('#field_changer').dialog({
|
||||
modal:true,
|
||||
buttons : buttons
|
||||
}).dialog('close');
|
||||
|
||||
$('a.field_change').bind('click', function(){
|
||||
$('#field_chooser').val('');
|
||||
var field_id = $('input',this).val();
|
||||
$('#current_field_label').val( $('input[name="src_'+field_id+'"]').val());
|
||||
$('input[name="field_id"]', dialog).val(field_id);
|
||||
dialog.dialog().dialog('open');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.alertTips').tooltip();
|
||||
|
||||
$('button.struct_saver').bind('click', function(){
|
||||
$('#form_struct').submit();
|
||||
});
|
||||
|
||||
var buttons = {};
|
||||
var dialog_adder = $('#field_adder');
|
||||
buttons['{% trans 'boutton::annuler' %}'] = function(){
|
||||
$('#field_adder').dialog('close');
|
||||
};
|
||||
buttons['{% trans 'boutton::valider' %}'] = function(){
|
||||
$('#newfield').val($('#field_adder input[name="newfield_name"]').val());
|
||||
$('#field_adder').dialog('close');
|
||||
$('#form_struct').submit();
|
||||
};
|
||||
$('#field_adder').dialog({
|
||||
modal:true,
|
||||
buttons : buttons
|
||||
}).dialog('close');
|
||||
|
||||
$('.field_adder').bind('click', function(){
|
||||
dialog_adder.dialog().dialog('open');
|
||||
});
|
||||
|
||||
$('.meta_deleter').bind('click', function(){
|
||||
if(confirm('{% trans 'Etes vous sur de vouloir supprimer cette metadonnee ? Elle sera definitivement perdue' %}'))
|
||||
{
|
||||
var field = $('input[name="field_ids[]"]', $(this).parent());
|
||||
var field_id = $('input', $(this)).val();
|
||||
field.attr('name', 'todelete_ids[]');
|
||||
$('.metafield_'+field_id).attr('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('.dces_selector').bind('change', function(event){
|
||||
if($.trim($(this).val()) === '') {
|
||||
return;
|
||||
}
|
||||
var $this = $(this);
|
||||
var $others = $('.dces_selector option[value="'+$this.val()+'"]:selected');
|
||||
if($others.length > 1)
|
||||
{
|
||||
var other_name = $($others.get(0)).closest('tr').find('input.meta_namer').val();
|
||||
|
||||
$('#warning_dialog').html("<p>{% trans 'Attention, deux champs ne peuvent représenter le meme element Dublin Core.' %}<br/><br/>{% trans 'La precedente attribution a ete desactivee' %} </p><p style='margin-top:10px;text-align:center;font-weight:bold;'>"+other_name+'</p>').dialog({modal:true});
|
||||
$others.each(function(i, el){
|
||||
var $parent = $(el).parent();
|
||||
if($parent.attr('name') !== $this.attr('name'))
|
||||
$parent.val('');
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('.meta_multi, .meta_src').bind('change', function(){
|
||||
var id = $(this).attr('name').split('_').pop();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin/fields/checkmulti/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
multi : $('input[name="multi_'+id+'"]').attr('checked'),
|
||||
source : $('input[name="src_'+id+'"]').val()
|
||||
},
|
||||
error: function(){
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
return;
|
||||
},
|
||||
success: function(data){
|
||||
var $parent = $('input[name="multi_'+id+'"]').parent();
|
||||
$('.alert', $parent).hide();
|
||||
if(data.result === false && data.is_multi === true)
|
||||
$('.alert_is_multi', $parent).show();
|
||||
else if(data.result === false && data.is_multi === false)
|
||||
$('.alert_not_multi', $parent).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('.meta_readonly, .meta_src').bind('change', function(){
|
||||
var id = $(this).attr('name').split('_').pop();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin/fields/checkreadonly/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
readonly : $('input[name="readonly_'+id+'"]').attr('checked'),
|
||||
source : $('input[name="src_'+id+'"]').val()
|
||||
},
|
||||
error: function(){
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
return;
|
||||
},
|
||||
success: function(data){
|
||||
var $parent = $('input[name="readonly_'+id+'"]').parent();
|
||||
$('.alert', $parent).hide();
|
||||
if(data.result === false && data.is_readonly === true)
|
||||
$('.alert_is_readonly', $parent).show();
|
||||
else if(data.result === false && data.is_readonly === false)
|
||||
$('.alert_not_readonly', $parent).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body style="overflow-x:scroll;">
|
||||
<div id="warning_dialog" style="display:none" title="{% trans 'Attention !' %}" >
|
||||
</div>
|
||||
<div style="display:none" id="field_changer">
|
||||
@@ -227,8 +30,21 @@
|
||||
<button id="tag_remover">{% trans 'Delete' %}</button>
|
||||
<input name="field_id" type="hidden" value=""/>
|
||||
</div>
|
||||
<div style="display:none" id="field_adder">
|
||||
<input name="newfield_name" type="text"/>
|
||||
<div style="display:none" id="field_adder" title="{% trans 'Add a field' %}">
|
||||
<div>
|
||||
<label for="input_new_field_name">
|
||||
<input name="newfield_name" type="text" id="input_new_field_name"/>
|
||||
{% trans 'New field name' %}
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="checkbox" for="input_new_field_multi">
|
||||
<input type="checkbox" name="newfield_multi" value="1" type="text" id="input_new_field_multi"/>
|
||||
{% trans 'This field is multi-valued' %} *
|
||||
</label>
|
||||
</div>
|
||||
<br/>
|
||||
<blockquote>* {% trans 'This can not be changed' %}</blockquote>
|
||||
</div>
|
||||
<div>
|
||||
<button class="field_adder">
|
||||
@@ -238,6 +54,7 @@
|
||||
</div>
|
||||
<form action="/admin/description/{{ databox.get_sbas_id() }}/" method="post" target="_self" id="form_struct">
|
||||
<input name="newfield" id="newfield" type="hidden" />
|
||||
<input name="newfield_multi" id="newfield_multi" type="hidden" />
|
||||
<table class="admintable">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -283,10 +100,10 @@
|
||||
<td>
|
||||
{{ _self.dces_selector(available_dc_fields, field) }}
|
||||
</td>
|
||||
<td>
|
||||
<input class="meta_multi metafield_{{ field.get_id() }}" {{ disabled }} name="multi_{{ field.get_id() }}" type="checkbox" {% if field.is_multi() %}checked="checked"{% endif %}/>
|
||||
<img class="alert alertTips alert_not_multi" src="/skins/icons/alert.png" title="{% trans 'Attention, la source descriptive selectionne n\'est pas multivaluee, vous devriez decocher cette case' %}" style="display:none;" />
|
||||
<img class="alert alertTips alert_is_multi" src="/skins/icons/alert.png" title="{% trans 'Attention, la source descriptive selectionne est multivaluee, vous devriez cocher cette case' %}" style="display:none;" />
|
||||
<td style="text-align:center;" class="multi_{{ field.get_id() }}">
|
||||
{% if field.is_multi() %}<img src="/skins/icons/ok.png"/>{% endif %}
|
||||
<img class="alert alertTips alert_not_multi" src="/skins/icons/alert.png" title="{% trans 'Attention, la source descriptive selectionne n\'est pas multivaluee' %}" style="display:none;" />
|
||||
<img class="alert alertTips alert_is_multi" src="/skins/icons/alert.png" title="{% trans 'Attention, la source descriptive selectionne est multivaluee' %}" style="display:none;" />
|
||||
</td>
|
||||
<td>
|
||||
<input class="metafield_{{ field.get_id() }}" {{ disabled }} name="indexable_{{ field.get_id() }}" type="checkbox" {% if field.is_indexable() %}checked="checked"{% endif %}/>
|
||||
@@ -346,5 +163,232 @@
|
||||
</table>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
<style>
|
||||
body{
|
||||
font-size:12px;
|
||||
}
|
||||
.ui-autocomplete {
|
||||
max-height: 200px;
|
||||
max-width: 400px;
|
||||
overflow-y: auto;
|
||||
/* prevent horizontal scrollbar */
|
||||
overflow-x: hidden;
|
||||
/* add padding to account for vertical scrollbar */
|
||||
padding-right: 20px;
|
||||
}
|
||||
/** IE 6 doesn't support max-height
|
||||
* we use height instead, but this forces the menu to always be this tall
|
||||
*/
|
||||
* html .ui-autocomplete {
|
||||
height: 200px;
|
||||
}
|
||||
.ui-autocomplete-loading { background: white url('/skins/icons/ui-anim_basic_16x16.gif') right center no-repeat; }
|
||||
.alertTips{
|
||||
cursor:help;
|
||||
}
|
||||
.alert{
|
||||
vertical-align: baseline;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
var container = $('#right-ajax');
|
||||
|
||||
$('#form_struct').bind('submit', function(){
|
||||
|
||||
var $this = $(this),
|
||||
datas = $this.serializeArray(),
|
||||
method = $this.attr('method') ? $this.attr('method') : 'GET',
|
||||
url = $this.attr('action');
|
||||
|
||||
container.empty().addClass('loading');
|
||||
|
||||
$.ajax({
|
||||
type: method,
|
||||
url: url,
|
||||
dataType: 'html',
|
||||
data: datas,
|
||||
error: function(){
|
||||
container.removeClass('loading');
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
container.removeClass('loading');
|
||||
return;
|
||||
},
|
||||
success: function(data){
|
||||
container.removeClass('loading').empty().append(data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#field_chooser").autocomplete({
|
||||
source: "/admin/description/metadatas/search/",
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
$('#current_field_label').val(ui.item.value);
|
||||
}
|
||||
});
|
||||
|
||||
var buttons = {};
|
||||
var dialog = $('#field_changer');
|
||||
buttons['{% trans 'boutton::annuler' %}'] = function(){
|
||||
$('#field_changer').dialog('close');
|
||||
};
|
||||
|
||||
$('#tag_remover').bind('click', function(){
|
||||
$('#current_field_label').val('');
|
||||
});
|
||||
|
||||
buttons['{% trans 'boutton::valider' %}'] = function(){
|
||||
var field_id = $('input[name="field_id"]', dialog).val();
|
||||
$('#field_changer').dialog('close');
|
||||
|
||||
$('#display_value_'+field_id).empty().append($('#current_field_label').val());
|
||||
$('input[name="src_'+field_id+'"]', container).val($('#current_field_label').val());
|
||||
$('input[name="src_'+field_id+'"]', container).trigger('change');
|
||||
$('.metafield_'+field_id, container).removeAttr('disabled');
|
||||
};
|
||||
$('#field_changer').dialog({
|
||||
modal:true,
|
||||
buttons : buttons,
|
||||
draggable:false,
|
||||
resizable:false
|
||||
}).dialog('close');
|
||||
|
||||
$('a.field_change', container).bind('click', function(){
|
||||
$('#field_chooser').val('');
|
||||
var field_id = $('input',this).val();
|
||||
$('#current_field_label').val( $('input[name="src_'+field_id+'"]', container).val());
|
||||
$('input[name="field_id"]', dialog).val(field_id);
|
||||
dialog.dialog().dialog('open');
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.alertTips', container).tooltip();
|
||||
|
||||
$('button.struct_saver', container).bind('click', function(){
|
||||
$('#form_struct').submit();
|
||||
});
|
||||
|
||||
|
||||
$('.field_adder', container).bind('click', function(){
|
||||
|
||||
|
||||
var buttons = {};
|
||||
|
||||
buttons['{% trans 'boutton::annuler' %}'] = function(){
|
||||
$('#field_adder').dialog('destroy').remove();
|
||||
};
|
||||
buttons['{% trans 'boutton::valider' %}'] = function(){
|
||||
$('#newfield').val($('#field_adder input[name="newfield_name"]').val());
|
||||
$('#newfield_multi').val($('#field_adder input[name="newfield_multi"]').attr('checked') ? 1 : 0);
|
||||
$('#field_adder').dialog('destroy').remove();
|
||||
$('#form_struct').submit();
|
||||
};
|
||||
|
||||
$('#field_adder').dialog({
|
||||
modal:true,
|
||||
buttons : buttons,
|
||||
draggable:false,
|
||||
resizable:false,
|
||||
width:400
|
||||
}).dialog('open');
|
||||
|
||||
});
|
||||
|
||||
$('.meta_deleter', container).bind('click', function(){
|
||||
if(confirm('{% trans 'Etes vous sur de vouloir supprimer cette metadonnee ? Elle sera definitivement perdue' %}'))
|
||||
{
|
||||
var field = $('input[name="field_ids[]"]', $(this).parent());
|
||||
var field_id = $('input', $(this)).val();
|
||||
field.attr('name', 'todelete_ids[]');
|
||||
$('.metafield_'+field_id, container).attr('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('.dces_selector', container).bind('change', function(event){
|
||||
if($.trim($(this).val()) === '') {
|
||||
return;
|
||||
}
|
||||
var $this = $(this);
|
||||
var $others = $('.dces_selector option[value="'+$this.val()+'"]:selected', container);
|
||||
if($others.length > 1)
|
||||
{
|
||||
var other_name = $($others.get(0)).closest('tr').find('input.meta_namer').val();
|
||||
|
||||
$('#warning_dialog').html("<p>{% trans 'Attention, deux champs ne peuvent représenter le meme element Dublin Core.' %}<br/><br/>{% trans 'La precedente attribution a ete desactivee' %} </p><p style='margin-top:10px;text-align:center;font-weight:bold;'>"+other_name+'</p>').dialog({modal:true});
|
||||
$others.each(function(i, el){
|
||||
var $parent = $(el).parent();
|
||||
if($parent.attr('name') !== $this.attr('name'))
|
||||
$parent.val('');
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('.meta_src', container).bind('change', function(){
|
||||
var id = $(this).attr('name').split('_').pop();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin/fields/checkmulti/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
multi : $('input[name="multi_'+id+'"]', container).attr('checked'),
|
||||
source : $('input[name="src_'+id+'"]', container).val()
|
||||
},
|
||||
error: function(){
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
return;
|
||||
},
|
||||
success: function(data){
|
||||
var $parent = $('.multi_'+id, container);
|
||||
$('.alert', $parent).hide();
|
||||
if(data.result === false && data.is_multi === true)
|
||||
$('.alert_is_multi', $parent).show();
|
||||
else if(data.result === false && data.is_multi === false)
|
||||
$('.alert_not_multi', $parent).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$('.meta_readonly, .meta_src', container).bind('change', function(){
|
||||
var id = $(this).attr('name').split('_').pop();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/admin/fields/checkreadonly/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
readonly : $('input[name="readonly_'+id+'"]', container).attr('checked'),
|
||||
source : $('input[name="src_'+id+'"]', container).val()
|
||||
},
|
||||
error: function(){
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
return;
|
||||
},
|
||||
success: function(data){
|
||||
var $parent = $('input[name="readonly_'+id+'"]', container).parent();
|
||||
$('.alert', $parent).hide();
|
||||
if(data.result === false && data.is_readonly === true)
|
||||
$('.alert_is_readonly', $parent).show();
|
||||
else if(data.result === false && data.is_readonly === false)
|
||||
$('.alert_not_readonly', $parent).show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
@@ -113,7 +113,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a target="right" href="/admin/description/{{ sbas_id }}/">
|
||||
<a target="right" href="/admin/description/{{ sbas_id }}/" class="ajax">
|
||||
<img src="/skins/icons/miniadjust01.gif"/>
|
||||
{% trans 'CHAMPS' %}
|
||||
</a>
|
||||
|
@@ -9,10 +9,10 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
|
||||
|
||||
|
||||
$app['debug'] = true;
|
||||
unset($app['exception_handler']);
|
||||
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$name = "testtest" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array($id)
|
||||
@@ -53,7 +53,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$name = "test" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
|
||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||
@@ -111,7 +111,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||
|
||||
$name = "test" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array($id)
|
||||
@@ -129,7 +129,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$field->delete();
|
||||
|
||||
$name = "test" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array($id)
|
||||
@@ -146,8 +146,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$field->delete();
|
||||
|
||||
$name = "test" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field->set_multi(false);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$field->set_indexable(false);
|
||||
$field->set_required(true);
|
||||
$field->set_readonly(true);
|
||||
@@ -173,7 +172,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
|
||||
$name = "test" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array('unknow_id')
|
||||
@@ -201,7 +200,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$databox = array_shift($appbox->get_databoxes());
|
||||
$name = "test" . uniqid();
|
||||
$field = \databox_field::create($databox, $name);
|
||||
$field = \databox_field::create($databox, $name, false);
|
||||
$id = $field->get_id();
|
||||
$this->client->request("POST", "/description/" . $databox->get_sbas_id() . "/", array(
|
||||
'field_ids' => array($id)
|
||||
@@ -253,7 +252,7 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$datas = json_decode($this->client->getResponse()->getContent(), true);
|
||||
$this->assertEquals(array(), $datas);
|
||||
|
||||
|
||||
$this->client->request("GET", "/description/metadatas/search/", array('term'=>'xmp'));
|
||||
$this->assertTrue($this->client->getResponse()->isOk());
|
||||
|
||||
|
@@ -9,10 +9,10 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
|
||||
|
||||
|
||||
$app['debug'] = true;
|
||||
unset($app['exception_handler']);
|
||||
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName();
|
||||
|
||||
$field = \databox_field::create($databox, "test" . time());
|
||||
$field = \databox_field::create($databox, "test" . time(), false);
|
||||
$field->set_tag($tag)->save();
|
||||
|
||||
$this->client->request("GET", "/fields/checkmulti/", array(
|
||||
@@ -54,7 +54,7 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$tag = new PHPExiftool\Driver\Tag\IPTC\ObjectName();
|
||||
|
||||
$field = \databox_field::create($databox, "test" . time());
|
||||
$field = \databox_field::create($databox, "test" . time(), false);
|
||||
$field->set_tag($tag)->save();
|
||||
|
||||
$this->client->request("GET", "/fields/checkreadonly/", array(
|
||||
|
@@ -24,11 +24,11 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
||||
|
||||
$this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
|
||||
|
||||
if ( ! $this->object_mono instanceof databox_field)
|
||||
$this->object_mono = databox_field::create($this->databox, $this->name_mono);
|
||||
if ( ! $this->object_mono instanceof databox_field) {
|
||||
$this->object_mono = databox_field::create($this->databox, $this->name_mono, false);
|
||||
}
|
||||
if ( ! $this->object_multi instanceof databox_field) {
|
||||
$this->object_multi = databox_field::create($this->databox, $this->name_multi);
|
||||
$this->object_multi->set_multi(true)->save();
|
||||
$this->object_multi = databox_field::create($this->databox, $this->name_multi, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,14 +217,6 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
||||
$this->assertTrue($this->object_mono->isBusiness());
|
||||
}
|
||||
|
||||
public function testSet_multi()
|
||||
{
|
||||
$this->object_mono->set_multi(false);
|
||||
$this->assertFalse($this->object_mono->is_multi());
|
||||
$this->object_mono->set_multi(true);
|
||||
$this->assertTrue($this->object_mono->is_multi());
|
||||
}
|
||||
|
||||
public function testSet_report()
|
||||
{
|
||||
$this->object_mono->set_report(false);
|
||||
@@ -364,105 +356,4 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
||||
$this->assertEquals($value->getValue(), $AddedValue);
|
||||
}
|
||||
|
||||
public function testChangeMulti()
|
||||
{
|
||||
$AddedValue_1 = 'scalar value 1';
|
||||
$AddedValue_2 = 'scalar value 2';
|
||||
|
||||
static::$records['record_1']->set_metadatas(array(
|
||||
array(
|
||||
'meta_id' => null,
|
||||
'meta_struct_id' => $this->object_multi->get_id(),
|
||||
'value' => $AddedValue_1
|
||||
),
|
||||
array(
|
||||
'meta_id' => null,
|
||||
'meta_struct_id' => $this->object_multi->get_id(),
|
||||
'value' => $AddedValue_2
|
||||
)
|
||||
));
|
||||
|
||||
$this->assertEquals(2, count(static::$records['record_1']->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
|
||||
|
||||
$this->object_multi->set_multi(false)->save();
|
||||
|
||||
$this->assertEquals(1, count(static::$records['record_1']->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testCreate().
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement test__sleep().
|
||||
*/
|
||||
public function test__sleep()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement test__wakeup().
|
||||
*/
|
||||
public function test__wakeup()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testGet_cache_key().
|
||||
*/
|
||||
public function testGet_cache_key()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testGet_data_from_cache().
|
||||
*/
|
||||
public function testGet_data_from_cache()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testSet_data_to_cache().
|
||||
*/
|
||||
public function testSet_data_to_cache()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement testDelete_data_from_cache().
|
||||
*/
|
||||
public function testDelete_data_from_cache()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user