4 * @file AdminSettingsHandler.inc.php
6 * Copyright (c) 2003-2008 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9 * @class AdminSettingsHandler
10 * @ingroup pages_admin
12 * @brief Handle requests for changing site admin settings.
14 * $Id: AdminSettingsHandler.inc.php,v 1.6 2009/09/22 21:27:34 asmecher Exp $
17 import('pages.admin.AdminHandler');
19 class AdminSettingsHandler
extends AdminHandler
{
20 function AdminSettingsHandler() {
21 parent
::AdminHandler();
25 * Display form to modify site settings.
29 $this->setupTemplate(true);
31 import('admin.form.SiteSettingsForm');
33 $settingsForm = new SiteSettingsForm();
34 if ($settingsForm->isLocaleResubmit()) {
35 $settingsForm->readInputData();
37 $settingsForm->initData();
39 $settingsForm->display();
43 * Validate and save changes to site settings.
45 function saveSettings() {
47 $this->setupTemplate(true);
48 $site =& Request
::getSite();
50 import('admin.form.SiteSettingsForm');
52 $settingsForm = new SiteSettingsForm();
53 $settingsForm->readInputData();
55 if (Request
::getUserVar('uploadSiteStyleSheet')) {
56 if (!$settingsForm->uploadSiteStyleSheet()) {
57 $settingsForm->addError('siteStyleSheet', Locale
::translate('admin.settings.siteStyleSheetInvalid'));
59 } elseif (Request
::getUserVar('deleteSiteStyleSheet')) {
60 $publicFileManager = new PublicFileManager();
61 $publicFileManager->removeSiteFile($site->getSiteStyleFilename());
62 } elseif (Request
::getUserVar('uploadPageHeaderTitleImage')) {
63 if (!$settingsForm->uploadPageHeaderTitleImage($settingsForm->getFormLocale())) {
64 $settingsForm->addError('pageHeaderTitleImage', Locale
::translate('admin.settings.homeHeaderImageInvalid'));
66 } elseif (Request
::getUserVar('deletePageHeaderTitleImage')) {
67 $publicFileManager = new PublicFileManager();
68 $setting = $site->getData('pageHeaderTitleImage');
69 $formLocale = $settingsForm->getFormLocale();
70 if (isset($setting[$formLocale])) {
71 $publicFileManager->removeSiteFile($setting[$formLocale]['uploadName']);
72 unset($setting[$formLocale]);
73 $site->setData('pageHeaderTitleImage', $setting);
74 $siteSettingsDao =& DAORegistry
::getDAO('SiteSettingsDAO');
75 $siteSettingsDao->deleteSetting('pageHeaderTitleImage', $formLocale);
77 // Refresh site header
78 $templateMgr =& TemplateManager
::getManager();
79 $templateMgr->assign('displayPageHeaderTitle', $site->getLocalizedPageHeaderTitle());
81 } elseif ($settingsForm->validate()) {
82 $settingsForm->execute();
84 $templateMgr =& TemplateManager
::getManager();
85 $templateMgr->assign(array(
86 'currentUrl' => Request
::url(null, null, 'settings'),
87 'pageTitle' => 'admin.siteSettings',
88 'message' => 'common.changesSaved',
89 'backLink' => Request
::url(null, Request
::getRequestedPage()),
90 'backLinkLabel' => 'admin.siteAdmin'
92 $templateMgr->display('common/message.tpl');
95 $settingsForm->display();