Changeset 90
- Timestamp:
- 06/01/07 18:31:43 (5 years ago)
- File:
-
- 1 edited
-
openweather/openweather.module (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
openweather/openweather.module
r89 r90 121 121 } 122 122 123 /** 124 * _page hook 125 * Display official stats, and a list of weather stations w/ stats 126 */ 123 127 function openweather_page() { 124 128 global $user; … … 127 131 128 132 // If there is official weather get it 129 $radarURL = get_variable('openweather_radar', null);133 $radarURL = variable_get('openweather_radar', null); 130 134 if ($radarURL != null) $output .= "<img src='$radarURL'/>"; 131 135 … … 136 140 $output .= '<ul>'; 137 141 while ($node = db_fetch_object($result)) { 138 $output .= '<li>'. l($node->title, "node/$node->nid") .'</li>';142 $output .= '<li>'. l($node->title, "node/$node->nid").openweather_summary($node->nid) .'</li>'; 139 143 } 140 144 $output .= '</ul>'; 141 145 $output .= theme("pager", NULL, 15); 142 146 return $output; 147 } 148 149 function openweather_settings() { 150 $form['openweather_radar'] = array( 151 '#type'=>'textfield', 152 '#title'=>t('URL for weather radar'), 153 '#default_value'=>variable_get('openweather_radar', '')); 154 155 return $form; 143 156 } 144 157 … … 195 208 196 209 /** 210 * Summary table of weather station feed 211 */ 212 function openweather_summary($nid){ 213 $data = db_query("SELECT * FROM {openweather_readings} WHERE nid = $nid ORDER BY `time` DESC LIMIT 1"); 214 $data = db_fetch_object($data); 215 216 $output .= "<table>"; 217 $output .= "<tr><th>Temperature</th><td>$data->temp_out dec C</td><th>Humidity</th><td>$data->rel_hum_out %</td></tr>"; 218 $output .= "<tr><th>Wind speed</th><td>$data->windspeed kMh</td><th>Wind direction</th><td>".openweather_to_direction($data->wind_angle)."($data->wind_angle)</td></tr>"; 219 $output .= "<tr><th>Relative pressure</th><td>$data->rel_pressure</td><th>Timestamp</th><td>$data->time</td></tr>"; 220 $output .= "</table>"; 221 return $output; 222 } 223 224 /** 197 225 * Implementation of hook_view(). 198 226 * … … 209 237 $links[] = l(t('export readings'), 'node/'.$node->nid.'/csv_readings',array('title'=>'Export the openweather readings as CSV')); 210 238 211 $data = db_query("SELECT * FROM {openweather_readings} WHERE nid = $node->nid ORDER BY `time` DESC LIMIT 1"); 212 $data = db_fetch_object($data); 213 214 $output .= "<table>"; 215 $output .= "<tr><th>Temperature</th><td>$data->temp_out dec C</td><th>Humidity</th><td>$data->rel_hum_out %</td></tr>"; 216 $output .= "<tr><th>Wind speed</th><td>$data->windspeed kMh</td><th>Wind direction</th><td>".openweather_to_direction($data->wind_angle)."($data->wind_angle)</td></tr>"; 217 $output .= "<tr><th>Relative pressure</th><td>$data->rel_pressure</td><th></th><td></td></tr>"; 218 $output .= "</table>"; 239 $output .= openweather_summary($node->nid); 219 240 220 241 $output .= "<img src='?q=node/".$node->nid."/graph/temp_out' />";
Note: See TracChangeset
for help on using the changeset viewer.
