Completed
Pull Request — master (#3)
by Michael
01:28
created

TDMObjectTree::_makeArrayTreeOptions()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 5
eloc 8
c 3
b 0
f 0
nc 6
nop 5
dl 0
loc 13
rs 8.8571
1
<?php
2
/**
3
 * TDMDownload
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright   Gregory Mage (Aka Mage)
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Gregory Mage (Aka Mage)
15
 */
16
// xoops >2.5.9
17
class TDMObjectTree extends XoopsObjectTree {
18
	
19
	protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '')
20
    {
21
        if ($key > 0) {
22
            $value = $this->tree[$key]['obj']->getVar($this->myId);
23
            $ret[$value] = $prefix_curr . $this->tree[$key]['obj']->getVar($fieldName);
24
            $prefix_curr .= $prefix_orig;
25
        }
26
        if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) {
27
            foreach ($this->tree[$key]['child'] as $childKey) {
28
                $this->makeArrayTreeOptions($fieldName, $childKey, $ret, $prefix_orig, $prefix_curr);
29
            }
30
        }
31
    }
32
	
33
	public function makeArrayTree($fieldName, $prefix = '-', $key = 0) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
34
		$ret = array();
35
        $this->makeArrayTreeOptions($fieldName, $key, $ret, $prefix);
36
37
        return $ret;
38
    }
39
}
40
/* xoops 2.5.8
41
class TDMObjectTree extends XoopsObjectTree {
42
    
43
    protected function makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '')
44
    {
45
        if ($key > 0) {
46
            $value = $this->_tree[$key]['obj']->getVar($this->_myId);
47
            $ret[$value] = $prefix_curr . $this->_tree[$key]['obj']->getVar($fieldName);
48
            $prefix_curr .= $prefix_orig;
49
        }
50
        if (isset($this->_tree[$key]['child']) && !empty($this->_tree[$key]['child'])) {
51
            foreach ($this->_tree[$key]['child'] as $childKey) {
52
                $this->makeArrayTreeOptions($fieldName, $childKey, $ret, $prefix_orig, $prefix_curr);
53
            }
54
        }
55
    }
56
    
57
    public function makeArrayTree($fieldName, $prefix = '-', $key = 0) {
58
        $ret = array();
59
        $this->makeArrayTreeOptions($fieldName, $key, $ret, $prefix);
60
61
        return $ret;
62
    }
63
}*/
64