Date: Sat, 5 Nov 2011 20:33:42 +0100
Subject: [PATCH 04/10] Use a function to generate select options
---
ajax/getdetails.php | 12 ++++++++++++
ajax/showaddcard.php | 5 +++++
ajax/showsetproperty.php | 2 ++
lib/vcard.php | 20 ++++++++++++++++++++
templates/part.addcardform.php | 16 +++-------------
templates/part.details.php | 17 +++--------------
templates/part.setpropertyform.php | 6 ++++++
7 files changed, 51 insertions(+), 27 deletions(-)
diff --git a/ajax/getdetails.php b/ajax/getdetails.php
index 0e76de61..260fb53a 100644
--- a/ajax/getdetails.php
+++ b/ajax/getdetails.php
@@ -51,10 +51,22 @@ if(is_null($vcard)){
exit();
}
+$property_types = array(
+ 'ADR' => $l10n->t('Address'),
+ 'TEL' => $l10n->t('Telephone'),
+ 'EMAIL' => $l10n->t('Email'),
+ 'ORG' => $l10n->t('Organization'),
+);
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$details = OC_Contacts_VCard::structureContact($vcard);
$tmpl = new OC_Template('contacts','part.details');
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
+$tmpl->assign('property_types',$property_types);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/ajax/showaddcard.php b/ajax/showaddcard.php
index 2f534f0f..98367758 100644
--- a/ajax/showaddcard.php
+++ b/ajax/showaddcard.php
@@ -29,9 +29,14 @@ $l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
$tmpl->assign('addressbooks',$addressbooks);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/ajax/showsetproperty.php b/ajax/showsetproperty.php
index 6188f477..4ec3dd7d 100644
--- a/ajax/showsetproperty.php
+++ b/ajax/showsetproperty.php
@@ -61,11 +61,13 @@ if(is_null($line)){
exit();
}
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
$tmpl = new OC_Template('contacts','part.setpropertyform');
$tmpl->assign('id',$id);
$tmpl->assign('checksum',$checksum);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line]));
+$tmpl->assign('adr_types',$adr_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/lib/vcard.php b/lib/vcard.php
index a6795c79..56602f25 100644
--- a/lib/vcard.php
+++ b/lib/vcard.php
@@ -372,4 +372,24 @@ class OC_Contacts_VCard{
return null;
}
}
+ public static function getTypesOfProperty($l, $prop){
+ switch($prop){
+ case 'ADR':
+ return array(
+ 'WORK' => $l->t('Work'),
+ 'HOME' => $l->t('Home'),
+ );
+ case 'TEL':
+ return array(
+ 'HOME' => $l->t('Home'),
+ 'CELL' => $l->t('Mobile'),
+ 'WORK' => $l->t('Work'),
+ 'TEXT' => $l->t('Text'),
+ 'VOICE' => $l->t('Voice'),
+ 'FAX' => $l->t('Fax'),
+ 'VIDEO' => $l->t('Video'),
+ 'PAGER' => $l->t('Pager'),
+ );
+ }
+ }
}
diff --git a/templates/part.addcardform.php b/templates/part.addcardform.php
index a596ad81..037e3629 100644
--- a/templates/part.addcardform.php
+++ b/templates/part.addcardform.php
@@ -7,9 +7,7 @@
@@ -46,14 +44,7 @@
@@ -67,8 +58,7 @@
diff --git a/templates/part.details.php b/templates/part.details.php
index 212be283..f5bd7580 100644
--- a/templates/part.details.php
+++ b/templates/part.details.php
@@ -27,10 +27,7 @@
@@ -44,8 +41,7 @@
@@ -80,14 +76,7 @@
diff --git a/templates/part.setpropertyform.php b/templates/part.setpropertyform.php
index eb8a67a8..811b9626 100644
--- a/templates/part.setpropertyform.php
+++ b/templates/part.setpropertyform.php
@@ -5,6 +5,12 @@
+ -
+
+
+
-
From 3abb1a1285d7d0f51fc88cbd9af06e7f90b40a7b Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Thu, 17 Nov 2011 23:54:14 +0100
Subject: [PATCH 05/10] Add type selects to editing ADR & TEL contact property
types
---
ajax/addcard.php | 5 +++++
ajax/setproperty.php | 5 +++++
ajax/showsetproperty.php | 2 ++
index.php | 6 ++++++
templates/part.property.php | 22 ++++++++++++++++++++--
templates/part.setpropertyform.php | 5 ++++-
6 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/ajax/addcard.php b/ajax/addcard.php
index 0cecd3bd..dd5b9065 100644
--- a/ajax/addcard.php
+++ b/ajax/addcard.php
@@ -68,11 +68,16 @@ foreach( $add as $propname){
}
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$details = OC_Contacts_VCard::structureContact($vcard);
$name = $details['FN'][0]['value'];
$tmpl = new OC_Template('contacts','part.details');
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));
diff --git a/ajax/setproperty.php b/ajax/setproperty.php
index 18e00872..9164f869 100644
--- a/ajax/setproperty.php
+++ b/ajax/setproperty.php
@@ -94,7 +94,12 @@ $checksum = md5($vcard->children[$line]->serialize());
OC_Contacts_VCard::edit($id,$vcard->serialize());
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$tmpl = new OC_Template('contacts','part.property');
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line));
$page = $tmpl->fetchPage();
diff --git a/ajax/showsetproperty.php b/ajax/showsetproperty.php
index 4ec3dd7d..2ec4b89b 100644
--- a/ajax/showsetproperty.php
+++ b/ajax/showsetproperty.php
@@ -62,12 +62,14 @@ if(is_null($line)){
}
$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
$tmpl = new OC_Template('contacts','part.setpropertyform');
$tmpl->assign('id',$id);
$tmpl->assign('checksum',$checksum);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line]));
$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/index.php b/index.php
index 7e93d618..29d41d3c 100644
--- a/index.php
+++ b/index.php
@@ -75,8 +75,14 @@ if( !is_null($id) || count($contacts)){
$details = OC_Contacts_VCard::structureContact($vcard);
}
+$l10n = new OC_L10N('contacts');
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
// Process the template
$tmpl = new OC_Template( 'contacts', 'index', 'user' );
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('addressbooks', $addressbooks);
$tmpl->assign('contacts', $contacts);
$tmpl->assign('details', $details );
diff --git a/templates/part.property.php b/templates/part.property.php
index 4bc3a4d8..dbd125dc 100644
--- a/templates/part.property.php
+++ b/templates/part.property.php
@@ -24,7 +24,16 @@
- (t(ucwords(str_replace('cell','mobile',strtolower($_['property']['parameters']['TYPE'])))); ?>)
+t(ucwords(strtolower($type)));
+ }
+?>
+ ()
@@ -34,7 +43,16 @@
t('Address'); ?>
- (t(ucwords($_['property']['parameters']['TYPE'])); ?>)
+t(ucwords(strtolower($type)));
+ }
+?>
+ ()
diff --git a/templates/part.setpropertyform.php b/templates/part.setpropertyform.php
index 811b9626..9340ce7c 100644
--- a/templates/part.setpropertyform.php
+++ b/templates/part.setpropertyform.php
@@ -42,7 +42,10 @@
-
+
+
From 5372e61d348b84b606c59875a99003c91c08d622 Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Wed, 23 Nov 2011 21:06:51 +0100
Subject: [PATCH 06/10] Contacts: support multiple phone type parameter
---
ajax/setproperty.php | 12 +++++++++++-
css/formtastic.css | 8 +++-----
css/styles.css | 11 ++++++++---
js/interface.js | 12 ++++++++----
lib/vcard.php | 20 ++++++++++++++++++--
templates/part.addcardform.php | 2 +-
templates/part.property.php | 19 +++++++++++--------
templates/part.setpropertyform.php | 6 +++---
8 files changed, 63 insertions(+), 27 deletions(-)
diff --git a/ajax/setproperty.php b/ajax/setproperty.php
index 9164f869..c9102c4a 100644
--- a/ajax/setproperty.php
+++ b/ajax/setproperty.php
@@ -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;$ichildren[$line]->parameters);$i++){
$name = $vcard->children[$line]->parameters[$i]->name;
if(array_key_exists($name,$postparameters)){
@@ -77,7 +80,14 @@ for($i=0;$ichildren[$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]);
}
diff --git a/css/formtastic.css b/css/formtastic.css
index 629c2207..fede92b6 100644
--- a/css/formtastic.css
+++ b/css/formtastic.css
@@ -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
--------------------------------------------------------------------------------------------------*/
diff --git a/css/styles.css b/css/styles.css
index ad64c777..e226c48a 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -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; } */
diff --git a/js/interface.js b/js/interface.js
index 1cc3a5df..24b512e5 100644
--- a/js/interface.js
+++ b/js/interface.js
@@ -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();
});
diff --git a/lib/vcard.php b/lib/vcard.php
index 56602f25..4865fae7 100644
--- a/lib/vcard.php
+++ b/lib/vcard.php
@@ -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;
}
diff --git a/templates/part.addcardform.php b/templates/part.addcardform.php
index 037e3629..62705354 100644
--- a/templates/part.addcardform.php
+++ b/templates/part.addcardform.php
@@ -43,7 +43,7 @@
-
diff --git a/templates/part.property.php b/templates/part.property.php
index dbd125dc..afef4311 100644
--- a/templates/part.property.php
+++ b/templates/part.property.php
@@ -23,15 +23,18 @@
t('Phone'); ?>
-
+
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);
?>
()
diff --git a/templates/part.setpropertyform.php b/templates/part.setpropertyform.php
index 9340ce7c..bd18d86b 100644
--- a/templates/part.setpropertyform.php
+++ b/templates/part.setpropertyform.php
@@ -42,9 +42,9 @@
-
-
-
+
+
+
From f076db00dc3bb919b8762e37f165db8ec7bbfd09 Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Wed, 23 Nov 2011 21:07:26 +0100
Subject: [PATCH 07/10] Contacts: remove redundant li in setpropertyform
template
---
templates/part.setpropertyform.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/templates/part.setpropertyform.php b/templates/part.setpropertyform.php
index bd18d86b..b0bf6645 100644
--- a/templates/part.setpropertyform.php
+++ b/templates/part.setpropertyform.php
@@ -1,4 +1,3 @@
-
-
From adab7b7012168e5a90c2a7f34f8e0c01badb7480 Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Thu, 24 Nov 2011 21:34:50 +0100
Subject: [PATCH 08/10] Contacts: make type of phone property also multiselect
in addproperty
---
js/interface.js | 1 +
templates/part.details.php | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/js/interface.js b/js/interface.js
index 24b512e5..ba1c0e53 100644
--- a/js/interface.js
+++ b/js/interface.js
@@ -64,6 +64,7 @@ $(document).ready(function(){
else{
$('#contacts_generic').clone().insertAfter($('#contacts_addpropertyform .contacts_property_name'));
}
+ $('#contacts_addpropertyform .contacts_property_data select').chosen();
});
$('#contacts_addpropertyform input[type="submit"]').live('click',function(){
diff --git a/templates/part.details.php b/templates/part.details.php
index f5bd7580..5e9a5c56 100644
--- a/templates/part.details.php
+++ b/templates/part.details.php
@@ -75,7 +75,7 @@
-
+
From 0e9fa8b88fdd228e5475c6e71c25b12711e3f90e Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Thu, 24 Nov 2011 21:35:41 +0100
Subject: [PATCH 09/10] Contacts: better label for saving a property
---
templates/part.setpropertyform.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/part.setpropertyform.php b/templates/part.setpropertyform.php
index b0bf6645..d31bde00 100644
--- a/templates/part.setpropertyform.php
+++ b/templates/part.setpropertyform.php
@@ -52,5 +52,5 @@
-
+
From 59e3d53e6208d80710dbdec3bf32df0447111497 Mon Sep 17 00:00:00 2001
From: Bart Visscher
Date: Thu, 24 Nov 2011 21:36:14 +0100
Subject: [PATCH 10/10] Contacts: layout updates
---
css/styles.css | 3 ++-
templates/part.details.php | 4 ++--
templates/part.setpropertyform.php | 4 ++--
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/css/styles.css b/css/styles.css
index e226c48a..f351589f 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -3,9 +3,10 @@
#contacts_deletecard {position:absolute;top:15px;right:0;}
#contacts_details_list { list-style:none; }
+#contacts_details_list li { overflow:visible; }
#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%;float:left; }
-#contacts_addproperty_button, #contacts_setproperty_button { margin-left:25%; }
+#contacts_setproperty_button { margin-left:25%; }
.contacts_property_data ul, ol.contacts_property_data { list-style:none; }
.contacts_property_data li { overflow: hidden; }
diff --git a/templates/part.details.php b/templates/part.details.php
index 5e9a5c56..f6d69005 100644
--- a/templates/part.details.php
+++ b/templates/part.details.php
@@ -29,12 +29,12 @@
+
+
-
-