Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
LibraryFileForm.inc.php
1 <?php
2 
16 import('lib.pkp.classes.form.Form');
17 import('classes.file.LibraryFileManager');
18 
19 class LibraryFileForm extends Form {
22 
25 
31  function LibraryFileForm($template, $contextId) {
32  $this->contextId = $contextId;
33 
34  parent::Form($template);
35  $this->libraryFileManager = new LibraryFileManager($contextId);
36 
37  $this->addCheck(new FormValidatorLocale($this, 'libraryFileName', 'required', 'settings.libraryFiles.nameRequired'));
38  $this->addCheck(new FormValidatorCustom($this, 'fileType', 'required', 'settings.libraryFiles.typeRequired',
39  create_function('$type, $form, $libraryFileManager', 'return is_numeric($type) && $libraryFileManager->getNameFromType($type);'), array($this, $this->libraryFileManager)));
40 
41  $this->addCheck(new FormValidatorPost($this));
42  }
43 
49  function fetch($request) {
50  AppLocale::requireComponents(LOCALE_COMPONENT_APP_MANAGER);
51 
52  // load the file types for the selector on the form.
53  $templateMgr = TemplateManager::getManager($request);
54  $fileTypeKeys = $this->libraryFileManager->getTypeTitleKeyMap();
55  $templateMgr->assign('fileTypes', $fileTypeKeys);
56 
57  return parent::fetch($request);
58  }
59 
64  function readInputData() {
65  $this->readUserVars(array('libraryFileName', 'fileType'));
66  }
67 }
68 
69 ?>
addCheck($formValidator)
Definition: Form.inc.php:396
Form validation check with a custom user function performing the validation check.
Form validation check to make sure the form is POSTed.
static requireComponents()
LibraryFileForm($template, $contextId)
readUserVars($vars)
Definition: Form.inc.php:364
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
Wrapper class for uploading files to a site/context&#39; library directory.
Class to represent a form validation check for localized fields.
Form for adding/editing a file.