Skip to content

Commit dd406b1

Browse files
committed
XoopsConfirm to Confirm
1 parent 3773bec commit dd406b1

7 files changed

Lines changed: 58 additions & 38 deletions

File tree

admin/modules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@
230230
$GLOBALS['xoopsTpl']->assign('error', $modulesObj->getHtmlErrors());
231231
}
232232
} else {
233-
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\XoopsConfirm(
233+
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\Confirm(
234234
['ok' => 1, 'mod_id' => $modId, 'op' => 'delete'],
235235
\Xmf\Request::getString('REQUEST_URI', '', 'SERVER'),
236236
$modulesObj->getVar('mod_name')
237237
);
238-
$form = $xoopsconfirm->getFormXoopsConfirm();
238+
$form = $xoopsconfirm->getFormConfirm();
239239
$GLOBALS['xoopsTpl']->assign('form', $form->render());
240240
}
241241
break;

admin/morefiles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@
134134
$GLOBALS['xoopsTpl']->assign('error', $morefilesObj->getHtmlErrors());
135135
}
136136
} else {
137-
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\XoopsConfirm(
137+
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\Confirm(
138138
['ok' => 1, 'file_id' => $fileId, 'op' => 'delete'], \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'), $morefilesObj->getVar('file_name')
139139
);
140-
$form = $xoopsconfirm->getFormXoopsConfirm();
140+
$form = $xoopsconfirm->getFormConfirm();
141141
$GLOBALS['xoopsTpl']->assign('form', $form->render());
142142
}
143143
break;

admin/settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@
170170
$GLOBALS['xoopsTpl']->assign('error', $settingsObj->getHtmlErrors());
171171
}
172172
} else {
173-
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\XoopsConfirm(
173+
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\Confirm(
174174
['ok' => 1, 'set_id' => $setId, 'op' => 'delete'], \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'), $settingsObj->getVar('set_name')
175175
);
176-
$form = $xoopsconfirm->getFormXoopsConfirm();
176+
$form = $xoopsconfirm->getFormConfirm();
177177
$GLOBALS['xoopsTpl']->assign('form', $form->render());
178178
}
179179
break;

admin/tables.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,10 @@
272272
$GLOBALS['xoopsTpl']->assign('error', $tablesObj->getHtmlErrors());
273273
}
274274
} else {
275-
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\XoopsConfirm(
275+
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\Confirm(
276276
['ok' => 1, 'table_id' => $tableId, 'table_mid' => $tableMid, 'op' => 'delete'], \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'), $tablesObj->getVar('table_name')
277277
);
278-
$form = $xoopsconfirm->getFormXoopsConfirm();
278+
$form = $xoopsconfirm->getFormConfirm();
279279
$GLOBALS['xoopsTpl']->assign('form', $form->render());
280280
}
281281
break;
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,32 @@
1313
*/
1414

1515
/**
16-
* My Module module for xoops
16+
* Custom form confirm for XOOPS modules
1717
*
1818
* @copyright 2020 XOOPS Project (https://xoops.org)
1919
* @license GPL 2.0 or later
20-
* @package Modulebuilder
20+
* @package general
2121
* @since 1.0
2222
* @min_xoops 2.5.9
2323
* @author Goffy - Email:<goffy@myxoops.org> - Website:<https://xoops.org>
24+
*
25+
*
26+
* Example:
27+
$xoopsconfirm = 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 = $xoopsconfirm->getFormConfirm();
33+
$GLOBALS['xoopsTpl']->assign('form', $form->render());
2434
*/
2535

26-
use XoopsModules\Modulebuilder;
27-
2836
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
2937

3038
/**
31-
* Class Object XoopsConfirm
39+
* Class Object Confirm
3240
*/
33-
class XoopsConfirm
41+
class Confirm
3442
{
3543
private $hiddens = [];
3644
private $action = '';
@@ -56,31 +64,33 @@ public function __construct($hiddens, $action, $object, $title = '', $label = ''
5664
}
5765

5866
/**
59-
* @public function getXoopsConfirm
67+
* @public function getFormConfirm
6068
* @return \XoopsThemeForm
6169
*/
62-
public function getFormXoopsConfirm()
70+
public function getFormConfirm()
6371
{
72+
$moduleDirName = \basename(__DIR__);
73+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
6474
//in order to be accessable from user and admin area this should be place in language common.php
65-
if (!\defined('CO_MODULEBUILDER_DELETE_CONFIRM')) {
66-
\define('CO_MODULEBUILDER_DELETE_CONFIRM', 'Confirm delete');
67-
\define('CO_MODULEBUILDER_DELETE_LABEL', 'Do you really want to delete:');
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:');
6878
}
6979

7080
// Get Theme Form
7181
if ('' === $this->action) {
7282
$this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
7383
}
7484
if ('' === $this->title) {
75-
$this->title = \CO_MODULEBUILDER_DELETE_CONFIRM;
85+
$this->title = \constant('CO_' . $moduleDirNameUpper . '_DELETE_CONFIRM');
7686
}
7787
if ('' === $this->label) {
7888

79-
$this->label = \CO_MODULEBUILDER_DELETE_LABEL;
89+
$this->label = \constant('CO_' . $moduleDirNameUpper . '_DELETE_LABEL');
8090
}
8191

8292
\xoops_load('XoopsFormLoader');
83-
$form = new \XoopsThemeForm($this->title, 'formXoopsConfirm', $this->action, 'post', true);
93+
$form = new \XoopsThemeForm($this->title, 'formConfirm', $this->action, 'post', true);
8494
$form->setExtra('enctype="multipart/form-data"');
8595
$form->addElement(new \XoopsFormLabel($this->label, $this->object));
8696
//hiddens

class/Files/CreateXoopsCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,12 @@ public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $
10381038
$server = $pc->getPhpCodeGlobalsVariables('REQUEST_URI', 'SERVER');
10391039
$getVar = $this->getXcGetVar('', $tableName . 'Obj', $fieldMain, true);
10401040
$sprintf = $pc->getPhpCodeSprintf($language . 'FORM_SURE_' . $stuOptions, $getVar);
1041-
$confirm = 'new Common\XoopsConfirm(' . "\n";
1041+
$confirm = 'new Common\Confirm(' . "\n";
10421042
$confirm .= $t . "\t" . $array . ",\n";
10431043
$confirm .= $t . "\t" . $server . ",\n";
10441044
$confirm .= $t . "\t" . $sprintf . ')';
10451045
$ret = $xc->getXcEqualsOperator('$xoopsconfirm', $confirm, '', $t);
1046-
$ret .= $xc->getXcEqualsOperator('$form', '$xoopsconfirm->getFormXoopsConfirm()', '', $t);
1046+
$ret .= $xc->getXcEqualsOperator('$form', '$xoopsconfirm->getFormConfirm()', '', $t);
10471047
$ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t);
10481048
return $ret;
10491049
}

files/commonfiles/class/Common/XoopsConfirm.php renamed to files/commonfiles/class/Common/Confirm.php

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,32 @@
1313
*/
1414

1515
/**
16-
* My Module module for xoops
16+
* Custom form confirm for XOOPS modules
1717
*
1818
* @copyright 2020 XOOPS Project (https://xoops.org)
1919
* @license GPL 2.0 or later
20-
* @package Modulebuilder
20+
* @package general
2121
* @since 1.0
2222
* @min_xoops 2.5.9
2323
* @author Goffy - Email:<goffy@myxoops.org> - Website:<https://xoops.org>
24+
*
25+
*
26+
* Example:
27+
$xoopsconfirm = 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 = $xoopsconfirm->getFormConfirm();
33+
$GLOBALS['xoopsTpl']->assign('form', $form->render());
2434
*/
2535

26-
use XoopsModules\Modulebuilder;
27-
2836
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
2937

3038
/**
31-
* Class Object XoopsConfirm
39+
* Class Object Confirm
3240
*/
33-
class XoopsConfirm
41+
class Confirm
3442
{
3543
private $hiddens = [];
3644
private $action = '';
@@ -56,31 +64,33 @@ public function __construct($hiddens, $action, $object, $title = '', $label = ''
5664
}
5765

5866
/**
59-
* @public function getXoopsConfirm
67+
* @public function getFormConfirm
6068
* @return \XoopsThemeForm
6169
*/
62-
public function getFormXoopsConfirm()
70+
public function getFormConfirm()
6371
{
72+
$moduleDirName = \basename(__DIR__);
73+
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
6474
//in order to be accessable from user and admin area this should be place in language common.php
65-
if (!\defined('CO_MODULEBUILDER_DELETE_CONFIRM')) {
66-
\define('CO_MODULEBUILDER_DELETE_CONFIRM', 'Confirm delete');
67-
\define('CO_MODULEBUILDER_DELETE_LABEL', 'Do you really want to delete:');
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:');
6878
}
6979

7080
// Get Theme Form
7181
if ('' === $this->action) {
7282
$this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
7383
}
7484
if ('' === $this->title) {
75-
$this->title = \CO_MODULEBUILDER_DELETE_CONFIRM;
85+
$this->title = \constant('CO_' . $moduleDirNameUpper . '_DELETE_CONFIRM');
7686
}
7787
if ('' === $this->label) {
7888

79-
$this->label = \CO_MODULEBUILDER_DELETE_LABEL;
89+
$this->label = \constant('CO_' . $moduleDirNameUpper . '_DELETE_LABEL');
8090
}
8191

8292
\xoops_load('XoopsFormLoader');
83-
$form = new \XoopsThemeForm($this->title, 'formXoopsConfirm', $this->action, 'post', true);
93+
$form = new \XoopsThemeForm($this->title, 'formConfirm', $this->action, 'post', true);
8494
$form->setExtra('enctype="multipart/form-data"');
8595
$form->addElement(new \XoopsFormLabel($this->label, $this->object));
8696
//hiddens

0 commit comments

Comments
 (0)