}
}
+ // XXX: getPhones, getIms, and getWebsites pretty much do the same thing,
+ // so refactor.
function getPhones()
{
$phones = (isset($this->fields['phone'])) ? $this->fields['phone'] : null;
return $iArrays;
}
+ function getWebsites()
+ {
+ $sites = (isset($this->fields['website'])) ? $this->fields['website'] : null;
+ $wArrays = array();
+
+ if (empty($sites)) {
+ $wArrays[] = array(
+ 'label' => _m('Website'),
+ 'type' => 'website'
+ );
+ } else {
+ for ($i = 0; $i < sizeof($sites); $i++) {
+ $wa = array(
+ 'label' => _m('Website'),
+ 'type' => 'website',
+ 'index' => intval($sites[$i]->value_index),
+ 'rel' => $sites[$i]->rel,
+ 'value' => $sites[$i]->field_value,
+ );
+
+ $wArrays[] = $wa;
+ }
+ }
+ return $wArrays;
+ }
+
function getExperiences()
{
$companies = (isset($this->fields['company'])) ? $this->fields['company'] : null;
'contact' => array(
'label' => _m('Contact'),
'fields' => array(
- 'phone' => $this->getPhones(),
- 'im' => $this->getIms(),
- 'website' => array(
- 'label' => _m('Websites'),
- 'type' => 'website',
- 'multi' => true,
- ),
+ 'phone' => $this->getPhones(),
+ 'im' => $this->getIms(),
+ 'website' => $this->getWebsites()
),
),
'personal' => array(
switch($fieldName) {
case 'phone':
case 'im':
+ case 'website':
case 'experience':
case 'education':
$this->showMultiple($fieldName, $field);
}
}
+ // XXX: showPhone, showIm and showWebsite all work the same, so
+ // combine
protected function showPhone($name, $field)
{
$this->out->elementStart('div', array('class' => 'phone-display'));
$this->out->elementEnd('div');
}
+ protected function showWebsite($name, $field)
+ {
+ $this->out->elementStart('div', array('class' => 'website-display'));
+ $this->out->text($field['value']);
+ if (!empty($field['rel'])) {
+ $this->out->text(' (' . $field['rel'] . ')');
+ }
+ $this->out->elementEnd('div');
+ }
+
protected function showEditableIm($name, $field)
{
$index = isset($field['index']) ? $field['index'] : 0;
$this->out->elementEnd('div');
}
+ protected function showEditableWebsite($name, $field)
+ {
+ $index = isset($field['index']) ? $field['index'] : 0;
+ $id = "extprofile-$name-$index";
+ $rel = $id . '-rel';
+ $this->out->elementStart(
+ 'div', array(
+ 'id' => $id . '-edit',
+ 'class' => 'website-edit'
+ )
+ );
+ $this->out->input(
+ $id,
+ null,
+ isset($field['value']) ? $field['value'] : null
+ );
+ $this->out->dropdown(
+ $id . '-rel',
+ 'Type',
+ array(
+ 'blog' => 'Blog',
+ 'homepage' => 'Homepage',
+ 'facebook' => 'Facebook',
+ 'linkedin' => 'LinkedIn',
+ 'flickr' => 'Flickr',
+ 'google' => 'Google Profile',
+ 'other' => 'Other',
+ 'twitter' => 'Twitter'
+ ),
+ null,
+ false,
+ isset($field['rel']) ? $field['rel'] : null
+ );
+
+ $this->showMultiControls();
+ $this->out->elementEnd('div');
+ }
+
protected function showExperience($name, $field)
{
$this->out->elementStart('div', 'experience-item');
case 'phone':
$this->showPhone($name, $field);
break;
+ case 'website':
+ $this->showWebsite($name, $field);
+ break;
case 'im':
$this->showIm($name, $field);
break;
case 'im':
$this->showEditableIm($name, $field);
break;
+ case 'website':
+ $this->showEditableWebsite($name, $field);
+ break;
case 'experience':
$this->showEditableExperience($name, $field);
break;
$this->savePhoneNumbers($user);
$this->saveIms($user);
+ $this->saveWebsites($user);
$this->saveExperiences($user);
$this->saveEducations($user);
}
}
+ function findWebsites() {
+
+ // Form vals look like this:
+
+ $sites = $this->sliceParams('website', 2);
+ $wsArray = array();
+
+ foreach ($sites as $site) {
+ list($id, $rel) = array_values($site);
+ $wsArray[] = array(
+ 'value' => $id,
+ 'rel' => $rel
+ );
+ }
+
+ return $wsArray;
+ }
+
+ function saveWebsites($user) {
+ $sites = $this->findWebsites();
+ $this->removeAll($user, 'website');
+ $i = 0;
+ foreach($sites as $site) {
+ if (!empty($site['value'])) {
+ ++$i;
+ $this->saveField(
+ $user,
+ 'website',
+ $site['value'],
+ $site['rel'],
+ $i
+ );
+ }
+ }
+ }
+
function findExperiences() {
// Form vals look like this: