Contacts: support multiple phone type parameter
This commit is contained in:
parent
ad390d5e42
commit
a2ecdfcac1
|
@ -70,6 +70,9 @@ $vcard->children[$line]->setValue($value);
|
|||
|
||||
// Add parameters
|
||||
$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array();
|
||||
if ($vcard->children[$line]->name == 'TEL' && !array_key_exists('TYPE', $postparameters)){
|
||||
$postparameters['TYPE']='';
|
||||
}
|
||||
for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
|
||||
$name = $vcard->children[$line]->parameters[$i]->name;
|
||||
if(array_key_exists($name,$postparameters)){
|
||||
|
@ -77,7 +80,14 @@ for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
|
|||
unset($vcard->children[$line]->parameters[$i]);
|
||||
}
|
||||
else{
|
||||
$vcard->children[$line]->parameters[$i]->value = $postparameters[$name];
|
||||
unset($vcard->children[$line][$name]);
|
||||
$values = $postparameters[$name];
|
||||
if (!is_array($values)){
|
||||
$values = array($values);
|
||||
}
|
||||
foreach($values as $value){
|
||||
$vcard->children[$line]->add($name, $value);
|
||||
}
|
||||
}
|
||||
unset($postparameters[$name]);
|
||||
}
|
||||
|
|
|
@ -94,16 +94,14 @@ This stylesheet forms part of the Formtastic Rails Plugin
|
|||
/* INPUTS
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
.formtastic .inputs {
|
||||
overflow:hidden; /* clear containing floats */
|
||||
}
|
||||
|
||||
.formtastic .input {
|
||||
overflow:hidden; /* clear containing floats */
|
||||
padding:0.5em 0; /* padding and negative margin juggling is for Firefox */
|
||||
margin-top:-0.5em;
|
||||
margin-bottom:1em;
|
||||
}
|
||||
|
||||
.formtastic .input {
|
||||
}
|
||||
|
||||
|
||||
/* LEFT ALIGNED LABELS
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
|
|
@ -3,16 +3,21 @@
|
|||
|
||||
#contacts_deletecard {position:absolute;top:15px;right:0;}
|
||||
#contacts_details_list { list-style:none; }
|
||||
#contacts_details_list li { overflow:hidden; }
|
||||
#contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; }
|
||||
#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%; overflow:hidden; }
|
||||
#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; }
|
||||
#contacts_addproperty_button, #contacts_setproperty_button { margin-left:25%; }
|
||||
|
||||
.contacts_property_data ul, .contacts_property_data ol { list-style:none; }
|
||||
.contacts_property_data ul, ol.contacts_property_data { list-style:none; }
|
||||
.contacts_property_data li { overflow: hidden; }
|
||||
.contacts_property_data li label { width:20%; float:left; text-align:right;padding-right:0.3em; }
|
||||
.contacts_property_data input { float:left; }
|
||||
.contacts_property_data li input { width:70%;overflow:hidden; }
|
||||
|
||||
.chzn-container { margin:3px 0 0; }
|
||||
.chzn-container .chzn-choices { border-radius: 0.5em; }
|
||||
.chzn-container.chzn-container-active .chzn-choices { border-bottom-left-radius: 0;border-bottom-right-radius: 0; }
|
||||
.chzn-container .chzn-drop { border-bottom-left-radius: 0.5em;border-bottom-right-radius: 0.5em; }
|
||||
|
||||
/* Form setup ----------------------------------------------------------------*/
|
||||
/* .forme {} */
|
||||
/* .forme ul, .forme ol { list-style:none; } */
|
||||
|
|
|
@ -82,7 +82,8 @@ $(document).ready(function(){
|
|||
$.getJSON('ajax/showaddcard.php',{},function(jsondata){
|
||||
if(jsondata.status == 'success'){
|
||||
$('#rightcontent').data('id','');
|
||||
$('#rightcontent').html(jsondata.data.page);
|
||||
$('#rightcontent').html(jsondata.data.page)
|
||||
.find('select').chosen();
|
||||
}
|
||||
else{
|
||||
alert(jsondata.data.message);
|
||||
|
@ -111,7 +112,8 @@ $(document).ready(function(){
|
|||
var checksum = $(this).parents('li').first().data('checksum');
|
||||
$.getJSON('ajax/showsetproperty.php',{'id': id, 'checksum': checksum },function(jsondata){
|
||||
if(jsondata.status == 'success'){
|
||||
$('.contacts_property[data-checksum="'+checksum+'"]').html(jsondata.data.page);
|
||||
$('.contacts_property[data-checksum="'+checksum+'"]').html(jsondata.data.page)
|
||||
.find('select').chosen();
|
||||
}
|
||||
else{
|
||||
alert(jsondata.data.message);
|
||||
|
@ -148,10 +150,12 @@ $(document).ready(function(){
|
|||
|
||||
|
||||
$('.contacts_property').live('mouseenter',function(){
|
||||
$(this).find('span').show();
|
||||
$(this).find('span[data-use]').show();
|
||||
});
|
||||
|
||||
$('.contacts_property').live('mouseleave',function(){
|
||||
$(this).find('span').hide();
|
||||
$(this).find('span[data-use]').hide();
|
||||
});
|
||||
|
||||
$('#contacts_addcardform select').chosen();
|
||||
});
|
||||
|
|
|
@ -296,7 +296,13 @@ class OC_Contacts_VCard{
|
|||
$property = new Sabre_VObject_Property( $name, $value );
|
||||
$parameternames = array_keys($parameters);
|
||||
foreach($parameternames as $i){
|
||||
$property->parameters[] = new Sabre_VObject_Parameter($i,$parameters[$i]);
|
||||
$values = $parameters[$i];
|
||||
if (!is_array($values)){
|
||||
$values = array($values);
|
||||
}
|
||||
foreach($values as $value){
|
||||
$property->add($i, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$vcard->add($property);
|
||||
|
@ -352,7 +358,17 @@ class OC_Contacts_VCard{
|
|||
$parameter->name = 'PREF';
|
||||
$parameter->value = '1';
|
||||
}
|
||||
$temp['parameters'][$parameter->name] = $parameter->value;
|
||||
if ($property->name == 'TEL' && $parameter->name == 'TYPE'){
|
||||
if (isset($temp['parameters'][$parameter->name])){
|
||||
$temp['parameters'][$parameter->name][] = $parameter->value;
|
||||
}
|
||||
else{
|
||||
$temp['parameters'][$parameter->name] = array($parameter->value);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$temp['parameters'][$parameter->name] = $parameter->value;
|
||||
}
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</li>
|
||||
<li class="fragment">
|
||||
<label for="tel_type"><?php echo $l->t('Type'); ?></label>
|
||||
<select id="TEL" name="parameters[TEL][TYPE]" size="1">
|
||||
<select id="TEL" name="parameters[TEL][TYPE][]" multiple="multiple">
|
||||
<?php echo html_select_options($_['phone_types'], 'CELL') ?>
|
||||
</select>
|
||||
</li>
|
||||
|
|
|
@ -23,15 +23,18 @@
|
|||
<p class="contacts_property_name"><?php echo $l->t('Phone'); ?></p>
|
||||
<p class="contacts_property_data">
|
||||
<?php echo $_['property']['value']; ?>
|
||||
<?php if(isset($_['property']['parameters']['TYPE'])): ?>
|
||||
<?php if(isset($_['property']['parameters']['TYPE']) && !empty($_['property']['parameters']['TYPE'])): ?>
|
||||
<?php
|
||||
$type = $_['property']['parameters']['TYPE'];
|
||||
if (isset($_['phone_types'][strtoupper($type)])){
|
||||
$label=$_['phone_types'][strtoupper($type)];
|
||||
}
|
||||
else{
|
||||
$label=$l->t(ucwords(strtolower($type)));
|
||||
}
|
||||
$types = array();
|
||||
foreach($_['property']['parameters']['TYPE'] as $type):
|
||||
if (isset($_['phone_types'][strtoupper($type)])){
|
||||
$types[]=$_['phone_types'][strtoupper($type)];
|
||||
}
|
||||
else{
|
||||
$types[]=$l->t(ucwords(strtolower($type)));
|
||||
}
|
||||
endforeach;
|
||||
$label = join(' ', $types);
|
||||
?>
|
||||
(<?php echo $label; ?>)
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
</ol>
|
||||
<?php elseif($_['property']['name']=='TEL'): ?>
|
||||
<p class="contacts_property_name"><label for="tel"><?php echo $l->t('Phone'); ?></label></p>
|
||||
<p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo $_['property']['value']; ?>">
|
||||
<select id="tel_type" name="parameters[TYPE]" size="1">
|
||||
<?php echo html_select_options($_['phone_types'], strtoupper($_['property']['parameters']['TYPE'])) ?>
|
||||
<p class="contacts_property_data"><input id="tel" type="phone" name="value" value="<?php echo $_['property']['value'] ?>">
|
||||
<select id="tel_type<?php echo $_['property']['checksum'] ?>" name="parameters[TYPE][]" multiple="multiple">
|
||||
<?php echo html_select_options($_['phone_types'], ($_['property']['parameters']['TYPE'])) ?>
|
||||
</select></p>
|
||||
<?php elseif($_['property']['name']=='EMAIL'): ?>
|
||||
<p class="contacts_property_name"><label for="email"><?php echo $l->t('Email'); ?></label></p>
|
||||
|
|
Loading…
Reference in New Issue