3 * StatusNet, the distributed open-source microblogging tool
5 * Site notice administration panel
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.
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.
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/>.
24 * @author Zach Copley <zach@status.net>
25 * @copyright 2010 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/
30 if (!defined('STATUSNET')) {
34 require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
37 * Update the site-wide notice text
41 * @author Zach Copley <zach@status.net>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://status.net/
45 class SitenoticeadminpanelAction extends AdminPanelAction
48 * Returns the page title
50 * @return string page title
54 // TRANS: Page title for site-wide notice tab in admin panel.
55 return _('Site Notice');
59 * Instructions for using this form.
61 * @return string instructions
63 function getInstructions()
65 // TRANS: Instructions for site-wide notice tab in admin panel.
66 return _('Edit site-wide message');
70 * Show the site notice admin panel form
76 $form = new SiteNoticeAdminPanelForm($this);
82 * Save settings from the form
86 function saveSettings()
88 $siteNotice = $this->trimmed('site-notice');
90 // assert(all values are valid);
91 // This throws an exception on validation errors
93 $this->validate($siteNotice);
95 $config = new Config();
97 $result = Config::save('site', 'notice', $siteNotice);
100 // TRANS: Server error displayed when saving a site-wide notice was impossible.
101 $this->ServerError(_('Unable to save site notice.'));
105 function validate(&$siteNotice)
107 // Validate notice text
109 if (mb_strlen($siteNotice) > 255) {
111 // TRANS: Client error displayed when a site-wide notice was longer than allowed.
112 _('Maximum length for the site-wide notice is 255 characters.')
120 'deny_attribute' => 'id,style,on*'
123 $siteNotice = htmLawed($siteNotice, $config);
127 class SiteNoticeAdminPanelForm extends AdminForm
132 * @return int ID of the form
137 return 'form_site_notice_admin_panel';
143 * @return string class of the form
148 return 'form_settings';
154 * @return string URL of the action
159 return common_local_url('sitenoticeadminpanel');
163 * Data elements of the form
170 $this->out->elementStart('ul', 'form_data');
172 $this->out->elementStart('li');
173 $this->out->textarea(
175 // TRANS: Label for site-wide notice text field in admin panel.
176 _('Site notice text'),
177 common_config('site', 'notice'),
178 // TRANS: Tooltip for site-wide notice text field in admin panel.
179 _('Site-wide notice text (255 characters maximum; HTML allowed)')
181 $this->out->elementEnd('li');
183 $this->out->elementEnd('ul');
192 function formActions()
196 // TRANS: Button text for saving site notice in admin panel.
200 // TRANS: Button title to save site notice in admin panel.
201 _('Save site notice.')