forked from GNUsocial/gnu-social
Extended profile - HTML layout for education entries
This commit is contained in:
parent
0ff7bf77e4
commit
bd238e9a4d
@ -164,6 +164,45 @@ class ExtendedProfile
|
|||||||
return $eArrays;
|
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
|
* Return all the sections of the extended profile
|
||||||
*
|
*
|
||||||
@ -241,16 +280,13 @@ class ExtendedProfile
|
|||||||
'experience' => array(
|
'experience' => array(
|
||||||
'label' => _m('Work experience'),
|
'label' => _m('Work experience'),
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'experience' => $this->getExperiences(),
|
'experience' => $this->getExperiences()
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'education' => array(
|
'education' => array(
|
||||||
'label' => _m('Education'),
|
'label' => _m('Education'),
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'education' => array(
|
'education' => $this->getEducation()
|
||||||
'type' => 'education',
|
|
||||||
'label' => _m('Institution'),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -107,6 +107,7 @@ class ExtendedProfileWidget extends Form
|
|||||||
switch($fieldName) {
|
switch($fieldName) {
|
||||||
case 'phone':
|
case 'phone':
|
||||||
case 'experience':
|
case 'experience':
|
||||||
|
case 'education':
|
||||||
$this->showMultiple($fieldName, $field);
|
$this->showMultiple($fieldName, $field);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -257,6 +258,74 @@ class ExtendedProfileWidget extends Form
|
|||||||
$this->out->elementEnd('div');
|
$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()
|
function showMultiControls()
|
||||||
{
|
{
|
||||||
$this->out->element(
|
$this->out->element(
|
||||||
@ -306,6 +375,9 @@ class ExtendedProfileWidget extends Form
|
|||||||
case 'experience':
|
case 'experience':
|
||||||
$this->showExperience($name, $field);
|
$this->showExperience($name, $field);
|
||||||
break;
|
break;
|
||||||
|
case 'education':
|
||||||
|
$this->showEducation($name, $field);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$this->out->text("TYPE: $type");
|
$this->out->text("TYPE: $type");
|
||||||
}
|
}
|
||||||
@ -343,6 +415,9 @@ class ExtendedProfileWidget extends Form
|
|||||||
case 'experience':
|
case 'experience':
|
||||||
$this->showEditableExperience($name, $field);
|
$this->showEditableExperience($name, $field);
|
||||||
break;
|
break;
|
||||||
|
case 'education':
|
||||||
|
$this->showEditableEducation($name, $field);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$out->input($id, null, "TYPE: $type");
|
$out->input($id, null, "TYPE: $type");
|
||||||
}
|
}
|
||||||
|
@ -140,26 +140,22 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
|
|
||||||
function findPhoneNumbers() {
|
function findPhoneNumbers() {
|
||||||
|
|
||||||
|
// Form vals look like this:
|
||||||
|
// 'extprofile-phone-1' => '11332',
|
||||||
|
// 'extprofile-phone-1-rel' => 'mobile',
|
||||||
|
|
||||||
$phones = $this->sliceParams('phone', 2);
|
$phones = $this->sliceParams('phone', 2);
|
||||||
$phoneTuples = array();
|
$phoneArray = array();
|
||||||
|
|
||||||
foreach ($phones as $phone) {
|
foreach ($phones as $phone) {
|
||||||
list($number, $rel) = array_values($phone);
|
list($number, $rel) = array_values($phone);
|
||||||
$phoneTuples[] = array(
|
$phoneArray[] = array(
|
||||||
'value' => $number,
|
'value' => $number,
|
||||||
'rel' => $rel
|
'rel' => $rel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $phoneTuples;
|
return $phoneArray;
|
||||||
}
|
|
||||||
|
|
||||||
function sliceParams($key, $size) {
|
|
||||||
$slice = array();
|
|
||||||
$params = $this->findMultiParams($key);
|
|
||||||
ksort($params);
|
|
||||||
$slice = $this->arraySplit($params, sizeof($params) / $size);
|
|
||||||
return $slice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function findExperiences() {
|
function findExperiences() {
|
||||||
@ -174,11 +170,7 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
$expArray = array();
|
$expArray = array();
|
||||||
|
|
||||||
foreach ($experiences as $exp) {
|
foreach ($experiences as $exp) {
|
||||||
|
|
||||||
common_debug('Experience: ' . var_export($exp, true));
|
|
||||||
|
|
||||||
list($company, $current, $end, $start) = array_values($exp);
|
list($company, $current, $end, $start) = array_values($exp);
|
||||||
|
|
||||||
$startTs = strtotime($start);
|
$startTs = strtotime($start);
|
||||||
|
|
||||||
if ($startTs === false) {
|
if ($startTs === false) {
|
||||||
@ -283,6 +275,14 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
|
|||||||
return $formVals;
|
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
|
* Save an extended profile field as a Profile_detail
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user