本文整理汇总了PHP中Apartment::getApartmentVisitCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Apartment::getApartmentVisitCount方法的具体用法?PHP Apartment::getApartmentVisitCount怎么用?PHP Apartment::getApartmentVisitCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Apartment
的用法示例。
在下文中一共展示了Apartment::getApartmentVisitCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
public function actionView($id = 0)
{
//$this->layout='//layouts/inner';
Yii::app()->bootstrap->plugins['tooltip'] = array('selector' => ' ', 'options' => array('placement' => 'top'));
$model = $this->loadModelWith(array('windowTo', 'objType', 'city'));
if (!in_array($model->type, Apartment::availableApTypesIds()) || !in_array($model->price_type, array_keys(Apartment::getPriceArray(Apartment::PRICE_SALE, true)))) {
throw404();
}
$this->render('view', array('model' => $model, 'statistics' => Apartment::getApartmentVisitCount($model)));
}
示例2: actionView
public function actionView($id = 0, $url = '', $printable = 0)
{
// если админ - делаем редирект на просмотр в админку
// if(Yii::app()->user->getState('isAdmin')){
// $this->redirect(array('backend/main/view', 'id' => $id));
// }
$apartment = NULL;
if (($id || $url) && issetModule('seo')) {
$url = $url ? $url : $id;
$seo = SeoFriendlyUrl::getForView($url, $this->modelName);
if ($seo) {
$this->setSeo($seo);
$id = $seo->model_id;
}
}
if ($id) {
$apartment = Apartment::model()->with(array('windowTo', 'objType', 'city'))->findByPk($id);
}
if (!$apartment) {
throw404();
}
if (!in_array($apartment->type, Apartment::availableApTypesIds())) {
throw404();
}
// "Толстый" запрос из-за JOIN'ов. Кешируем его.
// Зависимость кеша - выбираем дату последней модификации из 4 таблиц
// $apartment = Apartment::model()
// ->cache(param('cachingTime', 1209600), Apartment::getFullDependency($id))
// ->with('windowTo', 'comments', 'images', 'objType', 'city')
// ->findByPk($id);
//
// if (!$apartment)
// throw404();
if ($apartment->owner_id != 1 && $apartment->owner_active == Apartment::STATUS_INACTIVE) {
if (!(isset(Yii::app()->user->id) && Yii::app()->user->id == $apartment->owner_id) && !Yii::app()->user->getState('isAdmin')) {
Yii::app()->user->setFlash('notice', tt('apartments_main_index_propertyNotAvailable', 'apartments'));
throw404();
}
}
if (($apartment->active == Apartment::STATUS_INACTIVE || $apartment->active == Apartment::STATUS_MODERATION) && !Yii::app()->user->getState('isAdmin') && !(isset(Yii::app()->user->id) && Yii::app()->user->id == $apartment->owner_id)) {
Yii::app()->user->setFlash('notice', tt('apartments_main_index_propertyNotAvailable', 'apartments'));
//$this->redirect(Yii::app()->homeUrl);
throw404();
}
if ($apartment->active == Apartment::STATUS_MODERATION && $apartment->owner_active == Apartment::STATUS_ACTIVE && $apartment->owner_id == Yii::app()->user->id) {
Yii::app()->user->setFlash('error', tc('Awaiting moderation'));
}
$dateFree = CDateTimeParser::parse($apartment->is_free_to, 'yyyy-MM-dd');
if ($dateFree && $dateFree < time() - 60 * 60 * 24) {
$apartment->is_special_offer = 0;
$apartment->update(array('is_special_offer'));
}
if (!Yii::app()->request->isAjaxRequest) {
$ipAddress = Yii::app()->request->userHostAddress;
$userAgent = Yii::app()->request->userAgent;
Apartment::setApartmentVisitCount($apartment, $ipAddress, $userAgent);
}
if ($printable) {
$this->layout = '//layouts/print';
$this->render('view_print', array('model' => $apartment));
} else {
Apartment::model()->setLastVisitedObjectsCookies($apartment->id);
$this->render('view', array('model' => $apartment, 'statistics' => Apartment::getApartmentVisitCount($apartment)));
}
}
示例3: actionView
public function actionView($id = 0, $url = '', $printable = 0)
{
//$this->showSearchForm = false;
$this->htmlPageId = 'viewlisting';
$apartment = NULL;
$seo = NULL;
if (($id || $url) && issetModule('seo')) {
$url = $url ? $url : $id;
$seo = SeoFriendlyUrl::getForView($url, $this->modelName);
if ($seo) {
$this->setSeo($seo);
$id = $seo->model_id;
}
}
if ($id) {
$apartment = Apartment::model()->with(array('windowTo', 'objType', 'city'))->findByPk($id);
// избавляемся от дублей
$apartmentUrl = $apartment->getUrl(false);
if (!$printable && issetModule('seo') && $apartment->seo && Yii::app()->request->url != $apartmentUrl) {
$this->redirect($apartmentUrl, true, 301);
}
}
if (!$apartment) {
throw404();
}
if (!in_array($apartment->type, Apartment::availableApTypesIds()) || !in_array($apartment->price_type, array_keys(Apartment::getPriceArray(Apartment::PRICE_SALE, true)))) {
throw404();
}
if ($apartment->owner_id != 1 && $apartment->owner_active == Apartment::STATUS_INACTIVE) {
if (!(isset(Yii::app()->user->id) && Yii::app()->user->id == $apartment->owner_id) && !Yii::app()->user->checkAccess('backend_access')) {
Yii::app()->user->setFlash('notice', tt('apartments_main_index_propertyNotAvailable', 'apartments'));
throw404();
}
}
if (($apartment->active == Apartment::STATUS_INACTIVE || $apartment->active == Apartment::STATUS_MODERATION) && !Yii::app()->user->checkAccess('backend_access') && !(isset(Yii::app()->user->id) && Yii::app()->user->id == $apartment->owner_id)) {
Yii::app()->user->setFlash('notice', tt('apartments_main_index_propertyNotAvailable', 'apartments'));
//$this->redirect(Yii::app()->homeUrl);
throw404();
}
if ($apartment->active == Apartment::STATUS_MODERATION && $apartment->owner_active == Apartment::STATUS_ACTIVE && $apartment->owner_id == Yii::app()->user->id) {
Yii::app()->user->setFlash('error', tc('Awaiting moderation'));
}
if ($apartment->deleted) {
Yii::app()->user->setFlash('error', tt('Listing is deleted', 'apartments'));
}
$dateFree = CDateTimeParser::parse($apartment->is_free_to, 'yyyy-MM-dd');
if ($dateFree && $dateFree < time() - 60 * 60 * 24) {
$apartment->is_special_offer = 0;
$apartment->update(array('is_special_offer'));
}
if (!Yii::app()->request->isAjaxRequest) {
$ipAddress = Yii::app()->request->userHostAddress;
$userAgent = Yii::app()->request->userAgent;
Apartment::setApartmentVisitCount($apartment, $ipAddress, $userAgent);
}
$lastNews = News::getLastNews();
$lastArticles = Article::getLastArticles();
#######################################################################
# для соц. кнопок
if ($apartment->getStrByLang("title")) {
Yii::app()->clientScript->registerMetaTag($apartment->getStrByLang("title"), null, null, array('property' => 'og:title'));
}
if ($apartment->getStrByLang("description")) {
Yii::app()->clientScript->registerMetaTag($apartment->getStrByLang("description"), null, null, array('property' => 'og:description'));
}
Yii::app()->clientScript->registerMetaTag($apartment->getUrl(), null, null, array('property' => 'og:url'));
if (Yii::app()->theme->name == 'atlas') {
$res = Images::getMainThumb(640, 400, $apartment->images);
} else {
$res = Images::getMainThumb(300, 200, $apartment->images);
}
if (isset($res['thumbUrl']) && $res['thumbUrl']) {
Yii::app()->clientScript->registerMetaTag($res['thumbUrl'], null, null, array('property' => 'og:image'));
Yii::app()->clientScript->registerLinkTag('image_src', null, $res['thumbUrl']);
}
#######################################################################
if ($printable) {
$this->layout = '//layouts/print';
$this->render('view_print', array('model' => $apartment));
} else {
$this->render('view', array('model' => $apartment, 'statistics' => Apartment::getApartmentVisitCount($apartment), 'lastNews' => $lastNews, 'lastArticles' => $lastArticles));
}
}