/** * search * @list */ function lists() { global $G, $viewhelper, $pos; uses("trade", "industry", "area", "tradefield", "form", "tag"); $trusttypes = cache_read("trusttype"); $countries = cache_read("country"); $membergroups = cache_read("membergroup"); $area = new Areas(); $offer = new Tradefields(); $trade = new Trades(); $form = new Forms(); $industry = new Industries(); $tag = new Tags(); $conditions = array(); $industry_id = $area_id = 0; $conditions[] = "t.status=1"; !empty($_GET) && ($_GET = clear_html($_GET)); if (isset($_GET['navid'])) { setvar("nav_id", intval($_GET['navid'])); } $viewhelper->setTitle(L('offer', 'tpl')); $viewhelper->setPosition(L('offer', 'tpl'), "index.php?do=offer"); $trade_types = cache_read("type", "offertype"); if (isset($_GET['typeid'])) { $type_id = intval($_GET['typeid']); $conditions[] = "t.type_id='" . $type_id . "'"; setvar("typeid", $type_id); $type_name = $trade_types[$type_id]; $viewhelper->setTitle($type_name); $viewhelper->setPosition($type_name, "index.php?do=offer&action=lists&typeid=" . $type_id); } if (isset($_GET['industryid'])) { $industry_id = intval($_GET['industryid']); $tmp_info = $industry->setInfo($industry_id); if (!empty($tmp_info)) { $sub_ids = $industry->getSubDatas($tmp_info['id']); $sub_ids = array_keys($sub_ids); $conditions[] = "t.industry_id IN (" . implode(",", $sub_ids) . ")"; $viewhelper->setTitle($tmp_info['name']); $viewhelper->setPosition($tmp_info['name'], "index.php?do=offer&action=lists&industryid=" . $tmp_info['id']); } } if (isset($_GET['areaid'])) { $area_id = intval($_GET['areaid']); $tmp_info = $area->setInfo($area_id); if (!empty($tmp_info)) { $sub_ids = $area->getSubDatas($tmp_info['id']); $sub_ids = array_keys($sub_ids); $conditions[] = "t.area_id IN (" . implode(",", $sub_ids) . ")"; $viewhelper->setTitle($tmp_info['name']); $viewhelper->setPosition($tmp_info['name'], "index.php?do=offer&action=lists&areaid=" . $tmp_info['id']); } } if (isset($_GET['type'])) { if ($_GET['type'] == "urgent") { $conditions[] = "t.if_urgent='1'"; } } if (!empty($_GET['price_start']) || !empty($_GET['price_end'])) { $conditions[] = "t.price BETWEEN " . intval($_GET['price_start']) . " AND " . intval($_GET['price_end']); } if (!empty($_GET['picture'])) { $conditions[] = "t.picture!=''"; } if (!empty($_GET['urgent'])) { $conditions[] = "t.if_urgent=1"; } if (!empty($_GET['commend'])) { $conditions[] = "t.if_commend=1"; } if (!empty($_GET['country'])) { $conditions[] = "t.country_id='" . intval($_GET['country']) . "'"; } if (!empty($_GET['sure'])) { $conditions[] = "m.trusttype_ids='" . intval($_GET['sure']) . "'"; } if (!empty($_GET['date'])) { $d = intval($_GET['date']); if ($d <= 7948800) { $conditions[] = "t.submit_time<='" . intval($_GET['date']) . "'"; } } if (isset($_GET['q'])) { $searchkeywords = $_GET['q']; $viewhelper->setTitle(L("search_in_keyword", "tpl", $searchkeywords)); $viewhelper->setPosition(L("search_in_keyword", "tpl", $searchkeywords)); $conditions[] = "t.title like '%" . $searchkeywords . "%'"; setvar("highlight_str", $searchkeywords); } if (isset($_GET['pubdate'])) { switch ($_GET['pubdate']) { case "l3": $conditions[] = "t.submit_time>" . ($offer->timestamp - 3 * 86400); break; case "l10": $conditions[] = "t.submit_time>" . ($offer->timestamp - 10 * 86400); break; case "l30": $conditions[] = "t.submit_time>" . ($offer->timestamp - 30 * 86400); break; default: break; } } if ($G['setting']['offer_expire_method'] == 2 || $G['setting']['offer_expire_method'] == 3) { $conditions[] = "t.expire_time>" . $offer->timestamp; } $amount = $trade->findCount(null, $conditions, null, "t"); $result = $trade->getRenderDatas($conditions, $G['setting']['offer_filter']); $important_result = $trade->getStickyDatas(); setvar("StickyItems", $important_result); setvar('items', $result); setvar('trusttype', $trusttypes); setvar('countries', $countries); setvar("paging", array('total' => $amount)); render("offer/list"); }