/** * Constructor * * You have to supply a 'Yahoo! Where On Earth ID (WOEID)'. * If you do not supply a unit, degrees will be printed in Fahrenheit and all other attributes in English units. * For more information see {@link http://developer.yahoo.com/geo/geoplanet/guide/concepts.html} * * @param int $woeid The WOEID of the place, you want the weather information for. default = 2442047, which is the WOEID for Los Angeles, CA, USA. * @param string $unit default = 'f'. Use 'f' for °Fahrenheit or 'c' for °Celsius. **If you use Celsius, all other units will be metric units as well!** * @access public */ public function __construct($woeid = 2442047, $unit = 'f') { $this->woeid = $woeid; $this->unit = $unit; if (!Fruitframe_Cache::exists('weather_data')) { /* Let's use cURL to query the API and get all the XML data */ $curlobj = curl_init(); curl_setopt($curlobj, CURLOPT_URL, 'http://weather.yahooapis.com/forecastrss?w=' . $this->woeid . '&u=' . $this->unit); curl_setopt($curlobj, CURLOPT_RETURNTRANSFER, 1); Fruitframe_Cache::set('weather_data', $yahooapi = curl_exec($curlobj)); curl_close($curlobj); } else { $yahooapi = Fruitframe_Cache::get('weather_data'); } /* Now let's create a weather object of the returned XML */ $this->weather = new SimpleXMLElement($yahooapi); /* Some object items, we will use for our functions */ $this->weather_location = $this->weather->channel->xpath('yweather:location'); $this->weather_unit = $this->weather->channel->xpath('yweather:units'); $this->weather_wind = $this->weather->channel->xpath('yweather:wind'); $this->weather_atmosphere = $this->weather->channel->xpath('yweather:atmosphere'); $this->weather_astronomy = $this->weather->channel->xpath('yweather:astronomy'); $this->weather_condition = $this->weather->channel->item->xpath('yweather:condition'); $this->weather_forecast = $this->weather->channel->item->xpath('yweather:forecast'); }
protected function getProjects() { if (!Fruitframe_Cache::exists('projects_list')) { $query = 'SELECT * FROM ' . $GLOBALS['wpdb']->posts . ' p WHERE p.post_type = "project" AND p.post_status = "publish" ORDER BY p.post_title '; Fruitframe_Cache::set('projects_list', $GLOBALS['wpdb']->get_results($query)); } return Fruitframe_Cache::get('projects_list'); }