XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
SmilesUploadForm.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_ROOT_PATH . '/core/XCube_ActionForm.class.php';
17require_once XOOPS_MODULE_PATH . '/legacy/class/Legacy_Validator.class.php';
18
20{
21 public $mOldFileName = null;
22 public $_mIsNew = null;
23 public $mFormFile = null;
24 public $_allowExtensions = ['tar', 'tar.gz', 'tgz', 'gz', 'zip'];
25
26 public function getTokenName()
27 {
28 return 'module.legacy.SmilesUploadForm.TOKEN';
29 }
30
31 public function prepare()
32 {
33 //
34 // Set form properties
35 //
36 $this->mFormProperties['upload'] =new XCube_FileProperty('upload');
37
38 //
39 // Set field properties
40 //
41 $this->mFieldProperties['upload'] =new XCube_FieldProperty($this);
42 $this->mFieldProperties['upload']->setDependsByArray(['required']);
43 $this->mFieldProperties['upload']->addMessage('required', _AD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_SMILES_UPLOAD_FILE);
44 }
45
46 public function validateUpload()
47 {
48 $formFile = $this->get('upload');
49 if (null != $formFile) {
50 $flag = false;
51 foreach ($this->_allowExtensions as $ext) {
52 $flag |= preg_match('/' . str_replace('.', "\.", $ext) . '$/', $formFile->getFileName());
53 }
54
55 if (!$flag) {
56 $this->addErrorMessage(_AD_LEGACY_ERROR_EXTENSION_IS_WRONG);
57 }
58 }
59 }
60}
getTokenName()
Gets the token name of this actionform's token.
prepare()
[Abstract] Set up form properties and field properties.
addErrorMessage( $message)
Adds a message to the form's error message buffer.
[Abstract] Used for validating member property values of XCube_ActionForm.
Represents the special property which handles uploaded file.