return $eArrays;
}
+ function getEducation()
+ {
+ $schools = (isset($this->fields['school'])) ? $this->fields['school'] : null;
+ $degrees = (isset($this->fields['degree'])) ? $this->fields['degree'] : null;
+ $descs = (isset($this->fields['degree_description'])) ? $this->fields['degree_description'] : null;
+ $start = (isset($this->fields['school_start'])) ? $this->fields['school_start'] : null;
+ $end = (isset($this->fields['school_end'])) ? $this->fields['school_end'] : null;
+ $iArrays = array();
+
+ if (empty($schools)) {
+ $iArrays[] = array(
+ 'type' => 'education',
+ 'label' => _m('Institution'),
+ 'school' => null,
+ 'degree' => null,
+ 'description' => null,
+ 'start' => null,
+ 'end' => null,
+ 'index' => 0
+ );
+ } else {
+ for ($i = 0; $i < sizeof($schools); $i++) {
+ $ia = array(
+ 'type' => 'education',
+ 'label' => _m('Institution'),
+ 'school' => $schools[$i]->field_value,
+ 'degree' => $degrees[$i]->field_value,
+ 'description' => $descs[$i]->field_value,
+ 'index' => intval($schools[$i]->value_index),
+ 'start' => $start[$i]->date,
+ 'end' => $end[$i]->date
+ );
+ $iArrays[] = $ia;
+ }
+ }
+
+ return $iArrays;
+ }
+
/**
* Return all the sections of the extended profile
*
'experience' => array(
'label' => _m('Work experience'),
'fields' => array(
- 'experience' => $this->getExperiences(),
+ 'experience' => $this->getExperiences()
),
),
'education' => array(
'label' => _m('Education'),
'fields' => array(
- 'education' => array(
- 'type' => 'education',
- 'label' => _m('Institution'),
- ),
+ 'education' => $this->getEducation()
),
),
);
switch($fieldName) {
case 'phone':
case 'experience':
+ case 'education':
$this->showMultiple($fieldName, $field);
break;
default:
$this->out->elementEnd('div');
}
+ protected function showEducation($name, $field)
+ {
+ $this->out->elementStart('div', 'education-item');
+ $this->out->element('div', 'field', $field['school']);
+ $this->out->element('div', 'label', _m('Degree'));
+ $this->out->element('div', 'field', $field['degree']);
+ $this->out->element('div', 'label', _m('Description'));
+ $this->out->element('div', 'field', $field['description']);
+ $this->out->element('div', 'label', _m('Start'));
+ $this->out->element('div', array('class' => 'field date'), $field['start']);
+ $this->out->element('div', 'label', _m('End'));
+ $this->out->element('div', array('class' => 'field date'), $field['end']);
+ $this->out->elementEnd('div');
+ }
+
+ protected function showEditableEducation($name, $field)
+ {
+ $index = isset($field['index']) ? $field['index'] : 0;
+ $id = "extprofile-$name-$index";
+ $this->out->elementStart(
+ 'div', array(
+ 'id' => $id . '-edit',
+ 'class' => 'education-edit'
+ )
+ );
+ $this->out->input(
+ $id,
+ null,
+ isset($field['school']) ? $field['school'] : null
+ );
+
+ $this->out->element('div', 'label', _m('Degree'));
+ $this->out->input(
+ $id,
+ null,
+ isset($field['degree']) ? $field['degree'] : null
+ );
+
+ $this->out->element('div', 'label', _m('Description'));
+ $this->out->element('div', 'field', $field['description']);
+
+ $this->out->input(
+ $id,
+ null,
+ isset($field['description']) ? $field['description'] : null
+ );
+
+ $this->out->elementStart('ul', 'education-start-and-end');
+ $this->out->elementStart('li');
+ $this->out->input(
+ $id . '-start',
+ _m('Start'),
+ isset($field['start']) ? $field['start'] : null
+ );
+ $this->out->elementEnd('li');
+
+ $this->out->elementStart('li');
+ $this->out->input(
+ $id . '-end',
+ _m('End'),
+ isset($field['end']) ? $field['end'] : null
+ );
+ $this->out->elementEnd('ul');
+
+ $this->showMultiControls();
+ $this->out->elementEnd('div');
+ }
+
function showMultiControls()
{
$this->out->element(
case 'experience':
$this->showExperience($name, $field);
break;
+ case 'education':
+ $this->showEducation($name, $field);
+ break;
default:
$this->out->text("TYPE: $type");
}
case 'experience':
$this->showEditableExperience($name, $field);
break;
+ case 'education':
+ $this->showEditableEducation($name, $field);
+ break;
default:
$out->input($id, null, "TYPE: $type");
}
function findPhoneNumbers() {
- $phones = $this->sliceParams('phone', 2);
- $phoneTuples = array();
+ // Form vals look like this:
+ // 'extprofile-phone-1' => '11332',
+ // 'extprofile-phone-1-rel' => 'mobile',
+
+ $phones = $this->sliceParams('phone', 2);
+ $phoneArray = array();
foreach ($phones as $phone) {
list($number, $rel) = array_values($phone);
- $phoneTuples[] = array(
+ $phoneArray[] = array(
'value' => $number,
'rel' => $rel
);
}
- return $phoneTuples;
- }
-
- function sliceParams($key, $size) {
- $slice = array();
- $params = $this->findMultiParams($key);
- ksort($params);
- $slice = $this->arraySplit($params, sizeof($params) / $size);
- return $slice;
+ return $phoneArray;
}
function findExperiences() {
$expArray = array();
foreach ($experiences as $exp) {
-
- common_debug('Experience: ' . var_export($exp, true));
-
list($company, $current, $end, $start) = array_values($exp);
-
$startTs = strtotime($start);
if ($startTs === false) {
return $formVals;
}
+ function sliceParams($key, $size) {
+ $slice = array();
+ $params = $this->findMultiParams($key);
+ ksort($params);
+ $slice = $this->arraySplit($params, sizeof($params) / $size);
+ return $slice;
+ }
+
/**
* Save an extended profile field as a Profile_detail
*