Changeset 1437341
- Timestamp:
- 06/15/2016 09:06:37 PM (10 years ago)
- Location:
- rets-rabbit/trunk
- Files:
-
- 15 edited
-
composer.json (modified) (1 diff)
-
composer.lock (modified) (3 diffs)
-
docs/rets_rabbit_for_wordpress_user_guide.md (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
retsrabbit.php (modified) (2 diffs)
-
rr_actions.php (modified) (4 diffs)
-
rr_adapter.php (modified) (7 diffs)
-
rr_shortcodes.php (modified) (3 diffs)
-
settings.php (modified) (3 diffs)
-
vendor/anecka/retsrabbit/README.md (modified) (4 diffs)
-
vendor/anecka/retsrabbit/src/Anecka/retsrabbit/RetsRabbitClient.php (modified) (4 diffs)
-
vendor/composer/ClassLoader.php (modified) (3 diffs)
-
vendor/composer/autoload_files.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (2 diffs)
-
vendor/composer/installed.json (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
rets-rabbit/trunk/composer.json
r1102919 r1437341 1 1 { 2 2 "require": { 3 "anecka/retsrabbit": " dev-master"3 "anecka/retsrabbit": "1.3" 4 4 } 5 5 } -
rets-rabbit/trunk/composer.lock
r1263335 r1437341 5 5 "This file is @generated automatically" 6 6 ], 7 "hash": " 16eaf1beb807f58c3e11f63147ee2159",8 "content-hash": " 63ec7e4368a0fc755eb9e953a4124e37",7 "hash": "8543c88d4bff4c80c4da2baece7b69a5", 8 "content-hash": "8f80d37d8cb62ca415e8f1e0d07d2745", 9 9 "packages": [ 10 10 { 11 11 "name": "anecka/retsrabbit", 12 "version": " dev-master",12 "version": "1.3", 13 13 "source": { 14 14 "type": "git", 15 15 "url": "https://github.com/patpohler/retsrabbit-php-sdk.git", 16 "reference": " 3c4e4f2ff917e52d85dbeb10ec39745f51f82ef7"16 "reference": "d8408734d2757440009a5c6b1d4312d7d0e61fff" 17 17 }, 18 18 "dist": { 19 19 "type": "zip", 20 "url": "https://api.github.com/repos/patpohler/retsrabbit-php-sdk/zipball/ 3c4e4f2ff917e52d85dbeb10ec39745f51f82ef7",21 "reference": " 3c4e4f2ff917e52d85dbeb10ec39745f51f82ef7",20 "url": "https://api.github.com/repos/patpohler/retsrabbit-php-sdk/zipball/d8408734d2757440009a5c6b1d4312d7d0e61fff", 21 "reference": "d8408734d2757440009a5c6b1d4312d7d0e61fff", 22 22 "shasum": "" 23 23 }, … … 39 39 "notification-url": "https://packagist.org/downloads/", 40 40 "description": "This is the PHP SDK for RetsRabbit", 41 "time": "201 5-10-02 19:57:43"41 "time": "2016-05-31 18:18:51" 42 42 }, 43 43 { … … 163 163 "aliases": [], 164 164 "minimum-stability": "stable", 165 "stability-flags": { 166 "anecka/retsrabbit": 20 167 }, 165 "stability-flags": [], 168 166 "prefer-stable": false, 169 167 "prefer-lowest": false, -
rets-rabbit/trunk/docs/rets_rabbit_for_wordpress_user_guide.md
r1263744 r1437341 3 3 *Author:* Patrick Pohler 4 4 5 *Version:* 1.0. 65 *Version:* 1.0.7 6 6 7 7 *URL:* <http://retsrabbit.com> … … 65 65 2. A Rets Rabbit account with a Client ID & Client Secret. To signup for an account, visit *RetsRabbit.com*. 66 66 67 Once you have your Rets Rabbit Client ID & Client Secret, click the Rets Rabbit section in the Wordpress Dashboard and enter them in the "Rets Rabbit Settings" page. 67 Once you have your Rets Rabbit Client ID & Client Secret, click the Rets Rabbit section in the Wordpress Dashboard and enter them in the "Rets Rabbit Settings" page. Optionally you might have a custom API endpoint (https://domain.retsrabbit.com/api), you can enter that into the "Rets Rabbit Settings" as well. 68 68 69 69 Once that's saved, you can confirm your access is working by click on "Metadata" under the Rets Rabbit admin to view your local MLS's metadata. -
rets-rabbit/trunk/readme.txt
r1263744 r1437341 4 4 Requires at least: 3.0.1 5 5 Tested up to: 4.3 6 Stable tag: 1.0. 66 Stable tag: 1.0.7 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 103 103 == Changelog == 104 104 105 = 1.0.7 - Add custom API endpoint 106 105 107 = 1.0.6 - Add caching options 106 108 -
rets-rabbit/trunk/retsrabbit.php
r1263744 r1437341 22 22 add_filter( 'query_vars', 'add_retsrabbit_query_vars' ); 23 23 24 include_once(dirname(__FILE__).'/rr_install.php'); 24 25 require_once(dirname(__FILE__).'/rr_adapter.php'); 25 26 require_once(dirname(__FILE__).'/rr_shortcodes.php'); … … 27 28 include_once(dirname(__FILE__).'/settings.php'); 28 29 29 30 register_activation_hook(__FILE__, 'retsrabbit_update_check' ); 30 31 31 32 ?> -
rets-rabbit/trunk/rr_actions.php
r1263744 r1437341 5 5 6 6 function retsrabbit_handle_search() { 7 global $wpdb; 7 8 $params = array(); 8 9 if(isset($_POST)) { … … 13 14 $new_key = str_replace('rets:', '', $key); 14 15 15 $val = $value;//sanitize_text_field($value); 16 if(is_array($value)) { 17 $val = implode("|", $value); 18 } else { 19 $val = $value;//sanitize_text_field($value); 20 } 16 21 17 22 //even though we don't send blank values to the RR API, save them anyway so … … 29 34 $sort_option = ((isset($_POST['sort_option']) && $_POST['sort_option'] != '') ? $_POST['sort_option'] : ""); 30 35 36 $data = array( 37 'params' => $params, 38 'limit' => $limit, 39 'result_page' => $results_page, 40 'orderby' => $orderby, 41 'sort_order' => $sort_order, 42 'sort_option' => $sort_option, 43 'page' => 1 44 ); 45 46 $key = md5(serialize($data)); 47 31 48 if(sizeof($params) > 0) { 32 set_transient('rr-search-query', null); 33 $data = array( 34 'params' => $params, 35 'limit' => $limit, 36 'result_page' => $results_page, 37 'orderby' => $orderby, 38 'sort_order' => $sort_order, 39 'sort_option' => $sort_option, 40 'page' => 1 49 $table_name = $wpdb->prefix . 'retsrabb_search'; 50 $wpdb->insert( 51 $table_name, 52 array( 53 'search_key' => "$key", 54 'search_value' => serialize($data), 55 ) 41 56 ); 42 set_transient('rr-search-query', $data);43 44 57 //we save the search parameters and redirect to the results page 45 58 //the results page actually hits the RR API and runs the search 46 59 47 wp_redirect($results_page );60 wp_redirect($results_page."?key=".$key); 48 61 exit; 49 62 } … … 54 67 if($option == "rr-client-id"){ 55 68 delete_transient('retsrabbit-access-code'); 56 delete_transient('rr-metadata'); 69 delete_transient('rr-metadata'); 57 70 } 58 71 } -
rets-rabbit/trunk/rr_adapter.php
r1263744 r1437341 19 19 $client_secret = get_option('rr-client-secret'); 20 20 21 $this->_getAPIEndpoint($client); 22 21 23 if($client_id && $client_secret) { 22 24 $client->getAccessCode($client_id, $client_secret); … … 31 33 public function metadata() { 32 34 $client = new Client($this->access_token); 35 $this->_getAPIEndpoint($client); 33 36 34 37 if($this->access_token) { … … 55 58 public function get_listing($mls_id, $num_photos = -1, $cache = false, $cache_duration = 4) { 56 59 $client = new Client($this->access_token, true); 60 $this->_getAPIEndpoint($client); 61 57 62 $servers = $client->getServers(); 58 63 $server_hash = $servers[0]['server_hash']; //dangerous, need to adjust this … … 92 97 public function run_search($params, $limit, $num_photos, $orderby = "", $sort_order = "", $sort_option = "", $cache = false, $cache_duration = 4) { 93 98 $client = new Client($this->access_token, true); 99 $this->_getAPIEndpoint($client); 100 94 101 $servers = $client->getServers(); 95 102 $server_hash = $servers[0]['server_hash']; //dangerous, need to adjust this … … 118 125 $this->total_records = $response['total_records']; 119 126 120 foreach($response['results'] as $listing) { 121 $fields = array(); 122 $variable = array(); 123 124 $variable['mls_id'] = $listing['mls_id']; 125 foreach($listing['fields'] as $key => $field) { 126 $variable[$key] = $field; 127 } 128 129 $variable = $this->_photo_array_builder($listing, $variable, $num_photos); 130 $variables[] = $variable; 127 $variables['total_records'] = $this->total_records; 128 $variables['params'] = $params; 129 130 if (is_array($response['results']) || is_object($response['results'])){ 131 foreach($response['results'] as $listing) { 132 $fields = array(); 133 $variable = array(); 134 135 $variable['mls_id'] = $listing['mls_id']; 136 foreach($listing['fields'] as $key => $field) { 137 $variable[$key] = $field; 138 } 139 140 $variable = $this->_photo_array_builder($listing, $variable, $num_photos); 141 $variables[] = $variable; 142 } 131 143 } 132 144 … … 166 178 167 179 foreach($query_params['params'] as $param => $value) { 168 $form_data[$param] = $value; 180 if(strpos($value, "|") !== FALSE) { 181 $form_data[$param] = explode("|", $value); 182 } else { 183 $form_data[$param] = $value; 184 } 169 185 } 170 186 } … … 229 245 } 230 246 247 private function _getAPIEndpoint(&$client) { 248 $api_endpoint = get_option('rr-api-endpoint'); 249 if($api_endpoint != '' && $api_endpoint != null) { 250 if(substr($api_endpoint, -1) != '/') 251 $api_endpoint .= '/'; 252 253 $client->setEndpoint($api_endpoint); 254 } 255 } 231 256 232 257 private function _pagination($total_pages) { -
rets-rabbit/trunk/rr_shortcodes.php
r1263744 r1437341 38 38 } 39 39 40 static function breadcrumb_search ($atts, $content = null, $tag) { 41 global $wp_query; 42 $city = get_query_var('city', ''); 43 $subdivision = get_query_var('subdivision', ''); 44 45 $params = []; 46 47 if($city !== ''){ 48 $city = urldecode($city); 49 $params['LIST_39'] = $city; 50 } 51 52 if($subdivision !== ''){ 53 $subdivision = urldecode($subdivision); 54 if(strpos($subdivision, '-') !== false){ 55 $subdivision = "\'".$subdivision."\'"; 56 } 57 $params['LIST_131:startswith'] = $subdivision; 58 } 59 60 $atts['params'] = json_encode($params); 61 62 return self::listings($atts, $content, $tag); 63 } 64 40 65 static function search_form($atts, $content = null, $tag = null) { 41 global $wp_query; 66 global $wp_query, $wpdb; 67 //global $wpdb; 42 68 $template = (isset($atts['template']) ? $atts['template'] : 'search-form.php'); 43 69 $rr_adapter = new rr_adapter(); 44 $query_params = get_transient('rr-search-query'); 70 71 $key = (isset($_GET['key']) ? $_GET['key'] : ''); 72 $query_params = ""; 73 if($key != "") { 74 $query_params = $wpdb->get_var("SELECT search_value FROM {$wpdb->prefix}retsrabb_search WHERE search_key = '$key'"); 75 $query_params = unserialize($query_params); 76 } 77 45 78 return $rr_adapter->generate_form($template, $query_params); 46 79 } 47 80 48 81 static function search_results($atts, $content = null, $tag = null) { 49 global $wp_query ;82 global $wp_query, $wpdb; 50 83 $template = (isset($atts['template']) ? $atts['template'] : 'results.php'); 51 84 $limit = (isset($atts['limit']) ? $atts['limit'] : get_option('rr-results-per-page', 10)); … … 55 88 $cache_duration = (isset($atts['cache_duration']) ? $atts['cache_duration'] : 4); 56 89 57 $query_params = get_transient('rr-search-query'); 90 $key = (isset($_GET['key']) ? $_GET['key'] : ''); 91 $query_params = ""; 92 if($key != "") { 93 $query_params = $wpdb->get_var("SELECT search_value FROM {$wpdb->prefix}retsrabb_search WHERE search_key = '$key'"); 94 $query_params = unserialize($query_params); 95 } 96 58 97 $params = $query_params['params']; 59 98 $orderby = $query_params['orderby']; … … 80 119 81 120 add_shortcode("retsrabbit-search-results", array("retsrabbit_shortcodes", "search_results")); 121 122 add_shortcode("retsrabbit-breadcrumb-search", array("retsrabbit_shortcodes", "breadcrumb_search")); 82 123 ?> -
rets-rabbit/trunk/settings.php
r1102922 r1437341 10 10 11 11 add_action('admin_init', 'retsrabbit_register_settings'); 12 13 add_action('wp_loaded', 'retsrabbit_build_pills'); 12 14 } 13 15 14 16 function retsrabbit_register_settings() { 17 register_setting('rr-settings-group', 'rr-api-endpoint'); 15 18 register_setting('rr-settings-group', 'rr-client-id'); 16 19 register_setting('rr-settings-group', 'rr-client-secret'); … … 45 48 <th scope="row">Client Secret</th> 46 49 <td><input type="text" class="regular-text" name="rr-client-secret" value="<?php echo get_option('rr-client-secret'); ?>"></td> 50 </tr> 51 <tr valign="top"> 52 <th scope="row">Custom API Endpoint (optional)</th> 53 <td><input type="text" class="regular-text" name="rr-api-endpoint" value="<?php echo get_option('rr-api-endpoint'); ?>"></td> 47 54 </tr> 48 55 <tr valign="top"> … … 157 164 <?php 158 165 } 166 167 function build_pills($params) { 168 $pills = ''; 169 170 if(sizeof($params)){ 171 $rr_adapter = new rr_adapter(); 172 $table_data = array(); 173 174 $types = $rr_adapter->metadata(); 175 176 if(sizeof($types)){ 177 //go through all the search params 178 foreach($params as $key => $value){ 179 if($value !== ''){ 180 $key = str_replace(":startswith", "", $key); 181 $key = str_replace(":indexof", "", $key); 182 //go through all types 183 foreach ($types as $type) { 184 //only hit property type 185 if($type->Resource == "Property") { 186 //go through the classes 187 foreach ($type->Data as $class) { 188 $fields = $class->Fields; 189 if($fields && sizeof($fields) > 0) { 190 //go through all fields of the class 191 foreach ($fields as $field) { 192 if($field->SystemName === $key){ 193 $pills .= '<div class="search-pill">'; 194 195 //get rid of escaped quotes due to hyphen in string 196 if($value[0] === '\\'){ 197 $value = substr($value, 0, -2); 198 $value = substr($value, 2, strlen($value)); 199 } 200 $pills .= $field->LongName.': '.$value; 201 $pills .= '</div>'; 202 break 3; 203 } 204 } 205 } 206 } 207 } 208 } 209 } 210 } 211 } 212 } 213 214 return $pills; 215 } 159 216 ?> -
rets-rabbit/trunk/vendor/anecka/retsrabbit/README.md
r1102919 r1437341 8 8 //New instance of the client 9 9 $client = new Anecka\retsrabbit\RetsRabbitClient($access_token); 10 11 //If using a custom API endpoint (ex. https://<domain>.retsrabbit.com/api) 12 //If your endpoint is https//api.retsrabbit.com you don't need to set this 13 $client->setEndpoint($endpoint_url); 10 14 11 15 //Get a listing from the MLS w/ an id of '5456655' … … 35 39 ### Authentication 36 40 37 In order to use the libary, you need to have valid client credentials to Rets Rabbit . You'll need the credentials to create an access token in order to sender requests to the API.41 In order to use the libary, you need to have valid client credentials to Rets Rabbit and an API endpoint URL (usually in the form of https://<domain>.retrabbit.com/api). You'll need the credentials to create an access token in order to sender requests to the API. 38 42 39 43 $client = new Anecka\retsrabbit\RetsRabbitClient; 44 45 //If using a custom API endpoint (ex. https://<domain>.retsrabbit.com/api) 46 //If your endpoint is https//api.retsrabbit.com you don't need to set this 47 $client->setEndpoint($endpoint_url); 40 48 41 49 $client->getAccessCode($client_id, $client_secret); … … 46 54 /* instantiating the client by passing an access_token */ 47 55 48 $client = new Anecka\retsrabbit\RetsRabbitClient($_SESSION['access_token'] );56 $client = new Anecka\retsrabbit\RetsRabbitClient($_SESSION['access_token'], $endpoint_url); 49 57 50 58 ### Getting a list of servers … … 110 118 ***** 111 119 112 ©201 4Anecka, LLC All rights reserved.120 ©2016 Anecka, LLC All rights reserved. 113 121 -
rets-rabbit/trunk/vendor/anecka/retsrabbit/src/Anecka/retsrabbit/RetsRabbitClient.php
r1263335 r1437341 10 10 class RetsRabbitClient { 11 11 12 /* if you're using a custom domain: ex https://<domain>.retsrabbit.com, you'll need to set this to https://<domain>.retsrabbit.com/api/ 13 using setEndpoint() */ 12 14 var $endpoint = "https://api.retsrabbit.com/"; 13 15 var $access_token = ""; … … 23 25 if($access_token != "") $this->setAccessToken($access_token); 24 26 } 27 25 28 26 29 public function _obj($response) { … … 75 78 } 76 79 77 public function getAccessCode($client_id, $client_secret, $scope = " scope1") {80 public function getAccessCode($client_id, $client_secret, $scope = "") { 78 81 79 82 $response = $this->client->post($this->endpoint."oauth/access_token", [ … … 125 128 return $this->_obj($response); 126 129 } 130 131 public function getOpenHousesForListing($server_hash, $listing_id) { 132 $response = $this->_get("v1/$server_hash/open_house/$listing_id"); 133 134 return $this->_obj($response); 135 } 136 137 public function getSearchOpenHouses($server_hash, $search) { 138 $response = $this->_get("v1/$server_hash/open_house/search", $search); 139 140 return $this->_obj($response); 141 } 127 142 } -
rets-rabbit/trunk/vendor/composer/ClassLoader.php
r1102919 r1437341 14 14 15 15 /** 16 * ClassLoader implements a PSR-0 class loader 17 * 18 * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md 16 * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. 19 17 * 20 18 * $loader = new \Composer\Autoload\ClassLoader(); … … 40 38 * @author Fabien Potencier <fabien@symfony.com> 41 39 * @author Jordi Boggiano <j.boggiano@seld.be> 40 * @see http://www.php-fig.org/psr/psr-0/ 41 * @see http://www.php-fig.org/psr/psr-4/ 42 42 */ 43 43 class ClassLoader … … 148 148 * 149 149 * @param string $prefix The prefix/namespace, with trailing '\\' 150 * @param array|string $paths The PSR- 0base directories150 * @param array|string $paths The PSR-4 base directories 151 151 * @param bool $prepend Whether to prepend the directories 152 152 * -
rets-rabbit/trunk/vendor/composer/autoload_files.php
r1102919 r1437341 7 7 8 8 return array( 9 $vendorDir . '/guzzlehttp/streams/src/functions.php',10 $vendorDir . '/guzzlehttp/guzzle/src/functions.php',9 'fad373d645dd668e85d44ccf3c38fbd6' => $vendorDir . '/guzzlehttp/streams/src/functions.php', 10 '154e0d165f5fe76e8e9695179d0a7345' => $vendorDir . '/guzzlehttp/guzzle/src/functions.php', 11 11 ); -
rets-rabbit/trunk/vendor/composer/autoload_real.php
r1102919 r1437341 24 24 spl_autoload_unregister(array('ComposerAutoloaderInit622f64cd02c5d1abe8bd9e50d8c9eb39', 'loadClassLoader')); 25 25 26 $map = require __DIR__ . '/autoload_namespaces.php'; 27 foreach ($map as $namespace => $path) { 28 $loader->set($namespace, $path); 29 } 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); 27 if ($useStaticLoader) { 28 require_once __DIR__ . '/autoload_static.php'; 30 29 31 $map = require __DIR__ . '/autoload_psr4.php'; 32 foreach ($map as $namespace => $path) { 33 $loader->setPsr4($namespace, $path); 34 } 30 call_user_func(\Composer\Autoload\ComposerStaticInit622f64cd02c5d1abe8bd9e50d8c9eb39::getInitializer($loader)); 31 } else { 32 $map = require __DIR__ . '/autoload_namespaces.php'; 33 foreach ($map as $namespace => $path) { 34 $loader->set($namespace, $path); 35 } 35 36 36 $classMap = require __DIR__ . '/autoload_classmap.php'; 37 if ($classMap) { 38 $loader->addClassMap($classMap); 37 $map = require __DIR__ . '/autoload_psr4.php'; 38 foreach ($map as $namespace => $path) { 39 $loader->setPsr4($namespace, $path); 40 } 41 42 $classMap = require __DIR__ . '/autoload_classmap.php'; 43 if ($classMap) { 44 $loader->addClassMap($classMap); 45 } 39 46 } 40 47 41 48 $loader->register(true); 42 49 43 $includeFiles = require __DIR__ . '/autoload_files.php'; 44 foreach ($includeFiles as $file) { 45 composerRequire622f64cd02c5d1abe8bd9e50d8c9eb39($file); 50 if ($useStaticLoader) { 51 $includeFiles = Composer\Autoload\ComposerStaticInit622f64cd02c5d1abe8bd9e50d8c9eb39::$files; 52 } else { 53 $includeFiles = require __DIR__ . '/autoload_files.php'; 54 } 55 foreach ($includeFiles as $fileIdentifier => $file) { 56 composerRequire622f64cd02c5d1abe8bd9e50d8c9eb39($fileIdentifier, $file); 46 57 } 47 58 … … 50 61 } 51 62 52 function composerRequire622f64cd02c5d1abe8bd9e50d8c9eb39($file )63 function composerRequire622f64cd02c5d1abe8bd9e50d8c9eb39($fileIdentifier, $file) 53 64 { 54 require $file; 65 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { 66 require $file; 67 68 $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; 69 } 55 70 } -
rets-rabbit/trunk/vendor/composer/installed.json
r1263335 r1437341 124 124 { 125 125 "name": "anecka/retsrabbit", 126 "version": " dev-master",127 "version_normalized": " 9999999-dev",126 "version": "1.3", 127 "version_normalized": "1.3.0.0", 128 128 "source": { 129 129 "type": "git", 130 130 "url": "https://github.com/patpohler/retsrabbit-php-sdk.git", 131 "reference": " 3c4e4f2ff917e52d85dbeb10ec39745f51f82ef7"131 "reference": "d8408734d2757440009a5c6b1d4312d7d0e61fff" 132 132 }, 133 133 "dist": { 134 134 "type": "zip", 135 "url": "https://api.github.com/repos/patpohler/retsrabbit-php-sdk/zipball/ 3c4e4f2ff917e52d85dbeb10ec39745f51f82ef7",136 "reference": " 3c4e4f2ff917e52d85dbeb10ec39745f51f82ef7",135 "url": "https://api.github.com/repos/patpohler/retsrabbit-php-sdk/zipball/d8408734d2757440009a5c6b1d4312d7d0e61fff", 136 "reference": "d8408734d2757440009a5c6b1d4312d7d0e61fff", 137 137 "shasum": "" 138 138 }, … … 143 143 "phpunit/phpunit": "4.1.3" 144 144 }, 145 "time": "201 5-10-02 19:57:43",145 "time": "2016-05-31 18:18:51", 146 146 "type": "library", 147 147 "installation-source": "source",
Note: See TracChangeset
for help on using the changeset viewer.