]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ExtendedProfile/extendedprofilewidget.php
2ec99b1992c92a61a60f69829265168f693e4d19
[quix0rs-gnu-social.git] / plugins / ExtendedProfile / extendedprofilewidget.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2011, StatusNet, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('STATUSNET')) {
21     exit(1);
22 }
23
24 class ExtendedProfileWidget extends Widget
25 {
26     const EDITABLE=true;
27
28     protected $profile;
29     protected $ext;
30
31     public function __construct(XMLOutputter $out=null, Profile $profile=null, $editable=false)
32     {
33         parent::__construct($out);
34
35         $this->profile = $profile;
36         $this->ext = new ExtendedProfile($this->profile);
37
38         $this->editable = $editable;
39     }
40
41     public function show()
42     {
43         $sections = $this->ext->getSections();
44         foreach ($sections as $name => $section) {
45             $this->showExtendedProfileSection($name, $section);
46         }
47     }
48
49     protected function showExtendedProfileSection($name, $section)
50     {
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);
55         }
56         $this->out->elementEnd('table');
57     }
58
59     protected function showExtendedProfileField($name, $field)
60     {
61         $this->out->elementStart('tr');
62
63         $this->out->element('th', null, $field['label']);
64
65         $this->out->elementStart('td');
66         // @fixme field value
67         $this->out->text($name);
68         $this->out->elementEnd('td');
69
70         $this->out->elementEnd('tr');
71     }
72 }