1 | <?php |
||||||
2 | |||||||
3 | namespace XoopsModules\Wggithub\Common; |
||||||
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 | * Custom form confirm for XOOPS modules |
||||||
17 | * |
||||||
18 | * @copyright 2020 XOOPS Project (https://xoops.org) |
||||||
19 | * @license GPL 2.0 or later |
||||||
20 | * @package general |
||||||
21 | * @since 1.0 |
||||||
22 | * @min_xoops 2.5.9 |
||||||
23 | * @author Goffy - Email:<[email protected]> - Website:<https://xoops.org> |
||||||
24 | * |
||||||
25 | * |
||||||
26 | * Example: |
||||||
27 | $customConfirm = new Common\Confirm( |
||||||
28 | ['ok' => 1, 'item_id' => $itemId, 'op' => 'delete'], |
||||||
29 | $_SERVER['REQUEST_URI'], |
||||||
30 | \sprintf(\_MA_MYMODULE_FORM_SURE_DELETE, |
||||||
31 | $itemsObj->getCaption())); |
||||||
32 | $form = $customConfirm->getFormConfirm(); |
||||||
33 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
34 | */ |
||||||
35 | |||||||
36 | \defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||||
37 | |||||||
38 | /** |
||||||
39 | * Class Object Confirm |
||||||
40 | */ |
||||||
41 | class Confirm |
||||||
42 | { |
||||||
43 | private $hiddens = []; |
||||||
44 | private $action = ''; |
||||||
45 | private $title = ''; |
||||||
46 | private $label = ''; |
||||||
47 | private $object = ''; |
||||||
48 | |||||||
49 | /** |
||||||
50 | * @public function constructor class |
||||||
51 | * @param $hiddens |
||||||
52 | * @param $action |
||||||
53 | * @param $object |
||||||
54 | * @param string $title |
||||||
55 | * @param string $label |
||||||
56 | */ |
||||||
57 | public function __construct($hiddens, $action, $object, $title = '', $label = '') |
||||||
58 | { |
||||||
59 | $this->hiddens = $hiddens; |
||||||
60 | $this->action = $action; |
||||||
61 | $this->object = $object; |
||||||
62 | $this->title = $title; |
||||||
63 | $this->label = $label; |
||||||
64 | } |
||||||
65 | |||||||
66 | /** |
||||||
67 | * @public function getFormConfirm |
||||||
68 | * @return \XoopsThemeForm |
||||||
69 | */ |
||||||
70 | public function getFormConfirm() |
||||||
71 | { |
||||||
72 | $moduleDirName = \basename(__DIR__); |
||||||
73 | $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
||||||
74 | //in order to be accessable from user and admin area this should be place in language common.php |
||||||
75 | if (!\defined('CO_' . $moduleDirNameUpper . '_DELETE_CONFIRM')) { |
||||||
76 | \define('CO_' . $moduleDirNameUpper . '_DELETE_CONFIRM', 'Confirm delete'); |
||||||
77 | \define('CO_' . $moduleDirNameUpper . '_DELETE_LABEL', 'Do you really want to delete:'); |
||||||
78 | } |
||||||
79 | |||||||
80 | // Get Theme Form |
||||||
81 | if ('' === $this->action) { |
||||||
82 | $this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'); |
||||||
0 ignored issues
–
show
|
|||||||
83 | } |
||||||
84 | if ('' === $this->title) { |
||||||
85 | $this->title = \constant('CO_' . $moduleDirNameUpper . '_DELETE_CONFIRM'); |
||||||
86 | } |
||||||
87 | if ('' === $this->label) { |
||||||
88 | |||||||
89 | $this->label = \constant('CO_' . $moduleDirNameUpper . '_DELETE_LABEL'); |
||||||
90 | } |
||||||
91 | |||||||
92 | \xoops_load('XoopsFormLoader'); |
||||||
0 ignored issues
–
show
The function
xoops_load was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
93 | $form = new \XoopsThemeForm($this->title, 'formConfirm', $this->action, 'post', true); |
||||||
0 ignored issues
–
show
The type
XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
94 | $form->setExtra('enctype="multipart/form-data"'); |
||||||
95 | $form->addElement(new \XoopsFormLabel($this->label, $this->object)); |
||||||
0 ignored issues
–
show
The type
XoopsFormLabel was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
96 | //hiddens |
||||||
97 | foreach ($this->hiddens as $key => $value) { |
||||||
98 | $form->addElement(new \XoopsFormHidden($key, $value)); |
||||||
0 ignored issues
–
show
The type
XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
99 | } |
||||||
100 | $form->addElement(new \XoopsFormHidden('ok', 1)); |
||||||
101 | $buttonTray = new \XoopsFormElementTray(''); |
||||||
0 ignored issues
–
show
The type
XoopsFormElementTray was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
102 | $buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', \_YES, 'submit')); |
||||||
0 ignored issues
–
show
The type
XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
103 | $buttonBack = new \XoopsFormButton('', 'confirm_back', \_NO, 'button'); |
||||||
0 ignored issues
–
show
|
|||||||
104 | $buttonBack->setExtra('onclick="history.go(-1);return true;"'); |
||||||
105 | $buttonTray->addElement($buttonBack); |
||||||
106 | $form->addElement($buttonTray); |
||||||
107 | return $form; |
||||||
108 | } |
||||||
109 | } |
||||||
110 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths