/** * Shows the field in the search form * @param bool $return return or display directly * @return string */ public function searchForm($return = false) { if ($this->searchMethod == 'general') { return false; } $hidden = null; $d = $this->getValues(false); $data = array('' => Sobi::Txt('FD.SEARCH_SELECT_LIST', array('name' => $this->name))); foreach ($d as $k => $v) { $data[$k] = $v; } $params = array('id' => $this->nid, 'size' => $this->ssize, 'class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect')); //still there for compatibility reason if ($this->swidth) { $params['style'] = "width: {$this->swidth}px;"; } if ($this->dependency) { SPFactory::header()->addJsFile('opt.field_select'); $request = json_decode(SPLang::clean(SPRequest::raw($this->nid . '_path', null, 'requestcache')), true); $params['class'] .= ' ctrl-dependency-field'; $hidden = $this->travelDependencyPath($request, $params); $this->_selected = isset($request[1]) ? $request[1] : null; $hiddenValue = str_replace('"', "'", json_encode((object) $request)); $hidden .= SPHtml_Input::hidden($this->nid . '_path', $hiddenValue, null, array('data' => array('selected' => '', 'section' => Sobi::Section()))); $params['data'] = array('order' => '1'); } return SPHtml_Input::select($this->nid, $data, $this->_selected, $this->searchMethod == 'mselect', $params) . $hidden; }
protected function tree() { $selector = null; $selectedCategories = array(); $tree = SPFactory::Instance('mlo.tree', Sobi::Cfg('list.categories_ordering'), array('preventParents' => !$this->catsWithChilds)); $tree->setHref('#'); $tree->setTask('category.chooser'); $tree->setId($this->nid); $tree->disable(Sobi::Section()); $tree->init(Sobi::Section()); $params = array(); $params['maxcats'] = $this->catsMaxLimit; $params['field'] = $this->nid; $params['preventParents'] = !$this->catsWithChilds; $setheight = ''; if ($this->height > 0) { $setheight = " style=\"height: {$this->height}px;\""; } $addBtParams = array('class' => 'btn'); $delBtParams = array('class' => 'btn'); $selectParams = array(); SPFactory::header()->addJsFile('opt.field_category_tree')->addJsCode('SobiPro.jQuery( document ).ready( function () { new SigsiuTreeEdit( ' . json_encode($params) . '); } );'); $selector = $selector . '<div class="tree"' . $setheight . '>' . $tree->display(true) . '</div>'; if (count($this->_selectedCats)) { $selected = SPLang::translateObject($this->_selectedCats, 'name', 'category'); if (count($selected)) { $count = 0; foreach ($selected as $category) { if ($category['id'] == $this->sid && SPRequest::task() != 'entry.add') { continue; } $selectedCategories[$category['id']] = $category['value']; $count++; if ($count == $this->catsMaxLimit) { break; } } } } if (count($selectedCategories) >= $this->catsMaxLimit) { $addBtParams['disabled'] = 'disabled'; $selectParams['readonly'] = 'readonly'; } elseif (!count($selectedCategories)) { $delBtParams['disabled'] = 'disabled'; } $selector .= '<div class="selected">'; $selector .= SPHtml_Input::select($this->nid . '_list', $selectedCategories, null, true, $selectParams); $selector .= SPHtml_Input::hidden($this->nid, 'json://' . json_encode(array_keys($selectedCategories))); $selector .= '</div>'; $selector .= '<div class="buttons">'; $selector .= SPHtml_Input::button('addCategory', Sobi::Txt('CC.ADD_BT'), $addBtParams); $selector .= SPHtml_Input::button('removeCategory', Sobi::Txt('CC.DEL_BT'), $delBtParams); $selector .= '</div>'; $selector = '<div class="SigsiuTree" id="' . $this->nid . '_canvas">' . $selector . '</div>'; if ($this->modal) { $selector = SPHtml_Input::modalWindow(Sobi::Txt('EN.SELECT_CAT_PATH'), $this->nid . '_modal', $selector, 'modaltree modal hide', 'CLOSE', null); $field = SPHtml_Input::button('select-category', Sobi::Txt('EN.SELECT_CAT_PATH'), array('class' => 'btn btn-primary', 'href' => '#' . $this->nid . '_modal', 'data-toggle' => 'modal', 'id' => $this->nid . '_modal_fire')); return $field . $selector; } else { return $selector; } }