baseline
[omp.pkp.sfu.ca.git] / pages / manager / PressLanguagesHandler.inc.php
blobe12c41afbe1d8b445aac272e68f3a4cc14a804ac
1 <?php
3 /**
4 * @file PressLanguagesHandler.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 PressLanguagesHandler
10 * @ingroup pages_manager
12 * @brief Handle requests for changing press language settings.
15 // $Id: PressLanguagesHandler.inc.php,v 1.5 2009/09/22 21:27:34 asmecher Exp $
17 import('pages.manager.ManagerHandler');
19 class PressLanguagesHandler extends ManagerHandler {
20 /**
21 * Constructor
22 */
23 function PressLanguagesHandler() {
24 parent::ManagerHandler();
27 /**
28 * Display form to edit language settings.
30 function languages() {
31 $this->validate();
32 $this->setupTemplate(true);
34 import('manager.form.LanguageSettingsForm');
36 $settingsForm = new LanguageSettingsForm();
37 $settingsForm->initData();
38 $settingsForm->display();
41 /**
42 * Save changes to language settings.
44 function saveLanguageSettings() {
45 $this->validate();
46 $this->setupTemplate(true);
48 import('manager.form.LanguageSettingsForm');
50 $settingsForm = new LanguageSettingsForm();
51 $settingsForm->readInputData();
53 if ($settingsForm->validate()) {
54 $settingsForm->execute();
56 $templateMgr =& TemplateManager::getManager();
57 $templateMgr->assign(array(
58 'currentUrl' => Request::url(null, null, 'languages'),
59 'pageTitle' => 'common.languages',
60 'message' => 'common.changesSaved',
61 'backLink' => Request::url(null, Request::getRequestedPage()),
62 'backLinkLabel' => 'manager.pressManagement'
63 ));
64 $templateMgr->display('common/message.tpl');
66 } else {
67 $settingsForm->display();
71 function reloadLocalizedDefaultSettings() {
72 // make sure the locale is valid
73 $locale = Request::getUserVar('localeToLoad');
74 if ( !Locale::isLocaleValid($locale) ) {
75 Request::redirect(null, null, 'languages');
78 $this->validate();
79 $this->setupTemplate(true);
81 $press =& Request::getPress();
82 $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
83 $pressSettingsDao->reloadLocalizedDefaultSettings($press->getId(), 'registry/pressSettings.xml', array(
84 'indexUrl' => Request::getIndexUrl(),
85 'pressPath' => $press->getData('path'),
86 'primaryLocale' => $press->getPrimaryLocale(),
87 'pressName' => $press->getName($press->getPrimaryLocale())
89 $locale);
91 $templateMgr =& TemplateManager::getManager();
92 $templateMgr->assign(array(
93 'currentUrl' => Request::url(null, null, 'languages'),
94 'pageTitle' => 'common.languages',
95 'message' => 'common.changesSaved',
96 'backLink' => Request::url(null, Request::getRequestedPage()),
97 'backLinkLabel' => 'manager.pressManagement'
98 ));
99 $templateMgr->display('common/message.tpl');