I've been looking at the new OOP pre2.0 version of PHP Weather in CVS on SourceForge. Looks great. I'm implementing it on part of our school's site, since internationalization appears to be the only thing fully lacking. A couple of suggestions I have for the code (everybody feel free to comment) : The current DB class and file name creates conflicts with PHPlib. Since PHPlib is so widely used, I suggest this issue be resolved. db_pgsql, db_mysql are TOO generic of names for the phpweather db classes. I ran regular expressions on the entire tree to change db_* to dbphpweather_*. I also renamed the db_pgsql.php to dbphpweather_pgsql.php, etc... I suggest returning HTML in a string for the print functions instead of echoing it directly. It allows for easy regular expression parsing for output so minimal modification to phpweather is necessary. and it's easy to issue a 'echo $weatherHTML; ' ;) code in the attachment will show this. I also think that phpweather->print_table() should be expanded to: phpweather->return_horz_table() // returns a horizontally wide HTML table phpweather->return_vert_table() // returns a vertically wide HTML table Again, code in the attachment will demonstrate. I am also modififying the print functions to allow for cascading style sheet formatting. I will post the code when I am successful - want to contribute something to this Open Source project ;) I am somewhat new to the web development realm, my background is in the sysadmin area, so it may take me a bit... Let me know what you guys think :) -Chris Len [EMAIL PROTECTED] Web Applications Developer Information & Media Technology Azusa Pacific University
//*********************************************** //* add to ./phpweather.php, phpweather class * //*********************************************** function return_horiz_table() { if (empty($this->decoded_metar)) { $this->decode_metar(); } return $this->output->return_horiz_table($this->decoded_metar); } function return_vert_table() { if (empty($this->decoded_metar)) { $this->decode_metar(); } return $this->output->return_vert_table($this->decoded_metar); } //************************************************************ //* add to ./locales/locale_common.php, class locale_common * //************************************************************ function return_horiz_table($data) { // This function is based off the print_table function // returns HTML instead of directly printing // uses a different table format (expanded horizontal instead of vertical) extract($data); $minutes = round((time() - $time)/60); $wind = $this->pref_units($wind['meters_per_second'] . ' mps', $wind['miles_per_hour'] . ' mph') . '/' . $this->strings['wind_dir_short'][intval(round($wind['deg']/22.5))]; $temp = $this->pref_units($temperature['temp_c'] . '°C', $temperature['temp_f'] . '°F'); $pressure = $this->pref_units($altimeter['hpa'] . ' hPa', $altimeter['inhg'] . ' inHg'); /* The table-heading ought to be translated. */ $to_be_echoed = "<table> <tr> <th>Station</th> <th>Age (minutes)</th> <th>Wind/Direction</th> <th>Temperature</th> <th>Pressure</th> <th>Humidity</th> </tr> <tr> <td>$location</td> <td>$minutes</td> <td>$wind</td> <td>$temp</td> <td>$pressure</td> <td>$rel_humidity%</td> </tr> </table> "; return $to_be_echoed; } function return_vert_table($data) { // This function is based off the print_table function // returns HTML instead of directly printing // uses a different table format (expanded vertically instead of horiz.ly) extract($data); $minutes = round((time() - $time)/60); $wind = $this->pref_units($wind['meters_per_second'] . ' mps', $wind['miles_per_hour'] . ' mph') . '/' . $this->strings['wind_dir_short'][intval(round($wind['deg']/22.5))]; $temp = $this->pref_units($temperature['temp_c'] . '°C', $temperature['temp_f'] . '°F'); $pressure = $this->pref_units($altimeter['hpa'] . ' hPa', $altimeter['inhg'] . ' inHg'); /* The table-heading ought to be translated. */ $to_be_echoed="<table> <tr> <th>Field</th> <th>Value</th> </tr> <tr><td>Station</td> <td>$location</td></tr> <tr><td>Age (minutes)</td> <td>$minutes</td></tr> <tr><td>Wind/Direction</td> <td>$wind</td></tr> <tr><td>Temperature</td> <td>$temp</td></tr> <tr><td>Pressure</td> <td>$pressure</td></tr> <tr><td>Humidity</td> <td>$rel_humidity%</td></tr> </table>"; return $to_be_echoed; }