function insert($db, $r, $collection) { $att = new Dase_DBO_Attribute($db); $att->attribute_name = $this->getTitle(); //think about using getAscii or Slug also $att->ascii_id = Dase_Util::dirify($att->attribute_name); if (!Dase_DBO_Attribute::get($db, $collection->ascii_id, $att->ascii_id)) { $att->collection_id = $collection->id; $att->updated = date(DATE_ATOM); $att->sort_order = 9999; $att->is_on_list_display = 1; $att->is_public = 1; $att->in_basic_search = 1; $att->html_input_type = $this->getHtmlInputType(); $att->insert(); $sort_order = 0; foreach ($this->getDefinedValues() as $dv) { $sort_order++; $att->addDefinedValue($dv, $sort_order); } foreach ($this->getItemTypes() as $type) { $att->addItemType($type); } $att->resort(); } else { throw new Dase_Exception('attribute exists'); } return $att; }