Skip to content

Commit 856304a

Browse files
committed
- implementation new xoops_confirm - step 1
1 parent 3208686 commit 856304a

4 files changed

Lines changed: 152 additions & 39 deletions

File tree

admin/modules.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@
190190
$GLOBALS['xoopsTpl']->assign('error', $modulesObj->getHtmlErrors());
191191
}
192192
} else {
193-
xoops_confirm(['ok' => 1, 'mod_id' => $modId, 'op' => 'delete'], \Xmf\Request::getString('REQUEST_URI', '', 'SERVER'), sprintf(_AM_MODULEBUILDER_FORMSUREDEL, $modulesObj->getVar('mod_name')));
193+
$xoopsconfirm = new \XoopsModules\Modulebuilder\Common\XoopsConfirm();
194+
$xoopsconfirm->hiddens = ['ok' => 1, 'mod_id' => $modId, 'op' => 'delete'];
195+
$xoopsconfirm->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
196+
$xoopsconfirm->object = $modulesObj->getVar('mod_name');
197+
$form = $xoopsconfirm->getFormXoopsConfirm();
198+
$GLOBALS['xoopsTpl']->assign('form', $form->render());
194199
}
195-
196200
break;
197201
case 'display':
198202
$modFieldArray = ['admin', 'user', 'blocks', 'search', 'comments', 'notifications', 'permissions'];

class/Common/XoopsConfirm.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace XoopsModules\Modulebuilder\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+
* My Module module for xoops
17+
*
18+
* @copyright 2020 XOOPS Project (https://xooops.org)
19+
* @license GPL 2.0 or later
20+
* @package Modulebuilder
21+
* @since 1.0
22+
* @min_xoops 2.5.9
23+
* @author Goffy - Email:<goffy@myxoops.org> - Website:<http://xoops.org>
24+
*/
25+
26+
use XoopsModules\Modulebuilder;
27+
28+
defined('XOOPS_ROOT_PATH') || die('Restricted access');
29+
30+
/**
31+
* Class Object XoopsConfirm
32+
*/
33+
class XoopsConfirm extends \XoopsObject
34+
{
35+
public $hiddens = [];
36+
public $action = '';
37+
public $title = '';
38+
public $label = '';
39+
public $object = '';
40+
41+
/**
42+
* @public function constructor class
43+
*
44+
* @param null
45+
*/
46+
public function __construct()
47+
{
48+
}
49+
50+
/**
51+
* @static function &getInstance
52+
*
53+
* @param null
54+
*/
55+
public static function getInstance()
56+
{
57+
static $instance = false;
58+
if (!$instance) {
59+
$instance = new self();
60+
}
61+
}
62+
63+
64+
/**
65+
* @public function getXoopsConfirm
66+
* @param bool $action
67+
* @return \XoopsThemeForm
68+
*/
69+
public function getFormXoopsConfirm()
70+
{
71+
//in order to be accessable from user and admin area this should be place in language common.php
72+
define('CO__MODULEBUILDER_DELETE_CONFIRM', 'Confirm delete');
73+
define('CO__MODULEBUILDER_DELETE_LABEL', 'Do you really want to delete:');
74+
75+
// Get Theme Form
76+
if ('' === $this->action) {
77+
$this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
78+
}
79+
if ('' === $this->title) {
80+
$this->title = CO__MODULEBUILDER_DELETE_CONFIRM;
81+
}
82+
if ('' === $this->label) {
83+
84+
$this->label = CO__MODULEBUILDER_DELETE_LABEL;
85+
}
86+
87+
xoops_load('XoopsFormLoader');
88+
$form = new \XoopsThemeForm($this->title, 'form', $this->action, 'post', true);
89+
$form->setExtra('enctype="multipart/form-data"');
90+
$form->addElement(new \XoopsFormLabel($this->label, $this->object));
91+
//hiddens
92+
foreach ($this->hiddens as $key => $value) {
93+
$form->addElement(new \XoopsFormHidden($key, $value));
94+
}
95+
$form->addElement(new \XoopsFormHidden('ok', 1));
96+
$buttonTray = new \XoopsFormElementTray('');
97+
$buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', _YES, 'submit', false));
98+
$buttonBack = new \XoopsFormButton('', 'confirm_back', _NO, 'button', false);
99+
$buttonBack->setExtra('onclick="history.go(-1);return true;"');
100+
$buttonTray->addElement($buttonBack);
101+
$form->addElement($buttonTray);
102+
return $form;
103+
}
104+
}

class/Files/Classes/ClassSpecialFiles.php

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,41 @@ public function write($module, $table, $tables, $filename)
8282
}
8383

8484
/**
85-
* @public function renderPermissionsHandler
85+
* @public function render
86+
* @param null
87+
*
88+
* @return bool|string
89+
*/
90+
public function renderClass()
91+
{
92+
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
93+
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
94+
$module = $this->getModule();
95+
$filename = $this->getFileName();
96+
$moduleDirname = $module->getVar('mod_dirname');
97+
$namespace = $pc->getPhpCodeNamespace(['XoopsModules', $moduleDirname]);
98+
$content = $this->getHeaderFilesComments($module, null, $namespace);
99+
$content .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname]);
100+
$content .= $pc->getPhpCodeDefined();
101+
$content .= $pc->getPhpCodeCommentMultiLine(['Class Object' => $this->className]);
102+
$cCl = $pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t");
103+
$constr = '';
104+
$cCl .= $pc->getPhpCodeFunction('__construct', '', $constr, 'public ', false, "\t");
105+
$arrGetInstance = ['@static function' => '&getInstance', '' => '', '@param' => 'null'];
106+
$cCl .= $pc->getPhpCodeCommentMultiLine($arrGetInstance, "\t");
107+
$getInstance = $pc->getPhpCodeVariableClass('static', 'instance', 'false', "\t\t");
108+
$instance = $xc->getXcEqualsOperator('$instance', 'new self()', null, "\t\t\t");
109+
$getInstance .= $pc->getPhpCodeConditions('!$instance', '', '', $instance, false, "\t\t");
110+
$cCl .= $pc->getPhpCodeFunction('getInstance', '', $getInstance, 'public static ', false, "\t");
111+
$content .= $pc->getPhpCodeClass($this->className, $cCl, '\XoopsObject');
112+
113+
$this->create($moduleDirname, 'class', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);
114+
115+
return $this->renderFile();
116+
}
117+
118+
/**
119+
* @public function getGlobalPerms
86120
* @param null
87121
*
88122
* @return bool|string
@@ -146,42 +180,6 @@ public function getGlobalPerms($permId)
146180
return $functions;
147181
}
148182

149-
/**
150-
* @public function render
151-
* @param null
152-
*
153-
* @return bool|string
154-
*/
155-
public function renderClass()
156-
{
157-
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
158-
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
159-
$module = $this->getModule();
160-
$filename = $this->getFileName();
161-
$moduleDirname = $module->getVar('mod_dirname');
162-
$namespace = $pc->getPhpCodeNamespace(['XoopsModules', $moduleDirname]);
163-
$content = $this->getHeaderFilesComments($module, null, $namespace);
164-
$content .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname]);
165-
$content .= $pc->getPhpCodeDefined();
166-
$content .= $pc->getPhpCodeCommentMultiLine(['Class Object' => $this->className]);
167-
$cCl = $pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t");
168-
$constr = '';
169-
$cCl .= $pc->getPhpCodeFunction('__construct', '', $constr, 'public ', false, "\t");
170-
$arrGetInstance = ['@static function' => '&getInstance', '' => '', '@param' => 'null'];
171-
$cCl .= $pc->getPhpCodeCommentMultiLine($arrGetInstance, "\t");
172-
$getInstance = $pc->getPhpCodeVariableClass('static', 'instance', 'false', "\t\t");
173-
$instance = $xc->getXcEqualsOperator('$instance', 'new self()', null, "\t\t\t");
174-
$getInstance .= $pc->getPhpCodeConditions('!$instance', '', '', $instance, false, "\t\t");
175-
$cCl .= $pc->getPhpCodeFunction('getInstance', '', $getInstance, 'public static ', false, "\t");
176-
$content .= $pc->getPhpCodeClass($this->className, $cCl, '\XoopsObject');
177-
178-
$this->create($moduleDirname, 'class', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);
179-
180-
181-
182-
return $this->renderFile();
183-
}
184-
185183
/**
186184
* @public function renderPermissionsHandler
187185
* @param null
@@ -213,6 +211,12 @@ public function renderPermissionsHandler()
213211
return $this->renderFile();
214212
}
215213

214+
/**
215+
* @public function renderConstantsInterface
216+
* @param null
217+
*
218+
* @return bool|string
219+
*/
216220
public function renderConstantsInterface()
217221
{
218222
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- added permission check approve (goffy)
2424
- fixed bug for active settings (goffy)
2525
- restructured admin language file/removed duuplicates (goffy)
26+
- implementation new xoops_confirm - step 1 (goffy)
2627

2728
<h5>3.03 Alpha 3 [WORK IN PROGRESS - NOT RELEASED]</h5> Dev: XOOPS 2.5.11, PHP 7.4.5
2829
<hr>

0 commit comments

Comments
 (0)