Example #1
0
 function search()
 {
     $this->find();
     $tpl =& Registry::get('TTemplate');
     $tpl->config_load($GLOBALS['domain'] . '__' . lang() . '.conf', 'search');
     $ret['pages'] = TContent::getNavigation($this->search['total'], $this->search['limit'], $this->search['offset'], "search");
     $ret['search'] = $this->search;
     // Сохраняем в статистике
     if (!$ret['search']['type']) {
         $client = isset($GLOBALS['client_id']) ? $GLOBALS['client_id'] : 0;
         if (!empty($ret['search']['query'])) {
             sql_query('INSERT INTO stat_search (root_id, client_id, keyword, date) VALUES (' . ROOT_ID . ', ' . $client . ', "' . $ret['search']['query'] . '", ' . time() . ')');
         }
     }
     if (!$ret['search'] || $ret['search']['total'] > 0) {
         unset($tpl->_tpl_vars['sitemap']);
     }
     return $ret;
 }
Example #2
0
 function show(&$params)
 {
     $param = $this->getParams($params);
     $page =& Registry::get('TPage');
     if (empty($param['limit'])) {
         $param['limit'] = $page->tpl->get_config_vars('count_hot_news');
     }
     if (empty($param['limit']) || !is_numeric($param['limit'])) {
         $param['limit'] = 20;
     }
     $list = sql_getRows("SELECT n.* FROM " . $this->table . " AS n, tree AS t WHERE " . $this->sql . " AND n.pid=" . $page->content['id'] . " ORDER BY n.date DESC LIMIT " . $param['offset'] . "," . $param['limit']);
     foreach ($list as $key => $val) {
         $list[$key]['offset'] = sql_getValue('SELECT COUNT(*) FROM ' . $this->table . ' WHERE visible > 0 AND pid=' . $page->content['id'] . ' AND date > "' . $val['date'] . '" ORDER BY date');
     }
     // Навигация
     $all_count = (int) sql_getValue('SELECT COUNT(*) FROM ' . $this->table . ' AS n, tree AS t WHERE ' . $this->sql . ' AND n.pid=' . $page->content['id']);
     if ($all_count > $param['limit']) {
         $ret['pages'] = TContent::getNavigation($all_count, $param['limit'], $param['offset'], $page->content['href']);
     }
     $ret['list'] = $list;
     return $ret;
 }
Example #3
0
 /**
  * Функция поиска по параметрам
  *
  */
 function search(&$params)
 {
     $page_obj =& Registry::get('TPage');
     $res = $params;
     $sql = $this->generateQuery($res);
     //------------------------------------------------------------------------
     // Сортировка
     $order_by = $this->getSort($res);
     $list = $this->getList($res, $sql, $order_by);
     $res['objects'] = $list['list'];
     $this->getFlatStars($list['list']);
     $search_query = '?' . $_SERVER['QUERY_STRING'];
     $search_query = remove_query_arg($search_query, 'offset');
     $search_query = remove_query_arg($search_query, 'limit');
     $search_query = remove_query_arg($search_query, 'sort_by');
     $search_query = remove_query_arg($search_query, 'sort_type');
     $res['search_query'] = '&' . substr($search_query, 1);
     $res['pages1'] = TContent::getNavigation($list['count'], $res['limit'], $res['offset'], $page_obj->content['href']);
     $res['pages2'] = TContent::getNavigation($list['count'], $res['limit'], $res['offset'], $page_obj->content['href'], null, 'ids_pages.html');
     $res['sort_by'] = $res['sort_by'] ? $res['sort_by'] : 'price_rub';
     $res['sort_type'] = $res['sort_type'] ? $res['sort_type'] : 'asc';
     $res['sort'] = array();
     $res['sort'][$res['sort_by']] = $res['sort_type'];
     return $res;
 }
Example #4
0
 function Show(&$params)
 {
     $param = $this->getParams($params);
     $page =& Registry::get('TPage');
     // Разбираем путь на части
     $real_path = $_SERVER['REQUEST_URI'];
     if (substr($real_path, -1) != '/') {
         $real_path .= '/';
     }
     // Текущий путь
     $query = explode('?', $real_path);
     $pids = explode('/', $query[0]);
     $pos = array_search('object', $pids);
     // Позиция слова object в пути страницы
     if ($pos !== false) {
         $param['id'] = (int) $pids[$pos + 1];
     }
     // Определяем id объекта (должен находиться в пути после object)
     $param['path'] = '';
     for ($i = 0; $i <= $pos - 1; $i++) {
         $param['path'] .= $pids[$i] . '/';
     }
     if (isset($param['id'])) {
         return $this->getOneObject($param['id'], $pids, $pos, isset($pids[$pos + 2]) ? $pids[$pos + 2] : '');
     }
     // Способ отображения
     $ret['show'] = $param['show'] ? $param['show'] : 'table';
     // Данные с формы поиска
     $ret['data'] = get('search', array(), 'g');
     // Сортировка
     $sort = $this->getSort($param);
     if (empty($param['sort_by'])) {
         switch ($this->type) {
             case 'room':
                 $param['sort_by'] = "price_rub";
                 break;
             case 'newbuild':
             case 'commerce':
                 $param['sort_by'] = $param['show'] == 'table' ? "address_id" : "price_rub";
                 break;
             default:
                 $param['sort_by'] = "price_rub";
                 break;
         }
     }
     $ret['sort_by'] = $param['sort_by'] ? $param['sort_by'] : 'price_rub';
     $ret['sort_type'] = $param['sort_type'] ? $param['sort_type'] : 'asc';
     $ret['sort'] = array();
     $ret['sort'][$ret['sort_by']] = $ret['sort_type'];
     foreach ($this->fields as $key => $val) {
         if ($val != $param['sort_by']) {
             $ret['sort'][$val] = "";
         }
     }
     // Список объектов
     $list = $this->getList($param, " AND o.winner='0'", $sort);
     $ret['objects'] = $list['list'];
     // Колонки
     $ret['fields'] = $this->fields;
     $ret['count_fields'] = count($this->fields);
     $ret['align'] = $this->fields_align;
     // Данные дляфильтра
     $ret['filter'] = $this->filter;
     // Навигация
     $ret['limit'] = $param['limit'];
     $ret['offset'] = $param['offset'];
     $ret['pages1'] = TContent::getNavigation($list['count'], $param['limit'], $param['offset'], $page->content['href']);
     $ret['pages2'] = TContent::getNavigation($list['count'], $param['limit'], $param['offset'], $page->content['href'], null, 'ids_pages.html');
     $ret['moscow'] = $param['moscow'];
     $ret['market'] = $param['market'];
     $url = $page->content['href'];
     // Формируем разные пути
     $path = array('show_path' => array('moscow', 'market'), 'type_path' => array('sort_by', 'sort_type', 'limit', 'show', 'market'), 'sort_path' => array('offset', 'limit', 'show', 'moscow', 'market'));
     foreach ($path as $key => $val) {
         $ret[$key] = $url;
         foreach ($val as $p) {
             if (isset($ret[$p])) {
                 $ret[$key] = add_query_arg($ret[$key], $p, $ret[$p]);
             }
         }
         if (strpos($ret[$key], '?') === false) {
             $ret[$key] .= '?';
         } else {
             $ret[$key] .= '&';
         }
     }
     $ret['type'] = $this->type;
     return $ret;
 }