$r = (int) $_GET['r']; if ($r != 0) { $r = 1; } $a['sponsored'] = $r; $a['sponsoredon'] = $r = 0 ? '' : date('Y-m-d', time()); Ad::update($o, $a); } $tct = Ad::count(); //total count $rpp = 10; //row per page $pager_options = array('mode' => 'Sliding', 'perPage' => $rpp, 'delta' => 2, 'totalItems' => $tct, 'excludeVars' => array('o', 'r', 'd', 't', 'e')); $pager = @Pager::factory($pager_options); list($from, $to) = $pager->getOffsetByPageId(); $ads = Ad::get_all(array(), '', $from - 1 . ", {$rpp}"); include "page-header.php"; ?> <div id="wrapper"> <?php include "page-left.php"; ?> <div id="content"> <?php if ($tct > $rpp) { echo $pager->links . '<br /><br />'; }
$or_filter .= " OR id LIKE '{$gs_description}'"; } if ($or_filter != '') { $filter .= " AND (1=2 {$or_filter})"; } if ($g_category != "any" && $g_category != '0') { $filter .= " AND (category=(SELECT r.id FROM category r WHERE r.slug='{$g_category}' LIMIT 1) OR category IN (SELECT r.id FROM category r WHERE r.parent=(SELECT s.id FROM category s WHERE s.slug='{$g_category}' LIMIT 1)))"; } if ($g_region != "any" && $g_region != '0') { $filter .= " AND (region=(SELECT r.id FROM region r WHERE r.slug='{$g_region}' LIMIT 1) OR region IN (SELECT r.id FROM region r WHERE r.parent=(SELECT s.id FROM region s WHERE s.slug='{$g_region}' LIMIT 1)))"; } if ($g_min_price != "") { $filter .= " AND ar>={$g_min_price}"; } if ($g_max_price != "") { $filter .= " AND ar<={$g_max_price}"; } if ($g_id > 0) { $filter .= " AND id='{$g_id}'"; } } $rpp = 15; //row per page $tct = Ad::count(array(), $filter); //total count $pager_options = array('mode' => 'Sliding', 'perPage' => $rpp, 'delta' => 2, 'totalItems' => $tct); $pager = @Pager::factory($pager_options); list($from, $to) = $pager->getOffsetByPageId(); $ads = Ad::get_all(array(), $filter, $from - 1 . ", {$rpp}"); $curr_page = "home"; include "./templates/ad-list.php";
/** * Get user's all favourite ads * * @param int $user_id The user's id. * @param int $limit Number of rows needs to be returned. * @return array The result rows as array. */ public static function get_all($user_id, $limit) { global $db; $filter = sprintf("h.active=1 AND h.id IN (SELECT f.ad_id FROM " . static::$table_name . " f WHERE f.user_id=%d)", $user_id); return Ad::get_all(array(), $filter, $limit); }