PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
wp-google-maps
/
includes
<?php namespace WPGMZA; class Feature extends Crud { private static $cachedSubclasses; public static function isTypeSpatial($type) { $type = strtolower(preg_replace('/\(\d+\)$/', '', $type)); switch($type) { case 'geometry': case 'point': case 'linestring': case 'polygon': case 'multipoint': case 'multilinestring': case 'multipolygon': case 'geometrycollection': return true; break; default: break; } return false; } public static function getSubclasses() { if(Feature::$cachedSubclasses) return Feature::$cachedSubclasses; foreach(glob(__DIR__ . '/*.php') as $file){ if(basename($file) === 'class.dom-element.php'){ continue; } require_once($file); } /* Developer Hook (Action) - Load required feature classes */ do_action('wpgmza_require_feature_classes'); foreach(get_declared_classes() as $class) { if(!is_subclass_of($class, 'WPGMZA\\Feature')) continue; $reflection = new \ReflectionClass($class); if(preg_match('/^Pro/', $reflection->getShortName())) continue; Feature::$cachedSubclasses[] = $reflection->getShortName(); } return Feature::$cachedSubclasses; } public static function getBulkReadColumns($table) { global $wpgmza; $columns = array(); foreach(Crud::getColumnsByTableName($table) as $obj) { if(Feature::isTypeSpatial($obj->Type)) $columns[] = "{$wpgmza->spatialFunctionPrefix}AsText(`{$obj->Field}`) AS {$obj->Field}"; else $columns[] = "`{$obj->Field}`"; } return $columns; } public static function convertSpatialTextToJson($text) { if(preg_match_all('/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/', $text, $m) === false) throw new \Exception('Invalid spatial data, no coordinates found'); $floats = $m[0]; $count = count($floats); if($count % 2 == 1) throw new \Exception('Invalid spatial data, odd number of coordinates found'); if(preg_match('/^POINT/i', $text) || $count == 2) { if(count($floats) != 2) throw new \Exception('Invalid number of coordinates found in point data'); $result = array( 'lat' => $floats[0], 'lng' => $floats[1] ); } else { $result = array(); for($i = 0; $i < $count; $i += 2) { $result[] = array( 'lat' => $floats[$i], 'lng' => $floats[$i + 1] ); } } return $result; } protected function getReadColumns() { global $wpgmza; $columns = $this->get_columns(); $result = array(); foreach($columns as $key => $definition) { if(Feature::isTypeSpatial($definition->Type)) $result[] = "{$wpgmza->spatialFunctionPrefix}AsText({$definition->Field}) AS {$definition->Field}"; else $result[] = $definition->Field; } return $result; } protected function get_placeholder_by_type($type) { global $wpgmza; switch($type) { case 'geometry': case 'point': case 'linestring': case 'polygon': case 'multipoint': case 'multilinestring': case 'multipolygon': case 'geometrycollection': return "{$wpgmza->spatialFunctionPrefix}GeomFromText(%s)"; break; default: break; } return Crud::get_placeholder_by_type($type); } public function jsonSerialize() { $json = Crud::jsonSerialize(); $columns = $this->get_columns_by_name(); foreach($json as $key => $value) { switch($key) { case 'dataset': case 'polydata': // NB: Legacy field support try{ $json[$key] = $this->convertSpatialTextToJson($value); } catch(\Exception $ex){ /* * This was added for legacy shape fallback, when the dataset is corrupted * Prevents bad spatial data from breaking the map editor * Added: 2021-01-22 */ $json[$key] = null; } break; default: if(isset($columns[$key]) && $this->isTypeSpatial($columns[$key]->Type)) { $converted = $this->convertSpatialTextToJson($value); $json[$key] = $converted; } break; } } return $json; } }
[-] class.admin-ui.php
[edit]
[+]
3rd-party-integration
[-] class.latlng.php
[edit]
[-] class.map.php
[edit]
[-] class.admin-notices.php
[edit]
[-] class.dom-query-results.php
[edit]
[-] class.pointlabel.php
[edit]
[-] class.upgrader.php
[edit]
[-] class.map-list-page.php
[edit]
[-] class.integrity-checker.php
[edit]
[-] class.dom-document.php
[edit]
[-] class.crud.php
[edit]
[+]
styling
[-] class.dynamic-translations.php
[edit]
[-] class.strings.php
[edit]
[-] class.library-script-panel.php
[edit]
[+]
open-layers
[-] class.maps-engine-dialog.php
[edit]
[+]
compat
[-] class.plugin.php
[edit]
[-] class.theme-panel.php
[edit]
[-] class.global-settings.php
[edit]
[+]
google-maps
[-] class.query.php
[edit]
[-] class.modal-dialog.php
[edit]
[-] class.script-loader.php
[edit]
[-] class.internal-engine.php
[edit]
[-] class.selector-to-xpath.php
[edit]
[-] class.polygon.php
[edit]
[-] class.rectangle.php
[edit]
[-] class.system-info.php
[edit]
[-] class.shortcodes.php
[edit]
[-] class.gdpr-compliance.php
[edit]
[+]
php8
[-] build.log
[edit]
[+]
tables
[-] class.polyline.php
[edit]
[-] class.settings.php
[edit]
[-] class.store-locator.php
[edit]
[-] class.country-select.php
[edit]
[-] class.settings-page.php
[edit]
[-] class.dom-element.php
[edit]
[+]
..
[-] class.elias-fano.php
[edit]
[-] class.distance.php
[edit]
[-] class.auto-loader.php
[edit]
[-] class.circle.php
[edit]
[-] class.page.php
[edit]
[-] class.component-anchor-control.php
[edit]
[+]
map-edit-page
[-] class.feature.php
[edit]
[-] class.marker.php
[edit]
[-] class.database.php
[edit]
[-] class.marker-filter.php
[edit]
[-] class.google-maps-api-loader.php
[edit]
[-] class.factory.php
[edit]
[+]
legacy
[-] class.installer-page.php
[edit]
[-] class.query-fragment.php
[edit]