PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.2.1
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.2.1
7.2.1 7.2 7.1.2 7.1.1 7.1 7.0.4 7.0.6 7.0.7 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 6.3.1 trunk 5.7.3 5.7.5 5.8.1 5.8.2 5.8.3 5.8.4 5.8.6 6.0.4 6.0.5 All 36 releases
mlsimport / enviroment / BridgeResoClass.php

BridgeResoClass.php in MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings 7.2.1, at enviroment/BridgeResoClass.php

86 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MLS provider adapter: Bridge (Bridge Data Output API, RESO standard).
4 *
5 * Owns Bridge identity, Stored request exceptions, native Direct MLS queries,
6 * endpoint rewriting, and saved-token login.
7 */
8 if ( ! defined( 'ABSPATH' ) ) {
9 // Block direct web access — only load when WordPress is bootstrapped.
10 exit; // Exit if accessed directly
11 }
12
13 /*
14 * To change this license header, choose License Headers in Project Properties.
15 * To change this template file, choose Tools | Templates
16 * and open the template in the editor.
17 */
18
19 /**
20 * Description of BridgeResoClass
21 *
22 * @author cretu
23 */
24 class BridgeResoClass extends ResoBase {
25
26 /** @var string Stable provider type saved for Bridge. */
27 protected $provider_type = 'bridge';
28
29 /** @var bool Bridge sends its saved bearer token unchanged. */
30 protected $direct_uses_stored_token = true;
31
32 // Active theme adapter (e.g. ResidenceClass) this provider maps RESO fields through.
33 public $theme_importer;
34
35 /**
36 * Store the theme importer so RESO-to-theme mapping can delegate to it.
37 *
38 * @param object $theme_importer The active theme adapter instance.
39 */
40 public function __construct( $theme_importer ) {
41 // Keep the theme adapter reference for later field mapping.
42 $this->theme_importer = $theme_importer;
43 }
44
45 /** Format Bridge sync times with seconds and no forced UTC suffix. */
46 protected function format_stored_timestamp( $value ) {
47 return $this->format_utc_timestamp( $value, false, false );
48 }
49
50 /** Remove StandardStatus for Edmonton, whose feed has no status field. */
51 public function prepare_stored_request( array $arguments, $last_date = '' ) {
52 if ( isset( $arguments['mls_id'] ) && 111 === (int) $arguments['mls_id'] ) {
53 unset( $arguments['status'] );
54 }
55 return parent::prepare_stored_request( $arguments, $last_date );
56 }
57
58 /**
59 * Build Bridge's native listings query instead of an OData query.
60 *
61 * @param array $params Standalone filter and paging values.
62 * @param array $config Per-MLS config including field_corellation.
63 * @return string
64 */
65 public function build_direct_query( array $params, array $config ) {
66 return mlsimport_live_build_query_bridge( $params, $config );
67 }
68
69 /** Build Bridge's native exact-ListingKey query. */
70 public function build_direct_get_query( $listing_key, array $config ) {
71 return '?ListingKey=' . rawurlencode( (string) $listing_key );
72 }
73
74 /**
75 * Rewrite Bridge's configured OData Property URL to its native listings URL.
76 *
77 * @param array $config Per-MLS configuration.
78 * @return string
79 */
80 public function direct_endpoint( array $config ) {
81 $base = parent::direct_endpoint( $config );
82 $native = preg_replace( '#/OData/([^/?]+)/Property/?#i', '/$1/listings', $base );
83 return is_string( $native ) && '' !== $native ? $native : $base;
84 }
85 }
86