Extended profile - HTML layout for education entries

This commit is contained in:
Zach Copley 2011-03-14 20:58:35 -07:00
parent 0ff7bf77e4
commit bd238e9a4d
3 changed files with 132 additions and 21 deletions

View File

@ -164,6 +164,45 @@ class ExtendedProfile
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
*
@ -241,16 +280,13 @@ class ExtendedProfile
'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()
),
),
);

View File

@ -107,6 +107,7 @@ class ExtendedProfileWidget extends Form
switch($fieldName) {
case 'phone':
case 'experience':
case 'education':
$this->showMultiple($fieldName, $field);
break;
default:
@ -257,6 +258,74 @@ class ExtendedProfileWidget extends Form
$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(
@ -306,6 +375,9 @@ class ExtendedProfileWidget extends Form
case 'experience':
$this->showExperience($name, $field);
break;
case 'education':
$this->showEducation($name, $field);
break;
default:
$this->out->text("TYPE: $type");
}
@ -343,6 +415,9 @@ class ExtendedProfileWidget extends Form
case 'experience':
$this->showEditableExperience($name, $field);
break;
case 'education':
$this->showEditableEducation($name, $field);
break;
default:
$out->input($id, null, "TYPE: $type");
}

View File

@ -140,26 +140,22 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
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() {
@ -174,11 +170,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
$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) {
@ -283,6 +275,14 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
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
*