Changeset 1465597
- Timestamp:
- 08/02/2016 12:45:32 AM (10 years ago)
- Location:
- rets-rabbit/trunk
- Files:
-
- 1 added
- 5 edited
-
readme.txt (modified) (1 diff)
-
retsrabbit.php (modified) (2 diffs)
-
rr_adapter.php (modified) (8 diffs)
-
rr_install.php (added)
-
rr_shortcodes.php (modified) (5 diffs)
-
settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
rets-rabbit/trunk/readme.txt
r1437341 r1465597 4 4 Requires at least: 3.0.1 5 5 Tested up to: 4.3 6 Stable tag: 1.0. 76 Stable tag: 1.0.8 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
rets-rabbit/trunk/retsrabbit.php
r1437341 r1465597 4 4 Plugin URI: http://retsrabbit.com/wordpress 5 5 Description: Plugin to integrate the real estate cloud service, Rets Rabbit, with Wordpress. 6 Version: 1.0. 66 Version: 1.0.8 7 7 Author: Patrick Pohler 8 8 Author URI: http://www.anecka.com … … 29 29 30 30 register_activation_hook(__FILE__, 'retsrabbit_update_check' ); 31 31 register_activation_hook( __FILE__, 'rr_install' ); 32 32 ?> -
rets-rabbit/trunk/rr_adapter.php
r1437341 r1465597 31 31 } 32 32 33 public function metadata( ) {33 public function metadata($server_hash = "") { 34 34 $client = new Client($this->access_token); 35 35 $this->_getAPIEndpoint($client); … … 39 39 40 40 if(sizeof($servers) > 0) { 41 $server_hash = $servers[0]->server_hash; 41 if($server_hash == "") 42 $server_hash = $servers[0]->server_hash; 42 43 43 44 $metadata = get_transient("rr-metadata"); … … 56 57 } 57 58 58 public function get_ listing($mls_id, $num_photos = -1, $cache = false, $cache_duration = 4) {59 public function get_servers() { 59 60 $client = new Client($this->access_token, true); 60 61 $this->_getAPIEndpoint($client); 61 62 62 63 $servers = $client->getServers(); 63 $server_hash = $servers[0]['server_hash']; //dangerous, need to adjust this 64 return $servers; 65 } 66 67 public function get_listing($mls_id, $server_num, $num_photos = -1, $cache = false, $cache_duration = 4) { 68 $client = new Client($this->access_token, true); 69 $this->_getAPIEndpoint($client); 70 71 $servers = $client->getServers(); 72 if(isset($servers[$server_num])) { 73 $server_hash = $servers[$server_num]['server_hash']; //dangerous, need to adjust this 74 } else { 75 $server_hash = $servers[0]['server_hash']; 76 } 64 77 $response = null; 65 78 $query_key = ""; … … 80 93 } 81 94 82 $variable s= array();95 $variable = array(); 83 96 84 97 if($response != null) { 85 $variable = array();86 98 $variable['mls_id'] = $response['mls_id']; 87 99 foreach($response['fields'] as $key => $field) { … … 95 107 } 96 108 97 public function run_search($params, $limit, $num_photos, $ orderby = "", $sort_order = "", $sort_option = "", $cache = false, $cache_duration = 4) {109 public function run_search($params, $limit, $num_photos, $server_num, $orderby = "", $sort_order = "", $sort_option = "", $cache = false, $cache_duration = 4) { 98 110 $client = new Client($this->access_token, true); 99 111 $this->_getAPIEndpoint($client); 100 112 101 113 $servers = $client->getServers(); 102 $server_hash = $servers[0]['server_hash']; //dangerous, need to adjust this 114 if(isset($servers[$server_num])) { 115 $server_hash = $servers[$server_num]['server_hash']; //dangerous, need to adjust this 116 } else { 117 $server_hash = $servers[0]['server_hash']; 118 } 119 103 120 $response = null; 104 121 $query_key = ""; … … 120 137 } 121 138 122 123 139 $variables = array(); 124 140 … … 127 143 $variables['total_records'] = $this->total_records; 128 144 $variables['params'] = $params; 145 $results = []; 129 146 130 147 if (is_array($response['results']) || is_object($response['results'])){ … … 139 156 140 157 $variable = $this->_photo_array_builder($listing, $variable, $num_photos); 141 $variables[] = $variable; 142 } 143 } 158 $results[] = $variable; 159 } 160 } 161 162 $variables['results'] = $results; 144 163 145 164 return $variables; -
rets-rabbit/trunk/rr_shortcodes.php
r1437341 r1465597 13 13 $cache = (isset($atts['cache']) ? $atts['cache'] : false); 14 14 $cache_duration = (isset($atts['cache_duration']) ? $atts['cache_duration'] : 4); 15 $server_num = intval((isset($atts['server_num']) ? $atts['server_num'] : 0)); 16 $params = json_decode($atts['params'], true); 17 18 foreach($params as $key => $param) { 19 if(strpos($key, ":escapedash") > -1) { 20 unset($params[$key]); 21 $key = str_replace(":escapedash", "", $key); 15 22 16 $params = json_decode($atts['params'], true); 23 if (strpos($param, "|") > -1) { 24 $values = explode("|", $param); 25 $param_array = []; 26 foreach ($values as $value) { 27 $param_array[] = "'" . $value . "'"; 28 } 29 $params[$key] = implode("|", $param_array); 30 } else { 31 $params[$key] = "'" . $param . "'"; 32 } 33 } 34 } 35 17 36 18 37 $rr_adapter = new rr_adapter(); 19 $results = $rr_adapter->run_search($params, $limit, $num_photos, $ orderby, $sort_order, $cache, $cache_duration);38 $results = $rr_adapter->run_search($params, $limit, $num_photos, $server_num, $orderby, $sort_order, $cache, $cache_duration); 20 39 //$results = $response->results; 21 40 return $rr_adapter->parse($results, $template, $paginate, $limit); … … 29 48 $cache = (isset($atts['cache']) ? $atts['cache'] : false); 30 49 $cache_duration = (isset($atts['cache_duration']) ? $atts['cache_duration'] : 4); 50 $server_num = intval((isset($atts['server_num']) ? $atts['server_num'] : 0)); 51 31 52 32 53 if(!$mls_id = get_query_var('mls_id')) … … 34 55 35 56 $rr_adapter = new rr_adapter(); 36 $result = $rr_adapter->get_listing($mls_id, $ num_photos, $cache, $cache_duration);57 $result = $rr_adapter->get_listing($mls_id, $server_num, $num_photos, $cache, $cache_duration); 37 58 return $rr_adapter->parse_single($result, $template); 38 59 } … … 87 108 $cache = (isset($atts['cache']) ? $atts['cache'] : false); 88 109 $cache_duration = (isset($atts['cache_duration']) ? $atts['cache_duration'] : 4); 110 $server_num = intval((isset($atts['server_num']) ? $atts['server_num'] : 0)); 89 111 90 112 $key = (isset($_GET['key']) ? $_GET['key'] : ''); … … 103 125 if($params != null && sizeof($params) > 0) { 104 126 $rr_adapter = new rr_adapter(); 105 $results = $rr_adapter->run_search($params, $limit, $num_photos, $ orderby, $sort_order, $sort_option, $cache, $cache_duration);127 $results = $rr_adapter->run_search($params, $limit, $num_photos, $server_num, $orderby, $sort_order, $sort_option, $cache, $cache_duration); 106 128 107 129 return $rr_adapter->parse($results, $template, $paginate, $limit); -
rets-rabbit/trunk/settings.php
r1437341 r1465597 99 99 $table_data = array(); 100 100 101 $types = $rr_adapter->metadata(); 101 $servers = $rr_adapter->get_servers(); 102 $x = 0; 103 $filter_html = ""; 104 $filter_html .= "<h2>Select Servers</h2>"; 105 $filter_html .= "<form method='POST' action=''>"; 106 $filter_html .= "<label for='server'>Servers</label>"; 107 $filter_html .= "<select name='server' id='server'>"; 108 109 $selected_server = (isset($_POST['server']) ? $_POST['server'] : ''); 110 foreach ($servers as $server) { 111 $selected = ""; 112 if($selected_server == $server['server_hash']) { 113 $selected = " selected "; 114 } 115 $filter_html .= "<option value='".$server['server_hash']."'".$selected.">".$x." - ".$server['name']."</option>"; 116 $x++; 117 } 118 $filter_html .= "</select>"; 119 $filter_html .= "<input type='submit' value='Submit'>"; 120 $filter_html .= "</form>"; 121 122 echo($filter_html); 123 124 $types = $rr_adapter->metadata($selected_server); 102 125 103 126 if(sizeof($types) == 0)
Note: See TracChangeset
for help on using the changeset viewer.