Change <? to <?php and add some formatting
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
class weather extends Module {
|
||||
|
||||
class weather extends Module
|
||||
{
|
||||
|
||||
protected $moduleTitle = 'Météo';
|
||||
|
||||
@@ -16,15 +18,17 @@ class weather extends Module {
|
||||
|
||||
public function build(){
|
||||
$ville = $this->getParam('city');
|
||||
$future_weather = [];
|
||||
include $this->pathToModule.'includes/GoogleMeteo.php';
|
||||
echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
|
||||
if (!empty($present_weather)) {
|
||||
echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css">';
|
||||
echo '<div id="weather" style="left:'.$this->getParam("x").'; top:'.$this->getParam("y").';">
|
||||
'.$city.'<br/>
|
||||
echo '<div id="weather" style="left:'.$this->getParam("x").'; top:'.$this->getParam("y").';">
|
||||
'.$ville.'<br/>
|
||||
<div class="weatherpic"></div>
|
||||
<strong>'.$present_weather.'</strong><br/>
|
||||
'.$future_weather1.'<br/>
|
||||
'.$future_weather2.'
|
||||
</div>';
|
||||
'.implode('<br/>', $future_weather).'
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,38 +1,45 @@
|
||||
<?php
|
||||
require('class/GoogleWeather.class.php');
|
||||
|
||||
//ça récupère un truc du style : http://www.google.com/ig/api?weather=paris&hl=fr
|
||||
if($ville != '' || $ville != null){
|
||||
$gweather = new GoogleWeatherAPI($ville,'fr');
|
||||
|
||||
if($gweather->isFound()) {
|
||||
$city = $gweather->getCity();
|
||||
$currentTemp = $gweather->getCurrent();
|
||||
$forecastTemp = $gweather->getForecast();
|
||||
|
||||
$present_weather = 'Actuellement : '.$currentTemp['temp_c'].'°C - '.$currentTemp['condition'];
|
||||
$i=0;
|
||||
foreach($forecastTemp as $temp) {
|
||||
${'future_weather'.$i} = $temp['day_of_week'].' : '.$temp['low'].'°C | '.$temp['high'].'°C - '.$temp['condition'];
|
||||
$i++;
|
||||
}
|
||||
require('class/GoogleWeather.class.php');
|
||||
$present_weather = null;
|
||||
//ça récupère un truc du style : http://www.google.com/ig/api?weather=paris&hl=fr
|
||||
if ( !empty($ville) ) {
|
||||
$google_weather = new GoogleWeatherAPI($ville, 'fr');
|
||||
|
||||
if(strpos(strtolower($present_weather),"soleil") !== false) {?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/soleil.css">
|
||||
<?}
|
||||
if(strpos(strtolower($present_weather),"nuage") !== false) {?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/nuage.css">
|
||||
<?}
|
||||
if(strpos(strtolower($present_weather),"peu nuageux") !== false) {?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/peunuage.css">
|
||||
<?}
|
||||
if((strpos(strtolower($present_weather),"pluie") !== false) || (strpos(strtolower($present_weather),"averse") !== false)) {?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/pluie.css">
|
||||
<?}
|
||||
if(strpos(strtolower($present_weather),"neige") !== false) {?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/neige.css">
|
||||
<?}
|
||||
}else{ $present_weather = 'Ville non trouvé : '.$city; }
|
||||
}else
|
||||
$present_weather = 'Ville non renseignée';
|
||||
|
||||
if ($google_weather->isFound()) {
|
||||
$city = $google_weather->getCity();
|
||||
$currentTemp = $google_weather->getCurrent();
|
||||
$forecastTemp = $google_weather->getForecast();
|
||||
|
||||
$present_weather = 'Actuellement : ' . $currentTemp['temp_c'] . '°C - ' . $currentTemp['condition'];
|
||||
$future_weather = [];
|
||||
foreach ($forecastTemp as $temp) {
|
||||
$future_weather[] = $temp['day_of_week'] . ' : ' . $temp['low'] . '°C | ' . $temp['high'] . '°C - ' . $temp['condition'];
|
||||
}
|
||||
|
||||
if (strpos(strtolower($present_weather), "soleil") !== false) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/soleil.css">
|
||||
<?php
|
||||
}
|
||||
if (strpos(strtolower($present_weather), "nuage") !== false) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/nuage.css">
|
||||
<?php
|
||||
}
|
||||
if (strpos(strtolower($present_weather), "peu nuageux") !== false) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/peunuage.css">
|
||||
<?php
|
||||
}
|
||||
if ((strpos(strtolower($present_weather), "pluie") !== false) || (strpos(strtolower($present_weather), "averse") !== false)) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/pluie.css">
|
||||
<?php
|
||||
}
|
||||
if (strpos(strtolower($present_weather), "neige") !== false) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="modules/weather/css/neige.css">
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
$present_weather = 'Ville non trouvé : ' . $ville;
|
||||
}
|
||||
} else {
|
||||
$present_weather = 'Ville non renseignée';
|
||||
}
|
||||
|
Reference in New Issue
Block a user