]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/section.php
Avoid having to check for notices without rendered copies in upgrade.php
[quix0rs-gnu-social.git] / lib / section.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Base class for sections (sidebar widgets)
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Widget
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @copyright 2009 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
31
32 /**
33  * Base class for sections
34  *
35  * These are the widgets that show interesting data about a person
36  * group, or site.
37  *
38  * @category Widget
39  * @package  StatusNet
40  * @author   Evan Prodromou <evan@status.net>
41  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42  * @link     http://status.net/
43  */
44 abstract class Section extends Widget
45 {
46     /**
47      * Show the form
48      *
49      * Uses a recipe to output the form.
50      *
51      * @return void
52      * @see Widget::show()
53      */
54     function show()
55     {
56         $this->out->elementStart('div',
57                                  array('id' => $this->divId(),
58                                        'class' => 'section'));
59
60         $this->showTitle();
61
62         $have_more = $this->showContent();
63
64         if ($have_more) {
65             $this->showMore();
66         }
67
68         $this->out->elementEnd('div');
69     }
70
71     function showTitle()
72     {
73         $link = $this->link();
74         if (!empty($link)) {
75             $this->out->elementStart('h2');
76             $this->out->element('a', array('href' => $link), $this->title());
77             $this->out->elementEnd('h2');
78         } else {
79             $this->out->element('h2', null,
80                                 $this->title());
81         }
82     }
83
84     function showMore()
85     {
86         $this->out->elementStart('p');
87         $this->out->element('a', array('href' => $this->moreUrl(),
88                                        'class' => 'more'),
89                             $this->moreTitle());
90         $this->out->elementEnd('p');
91     }
92
93     abstract public function divId();
94
95     function title()
96     {
97         // TRANS: Default title for section/sidebar widget.
98         return _('Untitled section');
99     }
100
101     function link()
102     {
103         return null;
104     }
105
106     function showContent()
107     {
108         $this->out->element('p', null,
109                             // TRANS: Default content for section/sidebar widget.
110                             _('(None)'));
111         return false;
112     }
113
114     function moreUrl()
115     {
116         return null;
117     }
118
119     function moreTitle()
120     {
121         // TRANS: Default "More..." title for section/sidebar widget.
122         return _('More...');
123     }
124 }