diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-01-11 03:56:53 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-01-11 04:05:30 +0100 |
commit | 1a6ad816a32eb9d4813b66457f8bcdc9c46e2141 (patch) | |
tree | 1aaae79b6e28021937364b8b02db904f041f0362 | |
parent | 5500041ccab0fb7664a06ffa40fe3532d11bacb4 (diff) | |
download | nextcloud-server-1a6ad816a32eb9d4813b66457f8bcdc9c46e2141.tar.gz nextcloud-server-1a6ad816a32eb9d4813b66457f8bcdc9c46e2141.zip |
CSS cleanup, more error checking, better error messages, general cleanup.
-rw-r--r-- | apps/contacts/ajax/addproperty.php | 10 | ||||
-rw-r--r-- | apps/contacts/css/styles.css | 39 | ||||
-rw-r--r-- | apps/contacts/export.php | 8 | ||||
-rw-r--r-- | apps/contacts/index.php | 6 | ||||
-rw-r--r-- | apps/contacts/js/interface.js | 59 | ||||
-rw-r--r-- | apps/contacts/lib/addressbook.php | 10 | ||||
-rw-r--r-- | apps/contacts/lib/app.php | 1 | ||||
-rw-r--r-- | apps/contacts/lib/vcard.php | 3 | ||||
-rw-r--r-- | apps/contacts/templates/index.php | 7 | ||||
-rw-r--r-- | apps/contacts/templates/part.addcardform.php | 117 |
10 files changed, 171 insertions, 89 deletions
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index 0f76add3c9b..74f1c3d0e9e 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -26,13 +26,21 @@ require_once('../../../lib/base.php'); // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); +$l=new OC_L10N('contacts'); $id = $_POST['id']; $vcard = OC_Contacts_App::getContactVCard( $id ); $name = $_POST['name']; $value = $_POST['value']; -$parameters = isset($_POST['parameters'])?$_POST['parameters']:array(); +if(!is_array($value)){ + $value = trim($value); + if(!$value && in_array($name, array('TEL', 'EMAIL'))) { + OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.')))); + exit(); + } +} +$parameters = isset($_POST['parameters']) ? $_POST['parameters'] : array(); $property = $vcard->addProperty($name, $value); //, $parameters); diff --git a/apps/contacts/css/styles.css b/apps/contacts/css/styles.css index 7b56767bab0..dfc296a221b 100644 --- a/apps/contacts/css/styles.css +++ b/apps/contacts/css/styles.css @@ -8,9 +8,46 @@ #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_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; clear: right; } #contacts_setproperty_button { margin-left:25%; } +dl.form +{ + width: 100%; + float: left; + clear: right; + margin: 1em; + padding: 0; +} + +.form dt +{ + display: table-cell; + clear: left; + float: left; + min-width: 10em; + margin: 0; + padding-top: 0.5em; + padding-right: 1em; + font-weight: bold; + text-align:right; + vertical-align: text-bottom; + bottom: 0px; +} + +.form dd +{ + display: table-cell; + clear: right; + float: left; + min-width: 20em; + margin: 0; + padding: 0; + white-space: nowrap; + top: 0px; +} +.form input { position: relative; width: 20em; } + .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; } diff --git a/apps/contacts/export.php b/apps/contacts/export.php index fd2d7da1750..a1e974c962b 100644 --- a/apps/contacts/export.php +++ b/apps/contacts/export.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de> + * Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -20,9 +20,9 @@ if(isset($book)){ $cardobjects = OC_Contacts_VCard::all($book); header('Content-Type: text/directory'); header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf'); - for($i = 0;$i <= count($cardobjects); $i++){ - echo $cardobjects[$i]['carddata']; - //echo '\r\n'; + + foreach($cardobjects as $card) { + echo $card['carddata']; } }elseif(isset($contact)){ $data = OC_Contacts_App::getContactObject($contact); diff --git a/apps/contacts/index.php b/apps/contacts/index.php index 0b705e71b5d..6f65ac1c605 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -60,10 +60,10 @@ if(!is_null($id)) { // Include Style and Script OC_Util::addScript('contacts','interface'); -OC_Util::addStyle('contacts','styles'); -OC_Util::addStyle('contacts','formtastic'); +OC_Util::addScript('contacts','jquery.inview'); OC_Util::addScript('', 'jquery.multiselect'); -OC_Util::addStyle('', 'jquery.multiselect'); +OC_Util::addStyle('contacts','styles'); +//OC_Util::addStyle('contacts','formtastic'); $property_types = OC_Contacts_App::getAddPropertyOptions(); $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js index 4a27073c156..9547c581c87 100644 --- a/apps/contacts/js/interface.js +++ b/apps/contacts/js/interface.js @@ -29,18 +29,28 @@ Contacts={ $('#carddav_url_close').show(); }, messageBox:function(title, msg) { - var $dialog = $('<div></div>') - .html(msg) - .dialog({ - autoOpen: true, - title: title,buttons: [ + if($('#messagebox').dialog('isOpen') == true){ + // NOTE: Do we ever get here? + $('#messagebox').dialog('moveToTop'); + }else{ + $('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'messagebox.php'), function(){ + $('#messagebox').dialog( { - text: "Ok", - click: function() { $(this).dialog("close"); } - } - ] - } - ); + autoOpen: true, + title: title, + buttons: [{ + text: "Ok", + click: function() { $(this).dialog("close"); } + }], + close: function(event, ui) { + $(this).dialog('destroy').remove(); + }, + open: function(event, ui) { + $('#messagebox_msg').html(msg); + } + }); + }); + } }, Addressbooks:{ overview:function(){ @@ -159,6 +169,10 @@ $(document).ready(function(){ /*------------------------------------------------------------------------- * Event handlers *-----------------------------------------------------------------------*/ + + /** + * Load the details view for a contact. + */ $('#leftcontent li').live('click',function(){ var id = $(this).data('id'); var oldid = $('#rightcontent').data('id'); @@ -179,6 +193,9 @@ $(document).ready(function(){ return false; }); + /** + * Delete currently selected contact (and clear form?) + */ $('#contacts_deletecard').live('click',function(){ var id = $('#rightcontent').data('id'); $.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){ @@ -195,6 +212,10 @@ $(document).ready(function(){ return false; }); + /** + * Add a property to the contact. + * NOTE: Where does 'contacts_addproperty' exist? + */ $('#contacts_addproperty').live('click',function(){ var id = $('#rightcontent').data('id'); $.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){ @@ -204,12 +225,15 @@ $(document).ready(function(){ } else{ Contacts.UI.messageBox('Error', jsondata.data.message); - //alert(jsondata.data.message); + alert('From handler: '+jsondata.data.message); } }); return false; }); + /** + * Change the inputs based on which type of property is selected for addition. + */ $('#contacts_addpropertyform [name="name"]').live('change',function(){ $('#contacts_addpropertyform #contacts_addresspart').remove(); $('#contacts_addpropertyform #contacts_phonepart').remove(); @@ -234,12 +258,14 @@ $(document).ready(function(){ } else{ Contacts.UI.messageBox('Error', jsondata.data.message); - //alert(jsondata.data.message); } }, 'json'); return false; }); + /** + * Show the Addressbook chooser + */ $('#chooseaddressbook').click(function(){ Contacts.UI.Addressbooks.overview(); return false; @@ -292,6 +318,10 @@ $(document).ready(function(){ }, 'json'); return false; }); + + /** + * Show inputs for editing a property. + */ $('.contacts_property [data-use="edit"]').live('click',function(){ var id = $('#rightcontent').data('id'); var checksum = $(this).parents('.contacts_property').first().data('checksum'); @@ -308,6 +338,9 @@ $(document).ready(function(){ return false; }); + /** + * Save the edited property + */ $('#contacts_setpropertyform input[type="submit"]').live('click',function(){ $.post('ajax/setproperty.php',$(this).parents('form').first().serialize(),function(jsondata){ if(jsondata.status == 'success'){ diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php index 78792f5f948..41d488c09f9 100644 --- a/apps/contacts/lib/addressbook.php +++ b/apps/contacts/lib/addressbook.php @@ -203,15 +203,6 @@ class OC_Contacts_Addressbook{ while( $row = $result->fetchRow()){ $addressbooks[] = $row; } - /* - foreach( $active as $aid ){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ? ORDER BY displayname' ); - $result = $stmt->execute(array($aid,)); - - while( $row = $result->fetchRow()){ - $addressbooks[] = $row; - } - }*/ return $addressbooks; } @@ -240,6 +231,7 @@ class OC_Contacts_Addressbook{ unset($openaddressbooks[array_search($id, $openaddressbooks)]); } } + // NOTE: Ugly hack... $openaddressbooks = self::cleanArray($openaddressbooks, false); sort($openaddressbooks, SORT_NUMERIC); // FIXME: I alway end up with a ';' prepending when imploding the array..? diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index 79e00920a65..907ce82c76a 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -73,6 +73,7 @@ class OC_Contacts_App{ for($i=0;$i<count($vcard->children);$i++){ if(md5($vcard->children[$i]->serialize()) == $checksum ){ $line = $i; + break; } } if(is_null($line)){ diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 6a248ff59e4..401f9622547 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -151,6 +151,7 @@ class OC_Contacts_VCard{ foreach($card->children as $property){ if($property->name == 'FN'){ $fn = $property->value; + break; } } } @@ -178,6 +179,7 @@ class OC_Contacts_VCard{ foreach($card->children as $property){ if($property->name == 'FN'){ $fn = $property->value; + break; } } } @@ -206,6 +208,7 @@ class OC_Contacts_VCard{ foreach($card->children as $property){ if($property->name == 'FN'){ $fn = $property->value; + break; } } } diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php index 24484231af4..d548f17172d 100644 --- a/apps/contacts/templates/index.php +++ b/apps/contacts/templates/index.php @@ -1,10 +1,3 @@ -<?php // Include Style and Script -//OC_Util::addScript('contacts','interface'); // this line caused entry duplication, cause contacts/index.php already inlcudes it -OC_Util::addScript('contacts','jquery.inview'); -OC_Util::addStyle('contacts','styles'); -OC_Util::addStyle('contacts','formtastic'); -?> - <script type='text/javascript'> var totalurl = '<?php echo OC_Helper::linkTo('contacts', 'carddav.php', null, true); ?>/addressbooks'; </script> diff --git a/apps/contacts/templates/part.addcardform.php b/apps/contacts/templates/part.addcardform.php index 627053547ad..510096a9e81 100644 --- a/apps/contacts/templates/part.addcardform.php +++ b/apps/contacts/templates/part.addcardform.php @@ -3,93 +3,108 @@ <input type="hidden" name="id" value="<?php echo $_['addressbooks'][0]['id']; ?>"> <?php else: ?> <fieldset class="inputs"> - <ol> - <li class="input stringish"> + <dl class="form"> + <dt> <label class="label" for="id"><?php echo $l->t('Group'); ?></label> + </dt> + <dd> <select name="id" size="1"> <?php echo html_select_options($_['addressbooks'], null, array('value'=>'id', 'label'=>'displayname')); ?> </select> - </li> - </ol> + </dd> + </dl> </fieldset> <?php endif; ?> <fieldset class="inputs"> - <ol> - <li class="input stringish"> + <dl class="form"> + <dt> <label class="label" for="fn"><?php echo $l->t('Name'); ?></label> + </dd> + <dd> <input id="fn" type="text" name="fn" value=""><br> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="org"><?php echo $l->t('Organization'); ?></label> + </dt> + <dd> <input id="org" type="text" name="value[ORG]" value=""> - </li> - </ol> + </dd> + </dl> </fieldset> <fieldset class="inputs"> - <ol> - <li class="input stringish"> + <dl class="form"> + <dt> <label class="label" for="email"><?php echo $l->t('Email'); ?></label> + </dt> + <dd> <input id="email" type="text" name="value[EMAIL]" value=""> - </li> - <li class="input"> - <fieldset class="fragments"> - <legend class="label"> - <label for="tel"><?php echo $l->t('Telephone'); ?></label> - </legend> - <ol class="fragments-group"> - <li class="fragment"> - <label for="tel"><?php echo $l->t('Number'); ?></label> - <input type="phone" id="tel" name="value[TEL]" value=""> - </li> - <li class="fragment"> - <label for="tel_type"><?php echo $l->t('Type'); ?></label> - <select id="TEL" name="parameters[TEL][TYPE][]" multiple="multiple"> - <?php echo html_select_options($_['phone_types'], 'CELL') ?> - </select> - </li> - </ol> - </fieldset> - </li> - </ol> + </dd> + <dt> + <label for="tel"><?php echo $l->t('Telephone'); ?></label> + </dt> + <dd> + <input type="phone" id="tel" name="value[TEL]" value=""> + <select id="TEL" name="parameters[TEL][TYPE][]" multiple="multiple"> + <?php echo html_select_options($_['phone_types'], 'CELL') ?> + </select> + </dd> + </dl> </fieldset> <fieldset class="inputs"> <legend><?php echo $l->t('Address'); ?></legend> - <ol> - <li class="input"> + <dl class="form"> + <dt> <label class="label" for="adr_type"><?php echo $l->t('Type'); ?></label> + </dt> + <dd> <select id="adr_type" name="parameters[ADR][TYPE]" size="1"> <?php echo html_select_options($_['adr_types'], 'HOME') ?> </select> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="adr_pobox"><?php echo $l->t('PO Box'); ?></label> + </dt> + <dd> <input type="text" id="adr_pobox" name="value[ADR][0]" value=""> - </li> - <li class="input stringish"> + </dd> + <dd> + <dt> <label class="label" for="adr_extended"><?php echo $l->t('Extended'); ?></label> + </dt> + <dd> <input type="text" id="adr_extended" name="value[ADR][1]" value=""> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="adr_street"><?php echo $l->t('Street'); ?></label> + </dt> + <dd> <input type="text" id="adr_street" name="value[ADR][2]" value=""> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="adr_city"><?php echo $l->t('City'); ?></label> + </dt> + <dd> <input type="text" id="adr_city" name="value[ADR][3]" value=""> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="adr_region"><?php echo $l->t('Region'); ?></label> + </dt> + <dd> <input type="text" id="adr_region" name="value[ADR][4]" value=""> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label> + </dtl> + <dd> <input type="text" id="adr_zipcode" name="value[ADR][5]" value=""> - </li> - <li class="input stringish"> + </dd> + <dt> <label class="label" for="adr_country"><?php echo $l->t('Country'); ?></label> + </dt> + <dd> <input type="text" id="adr_country" name="value[ADR][6]" value=""> - </li> - </ol> + </dd> + </dl> </fieldset> <fieldset class="buttons"> <ol> |