cvs: pear /Services_Weather/examples weather.com-extensive.php

From: Date: Wed, 12 Oct 2005 16:09:24 +0000
Subject: cvs: pear /Services_Weather/examples weather.com-extensive.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-35453@lists.php.net to get a copy of this message
eru Wed Oct 12 12:09:24 2005 EDT Modified files: /pear/Services_Weather/examples weather.com-extensive.php Log: Fixed bug in handling of non-standard condition-icons delivered by Weather.com http://cvs.php.net/diff.php/pear/Services_Weather/examples/weather.com-extensive.php?r1=1.12&r2=1.13&ty=u Index: pear/Services_Weather/examples/weather.com-extensive.php diff -u pear/Services_Weather/examples/weather.com-extensive.php:1.12 pear/Services_Weather/examples/weather.com-extensive.php:1.13 --- pear/Services_Weather/examples/weather.com-extensive.php:1.12 Thu Jul 21 11:09:31 2005 +++ pear/Services_Weather/examples/weather.com-extensive.php Wed Oct 12 12:09:22 2005 @@ -16,7 +16,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: weather.com-extensive.php,v 1.12 2005/07/21 15:09:31 eru Exp $ +// $Id: weather.com-extensive.php,v 1.13 2005/10/12 16:09:22 eru Exp $ /* * Well, this is a more elaborate example how to create a neat little page @@ -124,6 +124,11 @@ // This triggers if the day-forecast for the current day will get shown. $afternoon = ($location["time"] > "13:59" || date("Ymd", $fup) < date("Ymd")) ? true : false; +// The usual notation for condition icons is numeric. Check for numeric icon or "na" and set to "na" if that's not the case +if (!(ctype_digit($weather["conditionIcon"]) || $weather["conditionIcon"] == "na")) { + $weather["conditionIcon"] = "na"; +} + // Now we output all the data, please don't expect extensive comments here, this is basic // HTML/CSS stuff. Also this isn't a very fancy design, it's just to show you, what // the script is able to do (and more ;-))... @@ -253,6 +258,14 @@ } // Afternoon is only important for today $afternoon = ($day == 0) ? $afternoon : false; + + // The usual notation for condition icons is numeric. Check for numeric icon or "na" and set to "na" if that's not the case + if (!(ctype_digit($forecast["days"][$day]["day"]["conditionIcon"]) || $forecast["days"][$day]["day"]["conditionIcon"] == "na")) { + $forecast["days"][$day]["day"]["conditionIcon"] = "na"; + } + if (!(ctype_digit($forecast["days"][$day]["night"]["conditionIcon"]) || $forecast["days"][$day]["night"]["conditionIcon"] == "na")) { + $forecast["days"][$day]["night"]["conditionIcon"] = "na"; + } ?> <td style="width: <?=(90 / $forecastDays)?>%"> <table style="width: 100%"<?=($day % 2) ? ' class="bggrey"' : ""?>>

« previous php.pear.cvs (#35453) next »