1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Publisher\Form; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Publisher form class |
17
|
|
|
* |
18
|
|
|
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
19
|
|
|
* @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
20
|
|
|
* @package Publisher |
21
|
|
|
* @since 1.0 |
22
|
|
|
* @author trabis <[email protected]> |
23
|
|
|
* @version $Id$ |
24
|
|
|
*/ |
25
|
|
|
use Xoops; |
26
|
|
|
use Xoops\Form\Button; |
27
|
|
|
use Xoops\Form\ElementTray; |
28
|
|
|
use Xoops\Form\File; |
29
|
|
|
use Xoops\Form\Hidden; |
30
|
|
|
use Xoops\Form\RadioYesNo; |
31
|
|
|
use Xoops\Form\Text; |
32
|
|
|
use Xoops\Form\TextArea; |
33
|
|
|
use Xoops\Form\ThemeForm; |
34
|
|
|
use XoopsModules\Publisher; |
35
|
|
|
use XoopsModules\Publisher\Helper; |
36
|
|
|
|
37
|
|
|
require_once \dirname(\dirname(__DIR__)) . '/include/common.php'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Class FileForm |
41
|
|
|
* @package XoopsModules\Publisher\Form |
42
|
|
|
*/ |
43
|
|
|
class FileForm extends ThemeForm |
44
|
|
|
{ |
45
|
|
|
public function __construct(Publisher\File $obj) |
46
|
|
|
{ |
47
|
|
|
$xoops = Xoops::getInstance(); |
48
|
|
|
$helper = Helper::getInstance(); |
49
|
|
|
$helper->loadLanguage('main'); |
50
|
|
|
|
51
|
|
|
parent::__construct(_AM_PUBLISHER_UPLOAD_FILE, 'form', $xoops->getEnv('PHP_SELF')); |
52
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
53
|
|
|
|
54
|
|
|
// NAME |
55
|
|
|
$name_text = new Text(_CO_PUBLISHER_FILENAME, 'name', 50, 255, $obj->getVar('name')); |
|
|
|
|
56
|
|
|
$name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC); |
57
|
|
|
$this->addElement($name_text, true); |
58
|
|
|
|
59
|
|
|
// DESCRIPTION |
60
|
|
|
$description_text = new TextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'description', $obj->getVar('description')); |
|
|
|
|
61
|
|
|
$description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC); |
62
|
|
|
$this->addElement($description_text); |
63
|
|
|
|
64
|
|
|
// FILE TO UPLOAD |
65
|
|
|
$file_box = new File(_CO_PUBLISHER_FILE_TO_UPLOAD, 'item_upload_file'); |
66
|
|
|
$file_box->set('size', 50); |
67
|
|
|
$this->addElement($file_box); |
68
|
|
|
|
69
|
|
|
$status_select = new RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'file_status', _PUBLISHER_STATUS_FILE_ACTIVE); |
70
|
|
|
$status_select->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC); |
71
|
|
|
$this->addElement($status_select); |
72
|
|
|
|
73
|
|
|
// fileid |
74
|
|
|
$this->addElement(new Hidden('fileid', $obj->getVar('fileid'))); |
|
|
|
|
75
|
|
|
|
76
|
|
|
// itemid |
77
|
|
|
$this->addElement(new Hidden('itemid', $obj->getVar('itemid'))); |
78
|
|
|
|
79
|
|
|
$files_button_tray = new ElementTray('', ''); |
80
|
|
|
$files_hidden = new Hidden('op', 'uploadfile'); |
81
|
|
|
$files_button_tray->addElement($files_hidden); |
82
|
|
|
|
83
|
|
|
if (!$obj->getVar('fileid')) { |
84
|
|
|
$files_butt_create = new Button('', '', _MD_PUBLISHER_UPLOAD, 'submit'); |
85
|
|
|
$files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"'); |
|
|
|
|
86
|
|
|
$files_button_tray->addElement($files_butt_create); |
87
|
|
|
|
88
|
|
|
$files_butt_another = new Button('', '', _CO_PUBLISHER_FILE_UPLOAD_ANOTHER, 'submit'); |
89
|
|
|
$files_butt_another->setExtra('onclick="this.form.elements.op.value=\'uploadanother\'"'); |
|
|
|
|
90
|
|
|
$files_button_tray->addElement($files_butt_another); |
91
|
|
|
} else { |
92
|
|
|
$files_butt_create = new Button('', '', _MD_PUBLISHER_MODIFY, 'submit'); |
93
|
|
|
$files_butt_create->setExtra('onclick="this.form.elements.op.value=\'modify\'"'); |
|
|
|
|
94
|
|
|
$files_button_tray->addElement($files_butt_create); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
$files_butt_clear = new Button('', '', _MD_PUBLISHER_CLEAR, 'reset'); |
98
|
|
|
$files_button_tray->addElement($files_butt_clear); |
99
|
|
|
|
100
|
|
|
$buttonCancel = new Button('', '', _MD_PUBLISHER_CANCEL, 'button'); |
101
|
|
|
$buttonCancel->setExtra('onclick="history.go(-1)"'); |
|
|
|
|
102
|
|
|
$files_button_tray->addElement($buttonCancel); |
103
|
|
|
|
104
|
|
|
$this->addElement($files_button_tray); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|