|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Wfdownloads; |
|
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
|
|
|
* Wfdownloads module |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
20
|
|
|
* @package wfdownload |
|
21
|
|
|
* @since 3.23 |
|
22
|
|
|
* @author Xoops Development Team |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use XoopsModules\Wfdownloads; |
|
26
|
|
|
|
|
27
|
|
|
require_once \dirname(__DIR__) . '/include/common.php'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class Mirror |
|
31
|
|
|
*/ |
|
32
|
|
|
class Mirror extends \XoopsObject |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @access public |
|
36
|
|
|
*/ |
|
37
|
|
|
public $helper; |
|
38
|
|
|
public $db; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param int|null $id |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct($id = null) |
|
44
|
|
|
{ |
|
45
|
|
|
/** @var Wfdownloads\Helper $this ->helper */ |
|
46
|
|
|
$this->helper = Wfdownloads\Helper::getInstance(); |
|
|
|
|
|
|
47
|
|
|
$this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
|
|
|
|
|
48
|
|
|
$this->initVar('mirror_id', \XOBJ_DTYPE_INT); |
|
|
|
|
|
|
49
|
|
|
$this->initVar('lid', \XOBJ_DTYPE_INT); |
|
50
|
|
|
$this->initVar('title', \XOBJ_DTYPE_TXTBOX); |
|
51
|
|
|
$this->initVar('homeurl', \XOBJ_DTYPE_URL, 'http://'); |
|
52
|
|
|
$this->initVar('location', \XOBJ_DTYPE_TXTBOX); |
|
53
|
|
|
$this->initVar('continent', \XOBJ_DTYPE_TXTBOX, \_MD_WFDOWNLOADS_CONT4); |
|
54
|
|
|
$this->initVar('downurl', \XOBJ_DTYPE_URL, ''); |
|
55
|
|
|
$this->initVar('submit', \XOBJ_DTYPE_INT); // boolean |
|
56
|
|
|
$this->initVar('date', \XOBJ_DTYPE_INT); |
|
57
|
|
|
$this->initVar('uid', \XOBJ_DTYPE_INT); |
|
58
|
|
|
|
|
59
|
|
|
if (null !== $id) { |
|
60
|
|
|
$item = $this->helper->getHandler('Item')->get($id); |
|
61
|
|
|
foreach ($item->vars as $k => $v) { |
|
62
|
|
|
$this->assignVar($k, $v['value']); |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return \XoopsThemeForm |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getForm() |
|
71
|
|
|
{ |
|
72
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
73
|
|
|
$uid = !empty($GLOBALS['xoopsUser']) ? (int)$GLOBALS['xoopsUser']->getVar('uid') : 0; |
|
74
|
|
|
|
|
75
|
|
|
$form = new \XoopsThemeForm(\_AM_WFDOWNLOADS_MIRROR_SNEWMNAMEDESC, 'mirrorform', $_SERVER['REQUEST_URI']); |
|
76
|
|
|
// title |
|
77
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WFDOWNLOADS_MIRROR_FHOMEURLTITLE, 'title', 50, 255, $this->getVar('title', 'e')), true); |
|
|
|
|
|
|
78
|
|
|
// homeurl |
|
79
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WFDOWNLOADS_MIRROR_FHOMEURL, 'homeurl', 50, 255, $this->getVar('homeurl', 'e')), true); |
|
80
|
|
|
// location |
|
81
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WFDOWNLOADS_MIRROR_LOCATION, 'location', 50, 255, $this->getVar('location', 'e')), true); |
|
82
|
|
|
// continent |
|
83
|
|
|
$continent_select = new \XoopsFormSelect(\_AM_WFDOWNLOADS_MIRROR_CONTINENT, 'continent', $this->getVar('continent')); |
|
84
|
|
|
$continent_select->addOptionArray( |
|
85
|
|
|
[ |
|
86
|
|
|
\_AM_WFDOWNLOADS_CONT1 => \_AM_WFDOWNLOADS_CONT1, |
|
87
|
|
|
\_AM_WFDOWNLOADS_CONT2 => \_AM_WFDOWNLOADS_CONT2, |
|
88
|
|
|
\_AM_WFDOWNLOADS_CONT3 => \_AM_WFDOWNLOADS_CONT3, |
|
89
|
|
|
\_AM_WFDOWNLOADS_CONT4 => \_AM_WFDOWNLOADS_CONT4, |
|
90
|
|
|
\_AM_WFDOWNLOADS_CONT5 => \_AM_WFDOWNLOADS_CONT5, |
|
91
|
|
|
\_AM_WFDOWNLOADS_CONT6 => \_AM_WFDOWNLOADS_CONT6, |
|
92
|
|
|
\_AM_WFDOWNLOADS_CONT7 => \_AM_WFDOWNLOADS_CONT7, |
|
93
|
|
|
] |
|
94
|
|
|
); |
|
95
|
|
|
$form->addElement($continent_select); |
|
96
|
|
|
// downurl |
|
97
|
|
|
$form->addElement(new \XoopsFormText(\_AM_WFDOWNLOADS_MIRROR_DOWNURL, 'downurl', 50, 255, $this->getVar('downurl', 'e')), true); |
|
98
|
|
|
// approve |
|
99
|
|
|
$approved = (0 == $this->getVar('submit')) ? 0 : 1; |
|
100
|
|
|
$approve_checkbox = new \XoopsFormCheckBox(\_AM_WFDOWNLOADS_MIRROR_FAPPROVE, 'approve', $approved); |
|
101
|
|
|
$approve_checkbox->addOption(1, ' '); |
|
102
|
|
|
$form->addElement($approve_checkbox); |
|
103
|
|
|
// lid |
|
104
|
|
|
$form->addElement(new \XoopsFormHidden('lid', (int)$this->getVar('lid'))); |
|
105
|
|
|
// mirror_id |
|
106
|
|
|
$form->addElement(new \XoopsFormHidden('mirror_id', (int)$this->getVar('mirror_id'))); |
|
107
|
|
|
// uid |
|
108
|
|
|
$form->addElement(new \XoopsFormHidden('uid', $uid)); |
|
109
|
|
|
// confirm |
|
110
|
|
|
$form->addElement(new \XoopsFormHidden('confirm', 1)); |
|
111
|
|
|
// op |
|
112
|
|
|
$form->addElement(new \XoopsFormHidden('op', '')); |
|
113
|
|
|
// buttons |
|
114
|
|
|
$buttonTray = new \XoopsFormElementTray('', ''); |
|
115
|
|
|
if ($this->isNew()) { |
|
116
|
|
|
$createButton = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_BSAVE, 'submit'); |
|
117
|
|
|
$createButton->setExtra('onclick="this.form.elements.op.value=\'mirror.save\'"'); |
|
118
|
|
|
$buttonTray->addElement($createButton); |
|
119
|
|
|
$clearButton = new \XoopsFormButton('', '', _RESET, 'reset'); |
|
120
|
|
|
$buttonTray->addElement($clearButton); |
|
121
|
|
|
$cancelButton = new \XoopsFormButton('', '', _CANCEL, 'button'); |
|
122
|
|
|
$cancelButton->setExtra('onclick="history.go(-1)"'); |
|
123
|
|
|
$buttonTray->addElement($cancelButton); |
|
124
|
|
|
} else { |
|
125
|
|
|
$createButton = new \XoopsFormButton('', '', \_AM_WFDOWNLOADS_BSAVE, 'submit'); |
|
126
|
|
|
$createButton->setExtra('onclick="this.form.elements.op.value=\'mirror.save\'"'); |
|
127
|
|
|
$buttonTray->addElement($createButton); |
|
128
|
|
|
$deleteButton = new \XoopsFormButton('', '', _DELETE, 'submit'); |
|
129
|
|
|
$deleteButton->setExtra('onclick="this.form.elements.op.value=\'mirror.delete\'"'); |
|
130
|
|
|
$buttonTray->addElement($deleteButton); |
|
131
|
|
|
$cancelButton = new \XoopsFormButton('', '', _CANCEL, 'button'); |
|
132
|
|
|
$cancelButton->setExtra('onclick="history.go(-1)"'); |
|
133
|
|
|
$buttonTray->addElement($cancelButton); |
|
134
|
|
|
} |
|
135
|
|
|
$form->addElement($buttonTray); |
|
136
|
|
|
|
|
137
|
|
|
return $form; |
|
138
|
|
|
} |
|
139
|
|
|
} |
|
140
|
|
|
|