2011-02-03 00:23:24 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2011, StatusNet, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('STATUSNET')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* Class for outputting a widget to display or edit
|
|
|
|
* extended profiles
|
|
|
|
*/
|
|
|
|
class ExtendedProfileWidget extends Form
|
2011-02-03 00:23:24 +00:00
|
|
|
{
|
2011-03-09 03:20:43 +00:00
|
|
|
const EDITABLE = true;
|
2011-02-03 00:23:24 +00:00
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* The parent profile
|
|
|
|
*
|
|
|
|
* @var Profile
|
|
|
|
*/
|
2011-02-03 00:23:24 +00:00
|
|
|
protected $profile;
|
2011-03-09 03:20:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The extended profile
|
|
|
|
*
|
2019-08-09 15:22:55 +01:00
|
|
|
* @var ExtendedProfile
|
2011-03-09 03:20:43 +00:00
|
|
|
*/
|
2011-02-03 00:23:24 +00:00
|
|
|
protected $ext;
|
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2019-08-09 15:22:55 +01:00
|
|
|
* @param Action $out
|
|
|
|
* @param Profile $profile
|
|
|
|
* @param boolean $editable
|
|
|
|
* @throws NoSuchUserException
|
2011-03-09 03:20:43 +00:00
|
|
|
*/
|
2019-08-09 15:22:55 +01:00
|
|
|
public function __construct(Action $out = null, Profile $profile = null, $editable = false)
|
2011-02-03 00:23:24 +00:00
|
|
|
{
|
|
|
|
parent::__construct($out);
|
|
|
|
|
|
|
|
$this->profile = $profile;
|
|
|
|
$this->ext = new ExtendedProfile($this->profile);
|
|
|
|
|
|
|
|
$this->editable = $editable;
|
|
|
|
}
|
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* Show the extended profile, or the edit form
|
|
|
|
*/
|
2011-02-03 00:23:24 +00:00
|
|
|
public function show()
|
2011-03-09 03:20:43 +00:00
|
|
|
{
|
|
|
|
if ($this->editable) {
|
|
|
|
parent::show();
|
|
|
|
} else {
|
|
|
|
$this->showSections();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show form data
|
|
|
|
*/
|
|
|
|
public function formData()
|
|
|
|
{
|
2011-03-16 06:51:28 +00:00
|
|
|
// For JQuery UI modal dialog
|
|
|
|
$this->out->elementStart(
|
2011-03-16 08:23:47 +00:00
|
|
|
'div',
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Title for extended profile entry deletion dialog.
|
|
|
|
array('id' => 'confirm-dialog', 'title' => _m('Confirmation Required'))
|
2011-03-16 06:51:28 +00:00
|
|
|
);
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Confirmation text for extended profile entry deletion dialog.
|
|
|
|
$this->out->text(_m('Really delete this entry?'));
|
2011-03-16 06:51:28 +00:00
|
|
|
$this->out->elementEnd('div');
|
2011-03-09 03:20:43 +00:00
|
|
|
$this->showSections();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show each section of the extended profile
|
|
|
|
*/
|
|
|
|
public function showSections()
|
2011-02-03 00:23:24 +00:00
|
|
|
{
|
|
|
|
$sections = $this->ext->getSections();
|
|
|
|
foreach ($sections as $name => $section) {
|
|
|
|
$this->showExtendedProfileSection($name, $section);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* Show an extended profile section
|
|
|
|
*
|
2019-08-09 15:22:55 +01:00
|
|
|
* @param string $name name of the section
|
|
|
|
* @param array $section array of fields for the section
|
|
|
|
* @throws Exception
|
2011-03-09 03:20:43 +00:00
|
|
|
*/
|
2011-02-03 00:23:24 +00:00
|
|
|
protected function showExtendedProfileSection($name, $section)
|
|
|
|
{
|
|
|
|
$this->out->element('h3', null, $section['label']);
|
|
|
|
$this->out->elementStart('table', array('class' => 'extended-profile'));
|
2011-03-11 00:57:41 +00:00
|
|
|
|
2011-02-03 00:23:24 +00:00
|
|
|
foreach ($section['fields'] as $fieldName => $field) {
|
2019-08-09 15:22:55 +01:00
|
|
|
switch ($fieldName) {
|
|
|
|
case 'phone':
|
|
|
|
case 'im':
|
|
|
|
case 'website':
|
|
|
|
case 'experience':
|
|
|
|
case 'education':
|
|
|
|
$this->showMultiple($fieldName, $field);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->showExtendedProfileField($fieldName, $field);
|
2011-03-11 00:57:41 +00:00
|
|
|
}
|
2011-02-03 00:23:24 +00:00
|
|
|
}
|
|
|
|
$this->out->elementEnd('table');
|
|
|
|
}
|
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* Show an extended profile field
|
|
|
|
*
|
2019-08-09 15:22:55 +01:00
|
|
|
* @param string $name name of the field
|
|
|
|
* @param array $field set of key/value pairs for the field
|
|
|
|
* @throws Exception
|
2011-03-09 03:20:43 +00:00
|
|
|
*/
|
2011-02-03 00:23:24 +00:00
|
|
|
protected function showExtendedProfileField($name, $field)
|
|
|
|
{
|
|
|
|
$this->out->elementStart('tr');
|
|
|
|
|
2019-08-09 15:22:55 +01:00
|
|
|
$this->out->element('th', str_replace(' ', '_', strtolower($field['label'])), $field['label']);
|
2011-02-03 00:23:24 +00:00
|
|
|
|
|
|
|
$this->out->elementStart('td');
|
2011-02-03 00:38:01 +00:00
|
|
|
if ($this->editable) {
|
|
|
|
$this->showEditableField($name, $field);
|
|
|
|
} else {
|
|
|
|
$this->showFieldValue($name, $field);
|
|
|
|
}
|
2011-02-03 00:23:24 +00:00
|
|
|
$this->out->elementEnd('td');
|
|
|
|
|
|
|
|
$this->out->elementEnd('tr');
|
|
|
|
}
|
2011-02-03 00:38:01 +00:00
|
|
|
|
2019-08-09 15:22:55 +01:00
|
|
|
protected function showMultiple($name, $fields)
|
|
|
|
{
|
2011-03-14 22:29:11 +00:00
|
|
|
foreach ($fields as $field) {
|
|
|
|
$this->showExtendedProfileField($name, $field);
|
2011-03-11 00:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-15 17:10:18 +00:00
|
|
|
// XXX: showPhone, showIm and showWebsite all work the same, so
|
|
|
|
// combine
|
2011-03-14 08:49:46 +00:00
|
|
|
protected function showPhone($name, $field)
|
2011-03-10 22:14:21 +00:00
|
|
|
{
|
|
|
|
$this->out->elementStart('div', array('class' => 'phone-display'));
|
2011-03-16 21:52:42 +00:00
|
|
|
if (!empty($field['value'])) {
|
|
|
|
$this->out->text($field['value']);
|
|
|
|
if (!empty($field['rel'])) {
|
2019-08-09 15:22:55 +01:00
|
|
|
// TRANS: Value between parentheses (phone number, website, or IM address).
|
|
|
|
$outtext = sprintf(_m('(%s)'), $field['rel']);
|
|
|
|
$this->out->text(' ' . $outtext);
|
2011-03-16 21:52:42 +00:00
|
|
|
}
|
2011-03-11 00:57:41 +00:00
|
|
|
}
|
2011-03-10 22:14:21 +00:00
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-15 05:38:34 +00:00
|
|
|
protected function showIm($name, $field)
|
|
|
|
{
|
|
|
|
$this->out->elementStart('div', array('class' => 'im-display'));
|
|
|
|
$this->out->text($field['value']);
|
|
|
|
if (!empty($field['rel'])) {
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Value between parentheses (phone number, website, or IM address).
|
2019-08-09 15:22:55 +01:00
|
|
|
$outtext = sprintf(_m('(%s)'), $field['rel']);
|
|
|
|
$this->out->text(' ' . $outtext);
|
2011-03-15 05:38:34 +00:00
|
|
|
}
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-15 17:10:18 +00:00
|
|
|
protected function showWebsite($name, $field)
|
|
|
|
{
|
|
|
|
$this->out->elementStart('div', array('class' => 'website-display'));
|
2011-03-16 08:23:47 +00:00
|
|
|
|
|
|
|
$url = $field['value'];
|
|
|
|
|
|
|
|
$this->out->element(
|
|
|
|
"a",
|
|
|
|
array(
|
2019-08-09 15:22:55 +01:00
|
|
|
'href' => $url,
|
|
|
|
'class' => 'extended-profile-link',
|
2011-03-16 08:23:47 +00:00
|
|
|
'target' => "_blank"
|
|
|
|
),
|
|
|
|
$url
|
|
|
|
);
|
|
|
|
|
2011-03-15 17:10:18 +00:00
|
|
|
if (!empty($field['rel'])) {
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Value between parentheses (phone number, website, or IM address).
|
2019-08-09 15:22:55 +01:00
|
|
|
$outtext = sprintf(_m('(%s)'), $field['rel']);
|
|
|
|
$this->out->text(' ' . $outtext);
|
2011-03-15 17:10:18 +00:00
|
|
|
}
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-15 05:38:34 +00:00
|
|
|
protected function showEditableIm($name, $field)
|
|
|
|
{
|
|
|
|
$index = isset($field['index']) ? $field['index'] : 0;
|
2019-08-09 15:22:55 +01:00
|
|
|
$id = "extprofile-$name-$index";
|
|
|
|
$rel = $id . '-rel';
|
2011-03-15 05:38:34 +00:00
|
|
|
$this->out->elementStart(
|
2019-08-09 15:22:55 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2011-03-15 05:38:34 +00:00
|
|
|
'id' => $id . '-edit',
|
2011-03-15 17:08:41 +00:00
|
|
|
'class' => 'im-item'
|
2011-03-15 05:38:34 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->out->input(
|
|
|
|
$id,
|
|
|
|
null,
|
|
|
|
isset($field['value']) ? $field['value'] : null
|
|
|
|
);
|
|
|
|
$this->out->dropdown(
|
|
|
|
$id . '-rel',
|
|
|
|
'Type',
|
|
|
|
array(
|
|
|
|
'jabber' => 'Jabber',
|
2019-08-09 15:22:55 +01:00
|
|
|
'gtalk' => 'GTalk',
|
|
|
|
'aim' => 'AIM',
|
|
|
|
'yahoo' => 'Yahoo! Messenger',
|
|
|
|
'msn' => 'MSN',
|
|
|
|
'skype' => 'Skype',
|
|
|
|
'other' => 'Other'
|
2011-03-15 05:38:34 +00:00
|
|
|
),
|
|
|
|
null,
|
|
|
|
false,
|
|
|
|
isset($field['rel']) ? $field['rel'] : null
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->showMultiControls();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-10 22:14:21 +00:00
|
|
|
protected function showEditablePhone($name, $field)
|
|
|
|
{
|
2011-03-14 08:49:46 +00:00
|
|
|
$index = isset($field['index']) ? $field['index'] : 0;
|
2019-08-09 15:22:55 +01:00
|
|
|
$id = "extprofile-$name-$index";
|
|
|
|
$rel = $id . '-rel';
|
2011-03-13 23:32:13 +00:00
|
|
|
$this->out->elementStart(
|
2019-08-09 15:22:55 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2011-03-13 23:32:13 +00:00
|
|
|
'id' => $id . '-edit',
|
2011-03-15 17:08:41 +00:00
|
|
|
'class' => 'phone-item'
|
2011-03-13 23:32:13 +00:00
|
|
|
)
|
|
|
|
);
|
2011-03-14 08:49:46 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id,
|
|
|
|
null,
|
|
|
|
isset($field['value']) ? $field['value'] : null
|
|
|
|
);
|
2011-03-10 22:14:21 +00:00
|
|
|
$this->out->dropdown(
|
|
|
|
$id . '-rel',
|
|
|
|
'Type',
|
|
|
|
array(
|
|
|
|
'office' => 'Office',
|
|
|
|
'mobile' => 'Mobile',
|
2019-08-09 15:22:55 +01:00
|
|
|
'home' => 'Home',
|
|
|
|
'pager' => 'Pager',
|
|
|
|
'other' => 'Other'
|
2011-03-10 22:14:21 +00:00
|
|
|
),
|
|
|
|
null,
|
|
|
|
false,
|
2011-03-14 08:49:46 +00:00
|
|
|
isset($field['rel']) ? $field['rel'] : null
|
2011-03-10 22:14:21 +00:00
|
|
|
);
|
2011-03-14 08:49:46 +00:00
|
|
|
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->showMultiControls();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-15 17:10:18 +00:00
|
|
|
protected function showEditableWebsite($name, $field)
|
|
|
|
{
|
|
|
|
$index = isset($field['index']) ? $field['index'] : 0;
|
2019-08-09 15:22:55 +01:00
|
|
|
$id = "extprofile-$name-$index";
|
|
|
|
$rel = $id . '-rel';
|
2011-03-15 17:10:18 +00:00
|
|
|
$this->out->elementStart(
|
2019-08-09 15:22:55 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2011-03-15 17:10:18 +00:00
|
|
|
'id' => $id . '-edit',
|
2011-03-16 07:34:00 +00:00
|
|
|
'class' => 'website-item'
|
2011-03-15 17:10:18 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->out->input(
|
|
|
|
$id,
|
|
|
|
null,
|
|
|
|
isset($field['value']) ? $field['value'] : null
|
|
|
|
);
|
|
|
|
$this->out->dropdown(
|
|
|
|
$id . '-rel',
|
|
|
|
'Type',
|
|
|
|
array(
|
2019-08-09 15:22:55 +01:00
|
|
|
'blog' => 'Blog',
|
2011-03-15 17:10:18 +00:00
|
|
|
'homepage' => 'Homepage',
|
|
|
|
'facebook' => 'Facebook',
|
|
|
|
'linkedin' => 'LinkedIn',
|
2019-08-09 15:22:55 +01:00
|
|
|
'flickr' => 'Flickr',
|
|
|
|
'other' => 'Other',
|
|
|
|
'twitter' => 'Twitter'
|
2011-03-15 17:10:18 +00:00
|
|
|
),
|
|
|
|
null,
|
|
|
|
false,
|
|
|
|
isset($field['rel']) ? $field['rel'] : null
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->showMultiControls();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-14 22:29:11 +00:00
|
|
|
protected function showExperience($name, $field)
|
|
|
|
{
|
2011-03-15 02:09:22 +00:00
|
|
|
$this->out->elementStart('div', 'experience-item');
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field label in experience area of extended profile.
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('Company'));
|
2011-03-16 04:55:47 +00:00
|
|
|
|
2011-03-16 08:26:53 +00:00
|
|
|
if (!empty($field['company'])) {
|
|
|
|
$this->out->element('div', 'field', $field['company']);
|
2011-03-16 04:55:47 +00:00
|
|
|
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one start a position or education).
|
2011-03-16 08:26:53 +00:00
|
|
|
$this->out->element('div', 'label', _m('Start'));
|
|
|
|
$this->out->element(
|
|
|
|
'div',
|
|
|
|
array('class' => 'field date'),
|
2019-08-09 15:22:55 +01:00
|
|
|
date(
|
|
|
|
'j M Y',
|
|
|
|
strtotime($field['start'])
|
2011-03-16 08:26:53 +00:00
|
|
|
)
|
|
|
|
);
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one end a position or education).
|
2011-03-16 08:26:53 +00:00
|
|
|
$this->out->element('div', 'label', _m('End'));
|
2011-03-15 02:09:22 +00:00
|
|
|
$this->out->element(
|
|
|
|
'div',
|
2011-03-16 08:26:53 +00:00
|
|
|
array('class' => 'field date'),
|
2019-08-09 15:22:55 +01:00
|
|
|
date(
|
|
|
|
'j M Y',
|
|
|
|
strtotime($field['end'])
|
2011-03-16 08:26:53 +00:00
|
|
|
)
|
2011-03-15 02:09:22 +00:00
|
|
|
);
|
2011-03-16 08:26:53 +00:00
|
|
|
|
|
|
|
if ($field['current']) {
|
|
|
|
$this->out->element(
|
|
|
|
'div',
|
|
|
|
array('class' => 'field current'),
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field value in experience area of extended profile (one still holds a position).
|
|
|
|
_m('(Current)')
|
2011-03-16 08:26:53 +00:00
|
|
|
);
|
|
|
|
}
|
2011-03-14 22:29:11 +00:00
|
|
|
}
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function showEditableExperience($name, $field)
|
|
|
|
{
|
|
|
|
$index = isset($field['index']) ? $field['index'] : 0;
|
2019-08-09 15:22:55 +01:00
|
|
|
$id = "extprofile-$name-$index";
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->out->elementStart(
|
2019-08-09 15:22:55 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2011-03-14 22:29:11 +00:00
|
|
|
'id' => $id . '-edit',
|
2011-03-15 17:08:41 +00:00
|
|
|
'class' => 'experience-item'
|
2011-03-14 22:29:11 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field label in experience edit area of extended profile (which company does one work for).
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('Company'));
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id,
|
|
|
|
null,
|
|
|
|
isset($field['company']) ? $field['company'] : null
|
|
|
|
);
|
|
|
|
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one start a position or education).
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('Start'));
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id . '-start',
|
2011-03-15 17:08:41 +00:00
|
|
|
null,
|
2011-03-16 04:55:47 +00:00
|
|
|
isset($field['start']) ? date('j M Y', strtotime($field['start'])) : null
|
2011-03-14 22:29:11 +00:00
|
|
|
);
|
|
|
|
|
2019-08-09 15:22:55 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one end a position or education).
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('End'));
|
2011-03-16 09:41:32 +00:00
|
|
|
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id . '-end',
|
2011-03-15 17:08:41 +00:00
|
|
|
null,
|
2011-03-16 04:55:47 +00:00
|
|
|
isset($field['end']) ? date('j M Y', strtotime($field['end'])) : null
|
2011-03-14 22:29:11 +00:00
|
|
|
);
|
2011-03-15 00:27:50 +00:00
|
|
|
$this->out->hidden(
|
|
|
|
$id . '-current',
|
|
|
|
'false'
|
|
|
|
);
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->elementStart('div', 'current-checkbox');
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->out->checkbox(
|
|
|
|
$id . '-current',
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Checkbox label in experience edit area of extended profile (one still works at a company).
|
2011-03-14 22:29:11 +00:00
|
|
|
_m('Current'),
|
|
|
|
$field['current']
|
|
|
|
);
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->elementEnd('div');
|
|
|
|
|
2011-03-14 22:29:11 +00:00
|
|
|
$this->showMultiControls();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2011-03-15 03:58:35 +00:00
|
|
|
protected function showEducation($name, $field)
|
|
|
|
{
|
|
|
|
$this->out->elementStart('div', 'education-item');
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field label in education area of extended profile.
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('Institution'));
|
2011-03-16 17:58:13 +00:00
|
|
|
if (!empty($field['school'])) {
|
|
|
|
$this->out->element('div', 'field', $field['school']);
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile for specifying an academic degree.
|
2011-03-16 17:58:13 +00:00
|
|
|
$this->out->element('div', 'label', _m('Degree'));
|
|
|
|
$this->out->element('div', 'field', $field['degree']);
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field label in education area of extended profile.
|
2011-03-16 17:58:13 +00:00
|
|
|
$this->out->element('div', 'label', _m('Description'));
|
|
|
|
$this->out->element('div', 'field', $field['description']);
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one start a position or education).
|
2011-03-16 17:58:13 +00:00
|
|
|
$this->out->element('div', 'label', _m('Start'));
|
|
|
|
$this->out->element(
|
|
|
|
'div',
|
|
|
|
array('class' => 'field date'),
|
2019-08-09 15:22:55 +01:00
|
|
|
date(
|
|
|
|
'j M Y',
|
|
|
|
strtotime($field['start'])
|
2011-03-16 17:58:13 +00:00
|
|
|
)
|
|
|
|
);
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one end a position or education).
|
2011-03-16 17:58:13 +00:00
|
|
|
$this->out->element('div', 'label', _m('End'));
|
|
|
|
$this->out->element(
|
|
|
|
'div',
|
|
|
|
array('class' => 'field date'),
|
2019-08-09 15:22:55 +01:00
|
|
|
date(
|
|
|
|
'j M Y',
|
|
|
|
strtotime($field['end'])
|
2011-03-16 17:58:13 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function showEditableEducation($name, $field)
|
|
|
|
{
|
|
|
|
$index = isset($field['index']) ? $field['index'] : 0;
|
2019-08-09 15:22:55 +01:00
|
|
|
$id = "extprofile-$name-$index";
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->elementStart(
|
2019-08-09 15:22:55 +01:00
|
|
|
'div',
|
|
|
|
array(
|
2011-03-15 03:58:35 +00:00
|
|
|
'id' => $id . '-edit',
|
2011-03-15 17:08:41 +00:00
|
|
|
'class' => 'education-item'
|
2011-03-15 03:58:35 +00:00
|
|
|
)
|
|
|
|
);
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field label in education edit area of extended profile.
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('Institution'));
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id,
|
|
|
|
null,
|
|
|
|
isset($field['school']) ? $field['school'] : null
|
|
|
|
);
|
|
|
|
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile for specifying an academic degree.
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->element('div', 'label', _m('Degree'));
|
|
|
|
$this->out->input(
|
2011-03-15 05:02:24 +00:00
|
|
|
$id . '-degree',
|
2011-03-15 03:58:35 +00:00
|
|
|
null,
|
|
|
|
isset($field['degree']) ? $field['degree'] : null
|
|
|
|
);
|
|
|
|
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Field label in education edit area of extended profile.
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->element('div', 'label', _m('Description'));
|
|
|
|
|
2011-03-15 22:35:00 +00:00
|
|
|
$this->out->textarea(
|
2011-03-15 05:02:24 +00:00
|
|
|
$id . '-description',
|
2011-03-15 03:58:35 +00:00
|
|
|
null,
|
|
|
|
isset($field['description']) ? $field['description'] : null
|
|
|
|
);
|
|
|
|
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one start a position or education).
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('Start'));
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id . '-start',
|
2011-03-15 17:08:41 +00:00
|
|
|
null,
|
2011-04-07 21:25:16 +01:00
|
|
|
// @todo FIXME: does date format need i18n? If so, should probly be dealt with in core.
|
2011-03-16 04:55:47 +00:00
|
|
|
isset($field['start']) ? date('j M Y', strtotime($field['start'])) : null
|
2011-03-15 03:58:35 +00:00
|
|
|
);
|
|
|
|
|
2011-05-20 15:03:29 +01:00
|
|
|
// TRANS: Field label in extended profile (when did one end a position or education).
|
2011-03-15 17:08:41 +00:00
|
|
|
$this->out->element('div', 'label', _m('End'));
|
2011-03-15 03:58:35 +00:00
|
|
|
$this->out->input(
|
|
|
|
$id . '-end',
|
2011-03-15 17:08:41 +00:00
|
|
|
null,
|
2011-04-07 21:25:16 +01:00
|
|
|
// @todo FIXME: does date format need i18n? If so, should probly be dealt with in core.
|
2011-03-16 04:55:47 +00:00
|
|
|
isset($field['end']) ? date('j M Y', strtotime($field['end'])) : null
|
2011-03-15 03:58:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->showMultiControls();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
2019-08-09 15:22:55 +01:00
|
|
|
public function showMultiControls()
|
2011-03-14 22:29:11 +00:00
|
|
|
{
|
2011-03-14 08:49:46 +00:00
|
|
|
$this->out->element(
|
|
|
|
'a',
|
|
|
|
array(
|
2011-03-15 17:08:41 +00:00
|
|
|
'class' => 'remove_row',
|
2011-03-14 08:49:46 +00:00
|
|
|
'href' => 'javascript://',
|
2011-03-16 04:23:34 +00:00
|
|
|
'style' => 'display: none;'
|
2011-03-14 08:49:46 +00:00
|
|
|
),
|
2011-03-15 17:08:41 +00:00
|
|
|
'-'
|
2011-03-14 08:49:46 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->out->element(
|
|
|
|
'a',
|
|
|
|
array(
|
2011-03-15 17:08:41 +00:00
|
|
|
'class' => 'add_row',
|
2011-03-14 08:49:46 +00:00
|
|
|
'href' => 'javascript://',
|
2011-03-16 04:23:34 +00:00
|
|
|
'style' => 'display: none;'
|
2011-03-14 08:49:46 +00:00
|
|
|
),
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Link description in extended profile page to add another profile element.
|
|
|
|
_m('Add another item')
|
2011-03-14 08:49:46 +00:00
|
|
|
);
|
2011-03-14 22:29:11 +00:00
|
|
|
}
|
2011-03-14 08:49:46 +00:00
|
|
|
|
2011-03-14 22:29:11 +00:00
|
|
|
/**
|
|
|
|
* Outputs the value of a field
|
|
|
|
*
|
2019-08-09 15:22:55 +01:00
|
|
|
* @param string $name name of the field
|
|
|
|
* @param array $field set of key/value pairs for the field
|
2011-03-14 22:29:11 +00:00
|
|
|
*/
|
|
|
|
protected function showFieldValue($name, $field)
|
|
|
|
{
|
|
|
|
$type = strval(@$field['type']);
|
|
|
|
|
2019-08-09 15:22:55 +01:00
|
|
|
switch ($type) {
|
|
|
|
case '':
|
|
|
|
case 'text':
|
|
|
|
case 'textarea':
|
|
|
|
case 'person':
|
|
|
|
$this->out->text($this->ext->getTextValue($name));
|
|
|
|
break;
|
|
|
|
case 'custom-text':
|
|
|
|
case 'custom-textarea':
|
2019-08-10 20:04:43 +01:00
|
|
|
$this->out->text(isset($field['value']) ? $field['value'] : null);
|
2019-08-09 15:22:55 +01:00
|
|
|
break;
|
|
|
|
case 'date':
|
|
|
|
$value = $this->ext->getDateValue($name);
|
|
|
|
if (!empty($value)) {
|
|
|
|
$this->out->element(
|
|
|
|
'div',
|
|
|
|
array('class' => 'field date'),
|
|
|
|
date('j M Y', strtotime($value))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'tags':
|
|
|
|
$this->out->text($this->ext->getTags());
|
|
|
|
break;
|
|
|
|
case 'phone':
|
|
|
|
$this->showPhone($name, $field);
|
|
|
|
break;
|
|
|
|
case 'website':
|
|
|
|
$this->showWebsite($name, $field);
|
|
|
|
break;
|
|
|
|
case 'im':
|
|
|
|
$this->showIm($name, $field);
|
|
|
|
break;
|
|
|
|
case 'experience':
|
|
|
|
$this->showExperience($name, $field);
|
|
|
|
break;
|
|
|
|
case 'education':
|
|
|
|
$this->showEducation($name, $field);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->out->text("TYPE: $type");
|
2011-03-14 22:29:11 +00:00
|
|
|
}
|
2011-02-03 00:38:01 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 03:20:43 +00:00
|
|
|
/**
|
|
|
|
* Show an editable version of the field
|
|
|
|
*
|
2019-08-09 15:22:55 +01:00
|
|
|
* @param string $name name fo the field
|
|
|
|
* @param array $field array of key/value pairs for the field
|
|
|
|
* @throws Exception
|
2011-03-09 03:20:43 +00:00
|
|
|
*/
|
2011-02-03 00:38:01 +00:00
|
|
|
protected function showEditableField($name, $field)
|
|
|
|
{
|
|
|
|
$out = $this->out;
|
2011-03-09 03:20:43 +00:00
|
|
|
|
2011-02-03 00:38:01 +00:00
|
|
|
$type = strval(@$field['type']);
|
|
|
|
$id = "extprofile-" . $name;
|
2011-03-09 03:20:43 +00:00
|
|
|
|
2011-02-03 00:38:01 +00:00
|
|
|
$value = 'placeholder';
|
|
|
|
|
|
|
|
switch ($type) {
|
2019-08-09 15:22:55 +01:00
|
|
|
case '':
|
|
|
|
case 'text':
|
|
|
|
case 'person':
|
|
|
|
$out->input($id, null, $this->ext->getTextValue($name));
|
|
|
|
break;
|
|
|
|
case 'custom-text':
|
|
|
|
case 'custom-textarea':
|
|
|
|
$out->input($id, null, isset($field['value']) ? $field['value'] : null);
|
|
|
|
break;
|
|
|
|
case 'date':
|
|
|
|
$value = $this->ext->getDateValue($name);
|
|
|
|
$out->input(
|
|
|
|
$id,
|
|
|
|
null,
|
|
|
|
empty($value) ? null : date('j M Y', strtotime($value))
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'textarea':
|
|
|
|
$out->textarea($id, null, $this->ext->getTextValue($name));
|
|
|
|
break;
|
|
|
|
case 'tags':
|
|
|
|
$out->input($id, null, $this->ext->getTags());
|
|
|
|
break;
|
|
|
|
case 'phone':
|
|
|
|
$this->showEditablePhone($name, $field);
|
|
|
|
break;
|
|
|
|
case 'im':
|
|
|
|
$this->showEditableIm($name, $field);
|
|
|
|
break;
|
|
|
|
case 'website':
|
|
|
|
$this->showEditableWebsite($name, $field);
|
|
|
|
break;
|
|
|
|
case 'experience':
|
|
|
|
$this->showEditableExperience($name, $field);
|
|
|
|
break;
|
|
|
|
case 'education':
|
|
|
|
$this->showEditableEducation($name, $field);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// TRANS: Field label for undefined field in extended profile.
|
|
|
|
$out->input($id, null, sprintf(_m('TYPE: %s'), $type));
|
2011-02-03 00:38:01 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-09 03:20:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Action elements
|
|
|
|
*
|
|
|
|
* @return void
|
2019-08-09 15:22:55 +01:00
|
|
|
* @throws Exception
|
2011-03-09 03:20:43 +00:00
|
|
|
*/
|
2019-08-09 15:22:55 +01:00
|
|
|
public function formActions()
|
2011-03-09 03:20:43 +00:00
|
|
|
{
|
|
|
|
$this->out->submit(
|
|
|
|
'save',
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: Button text for saving extended profile properties.
|
2019-08-09 15:22:55 +01:00
|
|
|
_m('BUTTON', 'Save'),
|
2011-03-09 03:20:43 +00:00
|
|
|
'submit form_action-secondary',
|
|
|
|
'save',
|
2011-04-07 21:25:16 +01:00
|
|
|
// TRANS: .
|
|
|
|
// TRANS: Button title for saving extended profile properties.
|
2011-03-30 21:30:23 +01:00
|
|
|
_m('Save details')
|
2019-08-09 15:22:55 +01:00
|
|
|
);
|
2011-03-09 03:20:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ID of the form
|
|
|
|
*
|
|
|
|
* @return string ID of the form
|
|
|
|
*/
|
2019-08-09 15:22:55 +01:00
|
|
|
public function id()
|
2011-03-09 03:20:43 +00:00
|
|
|
{
|
|
|
|
return 'profile-details-' . $this->profile->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* class of the form
|
|
|
|
*
|
|
|
|
* @return string of the form class
|
|
|
|
*/
|
2019-08-09 15:22:55 +01:00
|
|
|
public function formClass()
|
2011-03-09 03:20:43 +00:00
|
|
|
{
|
2011-03-15 17:08:41 +00:00
|
|
|
return 'form_profile_details form_settings';
|
2011-03-09 03:20:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action of the form
|
|
|
|
*
|
|
|
|
* @return string URL of the action
|
|
|
|
*/
|
2019-08-09 15:22:55 +01:00
|
|
|
public function action()
|
2011-03-09 03:20:43 +00:00
|
|
|
{
|
|
|
|
return common_local_url('profiledetailsettings');
|
|
|
|
}
|
2011-02-03 00:23:24 +00:00
|
|
|
}
|