예제 #1
0
파일: Recommend.php 프로젝트: bmchun/sunset
 function recommend($pageId, $uid = null)
 {
     $itemsNum = 4;
     //控制次调用返回的数据数量$itemsNum-1个
     $from = $itemsNum * ($pageId - 1);
     $to = $itemsNum;
     $limit = ' ' . $from . ',' . $to . ' ';
     // 每页4条数据
     if (isset($uid)) {
         $items = UserLikeModel::getUserItems($uid);
         $arr = array('isRecommend' => 1);
         $orderby = '`itemPic desc`';
         $re = ItemInfo::iteminfo_select_ordby($arr, $orderby, $limit);
         $data = array();
         while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
             if (in_array($line['id'], $items)) {
                 $line['isFavorite'] = 1;
             } else {
                 $line['isFavorite'] = 0;
             }
             $data[] = $line;
         }
         return $data;
     } else {
         $arr = array('isRecommend' => 1);
         $orderby = '`itemPic desc`';
         $re = ItemInfo::iteminfo_select_ordby($arr, $orderby, $limit);
         $data = array();
         while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
             $line['isFavorite'] = 0;
             $data[] = $line;
         }
         return $data;
     }
 }
예제 #2
0
파일: Discovery.php 프로젝트: bmchun/sunset
 function presentForHuman($gender, $type = 0, $pageId = 1, $uid = 0)
 {
     $itemsNum = 6;
     //控制次调用返回的数据数量
     $from = $itemsNum * ($pageId - 1);
     $to = $itemsNum;
     $limit = ' ' . $from . ',' . $to . ' ';
     // 数据
     $like = new UserLikeModel();
     if ($gender == NULL) {
         if ($type == 0) {
             $arr = array("isRecommend" => 1);
         } else {
             $arr = array("isRecommend" => 1, "type" => $type);
         }
         $orderby = 'itemDate';
         $re = ItemInfo::iteminfo_select_ordby($arr, $orderby, $limit);
         $data = array();
         while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
             $line['islike'] = $like->checkUserLike($uid, $line['id']);
             $line['likesum'] = $like->itemLikeSum($line['id']);
             $data[] = $line;
         }
         return $data;
     }
     if ($type == 0) {
         $arr = array("isRecommend" => 1, "itemGender" => $gender);
     } else {
         $arr = array("itemGender" => $gender, 'type' => $type, "isRecommend" => 1);
     }
     $orderby = 'itemDate';
     $re = ItemInfo::iteminfo_select_ordby($arr, $orderby, $limit);
     $data = array();
     while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
         $line['islike'] = $like->checkUserLike($uid, $line['id']);
         $line['likesum'] = $like->itemLikeSum($line['id']);
         $data[] = $line;
     }
     return $data;
 }
예제 #3
0
파일: NewItems.php 프로젝트: bmchun/sunset
 function newItems($pageId, $itemNum = null, $uid = 0)
 {
     $itemsNum = isset($itemNum) ? $itemNum : 6;
     //控制次调用返回的数据数量
     $from = $itemsNum * ($pageId - 1);
     $to = $itemsNum;
     $limit = ' ' . $from . ',' . $to . ' ';
     $orderby = 'itemDate';
     $arr = array('isTop' => 0);
     //第一页加上置顶内容
     if ($pageId == 1) {
         $arr_top = array('isTop' => 1);
         $re1 = ItemInfo::iteminfo_select_ordby($arr_top, $orderby, null);
         $re2 = ItemInfo::iteminfo_select_ordby($arr, $orderby, $limit);
         $data = array();
         $like = new UserLikeModel();
         while ($line = mysql_fetch_array($re1, MYSQL_ASSOC)) {
             $line['islike'] = $like->checkUserLike($uid, $line['id']);
             $line['likesum'] = $like->itemLikeSum($line['id']);
             $data[] = $line;
         }
         while ($line = mysql_fetch_array($re2, MYSQL_ASSOC)) {
             $line['islike'] = $like->checkUserLike($uid, $line['id']);
             $line['likesum'] = $like->itemLikeSum($line['id']);
             $data[] = $line;
         }
         return $data;
     } else {
         $re = ItemInfo::iteminfo_select_ordby($arr, $orderby, $limit);
         $data = array();
         $like = new UserLikeModel();
         while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
             $line['islike'] = $like->checkUserLike($uid, $line['id']);
             $line['likesum'] = $like->itemLikeSum($line['id']);
             $data[] = $line;
         }
         return $data;
     }
 }
예제 #4
0
파일: search.php 프로젝트: bmchun/sunset
    $re = $search->search($_GET['key'], $page, $uid, $n);
    while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
        $line['islike'] = $like->checkUserLike($uid, $line['id']);
        $line['likesum'] = $like->itemLikeSum($line['id']);
        $data[] = $line;
    }
    echo $style->show(200, $data);
} elseif ($_GET['key'] && $_GET['type']) {
    $data = array();
    $uid = isset($_GET['uid']) ? $_GET['uid'] : null;
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    if (isset($_GET['type'])) {
        $type = type($_GET['type']);
    }
    $search = new Search();
    $like = new UserLikeModel();
    $re = $search->search_admin($_GET['key'], $type, $page);
    while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
        $line['islike'] = $like->checkUserLike($uid, $line['id']);
        $line['likesum'] = $like->itemLikeSum($line['id']);
        $data[] = $line;
    }
    echo $style->show(200, $data);
} else {
    echo $style->show(400);
}
function type($type)
{
    switch ($type) {
        case '外套':
            return 1;