diff -ruaN phone/phone.css phone-new/phone.css --- phone/phone.css 1969-12-31 19:00:00.000000000 -0500 +++ phone-new/phone.css 2008-06-27 15:14:58.000000000 -0400 @@ -0,0 +1,9 @@ +.phone-fields-wrapper div.form-item { + float: left; + width: 48%; +} + +.phone-field-wrapper div.form-item { + float: left; + width: 48%; +} diff -ruaN phone/phone.install phone-new/phone.install --- phone/phone.install 1969-12-31 19:00:00.000000000 -0500 +++ phone-new/phone.install 2008-06-27 15:14:58.000000000 -0400 @@ -0,0 +1,40 @@ + TRUE, 'default' => '')); + break; + + case 'mysql': + case 'mysqli': + $field_instance_result = db_query("SELECT field_name, type_name from {node_field_instance} where widget_type = 'phone'"); + while ($field_instance = db_fetch_array($field_instance_result)) { + // ? // $field_instance['fields'] = array(); + $field_result = db_query("SELECT multiple from {node_field} where field_name = '%s'", $field_instance['field_name']); + while ($field = db_fetch_array($field_result)) { + $content_field_table = 'content_' . $field_instance['field_name']; + $content_field_type_value = $field_instance['field_name'] . '_type_value'; + $content_type_table = 'content_type_' . $field_instance['type_name']; + if ($field['multiple']) { + // multiple fields + $ret[] = update_sql("ALTER TABLE { $content_field_table } ADD COLUMN $content_field_type_value varchar(255) NOT NULL"); + } + else { + // single field + $ret[] = update_sql("ALTER TABLE { $content_type_table } ADD COLUMN $content_field_type_value varchar(255) NOT NULL"); + } + } + } + break; + } + + return $ret; +} diff -ruaN phone/phone.module phone-new/phone.module --- phone/phone.module 2008-05-28 18:45:34.000000000 -0400 +++ phone-new/phone.module 2008-06-27 15:15:46.000000000 -0400 @@ -67,12 +67,13 @@ || $field['type'] == 'es_phone' || $field['type'] == 'au_phone' || $field['type'] == 'cs_phone' - ){ - $columns = array( - 'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), - ); - } - return $columns; + ){ + $columns = array( + 'value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), + 'type_value' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), + ); + } + return $columns; } } @@ -124,19 +125,32 @@ * Implementation of hook_field_formatter(). **/ function phone_field_formatter($field, $item, $formatter, $node) { - if (!isset($item['value'])) { + // Deal with blank items in db - isset($item['value']) should have taken care of it, but it doesn't - this does catch it. + if (trim($item['value']) == '') { return ''; } if ($field['text_processing']) { $text = check_markup($item['value'], $item['format'], is_null($node) || isset($node->in_preview)); + $full_text = $text .' '. check_markup($item['type_value'], $item['format'], is_null($node) || isset($node->in_preview)); } else { $text = check_plain($item['value']); + // I don't know if iPhones can have number and type - probably just one field. + // if they can the $full_text part can go away and just use - $text .= check_plain($item['type_value']); + // Also change it up in the 'text processing' area to something similar. + $full_text = $text .' '. check_plain($item['type_value']); } // iPhone Support if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) { - $text = '' . $text . ''; - } + // To test iPhone for both fields uncomment next line and comment following line. + //$text = '' . $full_text . ''; + $text = '' . $text . ''; + // Or maybe the href could contain the phone number type - comment previous line and uncomment the next line. + //$text = '' . $text . ''; + } + else { + $text = $full_text; + } return $text; } @@ -179,29 +193,52 @@ * Implementation of hook_widget(). */ function phone_widget($op, &$node, $field, &$node_field) { - switch ($op) { + drupal_add_css(drupal_get_path('module', 'phone'). '/phone.css', 'module', 'all', FALSE); + switch ($op) { case 'form': $form = array(); - - $form[$field['field_name']] = array('#tree' => TRUE); - + + $form[$field['field_name']] = array('#tree' => TRUE, '#theme' => 'phone_widget_form'); + if ($field['multiple']) { $form[$field['field_name']]['#type'] = 'fieldset'; $form[$field['field_name']]['#title'] = t($field['widget']['label']); + $form[$field['field_name']]['wrapper'] = array( + '#type' => 'markup', + '#value' => '
', + ); foreach (range(0,2) as $delta) { $form[$field['field_name']][$delta]['value'] = array( '#type' => 'textfield', - '#title' => '', + '#title' => $delta == 0 ? t('Phone Number') : '', '#default_value' => isset($node_field[$delta]['value']) ? $node_field[$delta]['value'] : '', - '#required' => $field['required'] ? $field['required'] : FALSE, + '#required' => $delta == 0 ? $field['required'] : FALSE, '#maxlength' => 255, '#weight' => $field['widget']['weight'], '#size' => isset($field['widget']['size']) ? $field['widget']['size'] : 20, '#description' => $field['widget']['description'], ); + $order_options = array('Mobile' => 'Mobile', 'Home' => 'Home', 'Office' => 'Office', 'Apt' => 'Apt', 'Dorm' => 'Dorm', 'Fax' => 'Fax'); + $form[$field['field_name']][$delta]['type_value'] = array( + '#type' => 'select', + '#title' => $delta == 0 ? t('Phone Type') : NULL, + '#default_value' => isset($node_field[$delta]['type_value']) ? $node_field[$delta]['type_value'] : '', + '#weight' => $field['widget']['weight']+1, + '#options' => $order_options, + '#description' => $field['widget']['description'], + '#required' => $delta == 0 ? $field['required'] : FALSE, + ); } - } + $form[$field['field_name']]['end-wrapper'] = array( + '#type' => 'markup', + '#value' => '
', + ); + } else { + $form[$field['field_name']]['wrapper'] = array( + '#type' => 'markup', + '#value' => '
', + ); $form[$field['field_name']][0]['value'] = array( '#type' => 'textfield', '#title' => $field['widget']['label'], @@ -210,7 +247,21 @@ '#maxlength' => 255, '#weight' => $field['widget']['weight'], '#size' => isset($field['widget']['size']) ? $field['widget']['size'] : 20, - '#description' => $field['widget']['description'], + '#description' => $field['widget']['description'], + ); + $order_options = array('Mobile' => 'Mobile', 'Home' => 'Home', 'Office' => 'Office', 'Apt' => 'Apt', 'Dorm' => 'Dorm', 'Fax' => 'Fax'); + $form[$field['field_name']][0]['type_value'] = array( + '#type' => 'select', + '#title' => $delta == 0 ? t('Phone Type') : NULL, + '#default_value' => isset($node_field[0]['type_value']) ? $node_field[0]['type_value'] : '', + '#weight' => $field['widget']['weight']+1, + '#options' => $order_options, + '#description' => $field['widget']['description'], + '#required' => $field['required'] ? $field['required'] : FALSE, + ); + $form[$field['field_name']]['end-wrapper'] = array( + '#type' => 'markup', + '#value' => '
', ); }