Passed
Push — master ( df5caf...cd5737 )
by Michael
02:02
created

ClassifiedsTree   F

Complexity

Total Complexity 73

Size/Duplication

Total Lines 466
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 73
c 0
b 0
f 0
dl 0
loc 466
rs 2.459

14 Methods

Rating   Name   Duplication   Size   Complexity  
D makeMySelBox() 0 46 11
A getCategoryList() 0 13 2
B getChildTreeArray() 0 26 6
B getAllParentId() 0 21 5
A getIdPathFromId() 0 15 3
B getChildTreeMapArray() 0 25 6
C makeAdSelBox() 0 46 8
B getAllChild() 0 24 6
A getNicePathFromId() 0 21 3
B getAllChildId() 0 24 6
B getFirstChild() 0 24 6
B getFirstChildId() 0 20 5
B getPathFromId() 0 26 5
A __construct() 0 6 1

How to fix   Complexity   

Complex Class

Complex classes like ClassifiedsTree often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ClassifiedsTree, and based on these observations, apply Extract Interface, too.

1
<?php namespace XoopsModules\Adslight;
2
/*
3
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
23
use XoopsModules\Adslight;
24
25
/**
26
 * Class ClassifiedsTree
27
 */
28
class ClassifiedsTree
29
{
30
    public $table;
31
    public $id;
32
    public $pid;
33
    public $order;
34
    public $title;
35
    public $db;
36
37
    /**
38
     * @param $table_name
39
     * @param $id_name
40
     * @param $pid_name
41
     */
42
    public function __construct($table_name, $id_name, $pid_name)
43
    {
44
        $this->db    = \XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
Bug introduced by
The type XoopsDatabaseFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
45
        $this->table = $table_name;
46
        $this->id    = $id_name;
47
        $this->pid   = $pid_name;
48
    }
49
50
    /**
51
     * @param int    $sel_id
52
     * @param string $order
53
     *
54
     * @return array
55
     */
56
    public function getFirstChild($sel_id, $order = '')
57
    {
58
        $arr = [];
59
        $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . (int)$sel_id . '';
60
61
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
62
        if (is_array($categories) && count($categories) > 0) {
63
            $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') ';
64
        }
65
66
        if ('' != $order) {
67
            $sql .= " ORDER BY $order";
68
        }
69
70
        $result = $this->db->query($sql);
71
        $count  = $this->db->getRowsNum($result);
72
        if (0 == $count) {
73
            return $arr;
74
        }
75
       while (false !== ($myrow = $this->db->fetchArray($result))) {
76
            array_push($arr, $myrow);
77
        }
78
79
        return $arr;
80
    }
81
82
    /**
83
     * @param $sel_id
84
     *
85
     * @return array
86
     */
87
    public function getFirstChildId($sel_id)
88
    {
89
        $idarray = [];
90
        $sel_id  = (int)$sel_id;
91
        $result  = $this->db->query('SELECT SQL_CACHE ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id);
92
93
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
94
        if (is_array($categories) && count($categories) > 0) {
95
            $result .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') ';
96
        }
97
98
        $count = $this->db->getRowsNum($result);
99
        if (0 == $count) {
100
            return $idarray;
101
        }
102
        while (list($id) = $this->db->fetchRow($result)) {
103
            array_push($idarray, $id);
104
        }
105
106
        return $idarray;
107
    }
108
109
    /**
110
     * @param        $sel_id
111
     * @param string $order
112
     * @param array  $idarray
113
     *
114
     * @return array
115
     */
116
    public function getAllChildId($sel_id, $order = '', $idarray = [])
117
    {
118
        $sel_id = (int)$sel_id;
119
        $sql    = 'SELECT SQL_CACHE ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id;
120
121
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
122
        if (is_array($categories) && count($categories) > 0) {
123
            $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') ';
124
        }
125
126
        if ('' != $order) {
127
            $sql .= " ORDER BY {$order}";
128
        }
129
        $result = $this->db->query($sql);
130
        $count  = $this->db->getRowsNum($result);
131
        if (0 == $count) {
132
            return $idarray;
133
        }
134
        while (list($r_id) = $this->db->fetchRow($result)) {
135
            array_push($idarray, $r_id);
136
            $idarray = $this->getAllChildId($r_id, $order, $idarray);
137
        }
138
139
        return $idarray;
140
    }
141
142
    /**
143
     * @param        $sel_id
144
     * @param string $order
145
     * @param array  $idarray
146
     *
147
     * @return array
148
     */
149
    public function getAllParentId($sel_id, $order = '', $idarray = [])
150
    {
151
        $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id;
152
153
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
154
        if (is_array($categories) && count($categories) > 0) {
155
            $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') ';
156
        }
157
158
        if ('' != $order) {
159
            $sql .= " ORDER BY {$order}";
160
        }
161
        $result = $this->db->query($sql);
162
        list($r_id) = $this->db->fetchRow($result);
163
        if (0 == $r_id) {
164
            return $idarray;
165
        }
166
        array_push($idarray, $r_id);
167
        $idarray = $this->getAllParentId($r_id, $order, $idarray);
168
169
        return $idarray;
170
    }
171
172
    /**
173
     * @param        $sel_id
174
     * @param        $title
175
     * @param string $path
176
     *
177
     * @return string
178
     */
179
    public function getPathFromId($sel_id, $title, $path = '')
180
    {
181
        $sql = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id . '';
182
        //        $result = $this->db->query('SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $this->db->escape($sel_id) . "'");
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
183
184
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
185
        if (is_array($categories) && count($categories) > 0) {
186
            //            $result .= ' AND cid IN (' . implode(',', $categories) . ') ';
0 ignored issues
show
Unused Code Comprehensibility introduced by
41% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
187
            $sql .= ' AND cid IN (' . implode(',', $categories) . ') ';
188
        }
189
190
        $result = $this->db->query($sql);
191
192
        if (0 == $this->db->getRowsNum($result)) {
193
            return $path;
194
        }
195
        list($parentid, $name) = $this->db->fetchRow($result);
196
        $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Bug introduced by
The type MyTextSanitizer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
197
        $name = $myts->htmlSpecialChars($name);
198
        $path = '/' . $name . $path . '';
199
        if (0 == $parentid) {
200
            return $path;
201
        }
202
        $path = $this->getPathFromId($parentid, $title, $path);
203
204
        return $path;
205
    }
206
207
    /**
208
     * @param        $title
209
     * @param string $order
210
     * @param int    $preset_id
211
     * @param int    $none
212
     * @param string $sel_name
213
     * @param string $onchange
214
     */
215
    public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
216
    {
217
        if ('' == $sel_name) {
218
            $sel_name = $this->id;
219
        }
220
        $myts = \MyTextSanitizer::getInstance();
221
        echo '<select name="' . $sel_name . '"';
222
        if ('' != $onchange) {
223
            echo ' onchange="' . $onchange . '"';
224
        }
225
        echo '>';
226
227
        $sql        = 'SELECT SQL_CACHE cid, title FROM ' . $this->table . ' WHERE pid=0';
228
        $categories = Adslight\Utility::getMyItemIds('adslight_submit');
229
230
        if (is_array($categories) && count($categories) > 0) {
231
            $sql .= ' AND cid IN (' . implode(',', $categories) . ') ';
232
        }
233
234
        if ('' != $order) {
235
            $sql .= " ORDER BY $order";
236
        }
237
238
        $result = $this->db->query($sql);
239
        if ($none) {
240
            echo '<option value="0">----</option>';
241
        }
242
        while (list($catid, $name) = $this->db->fetchRow($result)) {
243
            $sel = '';
244
            if ($catid == $preset_id) {
245
                $sel = ' selected';
246
            }
247
            echo "<option value=\"{$catid}\"{$sel}>{$name}</option>";
248
            $sel = '';
249
            $arr = $this->getChildTreeArray($catid, $order);
250
            foreach ($arr as $option) {
251
                $option['prefix'] = str_replace('.', '--', $option['prefix']);
252
                $catpath          = $option['prefix'] . '&nbsp;' . $myts->displayTarea($option[$title]);
253
                if ($option['cid'] == $preset_id) {
254
                    $sel = ' selected';
255
                }
256
                echo "<option value=\"{$option['cid']}\"{$sel}>{$catpath}</option>";
257
                $sel = '';
258
            }
259
        }
260
        echo '</select>';
261
    }
262
263
    /**
264
     * @param        $sel_id
265
     * @param        $title
266
     * @param        $funcURL
267
     * @param string $path
268
     *
269
     * @return string
270
     */
271
    public function getNicePathFromId($sel_id, $title, $funcURL, $path = '')
272
    {
273
        $sql    = 'SELECT SQL_CACHE ' . $this->pid . ", {$title} FROM " . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id;
274
        $result = $this->db->query($sql);
275
        if (0 == $this->db->getRowsNum($result)) {
276
            return $path;
277
        }
278
        list($parentid, $name) = $this->db->fetchRow($result);
279
        $myts = \MyTextSanitizer::getInstance();
280
        $name = $myts->htmlSpecialChars($name);
281
282
        $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="&raquo;" >';
0 ignored issues
show
Bug introduced by
The constant XoopsModules\Adslight\XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
283
284
        $path = "&nbsp;&nbsp;{$arrow}&nbsp;&nbsp;<a title=\"" . _ADSLIGHT_ANNONCES . " {$name}\" href=\"{$funcURL}" . $this->id . '=' . (int)$sel_id . "\">{$name}</a>{$path}";
285
286
        if (0 == $parentid) {
287
            return $path;
288
        }
289
        $path = $this->getNicePathFromId($parentid, $title, $funcURL, $path);
290
291
        return $path;
292
    }
293
294
    /**
295
     * @param        $sel_id
296
     * @param string $path
297
     *
298
     * @return string
299
     */
300
    public function getIdPathFromId($sel_id, $path = '')
301
    {
302
        $sel_id = (int)$sel_id;
303
        $result = $this->db->query('SELECT SQL_CACHE ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $sel_id);
304
        if (0 == $this->db->getRowsNum($result)) {
305
            return $path;
306
        }
307
        list($parentid) = $this->db->fetchRow($result);
308
        $path = "/{$sel_id}{$path}";
309
        if (0 == $parentid) {
310
            return $path;
311
        }
312
        $path = $this->getIdPathFromId($parentid, $path);
313
314
        return $path;
315
    }
316
317
    /**
318
     * @param int    $sel_id
319
     * @param string $order
320
     * @param array  $parray
321
     *
322
     * @return array
323
     */
324
    public function getAllChild($sel_id = 0, $order = '', $parray = [])
325
    {
326
        $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . (int)$sel_id;
327
328
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
329
        if (is_array($categories) && count($categories) > 0) {
330
            $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') ';
331
        }
332
333
        if ('' != $order) {
334
            $sql .= " ORDER BY {$order}";
335
        }
336
337
        $result = $this->db->query($sql);
338
        $count  = $this->db->getRowsNum($result);
339
        if (0 == $count) {
340
            return $parray;
341
        }
342
        while (false !== ($row = $this->db->fetchArray($result))) {
343
            array_push($parray, $row);
344
            $parray = $this->getAllChild($row[$this->id], $order, $parray);
345
        }
346
347
        return $parray;
348
    }
349
350
    /**
351
     * @param int    $sel_id
352
     * @param string $order
353
     * @param array  $parray
354
     * @param string $r_prefix
355
     *
356
     * @return array
357
     */
358
    public function getChildTreeArray($sel_id = 0, $order = '', $parray = [], $r_prefix = '')
359
    {
360
        global $moduleDirName;
361
362
        $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . (int)$sel_id;
363
364
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
365
        if (is_array($categories) && count($categories) > 0) {
366
            $sql .= ' AND cid IN (' . implode(',', $categories) . ') ';
367
        }
368
369
        if ('' != $order) {
370
            $sql .= " ORDER BY {$order}";
371
        }
372
        $result = $this->db->query($sql);
373
        $count  = $this->db->getRowsNum($result);
374
        if (0 == $count) {
375
            return $parray;
376
        }
377
        while (false !== ($row = $this->db->fetchArray($result))) {
378
            $row['prefix'] = $r_prefix . '.';
379
            array_push($parray, $row);
380
            $parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']);
381
        }
382
383
        return $parray;
384
    }
385
386
    /**
387
     * @param        $title
388
     * @param string $order
389
     * @param int    $preset_id
390
     * @param int    $none
391
     * @param string $sel_name
392
     * @param string $onchange
393
     */
394
    public function makeAdSelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
0 ignored issues
show
Unused Code introduced by
The parameter $none is not used and could be removed. ( Ignorable by Annotation )

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

394
    public function makeAdSelBox($title, $order = '', $preset_id = 0, /** @scrutinizer ignore-unused */ $none = 0, $sel_name = '', $onchange = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $preset_id is not used and could be removed. ( Ignorable by Annotation )

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

394
    public function makeAdSelBox($title, $order = '', /** @scrutinizer ignore-unused */ $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $onchange is not used and could be removed. ( Ignorable by Annotation )

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

394
    public function makeAdSelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', /** @scrutinizer ignore-unused */ $onchange = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
395
    {
396
        global $myts, $xoopsDB;
397
        $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
0 ignored issues
show
Bug introduced by
The type Xmf\Module\Admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
398
        //        require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
399
400
        if ('' == $sel_name) {
401
            $sel_name = $this->id;
0 ignored issues
show
Unused Code introduced by
The assignment to $sel_name is dead and can be removed.
Loading history...
402
        }
403
404
        $sql = 'SELECT ' . $this->id . ', ' . $title . ', cat_order FROM ' . $this->table . ' WHERE ' . $this->pid . '=0';
405
        if ('' != $order) {
406
            $sql .= " ORDER BY {$order}";
407
        }
408
        $result = $xoopsDB->query($sql);
409
        while (list($catid, $name, $cat_order) = $xoopsDB->fetchRow($result)) {
410
            echo '<table class="width100 bnone outer"><tr>
411
                <th class="left">';
412
            if ('cat_order' === $GLOBALS['xoopsModuleConfig']['adslight_csortorder']) {
413
                echo "({$cat_order})";
414
            }
415
            echo "&nbsp;&nbsp;{$name}&nbsp;&nbsp;</th>
416
                <th class=\"center width10\"><a href=\"category.php?op=AdsNewCat&amp;cid={$catid}\"><img src=\"{$pathIcon16}/add.png\" border=\"0\" width=\"18\" height=\"18\" alt=\"" . _AM_ADSLIGHT_ADDSUBCAT . '" title="' . _AM_ADSLIGHT_ADDSUBCAT . "\"></a></th>
417
                <th class=\"center width10\"><a href=\"category.php?op=AdsModCat&amp;cid={$catid}\"><img src=\"{$pathIcon16}/edit.png\" border=\"0\" width=\"18\" height=\"18\" alt=\"" . _AM_ADSLIGHT_MODIFSUBCAT . '" title="' . _AM_ADSLIGHT_MODIFSUBCAT . "\"></a></th>
418
                <th class=\"center width10\"><a href=\"category.php?op=AdsDelCat&amp;cid={$catid}\"><img src=\"{$pathIcon16}/delete.png\" border=\"0\" width=\"18\" height=\"18\" alt=\"" . _AM_ADSLIGHT_DELSUBCAT . '" title="' . _AM_ADSLIGHT_DELSUBCAT . '"></a></th>
419
                </tr>';
420
421
            $arr   = $this->getChildTreeMapArray($catid, $order);
422
            $class = 'odd';
423
            foreach ($arr as $option) {
424
                echo "<tr class=\"{$class}\"><td>";
425
426
                $option['prefix'] = str_replace('.', ' &nbsp;&nbsp;-&nbsp;', $option['prefix']);
427
                $catpath          = $option['prefix'] . '&nbsp;&nbsp;' . $myts->htmlSpecialChars($option[$title]);
428
                $cat_orderS       = $option['cat_order'];
429
                if ('cat_order' == $GLOBALS['xoopsModuleConfig']['adslight_csortorder']) {
430
                    echo "({$cat_orderS})";
431
                }
432
                echo '' . $catpath . '</a></td>
433
                    <td align="center"><a href="category.php?op=AdsNewCat&amp;cid=' . $option[$this->id] . '"><img src="' . $pathIcon16 . '/add.png' . '" border=0 width=18 height=18 alt="' . _AM_ADSLIGHT_ADDSUBCAT . '"title="' . _AM_ADSLIGHT_ADDSUBCAT . '"></a></td>
434
                    <td align="center"><a href="category.php?op=AdsModCat&amp;cid=' . $option[$this->id] . '"><img src="' . $pathIcon16 . '/edit.png' . '" border=0 width=18 height=18 alt="' . _AM_ADSLIGHT_MODIFSUBCAT . '" title ="' . _AM_ADSLIGHT_MODIFSUBCAT . '"></a></td>
435
                    <td align="center"><a href="category.php?op=AdsDelCat&amp;cid=' . $option[$this->id] . '"><img src="' . $pathIcon16 . '/delete.png' . '" border=0 width=18 height=18 alt="' . _AM_ADSLIGHT_DELSUBCAT . '" title="' . _AM_ADSLIGHT_DELSUBCAT . '"></a></td>';
436
437
                $class = ('even' == $class) ? 'odd' : 'even';
438
            }
439
            echo '</td></tr></table><br>';
440
        }
441
    }
442
443
    /**
444
     * @param int    $sel_id
445
     * @param string $order
446
     * @param array  $parray
447
     * @param string $r_prefix
448
     *
449
     * @return array
450
     */
451
    public function getChildTreeMapArray($sel_id = 0, $order = '', $parray = [], $r_prefix = '')
452
    {
453
        global $xoopsDB;
454
        $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . (int)$sel_id . '';
455
456
        $categories = Adslight\Utility::getMyItemIds('adslight_view');
457
        if (is_array($categories) && count($categories) > 0) {
458
            $sql .= ' AND ' . $this->pid . ' IN (' . implode(',', $categories) . ') ';
459
        }
460
461
        if ('' != $order) {
462
            $sql .= " ORDER BY {$order}";
463
        }
464
        $result = $xoopsDB->query($sql);
465
        $count  = $xoopsDB->getRowsNum($result);
466
        if (0 == $count) {
467
            return $parray;
468
        }
469
        while (false !== ($row = $xoopsDB->fetchArray($result))) {
470
            $row['prefix'] = $r_prefix . '.';
471
            array_push($parray, $row);
472
            $parray = $this->getChildTreeMapArray($row[$this->id], $order, $parray, $row['prefix']);
473
        }
474
475
        return $parray;
476
    }
477
478
    /**
479
     * @return array
480
     */
481
    public function getCategoryList()
482
    {
483
        $result = $this->db->query('SELECT SQL_CACHE cid, pid, title FROM ' . $this->table);
484
        $ret    = [];
485
        $myts   = \MyTextSanitizer::getInstance();
486
       while (false !== ($myrow = $this->db->fetchArray($result))) {
487
            $ret[$myrow['cid']] = [
488
                'title' => $myts->htmlspecialchars($myrow['title']),
489
                'pid'   => $myrow['pid']
490
            ];
491
        }
492
493
        return $ret;
494
    }
495
}
496