1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace XoopsModules\Tdmdownloads; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* TDMDownload |
9
|
|
|
* |
10
|
|
|
* You may not change or alter any portion of this comment or credits |
11
|
|
|
* of supporting developers from this source code or any supporting source code |
12
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16
|
|
|
* |
17
|
|
|
* @copyright Gregory Mage (Aka Mage) |
18
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
19
|
|
|
* @author Gregory Mage (Aka Mage) |
20
|
|
|
*/ |
21
|
|
|
require_once $GLOBALS['xoops']->path('www/class/tree.php'); |
22
|
|
|
// xoops >2.5.9 |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class Tree |
26
|
|
|
* @package XoopsModules\Tdmdownloads |
27
|
|
|
*/ |
28
|
|
|
class Tree extends \XoopsObjectTree |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Tree constructor. |
32
|
|
|
* @param $objectArr |
33
|
|
|
* @param $myId |
34
|
|
|
* @param $parentId |
35
|
|
|
* @param null $rootId |
|
|
|
|
36
|
|
|
*/ |
37
|
|
|
public function __construct($objectArr, $myId, $parentId, $rootId = null) |
38
|
|
|
{ |
39
|
|
|
parent::__construct($objectArr, $myId, $parentId, $rootId); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param $fieldName |
44
|
|
|
* @param $key |
45
|
|
|
* @param $ret |
46
|
|
|
* @param $prefix_orig |
47
|
|
|
* @param string $prefix_curr |
48
|
|
|
*/ |
49
|
|
|
protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '') |
50
|
|
|
{ |
51
|
|
|
if ($key > 0) { |
52
|
|
|
$value = $this->tree[$key]['obj']->getVar($this->myId); |
53
|
|
|
$ret[$value] = $prefix_curr . $this->tree[$key]['obj']->getVar($fieldName); |
54
|
|
|
$prefix_curr .= $prefix_orig; |
55
|
|
|
} |
56
|
|
|
if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
57
|
|
|
foreach ($this->tree[$key]['child'] as $childKey) { |
58
|
|
|
$this->makeArrayTreeOptions($fieldName, $childKey, $ret, $prefix_orig, $prefix_curr); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param $fieldName |
65
|
|
|
* @param string $prefix |
66
|
|
|
* @param int $key |
67
|
|
|
* |
68
|
|
|
* @return array |
69
|
|
|
*/ |
70
|
|
|
public function makeArrayTree($fieldName, $prefix = '-', $key = 0) |
71
|
|
|
{ |
72
|
|
|
$ret = []; |
73
|
|
|
$this->makeArrayTreeOptions($fieldName, $key, $ret, $prefix); |
74
|
|
|
return $ret; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
/* xoops 2.5.8 |
78
|
|
|
class Tree extends \XoopsObjectTree { |
79
|
|
|
|
80
|
|
|
protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '') |
81
|
|
|
{ |
82
|
|
|
if ($key > 0) { |
83
|
|
|
$value = $this->_tree[$key]['obj']->getVar($this->_myId); |
84
|
|
|
$ret[$value] = $prefix_curr . $this->_tree[$key]['obj']->getVar($fieldName); |
85
|
|
|
$prefix_curr .= $prefix_orig; |
86
|
|
|
} |
87
|
|
|
if (isset($this->_tree[$key]['child']) && !empty($this->_tree[$key]['child'])) { |
88
|
|
|
foreach ($this->_tree[$key]['child'] as $childKey) { |
89
|
|
|
$this->makeArrayTreeOptions($fieldName, $childKey, $ret, $prefix_orig, $prefix_curr); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function makeArrayTree($fieldName, $prefix = '-', $key = 0) { |
95
|
|
|
$ret = []; |
96
|
|
|
$this->makeArrayTreeOptions($fieldName, $key, $ret, $prefix); |
97
|
|
|
|
98
|
|
|
return $ret; |
99
|
|
|
} |
100
|
|
|
}*/ |
101
|
|
|
|