Inserito meteo
This commit is contained in:
@@ -69,6 +69,8 @@ $config->files->gui_log = $config->paths->log . "/gui.log";
|
||||
$config->files->mail_log = $config->paths->log . "/mail.log";
|
||||
$config->files->api_log = $config->paths->log . "/api.log";
|
||||
|
||||
$config->files->meteoCache = $config->paths->tmp . "/meteo.json";
|
||||
|
||||
// Pages
|
||||
$config->pages = new StdClass();
|
||||
$config->pages->remoteLocationPath = $currentSystem->remoteLocationPath;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__). "/../load.php");
|
||||
|
||||
$tasks = array("NewsletterCheckTask","DeleteOldPasswordResetRequestsTask");
|
||||
$tasks = array("NewsletterCheckTask","DeleteOldPasswordResetRequestsTask", "UpdateMeteoCacheTask");
|
||||
|
||||
if (sizeof($tasks)>0){
|
||||
foreach ($tasks as $taskName){
|
||||
|
||||
@@ -33,6 +33,40 @@ class HTMLHelper {
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
public static function getMeteoBlock(){
|
||||
$config = GlobalVariables::get("config");
|
||||
$cont = file_get_contents($config->files->meteoCache);
|
||||
$json = json_decode($cont);
|
||||
|
||||
$todayImgUrl = " http://openweathermap.org/img/w/".$json->list[0]->weather[0]->icon.".png";
|
||||
$todayTemp = $json->list[0]->main->temp;
|
||||
$todayMax = $json->list[0]->main->temp_max;
|
||||
$todayMin = $json->list[0]->main->temp_min;
|
||||
|
||||
$tomorrowImgUrl = " http://openweathermap.org/img/w/".$json->list[1]->weather[0]->icon.".png";
|
||||
$tomorrowTemp = $json->list[1]->main->temp;
|
||||
$tomorrowMax = $json->list[1]->main->temp_max;
|
||||
$tomorrowMin = $json->list[1]->main->temp_min;
|
||||
|
||||
|
||||
?>
|
||||
<div class="meteoTitle">Meteo Napoli</div>
|
||||
<div class="meteo">
|
||||
<div class="today">
|
||||
<div class="day">Oggi</div>
|
||||
<div class="image"><img src="<?php echo $todayImgUrl;?>" alt="" /><?php echo $todayTemp;?>°</div>
|
||||
<div><span class="label">Max:</span> <?php echo $todayMax;?>°</div>
|
||||
<div><span class="label">Min:</span> <?php echo $todayMin;?>°</div>
|
||||
</div><div class="tomorrow">
|
||||
<div class="day">Domani</div>
|
||||
<div class="image"><img src="<?php echo $tomorrowImgUrl;?>" alt="" /><?php echo $tomorrowTemp;?>°</div>
|
||||
<div><span class="label">Max:</span> <?php echo $tomorrowMax;?>°</div>
|
||||
<div><span class="label">Min:</span> <?php echo $tomorrowMin;?>°</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/*
|
||||
Author: Riccardo Di Dato
|
||||
Creation Date: 17/mar/2016
|
||||
*/
|
||||
|
||||
|
||||
class UpdateMeteoCacheTask extends Task {
|
||||
public static function getName(){
|
||||
return "updateMeteoCache";
|
||||
}
|
||||
|
||||
public static function getLabel(){
|
||||
return "Aggiorna la cache per il meteo";
|
||||
}
|
||||
|
||||
public static function execute(){
|
||||
$config = GlobalVariables::get("config");
|
||||
|
||||
$cont = file_get_contents("http://api.openweathermap.org/data/2.5/forecast?q=Naples,IT&appid=b1b15e88fa797225412429c1c50c122a&units=metric&lang=it");
|
||||
|
||||
file_put_contents($config->files->meteoCache, $cont);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -19,4 +19,6 @@ require_once(dirname(__FILE__)."/GenerateAdminPasswordRecoveryMailTask.php");
|
||||
require_once(dirname(__FILE__)."/DeleteOldPasswordResetRequestsTask.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/GenerateUserActivationMailTask.php");
|
||||
|
||||
require_once(dirname(__FILE__)."/UpdateMeteoCacheTask.php");
|
||||
?>
|
||||
@@ -28,7 +28,8 @@ $taskList = array(
|
||||
"GenerateUserPasswordRecoveryMailTask",
|
||||
"GenerateAdminPasswordRecoveryMailTask",
|
||||
"DeleteOldPasswordResetRequestsTask",
|
||||
"GenerateUserActivationMailTask"
|
||||
"GenerateUserActivationMailTask",
|
||||
"UpdateMeteoCacheTask"
|
||||
);
|
||||
|
||||
$saved = false;
|
||||
|
||||
+2
-1
@@ -277,7 +277,8 @@ catch (Exception $ex){
|
||||
</div>
|
||||
</div>
|
||||
<div class="rightBarNews">
|
||||
<div class="meteo"><img alt="" src="images/meteo.png"></div>
|
||||
<?php HTMLHelper::getMeteoBlock(); ?>
|
||||
<!-- http://api.openweathermap.org/data/2.5/forecast?q=Naples,IT&appid=b1b15e88fa797225412429c1c50c122a&units=metric&lang=it -->
|
||||
<div class="middleRightBanner mediaContent"><?php BannerHelper::printBanner(BannerModel::POSITION_BODY);?></div>
|
||||
<div class="lastNews">
|
||||
<div class="categoryBar" style="text-align:left;">
|
||||
|
||||
+12
-3
@@ -261,9 +261,18 @@ display: inline-block;
|
||||
|
||||
.ristorantiTitle{margin-top:10px;}
|
||||
|
||||
.rightBarNews{display:inline-block;width:230px;height:1380px;vertical-align:top;margin-top:20px;}
|
||||
.meteo{max-height:165px;max-width:220px;}
|
||||
.meteo > img{max-width:220px;max-height:165px;}
|
||||
.rightBarNews{display:inline-block;width:230px;height:1380px;vertical-align:top;padding-top: 10px;}
|
||||
|
||||
.meteoTitle{font-size: 15px;font-weight: bold;border-bottom: 3px solid #339CD5;margin-bottom: 7px;text-align:center;}
|
||||
.meteo{max-height: 165px;max-width: 220px;text-align: center;border-bottom: 1px dotted #C1B4B4;padding-bottom: 10px;margin-bottom: 10px;}
|
||||
.meteo > div{display:inline-block; width:49%;}
|
||||
.meteo .today{border-right:1px dotted rgb(221, 221, 221);}
|
||||
.meteo .image{text-align:center;}
|
||||
.meteo .image *{vertical-align:middle;}
|
||||
.meteo div{font-size:10pt;}
|
||||
.meteo .day{font-size:11pt;text-align:center; font-weight:bold;}
|
||||
.meteo div span{font-weight:bold;}
|
||||
|
||||
.middleRightBanner{width: 220px;overflow: hidden;height: 165px;margin: 5px 0;}
|
||||
.middleRightBanner > img{max-width:220px; max-heigth:200px;}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user