Пример #1
0
 public function Index()
 {
     // get cats and subcats
     include_once 'Model/Base/Cats.class.php';
     $mDict = new Model_Base_Cats($this->mDb);
     $cl = $mDict->GetCatsList(0, 1, 'sortid, name ASC');
     foreach ($cl as $cat) {
         $pl[$cat['id']] = $mDict->GetCatsList($cat['id'], 1, 'name');
         if (empty($pl[$cat['id']])) {
             $pl[$cat['id']] = $mDict->GetCatsList($cat['id']);
         }
     }
     include_once 'View/Base/Index.class.php';
     $view = new View_Base_Index($this->mlObj, 'Base/Index');
     $view->assign('cl', $cl);
     $view->assign('pl', $pl);
     $view->display('homepage.php');
 }
Пример #2
0
 /**
  * Get list of Ads with pictures
  * @param int $cat - category ID
  * @param int $country - country ID
  * @param int $subcat - subcat ID
  * @param string $sort - sort param, default sorted by pubdate
  * @param int $first - for pagging, from which item
  * @param int $cnt - for pagging, count of returned items
  * @param int $region - region ID
  * @param int $city - city ID
  * @return array
  */
 public function GetList($cat, $params = array())
 {
     $sql = 'SELECT * FROM ' . $this->mTbAds . ' WHERE id = id';
     if ((int) $cat) {
         $sql .= ' AND id_cat = ' . (int) $cat;
     }
     if (!empty($params['search'])) {
         $search = mb_strtolower(mysql_escape_string(strip_tags($params['search'])), 'utf8');
         $sql .= ' AND LOWER(title) LIKE "%' . $search . '%"';
     }
     if (!empty($params['where'])) {
         $sql .= $where;
     }
     if (!empty($params['where']) && $params['active'] != -1) {
         $sql .= ' AND active = ' . $params['active'];
     }
     $sql .= !empty($params['sort']) ? ' ORDER BY ' . $params['sort'] : ' ORDER BY title ASC';
     $r = array();
     if (isset($params['cnt']) && isset($params['first'])) {
         $db = $this->mDb->limitQuery($sql, $params['first'], $params['cnt']);
     } else {
         $db = $this->mDb->query($sql);
     }
     include_once 'Model/Base/Cats.class.php';
     $mDict = new Model_Base_Cats($this->mDb);
     while ($row = $db->FetchRow()) {
         $row['path'] = $mDict->buildCatPath($row['id_cat']);
         $r[] = $row;
     }
     return $r;
 }
Пример #3
0
 public function Index()
 {
     define('API', 'PS');
     require_once 'siteadmin/includes/config/affiliatewindow.php';
     include_once 'View/Base/Companies.class.php';
     $view = new View_Base_Companies($this->mlObj, $this->location);
     $type = $_REQUEST['ptype'];
     $mod = $_REQUEST['pmod'];
     $cid = isset($_REQUEST['cid']) ? (int) $_REQUEST['cid'] : 0;
     $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
     $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
     $cat = isset($_REQUEST['cat']) ? $_REQUEST['cat'] : '';
     $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : '';
     $catname = '';
     $catsidebar = '';
     $breadcrumbs = '';
     $id_cat = 0;
     $id_company = 0;
     $cl = '';
     if (!empty($cat)) {
         list($id_cat, $id_company, $breadcrumbs, $catname, $catsidebar) = $this->mCompanies->getIDs();
         // get cats and subcats
         include_once 'Model/Base/Cats.class.php';
         $mDict = new Model_Base_Cats($this->mDb);
         $cl = $mDict->GetCatsList($id_cat, 1, 'sortid, name ASC');
     }
     $view->assign('breadcrumbs', $breadcrumbs);
     $view->assign('catname', $catname);
     $view->assign('meta_title', SITE_NAME . ': ' . $catname);
     $view->assign('meta_keywords', SITE_NAME . ',' . $catname);
     $view->assign('meta_description', SITE_NAME . ': ' . $catname);
     $view->assign('sidebar', $catsidebar);
     // pagging
     $limit = intval($_SESSION[$type . '.' . $mod . '.limit']);
     include_once 'View/Acc/Pagging.php';
     if ($limit == 0) {
         $limit = 10;
     }
     if (!empty($type) && !empty($mod)) {
         $limit = intval($_SESSION[$type . '.' . $mod . '.limit']);
     }
     $view->assign('limit', $limit);
     $view->assign('view', !empty($type) && !empty($mod) ? $_SESSION[$type . '.' . $mod . '.view'] : '');
     $pcnt = $limit;
     $rcnt = $this->mCompanies->GetPagesCount($id_cat, array('search' => $search, 'active' => 1));
     $page = (int) (!empty($_REQUEST['p'])) ? $_REQUEST['p'] : 1;
     if ($page > 1 && $rcnt <= $limit * ($page - 1)) {
         $page--;
     }
     if ($page < 1) {
         $page = 1;
     }
     $view->assign('page', $page);
     $pg = new Pagging($this->mlObj, '', $limit, $rcnt, $page, CPRoute::_('index.php?type=base&mod=ads&cat=' . $cat));
     $view->assign('rcnt', $rcnt);
     $range =& $pg->GetRange();
     $numberOfListingsOnPage = $range[1] - $range[0];
     $results_description = $numberOfListingsOnPage > 0 ? "Showing " . ($range[0] + 1) . " - " . $range[1] . " results out of total " . $rcnt . " listings" : "No results found";
     $view->assign('plist_c', $range[1] - $range[0]);
     $view->assign('results_description', $results_description);
     $list = $this->mCompanies->GetList($id_cat, array('sort' => $sort, 'first' => count($range > 1) ? $range[0] : 0, 'cnt' => $limit, 'search' => $search, 'active' => 1));
     $view->assign('cl', $cl);
     $view->assign('list', $list);
     $view->assign('paginator', $pg->Make());
     if (!empty($search)) {
         $view->assign('title', 'Search results for "' . $search . '"');
         $view->display('searchresults.php');
     } else {
         if (isset($catname)) {
             $view->assign('title', '');
         }
         $view->display('list.php');
     }
 }