Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function setCacheListByCategoryID($lang)
- {
- if (!$lang) {
- $lang = Yii::app()->language;
- }
- self::$_listByCategoryID[$lang] = array();
- $tmp = 'title_' . $lang;
- $sql = "SELECT id, reference_category_id, $tmp AS name, for_rent, for_sale, rent, buy, exchange, catb, cath FROM {{apartment_reference_values}} ORDER BY sorter";
- $items = Yii::app()->db->createCommand($sql)->queryAll(true);
- if ($items) {
- foreach ($items as $item) {
- self::$_listByCategoryID[$lang][$item['reference_category_id']][] = array(
- 'id' => $item['id'],
- 'name' => $item['name'],
- 'for_rent' => $item['for_rent'],
- 'for_sale' => $item['for_sale'],
- 'rent' => $item['rent'],
- 'buy' => $item['buy'],
- 'exchange' => $item['exchange'],
- 'catb' => $item['catb'],
- 'cath' => $item['cath'],
- );
- }
- }
- return self::$_listByCategoryID[$lang];
- }
- public static function getListByCategoryID($categoryID, $adType = 0)
- {
- $lang = Yii::app()->language;
- if (!isset(self::$_listByCategoryID) || !isset(self::$_listByCategoryID[Yii::app()->language])) {
- self::setCacheListByCategoryID($lang);
- }
- $forRent = $forSale = $rent = $buy = $exchange = $catb = $cath = 0;
- switch ($adType) {
- case Apartment::TYPE_RENT:
- $forRent = 1;
- break;
- case Apartment::TYPE_SALE:
- $forSale = 1;
- break;
- case Apartment::TYPE_RENTING:
- $rent = 1;
- break;
- case Apartment::TYPE_BUY:
- $buy = 1;
- break;
- case Apartment::TYPE_CHANGE:
- $exchange = 1;
- break;
- case Apartment::TYPE_CATALOG_BUILDING:
- $catb = 1;
- break;
- case Apartment::TYPE_CATALOG_HOTEL:
- $cath = 1;
- break;
- default:
- $forRent = $forSale = $rent = $buy = $exchange = $catb = $cath = 1;
- }
- $items = (isset(self::$_listByCategoryID[$lang][$categoryID])) ? self::$_listByCategoryID[$lang][$categoryID] : array();
- if ($items) {
- foreach($items as $key => $item) {
- if (
- ($item['for_rent'] != $forRent)
- || ($item['for_sale'] != $forSale)
- || ($item['rent'] != $rent)
- || ($item['buy'] != $buy)
- || ($item['exchange'] != $exchange)
- || ($item['catb'] != $catb)
- || ($item['cath'] != $cath)
- )
- {
- unset($items[$key]);
- }
- }
- $items = CHtml::listData($items, 'id', 'name');
- }
- return $items;
- }
- public static function isShowForAnything($field)
- {
- $sql = "SELECT f.id FROM {{formdesigner}} f INNER JOIN {{formdesigner_obj_type}} fo ON fo.formdesigner_id = f.id WHERE field=:field";
- return Yii::app()->db->createCommand($sql)->queryScalar(array(':field' => $field));
- }
- public static function getFieldsWithoutTip()
- {
- return array(
- 'location',
- 'obj_type_id',
- 'type',
- 'price',
- 'title',
- 'parent_id',
- 'references',
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement