Beispiel #1
0
 public static function findOrCreateAdmin($db, $attribute_ascii_id)
 {
     $att = new Dase_DBO_Attribute($db);
     $att->collection_id = 0;
     $att->ascii_id = $attribute_ascii_id;
     if (!$att->findOne()) {
         $attribute_ascii_id = Dase_Util::dirify($attribute_ascii_id);
         $att->attribute_name = ucwords(str_replace('_', ' ', $attribute_ascii_id));
         $att->sort_order = 0;
         $att->in_basic_search = 0;
         $att->is_on_list_display = 0;
         $att->is_public = 0;
         $att->mapped_admin_att_id = 0;
         $att->updated = date(DATE_ATOM);
         $att->html_input_type = 'no_edit';
         $att->insert();
     }
     return $att;
 }
Beispiel #2
0
 public static function sortIdArray($db, $sort, $item_ids)
 {
     $sortable_array = array();
     $test_att = new Dase_DBO_Attribute($db);
     $test_att->ascii_id = $sort;
     if (!$test_att->findOne()) {
         return $item_ids;
     }
     $prefix = $db->table_prefix;
     $dbh = $db->getDbh();
     $sql = "\n\t\t\t\t\t\tSELECT v.value_text\n\t\t\t\t\t\tFROM {$prefix}attribute a, {$prefix}value v\n\t\t\t\t\t\tWHERE v.item_id = ?\n\t\t\t\t\t\tAND v.attribute_id = a.id\n\t\t\t\t\t\tAND a.ascii_id = ?\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t";
     $sth = $dbh->prepare($sql);
     foreach ($item_ids as $item_id) {
         $sth->execute(array($item_id, $sort));
         $vt = $sth->fetchColumn();
         $value_text = $vt ? $vt : 99999999;
         $sortable_array[$item_id] = $value_text;
     }
     if (is_array($sortable_array)) {
         asort($sortable_array);
         return array_keys($sortable_array);
     }
 }