Completed
Push — master ( 658b35...b781ca )
by Richard
28s queued 23s
created

publisher_editCat()   D

Complexity

Conditions 13
Paths 160

Size

Total Lines 164
Code Lines 130

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 13
eloc 130
nc 160
nop 4
dl 0
loc 164
rs 4.8933
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
use Xmf\Request;
13
use XoopsModules\Publisher;
14
use XoopsModules\Publisher\Form\CategoryForm;
15
use XoopsModules\Publisher\Helper;
16
17
/**
18
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
19
 * @license         GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
20
 * @package         Publisher
21
 * @since           1.0
22
 * @author          trabis <[email protected]>
23
 * @author          The SmartFactory <www.smartfactory.ca>
24
 * @version         $Id$
25
 */
26
require_once __DIR__ . '/admin_header.php';
27
28
$xoops = Xoops::getInstance();
29
$op = Request::getCmd('op');
30
31
$op = isset($_POST['editor']) ? 'mod' : $op;
32
if (isset($_POST['addcategory'])) {
33
    $op = 'addcategory';
34
}
35
36
// Where do we start ?
37
$startcategory = Request::getInt('startcategory');
38
$categoryid = Request::getInt('categoryid');
39
40
switch ($op) {
41
    case 'del':
42
        /* @var Publisher\Category $categoryObj */
43
        $categoryObj = $helper->getCategoryHandler()->get($categoryid);
44
        $confirm = $_POST['confirm'] ?? 0;
45
        $name = $_POST['name'] ?? '';
46
        if ($confirm) {
47
            if (!$helper->getCategoryHandler()->delete($categoryObj)) {
48
                $xoops->redirect('category.php', 1, _AM_PUBLISHER_DELETE_CAT_ERROR);
49
            }
50
            $xoops->redirect('category.php', 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name));
51
        } else {
52
            $xoops->header();
53
            echo $xoops->confirm(
54
                ['op' => 'del', 'categoryid' => $categoryObj->getVar('categoryid'), 'confirm' => 1, 'name' => $categoryObj->getVar('name')],
55
                'category.php',
56
                _AM_PUBLISHER_DELETECOL . " '" . $categoryObj->getVar('name') . "'. <br> <br>" . _AM_PUBLISHER_DELETE_CAT_CONFIRM,
57
                _AM_PUBLISHER_DELETE
58
            );
59
            $xoops->footer();
60
        }
61
        break;
62
    case 'mod':
63
        //Added by fx2024
64
        $nb_subcats = isset($_POST['nb_subcats']) ? (int)$_POST['nb_subcats'] : 0;
65
        $nb_subcats = $nb_subcats + (isset($_POST['nb_sub_yet']) ? (int)$_POST['nb_sub_yet'] : 4);
66
        //end of fx2024 code
67
68
        Publisher\Utils::cpHeader();
69
        publisher_editCat(true, $categoryid, $nb_subcats);
70
        break;
71
    case 'addcategory':
72
        global $modify;
73
74
        $parentid = Request::getInt('parentid');
75
        /* @var Publisher\Category $categoryObj */
76
        if (0 != $categoryid) {
77
            $categoryObj = $helper->getCategoryHandler()->get($categoryid);
78
        } else {
79
            $categoryObj = $helper->getCategoryHandler()->create();
80
        }
81
82
        // Uploading the image, if any
83
        // Retreive the filename to be uploaded
84
        if (isset($_FILES['image_file']['name']) && '' != $_FILES['image_file']['name']) {
85
            $filename = $_POST['xoops_upload_file'][0];
86
            if (!empty($filename) || '' != $filename) {
87
                // TODO : implement publisher mimetype management
88
                $max_size = $helper->getConfig('maximum_filesize');
89
                $max_imgwidth = $helper->getConfig('maximum_image_width');
90
                $max_imgheight = $helper->getConfig('maximum_image_height');
91
                $allowed_mimetypes = Publisher\Utils::getAllowedImagesTypes();
92
93
                if ('' == $_FILES[$filename]['tmp_name'] || !is_readable($_FILES[$filename]['tmp_name'])) {
94
                    $xoops->redirect('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
95
                }
96
97
                $uploader = new XoopsMediaUploader(Publisher\Utils::getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
98
                if ($uploader->fetchMedia($filename) && $uploader->upload()) {
99
                    $categoryObj->setVar('image', $uploader->getSavedFileName());
100
                } else {
101
                    $xoops->redirect('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR . $uploader->getErrors());
102
                }
103
            }
104
        } else {
105
            if (isset($_POST['image'])) {
106
                $categoryObj->setVar('image', $_POST['image']);
107
            }
108
        }
109
        $categoryObj->setVar('parentid', isset($_POST['parentid']) ? (int)$_POST['parentid'] : 0);
110
111
        $applyall = isset($_POST['applyall']) ? (int)$_POST['applyall'] : 0;
112
        $categoryObj->setVar('weight', isset($_POST['weight']) ? (int)$_POST['weight'] : 1);
113
114
        // Groups and permissions
115
        $grpread = $_POST['groups_read'] ?? [];
116
        $grpsubmit = $_POST['groups_submit'] ?? [];
117
        $grpmoderation = $_POST['groups_moderation'] ?? [];
118
119
        $categoryObj->setVar('name', $_POST['name']);
120
121
        //Added by skalpa: custom template support
122
        if (isset($_POST['template'])) {
123
            $categoryObj->setVar('template', $_POST['template']);
124
        }
125
126
        if (isset($_POST['meta_description'])) {
127
            $categoryObj->setVar('meta_description', $_POST['meta_description']);
128
        }
129
        if (isset($_POST['meta_keywords'])) {
130
            $categoryObj->setVar('meta_keywords', $_POST['meta_keywords']);
131
        }
132
        if (isset($_POST['short_url'])) {
133
            $categoryObj->setVar('short_url', $_POST['short_url']);
134
        }
135
        $categoryObj->setVar('moderator', (int)$_POST['moderator']);
136
        $categoryObj->setVar('description', $_POST['description']);
137
138
        if (isset($_POST['header'])) {
139
            $categoryObj->setVar('header', $_POST['header']);
140
        }
141
142
        if ($categoryObj->isNew()) {
143
            $redirect_msg = _AM_PUBLISHER_CATCREATED;
144
            $redirect_to = 'category.php?op=mod';
145
        } else {
146
            $redirect_msg = _AM_PUBLISHER_COLMODIFIED;
147
            $redirect_to = 'category.php';
148
        }
149
150
        if (!$categoryObj->store()) {
151
            $xoops->redirect('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . Publisher\Utils::formatErrors($categoryObj->getErrors()));
152
        }
153
        // TODO : put this function in the category class
154
        Publisher\Utils::saveCategoryPermissions($grpread, $categoryObj->getVar('categoryid'), 'category_read');
155
        Publisher\Utils::saveCategoryPermissions($grpsubmit, $categoryObj->getVar('categoryid'), 'item_submit');
156
        Publisher\Utils::saveCategoryPermissions($grpmoderation, $categoryObj->getVar('categoryid'), 'category_moderation');
157
158
        //Added by fx2024
159
        $parentCat = $categoryObj->getVar('categoryid');
160
        $sizeof = count($_POST['scname']);
161
        for ($i = 0; $i < $sizeof; ++$i) {
162
            if ('' != $_POST['scname'][$i]) {
163
                $categoryObj = $helper->getCategoryHandler()->create();
164
                $categoryObj->setVar('name', $_POST['scname'][$i]);
165
                $categoryObj->setVar('parentid', $parentCat);
166
167
                if (!$categoryObj->store()) {
168
                    $xoops->redirect('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . Publisher\Utils::formatErrors($categoryObj->getErrors()));
169
                }
170
                // TODO : put this function in the category class
171
                Publisher\Utils::saveCategoryPermissions($grpread, $categoryObj->getVar('categoryid'), 'category_read');
172
                Publisher\Utils::saveCategoryPermissions($grpsubmit, $categoryObj->getVar('categoryid'), 'item_submit');
173
                Publisher\Utils::saveCategoryPermissions($grpmoderation, $categoryObj->getVar('categoryid'), 'category_moderation');
174
            }
175
        }
176
        //end of fx2024 code
177
        $xoops->redirect($redirect_to, 2, $redirect_msg);
178
        break;
179
    //Added by fx2024
180
181
    case 'addsubcats':
182
        $categoryid = 0;
183
        $nb_subcats = (int)$_POST['nb_subcats'] + $_POST['nb_sub_yet'];
184
185
        $categoryObj = $helper->getCategoryHandler()->create();
186
        $categoryObj->setVar('name', $_POST['name']);
187
        $categoryObj->setVar('description', $_POST['description']);
188
        $categoryObj->setVar('weight', $_POST['weight']);
189
        if (isset($parentCat)) {
190
            $categoryObj->setVar('parentid', $parentCat);
191
        }
192
193
        Publisher\Utils::cpHeader();
194
        publisher_editCat(true, $categoryid, $nb_subcats, $categoryObj);
195
        exit();
196
197
        break;
198
    //end of fx2024 code
199
200
    case 'cancel':
201
        $xoops->redirect('category.php', 1, sprintf(_AM_PUBLISHER_BACK2IDX, ''));
202
        break;
203
    case 'default':
204
    default:
205
        Publisher\Utils::cpHeader();
206
        //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES);
207
208
        echo "<br>\n";
209
        echo '<form><div style="margin-bottom: 12px;">';
210
        echo "<input type='button' name='button' onclick=\"location='category.php?op=mod'\" value='" . _AM_PUBLISHER_CATEGORY_CREATE . "'>&nbsp;&nbsp;";
211
        //echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
212
        echo '</div></form>';
213
214
        // Creating the objects for top categories
215
        $categoriesObj = $helper->getCategoryHandler()->getCategories($helper->getConfig('idxcat_perpage'), $startcategory, 0);
216
217
        Publisher\Utils::openCollapsableBar('createdcategories', 'createdcategoriesicon', _AM_PUBLISHER_CATEGORIES_TITLE, _AM_PUBLISHER_CATEGORIES_DSC);
218
219
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
220
        echo '<tr>';
221
        echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
222
        echo "<td width='60' class='bg3' width='65' align='center'><strong>" . _CO_PUBLISHER_WEIGHT . '</strong></td>';
223
        echo "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
224
        echo '</tr>';
225
        $totalCategories = $helper->getCategoryHandler()->getCategoriesCount(0);
226
        if (count($categoriesObj) > 0) {
227
            foreach ($categoriesObj as $key => $thiscat) {
228
                publisher_displayCategory($thiscat);
229
            }
230
        } else {
231
            echo '<tr>';
232
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOCAT . '</td>';
233
            echo '</tr>';
234
            $categoryid = '0';
235
        }
236
        echo "</table>\n";
237
        $pagenav = new XoopsPageNav($totalCategories, $helper->getConfig('idxcat_perpage'), $startcategory, 'startcategory');
238
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
239
        echo '<br>';
240
        Publisher\Utils::closeCollapsableBar('createdcategories', 'createdcategoriesicon');
241
        echo '<br>';
242
        //editcat(false);
243
        break;
244
}
245
246
$xoops->footer();
247
248
/**
249
 * @param \XoopsModules\Publisher\Category $categoryObj
250
 * @param int                              $level
251
 */
252
/**
253
 * @param \XoopsModules\Publisher\Category $categoryObj
254
 * @param int                              $level
255
 */
256
function publisher_displayCategory(Publisher\Category $categoryObj, $level = 0)
257
{
258
    $helper = Helper::getInstance();
259
260
    $description = $categoryObj->getVar('description');
261
    if (!XoopsLocale::isMultiByte()) {
0 ignored issues
show
Deprecated Code introduced by
The function Xoops\Locale\AbstractLocale::isMultiByte() has been deprecated: since 2.6.0 -- UTF-8 is always used ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

261
    if (!/** @scrutinizer ignore-deprecated */ XoopsLocale::isMultiByte()) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
262
        if (mb_strlen($description) >= 100) {
0 ignored issues
show
Bug introduced by
It seems like $description can also be of type string[]; however, parameter $str of mb_strlen() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

262
        if (mb_strlen(/** @scrutinizer ignore-type */ $description) >= 100) {
Loading history...
263
            $description = mb_substr($description, 0, 100 - 1) . '...';
0 ignored issues
show
Bug introduced by
It seems like $description can also be of type string[]; however, parameter $str of mb_substr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

263
            $description = mb_substr(/** @scrutinizer ignore-type */ $description, 0, 100 - 1) . '...';
Loading history...
Unused Code introduced by
The assignment to $description is dead and can be removed.
Loading history...
264
        }
265
    }
266
    $modify = "<a href='category.php?op=mod&amp;categoryid=" . $categoryObj->getVar('categoryid') . '&amp;parentid=' . $categoryObj->getVar('parentid') . "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif' title='" . _AM_PUBLISHER_EDITCOL . "' alt='" . _AM_PUBLISHER_EDITCOL . "'></a>";
267
    $delete = "<a href='category.php?op=del&amp;categoryid=" . $categoryObj->getVar('categoryid') . "'><img src='" . PUBLISHER_URL . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETECOL . "' alt='" . _AM_PUBLISHER_DELETECOL . "'></a>";
268
269
    $spaces = '';
270
    for ($j = 0; $j < $level; ++$j) {
271
        $spaces .= '&nbsp;&nbsp;&nbsp;';
272
    }
273
274
    echo '<tr>';
275
    echo "<td class='even' align='left'>" . $spaces . "<a href='" . PUBLISHER_URL . '/category.php?categoryid=' . $categoryObj->getVar('categoryid') . "'><img src='" . PUBLISHER_URL . "/images/links/subcat.gif' alt=''>&nbsp;" . $categoryObj->getVar('name') . '</a></td>';
276
    echo "<td class='even' align='center'>" . $categoryObj->getVar('weight') . '</td>';
277
    echo "<td class='even' align='center'> $modify $delete </td>";
278
    echo '</tr>';
279
    $subCategoriesObj = $helper->getCategoryHandler()->getCategories(0, 0, $categoryObj->getVar('categoryid'));
280
    if (count($subCategoriesObj) > 0) {
281
        ++$level;
282
        foreach ($subCategoriesObj as $thiscat) {
283
            publisher_displayCategory($thiscat, $level);
284
        }
285
    }
286
    unset($categoryObj);
287
}
288
289
/**
290
 * @param bool $showmenu
291
 * @param int  $categoryid
292
 * @param int  $nb_subcats
293
 * @param null $categoryObj
294
 */
295
/**
296
 * @param bool $showmenu
297
 * @param int  $categoryid
298
 * @param int  $nb_subcats
299
 * @param null $categoryObj
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $categoryObj is correct as it would always require null to be passed?
Loading history...
300
 */
301
function publisher_editCat($showmenu = false, $categoryid = 0, $nb_subcats = 4, $categoryObj = null)
302
{
303
    $xoops = Xoops::getInstance();
304
    $helper = Helper::getInstance();
305
    /* @var Publisher\Category $categoryObj */
306
307
    // if there is a parameter, and the id exists, retrieve data: we're editing a category
308
    if (0 != $categoryid) {
309
        // Creating the category object for the selected category
310
        $categoryObj = $helper->getCategoryHandler()->get($categoryid);
311
        if ($categoryObj->notLoaded()) {
312
            $xoops->redirect('category.php', 1, _AM_PUBLISHER_NOCOLTOEDIT);
313
        }
314
    } else {
315
        if (!$categoryObj) {
0 ignored issues
show
introduced by
$categoryObj is of type XoopsModules\Publisher\Category, thus it always evaluated to true.
Loading history...
316
            $categoryObj = $helper->getCategoryHandler()->create();
317
        }
318
    }
319
320
    if (0 != $categoryid) {
321
        if ($showmenu) {
322
            //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_EDITING);
323
        }
324
        echo "<br>\n";
325
        Publisher\Utils::openCollapsableBar('edittable', 'edittableicon', _AM_PUBLISHER_EDITCOL, _AM_PUBLISHER_CATEGORY_EDIT_INFO);
326
    } else {
327
        if ($showmenu) {
328
            //publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES . " > " . _AM_PUBLISHER_CREATINGNEW);
329
        }
330
        Publisher\Utils::openCollapsableBar('createtable', 'createtableicon', _AM_PUBLISHER_CATEGORY_CREATE, _AM_PUBLISHER_CATEGORY_CREATE_INFO);
331
    }
332
333
    /* @var Publisher\Form\CategoryForm $sform */
334
    //    $sform = $helper->getForm($categoryObj, 'Category');
335
    $sform = new  CategoryForm($categoryObj);
0 ignored issues
show
Bug introduced by
It seems like $categoryObj can also be of type null; however, parameter $obj of XoopsModules\Publisher\F...goryForm::__construct() does only seem to accept XoopsModules\Publisher\Category, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

335
    $sform = new  CategoryForm(/** @scrutinizer ignore-type */ $categoryObj);
Loading history...
336
    $sform->setSubCatsCount($nb_subcats);
337
    $sform->display();
338
339
    if (!$categoryid) {
340
        Publisher\Utils::closeCollapsableBar('createtable', 'createtableicon');
341
    } else {
342
        Publisher\Utils::closeCollapsableBar('edittable', 'edittableicon');
343
    }
344
345
    //Added by fx2024
346
    if ($categoryid) {
347
        $sel_cat = $categoryid;
348
349
        Publisher\Utils::openCollapsableBar('subcatstable', 'subcatsicon', _AM_PUBLISHER_SUBCAT_CAT, _AM_PUBLISHER_SUBCAT_CAT_DSC);
350
        // Get the total number of sub-categories
351
        $categoriesObj = $helper->getCategoryHandler()->get($sel_cat);
352
        $totalsubs = $helper->getCategoryHandler()->getCategoriesCount($sel_cat);
353
        // creating the categories objects that are published
354
        $subcatsObj = $helper->getCategoryHandler()->getCategories(0, 0, $categoriesObj->getVar('categoryid'));
355
356
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
357
        echo '<tr>';
358
        echo "<td width='60' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATID . '</strong></td>';
359
        echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_CATCOLNAME . '</strong></td>';
360
        echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_SUBDESCRIPT . '</strong></td>';
361
        echo "<td width='60' class='bg3' align='right'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
362
        echo '</tr>';
363
        if ($totalsubs > 0) {
364
            /* @var Publisher\Category $subcat */
365
            foreach ($subcatsObj as $subcat) {
366
                $modify = "<a href='category.php?op=mod&amp;categoryid="
367
                          . $subcat->getVar('categoryid')
368
                          . "'><img src='"
369
                          . XoopsBaseConfig::get('url')
370
                          . '/modules/'
371
                          . $helper->getModule()->dirname()
372
                          . "/images/links/edit.gif' title='"
373
                          . _AM_PUBLISHER_MODIFY
374
                          . "' alt='"
375
                          . _AM_PUBLISHER_MODIFY
376
                          . "'></a>";
377
                $delete = "<a href='category.php?op=del&amp;categoryid="
378
                          . $subcat->getVar('categoryid')
379
                          . "'><img src='"
380
                          . XoopsBaseConfig::get('url')
381
                          . '/modules/'
382
                          . $helper->getModule()->dirname()
383
                          . "/images/links/delete.png' title='"
384
                          . _AM_PUBLISHER_DELETE
385
                          . "' alt='"
386
                          . _AM_PUBLISHER_DELETE
387
                          . "'></a>";
388
                echo '<tr>';
389
                echo "<td class='head' align='left'>" . $subcat->getVar('categoryid') . '</td>';
390
                echo "<td class='even' align='left'><a href='" . XoopsBaseConfig::get('url') . '/modules/' . $helper->getModule()->dirname() . '/category.php?categoryid=' . $subcat->getVar('categoryid') . '&amp;parentid=' . $subcat->getVar('parentid') . "'>" . $subcat->getVar('name') . '</a></td>';
391
                echo "<td class='even' align='left'>" . $subcat->getVar('description') . '</td>';
392
                echo "<td class='even' align='right'> {$modify} {$delete} </td>";
393
                echo '</tr>';
394
            }
395
        } else {
396
            echo '<tr>';
397
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOSUBCAT . '</td>';
398
            echo '</tr>';
399
        }
400
        echo "</table>\n";
401
        echo "<br>\n";
402
        Publisher\Utils::closeCollapsableBar('subcatstable', 'subcatsicon');
403
404
        Publisher\Utils::openCollapsableBar('bottomtable', 'bottomtableicon', _AM_PUBLISHER_CAT_ITEMS, _AM_PUBLISHER_CAT_ITEMS_DSC);
405
        $startitem = Request::getInt('startitem');
406
        // Get the total number of published ITEMS
407
        $totalitems = $helper->getItemHandler()->getItemsCount($sel_cat, [_PUBLISHER_STATUS_PUBLISHED]);
408
        // creating the items objects that are published
409
        $itemsObj = $helper->getItemHandler()->getAllPublished($helper->getConfig('idxcat_perpage'), $startitem, $sel_cat);
410
        $allcats = $helper->getCategoryHandler()->getObjects(null, true);
411
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
412
        echo '<tr>';
413
        echo "<td width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
414
        echo "<td width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCOLNAME . '</strong></td>';
415
        echo "<td class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMDESC . '</strong></td>';
416
        echo "<td width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
417
        echo "<td width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
418
        echo '</tr>';
419
        if ($totalitems > 0) {
420
            foreach ($itemsObj as $iValue) {
421
                $categoryObj = $allcats[$iValue->getVar('categoryid')];
422
                $modify = "<a href='item.php?op=mod&amp;itemid="
423
                               . $iValue->getVar('itemid')
424
                               . "'><img src='"
425
                               . XoopsBaseConfig::get('url')
426
                               . '/modules/'
427
                               . $helper->getModule()->dirname()
428
                               . "/images/links/edit.gif' title='"
429
                               . _AM_PUBLISHER_EDITITEM
430
                               . "' alt='"
431
                               . _AM_PUBLISHER_EDITITEM
432
                               . "'></a>";
433
                $delete = "<a href='item.php?op=del&amp;itemid="
434
                               . $iValue->getVar('itemid')
435
                               . "'><img src='"
436
                               . XoopsBaseConfig::get('url')
437
                               . '/modules/'
438
                               . $helper->getModule()->dirname()
439
                               . "/images/links/delete.png' title='"
440
                               . _AM_PUBLISHER_DELETEITEM
441
                               . "' alt='"
442
                               . _AM_PUBLISHER_DELETEITEM
443
                               . "'></a>";
444
                echo '<tr>';
445
                echo "<td class='head' align='center'>" . $iValue->getVar('itemid') . '</td>';
446
                echo "<td class='even' align='left'>" . $categoryObj->getVar('name') . '</td>';
447
                echo "<td class='even' align='left'>" . $iValue->getitemLink() . '</td>';
448
                echo "<td class='even' align='center'>" . $iValue->datesub('s') . '</td>';
449
                echo "<td class='even' align='center'> $modify $delete </td>";
450
                echo '</tr>';
451
            }
452
        } else {
453
            echo '<tr>';
454
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS . '</td>';
455
            echo '</tr>';
456
        }
457
        echo "</table>\n";
458
        echo "<br>\n";
459
        $parentid = Request::getInt('parentid');
460
        $pagenav_extra_args = "op=mod&categoryid=$sel_cat&parentid=$parentid";
461
        $pagenav = new XoopsPageNav($totalitems, $helper->getConfig('idxcat_perpage'), $startitem, 'startitem', $pagenav_extra_args);
462
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
463
        echo "<input type='button' name='button' onclick=\"location='item.php?op=mod&categoryid=" . $sel_cat . "'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
464
        echo '</div>';
465
    }
466
    //end of fx2024 code
467
}
468