|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Wfdownloads\Common; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
You may not change or alter any portion of this comment or credits |
|
7
|
|
|
of supporting developers from this source code or any supporting source code |
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* WfdownloadsObjectTree |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
|
20
|
|
|
* @author lucio <[email protected]> |
|
21
|
|
|
* @package Wfdownloads |
|
22
|
|
|
* @since 3.23 |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use XoopsModules\Wfdownloads; |
|
26
|
|
|
|
|
27
|
|
|
//xoops_load('XoopsObjectTree'); |
|
28
|
|
|
require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Form element that ... |
|
32
|
|
|
*/ |
|
33
|
|
|
class ObjectTree extends \XoopsObjectTree |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Make options for a select box from |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $fieldName Name of the member variable from the node objects that should be used as the title for the options. |
|
39
|
|
|
* @param int $key ID of the object to display as the root of select options |
|
40
|
|
|
* @param string $optionsArray (reference to a string when called from outside) Result from previous recursions |
|
41
|
|
|
* @param string $prefix_orig String to indent items at deeper levels |
|
42
|
|
|
* @param string $prefix_curr String to indent the current item |
|
43
|
|
|
* |
|
44
|
|
|
* @return string |
|
45
|
|
|
* @access private |
|
46
|
|
|
*/ |
|
47
|
|
|
public function makeSelBoxOptionsArray($fieldName, $key, &$optionsArray, $prefix_orig, $prefix_curr = '') |
|
48
|
|
|
{ |
|
49
|
|
|
if ($key > 0) { |
|
50
|
|
|
$value = $this->tree[$key]['obj']->getVar($this->_myId); |
|
|
|
|
|
|
51
|
|
|
$optionsArray[$value] = $prefix_curr . $this->tree[$key]['obj']->getVar($fieldName); |
|
52
|
|
|
$prefix_curr .= $prefix_orig; |
|
53
|
|
|
} |
|
54
|
|
|
if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
55
|
|
|
foreach ($this->tree[$key]['child'] as $childkey) { |
|
56
|
|
|
$this->makeSelBoxOptionsArray($fieldName, $childkey, $optionsArray, $prefix_orig, $prefix_curr); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return $optionsArray; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Make a select box with options from the tree |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $name |
|
67
|
|
|
* @param string $fieldName Name of the member variable from the node objects that should be used as the title for the options. |
|
68
|
|
|
* @param string $prefix String to indent deeper levels |
|
69
|
|
|
* @param string $selected |
|
70
|
|
|
* @param bool $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy |
|
71
|
|
|
* @param int $key ID of the object to display as the root of select options |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $extra |
|
74
|
|
|
* @return string $optionsArray Associative array of value->name pairs, useful for <a href='psi_element://XoopsFormSelect'>XoopsFormSelect</a>->addOptionArray method |
|
75
|
|
|
* addOptionArray method |
|
76
|
|
|
*/ |
|
77
|
|
|
public function makeSelBox($name, $fieldName, $prefix = '-', $selected = '', $addEmptyOption = false, $key = 0, $extra = '') |
|
78
|
|
|
// public function makeSelBox($fieldName, $prefix = '-', $addEmptyOption = false, $key = 0) |
|
79
|
|
|
{ |
|
80
|
|
|
$optionsArray = []; |
|
81
|
|
|
if ($addEmptyOption) { |
|
82
|
|
|
$optionsArray[0] = ''; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
return $this->makeSelBoxOptionsArray($fieldName, $key, $optionsArray, $prefix); |
|
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|