Passed
Push — master ( 188361...fd3319 )
by Michael
03:02
created

ObjectTree::getIdPathFromId()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 17
rs 9.8666
cc 3
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Adslight;
6
7
/**
8
 * Class ObjectTree
9
 * @package XoopsModules\Adslight
10
 */
11
class ObjectTree extends \XoopsObjectTree
12
{
13
    //generates id path from the root id to a given id
14
    // the path is delimetered with "/"
15
    /**
16
     * @param        $sel_id
17
     * @param string $path
18
     * @return string
19
     */
20
//    public function getIdPathFromId($sel_id, $path = ''): string
21
//    {
22
//        global $xoopsDB;
23
//        $sel_id = (int)$sel_id;
24
//        $sql    = 'SELECT ' . $this->parentId . ' FROM ' . $this->table . ' WHERE ' . $this->myId . "=${sel_id}";
25
//        $result = $xoopsDB->query($sql);
26
//        if (0 === $xoopsDB->getRowsNum($result)) {
27
//            return $path;
28
//        }
29
//        [$parentid] = $xoopsDB->fetchRow($result);
30
//        $path = '/' . $sel_id . $path . '';
31
//        if (0 === $parentid) {
32
//            return $path;
33
//        }
34
//        $path = $this->getIdPathFromId($parentid, $path);
35
//
36
//        return $path;
37
//    }
38
39
    //generates nicely formatted linked path from the root id to a given id
40
41
    /**
42
     * @param        $sel_id
43
     * @param        $title
44
     * @param        $funcURL
45
     * @param string $path
46
     * @return string
47
     */
48
//    public function getNicePathFromId($sel_id, $title, $funcURL, $path = ''): string
49
//    {
50
//        global $xoopsDB;
51
//        $path   = !empty($path) ? '&nbsp;:&nbsp;' . $path : $path;
52
//        $sel_id = (int)$sel_id;
53
//        $sql    = 'SELECT ' . $this->parentId . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->myId . "=${sel_id}";
54
//        $result = $xoopsDB->query($sql);
55
//        if (0 === $xoopsDB->getRowsNum($result)) {
56
//            return $path;
57
//        }
58
//        [$parentid, $name] = $xoopsDB->fetchRow($result);
59
//        $myts = \MyTextSanitizer::getInstance();
60
//        $name = \htmlspecialchars($name, \ENT_QUOTES | \ENT_HTML5);
61
//        $path = "<a href='" . $funcURL . '&amp;' . $this->myId . '=' . $sel_id . "'>" . $name . '</a>' . $path . '';
62
//        if (0 === $parentid) {
63
//            return $path;
64
//        }
65
//        $path = $this->getNicePathFromId($parentid, $title, $funcURL, $path);
66
//
67
//        return $path;
68
//    }
69
}
70