XoopsModules25x /
tdmdownloads
| 1 | <?php declare(strict_types=1); |
||||
| 2 | |||||
| 3 | namespace XoopsModules\Tdmdownloads\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 | * Module: Tdmdownloads |
||||
| 17 | * |
||||
| 18 | * @category Module |
||||
| 19 | * @package tdmdownloads |
||||
| 20 | * @author XOOPS Development Team <https://xoops.org> |
||||
| 21 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
| 22 | * @license GPL 2.0 or later |
||||
| 23 | * @link https://xoops.org/ |
||||
| 24 | * @since 1.0.0 |
||||
| 25 | */ |
||||
| 26 | |||||
| 27 | use Xmf\Request; |
||||
| 28 | use XoopsModules\Tdmdownloads; |
||||
| 29 | |||||
| 30 | require_once \dirname(\dirname(__DIR__)) . '/include/common.php'; |
||||
| 31 | |||||
| 32 | //$moduleDirName = basename(dirname(dirname(__DIR__))); |
||||
| 33 | //$helper = Tdmdownloads\Helper::getInstance(); |
||||
| 34 | $permHelper = new \Xmf\Module\Helper\Permission(); |
||||
| 35 | |||||
| 36 | \xoops_load('XoopsFormLoader'); |
||||
| 37 | |||||
| 38 | /** |
||||
| 39 | * Class FieldForm |
||||
| 40 | */ |
||||
| 41 | class UploadForm extends \XoopsThemeForm |
||||
| 42 | { |
||||
| 43 | public $targetObject; |
||||
| 44 | public $helper; |
||||
| 45 | |||||
| 46 | /** |
||||
| 47 | * Constructor |
||||
| 48 | * |
||||
| 49 | * @param \XoopsModules\Tdmdownloads\Category $target |
||||
| 50 | */ |
||||
| 51 | public function __construct($target) |
||||
| 52 | { |
||||
| 53 | $moduleDirName = \basename(\dirname(\dirname(__DIR__))); |
||||
| 54 | |||||
| 55 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
||||
| 56 | |||||
| 57 | /** @var \XoopsModules\Tdmdownloads\Helper $this->helper */ |
||||
| 58 | |||||
| 59 | $this->helper = $target->helper; |
||||
| 60 | |||||
| 61 | $this->targetObject = $target; |
||||
| 62 | |||||
| 63 | $title = $this->targetObject->isNew() ? \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_ADD')) : \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'FIELD_EDIT')); |
||||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||||
| 64 | |||||
| 65 | parent::__construct('', 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true); |
||||
| 66 | |||||
| 67 | $this->setExtra('enctype="multipart/form-data"'); |
||||
| 68 | |||||
| 69 | //include ID field, it's needed so the module knows if it is a new form or an edited form |
||||
| 70 | |||||
| 71 | $hidden = new \XoopsFormHidden('fid', $this->targetObject->getVar('cat_cid')); |
||||
|
0 ignored issues
–
show
It seems like
$this->targetObject->getVar('cat_cid') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 72 | |||||
| 73 | $this->addElement($hidden); |
||||
| 74 | |||||
| 75 | unset($hidden); |
||||
| 76 | |||||
| 77 | $categoryHandler = new \XoopsModules\Tdmdownloads\CategoryHandler(); |
||||
| 78 | |||||
| 79 | $start = Request::getInt('start', 0); |
||||
| 80 | |||||
| 81 | $catPaginationLimit = $this->helper->getConfig('userpager') ?: 10; |
||||
| 82 | |||||
| 83 | $criteria = new \CriteriaCompo(); |
||||
| 84 | |||||
| 85 | $criteria->setOrder('DESC'); |
||||
| 86 | |||||
| 87 | $criteria->setLimit($catPaginationLimit); |
||||
| 88 | |||||
| 89 | $criteria->setStart($start); |
||||
| 90 | |||||
| 91 | $catCount = $categoryHandler->getCount($criteria); |
||||
|
0 ignored issues
–
show
|
|||||
| 92 | |||||
| 93 | $catArray = $categoryHandler->getAll($criteria); |
||||
| 94 | |||||
| 95 | // Form Select Category |
||||
| 96 | |||||
| 97 | $categoryIdSelect = new \XoopsFormSelect(\constant('CO_' . $moduleDirNameUpper . '_' . 'SELECT'), 'cat_title', $this->targetObject->getVar('cat_cid')); |
||||
| 98 | |||||
| 99 | $categoryIdSelect->setExtra('onchange="submit()"'); |
||||
| 100 | |||||
| 101 | // $categoryIdSelect->addOption(0, ' '); |
||||
| 102 | |||||
| 103 | foreach (\array_keys($catArray) as $i) { |
||||
| 104 | $catName = $catArray[$i]->getVar('cat_title'); |
||||
| 105 | |||||
| 106 | $catPid = $catArray[$i]->getVar('cat_pid'); |
||||
| 107 | |||||
| 108 | if ($catPid > 0) { |
||||
| 109 | $categoryObj = $categoryHandler->get($catPid); |
||||
| 110 | |||||
| 111 | if (\is_object($categoryObj)) { |
||||
| 112 | $catName .= ' (' . $categoryObj->getVar('cat_title') . ')'; |
||||
| 113 | } else { |
||||
| 114 | $catName .= ' (' . \constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR_CATPID') . ')'; |
||||
| 115 | } |
||||
| 116 | } |
||||
| 117 | |||||
| 118 | $categoryIdSelect->addOption($catArray[$i]->getVar('cat_cid'), $catName); |
||||
| 119 | } |
||||
| 120 | |||||
| 121 | $this->addElement($categoryIdSelect); |
||||
| 122 | |||||
| 123 | unset($categoryCriteria); |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 124 | |||||
| 125 | $this->addElement(new \XoopsFormHidden('start', 0)); |
||||
| 126 | |||||
| 127 | $this->addElement(new \XoopsFormHidden('limit', 0)); |
||||
| 128 | } |
||||
| 129 | } |
||||
| 130 |