Файловый менеджер - Редактировать - /home/lmsyaran/public_html/pusher/openstreetmap.tar
Назад
changesets.php 0000644 00000015326 15117053013 0007404 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); /** * Openstreetmap API Changesets class for the Joomla Platform * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmapChangesets extends JOpenstreetmapObject { /** * Method to create a changeset * * @param array $changesets Array which contains changeset data * * @return array The XML response * * @since 3.2.0 */ public function createChangeset($changesets=array()) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], 'oauth_token_secret' => $token['secret'], ); // Set the API base $base = 'changeset/create'; // Build the request path. $path = $this->getOption('api.url') . $base; $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap">'; if (!empty($changesets)) { // Create Changeset element for every changeset foreach ($changesets as $tags) { $xml .= '<changeset>'; if (!empty($tags)) { // Create a list of tags for each changeset foreach ($tags as $key => $value) { $xml .= '<tag k="' . $key . '" v="' . $value . '"/>'; } } $xml .= '</changeset>'; } } $xml .= '</osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); return $response->body; } /** * Method to read a changeset * * @param integer $id identifier of the changeset * * @return array The XML response about a changeset * * @since 3.2.0 */ public function readChangeset($id) { // Set the API base $base = 'changeset/' . $id; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->changeset; } /** * Method to update a changeset * * @param integer $id Identifier of the changeset * @param array $tags Array of tags to update * * @return array The XML response of updated changeset * * @since 3.2.0 */ public function updateChangeset($id, $tags = array()) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'changeset/' . $id; // Build the request path. $path = $this->getOption('api.url') . $base; // Create a list of tags to update changeset $tag_list = ''; if (!empty($tags)) { foreach ($tags as $key => $value) { $tag_list .= '<tag k="' . $key . '" v="' . $value . '"/>'; } } $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <changeset>' . $tag_list . '</changeset> </osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); $xml_string = simplexml_load_string($response->body); return $xml_string->changeset; } /** * Method to close a changeset * * @param integer $id identifier of the changeset * * @return void * * @since 3.2.0 */ public function closeChangeset($id) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'changeset/' . $id . '/close'; // Build the request path. $path = $this->getOption('api.url') . $base; $header['format'] = 'text/xml'; // Send the request. $this->oauth->oauthRequest($path, 'PUT', $parameters, $header); } /** * Method to download a changeset * * @param integer $id Identifier of the changeset * * @return array The XML response of requested changeset * * @since 3.2.0 */ public function downloadChangeset($id) { // Set the API base $base = 'changeset/' . $id . '/download'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->create; } /** * Method to expand the bounding box of a changeset * * @param integer $id Identifier of the changeset * @param array $nodes List of lat lon about nodes * * @return array The XML response of changed changeset * * @since 3.2.0 */ public function expandBBoxChangeset($id, $nodes) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'changeset/' . $id . '/expand_bbox'; // Build the request path. $path = $this->getOption('api.url') . $base; // Create a list of tags to update changeset $node_list = ''; if (!empty($nodes)) { foreach ($nodes as $node) { $node_list .= '<node lat="' . $node[0] . '" lon="' . $node[1] . '"/>'; } } $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <changeset>' . $node_list . '</changeset> </osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); $xml_string = simplexml_load_string($response->body); return $xml_string->changeset; } /** * Method to query on changesets * * @param string $param Parameters for query * * @return array The XML response * * @since 3.2.0 */ public function queryChangeset($param) { // Set the API base $base = 'changesets/' . $param; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->osm; } /** * Method to upload a diff to a changeset * * @param string $xml Diff data to upload * @param integer $id Identifier of the changeset * * @return array The XML response of result * * @since 3.2.0 */ public function diffUploadChangeset($xml, $id) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'changeset/' . $id . '/upload'; // Build the request path. $path = $this->getOption('api.url') . $base; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); $xml_string = simplexml_load_string($response->body); return $xml_string->diffResult; } } elements.php 0000644 00000032325 15117053014 0007073 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); /** * Openstreetmap API Elements class for the Joomla Platform * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmapElements extends JOpenstreetmapObject { /** * Method to create a node * * @param integer $changeset Changeset id * @param float $latitude Latitude of the node * @param float $longitude Longitude of the node * @param array $tags Array of tags for a node * * @return array The XML response * * @since 3.2.0 */ public function createNode($changeset, $latitude, $longitude, $tags) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'node/create'; // Build the request path. $path = $this->getOption('api.url') . $base; $tag_list = ''; // Create XML node if (!empty($tags)) { foreach ($tags as $key => $value) { $tag_list .= '<tag k="' . $key . '" v="' . $value . '"/>'; } } $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <node changeset="' . $changeset . '" lat="' . $latitude . '" lon="' . $longitude . '">' . $tag_list . '</node> </osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); return $response->body; } /** * Method to create a way * * @param integer $changeset Changeset id * @param array $tags Array of tags for a way * @param array $nds Node ids to refer * * @return array The XML response * * @since 3.2.0 */ public function createWay($changeset, $tags, $nds) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'way/create'; // Build the request path. $path = $this->getOption('api.url') . $base; $tag_list = ''; // Create XML node if (!empty($tags)) { foreach ($tags as $key => $value) { $tag_list .= '<tag k="' . $key . '" v="' . $value . '"/>'; } } $nd_list = ''; if (!empty($nds)) { foreach ($nds as $value) { $nd_list .= '<nd ref="' . $value . '"/>'; } } $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <way changeset="' . $changeset . '">' . $tag_list . $nd_list . '</way> </osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); return $response->body; } /** * Method to create a relation * * @param integer $changeset Changeset id * @param array $tags Array of tags for a relation * @param array $members Array of members for a relation * eg: $members = array(array("type"=>"node", "role"=>"stop", "ref"=>"123"), array("type"=>"way", "ref"=>"123")) * * @return array The XML response * * @since 3.2.0 */ public function createRelation($changeset, $tags, $members) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'relation/create'; // Build the request path. $path = $this->getOption('api.url') . $base; $tag_list = ''; // Create XML node if (!empty($tags)) { foreach ($tags as $key => $value) { $tag_list .= '<tag k="' . $key . '" v="' . $value . '"/>'; } } // Members $member_list = ''; if (!empty($members)) { foreach ($members as $member) { if ($member['type'] == 'node') { $member_list .= '<member type="' . $member['type'] . '" role="' . $member['role'] . '" ref="' . $member['ref'] . '"/>'; } elseif ($member['type'] == 'way') { $member_list .= '<member type="' . $member['type'] . '" ref="' . $member['ref'] . '"/>'; } } } $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <relation relation="' . $changeset . '" >' . $tag_list . $member_list . '</relation> </osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); return $response->body; } /** * Method to read an element [node|way|relation] * * @param string $element [node|way|relation] * @param integer $id Element identifier * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function readElement($element, $id) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } // Set the API base $base = $element . '/' . $id; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->$element; } /** * Method to update an Element [node|way|relation] * * @param string $element [node|way|relation] * @param string $xml Full reperentation of the element with a version number * @param integer $id Element identifier * * @return array The xml response * * @since 3.2.0 * @throws DomainException */ public function updateElement($element, $xml, $id) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = $element . '/' . $id; // Build the request path. $path = $this->getOption('api.url') . $base; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); return $response->body; } /** * Method to delete an element [node|way|relation] * * @param string $element [node|way|relation] * @param integer $id Element identifier * @param integer $version Element version * @param integer $changeset Changeset identifier * @param float $latitude Latitude of the element * @param float $longitude Longitude of the element * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function deleteElement($element, $id, $version, $changeset, $latitude = null, $longitude = null) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = $element . '/' . $id; // Build the request path. $path = $this->getOption('api.url') . $base; // Create xml $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <' . $element . ' id="' . $id . '" version="' . $version . '" changeset="' . $changeset . '"'; if (!empty($latitude) && !empty($longitude)) { $xml .= ' lat="' . $latitude . '" lon="' . $longitude . '"'; } $xml .= '/></osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters, $xml, $header); return $response->body; } /** * Method to get history of an element [node|way|relation] * * @param string $element [node|way|relation] * @param integer $id Element identifier * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function historyOfElement($element, $id) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } // Set the API base $base = $element . '/' . $id . '/history'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->$element; } /** * Method to get details about a version of an element [node|way|relation] * * @param string $element [node|way|relation] * @param integer $id Element identifier * @param integer $version Element version * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function versionOfElement($element, $id, $version) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } // Set the API base $base = $element . '/' . $id . '/' . $version; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->$element; } /** * Method to get data about multiple ids of an element [node|way|relation] * * @param string $element [nodes|ways|relations] - use plural word * @param string $params Comma separated list of ids belonging to type $element * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function multiFetchElements($element, $params) { if ($element != 'nodes' && $element != 'ways' && $element != 'relations') { throw new DomainException('Element should be nodes, ways or relations'); } // Get singular word $single_element = substr($element, 0, strlen($element) - 1); // Set the API base, $params is a string with comma separated values $base = $element . '?' . $element . '=' . $params; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->$single_element; } /** * Method to get relations for an Element [node|way|relation] * * @param string $element [node|way|relation] * @param integer $id Element identifier * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function relationsForElement($element, $id) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } // Set the API base $base = $element . '/' . $id . '/relations'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->$element; } /** * Method to get ways for a Node element * * @param integer $id Node identifier * * @return array The XML response * * @since 3.2.0 */ public function waysForNode($id) { // Set the API base $base = 'node/' . $id . '/ways'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->way; } /** * Method to get full information about an element [way|relation] * * @param string $element [way|relation] * @param integer $id Identifier * * @return array The XML response * * @since 3.2.0 * @throws DomainException */ public function fullElement($element, $id) { if ($element != 'way' && $element != 'relation') { throw new DomainException('Element should be a way or a relation'); } // Set the API base $base = $element . '/' . $id . '/full'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path); return $xml_string->node; } /** * Method used by the DWG to hide old versions of elements containing data privacy or copyright infringements * * @param string $element [node|way|relation] * @param integer $id Element identifier * @param integer $version Element version * @param integer $redactionId Redaction id * * @return array The xml response * * @since 3.2.0 * @throws DomainException */ public function redaction($element, $id, $version, $redactionId) { if ($element != 'node' && $element != 'way' && $element != 'relation') { throw new DomainException('Element should be a node, a way or a relation'); } $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = $element . '/' . $id . '/' . $version . '/redact?redaction=' . $redactionId; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters); $xml_string = simplexml_load_string($response->body); return $xml_string; } } gps.php 0000644 00000007437 15117053014 0006056 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); /** * Openstreetmap API GPS class for the Joomla Platform * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmapGps extends JOpenstreetmapObject { /** * Method to retrieve GPS points * * @param float $left Left boundary * @param float $bottom Bottom boundary * @param float $right Right boundary * @param float $top Top boundary * @param integer $page Page number * * @return array The XML response containing GPS points * * @since 3.2.0 */ public function retrieveGps($left, $bottom, $right, $top, $page = 0) { // Set the API base $base = 'trackpoints?bbox=' . $left . ',' . $bottom . ',' . $right . ',' . $top . '&page=' . $page; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'GET', array()); $xml_string = simplexml_load_string($response->body); return $xml_string; } /** * Method to upload GPS Traces * * @param string $file File name that contains trace points * @param string $description Description on trace points * @param string $tags Tags for trace * @param integer $public 1 for public, 0 for private * @param string $visibility One of the following: private, public, trackable, identifiable * @param string $username Username * @param string $password Password * * @return JHttpResponse The response * * @since 3.2.0 */ public function uploadTrace($file, $description, $tags, $public, $visibility, $username, $password) { // Set parameters. $parameters = array( 'file' => $file, 'description' => $description, 'tags' => $tags, 'public' => $public, 'visibility' => $visibility, ); // Set the API base $base = 'gpx/create'; // Build the request path. $path = $this->getOption('api.url') . $base; $header['Content-Type'] = 'multipart/form-data'; $header = array_merge($header, $parameters); $header = array_merge($header, array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password))); // Send the request. $response = $this->sendRequest($path, 'POST', $header, array()); return $response; } /** * Method to download Trace details * * @param integer $id Trace identifier * @param string $username Username * @param string $password Password * * @return array The XML response * * @since 3.2.0 */ public function downloadTraceMetadetails($id, $username, $password) { // Set the API base $base = 'gpx/' . $id . '/details'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password))); return $xml_string; } /** * Method to download Trace data * * @param integer $id Trace identifier * @param string $username Username * @param string $password Password * * @return array The XML response * * @since 3.2.0 */ public function downloadTraceMetadata($id, $username, $password) { // Set the API base $base = 'gpx/' . $id . '/data'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $xml_string = $this->sendRequest($path, 'GET', array('Authorization' => 'Basic ' . base64_encode($username . ':' . $password))); return $xml_string; } } info.php 0000644 00000004131 15117053014 0006204 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); /** * Openstreetmap API Info class for the Joomla Platform * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmapInfo extends JOpenstreetmapObject { /** * Method to get capabilities of the API * * @return array The XML response * * @since 3.2.0 */ public function getCapabilities() { // Set the API base $base = 'capabilities'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'GET', array()); $xml_string = simplexml_load_string($response->body); return $xml_string; } /** * Method to retrieve map data of a bounding box * * @param float $left Left boundary * @param float $bottom Bottom boundary * @param float $right Right boundary * @param float $top Top boundary * * @return array The XML response * * @since 3.2.0 */ public function retrieveMapData($left, $bottom, $right, $top) { // Set the API base $base = 'map?bbox=' . $left . ',' . $bottom . ',' . $right . ',' . $top; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'GET', array()); $xml_string = simplexml_load_string($response->body); return $xml_string; } /** * Method to retrieve permissions for current user * * @return array The XML response * * @since 3.2.0 */ public function retrievePermissions() { // Set the API base $base = 'permissions'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'GET', array()); $xml_string = simplexml_load_string($response->body); return $xml_string; } } oauth.php 0000644 00000004726 15117053014 0006403 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); use Joomla\Registry\Registry; /** * Joomla Platform class for generating Openstreetmap API access token. * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmapOauth extends JOAuth1Client { /** * Options for the JOpenstreetmapOauth object. * * @var Registry * @since 3.2.0 */ protected $options; /** * Constructor. * * @param Registry $options JOpenstreetmapOauth options object. * @param JHttp $client The HTTP client object. * @param JInput $input The input object * * @since 3.2.0 */ public function __construct(Registry $options = null, JHttp $client = null, JInput $input = null) { $this->options = isset($options) ? $options : new Registry; $this->options->def('accessTokenURL', 'https://www.openstreetmap.org/oauth/access_token'); $this->options->def('authoriseURL', 'https://www.openstreetmap.org/oauth/authorize'); $this->options->def('requestTokenURL', 'https://www.openstreetmap.org/oauth/request_token'); /* $this->options->def('accessTokenURL', 'https://api06.dev.openstreetmap.org/oauth/access_token'); $this->options->def('authoriseURL', 'https://api06.dev.openstreetmap.org/oauth/authorize'); $this->options->def('requestTokenURL', 'https://api06.dev.openstreetmap.org/oauth/request_token'); */ // Call the JOauth1Client constructor to setup the object. parent::__construct($this->options, $client, $input, null, '1.0'); } /** * Method to verify if the access token is valid by making a request to an API endpoint. * * @return boolean Returns true if the access token is valid and false otherwise. * * @since 3.2.0 */ public function verifyCredentials() { return true; } /** * Method to validate a response. * * @param string $url The request URL. * @param JHttpResponse $response The response to validate. * * @return void * * @since 3.2.0 * @throws DomainException */ public function validateResponse($url, $response) { if ($response->code != 200) { $error = htmlspecialchars($response->body, ENT_COMPAT, 'UTF-8'); throw new DomainException($error, $response->code); } } } object.php 0000644 00000006101 15117053014 0006516 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); use Joomla\Registry\Registry; /** * Openstreetmap API object class for the Joomla Platform * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ abstract class JOpenstreetmapObject { /** * Options for the Openstreetmap object. * * @var Registry * @since 3.2.0 */ protected $options; /** * The HTTP client object to use in sending HTTP requests. * * @var JHttp * @since 3.2.0 */ protected $client; /** * The OAuth client. * * @var JOpenstreetmapOauth * @since 3.2.0 */ protected $oauth; /** * Constructor * * @param Registry &$options Openstreetmap options object. * @param JHttp $client The HTTP client object. * @param JOpenstreetmapOauth $oauth Openstreetmap oauth client * * @since 3.2.0 */ public function __construct(Registry &$options = null, JHttp $client = null, JOpenstreetmapOauth $oauth = null) { $this->options = isset($options) ? $options : new Registry; $this->client = isset($client) ? $client : new JHttp($this->options); $this->oauth = $oauth; } /** * Get an option from the JOpenstreetmapObject instance. * * @param string $key The name of the option to get. * * @return mixed The option value. * * @since 3.2.0 */ public function getOption($key) { return $this->options->get($key); } /** * Set an option for the JOpenstreetmapObject instance. * * @param string $key The name of the option to set. * @param mixed $value The option value to set. * * @return JOpenstreetmapObject This object for method chaining. * * @since 3.2.0 */ public function setOption($key, $value) { $this->options->set($key, $value); return $this; } /** * Method to send the request which does not require authentication. * * @param string $path The path of the request to make * @param string $method The request method. * @param array $headers The headers passed in the request. * @param mixed $data Either an associative array or a string to be sent with the post request. * * @return SimpleXMLElement The XML response * * @since 3.2.0 * @throws DomainException */ public function sendRequest($path, $method = 'GET', $headers = array(), $data = '') { // Send the request. switch ($method) { case 'GET': $response = $this->client->get($path, $headers); break; case 'POST': $response = $this->client->post($path, $data, $headers); break; } // Validate the response code. if ($response->code != 200) { $error = htmlspecialchars($response->body, ENT_COMPAT, 'UTF-8'); throw new DomainException($error, $response->code); } $xml_string = simplexml_load_string($response->body); return $xml_string; } } openstreetmap.php 0000644 00000006654 15117053014 0010153 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); use Joomla\Registry\Registry; /** * Joomla Platform class for interact with Openstreetmap API. * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmap { /** * Options for the Openstreetmap object. * * @var Registry * @since 3.2.0 */ protected $options; /** * The HTTP client object to use in sending HTTP requests. * * @var JHttp * @since 3.2.0 */ protected $client; /** * The OAuth client. * * @var JOpenstreetmapOauth * @since 3.2.0 */ protected $oauth; /** * Openstreetmap API object for changesets. * * @var JOpenstreetmapChangesets * @since 3.2.0 */ protected $changesets; /** * Openstreetmap API object for elements. * * @var JOpenstreetmapElements * @since 3.2.0 */ protected $elements; /** * Openstreetmap API object for GPS. * * @var JOpenstreetmapGps * @since 3.2.0 */ protected $gps; /** * Openstreetmap API object for info. * * @var JOpenstreetmapInfo * @since 3.2.0 */ protected $info; /** * Openstreetmap API object for user. * * @var JOpenstreetmapUser * @since 3.2.0 */ protected $user; /** * Constructor. * * @param JOpenstreetmapOauth $oauth Openstreetmap oauth client * @param Registry $options Openstreetmap options object * @param JHttp $client The HTTP client object * * @since 3.2.0 */ public function __construct(JOpenstreetmapOauth $oauth = null, Registry $options = null, JHttp $client = null) { $this->oauth = $oauth; $this->options = isset($options) ? $options : new Registry; $this->client = isset($client) ? $client : new JHttp($this->options); // Setup the default API url if not already set. $this->options->def('api.url', 'https://api.openstreetmap.org/api/0.6/'); // $this->options->def('api.url', 'https://api06.dev.openstreetmap.org/api/0.6/'); } /** * Method to get object instances * * @param string $name Name of property to retrieve * * @return JOpenstreetmapObject Openstreetmap API object * * @since 3.2.0 * @throws InvalidArgumentException */ public function __get($name) { $class = 'JOpenstreetmap' . ucfirst($name); if (class_exists($class)) { if (false == isset($this->$name)) { $this->$name = new $class($this->options, $this->client, $this->oauth); } return $this->$name; } throw new InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s', $name, $class)); } /** * Get an option from the JOpenstreetmap instance. * * @param string $key The name of the option to get. * * @return mixed The option value. * * @since 3.2.0 */ public function getOption($key) { return $this->options->get($key); } /** * Set an option for the Openstreetmap instance. * * @param string $key The name of the option to set. * @param mixed $value The option value to set. * * @return JOpenstreetmap This object for method chaining. * * @since 3.2.0 */ public function setOption($key, $value) { $this->options->set($key, $value); return $this; } } user.php 0000644 00000006324 15117053014 0006235 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Openstreetmap * * @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die(); /** * Openstreetmap API User class for the Joomla Platform * * @since 3.2.0 * @deprecated 4.0 Use the `joomla/openstreetmap` package via Composer instead */ class JOpenstreetmapUser extends JOpenstreetmapObject { /** * Method to get user details * * @return array The XML response * * @since 3.2.0 */ public function getDetails() { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'user/details'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'GET', $parameters); return $response->body; } /** * Method to get preferences * * @return array The XML response * * @since 3.2.0 */ public function getPreferences() { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'user/preferences'; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'GET', $parameters); return $response->body; } /** * Method to replace user preferences * * @param array $preferences Array of new preferences * * @return array The XML response * * @since 3.2.0 */ public function replacePreferences($preferences) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'user/preferences'; // Build the request path. $path = $this->getOption('api.url') . $base; // Create a list of preferences $preference_list = ''; if (!empty($preferences)) { foreach ($preferences as $key => $value) { $preference_list .= '<preference k="' . $key . '" v="' . $value . '"/>'; } } $xml = '<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="JOpenstreetmap"> <preferences>' . $preference_list . '</preferences> </osm>'; $header['Content-Type'] = 'text/xml'; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); return $response->body; } /** * Method to change user preferences * * @param string $key Key of the preference * @param string $preference New value for preference * * @return array The XML response * * @since 3.2.0 */ public function changePreference($key, $preference) { $token = $this->oauth->getToken(); // Set parameters. $parameters = array( 'oauth_token' => $token['key'], ); // Set the API base $base = 'user/preferences/' . $key; // Build the request path. $path = $this->getOption('api.url') . $base; // Send the request. $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $preference); return $response->body; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка