示例#1
0
 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;
 }
示例#2
0
 /** implicit 1000 limit */
 public function getAttributeValuesJson($r)
 {
     $attr = Dase_DBO_Attribute::get($this->db, $r->get('collection_ascii_id'), $r->get('att_ascii_id'));
     if (!$attr) {
         $r->renderError('404');
     }
     if (0 == $attr->collection_id) {
         //since it is admin att we need to be able to limit to items in this coll
         $values_array = $attr->getDisplayValues($this->collection->ascii_id, $r->get('limit'));
     } else {
         $values_array = $attr->getDisplayValues(null, $r->get('limit'));
     }
     $result['att_name'] = $attr->attribute_name;
     $result['att_ascii'] = $attr->ascii_id;
     $result['coll'] = $r->get('collection_ascii_id');
     $result['values'] = $values_array;
     $json_result = Dase_Json::get($result);
     if ($r->get('callback')) {
         $r->renderResponse($r->get('callback') . '(' . $json_result . ');');
     } else {
         $r->renderResponse($json_result);
     }
 }
示例#3
0
 public function getItemsByAttAsAtom($attribute_ascii_id, $app_root)
 {
     $feed = $this->getBaseAtomFeed($app_root);
     $feed->setFeedType('items');
     $att = Dase_DBO_Attribute::get($this->db, $this->ascii_id, $attribute_ascii_id);
     $vals = new Dase_DBO_Value($this->db);
     $vals->attribute_id = $att->id;
     foreach ($vals->find() as $val) {
         $item = new Dase_DBO_Item($this->db);
         $item->load($val->item_id);
         //use cached ???
         $entry = $item->injectAtomEntryData($feed->addEntry(), $app_root);
         $entry->setSummary($item->getValue($attribute_ascii_id));
     }
     return $feed->asXML($app_root);
 }
示例#4
0
 public function deleteItemTypeAttribute($r)
 {
     $type = Dase_DBO_ItemType::get($this->db, $this->collection->ascii_id, $r->get('type_ascii_id'));
     $att = Dase_DBO_Attribute::get($this->db, $this->collection->ascii_id, $r->get('att_ascii_id'));
     $ita = new Dase_DBO_AttributeItemType($this->db);
     $ita->attribute_id = $att->id;
     $ita->item_type_id = $type->id;
     if ($ita->findOne()) {
         $ita->delete();
         $r->renderOk('done');
     } else {
         $r->renderError(400);
     }
 }
示例#5
0
 function removeKeyval($att_ascii_id, $value_text, $eid)
 {
     $c = $this->getCollection();
     $att = Dase_DBO_Attribute::get($this->db, $c->ascii_id, $att_ascii_id);
     if ($att) {
         $val = new Dase_DBO_Value($this->db);
         $val->item_id = $this->id;
         $val->attribute_id = $att->id;
         $val->value_text = $value_text;
         if ($val->findOne()) {
             $this->removeMetadata($val->id, $eid);
             return true;
         }
     }
 }