1: <?php
2: /**
3: * This file contains the select box class for the plugin content allocation.
4: *
5: * @package Plugin
6: * @subpackage ContentAllocation
7: * @author Marco Jahn
8: * @copyright four for business AG <www.4fb.de>
9: * @license http://www.contenido.org/license/LIZENZ.txt
10: * @link http://www.4fb.de
11: * @link http://www.contenido.org
12: */
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: plugin_include('repository', 'custom/FrontendNavigation.php');
17:
18: /**
19: * Select box class for content allocation
20: *
21: * @package Plugin
22: * @subpackage ContentAllocation
23: */
24: class pApiContentAllocationSelectBox extends pApiTree {
25:
26: /**
27: * @var boolean
28: */
29: protected $_idSetter = true;
30:
31: /**
32: * @var array
33: */
34: protected $_load = array();
35:
36: /**
37: * pApiContentAllocationSelectBox constructor
38: *
39: * @param string $uuid
40: */
41: public function __construct($uuid) {
42: parent::__construct($uuid);
43: }
44:
45: /**
46: * Old constructor
47: *
48: * @deprecated [2016-02-11]
49: * This method is deprecated and is not needed any longer. Please use __construct() as constructor function.
50: * @param string $uuid
51: * @return __construct()
52: */
53: public function pApiContentAllocationSelectBox($uuid) {
54: cDeprecated('This method is deprecated and is not needed any longer. Please use __construct() as constructor function.');
55: return $this->__construct($uuid);
56: }
57:
58: /**
59: * Builed an render tree
60: *
61: * @param $tree
62: * @return string
63: */
64: protected function _buildRenderTre ($tree) {
65:
66: $this->_idSetter = false;
67: $result = '';
68:
69: foreach ($tree as $item_tmp) {
70: $spacer = '|-';
71: $spacer = str_pad($spacer, (($item_tmp['level'] + 1) * 2), "--", STR_PAD_RIGHT);
72:
73: $result .= '<option value="'.$item_tmp['idpica_alloc'].'_'.$item_tmp['level'].'">'.$spacer . $item_tmp['name'].'</option>';
74:
75: if ($item_tmp['children']) {
76: $children = $this->_buildRenderTree($item_tmp['children']);
77: $result .= $children;
78: }
79: }
80:
81: return $result;
82: }
83:
84:
85: /**
86: * Old function
87: *
88: * @deprecated [2016-02-11]
89: * This method is deprecated and is not needed any longer. *
90: * @param null $load
91: * @return boolean
92: */
93: public function setChecked($load = null) {
94: cDeprecated('This method is deprecated and is not needed any longer.');
95: return false;
96: }
97:
98: /**
99: * Render tree
100: *
101: * @param boolean $return
102: * @param mixed $parentId
103: * @param boolean $useTreeStatus (if true use expand/collapsed status of the tree, otherwise not)
104: * @return boolean|object
105: */
106: public function renderTree($return = true, $parentId = false, $bUseTreeStatus = false) {
107:
108: $tree = $this->fetchTree($parentId, 0, $bUseTreeStatus);
109:
110: if ($tree === false) {
111: return false;
112: }
113:
114: $tree = $this->_buildRenderTree($tree);
115:
116: if ($return === true) {
117: return $tree;
118: } else {
119: echo $tree;
120: }
121: }
122: }
123: ?>