Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
SettingsFileUploadForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 
19 
22 
27  function SettingsFileUploadForm($template = null) {
28  if ($template == null) {
29  $template = 'controllers/tab/settings/form/newFileUploadForm.tpl';
30  }
31 
32  parent::Form($template);
33  $this->addCheck(new FormValidator($this, 'temporaryFileId', 'required', 'manager.website.imageFileRequired'));
34  }
35 
36 
37  //
38  // Getters and setters.
39  //
44  function getFileSettingName() {
46  }
47 
52  function setFileSettingName($fileSettingName) {
53  $this->_fileSettingName = $fileSettingName;
54  }
55 
56 
57  //
58  // Implement template methods from Form.
59  //
63  function readInputData() {
64  $this->readUserVars(array('temporaryFileId'));
65  }
66 
70  function fetch($request, $params=null) {
71  $templateMgr = TemplateManager::getManager($request);
72 
73  if (!is_null($params)) {
74  $templateMgr->assign($params);
75  }
76  $templateMgr->assign('fileSettingName', $this->getFileSettingName());
77 
78  return parent::fetch($request);
79  }
80 
81 
82  //
83  // Public methods
84  //
90  function fetchTemporaryFile($request) {
91  $user = $request->getUser();
92 
93  $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO');
94  $temporaryFile = $temporaryFileDao->getTemporaryFile(
95  $this->getData('temporaryFileId'),
96  $user->getId()
97  );
98  return $temporaryFile;
99  }
100 
105  function removeTemporaryFile($request) {
106  $user = $request->getUser();
107 
108  import('lib.pkp.classes.file.TemporaryFileManager');
109  $temporaryFileManager = new TemporaryFileManager();
110  $temporaryFileManager->deleteFile($this->getData('temporaryFileId'), $user->getId());
111  }
112 
117  function uploadFile($request) {
118  $user = $request->getUser();
119 
120  import('lib.pkp.classes.file.TemporaryFileManager');
121  $temporaryFileManager = new TemporaryFileManager();
122  $temporaryFile = $temporaryFileManager->handleUpload('uploadedFile', $user->getId());
123 
124  if ($temporaryFile) return $temporaryFile->getId();
125 
126  return false;
127  }
128 }
129 
130 ?>
static & getDAO($name, $dbconn=null)
addCheck($formValidator)
Definition: Form.inc.php:396
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
fetch($request, $params=null)
Base class for a settings upload file form.
getData($key)
Definition: Form.inc.php:210
Class to represent a form validation check.