Beispiel #1
0
function osc_search_footer_links()
{
    if (!osc_rewrite_enabled()) {
        return array();
    }
    $categoryID = osc_search_category_id();
    if (!empty($categoryID)) {
        if (Category::newInstance()->isRoot(current($categoryID))) {
            $cat = Category::newInstance()->findSubcategories(current($categoryID));
            if (count($cat) > 0) {
                $categoryID = array();
                foreach ($cat as $c) {
                    $categoryID[] = $c['pk_i_id'];
                }
            }
        }
    }
    if (osc_search_city() != '') {
        return array();
    }
    $regionID = '';
    if (osc_search_region() != '') {
        $aRegion = Region::newInstance()->findByName(osc_search_region());
        if (isset($aRegion['pk_i_id'])) {
            $regionID = $aRegion['pk_i_id'];
        }
    }
    $conn = DBConnectionClass::newInstance();
    $data = $conn->getOsclassDb();
    $comm = new DBCommandClass($data);
    $comm->select('i.fk_i_category_id');
    $comm->select('l.*');
    $comm->select('COUNT(*) AS total');
    $comm->from(DB_TABLE_PREFIX . 't_item as i');
    $comm->from(DB_TABLE_PREFIX . 't_item_location as l');
    if (!empty($categoryID)) {
        $comm->whereIn('i.fk_i_category_id', $categoryID);
    }
    $comm->where('i.pk_i_id = l.fk_i_item_id');
    $comm->where('i.b_enabled = 1');
    $comm->where('i.b_active = 1');
    $comm->where(sprintf("dt_expiration >= '%s'", date('Y-m-d H:i:s')));
    $comm->where('l.fk_i_region_id IS NOT NULL');
    $comm->where('l.fk_i_city_id IS NOT NULL');
    if ($regionID != '') {
        $comm->where('l.fk_i_region_id', $regionID);
        $comm->groupBy('l.fk_i_city_id');
    } else {
        $comm->groupBy('l.fk_i_region_id');
    }
    $rs = $comm->get();
    if (!$rs) {
        return array();
    }
    return $rs->result();
}