getRadarImageUrl() 공개 메소드

Return the URL to a (possibly animated) radar image.
public getRadarImageUrl ( string $location ) : string | boolean
$location string The location
리턴 string | boolean The Url, or false if not available.
예제 #1
0
파일: Weather.php 프로젝트: horde/horde
 /**
  */
 protected function _content()
 {
     global $injector, $language, $page_output, $prefs, $registry;
     // Set the requested units.
     $this->_weather->units = $this->_params['units'];
     $view = $injector->getInstance('Horde_View');
     if (!empty($this->_refreshParams) && !empty($this->_refreshParams->location)) {
         $location = $this->_refreshParams->location;
         $view->instance = '';
     } else {
         $view->instance = hash('md5', mt_rand());
         $injector->getInstance('Horde_Core_Factory_Imple')->create('WeatherLocationAutoCompleter_Weather', array('id' => 'location' . $view->instance, 'instance' => $view->instance));
         $view->requested_location = $this->_params['location'];
         $location = $this->_params['location'];
     }
     $view->units = $this->_weather->getUnits($this->_weather->units);
     $view->params = $this->_params;
     $view->link = $this->_weather->link;
     $view->title = $this->_weather->title;
     if ($this->_weather->logo) {
         $view->logo = $this->_weather->logo;
     }
     // Test location
     try {
         $view->location = $this->_weather->searchLocations($location);
     } catch (Horde_Service_Weather_Exception $e) {
         return $e->getMessage();
     } catch (Horde_Exception_NotFound $e) {
         return _(sprintf("Location %s not found."), $location);
     }
     try {
         $view->forecast = $this->_weather->getForecast($view->location->code, $this->_params['days']);
         $view->station = $this->_weather->getStation();
         $view->current = $this->_weather->getCurrentConditions($view->location->code);
         // @todo: Add link to put alert text in redbox.
         $view->timezone = $prefs->getValue('timezone');
         $view->dateFormat = $prefs->getValue('date_format');
         $view->timeFormat = $prefs->getValue('time_format');
         $view->alerts = $this->_weather->getAlerts($view->location->code);
         $view->radar = $this->_weather->getRadarImageUrl($location);
     } catch (Horde_Service_Weather_Exception $e) {
         return $e->getMessage();
     }
     $view->languageFilter = '/^' . $registry->nlsconfig->languages[$language] . ': /i';
     if (!empty($this->_params['showMap']) && !empty($view->instance)) {
         $view->map = true;
         $page_output->addScriptFile('weatherblockmap.js', 'horde');
         Horde_Core_HordeMap::init(array('providers' => array('owm', 'osm')));
         $page_output->addInlineScript(array('WeatherBlockMap.initializeMap("' . $view->instance . '", { lat: "' . $view->location->lat . '", lon: "' . $view->location->lon . '"});$("weathermaplayer_' . $view->instance . '").show();'), true);
     }
     if (!empty($view->instance)) {
         return $view->render('block/weather');
     } else {
         return $view->render('block/weather_content');
     }
 }