123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
- class SitenoticeadminpanelAction extends AdminPanelAction
- {
-
- function title()
- {
-
- return _('Site Notice');
- }
-
- function getInstructions()
- {
-
- return _('Edit site-wide message');
- }
-
- function showForm()
- {
- $form = new SiteNoticeAdminPanelForm($this);
- $form->show();
- return;
- }
-
- function saveSettings()
- {
- $siteNotice = $this->trimmed('site-notice');
-
-
- $this->validate($siteNotice);
- $config = new Config();
- $result = Config::save('site', 'notice', $siteNotice);
- if (!$result) {
-
- $this->ServerError(_('Unable to save site notice.'));
- }
- }
- function validate(&$siteNotice)
- {
-
- if (mb_strlen($siteNotice) > 255) {
- $this->clientError(
-
- _('Maximum length for the site-wide notice is 255 characters.')
- );
- }
-
- $config = array(
- 'safe' => 1,
- 'deny_attribute' => 'id,style,on*'
- );
- $siteNotice = htmLawed($siteNotice, $config);
- }
- }
- class SiteNoticeAdminPanelForm extends AdminForm
- {
-
- function id()
- {
- return 'form_site_notice_admin_panel';
- }
-
- function formClass()
- {
- return 'form_settings';
- }
-
- function action()
- {
- return common_local_url('sitenoticeadminpanel');
- }
-
- function formData()
- {
- $this->out->elementStart('ul', 'form_data');
- $this->out->elementStart('li');
- $this->out->textarea(
- 'site-notice',
-
- _('Site notice text'),
- common_config('site', 'notice'),
-
- _('Site-wide notice text (255 characters maximum; HTML allowed)')
- );
- $this->out->elementEnd('li');
- $this->out->elementEnd('ul');
- }
-
- function formActions()
- {
- $this->out->submit(
- 'submit',
-
- _m('BUTTON','Save'),
- 'submit',
- null,
-
- _('Save site notice.')
- );
- }
- }
|