Skip to content

Commit b5d48bf

Browse files
committed
- added start/limit handling
1 parent da8be57 commit b5d48bf

File tree

7 files changed

+33
-20
lines changed

7 files changed

+33
-20
lines changed

class/Files/Classes/ClassFiles.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ private function getClassObject($module, $table, $fields)
222222
$cCl .= $this->pc->getPhpCodeVariableClass('private', 'options', $options);
223223
}
224224
unset($optionsFieldName);
225-
225+
$cCl .= $this->pc->getPhpCodeCommentMultiLine(['@var' => 'int'], "\t");
226+
$cCl .= $this->pc->getPhpCodeVariableClass('public', 'start', '0', "\t");
227+
$cCl .= $this->pc->getPhpCodeCommentMultiLine(['@var' => 'int'], "\t");
228+
$cCl .= $this->pc->getPhpCodeVariableClass('public', 'limit', '0', "\t");
226229
$cCl .= $this->pc->getPhpCodeCommentMultiLine(['Constructor' => '', '' => '', '@param' => 'null'], "\t");
227230
$constr = $this->getInitVars($fields);
228231
$cCl .= $this->pc->getPhpCodeFunction('__construct', '', $constr, 'public ', false, "\t");
@@ -321,6 +324,8 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm)
321324
$getForm .= $this->pc->getPhpCodeCommentLine('To Save', '', "\t\t");
322325
//$hiddenSave = $cc->getClassXoopsFormHidden('', "'op'", "'save'", true, false);
323326
$getForm .= $this->cxc->getClassAddElement('form', "new \XoopsFormHidden('op', 'save')");
327+
$getForm .= $this->cxc->getClassAddElement('form', "new \XoopsFormHidden('start', \$this->start)");
328+
$getForm .= $this->cxc->getClassAddElement('form', "new \XoopsFormHidden('limit', \$this->limit)");
324329
$getForm .= $this->cxc->getClassAddElement('form', "new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)");
325330
$getForm .= $this->getSimpleString('return $form;', "\t\t");
326331

class/Files/CreateXoopsCode.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ public function getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, $
10311031
$pc = Modulebuilder\Files\CreatePhpCode::getInstance();
10321032
$xc = Modulebuilder\Files\CreateXoopsCode::getInstance();
10331033

1034-
$array = "['ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'op' => '{$options}']";
1034+
$array = "['ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'start' => \$start, 'limit' => \$limit, 'op' => '{$options}']";
10351035
$server = $pc->getPhpCodeGlobalsVariables('REQUEST_URI', 'SERVER');
10361036
$getVar = $this->getXcGetVar('', $tableName . 'Obj', $fieldMain, true, '');
10371037
$sprintf = $pc->getPhpCodeSprintf($language . 'FORM_SURE_' . $stuOptions, $getVar);
@@ -1760,6 +1760,8 @@ public function getXcCommonPagesEdit($tableName, $ccFieldId, $t = '')
17601760

17611761
$ret = $pc->getPhpCodeCommentLine('Get Form', null, "\t\t");
17621762
$ret .= $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t);
1763+
$ret .= $xc->getXcEqualsOperator("\${$tableName}Obj->start", '$start', null, $t);
1764+
$ret .= $xc->getXcEqualsOperator("\${$tableName}Obj->limit", '$limit', null, $t);
17631765
$ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t);
17641766
$ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t);
17651767

class/Files/Templates/Admin/TemplatesAdminPages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $t
209209
$double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id');
210210
$src = $this->sc->getSmartyNoSimbol('xoModuleIcons16 edit.png');
211211
$img = $this->hc->getHtmlTag('img', ['src' => $src, 'alt' => $lang . ' ' . $tableName], '', true,'', '');
212-
$anchor = $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&{$fieldId}=" . $double, 'title' => $lang], $img, false, "\t\t\t\t\t");
212+
$anchor = $this->hc->getHtmlTag('a', ['href' => $tableName . ".php?op=edit&amp;{$fieldId}=" . $double . '&amp;start=<{$start}>&amp;limit=<{$limit}>', 'title' => $lang], $img, false, "\t\t\t\t\t");
213213
$lang = $this->sc->getSmartyConst('', '_CLONE');
214214
$double = $this->sc->getSmartyDoubleVar($tableSoleName, 'id');
215215
$src = $this->sc->getSmartyNoSimbol('xoModuleIcons16 editcopy.png');

class/Files/Templates/User/Defstyle/PagesItem.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,20 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table
183183

184184
$anchors = '';
185185
$lang = $this->sc->getSmartyConst($language, \mb_strtoupper($tableName) . '_LIST');
186-
$contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=list&amp;#{$ccFieldId}_" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n");
186+
$contIf = $this->hc->getHtmlAnchor($tableName . '.php?op=list&amp;start=<{$start}>&amp;limit=<{$limit}>#' .$ccFieldId . '_' . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n");
187187
$lang = $this->sc->getSmartyConst($language, 'DETAILS');
188-
$contElse = $this->hc->getHtmlAnchor($tableName . ".php?op=show&amp;{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n");
188+
$contElse = $this->hc->getHtmlAnchor($tableName . ".php?op=show&amp;{$fieldId}=" . $keyDouble . '&amp;start=<{$start}>&amp;limit=<{$limit}>', $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n");
189189
$anchors .= $this->sc->getSmartyConditions('showItem', '', '', $contIf, $contElse, '', '', "\t\t");
190190
$lang = $this->sc->getSmartyConst('', '_EDIT');
191-
$contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=edit&amp;{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n");
191+
$contIf = $this->hc->getHtmlAnchor($tableName . ".php?op=edit&amp;{$fieldId}=" . $keyDouble . '&amp;start=<{$start}>&amp;limit=<{$limit}>', $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n");
192192
$lang = $this->sc->getSmartyConst('', '_CLONE');
193193
$contIf .= $this->hc->getHtmlAnchor($tableName . ".php?op=clone&amp;{$fieldId}_source=" . $keyDouble, $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n");
194194
$lang = $this->sc->getSmartyConst('', '_DELETE');
195195
$contIf .= $this->hc->getHtmlAnchor($tableName . ".php?op=delete&amp;{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-danger right', '', "\t\t\t", "\n");
196196
$anchors .= $this->sc->getSmartyConditions('permEdit', '', '', $contIf, false, '', '', "\t\t");
197197
if (1 == $tableBroken) {
198198
$lang = $this->sc->getSmartyConst($language, 'BROKEN');
199-
$anchors .= $this->hc->getHtmlAnchor($tableName . ".php?op=broken&amp;{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-warning right', '', "\t\t", "\n");
199+
$anchors .= $this->hc->getHtmlAnchor($tableName . ".php?op=broken&amp;{$fieldId}=" . $keyDouble . '&amp;start=<{$start}>&amp;limit=<{$limit}>', $lang, $lang, '', 'btn btn-warning right', '', "\t\t", "\n");
200200
}
201201
$retFoot .= $this->hc->getHtmlDiv($anchors, 'col-sm-12 right',"\t", "\n");
202202
$ret .= $this->hc->getHtmlDiv($retFoot, 'panel-foot');

class/Files/User/UserPages.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ private function getUserPagesHeader($moduleDirname, $tableName, $fieldId, $table
113113
$ret .= $this->pc->getPhpCodeIncludeDir('\XOOPS_ROOT_PATH', 'header', true);
114114
$ret .= $this->pc->getPhpCodeBlankLine();
115115
$ret .= $this->xc->getXcXoopsRequest('op ', 'op', 'list', 'Cmd');
116+
$ret .= $this->xc->getXcXoopsRequest($ccFieldId, $fieldId, '0', 'Int');
116117
$ret .= $this->xc->getXcXoopsRequest('start', 'start', '0', 'Int');
117118
$userpager = $this->xc->getXcGetConfig('userpager');
118119
$ret .= $this->xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int');
119-
$ret .= $this->xc->getXcXoopsRequest($ccFieldId, $fieldId, '0', 'Int');
120+
$ret .= $this->xc->getXcXoopsTplAssign('start', '$start');
121+
$ret .= $this->xc->getXcXoopsTplAssign('limit', '$limit');
120122
$ret .= $this->pc->getPhpCodeBlankLine();
121123
$ret .= $this->pc->getPhpCodeCommentLine('Define Stylesheet');
122124
$ret .= $this->xc->getXcXoThemeAddStylesheet();
@@ -180,8 +182,9 @@ private function getUserPagesList($moduleDirname, $tableName, $fieldId, $fieldMa
180182
$ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $contIf, false, $t);
181183
$ret .= $this->xc->getXcHandlerCountClear($tableName . 'Count', $tableName, '$' . $critName, $t);
182184
$ret .= $this->xc->getXcXoopsTplAssign($tableName . 'Count', "\${$tableName}Count", '', $t);
183-
$ret .= $this->xc->getXcCriteriaSetStart($critName, '$start', $t);
184-
$ret .= $this->xc->getXcCriteriaSetLimit($critName, '$limit', $t);
185+
$contIf = $this->xc->getXcCriteriaSetStart($critName, '$start', $t . "\t");
186+
$contIf .= $this->xc->getXcCriteriaSetLimit($critName, '$limit', $t . "\t");
187+
$ret .= $this->pc->getPhpCodeConditions("\${$ccFieldId}", ' === ', '0', $contIf, false, $t);
185188
$ret .= $this->xc->getXcHandlerAllClear($tableName . 'All', $tableName, '$' . $critName, $t);
186189
$condIf = $this->pc->getPhpCodeArray($tableName, null, false, $t . "\t");
187190
$condIf .= $this->xc->getXcEqualsOperator("\${$ccFieldMain}", "''",'', $t . "\t");
@@ -343,10 +346,10 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole
343346
$contentInsert .= $this->pc->getPhpCodeCommentLine('redirect after insert', null, $t . "\t");
344347
if ($countUploader > 0) {
345348
$errIf = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \$new{$ucfFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t");
346-
$errElse = $this->xc->getXcRedirectHeader($tableName, '?op=list', '2', "{$language}FORM_OK", true, $t . "\t\t");
349+
$errElse = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&amp;start=' . \$start . '&amp;limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t");
347350
$confirmOk = $this->pc->getPhpCodeConditions('$uploaderErrors', ' !== ', "''", $errIf, $errElse, $t . "\t");
348351
} else {
349-
$confirmOk = $this->xc->getXcRedirectHeader($tableName, '', '2', "{$language}FORM_OK", true, $t . "\t");
352+
$confirmOk = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&amp;start=' . \$start . '&amp;limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t");
350353
}
351354
$contentInsert .= $confirmOk;
352355
$ret .= $this->pc->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t);
@@ -531,7 +534,7 @@ private function getUserPagesBroken($language, $moduleDirname, $tableName, $tabl
531534
$contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_broken', \$tags);", $t . "\t\t");
532535
$contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \${$ccFieldId}, '{$tableSoleName}_broken', \$tags);", $t . "\t\t");
533536
}
534-
$contInsert .= $this->xc->getXcRedirectHeader($tableName, '', '3', "{$language}FORM_OK", true, $t . "\t\t");
537+
$contInsert .= $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&amp;start=' . \$start . '&amp;limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t");
535538
$htmlErrors = $this->xc->getXcHtmlErrors($tableName, true);
536539
$internalElse = $this->xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t");
537540
$condition .= $this->pc->getPhpCodeConditions($insert, '', '', $contInsert, $internalElse, $t . "\t");

class/Files/admin/AdminPages.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ private function getAdminPagesHeader($moduleDirname, $fieldId)
105105
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants'], '', '');
106106
$ret .= $this->pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Common']);
107107
$ret .= $this->getRequire();
108-
$ret .= $this->pc->getPhpCodeCommentLine('It recovered the value of argument op in URL$');
108+
$ret .= $this->pc->getPhpCodeCommentLine('Get all request values');
109109
$ret .= $this->xc->getXcXoopsRequest('op', 'op', 'list', 'Cmd');
110-
$ret .= $this->pc->getPhpCodeCommentLine("Request {$fieldId}");
111110
$ret .= $this->xc->getXcXoopsRequest($ccFieldId, $fieldId, '', 'Int');
111+
$ret .= $this->xc->getXcXoopsRequest('start', 'start', '0', 'Int', false);
112+
$config = $this->xc->getXcGetConfig('adminpager');
113+
$ret .= $this->xc->getXcXoopsRequest('limit', 'limit', $config, 'Int', false);
114+
$ret .= $this->xc->getXcXoopsTplAssign('start', '$start');
115+
$ret .= $this->xc->getXcXoopsTplAssign('limit', '$limit');
116+
$ret .= $this->pc->getPhpCodeBlankLine();
112117

113118
return $ret;
114119
}
@@ -145,9 +150,6 @@ private function getAdminPagesList($moduleDirname, $table, $language, $fieldInFo
145150

146151
$ret = $this->pc->getPhpCodeCommentLine('Define Stylesheet', '', $t);
147152
$ret .= $this->xc->getXcXoThemeAddStylesheet('style', $t);
148-
$ret .= $this->xc->getXcXoopsRequest('start', 'start', '0', 'Int', false, $t);
149-
$adminpager = $this->xc->getXcGetConfig('adminpager');
150-
$ret .= $this->xc->getXcXoopsRequest('limit', 'limit', $adminpager, 'Int', false, $t);
151153
$ret .= $this->axc->getAdminTemplateMain($moduleDirname, $tableName, $t);
152154
$navigation = $this->axc->getAdminDisplayNavigation($tableName);
153155
$ret .= $this->xc->getXcXoopsTplAssign('navigation', $navigation, true, $t);
@@ -345,10 +347,10 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $
345347
}
346348
if ($countUploader > 0) {
347349
$errIf = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \${$ccFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t");
348-
$errElse = $this->xc->getXcRedirectHeader($tableName, '?op=list', '2', "{$language}FORM_OK", true, $t . "\t\t");
350+
$errElse = $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&amp;start=' . \$start . '&amp;limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t");
349351
$contentInsert .= $this->pc->getPhpCodeConditions('$uploaderErrors', ' !== ',"''" , $errIf, $errElse, $t . "\t");
350352
} else {
351-
$contentInsert .= $this->xc->getXcRedirectHeader($tableName . '', '?op=list', '2', "{$language}FORM_OK", true, $t . "\t");
353+
$contentInsert .= $this->xc->getXcRedirectHeader("'{$tableName}.php?op=list&amp;start=' . \$start . '&amp;limit=' . \$limit", '', '2', "{$language}FORM_OK", false, $t . "\t\t");
352354
}
353355
$ret .= $this->pc->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t);
354356
$ret .= $this->pc->getPhpCodeCommentLine('Get Form', null, $t);

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- updates for code quality (mamba/goffy)
3131
- added clone feature for items (mjoel/goffy)
3232
- update test data (mamba/goffy)
33+
- added start/limit handling (goffy)
3334

3435
<h5>3.04 Final [2020-11-11]</h5> Dev: XOOPS 2.5.11, PHP 7.4.5
3536
<hr>

0 commit comments

Comments
 (0)