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

Source for file week.php

Documentation is available at week.php

  1. <?php
  2. /**
  3.  * Week display.
  4.  * This file displays the week view consiting of seven 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. /** Configuration file */
  27. require_once("conf.php");
  28. /** Debugging functions */
  29. require_once("debugging.php");
  30. /** Week class */
  31. require_once("week_class.php");
  32. /** HRDI database class */
  33. require_once("hrdi_db_class.php");
  34. /** PHP session class */
  35. require_once("session_class.php");
  36. /** Common class */
  37. require_once("common_class.php");
  38. /** User class */
  39. require_once("user_class.php");
  40.  
  41. // Check to see if we're in offline mode
  42. $offline common::offline();
  43.  
  44. // HRDI database instance
  45. $hdb new hrdi_db ($dsn);
  46.  
  47. // Page title
  48. $page_title "Week View";
  49.  
  50. if ($offline{
  51.   $user new user($hdb);
  52. else {
  53.   // Start the session
  54.     $session new session();
  55.   $user new user($hdb$session);
  56. }
  57.  
  58. if ($offline{
  59.   // Get the day from the command line argument
  60.     $uars_day $argv[1];
  61. else {
  62.   // Get the day from the $_GET array
  63.     $uars_day @$_GET['uars_day'];
  64. }
  65.  
  66. // Validate the UARS day
  67. if (!is_numeric($uars_day|| ($uars_day 1)) {
  68.   if ($offline{
  69.     print "UARS Day is not valid";
  70.   else {
  71.     require_once("header.php");
  72.     error("UARS Day is not valid");
  73.     require_once("footer.php");
  74.   }
  75.  
  76.   exit(0);
  77. }
  78.  
  79. // Create a week class instance for the UARS day
  80. $week new week ($hdb$uars_day);
  81.  
  82. // Include the correct header
  83. if ($offline{
  84.   require_once("offline_header.php");
  85. else {
  86.   require_once("header.php");
  87. }
  88.  
  89. print "<div class=\"prev_next\">";
  90.  
  91. // Generate previous week link
  92. if (($uars_day $week->dow0{
  93.   $pday $uars_day 7;
  94.   if ($pday 1$pday 1;
  95.  
  96.   if ($offline{
  97.     $pweek floor(($pday 37);
  98.     $link "week_$pweek.html";
  99.   else {
  100.     $link "week.php?uars_day=$pday";
  101.   }
  102.  
  103.   print "<a href=\"$link\">&larrPrevious Week</a>";
  104. }
  105.  
  106. print "&nbsp;&nbsp;&nbsp;&nbsp;";
  107.  
  108. if (($uars_day $week->dow 7$week->newest{
  109.   // Generate next week link
  110.     $nday $uars_day 7;
  111.  
  112.   if ($offline{
  113.     $nweek floor(($nday 37);
  114.     $link "week_$nweek.html";
  115.   else {
  116.     $link "week.php?uars_day=$nday";
  117.   }
  118.  
  119.   print "<a href=\"$link\">Next Week &rarr;</a></div>";
  120. }
  121.  
  122. // Display the week table
  123. ?>
  124. <center>
  125. <table class="hrdi" id="week">
  126.   <tr class="c_label">
  127.     <td>UARS</td>
  128.     <td nowrap>Year-DOY</td>
  129.     <td>Date</td>
  130.     <td>Data Quality</td>
  131.     <td>Flight Direction</td>
  132.     <td>Beta Angle (deg.)</td>
  133.     <td nowrap>Pid: Azimuths</td>
  134.     <td align="left" width="49%">Comments</td>
  135.   </tr>
  136. <?php
  137. // Initialize the pids array
  138. $pids array();
  139.  
  140. $j 0;
  141.  
  142. for ($i 0$i 7$i++{
  143.   // Display each UARS day object
  144.     if (is_object(@$week->days[$i])) {
  145.     if ($offline{
  146.       $link "day_".$week->days[$i]->day.".html";
  147.     else {
  148.       $link "day.php?uars_day=".$week->days[$i]->day;
  149.     }
  150.  
  151.     // determine pretty output for Data_Valid flag
  152.         $valid_str '';
  153.     if ($week->days[$i]->data['Data_Valid'== NULL{
  154.       $valid_str "Unspecified";
  155.     elseif ($week->days[$i]->data['Data_Valid'== 1{
  156.       $valid_str "Valid";
  157.     else if ($week->days[$i]->data['Data_Valid'=== "0"{
  158.       $valid_str "Not Valid";
  159.     }
  160.  
  161.     // Print out the UARS day data
  162.         print "<tr class=\"data\" valign=\"top\"><td><a href=\"$link\">"
  163.         . $week->days[$i]->day
  164.         . "</a></td><td nowrap>"
  165.         . $week->days[$i]->data['Year']
  166.         . "-"
  167.         . $week->days[$i]->data['Day_Of_Year']
  168.         . "</td><td>"
  169.         . $week->days[$i]->data['Date']
  170.         . "</td><td>"
  171.         . $valid_str
  172.         . "</td><td nowrap>"
  173.         . @$week->days[$i]->data['Flight_Direction']
  174.         . "</td><td>"
  175.         . @$week->days[$i]->data['Beta_Angle']
  176.         . "</td><td nowrap>";
  177.  
  178.     // Create the pids table
  179.         foreach ($week->days[$i]->modes as $mode{
  180.       // If the mode has a description
  181.             if (strlen(trim($mode['Description']))) {
  182.         if (array_key_exists($mode['Description']$pids)) {
  183.           // We already have the description
  184.                     $def $pids[$mode['Description']]['Def'];
  185.         else {
  186.           // New description
  187.                     $pids[$mode['Description']]['Pid'$mode['Process_ID'];
  188.           $pids[$mode['Description']]['Def'$def $j;
  189.           $j++;
  190.         }
  191.  
  192.         print common::deflink($mode['Process_ID']$def);
  193.       else {
  194.         print $mode['Process_ID'];
  195.       }
  196.  
  197.       // Display the modes
  198.             print ": "
  199.           . $mode['Azimuth1']
  200.           . ", "
  201.           . $mode['Azimuth2']
  202.           . ", "
  203.           . $mode['Azimuth3']
  204.           . ", "
  205.           . $mode['Azimuth4']
  206.           . "<br/>\n";
  207.     }
  208.  
  209.     // Add line breaks to meet the minimum number of mode rows
  210.         for ($j count($week->days[$i]->modes)$j $min_mode_rows$j++{
  211.       print "<br/>\n";
  212.     }
  213.  
  214.     // Print out the comments
  215.         print "</td><td>"
  216.         . @$week->days[$i]->data['Comments']
  217.         . "</td></tr>\n";
  218.   }
  219. }
  220. ?>
  221. </table>
  222. <br/>
  223. <?php
  224.   asort($pids);
  225.  
  226.   $pids_string "";
  227.   $jscript_string "";
  228.  
  229.   // Create the additional JavaScript array indexes for the popup display
  230.     foreach ($pids as $desc => $keys{
  231.     $pids_string .= "<tr class=\"data\"><td>{$keys['Pid']}</td><td>$desc</td></tr>\n";
  232.     $jscript_string .= "defs['{$keys['Def']}'] = '$desc';\n";
  233.   }
  234. ?>
  235. <table class="hrdi" id="pids">
  236.   <tr class="label"><td>Pid</th><td>Description</td></tr>
  237.   <?php
  238.     // Print out the pids table
  239.         print $pids_string;
  240.   ?>
  241. </table>
  242. </center>
  243. <script type="text/javascript">
  244.   <?php
  245.     // Print out the JavaScript array
  246.         print $jscript_string;
  247.   ?>
  248. </script>
  249. <?php
  250. // Include the page footer
  251. require_once("footer.php");
  252. ?>

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