diff --git a/module/search/model.php b/module/search/model.php index 21c996c5a8..49a890bee2 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -869,172 +869,4 @@ class searchModel extends model return $object; } - - /** - * Build search form options. - * - * @param array $module - * @param array $fieldParams - * @param array $fieldsMap - * @param array $queries - * @param string $actionURL - * @access public - * @return object - */ - public function buildSearchFormOptions($module, $fieldParams, $fields, $queries, $actionURL = '') - { - $opts = new stdClass(); - $opts->formConfig = static::buildFormConfig(); - $opts->fields = static::buildFormFields($fieldParams, $fields); - $opts->operators = static::buildFormOperators($this->lang->search->operators); - $opts->andOr = static::buildFormAndOrs($this->lang->search->andor); - $opts->saveSearch = static::buildFormSaveSearch($module); - $opts->searchConditions = static::buildFormSavedQuery($queries, $actionURL); - - return $opts; - } - - /** - * Form Configuration of buildForm action. - * - * @access public - * @return object - */ - public static function buildFormConfig() - { - $config = new stdClass(); - $config->action = helper::createLink('search', 'buildQuery'); - $config->method = 'post'; - - return $config; - } - - /** - * Fields options of buildForm action. - * - * @param array $fieldParams - * @param array $fieldsMap - * @access public - * @return array - */ - public static function buildFormFields($fieldParams, $fieldsMap) - { - $fields = array(); - - foreach($fieldParams as $name => $param) - { - $field = new stdClass(); - $field->label = isset($fieldsMap[$name]) ? $fieldsMap[$name] : ''; - $field->name = $name; - $field->control = $param['control']; - $field->operator = $param['operator']; - $field->defaultValue = ''; - $field->placeholder = ''; - $field->values = $param['values']; - - $fields[] = $field; - } - - return $fields; - } - - /** - * Operators of buildForm action. - * - * @param array $operators - * @access public - * @return array - */ - public static function buildFormOperators($operators) - { - $ops = array(); - - foreach($operators as $val => $title) - { - $op = new stdClass(); - $op->value = $val; - $op->title = $title; - - $ops[] = $op; - } - - return $ops; - } - - /** - * AndOr options of buildForm action. - * - * @param array $andOrs - * @access public - * @return array - */ - public static function buildFormAndOrs($andOrs) - { - $result = array(); - - foreach($andOrs as $val => $title) - { - $item = new stdClass(); - $item->value = $val; - $item->title = $title; - - $result[] = $item; - } - - return $result; - } - - /** - * Save Search button of buildForm action. - * - * @param array $module - * @access public - * @return object - */ - public static function buildFormSaveSearch($module) - { - global $lang; - - $result = new stdClass(); - $result->text = $lang->search->saveCondition; - $result->hasPriv = common::hasPriv('search', 'saveQuery'); - $result->config = array( - 'data-toggle' => 'modal', - 'data-type' => 'ajax', - 'data-data-type' => 'html', - 'data-url' => helper::createLink('search', 'saveQuery', array('module' => $module)), - ); - - return $result; - } - - /** - * Saved Queries list of buildForm action. - * - * @param array $queries - * @param array $account - * @access public - * @return array - */ - public static function buildFormSavedQuery($queries, $actionURL) - { - $result = array(); - if(empty($queries)) return $result; - - global $lang; - $hasPriv = common::hasPriv('search', 'deleteQuery'); - foreach($queries as $query) - { - if(!is_object($query)) continue; - - $item = new stdClass(); - $item->text = $query->title; - $item->applyURL = str_replace('myQueryID', $query->id, $actionURL); - if($hasPriv) $item->deleteProps = array('className' => 'ajax-submit', 'data-confirm' => $lang->search->confirmDelete, 'href' => helper::createLink('search', 'deleteQuery', "queryID={$query->id}")); - - $result[] = $item; - } - - return $result; - } }