public function putAttributeDefinedValues($r) { $att = Dase_DBO_Attribute::get($this->db, $this->collection->ascii_id, $r->get('att_ascii_id')); $def_values = new Dase_DBO_DefinedValue($this->db); $def_values->attribute_id = $att->id; foreach ($def_values->find() as $df) { $df->delete(); } $defined_values = trim($r->getBody()); $pattern = "/[\n;]/"; $munged_string = preg_replace($pattern, '%', $defined_values); $response = array(); $def_value_array = explode('%', $munged_string); $response['count'] = count($def_value_array); $response['input'] = $att->html_input_type; $response['defined'] = $def_value_array; $sort_order = 0; foreach ($def_value_array as $df_text) { if (trim($df_text)) { $sort_order++; $def_value = new Dase_DBO_DefinedValue($this->db); $def_value->value_text = htmlspecialchars(trim($df_text), ENT_NOQUOTES, 'UTF-8'); $def_value->attribute_id = $att->id; $def_value->sort_order = $sort_order; $def_value->insert(); } } $r->response_mime_type = 'application/json'; $r->renderResponse(Dase_Json::get($response)); }
function addDefinedValue($text, $sort_order = 999) { $dv = new Dase_DBO_DefinedValue($this->db); $dv->attribute_id = $this->id; $dv->value_text = $text; $dv->sort_order = $sort_order; $dv->insert(); }