Leuven-script UV forecast multiple days

Examples

Demo scriptWhat does this script
ExplanationFirst an image copy with all parts visible and some explanations
Stand-aloneAn example running stand-alone, adaptable width, grey color
SaratogaAnd an example where the script is used in the Saratoga template
LeuvenAnd here the script is used in the Leuven Template, on the start-page, half-way the page!

Install


  1. Download from the link HERE
  2. Unzip the downloaded file
  3. Upload (FTP) the contents of the folder to the main folder on your website.
    For Saratoga and Stand-alone users, this is normally the root
    Leuven-template users place the contents in weather2/ If you already have a cache folder (with this exact name) you can skip the upload of that folder. If you already have a img/ folder (with this exact name) move the contents of the downloaded img/ folder to the existing folder.
  4. Set the permissions for the cache/ folder and its contents at 777
    otherwise an error message: [function.file-put-contents]: failed to open stream: Permission denied will occur
  5. Test the installation with www.website.xx/ uvforecastv3.php
    Please replace www.website.xx/ with the name of your website
    This test uses the data and settings for my own location.
  6. Check and adapt the settings as described in the next tab on this page
  7. If everything looks OK you can integrate the script on your site.
    • Saratoga-template
      1. The wxStartUV.php script you already copied from the download to the main folder of your website.
      2. Add a menu-entry in your menu file. Often this is named flyout-menu.xml. The menu-entry should look like:
      3. <item caption="UV Forecast" link="wxStartUV.php" title="UV Forecast"/>"
        

    • Leuven
      1. If you want to use a separate UV forecast page, you adapt the menu entry in wsMenuData.xml.
        <item nr="58" 	
                show="yes" 
        	link="uvforecastv3.php"
        	caption="UV Index Forecast"
        	title="UV forecast and warnings by KNMI"
        />
        

      2. If you want a folded/unfolded UV forecast somewhere on your start-page, you should add an include on the exact place where you want that forecast to appear. This is different for the version of the template and the type of start-page you are using. For instance in wsAjaxDashboard.php (all releases) you simply add a line:
                include 'uvforecastv3.php';
        

      3. In the more modern start-page wsStartPage.php (release 2.4 and on) you specify first a list of components which should appear in that sequence and then a set of if statements which call the scripts neeeded.
        $dashboard[]	= 'rain';			// rain 1, 2 or 3
        $dashboard[]	= 'uv';			        // 
        $dashboard[]	= 'AQ'; 			// soil  fc=forecast AQ=air quality
        

        if ($dashboard[$iDash] == 'uv') {
        	include 'uvforecastv3.php';
        	continue;
        }
        

    • Others You can use the UV forecast on any page by using:
              include 'uvforecastv3.php';
      

      Be aware that the width of the forecast is set to 100%, so it will adapt automatically to the width of the page. If you want a fixed width use an enclosing div:
          <iv style="width: 600px; ">
              include 'uvforecastv3.php';
          </div>
      

  8. These files and folders can be found in the download after unzip:
    nameWhere is it used for
    folders
    cacheTo store the retrieved UV forecast information for later use
    imgContains the UV images and the  for more information
    Scripts
    uvforecastv3.phpscriptTo use the UV forecast script:
    1. without any changes to test the installation first
    2. after adapting to your settings, to run the scripts "stand-alone" or in the Leuven-template
    wxStartUV.phpscriptTo use the UV forecast script from within the Saratoga-template

Settings



  • Leave this setting for the first few times until you are satisfied with the results. A small typing error is far easier to find with error messages switched on.
    #-----------------------------------------------------------------------
    # set error reporting  
    #-----------------------------------------------------------------------
    $errorMessages  = true;                 //##### set to false if everything is OK
    

  • Here we start with the real settings
    #-----------------------------------------------------------------------
    # these are your settings for retrieving information from www.tennis.nl
    #-----------------------------------------------------------------------
    

  • Normally you will do the include for a script from the same folder as the included script is in. With the Saratoga_template most scripts are in the root folder. With the Leuven template most in the weather2/ folder. If you have to include the UV script with a foldername you have to tell the UV script here what the name of that folder is.
    $myfolder       = './';                 //##### set if include 'foldername/uvforecastv3.php'; is used
    #$myfolder      = './uvv3/';            // EXAMPLE: include './uvv3/uvforecastv3.php';
    

  • The UV images are in a separate img folder. Normally you do not have to change that. If the UV forecast script is run from within a folder, that folder-name is added automatically. Just when you have your own naming conventions for folders and or their location, you should modify this setting here.
    $imgdir		= $myfolder.'img/';	// all img's for uv in own folder 
    

  • The default names for the UV images are set here. If you find other images with other extensions you can change this setting.
    $uvimg   	= $imgdir.'uv';         // location of images and first part of names
    $uvimgext       = '.gif';
    

  • The size for the UV images is set here. Removing the comment mark draws the images at half-size.
    $uvimgsize      = '';                   // default size
    #$uvimgsize      = 'width: 20px;';      // half size images
    

  • The number of icons (the forecast only supplies 6) you want to show in your forecast.
    $maxicons 	= 6;  			// maximum number of icons to display
    

  • If set to true the small  is used to unhide / hide more than half of the information as it is standard and in most cases not needed until higher UV levels are shown.
    $uvcompact      = true;
    

  • ADVANCED SETTING: If left at true, the script also prints the forecast to the browser of the visitor. If set to false, the whole forecast is generated into the $uvhtml variable for later printing.
    $uvprint        = true;
    

  • Normally the font setting for the enclosing page is used. If you want to use the script in an iframe or use a different font for the uv forecast you can set it here by removing the comment # at the second line, and adapting the setting to your needs.
    $standardfont   = '';                   // use font ssettings from enclosing page
    #$standardfont   = 'font-family: sans-serif; font-size: small;';  // own font settings
    

  • IMPORTANT: If you are using the Leuven-template this setting can be set to true and a few settings are than copied from the wsSettings.php script.
    $leuventemplate = false; 
    

  • If you are not using the Leuven-template you have to set these few extra settings before the script can generate your UV forecast.
    #-----------------------------------------------------------------------
    if ($leuventemplate <> true) {  // settings in not in leuven-template
    # -----------------   
    

    1. You can add more languages at the end of the script. This script does not uses the Saratoga or Leuven template translation routines.
      $lang		= 'en';			// default language - supported nl en fr de
      

    2. Your map coordinates. The UV forecast is retrieved based on these coordinates. Decimal system, not hh mm ss.ss
      $latitude       = '50.8444';            // the latitude of your stations location
      $longitude      = '4.9876';             // the longitude also
      

    3. IMPORTANT: the cachedir must be set. Without a cachedir to frequent calls to the temis.nl site will result in a blacklisted server.
      $cachedir       = $myfolder.'cache/';	// directory to cache files     IMPORTANT setting
      

    4. Set to false if you prefer a decimal point
      $commadecimal   = true; 
      

    5. default character set for webpages, UTF-8 is the modern one, windows-1252 is the most used one
      $charset	= 'UTF-8';
      

    6. All texts/translations will be in lowercase if set to true
      $strtolower     = false;
      

    7. IMPORTANT: OK for tmost op Europe. Do not change this without proper knowledge of the PHP version of the naming for timezones.
      $timezone       = 'Europe/Brussels'; 
      

  • These settings are copied if you are using the leuven-template
    #-----------------------------------------------------------------------
    } else {                        // settings for leuven template
    # ----------------------------------------------------------------------    
    $lang		= $SITE['lang'];        
    $latitude       = $SITE['latitude'];    // the latitude of your stations location
    $longitude      = $SITE['longitude'];   // the longitude also
    $cachedir       = $SITE['cacheDir'];	// directory to cache files     IMPORTANT setting
    #
    $commadecimal   = $SITE['commaDecimal'];//  most europeans use a comma for a decimal point.
    $charset	= $SITE['charset']; 	// default character set for webpages, UTF-8 is the modern one, windows-1252 is the most used one
    $strtolower     = $SITE['textLowerCase'];       // all texts/translations in lowercase if true
    

  • ADVANCED SETTINGS: Here you can change the appearance of the forecast, colors, rounded colors and so on. This is standard CSS stuff, so no explaining needed. Change these settings only when not using the Leuven-template.
    # ----------------------------------------------------------------------
    #                    these are the styles used for the boxes and colors
    if ($leuventemplate <> true) { 
    # ----------------------------------------------------------------------
            $darkcolor      = '#ACACAC';      // dark grey  '#ACACAC';      // dark green   '#00745B';
            $mediumcolor    = '#EEEEEE';      // light grey '#EEEEEE';      // light green  '#B1CBA0';
            $lightcolor     = 'transparent';  // transparent
            $blockdivstyle  = ' style="border-radius: 5px; margin: 5px 5px; color: black; background-color: transparent; border: 1px solid '.$darkcolor.'; border-bottom: 3px solid grey; overflow: hidden;" ';
            $blockheadstyle = ' style="font-size: 100%; border-radius: 3px; font-weight: bold; color:  white; background-color: '.$darkcolor.'; text-align: center;margin: 0;" ';
            $tablestyle     = ' style="border-collapse: collapse; width: 100%; color: black; text-align: center;" ';
            $rowdarkstyle   = ' style="background-color: '.$mediumcolor.';" ';
            $rowlightstyle  = ' style="background-color: '.$lightcolor.';" ';
    

  • As the Leuven template has a few classes which are used on almost any page, these are used here also. Not that much need to change them here. change them in the CSS files of the template.
  • And so we reached the end of the settings, if all worked well the UV forecast is adapted to your needs.
    # ------------------------------------------------------------------------------
    #           REALLY , I mean it:         do not change below this point
    # ------------------------------------------------------------------------------