<div class="<?php 
echo $divClass;
?>
">
    <span class="search"><div class="<?php 
echo $textClass;
?>
"><?php 
echo Yii::t('common', 'Property type');
?>
:</div> </span>
    <span class="search">
    <?php 
echo CHtml::dropDownList('objType', isset($this->objType) ? CHtml::encode($this->objType) : 0, CMap::mergeArray(array(0 => Yii::t('common', 'Please select')), Apartment::getObjTypesArray()), array('class' => $fieldClass));
Yii::app()->clientScript->registerScript('objType', '
		focusSubmit($("select#objType"));
	', CClientScript::POS_READY);
?>
    </span>
</div>
    <?php 
if ($this->searchShowLabel) {
    ?>
	<div class="<?php 
    echo $textClass;
    ?>
"><?php 
    echo Yii::t('common', 'Property type');
    ?>
:</div>
    <?php 
}
?>
	<li>
    <?php 
echo CHtml::dropDownList('objType', isset($this->objType) ? $this->objType : 0, CMap::mergeArray(array(0 => Yii::t('common', 'Property type')), Apartment::getObjTypesArray()), array('class' => $fieldClass));
?>
	</li>
示例#3
0
    private function addListingFromCSV($value, $isZip, $maxSorter, $selectedImportUser)
    {
        if (is_array($value)) {
            $model = new $this->modelName();
            $type = !empty($value['type']) ? $value['type'] : Apartment::TYPE_DEFAULT;
            $priceType = !empty($value['priceType']) ? $value['priceType'] : '';
            $objType = !empty($value['objType']) ? $value['objType'] : min(Apartment::getObjTypesArray());
            $countryName = !empty($value['countryName']) ? trim($value['countryName']) : null;
            $regionName = !empty($value['regionName']) ? trim($value['regionName']) : null;
            $cityName = !empty($value['cityName']) ? trim($value['cityName']) : null;
            $countryId = $countryInfo = $regionId = $regionInfo = $cityId = $cityInfo = 0;
            if (issetModule('location')) {
                if ($countryName) {
                    if (isFree()) {
                        $countryInfo = Country::model()->findByAttributes(array('name_' . Yii::app()->language => $countryName));
                    } else {
                        Yii::app()->setLanguage($this->defLang);
                        $countryInfo = Country::model()->findByAttributes(array('name_' . Yii::app()->language => $countryName));
                        Yii::app()->setLanguage($this->currLang);
                    }
                    if ($countryInfo && isset($countryInfo->id)) {
                        $countryId = $countryInfo->id;
                    }
                }
                if ($regionName) {
                    if (isFree()) {
                        $regionInfo = Region::model()->findByAttributes(array('name_' . Yii::app()->language => $regionName));
                    } else {
                        Yii::app()->setLanguage($this->defLang);
                        $regionInfo = Region::model()->findByAttributes(array('name_' . Yii::app()->language => $regionName));
                        Yii::app()->setLanguage($this->currLang);
                    }
                    if ($regionInfo && isset($regionInfo->id)) {
                        $regionId = $regionInfo->id;
                    }
                }
                if ($cityName) {
                    if (isFree()) {
                        $cityInfo = City::model()->findByAttributes(array('name_' . Yii::app()->language => $cityName));
                    } else {
                        Yii::app()->setLanguage($this->defLang);
                        $cityInfo = City::model()->findByAttributes(array('name_' . Yii::app()->language => $cityName));
                        Yii::app()->setLanguage($this->currLang);
                    }
                    if ($cityInfo && isset($cityInfo->id)) {
                        $cityId = $cityInfo->id;
                    }
                }
            } else {
                if ($cityName) {
                    Yii::import('application.modules.apartmentCity.models.ApartmentCity');
                    if (isFree()) {
                        $cityInfo = ApartmentCity::model()->findByAttributes(array('name_' . Yii::app()->language => $cityName));
                    } else {
                        Yii::app()->setLanguage($this->defLang);
                        $cityInfo = ApartmentCity::model()->findByAttributes(array('name_' . Yii::app()->language => $cityName));
                        Yii::app()->setLanguage($this->currLang);
                    }
                    if ($cityInfo && isset($cityInfo->id)) {
                        $cityId = $cityInfo->id;
                    }
                }
            }
            // if type for sale - set price type only for sale
            if ($type == Apartment::TYPE_SALE) {
                $priceType = Apartment::PRICE_SALE;
            }
            $isPricePoa = isset($value['isPricePoa']) ? $value['isPricePoa'] : 0;
            $price = !empty($value['price']) ? $value['price'] : '';
            $priceTo = !empty($value['priceTo']) ? $value['priceTo'] : '';
            $numberRooms = !empty($value['numberRooms']) ? $value['numberRooms'] : '';
            $floor = !empty($value['floor']) ? $value['floor'] : '';
            $floor_total = !empty($value['floorTotal']) ? $value['floorTotal'] : '';
            $square = !empty($value['square']) ? $value['square'] : '';
            $landSquare = !empty($value['landSquare']) ? $value['landSquare'] : '';
            $sleeps = !empty($value['sleeps']) ? $this->deleteChars($value['sleeps']) : '';
            if (isFree()) {
                $title = !empty($value['title']) ? $this->deleteChars($value['title']) : '';
                $description = !empty($value['description']) ? $this->deleteChars($value['description']) : '';
                $near = !empty($value['near']) ? $this->deleteChars($value['near']) : '';
                $address = !empty($value['location']) ? $this->deleteChars($value['location']) : '';
                $exchange = !empty($value['exchange']) ? $this->deleteChars($value['exchange']) : '';
            } else {
                if ($this->allLangs) {
                    foreach ($this->i18nMaskFields as $i18nMaskField) {
                        foreach ($this->allLangs as $lang) {
                            $title[$lang->name_iso] = $this->deleteChars($value['title_' . $lang->name_iso]);
                            $description[$lang->name_iso] = $this->deleteChars($value['description_' . $lang->name_iso]);
                            $near[$lang->name_iso] = $this->deleteChars($value['near_' . $lang->name_iso]);
                            $address[$lang->name_iso] = $this->deleteChars($value['location_' . $lang->name_iso]);
                            $exchange[$lang->name_iso] = $this->deleteChars($value['exchange_' . $lang->name_iso]);
                        }
                    }
                }
            }
            $lat = !empty($value['lat']) ? $value['lat'] : '';
            $lng = !empty($value['lng']) ? $value['lng'] : '';
            // references
            $adRef = array();
            $adRef['bathroom'] = !empty($value['bathroom']) ? explode($this->separatorElem, $value['bathroom']) : null;
            $adRef['safety'] = !empty($value['safety']) ? explode($this->separatorElem, $value['safety']) : null;
            $adRef['comfort'] = !empty($value['comfort']) ? explode($this->separatorElem, $value['comfort']) : null;
            $adRef['kitchen'] = !empty($value['kitchen']) ? explode($this->separatorElem, $value['kitchen']) : null;
            $adRef['employment'] = !empty($value['employment']) ? explode($this->separatorElem, $value['employment']) : null;
            $adRef['entertainment'] = !empty($value['entertainment']) ? explode($this->separatorElem, $value['entertainment']) : null;
            $adRef['services'] = !empty($value['services']) ? explode($this->separatorElem, $value['services']) : null;
            $adRef['terms'] = !empty($value['terms']) ? explode($this->separatorElem, $value['terms']) : null;
            $photos = !empty($value['photos']) ? explode($this->separatorElem, $value['photos']) : null;
            // insert into apartments table
            if (isFree()) {
                $sql = 'INSERT INTO {{apartment}} (type, obj_type_id, loc_country, loc_region, loc_city, city_id, date_updated, date_created, activity_always, is_price_poa, price, price_to, num_of_rooms, floor,
									floor_total, square, land_square, window_to, title_' . Yii::app()->language . ', description_' . Yii::app()->language . ',
									description_near_' . Yii::app()->language . ', exchange_to_' . Yii::app()->language . ',
									living_conditions, services, address_' . Yii::app()->language . ', berths, active, lat, lng,
									rating, is_special_offer, is_free_to, price_type, sorter, owner_active, owner_id)

								VALUES (:type, :objType, :locCountryId, :locRegionId, :locCityId, :cityId, NOW(), NOW(), :activityAlways, :isPricePoa, :price, :priceTo,:numberRooms, :floor,
									:floorTotal, :square, :landSquare, :windowTo, :title, :description,
									:descriptionNear, :exchangeTo,
									:livingConditions, :services, :address, :berths, :active, :lat, :lng,
									:rating, "", "", :priceType, :maxSorter, :ownerActive, :ownerId) ';
                $command = Yii::app()->db->createCommand($sql);
                $command->bindValue(":type", $type, PDO::PARAM_INT);
                $command->bindValue(":objType", $objType, PDO::PARAM_INT);
                $command->bindValue(":locCountryId", $countryId, PDO::PARAM_INT);
                $command->bindValue(":locRegionId", $regionId, PDO::PARAM_INT);
                $command->bindValue(":locCityId", $cityId, PDO::PARAM_INT);
                $command->bindValue(":cityId", $cityId, PDO::PARAM_INT);
                $command->bindValue(":activityAlways", 1, PDO::PARAM_INT);
                $command->bindValue(":isPricePoa", $isPricePoa, PDO::PARAM_INT);
                $command->bindValue(":price", $price, PDO::PARAM_STR);
                $command->bindValue(":priceTo", $priceTo, PDO::PARAM_STR);
                $command->bindValue(":numberRooms", $numberRooms, PDO::PARAM_INT);
                $command->bindValue(":floor", $floor, PDO::PARAM_INT);
                $command->bindValue(":floorTotal", $floor_total, PDO::PARAM_INT);
                $command->bindValue(":square", $square, PDO::PARAM_INT);
                $command->bindValue(":landSquare", $landSquare, PDO::PARAM_INT);
                $command->bindValue(":windowTo", 0, PDO::PARAM_INT);
                $command->bindValue(":title", $title, PDO::PARAM_STR);
                $command->bindValue(":description", $description, PDO::PARAM_STR);
                $command->bindValue(":descriptionNear", $near, PDO::PARAM_STR);
                $command->bindValue(":exchangeTo", $exchange, PDO::PARAM_STR);
                $command->bindValue(":livingConditions", 0, PDO::PARAM_INT);
                $command->bindValue(":services", 0, PDO::PARAM_INT);
                $command->bindValue(":address", $address, PDO::PARAM_STR);
                $command->bindValue(":berths", $sleeps, PDO::PARAM_STR);
                $command->bindValue(":active", 0, PDO::PARAM_INT);
                $command->bindValue(":lat", $lat, PDO::PARAM_STR);
                $command->bindValue(":lng", $lng, PDO::PARAM_STR);
                $command->bindValue(":rating", 0, PDO::PARAM_INT);
                $command->bindValue(":priceType", $priceType, PDO::PARAM_INT);
                $command->bindValue(":maxSorter", $maxSorter, PDO::PARAM_INT);
                $command->bindValue(":ownerActive", 1, PDO::PARAM_INT);
                $command->bindValue(":ownerId", $selectedImportUser, PDO::PARAM_INT);
                $command->execute();
                $lastId = Yii::app()->db->getLastInsertID();
            } else {
                $fieldsSQL = $placeholdersSQL = $valuesSQL = array();
                if ($this->allLangs) {
                    foreach ($this->allLangs as $lang) {
                        $fieldsSQL[] = 'title_' . $lang->name_iso;
                        $fieldsSQL[] = 'description_' . $lang->name_iso;
                        $fieldsSQL[] = 'description_near_' . $lang->name_iso;
                        $fieldsSQL[] = 'address_' . $lang->name_iso;
                        $fieldsSQL[] = 'exchange_to_' . $lang->name_iso;
                        $placeholdersSQL[] = ':title_' . $lang->name_iso;
                        $placeholdersSQL[] = ':description_' . $lang->name_iso;
                        $placeholdersSQL[] = ':description_near_' . $lang->name_iso;
                        $placeholdersSQL[] = ':address_' . $lang->name_iso;
                        $placeholdersSQL[] = ':exchange_to_' . $lang->name_iso;
                        $valuesSQL[':title_' . $lang->name_iso] = $this->deleteChars($title[$lang->name_iso]);
                        $valuesSQL[':description_' . $lang->name_iso] = $this->deleteChars($description[$lang->name_iso]);
                        $valuesSQL[':description_near_' . $lang->name_iso] = $this->deleteChars($near[$lang->name_iso]);
                        $valuesSQL[':address_' . $lang->name_iso] = $this->deleteChars($address[$lang->name_iso]);
                        $valuesSQL[':exchange_to_' . $lang->name_iso] = $this->deleteChars($exchange[$lang->name_iso]);
                    }
                }
                $sql = 'INSERT INTO {{apartment}} (
									type, obj_type_id, loc_country, loc_region, loc_city, city_id, date_updated, date_created, activity_always, is_price_poa, price, price_to, num_of_rooms, floor,
									floor_total, square, land_square, window_to,
									living_conditions, services, berths, active, lat, lng,
									rating, is_special_offer, is_free_to, price_type, sorter, owner_active, owner_id,
									' . implode(", ", $fieldsSQL) . '
									)
								VALUES (
									:type, :objType, :locCountryId, :locRegionId, :locCityId, :cityId, NOW(), NOW(), :activityAlways, :isPricePoa, :price, :priceTo,:numberRooms, :floor,
									:floorTotal, :square, :landSquare, :windowTo,
									:livingConditions, :services, :berths, :active, :lat, :lng,
									:rating, "", "", :priceType, :maxSorter, :ownerActive, :ownerId,
									' . implode(", ", $placeholdersSQL) . '
									) ';
                $command = Yii::app()->db->createCommand($sql);
                $command->bindValue(":type", $type, PDO::PARAM_INT);
                $command->bindValue(":objType", $objType, PDO::PARAM_INT);
                $command->bindValue(":locCountryId", $countryId, PDO::PARAM_INT);
                $command->bindValue(":locRegionId", $regionId, PDO::PARAM_INT);
                $command->bindValue(":locCityId", $cityId, PDO::PARAM_INT);
                $command->bindValue(":cityId", $cityId, PDO::PARAM_INT);
                $command->bindValue(":activityAlways", 1, PDO::PARAM_INT);
                $command->bindValue(":isPricePoa", $isPricePoa, PDO::PARAM_INT);
                $command->bindValue(":price", $price, PDO::PARAM_STR);
                $command->bindValue(":priceTo", $priceTo, PDO::PARAM_STR);
                $command->bindValue(":numberRooms", $numberRooms, PDO::PARAM_INT);
                $command->bindValue(":floor", $floor, PDO::PARAM_INT);
                $command->bindValue(":floorTotal", $floor_total, PDO::PARAM_INT);
                $command->bindValue(":square", $square, PDO::PARAM_INT);
                $command->bindValue(":landSquare", $landSquare, PDO::PARAM_INT);
                $command->bindValue(":windowTo", 0, PDO::PARAM_INT);
                $command->bindValue(":livingConditions", 0, PDO::PARAM_INT);
                $command->bindValue(":services", 0, PDO::PARAM_INT);
                $command->bindValue(":berths", $sleeps, PDO::PARAM_STR);
                $command->bindValue(":active", 0, PDO::PARAM_INT);
                $command->bindValue(":lat", $lat, PDO::PARAM_STR);
                $command->bindValue(":lng", $lng, PDO::PARAM_STR);
                $command->bindValue(":rating", 0, PDO::PARAM_INT);
                $command->bindValue(":priceType", $priceType, PDO::PARAM_INT);
                $command->bindValue(":maxSorter", $maxSorter, PDO::PARAM_INT);
                $command->bindValue(":ownerActive", 1, PDO::PARAM_INT);
                $command->bindValue(":ownerId", $selectedImportUser, PDO::PARAM_INT);
                foreach ($valuesSQL as $name => $value) {
                    $command->bindValue($name, $value, PDO::PARAM_STR);
                }
                $command->execute();
                $lastId = Yii::app()->db->getLastInsertID();
            }
            // insert references
            foreach ($adRef as $key => $value) {
                switch ($key) {
                    case 'comfort':
                        $refId = 1;
                        break;
                    case 'bathroom':
                        $refId = 2;
                        break;
                    case 'kitchen':
                        $refId = 3;
                        break;
                    case 'employment':
                        $refId = 4;
                        break;
                    case 'safety':
                        $refId = 5;
                        break;
                    case 'entertainment':
                        $refId = 7;
                        break;
                    case 'terms':
                        $refId = 9;
                        break;
                    case 'services':
                        $refId = 10;
                        break;
                }
                if (is_array($value) && count($value) > 0) {
                    foreach ($value as $item) {
                        // get reference id by name
                        if (isFree()) {
                            //$sql = "SELECT id FROM {{apartment_reference_values}} WHERE title_" . Yii::app()->language . " = '" . $item . "' AND reference_category_id = '" . $refId . "'";
                            //$valId = Yii::app()->db->createCommand($sql)->queryRow();
                            $valId = Yii::app()->db->createCommand()->select('id')->from('{{apartment_reference_values}}')->where('title_' . Yii::app()->language . ' = :title AND reference_category_id = :catId', array(':title' => $item, ':catId' => $refId))->queryRow();
                        } else {
                            Yii::app()->setLanguage($this->defLang);
                            //$sql = "SELECT id FROM {{apartment_reference_values}} WHERE title_" . Yii::app()->language . " = '" . $item . "' AND reference_category_id = '" . $refId . "'";
                            //$valId = Yii::app()->db->createCommand($sql)->queryRow();
                            $valId = Yii::app()->db->createCommand()->select('id')->from('{{apartment_reference_values}}')->where('title_' . Yii::app()->language . ' = :title AND reference_category_id = :catId', array(':title' => $item, ':catId' => $refId))->queryRow();
                            Yii::app()->setLanguage($this->currLang);
                        }
                        if (isset($valId['id']) && !empty($valId['id'])) {
                            $sql = 'INSERT INTO {{apartment_reference}} (reference_id, reference_value_id, apartment_id)
								VALUES (:refId, :refValId, :apId) ';
                            $command = Yii::app()->db->createCommand($sql);
                            $command->bindValue(":refId", $refId, PDO::PARAM_INT);
                            $command->bindValue(":refValId", $valId['id'], PDO::PARAM_INT);
                            $command->bindValue(":apId", $lastId, PDO::PARAM_INT);
                            $command->execute();
                        }
                    }
                }
            }
            // get and upload photos
            if (is_array($photos) && count($photos) > 0) {
                $arrFiles = $arrImgs = array();
                $IecsvFiles = array();
                foreach ($photos as $key => $item) {
                    if (!$isZip) {
                        if (stristr($item, "http")) {
                            $pathParts = pathinfo($item);
                            $file = $pathParts['basename'];
                            $fileExt = $pathParts['extension'];
                            $photoPath = $model->csvPath . DIRECTORY_SEPARATOR . $file;
                            // get file by cUrl
                            if (function_exists('curl_version')) {
                                $ch = curl_init();
                                $ch = curl_init();
                                curl_setopt($ch, CURLOPT_URL, $item);
                                $fp = fopen($photoPath, 'wb');
                                curl_setopt($ch, CURLOPT_FILE, $fp);
                                curl_setopt($ch, CURLOPT_HEADER, 0);
                                curl_exec($ch);
                                curl_close($ch);
                                fclose($fp);
                            } else {
                                // no CUrl, try differently
                                file_put_contents($photoPath, file_get_contents($item));
                            }
                            // reset file name - remove host. only filename and extension.
                            $item = $file;
                        }
                    } else {
                        // image from zip arhive
                        $photoPath = $model->csvPath . DIRECTORY_SEPARATOR . $item;
                    }
                    if (file_exists($photoPath)) {
                        $IecsvFiles[$key]['name'] = $item;
                        $IecsvFiles[$key]['tmp_name'] = $photoPath;
                    }
                }
                if (count($IecsvFiles) > 0) {
                    $apartment = Apartment::model()->findByPk($lastId);
                    $path = Yii::getPathOfAlias('webroot.uploads.objects.' . $apartment->id . '.' . Images::ORIGINAL_IMG_DIR);
                    $pathMod = Yii::getPathOfAlias('webroot.uploads.objects.' . $apartment->id . '.' . Images::MODIFIED_IMG_DIR);
                    $oldUMask = umask(0);
                    if (!is_dir($path)) {
                        @mkdir($path, 0777, true);
                    }
                    if (!is_dir($pathMod)) {
                        @mkdir($pathMod, 0777, true);
                    }
                    umask($oldUMask);
                    $result['error'] = '';
                    if (is_writable($path) && is_writable($pathMod)) {
                        touch($path . DIRECTORY_SEPARATOR . 'index.htm');
                        touch($pathMod . DIRECTORY_SEPARATOR . 'index.htm');
                        foreach ($IecsvFiles as $IecsvFile) {
                            if (copy($model->csvPath . DIRECTORY_SEPARATOR . $IecsvFile['name'], $path . DIRECTORY_SEPARATOR . $IecsvFile['name'])) {
                                $resize = new CImageHandler();
                                if ($resize->load($path . DIRECTORY_SEPARATOR . $IecsvFile['name'])) {
                                    $resize->thumb(param('maxImageWidth', 1024), param('maxImageHeight', 768), Images::KEEP_PHOTO_PROPORTIONAL)->save();
                                    $image = new Images();
                                    $image->id_object = $apartment->id;
                                    $image->id_owner = $apartment->owner_id;
                                    $image->file_name = $IecsvFile['name'];
                                    $image->save();
                                }
                            } else {
                                $result['error'] = 'No copy';
                            }
                        }
                    } else {
                        $result['error'] = 'Access denied.';
                    }
                }
            }
        }
    }
示例#4
0
echo $form->labelEx($model, 'type');
?>
    <?php 
echo $form->dropDownList($model, 'type', Apartment::getTypesArray(), array('class' => 'width240', 'id' => 'ap_type'));
?>
    <?php 
echo $form->error($model, 'type');
?>
</div>

<div class="rowold">
    <?php 
echo $form->labelEx($model, 'obj_type_id');
?>
    <?php 
echo $form->dropDownList($model, 'obj_type_id', Apartment::getObjTypesArray(), array('class' => 'width240', 'id' => 'obj_type'));
?>
    <?php 
echo $form->error($model, 'obj_type_id');
?>
</div>

<?php 
if (issetModule('location')) {
    ?>
    <?php 
    $countries = Country::getCountriesArray();
    ?>
    <div class="rowold">
        <?php 
    echo $form->labelEx($model, 'loc_country');
示例#5
0
 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>';
 }
示例#6
0
 public function actionCreate()
 {
     if (!Yii::app()->user->isGuest) {
         if (Yii::app()->user->checkAccess('backend_access')) {
             $this->redirect(Yii::app()->createUrl('/apartments/backend/main/create'));
         } else {
             $this->redirect(Yii::app()->createUrl('/userads/main/create'));
         }
     }
     if (param('user_registrationMode') == 'without_confirm') {
         $user = new User('register_without_confirm');
     } else {
         $user = new User('register');
     }
     $login = new LoginForm();
     $model = new Apartment();
     $model->active = Apartment::STATUS_DRAFT;
     $model->period_activity = param('apartment_periodActivityDefault', 'always');
     $model->references = $model->getFullInformation($model->id, $model->type);
     $isAdmin = false;
     $activeTab = 'tab_register';
     $isUpdate = Yii::app()->request->getPost('is_update');
     if (!$isUpdate && isset($_POST['LoginForm']) && ($_POST['LoginForm']['username'] || $_POST['LoginForm']['password'])) {
         if (Yii::app()->user->getState('attempts-login') >= LoginForm::ATTEMPTSLOGIN) {
             $login->scenario = 'withCaptcha';
         }
         $activeTab = 'tab_login';
         $login->attributes = $_POST['LoginForm'];
         if ($login->validate() && $login->login()) {
             Yii::app()->user->setState('attempts-login', 0);
             User::updateUserSession();
             $isAdmin = Yii::app()->user->checkAccess('backend_access');
             $user = User::model()->findByPk(Yii::app()->user->id);
         } else {
             Yii::app()->user->setState('attempts-login', Yii::app()->user->getState('attempts-login', 0) + 1);
             if (Yii::app()->user->getState('attempts-login') >= LoginForm::ATTEMPTSLOGIN) {
                 $login->scenario = 'withCaptcha';
             }
         }
     }
     if (isset($_POST['Apartment'])) {
         $model->attributes = $_POST['Apartment'];
         if (!$isUpdate) {
             $adValid = $model->validate();
             $userValid = false;
             if ($activeTab == 'tab_register' && param('useUserRegistration')) {
                 $user->attributes = $_POST['User'];
                 $userValid = $user->validate();
                 if ($adValid && $userValid) {
                     $user->activatekey = User::generateActivateKey();
                     $userData = User::createUser($user->attributes);
                     if ($userData) {
                         $user = $userData['userModel'];
                         $user->password = $userData['password'];
                         $user->activatekey = $userData['activatekey'];
                         $user->activateLink = $userData['activateLink'];
                         $notifier = new Notifier();
                         $notifier->raiseEvent('onNewUser', $user, array('forceEmail' => $user->email));
                     }
                 }
             }
             if ($user->id && ($activeTab == 'tab_login' && $adValid || $activeTab == 'tab_register' && param('useUserRegistration') && $adValid && $userValid)) {
                 if (param('useUseradsModeration', 1)) {
                     $model->active = Apartment::STATUS_MODERATION;
                 } else {
                     $model->active = Apartment::STATUS_ACTIVE;
                 }
                 $model->owner_active = Apartment::STATUS_ACTIVE;
                 $model->owner_id = $user->id;
                 if ($model->save(false)) {
                     if (!$isAdmin && param('useUseradsModeration', 1)) {
                         Yii::app()->user->setFlash('success', tc('The listing is succesfullty added and is awaiting moderation'));
                     } else {
                         Yii::app()->user->setFlash('success', tc('The listing is succesfullty added'));
                     }
                     if ($activeTab == 'tab_register') {
                         if (param('user_registrationMode') == 'without_confirm') {
                             $login = new LoginForm();
                             $login->setAttributes(array('username' => $user['username'], 'password' => $user['password']));
                             if ($login->validate() && $login->login()) {
                                 User::updateUserSession();
                                 User::updateLatestInfo(Yii::app()->user->id, Yii::app()->controller->currentUserIp);
                                 $this->redirect(array('/usercpanel/main/index'));
                             } else {
                                 /*echo 'getErrors=<pre>';
                                 		print_r($login->getErrors());
                                 		echo '</pre>';
                                 		exit;*/
                                 showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered.'));
                             }
                         } else {
                             showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered. The letter for account activation has been sent on {useremail}', array('{useremail}' => $user['email'])));
                         }
                     } else {
                         if ($isAdmin) {
                             NewsProduct::getProductNews();
                             $this->redirect(array('/apartments/backend/main/update', 'id' => $model->id));
                             Yii::app()->end();
                         } else {
                             $this->redirect(array('/userads/main/update', 'id' => $model->id));
                         }
                     }
                 }
             }
         }
     } else {
         $objTypes = array_keys(Apartment::getObjTypesArray());
         $model->setDefaultType();
         $model->obj_type_id = reset($objTypes);
         $user->unsetAttributes(array('verifyCode'));
     }
     $this->render('create', array('model' => $model, 'user' => $user, 'login' => $login, 'activeTab' => $activeTab));
 }
示例#7
0
 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;
 }
示例#8
0
<?php

Yii::app()->getModule('userads');
//if(!Yii::app()->request->isAjaxRequest){
//    echo '<h1>'.tt('Manage apartments', 'apartments').'</h1>';
//}
$this->pageTitle .= ' - ' . tt('Manage apartments', 'apartments');
if (!isset($this->breadcrumbs)) {
    $this->breadcrumbs = array(Yii::t('common', 'Control panel') => array('/usercpanel/main/index'), tt('Manage apartments', 'apartments'));
}
//echo CHtml::button(tc('Add ad', 'apartments'), array('onclick' => 'document.location.href="'.Yii::app()->createUrl('/userads/main/create').'"', 'class' => 'button-blue'));
Yii::app()->clientScript->registerScript('ajaxSetStatus', "\n\t\tfunction ajaxSetStatus(elem, id){\n\t\t\t\$.ajax({\n\t\t\t\turl: \$(elem).attr('href'),\n\t\t\t\tsuccess: function(){\n\t\t\t\t\t\$('#'+id).yiiGridView.update(id);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD);
$columns = array(array('name' => 'id', 'headerHtmlOptions' => array('class' => 'apartments_id_column')), array('name' => 'active', 'type' => 'raw', 'value' => 'UserAds::returnStatusHtml($data, "userads-grid", 0)', 'headerHtmlOptions' => array('class' => 'userads_status_column'), 'filter' => Apartment::getModerationStatusArray(), 'sortable' => false), array('name' => 'owner_active', 'type' => 'raw', 'value' => 'UserAds::returnStatusOwnerActiveHtml($data, "userads-grid", 1)', 'headerHtmlOptions' => array('class' => 'userads_owner_status_column'), 'filter' => array('0' => tc('Inactive'), '1' => tc('Active')), 'sortable' => false), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'filter' => Apartment::getTypesArray(), 'sortable' => false), array('name' => 'obj_type_id', 'type' => 'raw', 'value' => '(isset($data->objType) && $data->objType) ? $data->objType->name : ""', 'filter' => Apartment::getObjTypesArray(), 'sortable' => false), array('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->{"title_".Yii::app()->language}), $data->getUrl())'));
if (issetModule('location') && param('useLocation', 1)) {
    $columns[] = array('name' => 'loc_country', 'value' => '$data->loc_country ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1));
    $columns[] = array('name' => 'loc_region', 'value' => '$data->loc_region ? $data->locRegion->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Region::getRegionsArray($model->loc_country, 0, 1));
    $columns[] = array('name' => 'loc_city', 'value' => '$data->loc_city ? $data->locCity->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => City::getCitiesArray($model->loc_region, 0, 1));
} else {
    $columns[] = array('name' => 'city_id', 'value' => '$data->city_id ? $data->city->name : ""', 'sortable' => false, 'filter' => ApartmentCity::getAllCity());
}
if (issetModule('paidservices')) {
    $columns[] = array('header' => tc('Paid services'), 'value' => '$data->getPaidHtml(false, false, true)', 'type' => 'raw', 'htmlOptions' => array('class' => 'width70 center'));
}
$columns[] = array('class' => 'CButtonColumn', 'deleteConfirmation' => tc('Are you sure you want to delete this item?'), 'viewButtonUrl' => '$data->getUrl()', 'buttons' => array('update' => array('url' => 'Yii::app()->createUrl("/userads/main/update", array("id" => $data->id))'), 'delete' => array('url' => 'Yii::app()->createUrl("/userads/main/delete", array("id" => $data->id))')));
$this->widget('NoBootstrapGridView', array('id' => 'userads-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => $columns));
示例#9
0
    $cs = Yii::app()->clientScript;
    $cs->registerCoreScript('jquery.ui');
    $cs->registerScriptFile($cs->getCoreScriptUrl() . '/jui/js/jquery-ui-i18n.min.js');
    $cs->registerCssFile($cs->getCoreScriptUrl() . '/jui/css/base/jquery-ui.css');
}
$this->breadcrumbs = array(tt('Manage apartments'));
$this->menu = array(array('label' => tt('Add apartment'), 'url' => array('create')));
$this->adminTitle = tt('Manage apartments');
if (Yii::app()->user->hasFlash('mesIecsv')) {
    echo "<div class='flash-success'>" . Yii::app()->user->getFlash('mesIecsv') . "</div>";
}
if (param('useUserads', 1)) {
    Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/js/jquery.jeditable.js', CClientScript::POS_END);
    Yii::app()->clientScript->registerScript('editable_select', "\n\t\tfunction ajaxSetModerationStatus(elem, id, id_elem, owner_id, items){\n\t\t\t\$('#editable_select-'+id_elem).editable('" . Yii::app()->controller->createUrl("activate") . "', {\n\t\t\t\tdata   : items,\n\t\t\t\ttype   : 'select',\n\t\t\t\tcancel : '" . tc('Cancel') . "',\n\t\t\t\tsubmit : '" . tc('Ok') . "',\n\t\t\t\tstyle  : 'inherit',\n\t\t\t\tsubmitdata : function() {\n\t\t\t\t\treturn {id : id_elem};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD);
}
$columns = array(array('class' => 'CCheckBoxColumn', 'id' => 'itemsSelected', 'selectableRows' => '2', 'htmlOptions' => array('class' => 'center')), array('name' => 'id', 'htmlOptions' => array('class' => 'apartments_id_column'), 'sortable' => false), array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnControllerStatusHtml($data, "apartments-grid", 1)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getModerationStatusArray()), array('name' => 'owner_active', 'type' => 'raw', 'value' => 'Apartment::getApartmentsStatus($data->owner_active)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getApartmentsStatusArray()), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'filter' => Apartment::getTypesArray(), 'sortable' => false), array('name' => 'obj_type_id', 'type' => 'raw', 'value' => '(isset($data->objType) && $data->objType) ? $data->objType->name : ""', 'filter' => Apartment::getObjTypesArray(), 'sortable' => false));
if (issetModule('location') && param('useLocation', 1)) {
    $columns[] = array('name' => 'loc_country', 'value' => '$data->loc_country ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1));
    $columns[] = array('name' => 'loc_region', 'value' => '$data->loc_region ? $data->locRegion->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Region::getRegionsArray($model->loc_country, 0, 1));
    $columns[] = array('name' => 'loc_city', 'value' => '$data->loc_city ? $data->locCity->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => City::getCitiesArray($model->loc_region, 0, 1));
} else {
    $columns[] = array('name' => 'city_id', 'value' => '$data->location_id ? $data->location->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Location::getLocationArrayWithoutChooseOption());
}
$columns[] = array('name' => 'ownerEmail', 'htmlOptions' => array('style' => 'width: 150px;'), 'type' => 'raw', 'value' => '(isset($data->user) && $data->user->id != 1) ? CHtml::link(CHtml::encode($data->user->email), array("/users/backend/main/view","id" => $data->user->id)) : tt("administrator", "common")');
$columns[] = array('name' => 'ownerUsername', 'htmlOptions' => array('style' => 'width: 150px;'), 'value' => 'isset($data->user->username) ? $data->user->username : ""');
$columns[] = array('header' => tc('Name'), 'name' => 'title_' . Yii::app()->language, 'type' => 'raw', 'value' => 'CHtml::link(CHtml::encode($data->{"title_".Yii::app()->language}),array("/apartments/backend/main/view","id" => $data->id))', 'sortable' => false);
if (issetModule('paidservices')) {
    $columns[] = array('header' => tc('Paid services'), 'value' => '$data->getPaidHtml(true, true)', 'type' => 'raw', 'htmlOptions' => array('style' => 'width: 200px;'));
}
$columns[] = array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{up}{down}{view}{update}{delete}', 'deleteConfirmation' => tc('Are you sure you want to delete this item?'), 'viewButtonUrl' => "Yii::app()->createUrl('/apartments/backend/main/view', array('id' => \$data->id))", 'htmlOptions' => array('class' => 'width120'), 'buttons' => array('up' => array('label' => tc('Move an item up'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/up.gif'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/move", array("id"=>$data->id, "direction" => "down", "catid" => "0"))', 'options' => array('class' => 'infopages_arrow_image_up'), 'visible' => '$data->sorter < "' . $maxSorter . '"', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}"), 'down' => array('label' => tc('Move an item down'), 'imageUrl' => $url = Yii::app()->assetManager->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/down.gif'), 'url' => 'Yii::app()->createUrl("/apartments/backend/main/move", array("id"=>$data->id, "direction" => "up", "catid" => "0"))', 'options' => array('class' => 'infopages_arrow_image_down'), 'visible' => '$data->sorter > 1', 'click' => "js: function() { ajaxMoveRequest(\$(this).attr('href'), 'apartments-grid'); return false;}")));
$this->widget('CustomGridView', array('id' => 'apartments-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove();}', 'columns' => $columns));
示例#10
0
 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>';
 }
示例#11
0
$cs = Yii::app()->clientScript;
$cs->registerCoreScript('jquery.ui');
$cs->registerScriptFile($cs->getCoreScriptUrl() . '/jui/js/jquery-ui-i18n.min.js');
$cs->registerCssFile($cs->getCoreScriptUrl() . '/jui/css/base/jquery-ui.css');
$this->breadcrumbs = array(tt('Manage apartments'));
$this->menu = array(array('label' => tt('Add apartment'), 'url' => array('create')));
$this->adminTitle = tt('Manage apartments');
if (Yii::app()->user->hasFlash('mesIecsv')) {
    echo "<div class='flash-success'>" . Yii::app()->user->getFlash('mesIecsv') . "</div>";
}
if (param('useUserads', 1)) {
    Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery.jeditable.js', CClientScript::POS_END);
    Yii::app()->clientScript->registerScript('editable_select', "\n\t\tfunction ajaxSetModerationStatus(elem, id, id_elem, owner_id, items){\n\t\t\t\$('#editable_select-'+id_elem).editable('" . Yii::app()->controller->createUrl("activate") . "', {\n\t\t\t\tdata   : items,\n\t\t\t\ttype   : 'select',\n\t\t\t\tcancel : '" . tc('Cancel') . "',\n\t\t\t\tsubmit : '" . tc('Ok') . "',\n\t\t\t\tstyle  : 'inherit',\n\t\t\t\tsubmitdata : function() {\n\t\t\t\t\treturn {id : id_elem};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD);
}
$columns = array(array('class' => 'CCheckBoxColumn', 'id' => 'itemsSelected', 'selectableRows' => '2', 'htmlOptions' => array('class' => 'center')), array('name' => 'id', 'htmlOptions' => array('class' => 'apartments_id_column'), 'sortable' => false), array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnControllerStatusHtml($data, "apartments-grid", 1).
				(($data->deleted && !param("notDeleteListings", 0))  ? tt("Listing is deleted", "apartments") : "")', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getModerationStatusArray()), array('name' => 'owner_active', 'type' => 'raw', 'value' => 'Apartment::getApartmentsStatus($data->owner_active)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getApartmentsStatusArray()), array('name' => 'deleted', 'type' => 'raw', 'value' => 'Apartment::getApartmentsDeleted($data->deleted)', 'htmlOptions' => array('class' => 'apartments_status_column'), 'sortable' => false, 'filter' => Apartment::getApartmentsDeletedArray(), 'visible' => param("notDeleteListings", 0)), array('name' => 'type', 'type' => 'raw', 'value' => 'Apartment::getNameByType($data->type)', 'filter' => Apartment::getTypesArray(), 'sortable' => false), array('name' => 'price', 'type' => 'raw', 'value' => '$data->getPrettyPrice(false)', 'htmlOptions' => array('style' => 'width: 100px;'), 'filter' => false, 'sortable' => false), array('name' => 'obj_type_id', 'type' => 'raw', 'value' => '(isset($data->objType) && $data->objType) ? $data->objType->name : ""', 'filter' => Apartment::getObjTypesArray(), 'sortable' => false));
if (issetModule('location')) {
    $columns[] = array('name' => 'loc_country', 'value' => '($data->loc_country && isset($data->locCountry)) ? $data->locCountry->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Country::getCountriesArray(0, 1));
    $columns[] = array('name' => 'loc_region', 'value' => '($data->loc_region && isset($data->locRegion)) ? $data->locRegion->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Region::getRegionsArray($model->loc_country, 0, 1));
    $columns[] = array('name' => 'loc_city', 'value' => '($data->loc_city && isset($data->locCity)) ? $data->locCity->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => City::getCitiesArray($model->loc_region, 0, 1));
} else {
    $columns[] = array('name' => 'city_id', 'value' => '($data->city_id && isset($data->city)) ? $data->city->name : ""', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => ApartmentCity::getAllCity());
}
$columns[] = array('name' => 'ownerEmail', 'htmlOptions' => array('style' => 'width: 150px;'), 'type' => 'raw', 'value' => '(isset($data->user) && $data->user->role != "admin") ? CHtml::link(CHtml::encode($data->user->email), array("/users/backend/main/view","id" => $data->user->id)) : tt("administrator", "common")');
//$columns[]=array(
//    'name' => 'ownerUsername',
//    'htmlOptions' => array(
//        'style' => 'width: 150px;',
//    ),
//    'value' => 'isset($data->user->username) ? $data->user->username : ""'
//);