Advertisement
Sdelkadrom

Untitled

Jan 25th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. public static function setCacheListByCategoryID($lang)
  2. {
  3. if (!$lang) {
  4. $lang = Yii::app()->language;
  5. }
  6.  
  7. self::$_listByCategoryID[$lang] = array();
  8.  
  9. $tmp = 'title_' . $lang;
  10. $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";
  11. $items = Yii::app()->db->createCommand($sql)->queryAll(true);
  12.  
  13. if ($items) {
  14. foreach ($items as $item) {
  15. self::$_listByCategoryID[$lang][$item['reference_category_id']][] = array(
  16. 'id' => $item['id'],
  17. 'name' => $item['name'],
  18. 'for_rent' => $item['for_rent'],
  19. 'for_sale' => $item['for_sale'],
  20. 'rent' => $item['rent'],
  21. 'buy' => $item['buy'],
  22. 'exchange' => $item['exchange'],
  23. 'catb' => $item['catb'],
  24. 'cath' => $item['cath'],
  25.  
  26. );
  27. }
  28. }
  29.  
  30. return self::$_listByCategoryID[$lang];
  31. }
  32.  
  33. public static function getListByCategoryID($categoryID, $adType = 0)
  34. {
  35. $lang = Yii::app()->language;
  36. if (!isset(self::$_listByCategoryID) || !isset(self::$_listByCategoryID[Yii::app()->language])) {
  37. self::setCacheListByCategoryID($lang);
  38. }
  39.  
  40. $forRent = $forSale = $rent = $buy = $exchange = $catb = $cath = 0;
  41.  
  42. switch ($adType) {
  43. case Apartment::TYPE_RENT:
  44. $forRent = 1;
  45. break;
  46. case Apartment::TYPE_SALE:
  47. $forSale = 1;
  48. break;
  49. case Apartment::TYPE_RENTING:
  50. $rent = 1;
  51. break;
  52. case Apartment::TYPE_BUY:
  53. $buy = 1;
  54. break;
  55. case Apartment::TYPE_CHANGE:
  56. $exchange = 1;
  57. break;
  58. case Apartment::TYPE_CATALOG_BUILDING:
  59. $catb = 1;
  60. break;
  61. case Apartment::TYPE_CATALOG_HOTEL:
  62. $cath = 1;
  63. break;
  64. default:
  65. $forRent = $forSale = $rent = $buy = $exchange = $catb = $cath = 1;
  66. }
  67.  
  68.  
  69. $items = (isset(self::$_listByCategoryID[$lang][$categoryID])) ? self::$_listByCategoryID[$lang][$categoryID] : array();
  70. if ($items) {
  71. foreach($items as $key => $item) {
  72. if (
  73. ($item['for_rent'] != $forRent)
  74. || ($item['for_sale'] != $forSale)
  75. || ($item['rent'] != $rent)
  76. || ($item['buy'] != $buy)
  77. || ($item['exchange'] != $exchange)
  78. || ($item['catb'] != $catb)
  79. || ($item['cath'] != $cath)
  80. )
  81. {
  82. unset($items[$key]);
  83. }
  84. }
  85.  
  86. $items = CHtml::listData($items, 'id', 'name');
  87. }
  88.  
  89. return $items;
  90. }
  91.  
  92. public static function isShowForAnything($field)
  93. {
  94. $sql = "SELECT f.id FROM {{formdesigner}} f INNER JOIN {{formdesigner_obj_type}} fo ON fo.formdesigner_id = f.id WHERE field=:field";
  95. return Yii::app()->db->createCommand($sql)->queryScalar(array(':field' => $field));
  96. }
  97.  
  98. public static function getFieldsWithoutTip()
  99. {
  100. return array(
  101. 'location',
  102. 'obj_type_id',
  103. 'type',
  104. 'price',
  105. 'title',
  106. 'parent_id',
  107. 'references',
  108. );
  109. }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement