4 * @file pages/admin/$this->.inc.php
6 * Copyright (c) 2003-2008 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
10 * @ingroup pages_admin
12 * @brief Handle requests for press management in site administration.
15 // $Id: AdminPressHandler.inc.php,v 1.8 2009/10/06 21:57:31 asmecher Exp $this->.inc.php,v 1.4 2009/05/06 16:44:10 jalperin Exp $
17 import('pages.admin.AdminHandler');
19 class AdminPressHandler
extends AdminHandler
{
20 function AdminPressHandler() {
21 parent
::AdminHandler();
25 * Display a list of the presses hosted on the site.
29 $this->setupTemplate(true);
31 $rangeInfo = Handler
::getRangeInfo('presses');
33 $pressDao =& DAORegistry
::getDAO('PressDAO');
34 $presses =& $pressDao->getPresses($rangeInfo);
36 $templateMgr =& TemplateManager
::getManager();
37 $templateMgr->assign_by_ref('presses', $presses);
38 $templateMgr->assign('helpTopicId', 'site.siteManagement');
39 $templateMgr->display('admin/presses.tpl');
43 * Display form to create a new press.
45 function createPress() {
50 * Display form to create/edit a press.
51 * @param $args array optional, if set the first parameter is the ID of the press to edit
53 function editPress($args = array()) {
55 $this->setupTemplate(true);
57 import('admin.form.PressSiteSettingsForm');
59 if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor
60 $settingsForm = new PressSiteSettingsForm(!isset($args) ||
empty($args) ?
null : $args[0]);
62 $settingsForm =& new PressSiteSettingsForm(!isset($args) ||
empty($args) ?
null : $args[0]);
64 if ($settingsForm->isLocaleResubmit()) {
65 $settingsForm->readInputData();
67 $settingsForm->initData();
69 $settingsForm->display();
73 * Save changes to a press' settings.
75 function updatePress() {
78 import('admin.form.PressSiteSettingsForm');
80 if (checkPhpVersion('5.0.0')) { // WARNING: This form needs $this in constructor
81 $settingsForm = new PressSiteSettingsForm(Request
::getUserVar('pressId'));
83 $settingsForm =& new PressSiteSettingsForm(Request
::getUserVar('pressId'));
85 $settingsForm->readInputData();
87 if ($settingsForm->validate()) {
88 PluginRegistry
::loadCategory('blocks');
89 $settingsForm->execute();
90 Request
::redirect(null, null, 'presses');
93 $this->setupTemplate(true);
94 $settingsForm->display();
100 * @param $args array first parameter is the ID of the press to delete
102 function deletePress($args) {
105 $pressDao =& DAORegistry
::getDAO('PressDAO');
107 if (isset($args) && !empty($args) && !empty($args[0])) {
109 if ($pressDao->deletePressById($pressId)) {
110 // Delete press file tree
111 // FIXME move this somewhere better.
112 import('file.FileManager');
113 $fileManager = new FileManager();
115 $pressPath = Config
::getVar('files', 'files_dir') . '/presses/' . $pressId;
116 $fileManager->rmtree($pressPath);
118 import('file.PublicFileManager');
119 $publicFileManager = new PublicFileManager();
120 $publicFileManager->rmtree($publicFileManager->getPressFilesPath($pressId));
124 Request
::redirect(null, null, 'presses');
128 * Change the sequence of a press on the site index page.
130 function movePress() {
133 $pressDao =& DAORegistry
::getDAO('PressDAO');
134 $press =& $pressDao->getPress(Request
::getUserVar('pressId'));
136 if ($press != null) {
137 $press->setSequence($press->getSequence() +
(Request
::getUserVar('d') == 'u' ?
-1.5 : 1.5));
138 $pressDao->updatePress($press);
139 $pressDao->resequencePresses();
142 Request
::redirect(null, null, 'presses');