X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FGeonames%2FGeonamesPlugin.php;h=ff9192283f62ccf73b15c07e8a8769c5f6cf1ac0;hb=f85aa41adccb3c94cf5f2e4db18efc1e48a9277e;hp=3815a31fa681d90ed8b1fb8782f4791918bd18f4;hpb=95b534c5cee56602dffcc11121908c0f518cab6d;p=quix0rs-gnu-social.git diff --git a/plugins/Geonames/GeonamesPlugin.php b/plugins/Geonames/GeonamesPlugin.php index 3815a31fa6..ff9192283f 100644 --- a/plugins/Geonames/GeonamesPlugin.php +++ b/plugins/Geonames/GeonamesPlugin.php @@ -46,7 +46,6 @@ if (!defined('STATUSNET')) { * * @seeAlso Location */ - class GeonamesPlugin extends Plugin { const LOCATION_NS = 1; @@ -71,7 +70,6 @@ class GeonamesPlugin extends Plugin * * @return boolean whether to continue (results in $location) */ - function onLocationFromName($name, $language, &$location) { $loc = $this->getCache(array('name' => $name, @@ -129,7 +127,6 @@ class GeonamesPlugin extends Plugin * * @return boolean whether to continue (results in $location) */ - function onLocationFromId($id, $ns, $language, &$location) { if ($ns != self::LOCATION_NS) { @@ -198,7 +195,6 @@ class GeonamesPlugin extends Plugin * * @return boolean whether to continue (results in $location) */ - function onLocationFromLatLon($lat, $lon, $language, &$location) { // Make sure they're canonical @@ -276,7 +272,6 @@ class GeonamesPlugin extends Plugin * * @return boolean whether to continue */ - function onLocationNameLanguage($location, $language, &$name) { if ($location->location_ns != self::LOCATION_NS) { @@ -344,7 +339,6 @@ class GeonamesPlugin extends Plugin * * @return boolean whether to continue */ - function onLocationUrl($location, &$url) { if ($location->location_ns != self::LOCATION_NS) { @@ -368,7 +362,6 @@ class GeonamesPlugin extends Plugin * * @return boolean whether to continue */ - function onLocationRdfUrl($location, &$url) { if ($location->location_ns != self::LOCATION_NS) { @@ -384,7 +377,7 @@ class GeonamesPlugin extends Plugin function getCache($attrs) { - $c = common_memcache(); + $c = Cache::instance(); if (empty($c)) { return null; @@ -399,7 +392,7 @@ class GeonamesPlugin extends Plugin function setCache($attrs, $loc) { - $c = common_memcache(); + $c = Cache::instance(); if (empty($c)) { return null; @@ -416,11 +409,11 @@ class GeonamesPlugin extends Plugin { $key = 'geonames:' . implode(',', array_keys($attrs)) . ':'. - common_keyize(implode(',', array_values($attrs))); + Cache::keyize(implode(',', array_values($attrs))); if ($this->cachePrefix) { return $this->cachePrefix . ':' . $key; } else { - return common_cache_key($key); + return Cache::key($key); } } @@ -442,7 +435,8 @@ class GeonamesPlugin extends Plugin function getGeonames($method, $params) { if ($this->lastTimeout && (time() - $this->lastTimeout < $this->timeoutWindow)) { - throw new Exception("skipping due to recent web service timeout"); + // TRANS: Exception thrown when a geo names service is not used because of a recent timeout. + throw new Exception(_m('Skipping due to recent web service timeout.')); } $client = HTTPClient::start(); @@ -458,13 +452,16 @@ class GeonamesPlugin extends Plugin } if (!$result->isOk()) { - throw new Exception("HTTP error code " . $result->getStatus()); + // TRANS: Exception thrown when a geo names service does not return an expected response. + // TRANS: %s is an HTTP error code. + throw new Exception(sprintf(_m('HTTP error code %s.'),$result->getStatus())); } $body = $result->getBody(); if (empty($body)) { - throw new Exception("Empty HTTP body in response"); + // TRANS: Exception thrown when a geo names service returns an empty body. + throw new Exception(_m('Empty HTTP body in response.')); } // This will throw an exception if the XML is mal-formed @@ -480,7 +477,9 @@ class GeonamesPlugin extends Plugin } if (isset($document->status)) { - throw new Exception("Error #".$document->status['value']." ('".$document->status['message']."')"); + // TRANS: Exception thrown when a geo names service return a specific error number and error text. + // TRANS: %1$s is an error code, %2$s is an error message. + throw new Exception(sprintf(_m('Error #%1$s ("%2$s").'),$document->status['value'],$document->status['message'])); } // Array of elements, >0 elements @@ -488,13 +487,14 @@ class GeonamesPlugin extends Plugin return $document->geoname; } - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'Geonames', - 'version' => STATUSNET_VERSION, + 'version' => GNUSOCIAL_VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Geonames', 'rawdescription' => + // TRANS: Plugin description. _m('Uses Geonames service to get human-readable '. 'names for locations based on user-provided lat/long pairs.')); return true;