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 
<?php
namespace hji\ResponsiveIDX\models;

use \hji\common\utils\Views;
use \hji\common\models\Alerts;
use \hji\membership\Membership;
use \hji\ResponsiveIDX\controllers\IdxApp;
use \hji\ResponsiveIDX\controllers\Pagination;
use \hji\ResponsiveIDX\controllers\Settings;
use \hji\ResponsiveIDX\ResponsiveIDX;
use \hji\ResponsiveIDX\utils\View;


class SearchResultsViewModel
{
    protected $search_params;
    protected $view;
    protected $default_grid_size;
    protected $params;
    protected $alerts = false;
    protected $idxSearchModel;

    // TODO: get rid of $params and $search_params
    // TODO: instead use $this->params->original/apiready.
    function __construct(IdxSearchModel $idxSearchModel, View $view)
    {
        $this->idxSearchModel = $idxSearchModel;
        $this->view = $view;

        // Pass params from the controller

        $params = $this->idxSearchModel->GetSearchParams();

        $this->params = $params->original;

        $this->search_params = $params->apiready;

        $jsVars = array(
            array(
                'modelId' => $this->idxSearchModel->getChecksum(),
                'params'  => $params->original
            )
        );

        idxApp::getInstance()->JsVars->setVar('searchParams', $jsVars);

        // Important to set compliance view model in constructor
        // it uses some hooks within SearchResultsViewModel, so it needs to be
        // loaded before hooks execute.
        $this->compliance = ComplianceViewModel::getInstance($this->search_params['market']);

        $this->settingsController = Settings::getInstance();
        $this->default_grid_size = $this->settingsController->getOption('grid_size');
    }


    function setAlert($message, $severity = Alerts::INFO, $dismiss = false)
    {
        if (!$this->alerts)
        {
            $this->alerts = new Alerts();
        }

        $this->alerts->addAlert($message, $severity);

        return $this->alerts;
    }


    function getSearchResultsView()
    {
        $this->_setQuickSearchWidget();
        $this->_setListingsObj();
        $this->_setViewResultsAs(); // !before grid size
        $this->_setDisplayOptions();// !after view as
        $this->_setGridSize();
        $this->_setPagination();
        $this->_setCompliance();


        // Define wrapper classes

        $wrapperClasses = array();
        $wrapperClasses[] =  'checksum-' . $this->idxSearchModel->getChecksum();

        // Check if page should scroll to results automatically

        if (isset($_GET['idxs_do']))
        {
            $wrapperClasses[] =  'scroll-to-results';
        }

        if ($this->view->get('viewas') == 'grid')
        {
            $wrapperClasses[] =  'grid-view';
        }
        else if ($this->view->get('viewas') == 'map')
        {
            $wrapperClasses[] =  'map-view';
        }
        else
        {
            $wrapperClasses[] =  'list-view';
        }

        // Check if we're on a mobile device

        if (wp_is_mobile())
        {
            $wrapperClasses[] = 'is-mobile';
        }

        $this->view->set('wrapperClasses', $wrapperClasses);

        // Check if lead generation email was specifically set via shortcode

        if (isset($this->params['email']))
        {
            // Set email value into a session so it can be re-used
            // in the listing details pages forms

            $paginataionViewModel = PaginationViewModel::instance();
            $paginataionViewModel->addLeadGenEmail($this->params['email']);
        }

        // Adding data attributes array to indicate that we're using it.

        $this->view->set('wrapperDataAtts', array());

        return $this->view;
    }

    function getSearchSalesResultsView()
    {
        $this->_setListingsObj();
        $this->_setViewResultsAs(); // !before grid size
        $this->_setDisplayOptions();// !after view as
        $this->_setGridSize();
        $this->_setPagination();
        $this->_setCompliance();

        // Define wrapper classes

        $wrapperClasses = array();

        // Check if page should scroll to results automatically

        if (isset($_GET['idxs_do']))
        {
            $wrapperClasses[] =  'scroll-to-results';
            $wrapperClasses[] =  'checksum-' . $this->idxSearchModel->getChecksum();
        }

        if ($this->view->get('viewas') == 'grid')
        {
            $wrapperClasses[] =  'grid-view';
        }
        else if ($this->view->get('viewas') == 'map')
        {
            $wrapperClasses[] =  'map-view';
        }
        else
        {
            $wrapperClasses[] =  'list-view';
        }

        // Check if we're on a mobile device

        if (wp_is_mobile())
        {
            $wrapperClasses[] = 'is-mobile';
        }

        $this->view->set('wrapperClasses', $wrapperClasses);

        // Check if lead generation email was specifically set via shortcode

        if (isset($this->params['email']))
        {
            // Set email value into a session so it can be re-used
            // in the listing details pages forms

            $paginataionViewModel = PaginationViewModel::instance();
            $paginataionViewModel->addLeadGenEmail($this->params['email']);
        }

        return $this->view;
    }


    function getSliderView()
    {
        $this->_setListingsObj();
        $this->_setViewResultsAs();
        $this->_setGridSize();
        $this->_setSliderParams(); // slider after GridSize!
        $this->_setCompliance();

        // Define wrapper classes

        $wrapperClasses[] = 'hjitb';
        $wrapperClasses[] =  'checksum-' . $this->idxSearchModel->getChecksum();

        if (isset($this->params['grid_size']) && (int) $this->params['grid_size'] > 0)
        {
            $wrapperClasses[] =  'grid-view';
        }
        else
        {
            $wrapperClasses[] =  'list-view';
        }

        $this->view->set('wrapperClasses', $wrapperClasses);

        return $this->view;
    }


    function getPromotedListingsView()
    {
        $this->_setPromotedListingsObj();
        $this->_setViewResultsAs(); // !before grid size
        $this->_setDisplayOptions();// !after view as
        $this->_setGridSize();
        $this->_setPagination(true);
        $this->_setCompliance();


        // Define wrapper classes

        $wrapperClasses = array();
        $wrapperClasses[] =  'checksum-' . $this->idxSearchModel->getChecksum();

        // Check if page should scroll to results automatically

        if (isset($_GET['idxs_do']))
        {
            $wrapperClasses[] =  'scroll-to-results';
        }

        if ($this->view->get('viewas') == 'grid')
        {
            $wrapperClasses[] =  'grid-view';
        }
        else if ($this->view->get('viewas') == 'map')
        {
            $wrapperClasses[] =  'map-view';
        }
        else
        {
            $wrapperClasses[] =  'list-view';
        }

        // Check if we're on a mobile device

        if (wp_is_mobile())
        {
            $wrapperClasses[] = 'is-mobile';
        }

        $this->view->set('wrapperClasses', $wrapperClasses);

        // Check if lead generation email was specifically set via shortcode

        if (isset($this->params['email']))
        {
            // Set email value into a session so it can be re-used
            // in the listing details pages forms

            $paginataionViewModel = PaginationViewModel::instance();
            $paginataionViewModel->addLeadGenEmail($this->params['email']);
        }

        // Adding data attributes array to indicate that we're using it.

        $this->view->set('wrapperDataAtts', array());

        return $this->view;
    }


    function getListingDetailsView()
    {
        $this->_setListingDetailsObj();

        if ($listing = $this->view->get('listing'))
        {
            $listingType = strtolower($listing->listingType);
            $this->_setDetailsSnippetHashmap($listingType);

            $pagination = new Pagination();
            $this->view->set('pagination', $pagination->getListingDetailsPagination($listing->listing_id));

            $this->_setListingInquiryForms();

            $this->_setListingInquiryButtons();

            $this->_setListingHTMLDataAttributes($listing, $this->view);
        }

        $this->_setCompliance();

        return $this->view;
    }


    // Some vars are being added in the Settings controller as well
    function getPropertyAdsView()
    {
        $this->_setListingsObj();

        $this->view->set('markets', Membership::getInstance()->getMarkets());

        return $this->view;
    }


    protected function _setListingsObj()
    {
        if (isset($this->params['polygon']))
        {
            $results = $this->idxSearchModel->searchListingsByArea($this->search_params);

            if ($results && !isset($results->error))
            {
                $result = $results['listings'];
                $areas  = $results['areas'];
            }
            else
            {
                $result = $results;
            }
        }
        else if (method_exists($this->idxSearchModel,$this->params['action']))
        {
            $result = $this->idxSearchModel->{$this->params['action']}($this->search_params);
        }
        else
        {
            $result = $this->idxSearchModel->searchListings($this->search_params);
        }


        if (!$result || @$result->success === false)
        {
            if (isset($result->error['message']))
            {
                $alerts = $this->setAlert($result->error['message'], Alerts::ERROR);
                $this->view->set('alerts', $alerts);
            }

//            $this->view->set('listings', $results['listings']);
        }
        else if ($result->total == 0)
        {
            $errorMessage = '<p>No properties were found matching your criteria. Please refine your search.</p>';

            $alerts = $this->setAlert($errorMessage, Alerts::ERROR);
            $this->view->set('alerts', $alerts);
            
            $this->view->set('listings', $result->listings);
            $this->view->set('total',       $result->total);
            $this->view->set('last_count',  $result->last_count);
            $this->view->set('total_pages', $result->total_pages);
            $this->view->set('current_page',$result->current_page);
            $this->view->set('page_size',   $result->page_size);
        }
        else
        {
            $this->view->set('listings',    $result->listings);
            $this->view->set('total',       $result->total);
            $this->view->set('last_count',  $result->last_count);
            $this->view->set('total_pages', $result->total_pages);
            $this->view->set('current_page',$result->current_page);
            $this->view->set('page_size',   $result->page_size);
            $this->_setListingResultsSnippets();


            // Set polygons JS variables

            if (isset($areas) && !empty($areas))
            {
                foreach ($areas as $a)
                {
                    if (isset($a['geometry']))
                    {
                        foreach ($a['geometry']['coordinates'] as $polygons)
                        {
                            $p = array();

                            foreach ($polygons as $i => $shapes)
                            {
                                // Avoid holes

                                if ($i > 0)
                                    break;

                                foreach ($shapes as $coords)
                                {
                                    $p[] = array(
                                        $coords[1],
                                        $coords[0]
                                    );
                                }
                            }
                            $newAreas[] = $p;
                        }
                    }

                }

                $newPolygons[$this->idxSearchModel->getChecksum()] = $newAreas;

                IdxApp::setJsVar('polygons', $newPolygons);
            }

        }
    }


    protected function _setPromotedListingsObj()
    {
        $result = $this->idxSearchModel->GetPromotedListings($this->search_params);

        if (!$result || @$result->success === false)
        {
            if (isset($result->error['message']))
            {
                $alerts = $this->setAlert($result->error['message'], Alerts::ERROR);
                $this->view->set('alerts', $alerts);
            }

            $this->view->set('listings', false);
        }
        else if ($result->total == 0)
        {
            $errorMessage = '<p>No properties were found matching your criteria. Please refine your search.</p>';

            $alerts = $this->setAlert($errorMessage, Alerts::ERROR);
            $this->view->set('alerts', $alerts);
//            $this->view->set('listings', false);
        }
        else
        {
            $this->view->set('listings', $result->listings);
            $this->view->set('total', $result->total);
            $this->view->set('last_count', $result->last_count);
            $this->view->set('total_pages', $result->total_pages);
            $this->view->set('current_page', $result->current_page);
            $this->view->set('page_size', $result->page_size);
            $this->_setListingResultsSnippets();
        }
    }


    protected function _setListingDetailsObj()
    {
        if (isset($this->search_params['id']) && isset($this->search_params['market']))
        {
            $args['id'] = $this->search_params['id'];
            $args['market'] = $this->search_params['market'];
            $args['referrer'] = isset($this->search_params['referrer']) ? $this->search_params['referrer'] : null;
        }
        else
        {
            return;
        }

        $listing = $this->idxSearchModel->getListings($args);

        if (isset($listing[0]))
        {
            $this->view->set('listing', $listing[0]);

            $_listing = new \stdClass();
            $_listing->market  = $listing[0]->market;
            $_listing->id      = $listing[0]->id;
            $_listing->price   = $listing[0]->price;
            $_listing->address = $listing[0]->address;
            $_listing->street  = $listing[0]->address_street;
            $_listing->city    = $listing[0]->address_city;
            $_listing->state   = $listing[0]->address_state;
            $_listing->zip     = $listing[0]->address_zip;
            $_listing->lat     = $listing[0]->coordinates_latitude;
            $_listing->lng     = $listing[0]->coordinates_longitude;

            idxApp::setJsVar('listing', $_listing);
        }

    }


    protected function _setViewResultsAs()
    {
        $params = $this->params;

        /** BEGIN Cookies Section */
        //Check $_COOKIE['idx-results-viewas'] if views set by user (via JS)
        //and if so - adjust the current view

        if (@$params['action'] != 'GetListingsWidget')
        {
            if (isset($_COOKIE['idx-results-viewas'])
                && !empty($_COOKIE['idx-results-viewas']))
            {
                $this->view->set('viewas', $_COOKIE['idx-results-viewas']);
            }
            else if ($this->settingsController->getOption('expand_map'))
            {
                $this->view->set('viewas', 'map');
            }
            else if (@$params['grid_size'] == 0)
            {
                $this->view->set('viewas', 'list');
            }
            else
            {
                $this->view->set('viewas', 'grid');
            }
        }
        else
        {
            if (!isset($params['grid_size']) || $params['grid_size'] == 0)
            {
                $this->view->set('viewas', 'list');
            }
            else
            {
                $this->view->set('viewas', 'grid');
            }
        }

        /** END Cookies Section */
    }


    protected function _setGridSize()
    {
        if (!isset($this->params['grid_size']) || $this->params['grid_size'] == 0)
        {
            $this->view->set('grid_size', $this->default_grid_size);
        }
        else
        {
            $this->view->set('grid_size', $this->params['grid_size']);
        }
    }


    protected function _setPagination($paginationOn = false)
    {
        if ($paginationOn ||
            (isset($this->params['pagination']) && $this->params['pagination'] == 1))
        {
            if ($this->view->get('total') > 0 && $this->view->get('page_size') > 0)
            {
                $p = new Pagination();

                $pagination = $p->getSearchResultsPagination(
                    $this->view->get('listings'),
                    $this->view->get('total'),
                    $this->view->get('page_size')
                );

                $this->view->set('pagination', $pagination);
            }
        }
        else
        {
            $this->view->set('pagination', false);
        }
    }


    protected function _setSliderParams()
    {
        $sliderId = uniqid('slider_');

        $displaySlideQty = ($grid_size = $this->view->get('grid_size')) ? $grid_size : 1;

        $this->view->set('sliderId', $sliderId);
        $this->view->set('displaySlideQty', $displaySlideQty);
        $this->view->set('moveSlideQty', $displaySlideQty);
    }


    protected function _setCompliance()
    {
        // If listing object is set - pass it to compliance

        if ($listing = $this->view->get('listing'))
        {
            $this->compliance->setListing($listing);
        }

        $this->view->set('compliance', $this->compliance->getRules());
    }


    /**
     * Hashmap for main details fields
     * to display in search results snippet.
     *
     * @param bool $listingType
     * @return mixed|void - array of listing object properties or false
     */
    function _setResultsSnippetHashmap($listingType = false)
    {
        if (!$listingType && !isset($this->search_params['listingType']))
        {
            return;
        }
        else if (!$listingType)
        {
            $listingType = $this->search_params['listingType'];
        }

        switch (strtolower($listingType))
        {
            case "residential":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'beds', 'baths_total', 'size', 'status', 'id', 'propertyType', 'listingAgent_name', 'listingOffice_name' );
                break;

            case "commercial":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'size', 'lotSize_sqft', 'status', 'id', 'propertyType', 'listingAgent_name', 'listingOffice_name');
                break;

            case "farm":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'size', 'lotSize_acres', 'lotSize_sqft', 'status', 'id', 'propertyType', 'listingAgent_name', 'listingOffice_name');
                break;

            case "land":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'lotSize_acres', 'lotSize_sqft', 'status', 'id', 'propertyType', 'listingAgent_name', 'listingOffice_name');
                break;

            case "multifamily":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'units', 'status', 'id', 'propertyType', 'listingAgent_name',  'listingOffice_name');
                break;

            case "rental":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'beds', 'baths_total', 'size', 'status', 'id', 'propertyType', 'listingAgent_name', 'listingOffice_name');
                break;
        }

        $mainDetailsFields = apply_filters('ridx_results_snippet_hashmap', $mainDetailsFields, $listingType, $this->search_params['market']);

        $this->view->set('mainDetailsHashmap', $mainDetailsFields);

        return $mainDetailsFields;
    }


    /**
     * Hashmap for main details fields
     * to display on listing details pages.
     *
     * @param $listingType
     * @return mixed|void - array of listing object properties or false
     */
    function _setDetailsSnippetHashmap($listingType)
    {
        switch ($listingType)
        {
            case "residential":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'beds', 'baths_total', 'size', 'status', 'propertyType', 'lotSize_acres', 'lotSize_sqft', 'yearBuilt', 'subdivision', 'daysOnHJI');
                break;

            case "commercial":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'size', 'lotSize_acres', 'lotSize_sqft', 'status', 'propertyType', 'yearBuilt', 'daysOnHJI');
                break;

            case "farm":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'property_subtype', 'status', 'yearBuilt', 'daysOnHJI');
                break;

            case "land":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'lotSize_acres', 'lotSize_sqft', 'status', 'propertyType', 'daysOnHJI');
                break;

            case "multifamily":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'units', 'propertyType', 'status', 'distressed', 'yearBuilt', 'subdivision', 'daysOnHJI');

                break;

            case "rental":
                $mainDetailsFields = array(
                    'coListingAgent_licenseNumber', 'listPrice', 'beds', 'baths_total', 'size', 'status', 'propertyType', 'yearBuilt', 'subdivision', 'daysOnHJI');
                break;
        }

        $mainDetailsFields = apply_filters('ridx_details_snippet_hashmap', $mainDetailsFields, $listingType, $this->search_params['market']);

        $this->view->set('mainDetailsHashmap', $mainDetailsFields);
    }


    /**
     * Returns listing inquiry forms HTML for listing details page
     *
     * @return string
     */
    function _setListingInquiryForms()
    {
        $listing = $this->view->get('listing');
        $leadGenEmail = PaginationViewModel::instance()->getLeadGenEmail();

        $form_args = array(
            'listing'   => 'Listing ID: ' . $listing->id,
            'email'     => $leadGenEmail,
            'property'  => 'MLS# ' . $listing->id . ' - ' . $listing->listPrice . ' - ' . $listing->address . '.',
        );

        $forms = $this->getListingInquiryForms($form_args);

        $this->view->set('listingInquiryForms', $forms);
    }


    function _setListingInquiryButtons()
    {
        $settingsController = IdxApp::getInstance()->settingsController;
        
        // Default values

        $href_1 = '#hjpl_form_1_wrapper';
        $href_2 = '#hjpl_form_2_wrapper';

        $class_1 = ' popup_trigger';
        $class_2 = ' popup_trigger';

        $form_1 = $settingsController->getOption('form_1');
        $form_2 = $settingsController->getOption('form_2');

        // Determine if call to action button is a link or a colorbox trigger

        if (filter_var($form_1, FILTER_VALIDATE_URL) !== FALSE)
        {
            $href_1 = $form_1;
            $class_1 = '';
        }

        if (filter_var($form_2, FILTER_VALIDATE_URL) !== FALSE)
        {
            $href_2 = $form_2;
            $class_2 = '';
        }

        // Generate HTML output

        $output = '<a href="' . $href_1 . '" class="btn btn-primary hjpl_call2action button_1' . $class_1 . '" data-init_="_colorbox" data-init="modal" data-target="#hjpl_form_1_wrapper">' .
                        '<span class="idx-icon-info"></span> ' .
                        '<span class="btn-label">' . $settingsController->getOption('button_1') . '</span></a>';

        $output .= '<a href="' . $href_2 . '" class="btn btn-primary hjpl_call2action button_2' . $class_2 . '" data-init_="_colorbox" data-init="modal" data-target="#hjpl_form_2_wrapper">' .
                        '<span class="idx-icon-calendar"></span> ' .
                        '<span class="btn-label">' . $settingsController->getOption('button_2') . '</span></a>';

        $this->view->set('listingInquiryButtons', $output);
    }


    /**
     * Returns Quick Search widget for embedding on search results pages
     *
     * Output Quick Home Search widget at the top of search results
     * only if search is initiated - not when results are embedded via a shortcode or widget
     * OR when results embedded and "search_widget" parameter is set to TRUE
     */
    function _setQuickSearchWidget()
    {
        $params             = $this->params;
        $widgetParams       = $params;
        $quickSearchWidget  = false;

        if (
            ((isset($_REQUEST['idxs_do']) && isset($params['market']))
                || @$this->params['search_widget'] == '1')
            && !empty($params['market']))
        {
            // Define wrapper classes

            add_filter('quick-search-wrapper-classes', array($this, '_applySearchWidgetClassesFilter'), 10, 2);

            if (class_exists('\hji\ResponsiveIDX\widgets\QuickSearch_Widget'))
            {
                if (isset($this->params['search_widget_prepopulate']) && (bool)$this->params['search_widget_prepopulate'])
                {
                    add_filter('ridx_quick_search_widget_instance', array($this, 'prePopulateHorizontalWidget'), 10, 2);
                }

                ob_start();

                if (!dynamic_sidebar('idx-horizontal-search'))
                {
                    // Add same wrapper as in the sidebar

                    echo '<div id="horizontal-idx-search-widget">';

                    // Search widget turned on with a property via listings shortcode
                    // will output a widget with forms for all listing types
                    // regardless of listing types selected in the [listings] shortcode.

                    // Grab listing types for the current market

                    $allListingTypes = $this->idxSearchModel->GetPropertyTypes($params['market']);

                    if (is_array($allListingTypes) && !empty($allListingTypes))
                    {
                        $widgetParams['listingType'] = array_keys($allListingTypes);
                    }
                    else
                    {
                        // fallback onto residential
                        $widgetParams['listingType'] = 'residential';
                    };

                    // If listing type is selected, QSW needs to have respective form active

                    if (isset($params['listingType']) && is_string($params['listingType']))
                    {
                        $widgetParams['selectedListingType'] = $params['listingType'];
                    }

                    // Pass current search model

                    $widgetParams['idxSearchModel'] = $this->idxSearchModel;

                    // Since this widget is prepended to search results,
                    // we turn on radio buttons for listing type toggle

                    $widgetParams['property_types_radios'] = 1;

                    $widgetParams['layout'] = 'horizontal';

                    // Render widget

                    the_widget('\hji\ResponsiveIDX\widgets\QuickSearch_Widget', $widgetParams);

                    echo '</div>';
                }

                $quickSearchWidget = ob_get_contents();
                ob_end_clean();
            }
        }

        $this->view->set('quickSearchWidget', $quickSearchWidget);
    }


    function _applySearchWidgetClassesFilter($classes, $instance)
    {
        // If checksum is set, that means it was set for previous widget
        // for the current one we need to overwrite it with a new value

        foreach($classes as $k => $class)
        {
            if (strpos($class, 'checksum-') !== false)
            {
                unset($classes[$k]);
                break;
            }
        }

        $classes[] = 'checksum-' . $this->idxSearchModel->getChecksum();

        if (!array_search('sticky-search', $classes))
        {
            $settings = IdxApp::getInstance()->settingsController;

            if (!wp_is_mobile() && $settings->getOption('sticky_search'))
            {
                $classes[] = 'sticky-search';
            }
        }

        return $classes;
    }


    function _setDisplayOptions()
    {
        $sortByOpenHouse = false;

        if (isset($this->search_params['listingType']))
        {
            // OpenHouse sort option - check if supported by market

            $searchFilters = new SearchFilters(
                $this->search_params['market'],
                $this->search_params['listingType']);

            $filters = $searchFilters->getFilters();

            if (isset($filters['openHouse']) && $filters['openHouse']->getFilterExists())
            {
                $sortByOpenHouse = true;
            }
        }

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

        $vars = array(
            'params' => $this->search_params,
            'viewas' => $this->view->get('viewas'),
            'sortByOpenHouse' => $sortByOpenHouse
        );

        $this->view->set('displayOptions', $view->render('listing-results-display-options', $vars));
    }


    function _setListingResultsSnippets()
    {
        // Generate wrapper classes

        $wrapperClasses[] = 'idx-results';

        $this->view->set('listingSnippetsWrapperClasses', $wrapperClasses);
        $this->_setResultsSnippetHashmap();

        // Generate view for each listing snippet

        $listingViewSnippets = false;

        $jsMapData   = false;

        $mainDetailsHashmap = $this->view->get('mainDetailsHashmap');

        foreach ($this->view->get('listings') as $listing)
        {
            $view = new Views(ResponsiveIDX::$views);

            $view->set('listing', $listing);

            if (!$mainDetailsHashmap)
            {
                $mainDetailsHashmap = $this->_setResultsSnippetHashmap($listing->listingType);
            }

            $view->set('mainDetailsHashmap', $mainDetailsHashmap);
            $view->set('button_listing_details', $this->settingsController->getOption('button_listing_details'));

            $this->_setListingHTMLDataAttributes($listing, $view);

            $listingSnippet = $view->render('listing-results-snippet');

            $l = new \stdClass();
            $l->lat = $listing->latitude;
            $l->lng = $listing->longitude;
            $l->info = $listingSnippet;

            // Check if custom icons was selected

            if ($iconUrl = $this->settingsController->getOption('gmap-marker'))
            {
                $l->icon = $iconUrl;
            }
            else
            {
                $l->icon = ResponsiveIDX::$url . '/resources/images/marker.png';
            }

            $jsMapData[] = $l;

            $listingViewSnippets[] = $listingSnippet;
        }

        $this->view->set('listingSnippets', $listingViewSnippets);

        if ($jsMapData && !@$this->params['slider'])
        {
            // Merge map results with existing ones

            $jsVars = idxApp::getJsVars();

            $mapResults = isset($jsVars['mapResults']) ? $jsVars['mapResults'] : array();

            $mapResults[$this->idxSearchModel->getChecksum()] = $jsMapData;

            idxApp::setJsVar('mapResults', $mapResults);
        }
    }


    function _setListingHTMLDataAttributes($listing, $view)
    {
        $data = array();

        $data['data-type']          = 'listing';
        $data['data-market']        = $this->search_params['market'];
        $data['data-listing-id']    = $listing->id;

        if (@$listing->favorite_id)
        {
            $data['data-favorite-id']    = $listing->favorite_id;
        }

        foreach ($data as $k => $v)
        {
            $result[] = $k . '="' . $v . '"';
        }

        $view->set('htmlDataAttributes', $result);
    }


    /**
     * Returns listing inquiry forms for listing details pages.
     *
     * @param array $args
     * @return string
     */
    function getListingInquiryForms($args = array())
    {
        $defaults = array(
            'email'     => $this->settingsController->getOption('leads_email'),
            'listing'   => false,
            'property'  => false,
        );
        $args = array_filter($args);
        $args = wp_parse_args( (array)$args, $defaults);
        extract( $args );

        $thx = '';

        // Check Honeypot

        $isSpam = false;

        // Email2 field should be empty

        if (isset($_POST['email2']) && $_POST['email2'] != '')
        {
            $isSpam = true;
        }

        // Email3 field contains a timestamp, which should be
        // at least 5 seconds old before form submission.
        if (time() < (intval(@$_POST['email3']) + 5))
        {
            $isSpam = true;
        }

        if (isset($_POST['sendinquiry']) && ($_POST['email'] || $_POST['phone']))
        {


            $headers = 'From: ' . __('Property Inquiry') . ' <' . $email . '>' . "\r\n";
            $message = __('Full Name: ') . $_POST['full_name'] . "\r\n";
            $message .= __('Email: ') . $_POST['email'] . "\r\n";
            $message .= __('Phone: ') . $_POST['phone'] . "\r\n";
            $message .= __('Property: ') . $_POST['listing'] . "\r\n";

            if (isset($_POST['day_time']))
            {
                $message .= __('Showing on: ') . $_POST['day_time'] . "\r\n";
            }

            $message .= __('Message: ') . $_POST['message'] . "\r\n";
            $message .= __('Referring URL: ') . $_POST['ref_url'] . "\r\n";

            if (wp_mail($email, $_POST['listing'], $message, $headers))
            {
                $thx = "<script>jQuery(document).ready(function(){ alert('Thank you for your inquiry! We will get back to you shortly.'); });</script>";
            }

        }

        $view = new \hji\common\utils\Views(ResponsiveIDX::$views);

        $hCard = (IdxApp::hCard()) ? (IdxApp::hCard()) : '';

        if ($form_1 = $this->settingsController->getOption('form_1'))
        {
            if (filter_var($form_1, FILTER_VALIDATE_URL) === false)
            {
//                $form_1 = $this->doShortcode($form_1);
                $form_1 = $form_1; // shortcode should be naturally converted during the_content
                $form_1_output = '<div id="hjpl_form_1_wrapper">' . $form_1 . '</div>';
            }
        }
        else
        {
            $vars['title']          = 'Request More Information';
            $vars['id']             = 'hjpl_form_1';
            $vars['class']          = 'property_inquiry';
            $vars['listingInfo']    = $property;
            $vars['listingId']      = $listing;
            $vars['referringUrl']    = 'http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
            $vars['submitButton']   = 'Send Inquiry';
            $vars['message']        = 'Please, send me more information on this property: ' . $property;
            $vars['beforeForm']     = '<div id="hjpl_form_1_wrapper">' . $hCard;
            $vars['afterForm']      = '</div>';

            $form_1_output = $view->render('listing-inquiry-form', $vars);
        }

        if ($form_2 = $this->settingsController->getOption('form_2'))
        {
            if (filter_var($form_2, FILTER_VALIDATE_URL) === false)
            {
//                $form_2 = $this->doShortcode($form_2);
                $form_2 = $form_2; // shortcode should be naturally converted during the_content
                $form_2_output = '<div id="hjpl_form_2_wrapper">' . $form_2 . '</div>';
            }
        }
        else
        {
            $vars['title']          = 'Schedule a Showing';
            $vars['id']             = 'hjpl_form_2';
            $vars['class']          = 'showing_inquiry';
            $vars['listingInfo']    = $property;
            $vars['listingId']      = $listing;
            $vars['referringUrl']    = 'http://' . $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
            $vars['submitButton']   = 'Send Inquiry';
            $vars['message']        = 'I would like to schedule a showing appointment for this property: ' . $property;
            $vars['beforeForm']     = '<div id="hjpl_form_2_wrapper">' . $hCard;
            $vars['afterForm']      = '</div>';

            $form_2_output = $view->render('listing-inquiry-form', $vars);
        }

        return $thx . "\n\n\n" . '<div id="hjpl_listing_forms">' . $form_1_output . $form_2_output . '</div>' . "\n\n\n";

    }


    /**
     * Executes shortcodes as well as cForms' custom shortcode
     *
     * @param $value
     * @return string
     */
    function doShortcode($value)
    {
        $shortcode = html_entity_decode($value);

        if (strstr($shortcode,'<!--cforms') !==false && function_exists('cforms_insert'))
        {
            // Process cForms custom shortcode

            return cforms_insert($shortcode);
        }
        else
        {
            // Process regular shortcode

            return do_shortcode($shortcode);
        }
    }


    /**
     * Forcing horizontal search widget to pre-populate
     * with search parameters form current idxSearchModel.
     *
     * @since 3.0
     *
     * @param $instance
     * @param $args
     * @return mixed
     */
    function prePopulateHorizontalWidget($instance, $args)
    {
        if (isset($args['id']) && $args['id'] == 'idx-horizontal-search')
        {
            $instance['search_widget_prepopulate'] = true;
            $instance['idxSearchModel'] = $this->idxSearchModel;
        }

        return $instance;
    }
}
HJI WP Membership Code Reference API documentation generated by ApiGen