Changeset 4243 in subversion
- Timestamp:
- Nov 21, 2010 11:47:21 AM (3 years ago)
- Location:
- branches/devel-addressbook/program
- Files:
-
- 4 edited
-
include/rcube_addressbook.php (modified) (2 diffs)
-
include/rcube_contacts.php (modified) (1 diff)
-
js/app.js (modified) (1 diff)
-
steps/addressbook/func.inc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-addressbook/program/include/rcube_addressbook.php
r4227 r4243 6 6 | | 7 7 | This file is part of the Roundcube Webmail client | 8 | Copyright (C) 2006-20 09, Roundcube Dev. - Switzerland |8 | Copyright (C) 2006-2010, Roundcube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 28 28 abstract class rcube_addressbook 29 29 { 30 /** public properties */ 31 var $primary_key; 32 var $groups = false; 33 var $readonly = true; 34 var $ready = false; 35 var $list_page = 1; 36 var $page_size = 10; 30 /** public properties (mandatory) */ 31 public $primary_key; 32 public $groups = false; 33 public $readonly = true; 34 public $ready = false; 35 public $list_page = 1; 36 public $page_size = 10; 37 public $coltypes = array('name' => array('limit'=>1), 'firstname' => array('limit'=>1), 'surname' => array('limit'=>1), 'email' => array('limit'=>1)); 37 38 38 39 /** -
branches/devel-addressbook/program/include/rcube_contacts.php
r4240 r4243 48 48 49 49 // public properties 50 var $primary_key = 'contact_id'; 51 var $readonly = false; 52 var $groups = true; 53 var $list_page = 1; 54 var $page_size = 10; 55 var $group_id = 0; 56 var $ready = false; 50 public $primary_key = 'contact_id'; 51 public $readonly = false; 52 public $groups = true; 53 public $list_page = 1; 54 public $page_size = 10; 55 public $group_id = 0; 56 public $ready = false; 57 public $coltypes = array('name', 'firstname', 'surname', 'middlename', 'prefix', 'suffix', 'nickname', 58 'jobtitle', 'organization', 'department', 'gender', 'maidenname', 'email', 'phone', 'address', 59 'birthday', 'website', 'im', 'notes'); 57 60 58 61 -
branches/devel-addressbook/program/js/app.js
r4242 r4243 4029 4029 } 4030 4030 else if (colprop.type == 'composite') { 4031 var childcol, cp; 4032 for (var j=0; j < colprop.childs.length; j++) { 4033 childcol = colprop.childs[j]; 4034 cp = this.env.coltypes[childcol]; 4035 input = $('<input>') 4036 .addClass('ff_'+childcol) 4037 .attr('type', 'text') 4038 .attr('name', '_'+childcol+'[]') 4039 .attr('size', cp.size) 4040 .appendTo(cell); 4041 cell.append(" "); 4042 this.init_edit_field(childcol, input); 4043 } 4031 var childcol, cp, first; 4032 for (var childcol in colprop.childs) { 4033 cp = colprop.childs[childcol]; 4034 input = $('<input>') 4035 .addClass('ff_'+childcol) 4036 .attr('type', 'text') 4037 .attr('name', '_'+childcol+'[]') 4038 .attr('size', cp.size) 4039 .appendTo(cell); 4040 cell.append(" "); 4041 this.init_edit_field(childcol, input); 4042 if (!first) first = input; 4043 } 4044 input = first; // set focus to the first of this composite fields 4044 4045 } 4045 4046 else if (colprop.type == 'select') { -
branches/devel-addressbook/program/steps/addressbook/func.inc
r4242 r4243 57 57 58 58 59 // TODO: let the $CONTACT object define the list of possiblecoltypes59 // general definition of contact coltypes 60 60 $CONTACT_COLTYPES = array( 61 61 'name' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => rcube_label('name')), … … 73 73 'email' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('email'), 'subtypes' => array('home','work','other')), 74 74 'phone' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('phone'), 'subtypes' => array('home','home2','work','work2','mobile','main','homefax','workfax','car','pager','video','assistant','other')), 75 'address' => array('type' => 'composite', 'label' => rcube_label('address'), 'subtypes' => array('home','work','other'), 'childs' => array('street','locality','zipcode','region','country')), 76 'street' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('street'), 'composite' => true), 77 'locality' => array('type' => 'text', 'size' => 28, 'label' => rcube_label('locality'), 'composite' => true), 78 'zipcode' => array('type' => 'text', 'size' => 8, 'label' => rcube_label('zipcode'), 'composite' => true), 79 'region' => array('type' => 'text', 'size' => 12, 'label' => rcube_label('region'), 'composite' => true), 80 'country' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('country'), 'composite' => true), 75 'address' => array('type' => 'composite', 'label' => rcube_label('address'), 'subtypes' => array('home','work','other'), 'childs' => array( 76 'street' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('street')), 77 'locality' => array('type' => 'text', 'size' => 28, 'label' => rcube_label('locality')), 78 'zipcode' => array('type' => 'text', 'size' => 8, 'label' => rcube_label('zipcode')), 79 'region' => array('type' => 'text', 'size' => 12, 'label' => rcube_label('region')), 80 'country' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('country')), 81 )), 81 82 'birthday' => array('type' => 'date', 'size' => 12, 'label' => rcube_label('birthday'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col'), 82 83 'website' => array('type' => 'text', 'size' => 40, 'label' => rcube_label('website'), 'subtypes' => array('home','work','blog','other')), … … 86 87 ); 87 88 89 // reduce/extend $CONTACT_COLTYPES with specification from the current $CONTACT object 90 if (is_array($CONTACTS->coltypes)) { 91 // remove cols not listed by the backend class 92 $contact_cols = $CONTACTS->coltypes[0] ? array_flip($CONTACTS->coltypes) : $CONTACTS->coltypes; 93 $CONTACT_COLTYPES = array_intersect_key($CONTACT_COLTYPES, $contact_cols); 94 // add associative coltypes definition 95 if (!$CONTACTS->coltypes[0]) { 96 foreach ($CONTACTS->coltypes as $col => $colprop) 97 $CONTACT_COLTYPES[$col] = $CONTACT_COLTYPES[$col] ? array_merge($CONTACT_COLTYPES[$col], $colprop) : $colprop; 98 } 99 } 88 100 89 101 … … 282 294 // get default coltypes 283 295 $coltypes = $GLOBALS['CONTACT_COLTYPES']; 296 $coltype_lables = array(); 284 297 285 298 foreach ($coltypes as $col => $prop) { … … 288 301 $select_subtype->add($prop['subtypes']); 289 302 $coltypes[$col]['subtypes_select'] = $select_subtype->show(); 303 } 304 if ($prop['childs']) { 305 foreach ($prop['childs'] as $childcol => $cp) 306 $coltype_lables[$childcol] = array('label' => $cp['label']); 290 307 } 291 308 } … … 316 333 $fields = ''; 317 334 foreach ($colnames as $col) { 335 // skip cols unknown to the backend 336 if (!$coltypes[$col]) 337 continue; 338 318 339 if ($RCMAIL->action == 'show') { 319 340 if (!empty($record[$col])) … … 343 364 if (is_array($fieldset['content'])) { 344 365 foreach ($fieldset['content'] as $col => $colprop) { 366 // skip cols unknown to the backend 367 if (!$coltypes[$col]) 368 continue; 369 345 370 // remove subtype part of col name 346 371 list($field, $subtype) = explode(':', $col); … … 405 430 // render composite field 406 431 if ($colprop['type'] == 'composite') { 407 $composite = ''; 408 foreach ($colprop['childs'] as $ j => $childcol) {432 $composite = ''; $j = 0; 433 foreach ($colprop['childs'] as $childcol => $cp) { 409 434 $childvalue = $val[$childcol] ? $val[$childcol] : $val[$j]; 410 435 411 436 if ($edit_mode) { 412 $cp = $coltypes[$childcol];413 437 if ($colprop['subtypes']) $cp['array'] = true; 414 438 $composite .= rcmail_get_edit_field($childcol, $childvalue, $cp, $cp['type']) . " "; … … 418 442 $composite .= html::span('data ' . $childcol, $childval) . " "; 419 443 } 444 $j++; 420 445 } 421 446 … … 488 513 if ($edit_mode) { 489 514 $RCMAIL->output->set_env('contactdata', $formdata); 490 $RCMAIL->output->set_env('coltypes', $coltypes );515 $RCMAIL->output->set_env('coltypes', $coltypes + $coltype_lables); 491 516 $RCMAIL->output->set_env('delbutton', $del_button); 492 517 $RCMAIL->output->add_label('delete');
Note: See TracChangeset
for help on using the changeset viewer.
