Ejemplo n.º 1
0
 public function actionSaveSort()
 {
     $objTypeId = Yii::app()->request->getParam('id', NULL);
     $sort = Yii::app()->request->getParam('sort');
     if (count($sort) >= param('searchMaxField', 15)) {
         HAjax::jsonError(tt('Search max field ') . param('searchMaxField', 3));
     }
     if ($objTypeId !== NULL && $sort && is_array($sort)) {
         $elements = SearchForm::getSearchFields();
         $sql = "DELETE FROM {{search_form}} WHERE obj_type_id=:id AND status!=:status";
         Yii::app()->db->createCommand($sql)->execute(array(':id' => $objTypeId, ':status' => SearchFormModel::STATUS_NOT_REMOVE));
         $i = 3;
         foreach ($sort as $field) {
             if (!isset($elements[$field])) {
                 continue;
             }
             $search = new SearchFormModel();
             $search->attributes = array('obj_type_id' => $objTypeId, 'field' => $field, 'status' => $elements[$field]['status'], 'sorter' => $i, 'formdesigner_id' => isset($elements[$field]['formdesigner_id']) ? $elements[$field]['formdesigner_id'] : 0);
             $search->save();
             $i++;
         }
         // delete assets js cache
         ConfigurationModel::clearGenerateJSAssets();
         HAjax::jsonOk();
     }
     HAjax::jsonError();
 }
Ejemplo n.º 2
0
 public static function getLabelByField($field)
 {
     if ($field == SearchForm::SEARCH_LOCATION) {
         if (issetModule('location') && param('useLocation', 1)) {
             return tc('Country') . ' / ' . tc('Region') . ' / ' . tc('City');
         } else {
             return tc('City');
         }
     }
     $elements = SearchForm::getSearchFields();
     if (isset($elements[$field])) {
         return tc($elements[$field]['translate']);
     } else {
         return tc('Search by ' . $field);
     }
 }