HRDIODB
[ class tree: HRDIODB ] [ index: HRDIODB ] [ all elements ]

Source for file week_class.php

Documentation is available at week_class.php

  1. <?php
  2. /**
  3.  * A week of UARS Days.
  4.  * This file contains the week class, which represents a week of UARS Days.
  5.  * @package HRDIODB
  6.  */
  7.  
  8. /**
  9.  * This file is part of HRDIODB.
  10.  *
  11.  * HRDIODB is free software; you can redistribute it and/or modify
  12.  * it under the terms of the GNU General Public License as published by
  13.  * the Free Software Foundation; either version 2 of the License, or
  14.  * (at your option) any later version.
  15.  *
  16.  * HRDIODB is distributed in the hope that it will be useful,
  17.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  * GNU General Public License for more details.
  20.  *
  21.  * You should have received a copy of the GNU General Public License
  22.  * along with HRDIODB; if not, write to the Free Software
  23.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24.  */
  25.  
  26. /** UARS day class */
  27. require_once('uars_day_class.php');
  28.  
  29. /**
  30.  * The week class.
  31.  * The week class contains the 7 UARS Days that make up a given week. Each
  32.  * UARS Day is represented by a uars_day object.
  33.  * @package HRDIODB
  34.  */
  35. class week {
  36.   /**
  37.    * The hrdi_db class instance.
  38.    * @var $hdb 
  39.    */
  40.   var $hdb;
  41.  
  42.   /**
  43.    * Array of uars_day objects.
  44.    * @var $days 
  45.    */
  46.   var $days = array();
  47.  
  48.   /**
  49.    * Day of week of the day passed in.
  50.    * @var $dow 
  51.    */
  52.   var $dow;
  53.  
  54.   /**
  55.    * Newest UARS day in the database.
  56.    * @var $days 
  57.    */
  58.   var $newest;
  59.  
  60.   /**
  61.    * Constructor.
  62.    * The week class constructor. The constructor populates the $days array,
  63.    * which will contain up to 7 {@link uars_day} objects, one for each UARS
  64.    * Day in the week.
  65.    * @param hrdi_db $hdb The hrdi_db instance
  66.    * @param integer $uars_day UARS Day which is part of this week
  67.    */
  68.   function week (&$hdb$uars_day{
  69.     $this->hdb = $hdb;
  70.  
  71.     // Get the newest UARS day from the database
  72.     $sql "SELECT UARS_Day
  73.             FROM HRDI_Days
  74.             ORDER BY UARS_Day DESC
  75.             LIMIT 1";
  76.  
  77.     $this->newest = $this->hdb->get_one($sql)
  78.  
  79.     // Create a uars_day object for the passed in day
  80.     $day new uars_day($this->hdb$uars_day);
  81.  
  82.     // The day of the week for the passed in day
  83.     $this->dow = $day->data['DoW_Numeric'];
  84.  
  85.     // For each of the 7 days in a week
  86.     for ($i 0$i 7$i++{
  87.       if ($i $this->dow{
  88.         // We're looking at a day before the one passed in
  89.         $ud $uars_day ($this->dow - $i);
  90.  
  91.         // Check to see if we're looking at day after UARS day 1
  92.         if (($ud 0&& ($ud <= $this->newest)) {
  93.           $this->days[$i=new uars_day($this->hdb$ud);
  94.         }
  95.       else if ($i $this->dow{
  96.         // We're looking at a day after the one passed in
  97.         $ud $uars_day ($i $this->dow);
  98.  
  99.         // Check to see that the day is not after the newest day in the database
  100.         if ($ud <= $this->newest{
  101.           $this->days[$i=new uars_day($this->hdb$ud);
  102.         }
  103.       else if ($i == $this->dow{
  104.         // We're looking at the day that was passed in
  105.         $ud $uars_day;
  106.  
  107.         if (($ud <= $this->newest&& ($ud 0)) {
  108.           $this->days[$i=new uars_day($this->hdb$ud);
  109.         }
  110.       }
  111.     }
  112.   }
  113. }
  114. ?>

Documentation generated on Tue, 23 Jan 2007 22:57:55 -0500 by phpDocumentor 1.3.0RC6