示例#1
0
 /**
  * Loads the settings form
  */
 private function loadForm()
 {
     // init settings form
     $this->frm = new BackendForm('settings');
     // get current settings
     $this->settings = BackendSearchModel::getModuleSettings();
     // add field for pagination
     $this->frm->addDropdown('overview_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'overview_num_items', 20));
     $this->frm->addDropdown('autocomplete_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'autocomplete_num_items', 20));
     $this->frm->addDropdown('autosuggest_num_items', array_combine(range(1, 30), range(1, 30)), BackendModel::getModuleSetting($this->URL->getModule(), 'autosuggest_num_items', 20));
     // modules that, no matter what, can not be searched
     $disallowedModules = array('search');
     // loop modules
     foreach (BackendModel::getModulesForDropDown() as $module => $label) {
         // check if module is searchable
         if (!in_array($module, $disallowedModules) && is_callable(array('Frontend' . SpoonFilter::toCamelCase($module) . 'Model', 'search'))) {
             // add field to decide wether or not this module is searchable
             $this->frm->addCheckbox('search_' . $module, isset($this->settings[$module]) ? $this->settings[$module]['searchable'] == 'Y' : false);
             // add field to decide weight for this module
             $this->frm->addText('search_' . $module . '_weight', isset($this->settings[$module]) ? $this->settings[$module]['weight'] : 1);
             // field disabled?
             if (!isset($this->settings[$module]) || $this->settings[$module]['searchable'] != 'Y') {
                 $this->frm->getField('search_' . $module . '_weight')->setAttribute('disabled', 'disabled');
                 $this->frm->getField('search_' . $module . '_weight')->setAttribute('class', 'inputText disabled');
             }
             // add to list of modules
             $this->modules[] = array('module' => $module, 'id' => $this->frm->getField('search_' . $module)->getAttribute('id'), 'label' => $label, 'chk' => $this->frm->getField('search_' . $module)->parse(), 'txt' => $this->frm->getField('search_' . $module . '_weight')->parse(), 'txtError' => '');
         }
     }
 }