Changeset 624174
- Timestamp:
- 11/12/2012 07:47:35 PM (12 years ago)
- Location:
- wxsim-forecast/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
wxsim-forecast/trunk/WXSIMforecast.php
r302771 r624174 3 3 * @package WXSIM-Forecast 4 4 * @author Rob Douglass 5 * @version 1.05 * @version 2.0 6 6 */ 7 7 /* … … 10 10 Description: This Plugin is just a port from Saratoga weather scripts for use in Wordpress 11 11 Author: Rob Douglass 12 Version: 1.012 Version: 2.0 13 13 Author URI: http://www.jmrwebsolutions.co.uk 14 14 */ … … 38 38 'showhumidex' => 'false', 39 39 'showfrost' => 'false', 40 'showheatidx' => 'false'); 41 40 'showheatidx' => 'false', 41 'showHotIconF' => '100', 42 'showHotIconC' => '37.7', 43 'showWindChill' => 'true', 44 'showColdvalF' => '26', 45 'showColdvalC' => '-3', 46 'uomTemp' => 'C', 47 'ourTZ' => 'America/Los_Angeles', 48 'animatedimage' => 'false'); 49 42 50 $WXSIMOptions = get_option($this->adminOptionsName); 43 51 if (!empty($WXSIMOptions)) { … … 86 94 } 87 95 if (isset($_POST['WXSIMshowheatidx'])) { 88 $devOptions['showheatidx'] = apply_filters('content_save_pre', $_POST['WXSIMshowheatidx']);96 $devOptions['showheatidx'] = $_POST['WXSIMshowheatidx']; 89 97 } 90 98 if (isset($_POST['WXSIMshowHotIconF'])) { 99 $devOptions['showHotIconF'] = $_POST['WXSIMshowHotIconF']; 100 } 101 if (isset($_POST['WXSIMshowHotIconC'])) { 102 $devOptions['showHotIconC'] = $_POST['WXSIMshowHotIconC']; 103 } 104 if (isset($_POST['WXSIMshowWindChill'])) { 105 $devOptions['showWindChill'] = $_POST['WXSIMshowWindChill']; 106 } 107 if (isset($_POST['WXSIMshowColdvalF'])) { 108 $devOptions['showColdvalF'] = $_POST['WXSIMshowColdvalF']; 109 } 110 if (isset($_POST['WXSIMshowColdvalC'])) { 111 $devOptions['showColdvalC'] = $_POST['WXSIMshowColdvalC']; 112 } 113 if (isset($_POST['WXSIMuomTemp'])) { 114 $devOptions['uomTemp'] = $_POST['WXSIMuomTemp']; 115 } 116 if (isset($_POST['WXSIMourTZ'])) { 117 $devOptions['ourTZ'] = $_POST['WXSIMourTZ']; 118 } 119 if (isset($_POST['WXSIManimatedimage'])) { 120 $devOptions['animatedimage'] = apply_filters('content_save_pre', $_POST['WXSIManimatedimage']); 121 } 122 91 123 update_option($this->adminOptionsName, $devOptions); 92 124 … … 154 186 <label for="WXSIMshowheatidx_no"><input type="radio" id="WXSIMshowheatidx_no" name="WXSIMshowheatidx" value="false" 155 187 <?php if ($devOptions['showheatidx'] == "false") { _e('checked="checked"', "WXSIMForecast"); }?>/> No</label></p> 188 189 <h3>Show Hot icon if Heat-Index >= value (Fahrenheit)</h3> 190 <p>Heat Icon will be displayed if the value is equal to or greater than the value entered (Fahrenheit)</p> 191 <textarea name="WXSIMshowHotIconF" style="width: 10%; height: 30px;"><?php _e(apply_filters('format_to_edit',$devOptions['showHotIconF']), 'WXSIMForecast') ?></textarea> 192 193 <h3>Show Hot icon if Heat-Index >= value (Celcius)</h3> 194 <p>Heat Icon will be displayed if the value is equal to or greater than the value entered (Celcius)</p> 195 <textarea name="WXSIMshowHotIconC" style="width: 10%; height: 30px;"><?php _e(apply_filters('format_to_edit',$devOptions['showHotIconC']), 'WXSIMForecast') ?></textarea> 156 196 197 <h3>Show Windchill?</h3> 198 <p>Selecting "No" will disable Windchill from being displayed.</p> 199 <p><label for="WXSIMshowWindChill_true"><input type="radio" id="WXSIMshowWindChill_true" name="WXSIMshowWindChill" value="true" 200 <?php if ($devOptions['showWindChill'] == "true") { _e('checked="checked"', "WXSIMForecast"); }?> /> Yes</label> 201 <label for="WXSIMshowWindChill_false"><input type="radio" id="WXSIMshowWindChill_false" name="WXSIMshowWindChill" value="false" 202 <?php if ($devOptions['showWindChill'] == "false") { _e('checked="checked"', "WXSIMForecast"); }?>/> No</label></p> 203 204 <h3>Show Cold! if Wind-Chill <= value (Fahrenheit)</h3> 205 <p>Cold Icon will be displayed if the value is less than or greater than the value entered (Fahrenheit)</p> 206 <textarea name="WXSIMshowColdvalF" style="width: 10%; height: 30px;"><?php _e(apply_filters('format_to_edit',$devOptions['showColdvalF']), 'WXSIMForecast') ?></textarea> 207 208 <h3>Show Cold! if Wind-Chill <= value (Celcius)</h3> 209 <p>Cold Icon will be displayed if the value is less than or greater than the value entered (Celcius)</p> 210 <textarea name="WXSIMshowColdvalC" style="width: 10%; height: 30px;"><?php _e(apply_filters('format_to_edit',$devOptions['showColdvalC']), 'WXSIMForecast') ?></textarea> 211 212 <h3>UOM Temperature</h3> 213 <p>Selecting either °C or °F this value should match forecast temperature</p> 214 <p><label for="WXSIMuomTemp_C"><input type="radio" id="WXSIMuomTemp_C" name="WXSIMuomTemp" value="C" 215 <?php if ($devOptions['uomTemp'] == "C") { _e('checked="checked"', "WXSIMForecast"); }?> /> °C</label> 216 <label for="WXSIMuomTemp_F"><input type="radio" id="WXSIMuomTemp_F" name="WXSIMuomTemp" value="F" 217 <?php if ($devOptions['uomTemp'] == "F") { _e('checked="checked"', "WXSIMForecast"); }?>/> °F</label></p> 218 219 <h3>Language</h3> 220 <p>Please enter your timezone (http://php.net/manual/en/timezones.america.php)</p> 221 <textarea name="WXSIMourTZ" style="width: 10%; height: 30px;"><?php _e(apply_filters('format_to_edit',$devOptions['ourTZ']), 'WXSIMForecast') ?></textarea> 222 223 <h3>Show Animated images?</h3> 224 <p>Selecting "No" will show static images and selecting "Yes" will show animated images.</p> 225 <p><label for="WXSIManimatedimage_yes"><input type="radio" id="WXSIManimatedimage" name="WXSIManimatedimage" value="true" 226 <?php if ($devOptions['animatedimage'] == "true") { _e('checked="checked"', "WXSIMForecast"); }?> /> Yes</label> 227 <label for="WXSIManimatedimage_no"><input type="radio" id="WXSIManimatedimage_no" name="WXSIManimatedimage" value="false" 228 <?php if ($devOptions['animatedimage'] == "false") { _e('checked="checked"', "WXSIMForecast"); }?>/> No</label></p> 229 157 230 <div class="submit"> 158 231 <input type="submit" name="update_WXSIMForecastSettings" value="<?php _e('Update Settings', 'WXSIMForecast') ?>" /></div> … … 191 264 } 192 265 193 function WXSIMforecast_func() { 194 195 // plaintext-parser.php script by Ken True - [email protected] 266 ?> 267 268 <?php 269 270 function WXSIMforecast_func( $atts) { 271 196 272 // 197 273 // Version 0.90 - 24-Mar-2007 - Pre-release - testing and commments version … … 221 297 // Version 1.18 - 09-Jul-2010 - added support for Humidex and frost forecast optional displays 222 298 // Version 1.19 - 12-Aug-2010 - added support for Heat-index and 'hot' icon for Heat-index/humidex above specified values 223 // 224 $Version = "plaintext-parser.php Version 1.19 - 12-Aug-2010"; 299 // Version 1.20 - 18-Oct-2010 - Corrected Frost display wording below icons 300 // Version 1.21 - 01-Jan-2011 - added support for Wind-chill and 'Cold!' for windchill below specified value 301 // Version 1.22 - 03-Jan-2011 - added formatting to windchill, heatidx, humidex and frost arrays 302 // Version 1.23 - 23-Jan-2011 - corrected display for frost when windchill also exists 303 // Version 1.24 - 15-Feb-2011 - corrected display for snow conditions not being selected 304 // Version 1.25 - 18-Feb-2011 - added lang=en for optional translation and fixed 'snow likely' not showing snow icon 305 // Version 1.26 - 22-Feb-2011 - added more Wind-Chill processing for WXSIM 12.8.5+ 306 // Version 1.27 - 01-Oct-2011 - added support for alternative animated icon set from http://www.meteotreviglio.com/ 307 // Version 1.28 - 27-Dec-2011 - added support for RTL languages (Hebrew) 308 // 309 $Version = "plaintext-parser.php Version 1.28 - 27-Dec-2011"; 225 310 // 226 311 // error_reporting(E_ALL); // uncomment to turn on full error reporting … … 289 374 // $WXSIMtext[$i] - text of forecast (translated) 290 375 // $WXSIMuv[$i] - UV index value (number) 291 // note: you can use ' set_UV_string($WXSIMuv[$i])' to get a UV N and meaning text376 // note: you can use 'PPset_UV_string($WXSIMuv[$i])' to get a UV N and meaning text 292 377 // $WXSIMtemp[$i] - Temperature with translated text and formatting 293 378 // $WXSIMpop[$i] - Number - Probabability of Precipitation ('',10,20, ... ,100) … … 303 388 // $WXSIMBeaufort[$i] - Beaufort scale for max wind speed 'n Bft' or 'Light air' (translated) 304 389 // $WXSIMhumidex[$i] - humidex number (or '' if not present in forecast) 305 // $WXSIMfrost[$i] - frost forecast (or ''' if not present in forecast) 306 // $WXSIMheatidx[$i] - heat-index forecast (or ''' if not present in forecast) 390 // $WXSIMfrost[$i] - frost forecast (or '' if not present in forecast) 391 // $WXSIMheatidx[$i] - heat-index forecast (or '' if not present in forecast) 392 // $WXSIMwindchill[$i] - wind-chill forecast (or '' if not present in forecast) 307 393 // Note: 308 394 // 395 309 396 // Settings --------------------------------------------------------------- 397 310 398 global $LanguageLookup, $doTranslate; 311 399 $WXSIMOptions = get_option(WXSIMForecastAdminOptions); //Load array from wordpress options table 400 401 // Attributes 402 403 extract( shortcode_atts( array( 404 'lang' => $WXSIMOptions['language'] 405 ), $atts ) ); 406 $WXSIMlang = $lang; 407 //return $lang; 408 312 409 313 410 $iconDir ='./wp-content/plugins/wxsim-forecast/images/'; // directory for carterlake icons 314 411 $WXSIMstation = $WXSIMOptions['station']; // name of your weather station 315 412 $plaintextFile = $WXSIMOptions['plaintextfile']; // location of the WXSIM plaintext.txt 316 $lang = $WXSIMOptions['language']; // default language is 'en' = English 413 //$lang = $WXSIMOptions['language']; // default language is 'en' = English 414 $lang = $WXSIMlang; 415 317 416 $tempDegrees = '°' . $WXSIMOptions['tempdegrees']; // set to '' to omit degree sign 318 417 // // or set to '°', '°F' or '°C' … … 330 429 if ($WXSIMOptions['showheatidx'] == "true") {$showHeatIDX = true;} 331 430 332 $showHotIconF = 100; // show Hot icon if Heat-Index >= value 333 $showHotIconC = 37.7; // show Hot icon if Humidex >= value 334 // ---- end of settings --------------------------------------------------- 431 $showHotIconF = $WXSIMOptions['showHotIconF']; // show Hot icon if Heat-Index >= value 432 $showHotIconC = $WXSIMOptions['showHotIconC']; // show Hot icon if Humidex >= value 433 434 $showWindChill = true; // =true to display Wind-Chill, =false to suppress display 435 if ($WXSIMOptions['showWindChill'] == "true") {$showWindChill = true;} 436 $showColdvalF = $WXSIMOptions['showColdvalF']; // show Cold! if Wind-Chill <= value in F 437 $showColdvalC = $WXSIMOptions['showColdvalC']; // show Cold! if Wind-Chill <= value in C 438 $uomTemp = $WXSIMOptions['uomTemp']; // ='C' if forecast temperature in Centigrade, ='F' if in Fahrenheit 439 $ourTZ = 'America/Los_Angeles'; // your timezone 440 441 //Icon type 442 $iconType = '.jpg'; // default type='.jpg' -- use '.gif' for animated icons from http://www.meteotreviglio.com/ 443 if ($WXSIMOptions['animatedimage'] == "true") {$iconType = '.gif';} 444 335 445 // ---- end of settings --------------------------------------------------- 336 446 // … … 338 448 global $SITE; 339 449 if (isset($SITE['fcsticonsdir'])) {$iconDir = $SITE['fcsticonsdir'];} 450 if (isset($SITE['fcsticonstype'])) {$iconType = $SITE['fcsticonstype'];} 340 451 if (isset($SITE['defaultlang'])) {$lang = $SITE['defaultlang'];} 452 if (isset($SITE['uomTemp'])) {$uomTemp = $SITE['uomTemp'];} 453 if (isset($SITE['tz'])) {$ourTZ = $SITE['tz'];} 341 454 // end of overrides from Settings.php 342 455 // … … 357 470 exit; 358 471 } 472 # Set timezone in PHP5/PHP4 manner 473 if (!function_exists('date_default_timezone_set')) { 474 putenv("TZ=" . $ourTZ); 475 } else { 476 date_default_timezone_set("$ourTZ"); 477 } 478 359 479 $Status = "<!-- $Version -->\n"; 360 480 $doTranslate = true; 361 481 if (isset($_REQUEST['lang']) ) { 362 482 $lang=strtolower($_REQUEST['lang']); 363 if ($lang == 'en') { $doTranslate = false; };483 // if ($lang == 'en') { $doTranslate = false; }; 364 484 } 365 485 global $doDebug; … … 402 522 403 523 $useCharSet = 'iso-8859-1'; 404 $UTFLang = ',gr,ru,cn,jp,'; // languages needing UTF-8 character set for display 524 $UTFLang = ',gr,ru,cn,jp,he,'; // languages needing UTF-8 character set for display 525 $RTLlangs = ',he,cn,jp,'; // languages needing right-to-left display 526 $doRTL = (strpos($RTLlangs,$lang) !== false)?true:false; 405 527 $timeFormat = 'd-M-Y h:i a'; // default to USA format 406 528 // load the config file 407 529 $config = file("./wp-content/plugins/wxsim-forecast/plaintext-parser-data.txt"); // 408 530 // load and merge the language file (if it exists) 409 if ($doTranslate and $lang <> 'en' andfile_exists("./wp-content/plugins/wxsim-forecast/plaintext-parser-lang-$lang.txt") ) {531 if ($doTranslate and file_exists("./wp-content/plugins/wxsim-forecast/plaintext-parser-lang-$lang.txt") ) { 410 532 $lfile = file("./wp-content/plugins/wxsim-forecast/plaintext-parser-lang-$lang.txt"); 411 533 foreach ($lfile as $val) { … … 416 538 } else { 417 539 $doTranslate = false; 418 if($lang <> 'en') {540 // if($lang <> 'en') { 419 541 $Status .= "<!-- translation file for '$lang' not found -->\n"; 420 542 $lang = 'en'; 421 } 422 } 543 // } 544 } 545 546 $showColdVal = preg_match('|C|i',$uomTemp)?$showColdvalC:$showColdvalF; 547 $Status .= "<!-- using $showColdVal for wind-chill test -->\n"; 423 548 424 549 // Initialize -- read in control file and place in $Conditions and $Precip … … 538 663 'frost' => 'plaintext-frost.txt', 539 664 'hot' => 'plaintext-hot.txt', 665 'nl-frost' => 'plaintext-nl-frost.txt', 666 'wc' => 'plaintext-wc.txt', 667 'wc2' => 'plaintext-wc2.txt', 668 'nl4' => 'plaintext-nl4.txt', 669 'nl5' => 'plaintext-nl5.txt', 670 'sn4' => 'plaintext-sn4.txt', 671 'sn5' => 'plaintext-sn5.txt', 672 'wc3' => 'plaintext-wc3.txt', 540 673 ); 674 $linksList = ''; 675 if (isset($_REQUEST['testlinks'])) { 676 $thisTest = isset($_REQUEST['test'])?$_REQUEST['test']:'notspecified'; 677 foreach ($testFiles as $name => $fname) { 678 $linksList .= "<a href=\"?testlinks&test=$name&lang=$lang\">"; 679 if($thisTest == $name) { 680 $linksList .= "<b><span style=\"font-size: 14pt;\">$name</span></b></a> "; 681 } else { 682 $linksList .= "$name</a> "; 683 } 684 } 685 686 } 541 687 542 688 if (isset($_REQUEST['test']) ) { // for testing only … … 575 721 // Find city and update date 576 722 if (preg_match('|WXSIM text forecast for (.*), initialized at\s+(.*)|i',$plaintext,$matches)) { 577 $WXSIMcity = get_lang(trim($matches[1]));723 $WXSIMcity = PPget_lang(trim($matches[1])); 578 724 $wdate = trim($matches[2]); 579 725 $Status .= "<!-- wdate '$wdate' -->\n"; … … 614 760 $Status .= "<!-- updated '$wdate'-->\n"; 615 761 $d = strtotime($wdate); 616 $WXSIMupdated = get_lang(date('l',$d)) . ', ' . gmdate($timeFormat,$d) . ' UTC';762 $WXSIMupdated = PPget_lang(date('l',$d)) . ', ' . gmdate($timeFormat,$d) . ' UTC'; 617 763 } else { 618 764 $wdate = "$wDay-$wMon-$wYear $wTime " . date('O',time()); 619 765 $Status .= "<!-- updated '$wdate'-->\n"; 620 766 $d = strtotime($wdate); 621 $WXSIMupdated = get_lang(date('l',$d)) . ', ' . date($timeFormat,$d);767 $WXSIMupdated = PPget_lang(date('l',$d)) . ', ' . date($timeFormat,$d); 622 768 } 623 769 } … … 648 794 $WXSIMfrost[$i] = ''; 649 795 $WXSIMheatidx[$i] = ''; 796 $WXSIMwindchill[$i] = ''; 650 797 651 798 // make the period 'pretty' with HTML breaks. 652 $WXSIMtitles[$i] = preg_replace('! (\S+)$!',"<br />\\1", get_lang($WXSIMday[$i]));799 $WXSIMtitles[$i] = preg_replace('! (\S+)$!',"<br />\\1",PPget_lang($WXSIMday[$i])); 653 800 if (! preg_match('!<br />!',$WXSIMtitles[$i])) { 654 801 $WXSIMtitles[$i] .= '<br />'; // add line break to 'short' day titles … … 670 817 } 671 818 672 // extract Wind direction, values 819 // extract Wind-chill value 820 if (preg_match('/Wind chill (down to|ranging from) (\S+)/i',$WXSIMtext[$i],$mtemp) ) { 821 $WXSIMwindchill[$i] = $mtemp[2]; 822 } 823 824 // extract Wind direction, values 673 825 $testwind = str_replace('Wind chill','Wind-chill',$WXSIMtext[$i]); 674 826 if (preg_match('|Wind (.*)\.|Ui',$testwind,$mtemp) ) { … … 725 877 726 878 } 727 $WXSIMBeaufort[$i] = displayBeaufort(getBeaufort($maxWind,$WXSIMwindunits[$i])) ;879 $WXSIMBeaufort[$i] = PPdisplayBeaufort(PPgetBeaufort($maxWind,$WXSIMwindunits[$i])) ; 728 880 // $Status .= "<!-- dir='" . $WXSIMwinddir[$i] . "' wind='" . $WXSIMwind[$i] . 729 881 "' gust='" . $WXSIMgust[$i] . "' units='" . $WXSIMwindunits[$i] . … … 733 885 // extract temperature High/Low values 734 886 if (preg_match('!(high|low) ([-|\d]+)[\.|,]!i',$WXSIMtext[$i],$mtemp)) { 735 $WXSIMtemp[$i] = get_lang($mtemp[1] .':') . ' ' . $mtemp[2] . $tempDegrees;887 $WXSIMtemp[$i] = PPget_lang($mtemp[1] .':') . ' ' . $mtemp[2] . $tempDegrees; 736 888 if ($tempDegrees) { // fix up degrees in the text 737 889 $WXSIMtext[$i] = preg_replace( … … 767 919 if (preg_match('!with\s+(.*)\s+frost.!is',$WXSIMtext[$i],$mtemp)) { 768 920 // print "<pre>" . print_r($mtemp,true) . "</pre>\n"; 769 $WXSIMfrost[$i] = 'Frost '.$mtemp[1];921 $WXSIMfrost[$i] = ucfirst($mtemp[1]) . ' frost'; 770 922 if ($doTranslate) { 771 923 // perform optional translation if $Language has entries … … 785 937 reset($Conditions); // Do search in load order 786 938 foreach ($Conditions as $cond => $condrec) { // look for matching condition 939 if ($doDebug) { 940 $Status .= "<!-- check '$cond' -->\n"; 941 } 787 942 788 943 if(preg_match("!$cond!i",$WXSIMtext[$i],$mtemp)) { 789 944 list($dayicon,$nighticon,$condition) = explode("\t",$condrec); 790 945 if (preg_match('!chance!i',$condition) and $WXSIMpop[$i] < $minPoP) { 946 if ($doDebug) { 947 $Status .= "<!-- skip-chance -->\n"; 948 } 791 949 continue; // skip this one 792 950 } 793 if (preg_match("|$cond level|i",$WXSIMtext[$i]) ) { 951 if (preg_match("|$cond level|i",$WXSIMtext[$i]) and !preg_match("/(chance of $cond|$cond likely|$cond very likely)/i",$WXSIMtext[$i]) ) { 952 if ($doDebug) { 953 $Status .= "<!-- skip $cond level -->\n"; 954 } 794 955 continue; // skip 'snow level' and 'freezing level' entries 795 956 } 796 $WXSIMcond[$i] = get_lang($condition); 957 if ($doDebug) { 958 $Status .= "<!-- $cond / $condition selected -->\n"; 959 } 960 $WXSIMcond[$i] = PPget_lang($condition); 797 961 if (preg_match('|night|i',$WXSIMday[$i])) { 798 962 $WXSIMicon[$i] = $nighticon; … … 828 992 829 993 // now fix up the full icon name and PoP if available 830 $curicon = $WXSIMicon[$i] . '.jpg';994 $curicon = $WXSIMicon[$i] . $iconType; 831 995 if ($WXSIMpop[$i] > 0) { 832 $testicon = preg_replace( "|\.jpg|","$WXSIMpop[$i].jpg",$curicon);996 $testicon = preg_replace('|'.$iconType.'|',$WXSIMpop[$i].$iconType,$curicon); 833 997 // print "<pre>testicon='$testicon'</pre>\n"; 834 998 if (file_exists($iconDir . $testicon)) { … … 840 1004 $WXSIMicon[$i] = $curicon; 841 1005 } 842 1006 843 1007 if ($WXSIMtempdirect[$i] <> '') { 844 1008 $tempdirect = 'up.gif'; … … 858 1022 // put back translated text, fixing capitalization for sentence starts (except the first one). 859 1023 $WXSIMtext[$i] = preg_replace('!\.\s+([a-z])!es',"'. ' . strtoupper('\\1')",$text); 860 $WXSIMday[$i] = get_lang($WXSIMday[$i]); 861 $wdirs = get_lang('NESW'); // default directions 862 if(strlen($wdirs) == 4) { 863 $WXSIMwinddir[$i] = strtr($WXSIMwinddir[$i],'NESW',$wdirs); // do translation 864 } elseif (preg_match('|,|',$wdirs)) { //multichar translation 865 $wdirsmc = explode(',',$wdirs); 866 $wdirs = array('N','E','S','W'); 867 $wdirlook = array(); 868 foreach ($wdirs as $n => $d) { 869 $wdirlook[$d] = $wdirsmc[$n]; 870 } 871 $tstr = ''; // get ready to pass once through the string 872 for ($n=0;$n<strlen($WXSIMwinddir[$i]);$n++) { 873 $c = substr($WXSIMwinddir[$i],$n,1); 874 if(isset($wdirlook[$c])) { 875 $tstr .= $wdirlook[$c]; // use translation 876 } else { 877 $tstr .= $c; // use regular 878 } 1024 $WXSIMday[$i] = PPget_lang($WXSIMday[$i]); 1025 if($doRTL and isset($LanguageLookup['NESW-N'])) { // handle RTL language type 1026 $Status .= "<!-- RTLtrans input WXSIMwinddir[$i] = '".$WXSIMwinddir[$i]."' -->\n"; 1027 $tstr = preg_replace('|→|',"\t",$WXSIMwinddir[$i]); 1028 $twdirs = explode("\t",$tstr); 1029 foreach ($twdirs as $n => $twdir) { 1030 $twdirs[$n] = isset($LanguageLookup['NESW-'.$twdir])?$LanguageLookup['NESW-'.$twdir]:$twdir; 879 1031 } 880 $WXSIMwinddir[$i] = $tstr; // do translation 1032 $WXSIMwinddir[$i] = join('←',array_reverse($twdirs)); 1033 $Status .= "<!-- RTLtrans output WXSIMwinddir[$i] = '".$WXSIMwinddir[$i]."' -->\n"; 1034 if(preg_match('|→|',$WXSIMwind[$i])) { 1035 $Status .= "<!-- RTLtrans input WXSIMwind[$i] = '".$WXSIMwind[$i]."' -->\n"; 1036 $tstr = preg_replace('|→|',"\t",$WXSIMwind[$i]); 1037 $twspds = explode("\t",$tstr); 1038 $WXSIMwind[$i] = join('←',array_reverse($twspds)); 1039 $Status .= "<!-- RTLtrans output WXSIMwind[$i] = '".$WXSIMwind[$i]."' -->\n"; 1040 } 1041 1042 } else { // handle non-RTL language type 881 1043 1044 $wdirs = PPget_lang('NESW'); // default directions 1045 if(strlen($wdirs) == 4) { 1046 $WXSIMwinddir[$i] = strtr($WXSIMwinddir[$i],'NESW',$wdirs); // do translation 1047 } elseif (preg_match('|,|',$wdirs)) { //multichar translation 1048 $wdirsmc = explode(',',$wdirs); 1049 $wdirs = array('N','E','S','W'); 1050 $wdirlook = array(); 1051 foreach ($wdirs as $n => $d) { 1052 $wdirlook[$d] = $wdirsmc[$n]; 1053 } 1054 $tstr = ''; // get ready to pass once through the string 1055 for ($n=0;$n<strlen($WXSIMwinddir[$i]);$n++) { 1056 $c = substr($WXSIMwinddir[$i],$n,1); 1057 if(isset($wdirlook[$c])) { 1058 $tstr .= $wdirlook[$c]; // use translation 1059 } else { 1060 $tstr .= $c; // use regular 1061 } 1062 } 1063 $WXSIMwinddir[$i] = $tstr; // do translation 1064 1065 } 882 1066 } 883 1067 // translate speed and wind units based on lang entries in one pass 884 1068 $text = ' ' . $WXSIMwind[$i] . " \t " . $WXSIMwindunits[$i] . ' '; // make test string. 885 886 887 888 889 1069 reset ($Language); // process in order of the file 1070 foreach ($Language as $key => $replacement) { 1071 $text = str_replace($key,$replacement,$text); 1072 } 1073 $key = explode("\t",$text); 890 1074 $WXSIMwind[$i] = trim($key[0]); 891 1075 $WXSIMwindunits[$i] = trim($key[1]); 892 1076 893 1077 } 894 895 // override icon with hot.jpg if high heat-index or humidex 896 if($WXSIMheatidx[$i] >= $showHotIconF or $WXSIMhumidex[$i] >= $showHotIconC) { 897 $WXSIMicon[$i] = 'hot.jpg'; 898 $WXSIMcond[$i] .= "<br/>\n<span style=\"color:red;\"><strong>" . get_lang('Hot!') . "</strong></span>"; 899 } 1078 // override icon with hot.jpg if high heat-index or humidex 1079 if($WXSIMheatidx[$i] >= $showHotIconF or $WXSIMhumidex[$i] >= $showHotIconC) { 1080 $WXSIMicon[$i] = 'hot.jpg'; 1081 $WXSIMcond[$i] .= "<br/>\n<span style=\"color:red;\"><strong>" . PPget_lang('Hot!') . "</strong></span>"; 1082 } 1083 1084 if($WXSIMheatidx[$i] <> '') { 1085 $WXSIMheatidx[$i] = "<span style=\"color: red;\">".PPget_lang('Heat').": $WXSIMheatidx[$i]$tempDegrees</span>\n"; 1086 1087 } 900 1088 901 // make HTML for full icon with condition description 902 $WXSIMicons[$i] = "$WXSIMtitles[$i]<br /> 903 <img src=\"$iconDir$WXSIMicon[$i]\" alt=\"".strip_tags($WXSIMcond[$i])."\" title=\"". 904 strip_tags($WXSIMcond[$i]) ."\" /><br /> 905 $WXSIMcond[$i]"; 1089 if($WXSIMhumidex[$i] <> '') { 1090 $WXSIMhumidex[$i] = "<span style=\"color: red;\">".PPget_lang('Hmdx').": $WXSIMhumidex[$i]</span>\n"; 1091 } 1092 1093 // process Wind-chill 1094 if ($WXSIMwindchill[$i] <= $showColdVal and $WXSIMwindchill[$i] <> '') { 1095 $WXSIMcond[$i] .= "<br/>\n<span style=\"color:blue;\"><strong>" . PPget_lang('Cold!') . "</strong></span>"; 1096 // $WXSIMicon[$i] = 'cold.jpg'; 1097 } 1098 1099 1100 if($WXSIMwindchill[$i] <> '') { 1101 $WXSIMwindchill[$i] = "<span style=\"color: blue;\">".PPget_lang('WCh').": $WXSIMwindchill[$i]$tempDegrees</span>\n"; 1102 } 1103 1104 if ($WXSIMfrost[$i] <> '') { 1105 $WXSIMfrost[$i] = "<span style=\"color: blue;\">$WXSIMfrost[$i]</span>\n"; 1106 } 1107 1108 1109 // make HTML for full icon with condition description 1110 $WXSIMicons[$i] = "$WXSIMtitles[$i]<br /> 1111 <img src=\"$iconDir$WXSIMicon[$i]\" alt=\"".strip_tags($WXSIMcond[$i])."\" title=\"". 1112 strip_tags($WXSIMcond[$i]) ."\" /><br /> 1113 $WXSIMcond[$i]"; 906 1114 907 1115 } // end of main loop ------------------------- … … 930 1138 preg_match('|(\d+)(.*)|',$maxWidth,$widthparts); 931 1139 //$Status .= "<!-- widthparts\n" . print_r($widthparts,true) . " -->\n"; 932 //$nTD = count($WXSIMicon); 933 $nTD = $maxIcons; 1140 $nTD = count($WXSIMicon); 934 1141 if ($nTD < 1) { $nTD = 1; } 935 1142 $wTD = round($widthparts[1]/$nTD,0) . $widthparts[2]; … … 948 1155 } 949 1156 if ($printHeading) { 1157 $RTL = $doRTL?'style="unicode-bidi: embed;"':''; 1158 950 1159 ?> 951 <tr align="center">952 <td ><b><?php echoget_lang("WXSIM Forecast for:");?> </b><span style="color: green;">1160 <tr> 1161 <td align="center"<?php echo $RTL; ?>><b><?php echo PPget_lang("WXSIM Forecast for:");?> </b><span style="color: green;"> 953 1162 <?php echo $WXSIMcity; ?></span><br /> 954 <?php echo get_lang("Issued by:"); ?> <?php echo $WXSIMstation; ?>1163 <?php echo PPget_lang("Issued by:"); ?> <?php echo $WXSIMstation; ?> 955 1164 </td> 956 1165 </tr> 957 1166 <tr> 958 <td align="center"><?php echo get_lang("Updated:");?> <?php echo $WXSIMupdated; ?> 1167 <td align="center"<?php echo $RTL; ?>><?php echo PPget_lang("Updated:");?> <?php 1168 if($doRTL) { echo "<span style=\"unicode-bidi: bidi-override; direction: ltr;\">";} 1169 echo $WXSIMupdated; 1170 if($doRTL) { echo "</span>";} 1171 ?> 959 1172 </td> 960 1173 </tr> … … 966 1179 <tr> 967 1180 <td align="center"> 968 <table width=" <?php echo $maxWidth; ?>" border="0" cellpadding="0" cellspacing="0">1181 <table width="100%" border="0" cellpadding="0" cellspacing="0"> 969 1182 <tr valign ="top" align="center"> 970 1183 <?php 971 1184 for ($i=0;$i<min(count($WXSIMicons),$maxIcons);$i++) { 972 print "<td style=\"width: $wTD;\"><span >$WXSIMicons[$i]</span></td>\n";1185 print "<td style=\"width: $wTD;\"><span style=\"font-size: 8pt;\">$WXSIMicons[$i]</span></td>\n"; 973 1186 } 974 1187 ?> … … 978 1191 for ($i=0;$i<min(count($WXSIMprecip),$maxIcons);$i++) { 979 1192 print "<td style=\"width: $wTD; color: green;\">$WXSIMprecip[$i]</td>\n"; 980 1193 } 981 1194 ?> 982 1195 </tr> … … 989 1202 </tr> 990 1203 991 <?php if ($showHumidex or $show Frost or $showHeatIDX) {992 print "<tr valign =\"top\" align=\"center\">";993 1204 <?php if ($showHumidex or $showHeatIDX or $showWindChill) { ?> 1205 <tr valign ="top" align="center"> 1206 <?php 994 1207 for ($i=0;$i<min(count($WXSIMhumidex),$maxIcons);$i++) { 995 $temp = ''; 996 if ($WXSIMhumidex[$i] <> '') {$temp = get_lang('Hmdx').': '; 997 print "<td style=\"width: $wTD; color: red;\">$temp$WXSIMhumidex[$i]</td>\n"; 1208 $flag = 0; 1209 if ($showHumidex and $WXSIMhumidex[$i] <> '') {$flag++; 1210 print "<td style=\"width: $wTD;\">$WXSIMhumidex[$i]</td>\n"; 1211 998 1212 } 999 if ($ WXSIMheatidx[$i] <> '') {$temp = get_lang('Heat').': ';1000 print "<td style=\"width: $wTD; color: red;\">$temp$WXSIMheatidx[$i]$tempDegrees</td>\n";1213 if ($showHeatIDX and $WXSIMheatidx[$i] <> '') {$flag++; 1214 print "<td style=\"width: $wTD;\">$WXSIMheatidx[$i]</td>\n"; 1001 1215 } 1002 if ($ WXSIMfrost[$i] <> '') {1003 $temp = 'Frost ';1004 print "<td style=\"width: $wTD; color: blue;\">$WXSIMfrost[$i]</td>\n";1216 if ($showWindChill and $WXSIMwindchill[$i] <> '') {$flag++; 1217 print "<td style=\"width: $wTD;\">$WXSIMwindchill[$i]</td>\n"; 1218 1005 1219 } 1006 if($ temp == '') {1220 if($flag < 1) { // print spacer row 1007 1221 print "<td style=\"width: $wTD;\"> </td>\n"; 1008 1222 … … 1011 1225 ?> 1012 1226 </tr> 1013 <?php } // end of showHumidex or showFrost ?> 1227 <?php } // end of showHumidex/showHeatidx/showWindchill ?> 1228 <?php if ($showFrost and strlen(implode('',$WXSIMfrost)) > 1) { ?> 1229 <tr valign ="top" align="center"> 1230 <?php 1231 for ($i=0;$i<min(count($WXSIMfrost),$maxIcons);$i++) { 1232 1233 if ($WXSIMfrost[$i] <> '') {$flag++; 1234 print "<td style=\"width: $wTD;\">$WXSIMfrost[$i]</td>\n"; 1235 } else { 1236 print "<td style=\"width: $wTD;\"> </td>\n"; 1237 } 1238 } 1239 ?> 1240 </tr> 1241 <?php } // end of showFrost ?> 1014 1242 <tr valign ="top" align="center"> 1015 1243 <?php … … 1027 1255 <?php 1028 1256 for ($i=0;$i<min(count($WXSIMuv),$maxIcons);$i++) { 1029 print "<td style=\"width: $wTD;\">" . set_UV_string($WXSIMuv[$i]) . "</td>\n";1257 print "<td style=\"width: $wTD;\">" . PPset_UV_string($WXSIMuv[$i]) . "</td>\n"; 1030 1258 } 1031 1259 ?> … … 1047 1275 if ($printText) { 1048 1276 ?> 1049 <div class="WXSIMforecas tcontent">1277 <div class="WXSIMforecascontent"> 1050 1278 1051 1279 <table style="border: 0" width="<?php echo $maxWidth; ?>"> 1052 1280 <?php 1281 $rAlign = $doRTL?' text-align: right;':''; 1053 1282 for ($i=0;$i<count($WXSIMday);$i++) { 1054 1283 print "<tr valign =\"top\" align=\"left\">\n"; 1055 print "<td style=\"width: 20%; \"><b>$WXSIMday[$i]</b><br /> <br /></td>\n";1056 print "<td style=\"width: 80%; \">$WXSIMtext[$i]</td>\n";1284 print "<td style=\"width: 20%;$rAlign\"><b>$WXSIMday[$i]</b><br /> <br /></td>\n"; 1285 print "<td style=\"width: 80%;$rAlign\">$WXSIMtext[$i]</td>\n"; 1057 1286 print "</tr>\n"; 1058 1287 } 1059 1288 ?> 1060 1289 </table> 1061 </div><?php 1290 1291 <p><small><a href="http://www.wxsim.com/">WXSIM</a> 1292 <?php echo PPget_lang("forecast formatting script by");?> 1293 <a href="http://saratoga-weather.org/scripts.php"> Saratoga-Weather.org</a> 1294 <?php if($iconType <> '.jpg') { 1295 print "<br/>"; 1296 echo PPget_lang("Animated forecast icons courtesy of"); 1297 print " <a href=\"http://www.meteotreviglio.com/\">www.meteotreviglio.com</a>."; 1298 } 1299 ?> 1300 1301 </small></p></div><?php 1062 1302 } // end printText 1063 1064 1303 1065 1304 if (! $IncludeMode) { … … 1069 1308 <?php 1070 1309 } // print above only if not include mode 1071 } 1310 } // END FORECAST FUNCTION 1072 1311 // Functions ----------------------------------------------------------------------- 1073 1312 1074 1313 // replace text with language lookup text if available 1075 function get_lang( $text ) {1314 function PPget_lang( $text ) { 1076 1315 global $LanguageLookup, $doTranslate; 1316 1077 1317 if ($doTranslate && isset($LanguageLookup[$text])) { 1078 1318 $newtext = $LanguageLookup[$text]; … … 1084 1324 // decode UV to word+color for display 1085 1325 1086 function set_UV_string ( $uv ) {1326 function PPset_UV_string ( $uv ) { 1087 1327 // figure out a text value and color for UV exposure text 1088 1328 // 0 to 2 Low … … 1096 1336 break; 1097 1337 case (($uv > 0) and ($uv < 3)): 1098 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; background-color: #A4CE6a;"> ' . get_lang("Low") .' </span>';1338 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; background-color: #A4CE6a;"> ' . PPget_lang("Low") .' </span>'; 1099 1339 break; 1100 1340 case (($uv >= 3) and ($uv < 6)): 1101 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px;background-color: #FBEE09;"> ' . get_lang("Medium") .' </span>';1341 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px;background-color: #FBEE09;"> ' . PPget_lang("Medium") .' </span>'; 1102 1342 break; 1103 1343 case (($uv >=6 ) and ($uv < 8)): 1104 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; background-color: #FD9125;"> ' . get_lang("High") .' </span>';1344 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; background-color: #FD9125;"> ' . PPget_lang("High") .' </span>'; 1105 1345 break; 1106 1346 case (($uv >=8 ) and ($uv < 11)): 1107 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; color: #FFFFFF; background-color: #F63F37;"> ' . get_lang('Very High') . ' </span>';1347 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; color: #FFFFFF; background-color: #F63F37;"> ' . PPget_lang('Very High') . ' </span>'; 1108 1348 break; 1109 1349 case (($uv >= 11) ): 1110 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; color: #FFFF00; background-color: #807780;"> ' . get_lang("Extreme") .' </span>';1350 $uv = "UV: $uv<br/>" . '<span style="border: solid 1px; color: #FFFF00; background-color: #807780;"> ' . PPget_lang("Extreme") .' </span>'; 1111 1351 break; 1112 1352 } // end switch … … 1116 1356 1117 1357 // determine Beaufort number based on wind speed and units 1118 function getBeaufort ( $wind, $units) {1358 function PPgetBeaufort ( $wind, $units) { 1119 1359 1120 1360 global $showBeaufort,$BeaufortMPH,$BeaufortKPH,$BeaufortKTS,$BeaufortMS,$doDebug,$Status; … … 1141 1381 return($Bft); 1142 1382 1143 }// end getBeaufort1383 }// end PPgetBeaufort 1144 1384 1145 1385 // perform Beaufort display if desired by showBeaufort setting 1146 function displayBeaufort ($Bft) {1386 function PPdisplayBeaufort ($Bft) { 1147 1387 global $showBeaufort, $BeaufortText; 1148 1388 if ($Bft < 0 or $Bft > 12 ) { return(""); } 1149 1389 1150 if ($showBeaufort == 'T') { return( get_lang($BeaufortText[$Bft]) ); }1390 if ($showBeaufort == 'T') { return( PPget_lang($BeaufortText[$Bft]) ); } 1151 1391 1152 1392 if ($showBeaufort == 'V') { return("$Bft Bft"); } … … 1154 1394 return(""); 1155 1395 1156 }// end displayBeaufort 1157 1158 1159 1160 1161 1162 1163 1164 1165 1396 }// end PPdisplayBeaufort 1397 1166 1398 1167 1399 … … 1181 1413 1182 1414 1183 1184 1185 1415 ?> -
wxsim-forecast/trunk/plaintext-parser-data.txt
r219671 r624174 1 1 # 2 2 # data file for plaintext-parser.php -- used to determine caption and base icon for forecast 3 # Version 1.0 5 - 29-Jan-20073 # Version 1.06 - 01-Jan-2011 4 4 # 5 5 # select default date format by putting a '#' in front of the ones NOT to be used. … … 43 43 cond|fog after midnight|sctfg|nbknfg|Fog late| 44 44 cond|fog|fg|nfg|Fog| 45 cond|wind chill down to -|cold|cold|Very Cold|46 cond|heat index up to 1|hot|hot|Very Hot|47 45 cond|partly cloudy|sct|nsct|Partly Cloudy| 48 46 cond|mostly cloudy|bkn|nbkn|Mostly Cloudy| -
wxsim-forecast/trunk/readme.txt
r302770 r624174 4 4 Donate link: http://www.jmrwebsolutions.co.uk 5 5 Tags: weather, wxsim, forecast 6 Requires at least: 2.87 Tested up to: 3. 0.18 Stable tag: 1.06 Requires at least: 3.3 7 Tested up to: 3.4.2 8 Stable tag: 2.0 9 9 10 10 Displays WXSIM forecast on a specific page of your wordpress site. … … 29 29 10. Minimum Probability of Precipitation(PoP) - PoP percentage must equal this value or above to display rain icon, otherwise the sky icon with PoP is displayed. 30 30 11. Display Beaufort - Set to V' for no Beaufort and set to 'T' for translated name 31 12. Show Humidity Index - Selecting "No" will disable the humidity index from being displayed. 32 13. Show Frost - Selecting "No" will disable the Frost from being displayed. 33 14. Show Heat Index - Selecting "No" will disable the heat index from being displayed. 34 15. Show Hot icon - Heat Icon will be displayed if the value is equal to or greater than the value entered (Fahrenheit) 35 16. Show Hot icon - Heat Icon will be displayed if the value is equal to or greater than the value entered (Celcius) 36 17. Show Windchill - Selecting "No" will disable Windchill from being displayed. 37 18. Show Cold - Cold Icon will be displayed if the value is less than or greater than the value entered (Fahrenheit) 38 19. Show Cold - Cold Icon will be displayed if the value is less than or greater than the value entered (Celcius) 39 20. UOM Temperature - Selecting either °C or °F this value should match forecast temperature 40 21. TimeZone - Please enter your timezone Visit the following to identify the correct value http://php.net/manual/en/timezones.america.php 41 22. Show Animated images - Selecting "No" will show static images and selecting "Yes" will show animated images. 31 42 32 To add the widget to a posts and/or pages use the shortcode [forecast]. 43 To add the widget to a posts and/or pages use the shortcode [forecast] 44 You can now pass a language parameter in the shortcode to allow for multilinguaal forecast throughout your site [forecast lang = cy]. You must have a valid plaintext-parser-lang file for this to work. 33 45 34 46 == Frequently Asked Questions == 35 47 36 = A question that someone might have = 37 38 An answer to that question. 39 40 = What about foo bar? = 41 42 Answer to foo bar dilemma. 48 1. This will only work if you are running WXSIM and upload data from this to the web, IT IS NOT A STANDALONE PLUGIN 43 49 44 50 == Screenshots == 45 51 52 None 46 53 47 54 == Changelog == 55 56 = 2.0 - 12.11.2012 = 57 * Fixed numerous bugs in code 58 * Added a number of additional configuration items 59 * Added shortcode parameter for multilingual functionality 60 * Included animated images 48 61 49 62 = 1.0 - 21.10.2010 = … … 70 83 71 84 == A brief Markdown Example == 72 73 Ordered list:74 75 1.76 77 Unordered list:78 79 *80 81 Here's a link to [WordPress](http://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax].82 Titles are optional, naturally.83 84 [markdown syntax]: http://daringfireball.net/projects/markdown/syntax85 "Markdown is what the parser uses to process much of the readme file"86 87 Markdown uses email style notation for blockquotes and I've been told:88 > Asterisks for *emphasis*. Double it up for **strong**.89 90 `<?php code(); // goes in backticks ?>`
Note: See TracChangeset
for help on using the changeset viewer.