Skip to content

Commit 11d4efc

Browse files
authored
Merge pull request #29 from ggoffy/master
fixed bugs
2 parents f0fae3b + 4c71310 commit 11d4efc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2931
-2715
lines changed

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'];

assets/js/functions.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ $(document).ready(function () {
7676
});
7777
});
7878

79+
function modulebuilder_setStatus(data, img, file) {
80+
// Post request
81+
$.post(file, data, function (reponse, textStatus) {
82+
if (textStatus == 'success') {
83+
$('img#' + img).hide();
84+
$('#loading_' + img).show();
85+
setTimeout(function () {
86+
$('#loading_' + img).hide();
87+
$('img#' + img).fadeIn('fast');
88+
}, 500);
89+
// Change image src
90+
if ($('img#' + img).attr("src") == IMG_ON) {
91+
$('img#' + img).attr("src", IMG_OFF);
92+
} else {
93+
$('img#' + img).attr("src", IMG_ON);
94+
}
95+
}
96+
});
97+
}
98+
7999
function presetField(typeId) {
80100

81101
eleSelected = xoopsGetElementById('field_element[' + typeId + ']');

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:<[email protected]> - 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/Admin/AdminBroken.php

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,31 @@
3131
*/
3232
class AdminBroken extends Files\CreateFile
3333
{
34+
/**
35+
* @var mixed
36+
*/
37+
private $axc = null;
38+
39+
/**
40+
* @var mixed
41+
*/
42+
private $xc = null;
43+
44+
/**
45+
* @var mixed
46+
*/
47+
private $pc = null;
48+
3449
/**
3550
* @public function constructor
3651
* @param null
3752
*/
3853
public function __construct()
3954
{
4055
parent::__construct();
56+
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
57+
$this->pc = Modulebuilder\Files\CreatePhpCode::getInstance();
58+
$this->axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance();
4159
}
4260

4361
/**
@@ -78,19 +96,16 @@ public function write($module, $tables, $filename)
7896
*/
7997
private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
8098
{
81-
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
82-
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
83-
$axc = Modulebuilder\Files\Admin\AdminXoopsCode::getInstance();
84-
$ret = $pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', '');
85-
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', '');
86-
$ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']);
99+
$ret = $this->pc->getPhpCodeUseNamespace(['Xmf', 'Request'], '', '');
100+
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', '');
101+
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']);
87102
$ret .= $this->getInclude();
88-
$ret .= $pc->getPhpCodeBlankLine();
89-
$ret .= $pc->getPhpCodeCommentLine('Define Stylesheet', '', $t);
90-
$ret .= $xc->getXcXoThemeAddStylesheet('style', $t);
91-
$ret .= $axc->getAdminTemplateMain($moduleDirname, $tableName, $t);
92-
$navigation = $axc->getAdminDisplayNavigation($tableName);
93-
$ret .= $xc->getXcXoopsTplAssign('navigation', $navigation, true, $t);
103+
$ret .= $this->pc->getPhpCodeBlankLine();
104+
$ret .= $this->pc->getPhpCodeCommentLine('Define Stylesheet', '', $t);
105+
$ret .= $this->xc->getXcXoThemeAddStylesheet('style', $t);
106+
$ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t);
107+
$navigation = $this->axc->getAdminDisplayNavigation($tableName);
108+
$ret .= $this->xc->getXcXoopsTplAssign('navigation', $navigation, true, $t);
94109

95110
return $ret;
96111
}
@@ -104,20 +119,17 @@ private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '')
104119
*/
105120
private function getAdminBrokenList($tables, $language, $t = '')
106121
{
107-
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
108-
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
109-
110122
$ret = '';
111123
foreach (array_keys($tables) as $i) {
112124
if (1 === (int)$tables[$i]->getVar('table_broken')) {
113125
$tableName = $tables[$i]->getVar('table_name');
114126
$tableSoleName = $tables[$i]->getVar('table_solename');
115127
$ucfTableName = ucfirst($tableName);
116-
$ret .= $pc->getPhpCodeBlankLine();
117-
$ret .= $pc->getPhpCodeCommentLine('Check table', $tableName, $t);
118-
$ret .= $xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '0', 'Int', false, $t);
119-
$adminpager = $xc->getXcGetConfig('adminpager');
120-
$ret .= $xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, $t);
128+
$ret .= $this->pc->getPhpCodeBlankLine();
129+
$ret .= $this->pc->getPhpCodeCommentLine('Check table', $tableName, $t);
130+
$ret .= $this->xc->getXcXoopsRequest('start', 'start' . $ucfTableName, '0', 'Int', false, $t);
131+
$adminpager = $this->xc->getXcGetConfig('adminpager');
132+
$ret .= $this->xc->getXcXoopsRequest('limit', 'limit' . $ucfTableName, $adminpager, 'Int', false, $t);
121133
$critName = 'cr' . $ucfTableName;
122134

123135
$fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id'));
@@ -137,34 +149,34 @@ private function getAdminBrokenList($tables, $language, $t = '')
137149
}
138150
}
139151

140-
$ret .= $xc->getXcCriteriaCompo($critName, $t);
141-
$constant = $xc->getXcGetConstants('STATUS_BROKEN');
142-
$crit = $xc->getXcCriteria('', "'{$fieldSatus}'", $constant, '', true);
143-
$ret .= $xc->getXcCriteriaAdd($critName, $crit, $t, "\n");
144-
$ret .= $xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t);
145-
$ret .= $xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, $t);
146-
$sprintf = $pc->getPhpCodeSprintf($language . 'BROKEN_RESULT', "'{$ucfTableName}'");
147-
$ret .= $xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, $t);
148-
149-
$ret .= $xc->getXcCriteriaSetStart($critName,'$start', $t);
150-
$ret .= $xc->getXcCriteriaSetLimit($critName,'$limit', $t);
151-
$contIf = $xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", $t . "\t");
152-
$foreach = $xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', $t . "\t\t");
153-
$foreach .= $xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', $t . "\t\t");
154-
$foreach .= $xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, $t . "\t\t");
155-
$foreach .= $xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, $t . "\t\t");
156-
$foreach .= $xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t");
157-
$contIf .= $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t");
158-
$contIf .= $xc->getXcPageNav($tableName, $t . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit");
159-
$sprintf = $pc->getPhpCodeSprintf($language . 'BROKEN_NODATA', "'{$ucfTableName}'");
160-
$contElse = $xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, $t . "\t");
161-
162-
$ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, $t);
163-
$ret .= $pc->getPhpCodeUnset($critName, $t);
152+
$ret .= $this->xc->getXcCriteriaCompo($critName, $t);
153+
$constant = $this->xc->getXcGetConstants('STATUS_BROKEN');
154+
$crit = $this->xc->getXcCriteria('', "'{$fieldSatus}'", $constant, '', true);
155+
$ret .= $this->xc->getXcCriteriaAdd($critName, $crit, $t, "\n");
156+
$ret .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t);
157+
$ret .= $this->xc->getXcXoopsTplAssign($tableName . '_count', "\${$tableName}Count", true, $t);
158+
$sprintf = $this->pc->getPhpCodeSprintf($language . 'BROKEN_RESULT', "'{$ucfTableName}'");
159+
$ret .= $this->xc->getXcXoopsTplAssign($tableName . '_result', $sprintf, true, $t);
160+
161+
$ret .= $this->xc->getXcCriteriaSetStart($critName,'$start', $t);
162+
$ret .= $this->xc->getXcCriteriaSetLimit($critName,'$limit', $t);
163+
$contIf = $this->xc->getXcHandlerAllClear("{$tableName}All", $tableName, "\${$critName}", $t . "\t");
164+
$foreach = $this->xc->getXcEqualsOperator("\${$tableSoleName}['table']", "'{$ucfTableName}'", '', $t . "\t\t");
165+
$foreach .= $this->xc->getXcEqualsOperator("\${$tableSoleName}['key']", "'{$fieldId}'", '', $t . "\t\t");
166+
$foreach .= $this->xc->getXcGetVar("{$tableSoleName}['keyval']", "{$tableName}All[\$i]", "{$fieldId}", false, $t . "\t\t");
167+
$foreach .= $this->xc->getXcGetVar("{$tableSoleName}['main']", "{$tableName}All[\$i]", "{$fieldMain}", false, $t . "\t\t");
168+
$foreach .= $this->xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t");
169+
$contIf .= $this->pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $foreach, $t . "\t");
170+
$contIf .= $this->xc->getXcPageNav($tableName, $t . "\t", 'start' . $ucfTableName, "'op=list&limit{$ucfTableName}=' . \$limit");
171+
$sprintf = $this->pc->getPhpCodeSprintf($language . 'BROKEN_NODATA', "'{$ucfTableName}'");
172+
$contElse = $this->xc->getXcXoopsTplAssign('nodata' . $ucfTableName, $sprintf, true, $t . "\t");
173+
174+
$ret .= $this->pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $contIf, $contElse, $t);
175+
$ret .= $this->pc->getPhpCodeUnset($critName, $t);
164176
}
165177
}
166178

167-
$ret .= $pc->getPhpCodeBlankLine();
179+
$ret .= $this->pc->getPhpCodeBlankLine();
168180

169181
return $ret;
170182
}

0 commit comments

Comments
 (0)