1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: include_once dirname(dirname(__DIR__)) . '/include/common.php';
24:
25: class PublisherFileForm extends Xoops\Form\ThemeForm
26: {
27: 28: 29:
30: public function __construct(PublisherFile $obj)
31: {
32:
33: $xoops = Xoops::getInstance();
34: $publisher = Publisher::getInstance();
35: $publisher->loadLanguage('main');
36:
37: parent::__construct(_AM_PUBLISHER_UPLOAD_FILE, "form", $xoops->getEnv('PHP_SELF'));
38: $this->setExtra('enctype="multipart/form-data"');
39:
40:
41: $name_text = new Xoops\Form\Text(_CO_PUBLISHER_FILENAME, 'name', 50, 255, $obj->getVar('name'));
42: $name_text->setDescription(_CO_PUBLISHER_FILE_NAME_DSC);
43: $this->addElement($name_text, true);
44:
45:
46: $description_text = new Xoops\Form\TextArea(_CO_PUBLISHER_FILE_DESCRIPTION, 'description', $obj->getVar('description'));
47: $description_text->setDescription(_CO_PUBLISHER_FILE_DESCRIPTION_DSC);
48: $this->addElement($description_text);
49:
50:
51: $file_box = new Xoops\Form\File(_CO_PUBLISHER_FILE_TO_UPLOAD, "item_upload_file");
52: $file_box->set('size', 50);
53: $this->addElement($file_box);
54:
55: $status_select = new Xoops\Form\RadioYesNo(_CO_PUBLISHER_FILE_STATUS, 'file_status', _PUBLISHER_STATUS_FILE_ACTIVE);
56: $status_select->setDescription(_CO_PUBLISHER_FILE_STATUS_DSC);
57: $this->addElement($status_select);
58:
59:
60: $this->addElement(new Xoops\Form\Hidden('fileid', $obj->getVar('fileid')));
61:
62:
63: $this->addElement(new Xoops\Form\Hidden('itemid', $obj->getVar('itemid')));
64:
65: $files_button_tray = new Xoops\Form\ElementTray('', '');
66: $files_hidden = new Xoops\Form\Hidden('op', 'uploadfile');
67: $files_button_tray->addElement($files_hidden);
68:
69: if (!$obj->getVar('fileid')) {
70: $files_butt_create = new Xoops\Form\Button('', '', _MD_PUBLISHER_UPLOAD, 'submit');
71: $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"');
72: $files_button_tray->addElement($files_butt_create);
73:
74: $files_butt_another = new Xoops\Form\Button('', '', _CO_PUBLISHER_FILE_UPLOAD_ANOTHER, 'submit');
75: $files_butt_another->setExtra('onclick="this.form.elements.op.value=\'uploadanother\'"');
76: $files_button_tray->addElement($files_butt_another);
77: } else {
78: $files_butt_create = new Xoops\Form\Button('', '', _MD_PUBLISHER_MODIFY, 'submit');
79: $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'modify\'"');
80: $files_button_tray->addElement($files_butt_create);
81: }
82:
83: $files_butt_clear = new Xoops\Form\Button('', '', _MD_PUBLISHER_CLEAR, 'reset');
84: $files_button_tray->addElement($files_butt_clear);
85:
86: $buttonCancel = new Xoops\Form\Button('', '', _MD_PUBLISHER_CANCEL, 'button');
87: $buttonCancel->setExtra('onclick="history.go(-1)"');
88: $files_button_tray->addElement($buttonCancel);
89:
90: $this->addElement($files_button_tray);
91: }
92: }
93: