--- /dev/null
+<?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);
+}
+
+/**
+ * Extra profile bio-like fields
+ *
+ * @package ExtendedProfilePlugin
+ * @maintainer Brion Vibber <brion@status.net>
+ */
+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;
+ }
+}
--- /dev/null
+<?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);
+}
+
+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'),
+ ),
+ ),
+ ),
+ );
+ }
+}
--- /dev/null
+<?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);
+}
+
+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');
+ }
+}
--- /dev/null
+/* 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
--- /dev/null
+<?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);
+}
+
+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();
+ }
+}
--- /dev/null
+<?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);
+}
+
+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();
+ }
+}