Пример #1
0
 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));
 }
Пример #2
0
 function expunge()
 {
     $dv = new Dase_DBO_DefinedValue($this->db);
     $dv->attribute_id = $this->id;
     foreach ($dv->find() as $doomed) {
         $doomed->delete();
     }
     $ait = new Dase_DBO_AttributeItemType($this->db);
     $ait->attribute_id = $this->id;
     foreach ($ait->find() as $doomed) {
         $doomed->delete();
     }
     $this->delete();
 }