Exemple #1
0
 function getItemVipCat()
 {
     EClassApi::getCities();
     EClassApi::getCats();
     //get ID VIP CAT
     if (MEMCACHE_ON) {
         $category_id = CGlobal::$curCategory;
         $id_vip_cat = eb_memcache::do_get("id_vip_cat:{$category_id}");
         if (!$id_vip_cat || $id_vip_cat['ex_time'] < TIME_NOW) {
             $id_vip_cat = $this->getIdVipCat();
             eb_memcache::do_put("id_vip_cat:{$category_id}", $id_vip_cat);
         }
     } else {
         $id_vip_cat = $this->getIdVipCat();
     }
     $str_item_id = '';
     if (isset($id_vip_cat['id'])) {
         foreach ($id_vip_cat['id'] as $val) {
             $str_item_id .= $str_item_id != '' ? ",{$val}" : "{$val}";
         }
     }
     $items = array();
     if ($str_item_id != '') {
         $sql = 'SELECT id, name, up_time, created_time, user_id, user_name, description, city_id, category_id, currency_id, price, original_image_url, img_server FROM item WHERE';
         $where = '';
         $where .= ($where != '' ? " AND " : "") . " id IN({$str_item_id})";
         $where .= ($where != '' ? " AND " : "") . " (status=1 OR status = 2)";
         $sql .= "{$where} ORDER BY up_time DESC";
         $items = array();
         $re = DB::query($sql);
         if ($re) {
             while ($value = mysql_fetch_assoc($re)) {
                 $value['price'] = EClassApi::convertCurrency($value['price'], $value['currency_id']);
                 $value['currency_id'] = 1;
                 if (isset(CGlobal::$allCategories[$value['category_id']])) {
                     $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']) . '&nice_name=' . CGlobal::$allCategories[$value['category_id']]['nice_name']);
                 } else {
                     $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']));
                 }
                 $value['item_time'] = date('h:i | d.m', $value['created_time']);
                 $value['price_name'] = 'Giá bán';
                 $value['item_type'] = 'Giao dịch bán';
                 $value['name'] = strip_tags(EClassApi::filter_title($value['name']));
                 if ($value['price'] && $value['price'] > 0) {
                     $value['price'] = number_format($value['price'], 0, ',', '.');
                     $value['currency_id'] = CGlobal::$currency[$value['currency_id']];
                 } else {
                     $value['price'] = 'Liên hệ';
                     $value['currency_id'] = '';
                 }
                 if ($value['original_image_url']) {
                     $value['original_image_url'] = EClassApi::getImageThumb($value['original_image_url'], 80, 80, 0, $value['img_server']);
                 } else {
                     $value['original_image_url'] = 'style/images/no-images-69x53.jpg';
                 }
                 $value['profile_url'] = WEB_DIR . $value['user_name'];
                 $value['user_name_title'] = $value['user_name'];
                 $value['user_name'] = strlen($value['user_name']) > 10 ? substr($value['user_name'], 0, 10) . '...' : $value['user_name'];
                 if (isset(CGlobal::$cities[$value['city_id']])) {
                     $value['city'] = CGlobal::$cities[$value['city_id']]['name'];
                 } else {
                     $value['city'] = "Toàn quốc";
                 }
                 $value['vip_cat_img'] = "style/images/item-list/item_vip.gif";
                 $value['can_buy'] = 0;
                 $items[$value['id']] = $value;
             }
         }
     }
     //        $items['str_item_id'] = $str_item_id;
     return $items;
 }