Beispiel #1
0
 function before()
 {
     parent::before();
     $this->response->headers('Pragma', 'no-cache');
     $this->settings = Kohana::$config->load('settings');
     $this->site_name = $this->settings['site_name'];
     // Стили
     $this->add_css('assets/css/reset.css');
     $this->add_css('assets/js/multiselect/jquery.multiselect.css');
     $this->add_css('assets/js/gallery/css/jquery.lightbox-0.5.css');
     $this->add_css('assets/css/rmsform.css');
     $this->add_css('assets/js/css/flick/jquery-ui-1.8.16.custom.css');
     $this->add_css('assets/css/bootstrap_frontend.css');
     $this->add_css('assets/css/main_min.css?version=781');
     // Скрипты
     $this->add_js('assets/js/jquery-1.7.1.js');
     $this->add_js('assets/js/jquery-ui-1.8.17.custom.min.js');
     $this->add_js('assets/js/jquery.columnizer.min.js');
     $this->add_js('assets/js/jquery.scrollTo-min.js');
     $this->add_js('assets/js/jquery.showpassword.js');
     $this->add_js('assets/js/ckeditor/ckeditor.js');
     $this->add_js('assets/js/multiselect/jquery.multiselect.js');
     $this->add_js('assets/js/multiselect/jquery.multiselect.filter.js');
     $this->add_js('assets/js/gallery/jquery.lightbox-0.5.js');
     $this->add_js('assets/js/jquery.qtip-1.0.0-rc3.js');
     $this->add_js('assets/js/main.js?version=780');
     $this->add_js('http://userapi.com/js/api/openapi.js?48', 'before');
     // Count of notices
     if ($this->user) {
         $this->template->notice_count = ORM::factory('notice')->get_notices_count($this->user);
     }
     $this->template->css_class = '';
     $this->template->bc['/'] = 'Главная';
     //$current_city = $this->session->get('current_city', 'moscow');
     $items = array('cars' => array('name' => 'cars', 'ids' => NULL), 'works' => array('name' => 'works', 'ids' => NULL));
     $this->_geo_params = Geography::get_geography_params();
     $this->_selected_city_ids = Geography::set_selected_city_id($this->_geo_params['cities'], Cookie::get('filter_city'));
     // Cities select on header
     $this->template->cities = $this->_geo_params['cities']['total'];
     uasort($this->template->cities, array('Model_City', 'cmp'));
     $this->template->selected_city_ids = array('total' => $this->_selected_city_ids['total'], 'has_cars' => $this->_selected_city_ids['has_cars']);
     $this->template->assoc_news = ORM::factory('newsportal');
 }
Beispiel #2
0
 /**
  * Поиск по услуге services/search/work_:id
  * @return void
  */
 public function action_search_by_work()
 {
     $work_id = $this->request->param('work');
     $city_id = $this->request->param('city');
     $district_id = $this->request->query('district');
     $metro_id = $this->request->query('metro');
     $this->_selected_city_ids = Geography::set_selected_city_id($this->_geo_params['cities'], $city_id);
     if (!array_key_exists($city_id, $this->_geo_params['cities']['total'])) {
         $this->request->redirect('filter/auto/city_' . $this->_selected_city_ids['has_works']);
     }
     $params['city'] = array('field' => 'city_id', 'op' => '=', 'value' => $city_id);
     $current_district = Arr::get($this->_geo_params['districts'], $district_id);
     $current_metro_station = Arr::get($this->_geo_params['metro_stations'], $metro_id);
     if ($current_district and $current_district['city_id'] == $city_id and !empty($current_district['works']) and in_array($work_id, $current_district['works'])) {
         $params['district'] = array('field' => 'district_id', 'op' => '=', 'value' => $district_id);
     } else {
         $district_id = 0;
     }
     if ($current_metro_station and $current_metro_station['city_id'] == $city_id or $current_district and $current_metro_station['district_id'] == $district_id and !empty($current_metro_station['works']) and in_array($work_id, $current_metro_station['works'])) {
         $params['metro'] = array('field' => 'metro_id', 'op' => '=', 'value' => $metro_id);
     } else {
         $metro_id = 0;
     }
     $url = 'services/search/work_' . $work_id . '/city_' . $city_id;
     $items['works'] = array('name' => 'works', 'ids' => array($work_id));
     $district = ORM::factory('district')->set_has_items($items)->get_districts($this->_geo_params, $city_id);
     $metro = ORM::factory('metro')->set_has_items($items)->get_metro($this->_geo_params, $city_id, $district_id);
     $discount = ORM::factory('discount')->set_params($params)->get_discounts();
     $car_brand = ORM::factory('car_brand')->set_params($params)->get_cars(NULL, $items['works']['ids']);
     $work = ORM::factory('work')->set_params($params)->get_works(TRUE);
     $service = ORM::factory('service')->set_params($params)->set_has_items($items)->get_services_2();
     $service->reset(FALSE);
     $services_count = count($service->find_all());
     if ($services_count == 0) {
         Message::set(Message::ERROR, 'Неправильные параметры поиска, сервисы не найдены.');
         $this->request->redirect('filter/work/' . $this->_selected_city_ids['has_works']);
     }
     $current_work = ORM::factory('work')->extract_current_work_from_categories($work, $work_id);
     $content = $current_work['current_object']->content;
     $i18n_params = array(':work_name' => $current_work['name'], ':dativus_city_name' => $this->_geo_params['cities']['total'][$city_id]->dativus_name);
     $this->template->meta_keywords = __('search_work_keywords', $i18n_params);
     $this->template->meta_description = __('search_work_description', $i18n_params);
     $h1_title = __('search_work_h1', $i18n_params);
     $this->template->title = __('search_work_title', $i18n_params);
     $this->template->bc['filter/work/' . $this->_selected_city_ids['has_works']] = 'Подбор автосервиса по предоставляемым услугам';
     $this->template->bc['#'] = Text::limit_chars($h1_title, 75);
     /* Default text */
     if ($params['city']['value'] != 1 or !trim(strip_tags($content->text))) {
         $content->text = __(Kohana::$config->load('default_search_content.search_by_work'), array(':name' => $current_work['name']));
     }
     $this->view = View::factory('frontend/services/search')->set('city', $this->_geo_params['cities']['total'][$city_id])->set('metro_stations', $metro)->set('districts', $district)->set('discounts', $discount)->set('cars', $car_brand)->set('works', $work)->set('services', $service)->set('type', 'work')->set('work_id', $work_id)->set('car_id', NULL)->set('city_id', $city_id)->set('metro_id', $metro_id)->set('district_id', $district_id)->set('url', $url)->set('services_count', $services_count)->set('content', $content)->set('h1_title', $h1_title);
     $this->template->content = $this->view;
 }
Beispiel #3
0
 /**
  * Фильтр услуг и прочего
  * @return mixed
  */
 public function action_fast_filter()
 {
     $geo_params = Geography::get_geography_params();
     // Типы быстрого поиска на главной
     $types = array('has_cars', 'has_works', 'has_metro', 'has_district');
     if ($this->request->query('type') and in_array($this->request->query('type'), $types)) {
         Cookie::set('fast_filter_type', $this->request->query('type'));
         $filter_type = $this->request->query('type');
     } else {
         $filter_type = Cookie::get('fast_filter_type', 'has_cars');
         if (!in_array($filter_type, $types)) {
             $filter_type = 'has_cars';
         }
     }
     if ($this->request->query('city') and array_key_exists($this->request->query('city'), $geo_params['cities']['total'])) {
         Cookie::set('filter_city', $this->request->query('city'));
         $city_id = $this->request->query('city');
     } else {
         $city_id = Cookie::get('filter_city');
     }
     $selected_city_ids = Geography::set_selected_city_id($geo_params['cities'], $city_id);
     $params = array('city' => array('field' => 'city_id', 'op' => '=', 'value' => $selected_city_ids[$filter_type]));
     $header_cities_view = View::factory('frontend/navigation/header_cities')->set('cities', $geo_params['cities']['total'])->set('current_city', $selected_city_ids['total'])->render();
     if ($this->request->query('mode') == 'without_filter') {
         $result = array('header_cities' => $header_cities_view, 'auto_filter_city_id' => $selected_city_ids['has_cars']);
         echo json_encode($result);
         return;
     }
     $config = Kohana::$config->load('settings');
     $current_city = array('name' => $geo_params['cities']['total'][$selected_city_ids[$filter_type]]->name, 'genitive_name' => $geo_params['cities']['total'][$selected_city_ids[$filter_type]]->genitive_name);
     $primary_cities = array_intersect_key($geo_params['cities']['total'], $geo_params['cities'][$filter_type]);
     $other_cities = NULL;
     // Получение городов, основных и "других"
     if (count($primary_cities) > $config['max_fast_filter_cities']) {
         $primary_cities = array_intersect_key($primary_cities, array_flip($config['fast_filter_cities']));
         if (!array_key_exists($selected_city_ids[$filter_type], $primary_cities)) {
             array_pop($primary_cities);
             $primary_cities = array($selected_city_ids[$filter_type] => $geo_params['cities']['total'][$selected_city_ids[$filter_type]]) + $primary_cities;
         }
         $other_cities = array_diff_key(array_intersect_key($geo_params['cities']['total'], $geo_params['cities'][$filter_type]), $primary_cities);
     }
     $filter_type_view = View::factory('frontend/navigation/fast_filter_types')->set('types', $types)->set('current_type', $filter_type)->render();
     $cities_view = View::factory('frontend/navigation/fast_filter_cities')->set('cities', $primary_cities)->set('other_cities', $other_cities)->set('city_id', $selected_city_ids[$filter_type])->render();
     switch ($filter_type) {
         case 'has_cars':
             $car_brand = ORM::factory('car_brand')->set_params($params)->get_cars();
             if (count($car_brand) > $config['max_fast_filter_models']) {
                 $primary_cars = array_intersect_key($car_brand, array_flip($config['fast_filter_models']));
                 if (count($primary_cars) < $config['max_fast_filter_models']) {
                     $primary_cars = $primary_cars + array_slice(array_diff_key($car_brand, $primary_cars), 0, $config['max_fast_filter_models'] - count($primary_cars), TRUE);
                 }
                 $car_brand = $primary_cars;
             }
             $items_view = View::factory('frontend/fast_filter/car_brands')->set('city_id', $params['city']['value'])->set('car_brands', $car_brand)->render();
             break;
         case 'has_works':
             $work = ORM::factory('work')->set_params($params)->get_works();
             if (count($work) > $config['max_fast_filter_works']) {
                 $primary_works = array_intersect_key($work, array_flip($config['fast_filter_works']));
                 if (count($primary_works) < $config['max_fast_filter_works']) {
                     $primary_works = $primary_works + array_slice(array_diff_key($work, $primary_works), 0, $config['max_fast_filter_works'] - count($primary_works), TRUE);
                 }
                 $work = $primary_works;
             }
             $items_view = View::factory('frontend/fast_filter/works')->set('works', $work)->set('city_id', $params['city']['value'])->render();
             break;
         case 'has_metro':
             $metro = ORM::factory('metro')->get_metro($geo_params, $params['city']['value']);
             if (count($metro) > $config['max_fast_filter_metro']) {
                 $metro = array_slice($metro, 0, $config['max_fast_filter_metro'], TRUE);
             }
             $items_view = View::factory('frontend/fast_filter/metro')->set('metro_stations', $metro)->set('city_id', $params['city']['value'])->render();
             break;
         case 'has_district':
             $district = ORM::factory('district')->get_districts($geo_params, $params['city']['value']);
             if (count($district) > $config['max_fast_filter_districts']) {
                 $district = array_slice($district, 0, $config['max_fast_filter_districts'], TRUE);
             }
             $items_view = View::factory('frontend/fast_filter/districts')->set('districts', $district)->set('city_id', $params['city']['value'])->render();
             break;
     }
     $result = array('filter_type' => $filter_type_view, 'cities' => $cities_view, 'items' => $items_view, 'header_cities' => $header_cities_view, 'current_city' => $current_city, 'auto_filter_url' => URL::site('filter/auto/city_' . $selected_city_ids['has_cars']));
     if ($this->request->is_ajax()) {
         echo json_encode($result);
     } else {
         $this->response->body($result['filter_type'] . $result['cities'] . $result['items']);
     }
 }
Beispiel #4
0
 /**
  * Теги округов
  * @return void
  */
 function action_district()
 {
     if ($this->request->param('city')) {
         $this->_selected_city_ids = Geography::set_selected_city_id($this->_geo_params['cities'], $this->request->param('city'));
         $this->template->selected_city_ids = array_intersect_key($this->_selected_city_ids, $this->template->selected_city_ids);
         Cookie::set('filter_city', $this->_selected_city_ids['total']);
     } else {
         $this->request->redirect('filter/district/city_' . $this->_selected_city_ids['has_district']);
     }
     $params = array('city' => array('field' => 'city_id', 'op' => '=', 'value' => $this->_selected_city_ids['has_district']));
     $district = ORM::factory('district')->get_districts($this->_geo_params, $params['city']['value']);
     if (empty($district)) {
         Message::set(Message::ERROR, 'Не найдены округи');
         $this->request->redirect('filter/district/city_' . $this->_selected_city_ids['has_district']);
     }
     $current_city = $this->_geo_params['cities']['total'][$this->_selected_city_ids['has_district']];
     $content = $current_city->contents->where('type', '=', 'district')->find();
     if (!trim(strip_tags($content->text))) {
         $content->text = __('filter_district_default_content', array(':name' => $content->city->name));
     }
     if ($this->request->query('selected_city') and $this->request->query('selected_city') != $this->_selected_city_ids['has_district']) {
         Message::set(Message::NOTICE, __('filter_district_city_not_found', array(':city_name' => $current_city->name)));
     }
     $this->view = View::factory('frontend/filter/districts')->set('cities', array_intersect_key($this->_geo_params['cities']['total'], $this->_geo_params['cities']['has_district']))->set('selected_city_ids', $this->_selected_city_ids)->set('districts', $district)->set('content', $content);
     $this->template->title = 'Подбор автосервиса по округу';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }