From 1f1616223a907bb2e2cfcc8c0b3ed549b8907609 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 9 Jun 2011 17:05:17 -0400 Subject: [PATCH] Allow changing the site logo from the site admin panel --- actions/siteadminpanel.php | 62 +++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/actions/siteadminpanel.php b/actions/siteadminpanel.php index 29813ca3b9..11636b0b5c 100644 --- a/actions/siteadminpanel.php +++ b/actions/siteadminpanel.php @@ -24,7 +24,7 @@ * @author Evan Prodromou * @author Zach Copley * @author Sarven Capadisli - * @copyright 2008-2010 StatusNet, Inc. + * @copyright 2008-2011 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -88,9 +88,19 @@ class SiteadminpanelAction extends AdminPanelAction function saveSettings() { static $settings = array( - 'site' => array('name', 'broughtby', 'broughtbyurl', - 'email', 'timezone', 'language', - 'site', 'textlimit', 'dupelimit'), + 'site' => array( + 'name', + 'broughtby', + 'broughtbyurl', + 'email', + 'timezone', + 'language', + 'site', + 'textlimit', + 'dupelimit', + 'logo', + 'ssllogo' + ) ); $values = array(); @@ -144,6 +154,19 @@ class SiteadminpanelAction extends AdminPanelAction $this->clientError(_('Not a valid email address.')); } + // Validate logos + if (!empty($values['site']['logo']) && + !Validate::uri($values['site']['logo'], array('allowed_schemes' => array('http', 'https')))) { + // TRANS: Client error displayed when a logo URL does is not valid. + $this->clientError(_('Invalid logo URL.')); + } + + if (!empty($values['site']['ssllogo']) && + !Validate::uri($values['site']['ssllogo'], array('allowed_schemes' => array('https')))) { + // TRANS: Client error displayed when an SSL logo URL is invalid. + $this->clientError(_('Invalid SSL logo URL.')); + } + // Validate timezone if (is_null($values['site']['timezone']) || @@ -251,6 +274,8 @@ class SiteAdminPanelForm extends AdminForm $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); + $this->showLogo(); + $this->out->elementStart('fieldset', array('id' => 'settings_admin_local')); // TRANS: Fieldset legend on site settings panel. $this->out->element('legend', null, _m('LEGEND','Local')); @@ -307,6 +332,35 @@ class SiteAdminPanelForm extends AdminForm $this->out->elementEnd('fieldset'); } + function showLogo() + { + $this->out->elementStart('fieldset', array('id' => 'settings_site_logo')); + // TRANS: Fieldset legend for form to change logo. + $this->out->element('legend', null, _('Logo')); + + $this->out->elementStart('ul', 'form_data'); + + $this->li(); + $this->input('logo', + // TRANS: Field label for StatusNet site logo. + _('Site logo'), + // TRANS: Title for field label for StatusNet site logo. + 'Logo for the site (full URL).'); + $this->unli(); + + $this->li(); + $this->input('ssllogo', + // TRANS: Field label for SSL StatusNet site logo. + _('SSL logo'), + // TRANS: Title for field label for SSL StatusNet site logo. + 'Logo to show on SSL pages (full URL).'); + $this->unli(); + + $this->out->elementEnd('ul'); + + $this->out->elementEnd('fieldset'); + } + /** * Action elements * -- 2.39.5