3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('STATUSNET')) {
24 class ExtendedProfileWidget extends Widget
31 public function __construct(XMLOutputter $out=null, Profile $profile=null, $editable=false)
33 parent::__construct($out);
35 $this->profile = $profile;
36 $this->ext = new ExtendedProfile($this->profile);
38 $this->editable = $editable;
41 public function show()
43 $sections = $this->ext->getSections();
44 foreach ($sections as $name => $section) {
45 $this->showExtendedProfileSection($name, $section);
49 protected function showExtendedProfileSection($name, $section)
51 $this->out->element('h3', null, $section['label']);
52 $this->out->elementStart('table', array('class' => 'extended-profile'));
53 foreach ($section['fields'] as $fieldName => $field) {
54 $this->showExtendedProfileField($fieldName, $field);
56 $this->out->elementEnd('table');
59 protected function showExtendedProfileField($name, $field)
61 $this->out->elementStart('tr');
63 $this->out->element('th', null, $field['label']);
65 $this->out->elementStart('td');
66 if ($this->editable) {
67 $this->showEditableField($name, $field);
69 $this->showFieldValue($name, $field);
71 $this->out->elementEnd('td');
73 $this->out->elementEnd('tr');
76 protected function showFieldValue($name, $field)
78 $this->out->text($name);
81 protected function showEditableField($name, $field)
84 //$out = new HTMLOutputter();
86 $type = strval(@$field['type']);
87 $id = "extprofile-" . $name;
88 $value = 'placeholder';
93 $out->input($id, null, $value);
96 $out->textarea($id, null, $value);
99 $out->input($id, null, "TYPE: $type");