Make phone number save and display from DB

This commit is contained in:
Zach Copley 2011-03-10 16:57:41 -08:00
parent 3592397d77
commit 8efd2cf04d
2 changed files with 44 additions and 13 deletions

View File

@ -37,8 +37,10 @@ class ExtendedProfile
{
$this->profile = $profile;
$this->user = $profile->getUser();
$this->sections = $this->getSections();
$this->fields = $this->loadFields();
$this->sections = $this->getSections();
//common_debug(var_export($this->sections, true));
//common_debug(var_export($this->fields, true));
}
@ -96,19 +98,36 @@ class ExtendedProfile
}
}
function getPhones()
{
return array(
$phones = $this->fields['phone'];
$pArrays = array();
if (empty($phones)) {
$pArrays[] = array(
'label' => _m('Phone'),
'type' => 'phone',
'multi' => true,
'index' => 8123,
'rel' => 'home',
'value' => '510-528-0079',
'vcard' => 'tel'
'vcard' => 'tel',
'multi' => true
);
} else {
for ($i = 0; $i < sizeof($phones); $i++) {
$pa = array(
'label' => _m('Phone'),
'type' => 'phone',
'index' => $phones[$i]->value_index,
'rel' => $phones[$i]->rel,
'value' => $phones[$i]->field_value,
'vcard' => 'tel'
);
// Last phone record should allow adding more
if ($i == sizeof($phones) - 1) {
$pa['multi'] = true;
}
$pArrays[] = $pa;
}
}
return $pArrays;
}
/**

View File

@ -101,9 +101,14 @@ class ExtendedProfileWidget extends Form
{
$this->out->element('h3', null, $section['label']);
$this->out->elementStart('table', array('class' => 'extended-profile'));
foreach ($section['fields'] as $fieldName => $field) {
if ($fieldName == 'phone') {
$this->showPhones($fieldName, $field);
} else {
$this->showExtendedProfileField($fieldName, $field);
}
}
$this->out->elementEnd('table');
}
@ -151,7 +156,6 @@ class ExtendedProfileWidget extends Form
$this->out->text($this->ext->getTags());
break;
case 'phone':
common_debug("GOT a PHONE!");
$this->showPhone($field);
break;
default:
@ -159,11 +163,19 @@ class ExtendedProfileWidget extends Form
}
}
protected function showPhones($name, $field) {
foreach ($field as $phone) {
$this->showExtendedProfileField($name, $phone);
}
}
protected function showPhone($field)
{
$this->out->elementStart('div', array('class' => 'phone-display'));
$this->out->text($field['value']);
if (!empty($field['rel'])) {
$this->out->text(' (' . $field['rel'] . ')');
}
$this->out->elementEnd('div');
}