36 private $height = 500;
37 private $submitButton = TRUE;
38 protected $tree = NULL;
39 protected $pathMapping = [];
52 $this->pid = preg_replace(
"/[^0-9]/",
"", microtime(TRUE));
64 return 'bs_input_'.$this->pid;
74 $this->submitButton = $flag;
84 $this->height = $value;
94 if (isset($this->pathMapping[$base])) {
96 $this->lastState = TRUE;
97 return $this->
update(TRUE);
99 $this->lastState = FALSE;
111 return $this->lastState;
123 $this->pathMapping = [];
125 foreach ($bases as $base => $dummy) {
127 $elements = explode(
',', substr($base, 0, strlen($base) - strlen($config->current[
'BASE'])));
128 $elements = array_reverse($elements, TRUE);
130 $this->pathMapping[$base] = (($base == $config->current[
'BASE']) ?
'/' : preg_replace(
'/(^|,)[a-z0-9]+=/i',
'/', implode(
',', $elements)));
142 function update (
bool $force = FALSE): bool
144 if (!isset($this->base) || ($this->base ==
'')) {
145 $this->lastState = FALSE;
150 $this->action = NULL;
151 $last_base = $this->base;
152 if (isset($_REQUEST[
'BPID']) && $_REQUEST[
'BPID'] == $this->pid) {
153 if (!empty($_POST[
'bs_rebase_'.$this->pid])) {
154 $new_base = base64_decode($_POST[
'bs_rebase_'.$this->pid]);
155 if (isset($this->pathMapping[$new_base])) {
156 $this->base = $new_base;
157 $this->action =
'rebase';
159 $this->lastState = FALSE;
164 if (($this->submitButton && isset($_POST[
'submit_base_'.$this->pid.
'_x'])) || !$this->submitButton) {
167 $this->lastState = FALSE;
168 foreach ($this->pathMapping as $key => $path) {
169 if (mb_strtolower($path) == mb_strtolower($_POST[$this->
getInputHtmlId()])) {
171 $this->lastState = TRUE;
180 if ($this->tree && ($this->base == $last_base) && !$force) {
181 $this->lastState = TRUE;
188 $this->lastState = TRUE;
192 protected function renderTree ()
197 $departmentInfo = $config->getDepartmentInfo();
199 foreach (array_keys($this->pathMapping) as $base) {
200 if ($base == $config->current[
'BASE']) {
205 $elements = explode(
',', substr($base, 0, strlen($base) - strlen($config->current[
'BASE'])));
207 array_pop($elements);
209 array_shift($elements);
212 $elementBase = $config->current[
'BASE'];
213 foreach (array_reverse($elements) as $element) {
214 $elementBase = $element.
','.$elementBase;
215 if (!isset($array[$elementBase])) {
217 $array[$elementBase] = [
221 'img' => $departmentInfo[$elementBase][
'img'],
222 'name' => $departmentInfo[$elementBase][
'name'],
223 'description' => $departmentInfo[$elementBase][
'description'],
227 $array =& $array[$elementBase][
'tree'];
232 'selected' => ($this->base == $base),
234 'img' => $departmentInfo[$base][
'img'],
235 'name' => $departmentInfo[$base][
'name'],
236 'description' => $departmentInfo[$base][
'description'],
242 $smarty->assign(
'pid', $this->pid);
243 $smarty->assign(
'currentValue', $this->pathMapping[$this->base]);
244 $smarty->assign(
'submitButton', $this->submitButton);
245 $smarty->assign(
'height', $this->height);
246 $smarty->assign(
'selected', ($this->base == $config->current[
'BASE']));
247 $smarty->assign(
'rootBase', $config->current[
'BASE']);
248 $smarty->assign(
'tree', $tree);
260 if (!isset($this->tree)) {
284 return $this->pathMapping;
render()
Accessor of the member tree.
setSubmitButton($flag)
Set a new flag to the submit button.
get_template_path($filename='', $plugin=FALSE, $path='')
Return themed path for specified base file.
__construct(array $bases, string $base='')
baseSelector contructor
update(bool $force=FALSE)
Update the base.
static set($name, $value)
Set a value in a session.
checkLastBaseUpdate()
Check the last base value updated.
& get_smarty()
Get global smarty object.
setHeight($value)
Set a new value of the member height.
getBase()
Accessor of the base.
getInputHtmlId()
Returns id of the html field.
getBases()
Accessor of the bases.
setBases(array $bases)
Set new bases.
setBase(string $base)
Set a new value of the member base.