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