Changeset 1e37648 for src/webservice/htdocs/SiWeather
- Timestamp:
- Aug 28, 2015, 3:29:08 PM (11 years ago)
- Branches:
- master
- Children:
- b858e6f
- Parents:
- 851179e
- Location:
- src/webservice/htdocs/SiWeather/Webservice
- Files:
-
- 2 edited
-
Setup.php (modified) (4 diffs)
-
WebserviceConfig.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/webservice/htdocs/SiWeather/Webservice/Setup.php
r851179e r1e37648 306 306 307 307 public function apiCheckWithRewrite(&$errorMessage){ 308 $apiVersion = $this->_webserviceConfig->getConfig("webserviceApiVersion"); 309 if(!$apiVersion || empty($apiVersion)){ 310 $errorMessage = _("Could not determine API version"); 311 return false; 312 } 313 314 return $this->apiCheck($apiVersion ."/stations", $errorMessage); 308 return $this->apiCheck("stations", $errorMessage); 315 309 } 316 310 … … 326 320 327 321 private function apiCheck($url, &$errorMessage){ 328 $baseUrl = $this->_webserviceConfig-> getConfig("webserviceBaseUrl");322 $baseUrl = $this->_webserviceConfig->webserviceBaseUrl(); 329 323 if(!$baseUrl || empty($baseUrl)){ 330 324 $errorMessage = _("No webservice base url given!"); … … 332 326 } 333 327 328 # base_url needs to end with a /, otherwise the last element is chopped 334 329 $client = new \GuzzleHttp\Client 335 330 ( … … 347 342 $result = $response->getStatusCode(); 348 343 if($result != 200){ 349 $errorMessage = \Translator::swGettext("Got http error %s (%s) ", $result, $response->getReasonPhrase());344 $errorMessage = \Translator::swGettext("Got http error %s (%s) at url %s", $result, $response->getReasonPhrase(), $baseUrl ."/". $url); 350 345 return false; 351 346 } -
src/webservice/htdocs/SiWeather/Webservice/WebserviceConfig.php
r851179e r1e37648 24 24 25 25 function __construct(){ 26 require(__DIR__ ."/../../ config/config.php");26 require(__DIR__ ."/../../../config/config.php"); 27 27 $this->_config = $config; 28 28 $this->loadAdditionalConfiguration(); … … 35 35 private function loadAdditionalConfiguration(){ 36 36 $this->_config["dataDirectory"] = "data"; 37 38 require(__DIR__ ."/../../inc/internalconfig.php"); 39 foreach(array_keys($internalconfig) as $key){ 40 if(array_key_exists($key, $this->_config)){ 41 error_log("Internal config entry ". $key ." already exists --> Keeping existing value and discard internal config value"); 42 } 43 else{ 44 $this->_config[$key] = $internalconfig[$key]; 45 } 46 } 37 47 } 38 48 … … 47 57 return $this->dataDirectory(); 48 58 } 59 if($key == "webserviceBaseUrl"){ 60 // error_log("Use dataDirectory() function to access this value"); 61 return $this->webserviceBaseUrl(); 62 } 49 63 50 64 return $this->_config[$key]; … … 52 66 53 67 public function dataDirectory(){ 54 return __DIR__ ."/../../". $this->_config["dataDirectory"]; 68 return __DIR__ ."/../../../". $this->_config["dataDirectory"]; 69 } 70 71 public function webserviceBaseUrl(){ 72 $baseUrl = $this->_config["webserviceBaseUrl"]; 73 if(substr($baseUrl, strlen($baseUrl) - 1, 1) != "/"){ 74 $baseUrl .= "/"; 75 } 76 return $baseUrl; 55 77 } 56 78
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/siweather/chrome/site/your_project_logo.png)