HJI WP Membership Code Reference
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Slipstream API Docs

Namespaces

  • hji
    • AgentRoster
      • controllers
      • models
      • utils
    • common
      • factories
      • interfaces
      • models
      • utils
    • construction
      • admin
        • controllers
        • models
      • core
      • front
        • controllers
      • interfaces
      • models
        • listings
        • subdivisions
      • views
    • geofarms
      • common
      • controllers
      • models
      • widgets
    • homevalue
      • controllers
      • core
        • abstracts
      • models
    • lifestylefinder
    • listingstoblog
      • controllers
    • membership
      • abstracts
      • controllers
      • entities
      • extension
        • abstracts
        • interfaces
      • factories
      • includes
      • interfaces
      • models
        • data
        • webservice
          • abstracts
          • actions
          • interfaces
      • observers
      • services
    • recentsales
      • controllers
      • tinymce
      • widgets
    • ResponsiveIDX
      • abstracts
      • adapters
      • controllers
      • core
        • abstracts
      • entities
      • models
      • services
      • tinymce
      • utils
      • widgets
    • schools
      • controllers
      • tinymce
      • widgets
    • users
      • abstracts
      • admin
        • controllers
        • models
      • controllers
      • core
        • abstracts
      • entities
      • models
      • utils
  • None
  • REL
    • controllers
    • Models
    • Taxonomies
    • Utils
      • Convert
    • widgets

Classes

  • hji\AgentRoster\AgentRoster
  • hji\AgentRoster\controllers\AgentRosterAdmin
  • hji\AgentRoster\controllers\Testimonials
  • hji\AgentRoster\models\TestimonialsModel
  • hji\AgentRoster\utils\ContactForm
  • hji\common\factories\mcePluginFactory
  • hji\common\factories\WidgetTrioFactory
  • hji\common\interfaces\AbstractSettingsModel
  • hji\common\interfaces\Shortcode
  • hji\common\interfaces\Widget
  • hji\common\interfaces\WidgetShortcode
  • hji\common\models\Alerts
  • hji\common\models\GForms
  • hji\common\models\JsVars
  • hji\common\models\mcePluginModel
  • hji\common\models\Notices
  • hji\common\models\PluginJsVars
  • hji\common\utils\APIClient
  • hji\common\utils\Cookies
  • hji\common\utils\GFHelper
  • hji\common\utils\HTTP
  • hji\common\utils\ipAddress
  • hji\common\utils\MetaBoxes
  • hji\common\utils\Modal
  • hji\common\utils\Paths
  • hji\common\utils\SiteInfo
  • hji\common\utils\String
  • hji\common\utils\Updater
  • hji\common\utils\Validator
  • hji\common\utils\View
  • hji\common\utils\Views
  • hji\common\utils\WPCache
  • hji\common\utils\WPHelper
  • hji\construction\admin\AdminController
  • hji\construction\admin\controllers\GeneralPageController
  • hji\construction\admin\models\GeneralPageModel
  • hji\construction\App
  • hji\construction\core\Component
  • hji\construction\core\Controller
  • hji\construction\core\DataModel
  • hji\construction\core\DataObjectPostView
  • hji\construction\core\Model
  • hji\construction\core\Paths
  • hji\construction\core\PostModel
  • hji\construction\core\WebService
  • hji\construction\core\Widget
  • hji\construction\front\controllers\ListingsController
  • hji\construction\front\controllers\SubdivisionsController
  • hji\construction\front\FrontController
  • hji\construction\models\Images
  • hji\construction\models\Labels
  • hji\construction\models\listings\ListingModel
  • hji\construction\models\listings\ListingsGetFilters
  • hji\construction\models\listings\ListingsModel
  • hji\construction\models\listings\ListingsSearchFilters
  • hji\construction\models\NCSearchWidget
  • hji\construction\models\NCSearchWidgetViewModel
  • hji\construction\models\Pagination
  • hji\construction\models\Settings
  • hji\construction\models\subdivisions\SubdivisionModel
  • hji\construction\models\subdivisions\SubdivisionsGetFilters
  • hji\construction\models\subdivisions\SubdivisionsGetOptions
  • hji\construction\models\subdivisions\SubdivisionsModel
  • hji\construction\models\subdivisions\SubdivisionsSearchFilters
  • hji\construction\models\subdivisions\SubdivisionsSearchOptions
  • hji\construction\NewConstruction
  • hji\construction\ServiceContainer
  • hji\construction\views\ListingsView
  • hji\construction\views\SubdivisionsView
  • hji\geofarms\common\ImageResize
  • hji\geofarms\common\RewriteRules
  • hji\geofarms\controllers\AreaCache
  • hji\geofarms\controllers\CMB
  • hji\geofarms\controllers\CPT
  • hji\geofarms\controllers\FrontEnd
  • hji\geofarms\controllers\Settings
  • hji\geofarms\controllers\Shortcodes
  • hji\geofarms\controllers\Slipstream
  • hji\geofarms\controllers\Taxonomy
  • hji\geofarms\controllers\TinyMCE
  • hji\geofarms\controllers\UpdateNeighborhoods
  • hji\geofarms\GeoFarms
  • hji\geofarms\models\CMB
  • hji\geofarms\models\CPT
  • hji\geofarms\models\Settings
  • hji\geofarms\models\Slipstream
  • hji\geofarms\models\Taxonomy
  • hji\geofarms\models\TinyMCE
  • hji\geofarms\widgets\Display
  • hji\geofarms\widgets\Map
  • hji\homevalue\controllers\HomeValueTinyMCE
  • hji\homevalue\controllers\HomeValueWidget
  • hji\homevalue\controllers\Settings
  • hji\homevalue\controllers\Shortcodes
  • hji\homevalue\core\abstracts\Component
  • hji\homevalue\core\Controller
  • hji\homevalue\core\Model
  • hji\homevalue\HomeValue
  • hji\homevalue\models\Settings
  • hji\lifestylefinder\LifestyleFinder
  • hji\listingstoblog\controllers\ImportListings
  • hji\listingstoblog\controllers\Settings
  • hji\listingstoblog\ListingsToBlog
  • hji\membership\abstracts\Component
  • hji\membership\abstracts\Controller
  • hji\membership\abstracts\Model
  • hji\membership\controllers\APIClient
  • hji\membership\controllers\CommonScripts
  • hji\membership\controllers\Dependency
  • hji\membership\controllers\DependencyResolver
  • hji\membership\controllers\Dispatcher
  • hji\membership\controllers\Downloads
  • hji\membership\controllers\GForms
  • hji\membership\controllers\ProductManager
  • hji\membership\controllers\ProductRegistrar
  • hji\membership\controllers\RegistryEntry
  • hji\membership\controllers\RequireJs
  • hji\membership\controllers\Settings
  • hji\membership\controllers\UpdateManager
  • hji\membership\entities\Event
  • hji\membership\entities\UserActionEvent
  • hji\membership\extension\abstracts\Component
  • hji\membership\factories\ProductFactory
  • hji\membership\includes\CustomerInfoSynchronizer
  • hji\membership\interfaces\Product
  • hji\membership\Membership
  • hji\membership\models\APIClientModel
  • hji\membership\models\Customer
  • hji\membership\models\data\Address
  • hji\membership\models\data\Image
  • hji\membership\models\data\Images
  • hji\membership\models\data\Paging
  • hji\membership\models\data\Sorting
  • hji\membership\models\DependencyEntity
  • hji\membership\models\DependencyModel
  • hji\membership\models\PluginEntity
  • hji\membership\models\ProductDependencies
  • hji\membership\models\Settings
  • hji\membership\models\ThemeEntity
  • hji\membership\models\UserActionLogger
  • hji\membership\models\UserSession
  • hji\membership\models\webservice\abstracts\QueryProperties
  • hji\membership\models\webservice\abstracts\WebService
  • hji\membership\models\webservice\abstracts\WebServiceFilters
  • hji\membership\models\webservice\actions\ActionsSearchFilters
  • hji\membership\models\webservice\actions\ActionsWebService
  • hji\membership\models\webservice\WebServiceOptions
  • hji\membership\models\WpCatalog
  • hji\membership\observers\EventDispatcher
  • hji\membership\observers\EventLogger
  • hji\membership\services\CPT_Router
  • hji\membership\services\DependencyInjector
  • hji\membership\services\DependencyInjectorInterface
  • hji\membership\services\Request
  • hji\membership\services\Route
  • hji\membership\services\Router
  • hji\membership\services\ServiceContainer
  • hji\membership\services\SocialGraph
  • hji\recentsales\controllers\Shortcodes
  • hji\recentsales\RecentSales
  • hji\recentsales\tinymce\RecentSales
  • hji\recentsales\widgets\RecentSales
  • hji\ResponsiveIDX\abstracts\FilterSchema
  • hji\ResponsiveIDX\adapters\IdxAdapter
  • hji\ResponsiveIDX\adapters\LegalAdapter
  • hji\ResponsiveIDX\adapters\ListingAdapter
  • hji\ResponsiveIDX\controllers\BaseController
  • hji\ResponsiveIDX\controllers\IdxApp
  • hji\ResponsiveIDX\controllers\Pagination
  • hji\ResponsiveIDX\controllers\RecentlyViewed
  • hji\ResponsiveIDX\controllers\RegistrationForm
  • hji\ResponsiveIDX\controllers\Settings
  • hji\ResponsiveIDX\controllers\Upgrader
  • hji\ResponsiveIDX\core\abstracts\Component
  • hji\ResponsiveIDX\core\Controller
  • hji\ResponsiveIDX\core\Model
  • hji\ResponsiveIDX\entities\ComplianceRule
  • hji\ResponsiveIDX\entities\ListingEntity
  • hji\ResponsiveIDX\models\ComplianceModel
  • hji\ResponsiveIDX\models\ComplianceViewModel
  • hji\ResponsiveIDX\models\FieldLabels
  • hji\ResponsiveIDX\models\HashMap
  • hji\ResponsiveIDX\models\IdxSearchModel
  • hji\ResponsiveIDX\models\MarketMetadata
  • hji\ResponsiveIDX\models\PaginationViewModel
  • hji\ResponsiveIDX\models\QuickSearchViewModel
  • hji\ResponsiveIDX\models\SearchFilters
  • hji\ResponsiveIDX\models\SearchParams
  • hji\ResponsiveIDX\models\SearchResultsViewModel
  • hji\ResponsiveIDX\models\ShortcodesModel
  • hji\ResponsiveIDX\models\SpatialMatchModel
  • hji\ResponsiveIDX\ResponsiveIDX
  • hji\ResponsiveIDX\services\ServiceContainer
  • hji\ResponsiveIDX\tinymce\FeaturedListings
  • hji\ResponsiveIDX\utils\ArrayFormat
  • hji\ResponsiveIDX\utils\PluginDependency
  • hji\ResponsiveIDX\utils\StringFormat
  • hji\ResponsiveIDX\utils\View
  • hji\ResponsiveIDX\widgets\FeaturedListings_TinyMCE
  • hji\ResponsiveIDX\widgets\FeaturedListings_Widget
  • hji\ResponsiveIDX\widgets\QuickSearch_Widget
  • hji\schools\controllers\Shortcodes
  • hji\schools\Schools
  • hji\schools\tinymce\Schools
  • hji\schools\widgets\Schools
  • hji\users\abstracts\AdminPageModel
  • hji\users\abstracts\UserAdminTable
  • hji\users\admin\AdminController
  • hji\users\admin\BaseController
  • hji\users\admin\controllers\ActionsPageController
  • hji\users\admin\controllers\UsersPageController
  • hji\users\admin\models\ActionsPageModel
  • hji\users\admin\models\UsersPageModel
  • hji\users\controllers\GravityForms
  • hji\users\controllers\GravityFormsAdmin
  • hji\users\controllers\RegistrationPrompter
  • hji\users\controllers\Settings
  • hji\users\controllers\SocialAuth
  • hji\users\controllers\User
  • hji\users\controllers\UserPanel
  • hji\users\core\abstracts\Component
  • hji\users\core\Controller
  • hji\users\core\Model
  • hji\users\entities\GFEntry
  • hji\users\entities\User
  • hji\users\entities\UserProfile
  • hji\users\models\ActionsSearchFilters
  • hji\users\models\ActionsWebServiceOptions
  • hji\users\models\FavoritesViewModel
  • hji\users\models\FrontEndNotices
  • hji\users\models\RegistrationNotificationViewModel
  • hji\users\models\Request
  • hji\users\models\Settings
  • hji\users\models\SettingsTab
  • hji\users\models\User
  • hji\users\models\UserActionsModel
  • hji\users\models\UserFactory
  • hji\users\models\UsersSearchModel
  • hji\users\Users
  • hji\users\utils\GravityFormsHelper
  • hji\users\utils\UserActionsTable
  • hji\users\utils\UserAuth
  • hji\users\utils\UserFavoritesTable
  • hji\users\utils\UserFormEntriesTable
  • hji\users\utils\UserListTable
  • hji\users\utils\UserSearchesTable
  • hji\users\utils\UserSessionsTable
  • REL\controllers\Admin
  • REL\controllers\FSBO
  • REL\controllers\PocketListings
  • REL\controllers\rIDXImport
  • REL\Models\ListingViewModel
  • REL\Models\rIDXImport
  • REL\Models\Upgrades
  • REL\RealEstateListings
  • REL\Taxonomies\CustomTaxonomies
  • REL\Utils\Convert\ListingConverter
  • REL\widgets\PocketListingsSearchWidget
  • REL\widgets\PocketListingsWidget
  • SM_API_Client

Interfaces

  • hji\construction\interfaces\IPost
  • hji\membership\extension\interfaces\ExtensionInterface
  • hji\membership\interfaces\CRUD
  • hji\membership\interfaces\Dispatchable
  • hji\membership\interfaces\EventDispatcherInterface
  • hji\membership\interfaces\Loggable
  • hji\membership\models\webservice\interfaces\IGettable
  • hji\membership\models\webservice\interfaces\ISearchable

Functions

  • __admin_redirect
  • get_pocket_listing
  • hji\membership\controllers\__inject_plugin_table
  • hji\membership\controllers\__inject_theme_table
  • hji_user_favorite_toggle
  • hjigf_display
  • hjigf_display_map
  • hjigf_get_community_feature
  • hjigf_get_post_thumbnail
  • hjigf_has_area_map
  • ridx_get_listing
  • ridx_is_results_page
  • ridx_is_single
  • ridx_is_single_print
  • table_hjpl_cache
   1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  101  102  103  104  105  106  107  108  109  110  111  112  113  114  115  116  117  118  119  120  121  122  123  124  125  126  127  128  129  130  131  132  133  134  135  136  137  138  139  140  141  142  143  144  145  146  147  148  149  150  151  152  153  154  155  156  157  158  159  160  161  162  163  164  165  166  167  168  169  170  171  172  173  174  175  176  177  178  179  180  181  182  183  184  185  186  187  188  189  190  191  192  193  194  195  196  197  198  199  200  201  202  203  204  205  206  207  208  209  210  211  212  213  214  215  216  217  218  219  220  221  222  223  224  225  226  227  228  229  230  231  232  233  234  235  236  237  238  239  240  241  242  243  244  245  246  247  248  249  250  251  252  253  254  255  256  257  258  259  260  261  262  263  264  265  266  267  268  269  270  271  272  273  274  275  276  277  278  279  280  281  282  283  284  285  286  287  288  289  290  291  292  293  294  295  296  297  298  299  300  301  302  303  304  305  306  307  308  309  310  311  312  313  314  315  316  317  318  319  320  321  322  323  324  325  326  327  328  329  330  331  332  333  334  335  336  337  338  339  340  341  342  343  344  345  346  347  348  349  350  351  352  353  354  355  356  357  358  359  360  361  362  363  364  365  366  367  368  369  370  371  372  373  374  375  376  377  378  379  380  381  382  383  384  385  386  387  388  389  390  391  392  393  394  395  396  397  398  399  400  401  402  403  404  405  406  407  408  409  410  411  412  413  414  415  416  417  418  419  420  421  422  423  424  425  426  427  428  429  430  431  432  433  434  435  436  437  438  439  440  441  442  443  444  445  446  447  448  449  450  451  452  453  454  455  456  457  458  459  460  461  462  463  464  465  466  467  468  469  470  471  472  473  474  475  476  477  478  479  480  481  482  483  484  485  486  487  488  489  490  491  492  493  494  495  496  497  498  499  500  501  502  503  504  505  506  507  508  509  510  511  512  513  514  515  516  517  518  519  520  521  522  523  524  525  526  527  528  529  530  531  532  533  534  535  536  537  538  539  540  541  542  543  544  545  546  547  548  549  550  551  552  553  554  555  556  557  558  559  560  561  562  563  564  565  566  567  568  569  570  571  572  573  574  575  576  577  578  579  580  581  582  583  584  585  586  587  588  589  590  591  592  593  594  595  596  597  598  599  600  601  602  603  604  605  606  607  608  609  610  611  612  613  614  615  616  617  618  619  620  621  622  623  624  625  626  627  628  629  630  631  632  633  634  635  636  637  638  639  640  641  642  643  644  645  646  647  648  649  650  651  652  653  654  655  656  657  658  659  660  661  662  663  664  665  666  667  668  669  670  671  672  673  674  675  676  677  678  679  680  681  682  683  684  685  686  687  688  689  690  691  692  693  694  695  696  697  698  699  700  701  702  703  704  705  706  707  708  709  710  711  712  713  714  715  716  717  718  719  720  721  722  723  724  725  726  727  728  729  730  731  732  733  734  735  736  737  738  739  740  741  742  743  744  745  746  747  748  749  750  751  752  753  754  755  756  757  758  759  760  761  762  763  764  765  766  767  768  769  770  771  772  773  774  775  776  777  778  779  780  781  782  783  784  785  786  787  788  789  790  791  792  793  794  795  796  797  798  799  800  801  802  803  804  805  806  807  808  809  810  811  812  813  814  815  816  817  818  819  820  821  822  823  824  825  826  827  828  829  830  831  832  833  834  835  836  837  838  839  840  841  842  843  844  845  846  847  848  849  850  851  852  853  854  855  856  857  858  859  860  861  862  863  864  865  866  867  868  869  870  871  872  873  874  875  876  877  878  879  880  881  882  883  884  885  886  887  888  889  890  891  892  893  894  895  896  897  898  899  900  901  902  903  904  905  906  907  908  909  910  911  912  913  914  915  916  917  918  919  920  921  922  923  924  925  926  927  928  929  930  931  932  933  934  935  936  937  938  939  940  941  942  943  944  945  946  947  948  949  950  951  952  953  954  955  956  957  958  959  960  961  962  963  964  965  966  967  968  969  970  971  972  973  974  975  976  977  978  979  980  981  982  983  984  985  986  987  988  989  990  991  992  993  994  995  996  997  998  999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 
<?php

namespace hji\ResponsiveIDX\models;

use \hji\membership\Membership;
use \hji\common\utils\Views;
use \hji\ResponsiveIDX\ResponsiveIDX;
use \hji\ResponsiveIDX\models\HashMap;
use \hji\ResponsiveIDX\models\MarketMetadata;
use \hji\ResponsiveIDX\controllers\Settings;
use \hji\ResponsiveIDX\widgets\QuickSearch_Widget;

//TODO: Refactor construction of form fields:
// should be some sort of factory that would construct each field
// it needs to know of market and listing type, so it could check
// if filters are supported by the given market.

class QuickSearchViewModel
{
    private $_widget;
    private $idxSearchModel;
    public $settingsController;
    public $market;
    public $instanceSettings;


    function __construct(QuickSearch_Widget $widget)
    {
        $this->_widget = $widget;
        $this->idxSearchModel = $widget->idxSearchModel;
        $this->settingsController = Settings::getInstance();
    }


    /**
     * Returns search widget's HTML form for front-end rendering
     *
     * @param $args WP_Widget args
     * @param $instance WP_Widget instance
     * @return string
     */
    // TODO: refactor this method
    function getWidgetContent($args, $instance)
    {
        $this->args = $args;
        $this->instance = $instance;

        extract($args);

        // Convert old keys to new

        if (isset($instance['mls']))
        {
            $instance = HashMap::filters($instance);
        }

        // Set $market as a class property

        if (!isset($instance['market']) || $instance['market'] == null)
        {
            return;
        }

        $this->market = $instance['market'];

        // Check if license key for this market exists

        if (!in_array($instance['market'], Membership::getInstance()->getMarkets()))
        {
            // Render error message only for logged-in user

            if (is_user_logged_in())
            {
                echo '<p class="alert alert-danger">Error: You don\'t have a valid license for ' . $instance['market'] . ' market.</p>';
            }

            return;
        }

        // Define View variables

        $vars['market']                 = $instance['market'];

        // Set widget layout

        if (isset($instance['layout']))
        {
            $vars['layout']             = $instance['layout'];
        }

        if (isset($instance['listingTypeSelector']))
        {
            $vars['listingTypeSelector'] = $instance['listingTypeSelector'];
        }
        else
        {
            // Default
            $vars['layout']             = 'vertical';
        }

        $vars['listingTypes']           = $this->_getListingTypeValues($instance);
        $vars['selectedListingType']    = $this->_getSelectedListingType($instance);

        // Set processed settings for the instance, which can be
        // accessed via hooks

        $this->instanceSettings = $vars;

        // Prepare search forms for each listing type

        foreach ($vars['listingTypes'] as $k => $v)
        {
            $hide = ($k == $vars['selectedListingType']) ? false : true;

            ob_start();
            call_user_func_array(
                array(&$this, "_{$k}_search_form"),
                array($instance, $hide));

            $vars['forms'][$k]          = ob_get_clean();
        }

        // Create listing types selector view

        if (count($vars['listingTypes']) > 1)
        {
            $typeSelectorView = new Views(ResponsiveIDX::$views);
            $typeSelectorView->set('listingTypeSelector', $vars['listingTypeSelector']);
            $typeSelectorView->set('listingTypes', $vars['listingTypes']);
            $typeSelectorView->set('selectedListingType', $vars['selectedListingType']);

            $vars['listingTypeSelectorView'] = $typeSelectorView->render('quick-search-type-selector');
        }

        // Create Widget View

        $view = new Views(ResponsiveIDX::$views);

        $vars = apply_filters('ridx_quick_search_widget', $vars, $args, $instance, $this->_widget->id);

        return $view->render('quick-search-widget', $vars);
    }


    /**
     * Returns array of listing type
     * keys to labels for views
     *
     * @param $instance
     * @return array
     */
    function _getListingTypeValues($instance)
    {
        // Get all listing types supported by current market

        $listingTypes = MarketMetadata::getInstance($instance['market'])->getListingTypes();

        // If property type not selected inside widget settings (which is required)
        // Display ALL supported types

        if (!isset($instance['listingType']) || empty($instance['listingType']))
        {
            // Widget settings only save array keys, not labels
            // so we mimic that behavior
            $instance['listingType'] = array_keys($listingTypes);
        }

        $result = array();

        foreach ($instance['listingType'] as $value)
        {
            $value = strtolower($value);

            switch($value)
            {
                case 'residential':
                    $key = $value;
                    $label = 'For Sale';
                    break;
                case 'for sale': // backward compatibility with rIDX 2
                    $key = 'residential';
                    $label = 'For Sale';
                    break;
                case 'rentals':
                    $key = 'rental';
                    $label = 'Rental';
                    break;
                default:
                    $key = $value;
                    $label = $listingTypes[$value];
            }

            $result[$key] = $label;
        }

        return $result;
    }


    /**
     * Returns selected listing type
     * or falls back onto a default one.
     *
     * @param $instance instance of the widget
     * @return string
     */
    function _getSelectedListingType($instance)
    {
        // Default

        $selected = 'residential';

        // Check if listing type was set in a search query

        if ($listingType = $this->getParam('listingType'))
        {
            if (isset($listingType[0]) && !empty($listingType[0]))
            {
                $selected = $listingType[0];
            }
        }
        else if (isset($instance['listingType']) && isset($instance['listingType'][0]) &&
                 !empty($instance['listingType'][0]))
        {
            $selected = $instance['listingType'][0];
        }

        return $selected;
    }


    /**
     * Returns administrative HTML form content
     * for Quick Search Widget (Widget Dashboard)
     *
     * @param $instance Quick Search Widget instance
     */
    function widgetFormContent($instance)
    {
        if (isset($instance['title']))
        {
            $title = $instance['title'];
        }
        else
        {
            $title = null;
        }

        if (isset($instance['mls']))
        {
            $instance = HashMap::filters($instance);
        }

        // Get MLS IDs
        $mls_ids = Membership::getInstance()->getMarkets();
        ?>
        <p>
            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
        </p>

        <?php
        if (!empty($mls_ids))
        {
            $options = '';
            $tmp = $mls_ids;
            $selected_key = array_shift($tmp); //default selected

            foreach ($mls_ids as $mls)
            {
                $selected = false;
                $selected_key = false;

                if (isset($instance['market']))
                {
                    $selected = selected( $instance['market'], $mls, $echo = false );
                    $selected_key = ( isset($instance['market']) ) ? $instance['market'] : $selected_key;
                }

                $options .= '<option value="' . $mls . '" ' . $selected . '>' . strtoupper($mls) . '</option>';
            }

            echo '<p><label for="' . $this->get_field_id('market') . '">MLS</label> ';
            echo '<select class="market" id="' . $this->get_field_id('market') . '" name="' . $this->get_field_name('market') . '"">' . $options . '</select></p>';

            // Property Type Selector

            echo '<p><strong>Listing Types</strong></p>';

            if (isset($instance['market']))
            {
                foreach ($mls_ids as $mls)
                {
                    $MarketMetaData = MarketMetadata::getInstance($mls);

                    // Get property types of the current MLS

                    $listingTypes = $MarketMetaData->getListingTypes();

                    foreach ($listingTypes as $listingType => $label)
                    {
                        $toggler = '&nbsp;&nbsp;<a href="#" class="toggle-subtypes">Property Types</a>';

                        $propertyTypes = ($this->property_type_selector($instance, $mls, $listingType)) ? $toggler . $this->property_type_selector($instance, $mls, $listingType) : null;

                        $checkboxes[] = '<div><input type="checkbox" name="' . $this->get_field_name('listingType') . '[]" value="' . $listingType . '" ' . @checked(true, in_array($listingType, $instance['listingType']), false ) . '/> <label>' . $label . '</label>' . $propertyTypes . '</div>';
                    }

                    if (isset($checkboxes))
                    {
                        $html[$mls] = '<div id="property_types_for_' . $mls . '" class="property-type-checkboxes"><p>' . implode( '', $checkboxes ) . '</p></div>';
                    }

                    unset($checkboxes);
                }
            }

            if (!stristr($this->_widget->id, '__i__' ))
            {
                $json_arr = json_encode( array($this->_widget->id => $html ) );
                echo '<script>mls_pts.push(' . $json_arr . ');</script>';
            }

            echo '<div class="pts_container">' . @$html[$selected_key] . '</div>';

            $selectors = $this->_widget->getListingTypeSelectors();

            $options = null;

            foreach ($selectors as $option => $label)
            {
                $options .= '<option value="' . $option . '" ' . selected($instance['listingTypeSelector'], $option, false) . '>' . $label . '</option>';
            }

            echo '<label for="' . $this->get_field_id('listingTypeSelector') . '">Render as </label><select class="selector" id="' . $this->get_field_id('listingTypeSelector') . '" name="' . $this->get_field_name('listingTypeSelector') . '"">' . $options . '</select></p>';

            echo '<div class="description">Please, select at least one listing type.</div>';

            echo '<hr />';

            echo '<p>';

            echo '<label for="' . $this->get_field_id('layout') . '">Widget Layout</label> ';

            echo '<select id="' . $this->get_field_id('layout') . '" name="' . $this->get_field_name('layout') . '">';
                echo '<option value="vertical" ' . selected(@$instance['layout'], 'vertical', false) . '>Vertical</option>';
                echo '<option value="horizontal" ' . selected(@$instance['layout'], 'horizontal', false) . '>Horizontal</option>';
            echo '</select>';

            echo '</p>';

            echo '<p>';
            echo '<input type="checkbox" name="' . $this->get_field_name('expand_advanced_opt') . '" id="' . $this->get_field_id('expand_advanced_opt') . '" value="1" ' . checked(@$instance['expand_advanced_opt'], true, false) . ' /> ';
            echo '<label for="' . $this->get_field_id('expand_advanced_opt') . '">Expand Advanced Options</label>';
            echo '</p>';

            echo '<p>';
            echo '<input type="checkbox" name="' . $this->get_field_name('mobileOff') . '" id="' . $this->get_field_id('mobileOff') . '" value="1" ' . checked(@$instance['mobileOff'], true, false) . ' /> ';
            echo '<label for="' . $this->get_field_id('mobileOff') . '">No Mobile Version</label>';
            echo '</p>';

            // Default sorting

            echo '<p>';
                echo '<label for="'
 . $this->get_field_id('sortField') . '">Sort Field</label> ';
                echo '<select name="' . $this->get_field_name('sortField') . '">';
                    echo '<option value="daysOnHJI" ' . selected(@$instance['sortField'], 'daysOnHJI', false) . '>Days on Website</option>';
                    echo '<option value="listPrice" ' . selected(@$instance['sortField'], 'listPrice', false) . '>Price</option>';
                echo '</select>';
            echo '</p>';

            echo '<p>';
                echo '<label for="'
                    . $this->get_field_id('sortOrder') . '">Sort Order</label> ';
                echo '<select name="' . $this->get_field_name('sortOrder') . '">';
                    echo '<option value="desc" ' . selected(@$instance['sortOrder'], 'desc', false) . '>DESC</option>';
                    echo '<option value="asc" ' . selected(@$instance['sortOrder'], 'asc', false) . '>ASC</option>';
                echo '</select>';
            echo '</p>';

        }
    }


    /**
     * Returns listing types as a list of check-boxes
     * with expandable property types checkbox sub-lists
     * respectively to selected market.
     * (This is for back-end widget management form)
     *
     * @param $instance
     * @param $market
     * @param $listingType
     * @return bool|string
     */
    function property_type_selector($instance, $market, $listingType)
    {
        $propertyTypes = MarketMetadata::getInstance($market)->getPropertyTypes($listingType);

        if ($propertyTypes && count($propertyTypes) > 0)
        {
            $output = null;

            foreach ($propertyTypes as $value)
            {
                $checked = @checked(true, in_array($value, @$instance['propertyType'][$market . ' ' . $listingType]), false);

                $output .= '<input type="checkbox" name="' . $this->get_field_name('propertyType') . '[' . $market . ' ' . $listingType . '][' . $value . ']" id="' . $this->get_field_id('propertyType') . '" value="' .  $value . '" ' . $checked. '> <label>' . $value . '</label><br />';
            }

            return '<div class="property_subtypes">' . $output . '</div>';
        }

        return false;
    }


    /**
     * Returns search parameters value that were passed to the IdxSearchModel
     *
     * @param $param
     * @return array|null|string
     */
    public function getParam($param)
    {
        if (!$searchParams = $this->_widget->idxSearchModel->GetSearchParams())
        {
            return null;
        }

        $return = null;

        // Turn param into an array if it's a numeric condition

        if ($val = $searchParams->$param)
        {
            if ($param == 'listingType' && is_string($val))
            {
                $return = explode('|', $val);
            }
            else if(is_string($val) && is_numeric(substr($val, 0, -1)))
            {
                $char = substr($val, -1);

                if($char == '-')
                {
                    $return[0] = '';
                    $return[1] = intval($val);
                }
                else if($char == '+')
                {
                    $return[0] = intval($val);
                }
            }
            else if (is_string($val))
            {
                if(stristr($val, ':'))
                    $return = explode(':', $val);

                if(stristr($val, '|'))
                    $return = explode('|', $val);
            }

            if (!$return)
            {
                $return = $val;
            }

        }

        return ($this->market == $searchParams->market) ? $return : null;
    }


    /**
     * Checks if current widget is inside horizontal search sidebar
     *
     * @return bool
     */
    function is_in_horizontal_sidebar()
    {
        $sidebars_widgets = get_option('sidebars_widgets');

        if (isset($sidebars_widgets['idx-horizontal-search']) && !empty($sidebars_widgets['idx-horizontal-search']))
        {
            // Check if THIS widget's ID is in the horizontal sidebar - not another one
            if (in_array($this->_widget->id, $sidebars_widgets['idx-horizontal-search']))
            {
                return true;
            }
        }

        return false;
    }


    protected function filterSupported($filterName, $listingType)
    {
        if (!isset($filters[$this->market][$listingType]))
        {
            $Filters = new SearchFilters($this->market, $listingType);
            $this->filters[$this->market][$listingType] = $Filters->getFilters();
        }

        if (isset($this->filters[$this->market][$listingType][$filterName]))
        {
            return $this->filters[$this->market][$listingType][$filterName]->getFilterExists();
        }
    }


    /**
     * Residential search form
     *
     * @param      $instance
     * @param bool $hide
     * @return void [type] [description]
     */
    private function _residential_search_form($instance, $hide = false)
    {
        $listingType = 'residential';

        //Location
        $mainFields['polygon'] = $this->_polygon_field();

        // Beds
        $beds_field = apply_filters('ridx_search_widget_beds_field', 'beds_baths', array('beds', 'beds_baths', 'beds_range'), $this->_widget->id);

        switch($beds_field)
        {
            case 'beds_baths':
                $mainFields['beds_baths'] = $this->_beds_baths_field();
                break;

            case 'beds_range':
                $mainFields['beds_range'] = $this->_beds_range_field();
                break;

            case 'beds':
                $mainFields['beds'] = $this->_beds_field();
                break;
        }

        // Baths
        $baths_field = apply_filters('ridx_search_widget_baths_field', false, array('baths', 'baths_range'), $this->_widget->id);

        switch($baths_field)
        {
            case 'baths_range':
                $mainFields['baths_range'] = $this->_baths_range_field();
                break;

            case 'baths':
                $mainFields['baths'] = $this->_baths_field();
                break;
        }

        //Price range
        $mainFields['price_range'] = $this->_price_range_field();


        /** Advanced Search Options **/

        // Property Sub-Type
        $advancedFields['property_type'] = $this->_property_subtype_field($instance['market'], 'residential', $instance);

        // School District
        if ($this->filterSupported('schoolDistrict', $listingType))
        {
            $advancedFields['school_district'] = $this->_schoolDistrict_field();
        }

        // Keyword
        $advancedFields['keyword'] = $this->_keyword_field();

        // Living Area SqFt
        if ($this->filterSupported('yearBuilt', $listingType))
        {
            $advancedFields['size_year_built_range'] = $this->_living_area_year_built();
        }

        // Distressed
        if ($this->filterSupported('distressed', $listingType))
        {
            $advancedFields['distressed'] = $this->_distressed_field();
        }

        // Open House
        if ($this->filterSupported('openHouse', $listingType))
        {
            $advancedFields['open_house'] = $this->_openhouse_field();
        }

        $formSettings = ($hide) ? array('atts' => array('style' => 'display: none')) : array('classes' => 'active');

        echo $this->createForm('residential', $instance, $mainFields, $advancedFields, $formSettings);
    }


    /**
     * Rentals type was renamed to rental in Slipstream
     *
     * @param      $instance
     * @param bool $hide
     */
    private function _rentals_search_form($instance, $hide = false)
    {

        return $this->_rental_search_form($instance, $hide);
    }

    /**
     * Rental search form
     *
     * @param      $instance
     * @param bool $hide
     * @return void [type] [description]
     */
    private function _rental_search_form($instance, $hide = false)
    {
        $listingType = 'rental';

        //Location
        $mainFields['polygon'] = $this->_polygon_field();

        // Beds
        $beds_field = apply_filters('ridx_search_widget_beds_field', 'beds_baths', array('beds', 'beds_baths', 'beds_range'), $this->_widget->id);

        switch($beds_field)
        {
            case 'beds_baths':
                $mainFields['beds_baths'] = $this->_beds_baths_field();
                break;

            case 'beds_range':
                $mainFields['beds_range'] = $this->_beds_range_field();
                break;

            case 'beds':
                $mainFields['beds'] = $this->_beds_field();
                break;
        }

        // Baths
        $baths_field = apply_filters('ridx_search_widget_baths_field', false, array('baths', 'baths_range'), $this->_widget->id);

        switch($baths_field)
        {
            case 'baths_range':
                $mainFields['baths_range'] = $this->_baths_range_field();
                break;

            case 'baths':
                $mainFields['baths'] = $this->_baths_field();
                break;
        }

        //Price range
        $mainFields['price_range'] = $this->_lease_price_range_field();


        /** Advanced Search Options **/

        // Property Sub-Type
        $advancedFields['property_type'] = $this->_property_subtype_field($instance['market'], 'rental', $instance);

        // School District
        if ($this->filterSupported('schoolDistrict', $listingType))
        {
            $advancedFields['school_district'] = $this->_schoolDistrict_field();
        }

        // Keyword
        $advancedFields['keyword'] = $this->_keyword_field();

        //Living Area SqFt
        if ($this->filterSupported('yearBuilt', $listingType))
        {
            $advancedFields['size_year_built_range'] = $this->_living_area_year_built();
        }

        $formSettings = ($hide) ? array('atts' => array('style' => 'display: none')) : array('classes' => 'active');

        echo $this->createForm('rental', $instance, $mainFields, $advancedFields, $formSettings);
    }


    /**
     * Multifamily search form
     *
     * @param      $instance
     * @param bool $hide
     * @return void [type] [description]
     */
    private function _multifamily_search_form($instance, $hide = false)
    {
        $listingType = 'multifamily';

        $mainFields['polygon'] = $this->_polygon_field();

        //Number of units
        // filter is not available

        //Price range
        $mainFields['price_range'] = $this->_price_range_field();


        /** Advanced Search Options **/

        // Neighborhood
//        $this->_subdivision_field();

        // School District
        if ($this->filterSupported('schoolDistrict', $listingType))
        {
            $advancedFields['school_district'] = $this->_schoolDistrict_field();
        }

        // Keyword
        $advancedFields['keyword'] = $this->_keyword_field();

        //Living Area SqFt
        if ($this->filterSupported('size', $listingType))
        {
            $advancedFields['size'] = $this->_living_area_field();
        }

        //Year Built
        if ($this->filterSupported('yearBuilt', $listingType))
        {
            $advancedFields['year_built'] = $this->_year_built_field();
        }

        //Days on Market
//                    $this->_dom_field();

        $formSettings = ($hide) ? array('atts' => array('style' => 'display: none')) : array('classes' => 'active');

        echo $this->createForm('multifamily', $instance, $mainFields, $advancedFields, $formSettings);
    }


    /**
     * Land search form
     *
     * @param      $instance
     * @param bool $hide
     * @return void [type] [description]
     */
    private function _land_search_form($instance, $hide = false)
    {
        $listingType = 'land';

        $mainFields['polygon'] = $this->_polygon_field();

        //Lot Size
        if ($this->filterSupported('lotSize', $listingType))
        {
            $mainFields['lot_size'] = $this->_lost_size_field();
        }

        //Price range
        $mainFields['price_range'] = $this->_price_range_field();


        /** Advanced Search Options **/

        // Neighborhood
        if ($this->filterSupported('subdivision', $listingType))
        {
            $advancedFields['subdivision'] = $this->_subdivision_field();
        }

        //Days on Market
//                    $this->_dom_field();

        // Keyword
        $advancedFields['keyword'] = $this->_keyword_field();

        //Distressed
        if ($this->filterSupported('distressed', $listingType))
        {
            $advancedFields['distressed'] = $this->_distressed_field();
        }

        $formSettings = ($hide) ? array('atts' => array('style' => 'display: none')) : array('classes' => 'active');

        echo $this->createForm('land', $instance, $mainFields, $advancedFields, $formSettings);
    }


    /**
     * Deprecated @since 3.0 - Slipstream API doesn't have farm listing type
     * Farms search form
     *
     * @param      $instance
     * @param bool $hide
     * @return void [type] [description]
     */
    private function _farm_search_form($instance, $hide = false)
    {
        $listingType = 'farm';

        $mainFields['polygon'] = $this->_polygon_field();

        //Lot Size
        if ($this->filterSupported('lotSize', $listingType))
        {
            $mainFields['lot_size'] = $this->_lost_size_field();
        }

        //Price range
        $mainFields['price_range'] = $this->_price_range_field();


        /** Advanced Search Options **/

        // Neighborhood
        if ($this->filterSupported('subdivision', $listingType))
        {
            $advancedFields['subdivision'] = $this->_subdivision_field();
        }

        //Days on Market
//                    $this->_dom_field();

        // Keyword
        $advancedFields['keyword'] = $this->_keyword_field();

        //Distressed
        if ($this->filterSupported('distressed', $listingType))
        {
            $advancedFields['distressed'] = $this->_distressed_field();
        }

        $formSettings = ($hide) ? array('atts' => array('style' => 'display: none')) : array('classes' => 'active');

        echo $this->createForm('farm', $instance, $mainFields, $advancedFields, $formSettings);
    }


    /**
     * Commercial search form
     *
     * @param      $instance
     * @param bool $hide
     * @return void [type] [description]
     */
    private function _commercial_search_form($instance, $hide = false)
    {
        $listingType = 'commercial';

        $mainFields['polygon'] = $this->_polygon_field();

        //Building size

        //Lot Size
        if ($this->filterSupported('lotSize', $listingType))
        {
            $mainFields['lot_size'] = $this->_lost_size_field();
        }

        //Price range
        $mainFields['price_range'] = $this->_price_range_field();

        /** Advanced Search Options **/

        // Keyword
        $advancedFields['keyword'] = $this->_keyword_field();

        //Year Built
        if ($this->filterSupported('yearBuilt', $listingType))
        {
            $advancedFields['year_built'] = $this->_year_built_field();
        }

        //Days on Market
//                    $this->_dom_field();

        //Distressed
        if ($this->filterSupported('distressed', $listingType))
        {
            $advancedFields['distressed'] = $this->_distressed_field();
        }

        $formSettings = ($hide) ? array('atts' => array('style' => 'display: none')) : array('classes' => 'active');

        echo $this->createForm('commercial', $instance, $mainFields, $advancedFields, $formSettings);
    }

    // ******** Frequently re-usable form fields

    private function _sort_order($instance = false)
    {
        if (!$sortField = $this->getParam('sortField'))
        {
            $sortField = (isset($instance['sortField'])) ? $instance['sortField'] : 'listingDate';
        }

        if (!$sortOrder = $this->getParam('sortOrder'))
        {
            $sortOrder = (isset($instance['sortOrder'])) ? $instance['sortOrder'] : 'desc';
        }

        $_sort = array(
            'type'          => 'hidden',
            'name'          => 'sortField',
            'atts'          => array(
                'id'            => 'sortfield',
            ),
            'value'         => $sortField
        );

        $_order = array(
            'type'          => 'hidden',
            'name'          => 'sortOrder',
            'atts'          => array(
                'id'            => 'sortorder',
            ),
            'value'         => $sortOrder
        );

        $sort = $this->createFormField($_sort);
        $order = $this->createFormField($_order);

        return $sort . $order;
    }


    private function _city_zip_field($instance = false)
    {
        $city = ($this->getParam('city')) ? $this->getParam('city') : null;
        $zip =  ($this->getParam('postal_code')) ? $this->getParam('postal_code') : null;

        $settings = array(
            'type'          => 'text',
            'name'          => 'city-zip',
            'label'         => 'City/Zip Code <span class="idx-icon-info"></span>',
            'atts'          => array(
                'id'            => 'city-zip',
            ),
            'value'         => $city . $zip
        );

        return $this->createFormField($settings);

        return $output;
    }


    private function _price_range_field($instance = false)
    {
        $prices = array(
            50000, 100000, 150000, 200000, 250000, 300000,
            350000, 400000, 450000, 500000,
            600000, 700000, 800000, 900000, 1000000,
            1100000, 1200000, 1300000, 1400000, 1500000,
            1600000, 1800000, 1900000, 2000000,
            2250000, 2500000, 2750000, 3000000,
            3250000, 3500000, 3750000, 4000000,
            4500000, 5000000, 6000000, 8000000,
            10000000, 15000000
        );

        foreach ($prices as $p)
        {
            $price_min[$p] = $price_max[$p] = '$' . number_format($p);
        }

        // Price range filter

        $price_min = apply_filters('ridx_search_widget_price_min', $price_min, $this->_widget->id);
        $price_max = apply_filters('ridx_search_widget_price_max', $price_max, $this->_widget->id);

        $price = $this->getParam('listPrice');

        $min = array(
            'type'          => 'select',
            'name'          => 'listPrice',
            'label'         => 'Price Min',
            'atts'          => array(
                'id'            => 'price_min',
            ),
            'value'         => $price_min,
            'currentValue'  => @$price[0],
            'isArray'       => true
        );

        $max = array(
            'type'          => 'select',
            'name'          => 'listPrice',
            'label'         => 'Price Max',
            'atts'          => array(
                'id'            => 'price_max',
            ),
            'value'         => $price_max,
            'currentValue'  => @$price[1],
            'isArray'       => true
        );

        $field1 = $this->createFormField($min);
        $field2 = $this->createFormField($max);

        return $this->rangeView($field1, $field2);
    }


    private function _lease_price_range_field($instance = false)
    {
        //Price
        $prices = array(
            500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1500, 1600, 1700, 1800,
            1800, 1900, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4500,
            5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000
        );

        foreach ($prices as $p)
        {
            $price_min[$p] = $price_max[$p] = '$' . number_format($p);
        }

        // Price range filter

        $price_min = apply_filters('ridx_search_widget_lease_price_min', $price_min, $this->_widget->id);
        $price_max = apply_filters('ridx_search_widget_lease_price_max', $price_max, $this->_widget->id);

        $price = $this->getParam('listPrice');
        $price = (is_string($price) && stristr($price, ':')) ? explode(':', $price) : $price;

        $min = array(
            'type'          => 'select',
            'name'          => 'listPrice',
            'label'         => 'Price Min',
            'atts'          => array(
                'id'            => 'price_min',
            ),
            'value'         => $price_min,
            'currentValue'  => @$price[0],
            'isArray'       => true
        );

        $max = array(
            'type'          => 'select',
            'name'          => 'listPrice',
            'label'         => 'Price Max',
            'atts'          => array(
                'id'            => 'price_max',
            ),
            'value'         => $price_max,
            'currentValue'  => @$price[1],
            'isArray'       => true
        );

        $field1 = $this->createFormField($min);
        $field2 = $this->createFormField($max);

        return $this->rangeView($field1, $field2);
    }


    private function _beds_baths_field($instance = false)
    {
        $field1 = $this->_beds_field($instance);
        $field2 = $this->_baths_field($instance);

        return $this->rangeView($field1, $field2);
    }


    private function _beds_field($instance = false)
    {
        for ($i = 1; $i<= 6; $i++)
        {
            $_beds[$i . '+'] = $i . '+';
        }

        $_beds = apply_filters('ridx_search_widget_beds', $_beds, $this->_widget->id);

        $beds = $this->getParam('beds');
        $beds = $beds[0] . '+';

        $settings = array(
            'type'          => 'select',
            'name'          => 'beds',
            'label'         => 'Beds',
            'atts'          => array(
                'id'            => 'beds',
            ),
            'value'         => $_beds,
            'currentValue'  => $beds,
        );

        return $this->createFormField($settings);
    }


    private function _beds_range_field($instance = false)
    {
        for ($i = 1; $i<= 6; $i++)
        {
            $_beds_min[$i] = $_beds_max[$i] = $i;
        }

        $_beds_min = apply_filters('ridx_search_widget_beds_min', $_beds_min, $this->_widget->id);
        $_beds_max = apply_filters('ridx_search_widget_beds_max', $_beds_max, $this->_widget->id);

        $beds = $this->getParam('beds');

        $settingsMin = array(
            'type'          => 'select',
            'name'          => 'beds',
            'label'         => 'Beds Min',
            'atts'          => array(
                'id'            => 'beds_min',
            ),
            'value'         => $_beds_min,
            'currentValue'  => @$beds[0],
            'isArray'       => true
        );

        $settingsMax = array(
                'type'          => 'select',
                'name'          => 'beds',
                'label'         => 'Beds Max',
                'atts'          => array(
                    'id'            => 'beds_max',
                ),
                'value'         => $_beds_max,
                'currentValue'  => @$beds[1],
                'isArray'       => true
        );

        $field1 = $this->createFormField($settingsMin);
        $field2 = $this->createFormField($settingsMax);

        return $this->rangeView($field1, $field2);
    }


    private function _baths_range_field($instance = false)
    {
        for ($i = 1; $i<= 6; $i++)
        {
            $_baths_min[$i] = $_baths_max[$i] = $i;
        }

        $_baths_min = apply_filters('ridx_search_widget_baths_min', $_baths_min, $this->_widget->id);
        $_baths_max = apply_filters('ridx_search_widget_baths_max', $_baths_max, $this->_widget->id);

        $baths = $this->getParam('baths');

        $settingsMin = array(
            'type'          => 'select',
            'name'          => 'baths',
            'label'         => 'Baths Min',
            'atts'          => array(
                'id'            => 'baths_min',
            ),
            'value'         => $_baths_min,
            'currentValue'  => @$baths[0],
            'isArray'       => true
        );

        $settingsMax = array(
            'type'          => 'select',
            'name'          => 'baths',
            'label'         => 'Baths Max',
            'atts'          => array(
                'id'            => 'baths_max',
            ),
            'value'         => $_baths_max,
            'currentValue'  => @$baths[1],
            'isArray'       => true
        );

        $field1 = $this->createFormField($settingsMin);
        $field2 = $this->createFormField($settingsMax);

        return $this->rangeView($field1, $field2);
    }


    private function _baths_field($instance = false)
    {
        for ($i = 1; $i<= 6; $i++)
        {
            $_baths[$i . '+'] = $i . '+';
        }

        $_baths = apply_filters('ridx_search_widget_baths', $_baths, $this->_widget->id);

        $baths = $this->getParam('baths');

        $settings = array(
            'type'          => 'select',
            'name'          => 'baths',
            'label'         => 'Baths',
            'atts'          => array(
                'id'            => 'baths',
            ),
            'value'         => $_baths,
            'currentValue'  => $baths[0] . '+',
        );

        return $this->createFormField($settings);
    }


    private function _searchResultsUrl($instance)
    {
        global $post;

        $action = get_bloginfo('url') . '/' . $this->settingsController->getSearchPageSlug() . '/';

        return $action;
    }


    private function _search_btn_field($instance = false, $listingType = false)
    {
        _deprecated_function(__FUNCTION__, 3.0, null);
    }


    private function _lost_size_field()
    {
        $values = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50);

        foreach ($values as $v)
        {
            $acres[$v . '+'] = $v . '+ Acres';
        }

        $acres = apply_filters('ridx_search_widget_acres', $acres, $this->_widget->id);

        $selected = $this->getParam('lotSize');

        $settings = array(
            'type'          => 'select',
            'name'          => 'lotSize',
            'label'         => 'Lot Size',
            'atts'          => array(
                'id'            => 'lot_size',
            ),
            'value'         => $acres,
            'currentValue'  => $selected[0] . '+',
        );

        return $this->createFormField($settings);
    }


    private function _living_area_field()
    {
        $selected = $this->getParam('size');

        $values = array(600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3500, 4000, 4500, 5000, 5500, 6000);

        foreach ($values as $v)
        {
            $sqft[$v . '+'] = number_format($v) . ' ft2';
        }

        $sqft = apply_filters('ridx_search_widget_sqft', $sqft, $this->_widget->id);

        $settings = array(
            'type'          => 'select',
            'name'          => 'size',
            'label'         => 'Home Size',
            'atts'          => array(
                'id'            => 'living_area',
            ),
            'value'         => $sqft,
            'currentValue'  => $selected[0] . '+',
        );

        return $this->createFormField($settings);
    }


    private function _living_area_year_built()
    {
        $field1 = $this->_living_area_field();
        $field2 = $this->_year_built_field();

        return $this->rangeView($field1, $field2);
    }


    private function _property_subtype_field($market, $property_type, $instance)
    {
        if (isset($instance['propertyType'][$market . ' ' . $property_type]) && !empty($instance['propertyType'][$market . ' ' . $property_type]))
        {
            $propertyTypes = $instance['propertyType'][$market . ' ' . $property_type];
        }
        else
        {
            $propertyTypes = $this->idxSearchModel->GetPropertySubTypes($market, $property_type);
        }

        $propertyTypes = apply_filters('ridx_search_widget_property_types', $propertyTypes, $market, $this->_widget->id);

        if (count($propertyTypes) > 0)
        {
            $selected = $this->getParam('propertyType');

            $settings = array(
                'type'          => 'select',
                'name'          => 'propertyType',
                'label'         => 'Property Type',
                'atts'          => array(
                    'id'            => 'property_subtype',
                    'multiple'      => 'multiple'
                ),
                'value'         => $propertyTypes,
                'currentValue'  => $selected,
                'isArray'       => true
            );

            return $this->createFormField($settings);
        }
    }


    private function _polygon_field($instance = false)
    {
        $polygon = $this->getParam('polygon');

        if (is_array($polygon))
        {
            $polygon = implode('|', $polygon);
        }

        // Filter has to return array, which has to conatin ID => Label
        $polygon = apply_filters('ridx_search_widget_polygon', $polygon, $instance);

        // If array again, then we need to pre-populate polygons and polynames
        if (is_array($polygon))
        {
            $polynames = implode('|', $polygon);
            $polygon = array_keys($polygon);
            $polygon = implode('|', $polygon);
        }

        $settings = array(
            'type'          => 'text',
            'name'          => 'polygon',
            'label'         => 'Location <span class="idx-icon-info"></span>',
            'labelAfterField' => false,
            'atts'          => array(
                'id'            => 'polygon',
                'data-lookup'   => 'polygon',
                'data-market'   => $this->market,
                'placeholder'   => 'Neighborhood, city or zip'
            ),
            'value'         => $polygon,
            'isArray'       => false,
            'beforeField'        => '<label for="circle" data-type="nearbyToggle">Search Nearby  <span class="idx-icon-info"></span></label><div data-type="polygonFieldWrap">',
            'afterField'        => '</div><div data-type="nearbyFieldWrap"><input type="text" name="circle" data-type="circleInput" data-radius="0.5"></div>'
        );

        // Create a polynames field - which has to be located in the same container as polygon
        if (isset($polynames))
        {
            $settings['afterField'] = '<input type="hidden" class="polynames" name="polynames" value="' . $polynames . '">' . $settings['afterField'];
        }

        return $this->createFormField($settings);
    }


    private function _schoolDistrict_field($instance = false)
    {
        $settings = array(
            'type'          => 'text',
            'name'          => 'schoolDistrict',
            'label'         => 'School District',
            'atts'          => array(
                'id'            => 'schoolDistrict',
                'data-lookup'   => 'schoolDistrict',
                'data-market'   => $this->market
            ),
            'value'         => @$this->getParam('schoolDistrict'),
        );

        return $this->createFormField($settings);
    }


    private function _subdivision_field($instance = false)
    {
        $settings = array(
            'type'          => 'text',
            'name'          => 'subdivision',
            'label'         => 'Neighborhood <span class="idx-icon-info"></span>',
            'atts'          => array(
                'id'            => 'subdivision',
                'data-lookup'   => 'subdivision',
                'data-market'   => $this->market
            ),
            'value'         => @$this->getParam('subdivision'),
        );

        return $this->createFormField($settings);
    }


    private function _keyword_field($instance = false)
    {
        $settings = array(
            'type'          => 'text',
            'name'          => 'keyword',
            'label'         => 'Address, MLS# or Keyword <span class="idx-icon-info"></span>',
            'atts'          => array(
                'id'            => 'keyword',
            ),
            'value'         => @$this->getParam('keyword'),
        );

        return $this->createFormField($settings);
    }


    private function _year_built_field($instance = false)
    {
        $year_built = $this->getParam('yearBuilt');

        $year = date('Y');

        for ($i=$year; $i>=1930; $i--)
        {
            if ($i < 1990)
            {
                $i -=9;
            }
            $v = $i . '+';
            $years[$v] = $v;
        }

        $settings = array(
            'type'          => 'select',
            'name'          => 'yearBuilt',
            'label'         => 'Year',
            'atts'          => array(
                'id'            => 'year_built',
            ),
            'value'         => $years,
            'currentValue'  => @$year_built[0] . '+'
        );

        return $this->createFormField($settings);
    }


    private function _dom_field($instance = false)
    {
        $settings = array(
            'type'          => 'text',
            'name'          => 'daysOnMarket',
            'label'         => 'Days On Market <span class="idx-icon-info"></span></label>',
            'atts'          => array(
                'id'            => 'dom',
            ),
            'after'         => '<span class="legend">Example: "3-" three or less days on market.</span></div>',
            'currentValue'  => @$this->getParam('dom')
        );

        return $this->createFormField($settings);
    }


    private function _distressed_field()
    {
        $settings = array(
            'type'          => 'checkbox',
            'name'          => 'distressed',
            'label'         => 'Distressed',
            'atts'          => array(
                'id'            => 'distressed',
            ),
            'value'         => '1',
            'currentValue'  => @$this->getParam('distressed'),
            'labelAfterField' => true
        );

        return $this->createFormField($settings);
    }


    private function _openhouse_field()
    {
        $settings = array(
            'type'          => 'checkbox',
            'name'          => 'openhouse',
            'label'         => 'Open House',
            'atts'          => array(
                'id'            => 'openhouse',
            ),
            'value'         => '1',
            'currentValue'  => @$this->getParam('openhouse'),
            'labelAfterField' => true
        );

        return $this->createFormField($settings);
    }


    // Mimicking WP_Widget functions

    function get_field_id($str)
    {
        return $this->_widget->get_field_id($str);
    }


    function get_field_name($str)
    {
        return $this->_widget->get_field_name($str);
    }


    /**
     * Returns quick search form HTML
     *
     * @param       $listingType
     * @param       $instance
     * @param array $mainFields
     * @param array $advancedFields
     * @param array $formSettings
     * @return bool|string
     */
    function createForm($listingType, $instance, array $mainFields, array $advancedFields, array $formSettings = array())
    {
        $view = new Views(ResponsiveIDX::$views);

        $default = array(
            'id'                => 'sm-quick-search-' . $listingType,
            'name'              => 'sm-quick-search',
            'classes'           => false,
            'atts'              => false,
            'action'            => $this->_searchResultsUrl($instance),
            'searchResultsUrl'  => $this->_searchResultsUrl($instance),
            'mainFields'        => $mainFields,
            'advancedFields'    => $advancedFields,
            'searchBtnLabel'    => 'Search Now',
//            'doSettings'        => $this->_search_btn_field($instance, $listingType),
            'market'            => $this->market,
            'listingType'       => $listingType,
            'widgetInstance'    => $instance
        );

        if ($searchButtonLabel = $this->settingsController->getOption('button_search'))
        {
            $default['searchBtnLabel'] = $searchButtonLabel;
        }

        $default['hiddenFields']['sort_order'] = $this->_sort_order($instance);

        $vars = array_merge($default, $formSettings);

        $vars = apply_filters('ridx_search_form_' . $listingType, $vars, $this);
        $vars = apply_filters('ridx_search_form', $vars, $this);

        return $view->render('quick-search-form', $vars);
    }


    function createFormField(array $fieldSettings)
    {
        $view = new Views(ResponsiveIDX::$views);

        $class = (isset($fieldSettings['name'])) ? ' hji-' . strtolower($fieldSettings['name']) . '-wrap' : null;

        $default = array(
            'type'          => 'text',
            'name'          => false,
            'label'         => false,
            'labelAfterField' => false,
            'atts'          => array(),
            'before'        => '<div class="hji-fieldwrap'. $class .'">',
            'after'         => '</div>',
            'beforeField'   => false,
            'afterField'    => false,
            'value'         => false,
            'currentValue'  => null,
            'isArray'       => false,

        );

        $vars = array_merge($default, $fieldSettings);

        $vars['atts']['class'] = $vars['name'];

        $vars = apply_filters('ridx_search_form_field_' . $fieldSettings['name'], $vars, $this->instanceSettings, $this->_widget->id);

        if ($vars && !empty($vars))
        {
            return $view->render('quick-search-form-field', $vars);
        }
    }


    function rangeView($field1, $field2)
    {
        $view = new Views(ResponsiveIDX::$views);

        $vars = array(
            'field1'  => $field1,
            'field2'  => $field2
        );

        return $view->render('quick-search-range-fields', $vars);
    }

}
HJI WP Membership Code Reference API documentation generated by ApiGen