<?php if ($this->searchShowLabel) { ?> <div class="bt1 <?php echo $textClass; ?> "><?php echo tt('Search in section', 'common'); ?> :</div> <?php } ?> <li> <?php $data = SearchForm::apTypes(); echo CHtml::dropDownList('apType', isset($this->apType) ? CHtml::encode($this->apType) : '', $data['propertyType'], array('class' => $fieldClass . ' searchField')); ?> </li>
private function generateMap($isXml = false) { $map = array(); $defaultLastMod = date($this->dateFormat, time()); $articleAll = $menuAll = $newsAll = ''; // apartments module if (issetModule('apartments')) { if ($isXml) { $dependencyApartment = new CDbCacheDependency('SELECT MAX(date_updated) FROM {{apartment}}'); } } // article module if (issetModule('articles')) { $articlePage = Menu::model()->findByPk(Menu::ARTICLES_ID); if ($articlePage && $articlePage->active == 1) { Yii::import('application.modules.articles.models.Article'); $dependencyArticle = new CDbCacheDependency('SELECT MAX(date_updated) FROM {{articles}}'); $articleAll = Article::model()->cache(param('cachingTime', 1209600), $dependencyArticle)->findAll(array('condition' => 'active = 1')); if ($isXml) { $sql = 'SELECT MAX(date_updated) as date_updated FROM {{articles}}'; $maxUpdatedArticles = Yii::app()->db->createCommand($sql)->queryRow(); $maxUpdatedArticles = isset($maxUpdatedArticles['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedArticles['date_updated'])) : $defaultLastMod; } } } // infopages module if (issetModule('menumanager')) { $dependencyInfoPages = new CDbCacheDependency('SELECT MAX(date_updated) as date_updated FROM {{menu}}'); $menuAll = Menu::model()->cache(param('cachingTime', 1209600), $dependencyInfoPages)->findAll(array('order' => 'number', 'condition' => 'active = 1 AND (special = 0 OR id = 5)')); if ($isXml) { $sql = 'SELECT MAX(date_updated) as date_updated FROM {{menu}}'; $maxUpdatedInfo = Yii::app()->db->createCommand($sql)->queryRow(); $maxUpdatedInfo = isset($maxUpdatedInfo['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedInfo['date_updated'])) : $defaultLastMod; } } // news module if (issetModule('news')) { $newsPage = Menu::model()->findByPk(Menu::NEWS_ID); if ($newsPage && $newsPage->active == 1) { Yii::import('application.modules.news.models.News'); $dependencyNews = new CDbCacheDependency('SELECT MAX(date_updated) FROM {{news}}'); $newsAll = News::model()->cache(param('cachingTime', 1209600), $dependencyNews)->findAll(); if ($isXml) { $sql = 'SELECT MAX(date_updated) as date_updated FROM {{news}}'; $maxUpdatedNews = Yii::app()->db->createCommand($sql)->queryRow(); $maxUpdatedNews = isset($maxUpdatedNews['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedNews['date_updated'])) : $defaultLastMod; } } } ####################################### index page ####################################### if ($isXml) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['index_page']['title'][$keyLang] = tt('index_page'); $map['index_page']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('/'); $map['index_page']['lastmod'][$keyLang] = isset($indexPageInfo) && isset($indexPageInfo->date_updated) ? date($this->dateFormat, strtotime($indexPageInfo->date_updated)) : $defaultLastMod; } } $this->app->setLanguage($this->defaultLang); } else { $map['index_page']['title'] = tt('index_page'); $map['index_page']['url'] = Yii::app()->createAbsoluteUrl('/'); } ####################################### contact form and booking form ####################################### if ($isXml) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['contact_form']['title'][$keyLang] = tt('contact_form'); $map['contact_form']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('contactform/main/index'); $map['contact_form']['lastmod'][$keyLang] = isset($indexPageInfo) && isset($indexPageInfo->date_updated) ? date($this->dateFormat, strtotime($indexPageInfo->date_updated)) : $defaultLastMod; $map['booking_form']['title'][$keyLang] = tt('booking_form'); $map['booking_form']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('booking/main/mainform'); $map['booking_form']['lastmod'][$keyLang] = isset($indexPageInfo) && isset($indexPageInfo->date_updated) ? date($this->dateFormat, strtotime($indexPageInfo->date_updated)) : $defaultLastMod; } } $this->app->setLanguage($this->defaultLang); } else { $map['contact_form']['title'] = tt('contact_form'); $map['contact_form']['url'] = Yii::app()->createAbsoluteUrl('contactform/main/index'); $map['booking_form']['title'] = tt('booking_form'); $map['booking_form']['url'] = Yii::app()->createAbsoluteUrl('booking/main/mainform'); } ####################################### search ####################################### if ($isXml) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['quick_search']['title'][$keyLang] = tt('quick_search'); $map['quick_search']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch'); $sql = 'SELECT MAX(date_updated) as date_updated FROM {{apartment}}'; $maxUpdatedApartment = Yii::app()->db->createCommand($sql)->queryRow(); $maxUpdatedApartment = isset($maxUpdatedApartment['date_updated']) ? date($this->dateFormat, strtotime($maxUpdatedApartment['date_updated'])) : $defaultLastMod; $map['quick_search']['lastmod'][$keyLang] = $maxUpdatedApartment; } } $this->app->setLanguage($this->defaultLang); } else { $map['quick_search']['title'] = tt('quick_search'); $map['quick_search']['url'] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch'); } ####################################### search subtypes ####################################### $types = SearchForm::apTypes(); if (is_array($types) && isset($types['propertyType'])) { $i = 0; foreach ($types['propertyType'] as $key => $value) { if ($key > 0) { if ($isXml) { $apartmentsByType = null; $result = null; $titles = array(); if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $titles[] = 'title_' . $valLang; } } if (count($titles)) { $titles = implode(',', $titles); $sql = 'SELECT id, ' . $titles . ', date_updated FROM {{apartment}} WHERE price_type = ' . $key . ' AND active = ' . Apartment::STATUS_ACTIVE . ' AND owner_active = ' . Apartment::STATUS_ACTIVE . ' ORDER BY date_updated DESC'; $result = Yii::app()->db->createCommand($sql)->queryAll(); } if ($result) { foreach ($result as $item) { $apartmentsByType[$item['id']] = $item; } } $k = 0; if (is_array($apartmentsByType) && count($apartmentsByType) > 0) { $urls = array(); if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $urls[] = 'url_' . $valLang; } } if (issetModule('seo') && count($urls)) { $urls = implode(',', $urls); $sql = 'SELECT model_id, ' . $urls . ' FROM {{seo_friendly_url}} WHERE model_name="Apartment" GROUP BY model_id ORDER BY id ASC'; $resultSEO = Yii::app()->db->createCommand($sql)->queryAll(); if ($resultSEO) { foreach ($resultSEO as $item) { if (isset($apartmentsByType[$item['model_id']])) { $apartmentsByType[$item['model_id']] = CMap::mergeArray($apartmentsByType[$item['model_id']], $item); } } } } foreach ($apartmentsByType as $value) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); if (isset($value['title_' . $valLang]) && $value['title_' . $valLang]) { $map['quick_search']['subsection'][$i]['apartments'][$k]['title'][$keyLang] = $value['title_' . $valLang]; } if (isset($value['url_' . $valLang]) && $value['url_' . $valLang]) { $map['quick_search']['subsection'][$i]['apartments'][$k]['url'][$keyLang] = Yii::app()->createAbsoluteUrl('/apartments/main/view', array('url' => $value['url_' . $valLang] . (param('urlExtension') ? '.html' : ''))); } else { $map['quick_search']['subsection'][$i]['apartments'][$k]['url'][$keyLang] = Yii::app()->createAbsoluteUrl('/apartments/main/view', array('id' => $value['id'])); } if (isset($value['date_updated']) && $value['date_updated']) { $map['quick_search']['subsection'][$i]['apartments'][$k]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated'])); } } } $this->app->setLanguage($this->defaultLang); $k++; } } } else { //$map['apartment_types'][$i]['title'] = mb_convert_case($value, MB_CASE_TITLE, "UTF-8"); $map['quick_search']['subsection'][$i]['title'] = $value; $map['quick_search']['subsection'][$i]['url'] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch', array('apType' => $key)); } $i++; } } } ####################################### search object types ####################################### $objTypes = Apartment::getObjTypesArray(); if (is_array($objTypes)) { $i = 1; if (array_key_exists('subsection', $map['quick_search'])) { if ($isXml) { $countSubsection = count($map['quick_search']['subsection']); if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { foreach ($objTypes as $key => $value) { $this->app->setLanguage($valLang); $map['quick_search']['subsection'][$countSubsection + $i]['title'][$keyLang] = $value; $map['quick_search']['subsection'][$countSubsection + $i]['url'][$keyLang] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch', array('objType' => $key)); $i++; } } $this->app->setLanguage($this->defaultLang); } } else { $countSubsection = count($map['quick_search']['subsection']); foreach ($objTypes as $key => $value) { $map['quick_search']['subsection'][$countSubsection + $i]['title'] = $value; $map['quick_search']['subsection'][$countSubsection + $i]['url'] = Yii::app()->createAbsoluteUrl('quicksearch/main/mainsearch', array('objType' => $key)); $i++; } } } // no in xml because all links to listings generated above in search subtypes section // duplication link is not needed. } ####################################### special offers ####################################### if (issetModule('specialoffers')) { $specialOfferPage = Menu::model()->findByPk(Menu::SPECIALOFFERS_ID); if ($specialOfferPage && $specialOfferPage->active == 1) { $i = 0; if ($isXml) { $map['special_offers']['title'] = tt('special_offers'); $map['special_offers']['url'] = Yii::app()->createAbsoluteUrl('specialoffers/main/index'); $map['special_offers']['lastmod'] = $maxUpdatedApartment; $specialOffers = Apartment::model()->cache(param('cachingTime', 1209600), $dependencyApartment)->findAllByAttributes(array('is_special_offer' => 1), 'active = :active AND owner_active = :ownerActive', array(':active' => Apartment::STATUS_ACTIVE, ':ownerActive' => Apartment::STATUS_ACTIVE)); $k = 0; if (is_array($specialOffers) && count($specialOffers) > 0) { foreach ($specialOffers as $value) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['special_offers']['subsection'][$k]['title'][$keyLang] = $value->getStrByLang('title'); $map['special_offers']['subsection'][$k]['url'][$keyLang] = $value->getUrl(); $map['special_offers']['subsection'][$k]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated'])); } } $this->app->setLanguage($this->defaultLang); $k++; } } } else { $map['special_offers']['title'] = tt('special_offers'); $map['special_offers']['url'] = Yii::app()->createAbsoluteUrl('specialoffers/main/index'); } } } ####################################### get all info pages ####################################### if (is_array($menuAll) && $menuAll > 0) { $i = 0; if ($isXml) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['section_infopage']['title'][$keyLang] = tt('section_infopage'); $map['section_infopage']['url'][$keyLang] = null; $map['section_infopage']['lastmod'][$keyLang] = $maxUpdatedInfo; foreach ($menuAll as $value) { // убираем из карты сайта типы "Простая ссылка" и "Простая ссылка в выпад. списке" if ($value['type'] != Menu::LINK_NEW_MANUAL && $value['type'] != Menu::LINK_NONE) { $title = $value->getTitle(); if ($title && $value['id'] != 1) { $map['section_infopage']['subsection'][$i]['title'][$keyLang] = $title; if ($value['type'] == Menu::LINK_NEW_INFO) { $href = $value->getUrl(); } else { if ($value['id'] == Menu::SITEMAP_ID) { // sitemap $href = Yii::app()->controller->createAbsoluteUrl('/sitemap/main/index'); } } $map['section_infopage']['subsection'][$i]['url'][$keyLang] = $href; $map['section_infopage']['subsection'][$i]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated'])); $i++; } } } } } $this->app->setLanguage($this->defaultLang); } else { $map['section_infopage']['title'] = tt('section_infopage'); $map['section_infopage']['url'] = null; foreach ($menuAll as $value) { $title = $value->getTitle(); if ($title && $value['id'] != Menu::MAIN_PAGE_ID && $value['type'] != Menu::LINK_NONE) { $map['section_infopage']['subsection'][$i]['title'] = $title; $href = ''; if ($value['type'] == Menu::LINK_NEW_INFO) { $href = $value->getUrl(); } else { if ($value['id'] == Menu::SITEMAP_ID) { // sitemap $href = Yii::app()->controller->createAbsoluteUrl('/sitemap/main/index'); } else { $href = $value->getUrl(); } } if ($href) { $map['section_infopage']['subsection'][$i]['url'] = $href; } $i++; } } } } ####################################### get all news ####################################### if (is_array($newsAll) && count($newsAll) > 0) { $i = 0; if ($isXml) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['section_news']['title'][$keyLang] = tt('section_news'); $map['section_news']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('news/main/index'); $map['section_news']['lastmod'][$keyLang] = $maxUpdatedNews; foreach ($newsAll as $value) { $title = $value->getTitle(); if ($title) { $map['section_news']['subsection'][$i]['title'][$keyLang] = $title; $map['section_news']['subsection'][$i]['url'][$keyLang] = $value->getUrl(); $map['section_news']['subsection'][$i]['lastmod'][$keyLang] = date($this->dateFormat, strtotime($value['date_updated'])); $i++; } } } } $this->app->setLanguage($this->defaultLang); } else { $map['section_news']['title'] = tt('section_news'); $map['section_news']['url'] = Yii::app()->createAbsoluteUrl('news/main/index'); foreach ($newsAll as $value) { $title = $value->getTitle(); if ($title) { $map['section_news']['subsection'][$i]['title'] = $title; $map['section_news']['subsection'][$i]['url'] = $value->getUrl(); $i++; } } } } ####################################### get all article ####################################### if (is_array($articleAll) && count($articleAll) > 0) { $i = 0; if ($isXml) { if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['section_article']['title'] = tt('section_article'); $map['section_article']['url'] = Yii::app()->createAbsoluteUrl('articles/main/index'); $map['section_article']['lastmod'] = $maxUpdatedArticles; foreach ($articleAll as $value) { $title = $value->getPage_title(); if ($title) { $map['section_article']['subsection'][$i]['title'] = $title; $map['section_article']['subsection'][$i]['url'] = $value->getUrl(); $map['section_article']['subsection'][$i]['lastmod'] = date($this->dateFormat, strtotime($value['date_updated'])); $i++; } } } } $this->app->setLanguage($this->defaultLang); } else { $map['section_article']['title'] = tt('section_article'); $map['section_article']['url'] = Yii::app()->createAbsoluteUrl('articles/main/index'); foreach ($articleAll as $value) { $title = $value->getPage_title(); if ($title) { $map['section_article']['subsection'][$i]['title'] = $title; $map['section_article']['subsection'][$i]['url'] = $value->getUrl(); $i++; } } } } ####################################### reviews ####################################### if (issetModule('reviews')) { $reviewsPage = Menu::model()->findByPk(Menu::REVIEWS_ID); if ($reviewsPage && $reviewsPage->active == 1) { $i = 0; if ($isXml) { $sql = 'SELECT MAX(date_updated) as date_updated FROM {{reviews}}'; $maxUpdatedReviews = Yii::app()->db->createCommand($sql)->queryScalar(); if ($this->activeLangs && is_array($this->activeLangs)) { foreach ($this->activeLangs as $keyLang => $valLang) { $this->app->setLanguage($valLang); $map['reviews']['title'][$keyLang] = tt('Reviews', 'reviews'); $map['reviews']['url'][$keyLang] = Yii::app()->createAbsoluteUrl('reviews/main/index'); $map['reviews']['lastmod'][$keyLang] = date($this->dateFormat, strtotime($maxUpdatedReviews)); } } $this->app->setLanguage($this->defaultLang); } else { $map['reviews']['title'] = tt('Reviews', 'reviews'); $map['reviews']['url'] = Yii::app()->createAbsoluteUrl('reviews/main/index'); } } } return $map; }
public function renderFilter(&$criteria) { // start set filter $this->filterPriceType = Yii::app()->request->getParam('filterPriceType'); if ($this->filterPriceType) { $criteria->addCondition('price_type = :filterPriceType'); $criteria->params[':filterPriceType'] = $this->filterPriceType; } $this->filterObjType = Yii::app()->request->getParam('filterObjType'); if ($this->filterObjType) { $criteria->addCondition('obj_type_id = :filterObjType'); $criteria->params[':filterObjType'] = $this->filterObjType; } $this->filterByLat = Yii::app()->request->getParam('filterByLat'); if ($this->filterByLat) { $criteria->addCondition('lat = :filterByLat'); $criteria->params[':filterByLat'] = $this->filterByLat; } $this->filterByLng = Yii::app()->request->getParam('filterByLng'); if ($this->filterByLng) { $criteria->addCondition('lng = :filterByLng'); $criteria->params[':filterByLng'] = $this->filterByLng; } // end set filter // echo filter form $data = SearchForm::apTypes(); echo '<div class="block-filter-viewallonmap">'; echo '<form method="GET" action="" id="form-filter-viewallonmap">'; echo CHtml::dropDownList('filterPriceType', isset($this->filterPriceType) ? CHtml::encode($this->filterPriceType) : '', $data['propertyType']); echo CHtml::dropDownList('filterObjType', isset($this->filterObjType) ? CHtml::encode($this->filterObjType) : 0, CMap::mergeArray(array(0 => Yii::t('common', 'Please select')), Apartment::getObjTypesArray())); echo CHtml::button(tc('Filter'), array('onclick' => '$("#form-filter-viewallonmap").submit();', 'id' => 'click-filter-viewallonmap', 'class' => 'inline button-blue')); echo '</form>'; echo '</div>'; }
public function renderFilter(&$criteria) { // start set filter $this->filterPriceType = Yii::app()->request->getParam('filterPriceType'); if ($this->filterPriceType) { $criteria->addCondition('price_type = :filterPriceType'); $criteria->params[':filterPriceType'] = $this->filterPriceType; } $this->filterObjType = Yii::app()->request->getParam('filterObjType'); if ($this->filterObjType) { $criteria->addCondition('obj_type_id = :filterObjType'); $criteria->params[':filterObjType'] = $this->filterObjType; } // Комнаты $this->roomsCount = $_GET['rooms']; if ($this->roomsCount) { $criteria->addCondition('num_of_rooms = :roomsCount'); $criteria->params[':roomsCount'] = $this->roomsCount; } // !Комнаты // end set filter // echo filter form $data = SearchForm::apTypes(); echo '<div class="block-filter-viewallonmap">'; echo '<form method="GET" action="" id="form-filter-viewallonmap">'; echo CHtml::dropDownList('filterPriceType', isset($this->filterPriceType) ? CHtml::encode($this->filterPriceType) : '', $data['propertyType']); echo CHtml::dropDownList('filterObjType', isset($this->filterObjType) ? CHtml::encode($this->filterObjType) : 0, CMap::mergeArray(array(0 => Yii::t('common', 'Please select')), Apartment::getObjTypesArray())); // Комнаты $roomItems = array('0' => Yii::t('common', 'Number of rooms'), '1' => 1, '2' => 2, '3' => 3, '4' => Yii::t('common', '4 and more')); echo CHtml::dropDownList('rooms', isset($this->roomsCount) ? CHtml::encode($this->roomsCount) : 0, $roomItems, array('class' => $fieldClass . ' searchField')); // !Комнаты echo CHtml::button(tc('Filter'), array('onclick' => '$("#form-filter-viewallonmap").submit();', 'id' => 'click-filter-viewallonmap', 'class' => 'inline button-blue')); echo '</form>'; echo '</div>'; }