1
|
|
|
<?php namespace XoopsModules\Tdmdownloads\Form; |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
You may not change or alter any portion of this comment or credits |
5
|
|
|
of supporting developers from this source code or any supporting source code |
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Module: Tdmdownloads |
15
|
|
|
* |
16
|
|
|
* @category Module |
17
|
|
|
* @package tdmdownloads |
18
|
|
|
* @author XOOPS Development Team <https://xoops.org> |
19
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
20
|
|
|
* @license GPL 2.0 or later |
21
|
|
|
* @link https://xoops.org/ |
22
|
|
|
* @since 1.0.0 |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use Xmf\Request; |
26
|
|
|
use XoopsModules\Tdmdownloads; |
27
|
|
|
|
28
|
|
|
require_once dirname(dirname(__DIR__)) . '/include/common.php'; |
29
|
|
|
|
30
|
|
|
//$moduleDirName = basename(dirname(dirname(__DIR__))); |
31
|
|
|
//$helper = Tdmdownloads\Helper::getInstance(); |
32
|
|
|
$permHelper = new \Xmf\Module\Helper\Permission(); |
33
|
|
|
|
34
|
|
|
xoops_load('XoopsFormLoader'); |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Class FieldForm |
38
|
|
|
*/ |
39
|
|
|
class UploadForm extends \XoopsThemeForm |
40
|
|
|
{ |
41
|
|
|
public $targetObject; |
42
|
|
|
public $helper; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Constructor |
46
|
|
|
* |
47
|
|
|
* @param \XoopsModules\Tdmdownloads\Category $target |
48
|
|
|
*/ |
49
|
|
|
public function __construct($target) |
50
|
|
|
{ |
51
|
|
|
$moduleDirName = basename(dirname(dirname(__DIR__))); |
52
|
|
|
$moduleDirNameUpper = mb_strtoupper($moduleDirName); |
53
|
|
|
/** @var \XoopsModules\Tdmdownloads\Helper $this->helper */ |
54
|
|
|
$this->helper = $target->helper; |
55
|
|
|
$this->targetObject = $target; |
56
|
|
|
|
57
|
|
|
$title = $this->targetObject->isNew() ? sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : sprintf(constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); |
|
|
|
|
58
|
|
|
parent::__construct('', 'form', xoops_getenv('PHP_SELF'), 'post', true); |
59
|
|
|
$this->setExtra('enctype="multipart/form-data"'); |
60
|
|
|
|
61
|
|
|
//include ID field, it's needed so the module knows if it is a new form or an edited form |
62
|
|
|
|
63
|
|
|
$hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('cat_cid')); |
|
|
|
|
64
|
|
|
$this->addElement($hidden); |
65
|
|
|
unset($hidden); |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
$categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); |
69
|
|
|
$start = Request::getInt('start', 0); |
70
|
|
|
$catPaginationLimit = $this->helper->getConfig('userpager') ?: 10; |
71
|
|
|
|
72
|
|
|
$criteria = new \CriteriaCompo(); |
73
|
|
|
$criteria->setOrder('DESC'); |
74
|
|
|
$criteria->setLimit($catPaginationLimit); |
75
|
|
|
$criteria->setStart($start); |
76
|
|
|
|
77
|
|
|
$catCount = $categoryHandler->getCount($criteria); |
|
|
|
|
78
|
|
|
$catArray = $categoryHandler->getAll($criteria); |
79
|
|
|
|
80
|
|
|
// Form Select Category |
81
|
|
|
$categoryIdSelect = new \XoopsFormSelect( constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); |
82
|
|
|
$categoryIdSelect->setExtra('onchange="submit()"'); |
83
|
|
|
// $categoryIdSelect->addOption(0, ' '); |
84
|
|
|
|
85
|
|
|
foreach(array_keys($catArray) as $i) { |
86
|
|
|
$catName = $catArray[$i]->getVar('cat_title'); |
87
|
|
|
$catPid = $catArray[$i]->getVar('cat_pid'); |
88
|
|
|
if ( 0 < $catPid ) { |
89
|
|
|
$categoryObj = $categoryHandler->get($catPid); |
90
|
|
|
if (is_object( $categoryObj)) { |
91
|
|
|
$catName .= ' (' . $categoryObj->getVar('cat_title') . ')'; |
92
|
|
|
} else { |
93
|
|
|
$catName .= ' (' . constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
$categoryIdSelect->addOption($catArray[$i]->getVar('cat_cid'), $catName); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
$this->addElement($categoryIdSelect); |
100
|
|
|
unset($categoryCriteria); |
|
|
|
|
101
|
|
|
|
102
|
|
|
$this->addElement(new \XoopsFormHidden('start', 0)); |
103
|
|
|
$this->addElement(new \XoopsFormHidden('limit', 0)); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|