From 7a97243abfb64838b2108124b91e72a43b08bf3b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 2 Feb 2011 16:23:24 -0800 Subject: [PATCH] ExtendedProfile plugin initial checkin: stub mockup page --- .../ExtendedProfile/ExtendedProfilePlugin.php | 98 ++++++++++++++ plugins/ExtendedProfile/extendedprofile.php | 120 ++++++++++++++++++ .../ExtendedProfile/extendedprofilewidget.php | 72 +++++++++++ plugins/ExtendedProfile/profiledetail.css | 22 ++++ .../ExtendedProfile/profiledetailaction.php | 71 +++++++++++ .../profiledetailsettingsaction.php | 63 +++++++++ 6 files changed, 446 insertions(+) create mode 100644 plugins/ExtendedProfile/ExtendedProfilePlugin.php create mode 100644 plugins/ExtendedProfile/extendedprofile.php create mode 100644 plugins/ExtendedProfile/extendedprofilewidget.php create mode 100644 plugins/ExtendedProfile/profiledetail.css create mode 100644 plugins/ExtendedProfile/profiledetailaction.php create mode 100644 plugins/ExtendedProfile/profiledetailsettingsaction.php diff --git a/plugins/ExtendedProfile/ExtendedProfilePlugin.php b/plugins/ExtendedProfile/ExtendedProfilePlugin.php new file mode 100644 index 0000000000..36c8eaa232 --- /dev/null +++ b/plugins/ExtendedProfile/ExtendedProfilePlugin.php @@ -0,0 +1,98 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Extra profile bio-like fields + * + * @package ExtendedProfilePlugin + * @maintainer Brion Vibber + */ +class ExtendedProfilePlugin extends Plugin +{ + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'ExtendedProfile', + 'version' => STATUSNET_VERSION, + 'author' => 'Brion Vibber', + 'homepage' => 'http://status.net/wiki/Plugin:ExtendedProfile', + 'rawdescription' => + _m('UI extensions for additional profile fields.')); + + return true; + } + + /** + * Autoloader + * + * Loads our classes if they're requested. + * + * @param string $cls Class requested + * + * @return boolean hook return + */ + function onAutoload($cls) + { + $lower = strtolower($cls); + switch ($lower) + { + case 'extendedprofile': + case 'extendedprofilewidget': + case 'profiledetailaction': + case 'profiledetailsettingsaction': + require_once dirname(__FILE__) . '/' . $lower . '.php'; + return false; + default: + return true; + } + } + + /** + * Add paths to the router table + * + * Hook for RouterInitialized event. + * + * @param Net_URL_Mapper $m URL mapper + * + * @return boolean hook return + */ + function onStartInitializeRouter($m) + { + $m->connect(':nickname/detail', + array('action' => 'profiledetail'), + array('nickname' => Nickname::DISPLAY_FMT)); + $m->connect('settings/profile/detail', + array('action' => 'profiledetailsettings')); + + return true; + } + + function onEndAccountSettingsProfileMenuItem($widget, $menu) + { + // TRANS: Link title attribute in user account settings menu. + $title = _('Change additional profile settings'); + // TRANS: Link description in user account settings menu. + $widget->showMenuItem('profiledetailsettings',_m('Details'),$title); + return true; + } +} diff --git a/plugins/ExtendedProfile/extendedprofile.php b/plugins/ExtendedProfile/extendedprofile.php new file mode 100644 index 0000000000..18fef20331 --- /dev/null +++ b/plugins/ExtendedProfile/extendedprofile.php @@ -0,0 +1,120 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class ExtendedProfile +{ + function getSections() + { + return array( + 'basic' => array( + 'label' => _m('Personal'), + 'fields' => array( + 'fullname' => array( + 'label' => _m('Full name'), + 'profile' => 'fullname', + 'vcard' => 'fn', + ), + 'title' => array( + 'label' => _m('Title'), + 'vcard' => 'title', + ), + 'manager' => array( + 'label' => _m('Manager'), + 'type' => 'person', + 'vcard' => 'x-manager', + ), + 'location' => array( + 'label' => _m('Location'), + 'profile' => 'location' + ), + 'bio' => array( + 'label' => _m('Bio'), + 'type' => 'textarea', + 'profile' => 'bio', + ), + 'tags' => array( + 'label' => _m('Tags'), + 'type' => 'tags', + 'profile' => 'tags', + ), + ), + ), + 'contact' => array( + 'label' => _m('Contact'), + 'fields' => array( + 'phone' => array( + 'label' => _m('Phone'), + 'type' => 'phone', + 'multi' => true, + 'vcard' => 'tel', + ), + 'im' => array( + 'label' => _m('IM'), + 'type' => 'im', + 'multi' => true, + ), + 'website' => array( + 'label' => _m('Websites'), + 'type' => 'website', + 'multi' => true, + ), + ), + ), + 'personal' => array( + 'label' => _m('Personal'), + 'fields' => array( + 'birthday' => array( + 'label' => _m('Birthday'), + 'type' => 'date', + 'vcard' => 'bday', + ), + 'spouse' => array( + 'label' => _m('Spouse\'s name'), + 'vcard' => 'x-spouse', + ), + 'kids' => array( + 'label' => _m('Kids\' names') + ), + ), + ), + 'experience' => array( + 'label' => _m('Work experience'), + 'fields' => array( + 'experience' => array( + 'type' => 'experience', + 'label' => _m('Employer'), + ), + ), + ), + 'education' => array( + 'label' => _m('Education'), + 'fields' => array( + 'education' => array( + 'type' => 'education', + 'label' => _m('Institution'), + ), + ), + ), + ); + } +} diff --git a/plugins/ExtendedProfile/extendedprofilewidget.php b/plugins/ExtendedProfile/extendedprofilewidget.php new file mode 100644 index 0000000000..2ec99b1992 --- /dev/null +++ b/plugins/ExtendedProfile/extendedprofilewidget.php @@ -0,0 +1,72 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class ExtendedProfileWidget extends Widget +{ + const EDITABLE=true; + + protected $profile; + protected $ext; + + public function __construct(XMLOutputter $out=null, Profile $profile=null, $editable=false) + { + parent::__construct($out); + + $this->profile = $profile; + $this->ext = new ExtendedProfile($this->profile); + + $this->editable = $editable; + } + + public function show() + { + $sections = $this->ext->getSections(); + foreach ($sections as $name => $section) { + $this->showExtendedProfileSection($name, $section); + } + } + + protected function showExtendedProfileSection($name, $section) + { + $this->out->element('h3', null, $section['label']); + $this->out->elementStart('table', array('class' => 'extended-profile')); + foreach ($section['fields'] as $fieldName => $field) { + $this->showExtendedProfileField($fieldName, $field); + } + $this->out->elementEnd('table'); + } + + protected function showExtendedProfileField($name, $field) + { + $this->out->elementStart('tr'); + + $this->out->element('th', null, $field['label']); + + $this->out->elementStart('td'); + // @fixme field value + $this->out->text($name); + $this->out->elementEnd('td'); + + $this->out->elementEnd('tr'); + } +} diff --git a/plugins/ExtendedProfile/profiledetail.css b/plugins/ExtendedProfile/profiledetail.css new file mode 100644 index 0000000000..836b647a10 --- /dev/null +++ b/plugins/ExtendedProfile/profiledetail.css @@ -0,0 +1,22 @@ +/* Note the #content is only needed to override weird crap in default styles */ + +#content table.extended-profile { + width: 100%; + border-collapse: separate; + border-spacing: 8px; +} +#content table.extended-profile th { + color: #777; + background-color: #eee; + width: 150px; + + padding-top: 0; /* override bizarre theme defaults */ + + text-align: right; + padding-right: 8px; +} +#content table.extended-profile td { + padding: 0; /* override bizarre theme defaults */ + + padding-left: 8px; +} \ No newline at end of file diff --git a/plugins/ExtendedProfile/profiledetailaction.php b/plugins/ExtendedProfile/profiledetailaction.php new file mode 100644 index 0000000000..8c907eec2a --- /dev/null +++ b/plugins/ExtendedProfile/profiledetailaction.php @@ -0,0 +1,71 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class ProfileDetailAction extends ProfileAction +{ + function isReadOnly($args) + { + return true; + } + + function title() + { + return $this->profile->getFancyName(); + } + + function showLocalNav() + { + $nav = new PersonalGroupNav($this); + $nav->show(); + } + + function showStylesheets() { + parent::showStylesheets(); + $this->cssLink('plugins/ExtendedProfile/profiledetail.css'); + return true; + } + + function handle($args) + { + $this->showPage(); + } + + function showContent() + { + $cur = common_current_user(); + if ($cur && $cur->id == $this->profile->id) { // your own page + $this->elementStart('div', 'entity_actions'); + $this->elementStart('li', 'entity_edit'); + $this->element('a', array('href' => common_local_url('profiledetailsettings'), + // TRANS: Link title for link on user profile. + 'title' => _m('Edit extended profile settings')), + // TRANS: Link text for link on user profile. + _m('Edit')); + $this->elementEnd('li'); + $this->elementEnd('div'); + } + + $widget = new ExtendedProfileWidget($this, $this->profile, ExtendedProfileWidget::EDITABLE); + $widget->show(); + } +} diff --git a/plugins/ExtendedProfile/profiledetailsettingsaction.php b/plugins/ExtendedProfile/profiledetailsettingsaction.php new file mode 100644 index 0000000000..77d755c0b0 --- /dev/null +++ b/plugins/ExtendedProfile/profiledetailsettingsaction.php @@ -0,0 +1,63 @@ +. + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +class ProfileDetailSettingsAction extends AccountSettingsAction +{ + + function title() + { + return _m('Extended profile settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + function getInstructions() + { + // TRANS: Usage instructions for profile settings. + return _('You can update your personal profile info here '. + 'so people know more about you.'); + } + + function showStylesheets() { + parent::showStylesheets(); + $this->cssLink('plugins/ExtendedProfile/profiledetail.css'); + return true; + } + + function handle($args) + { + $this->showPage(); + } + + function showContent() + { + $cur = common_current_user(); + $profile = $cur->getProfile(); + + $widget = new ExtendedProfileWidget($this, $profile, ExtendedProfileWidget::EDITABLE); + $widget->show(); + } +} -- 2.39.5