public function getTags($fieldName) { $materials = new Model_Material('group'); //получаем ид поля по названию $fields[] = $materials->getField($fieldName); $tags = array(); foreach ($fields as $field) { //получить все значения $result = DB::select('value')->from('group_param_values')->where('pid', '=', $field['id'])->execute(); $vids = $result->as_array(); foreach ($vids as $vid) { $result = DB::select('value')->from($field['type'])->where('id', '=', $vid['value'])->execute(); $values = $result->as_array(); foreach ($values as $value) { $value = explode(',', $value['value']); foreach ($value as $tag) { if ($tag != '') { $tags[trim($tag)] = $materials->str2url($tag); } } } } } ksort($tags); return $tags; }
public function action_editfields() { $groupId = intval($this->request->param('id')); $paramName = $this->request->param('param'); $group = new Model_Material('groups'); if (isset($_POST['delete_fields'])) { $result = $group->deleteParams($_POST['pid']); } if (isset($_POST['sort_fields']) && isset($_POST['params'])) { $group->sortParams($_POST['params'], $groupId); Controller::redirect('/admin/materials/' . $groupId . '/fields'); } if (isset($_POST['saveParam'])) { $group->updateParam($_POST, $paramName, $groupId); Controller::redirect('/admin/materials/' . $groupId . '/fields'); } if (isset($_POST['saveExcelSettings'])) { $group->updateExcelSettings($_POST, $groupId); } $groupData = $group->getGroup($groupId); $this->data['groups'] = $group->getTree(); $this->data['groupParams'] = $group->getParams($groupId); $base = new Model_Base(); $options = $base->getOptions(); if (!$paramName) { $params = View::factory('admin/admParams', array('data' => $this->data['groupParams'], 'user' => $this->user, 'group' => $groupData, 'options' => $options)); } else { $param_data = $group->getField($paramName, $groupId); $params = View::factory('admin/admParam', array('data' => $param_data, 'user' => $this->user, 'group' => $groupData, 'options' => $options)); } $this->template->content = View::factory('admin/admMaterials', array('data' => $this->data, 'user' => $this->user, 'params' => $params)); }