{
$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));
}
}
}
-
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;
}
/**
{
$this->out->element('h3', null, $section['label']);
$this->out->elementStart('table', array('class' => 'extended-profile'));
+
foreach ($section['fields'] as $fieldName => $field) {
- $this->showExtendedProfileField($fieldName, $field);
+ if ($fieldName == 'phone') {
+ $this->showPhones($fieldName, $field);
+ } else {
+ $this->showExtendedProfileField($fieldName, $field);
+ }
}
$this->out->elementEnd('table');
}
$this->out->text($this->ext->getTags());
break;
case 'phone':
- common_debug("GOT a PHONE!");
$this->showPhone($field);
break;
default:
}
}
+ 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']);
- $this->out->text(' (' . $field['rel'] . ')');
+ if (!empty($field['rel'])) {
+ $this->out->text(' (' . $field['rel'] . ')');
+ }
$this->out->elementEnd('div');
}