Elxis CMS Forum

Extensions => Components => Topic started by: eliasbou on April 19, 2011, 16:40:22

Title: Weather component (error)
Post by: eliasbou on April 19, 2011, 16:40:22
Hi. After installation component weather in clean installation elxis in the appearance component I take and something waste, you know what can be. I thank.

[attachment deleted by admin]
Title: Re: Weather component (error)
Post by: acampball on April 19, 2011, 20:09:02
Write the address of the site
Title: Re: Weather component (error)
Post by: eliasbou on April 20, 2011, 08:42:59
http://www.ofmessinia.gr/
Title: Re: Weather component (error)
Post by: acampball on April 20, 2011, 16:16:31
I'm confused.
Maybe I forgot to remove debugging information.

Get me you e-mail, i send new component
Title: Re: Weather component (error)
Post by: eliasbou on April 21, 2011, 08:17:56
Hello. I got email and installed new component but did not exist no change. I tryed him http://www.webico.gr/demo/elxis/ and for i got the same result.
I thank.
Title: Re: Weather component (error)
Post by: acampball on April 21, 2011, 16:37:22
Replace this file in /administrator/components/com_weather/includes and test.

[attachment deleted by admin]
Title: Re: Weather component (error)
Post by: eliasbou on April 21, 2011, 18:04:33
Τhe same fault   :-[
Title: Re: Weather component (error)
Post by: datahell on April 21, 2011, 22:16:57
The problem is caused here:
file: includes/weather.class.php
line: 148
$this->cache_file = $this->cache_path . '/' . $this->filename_safe(eUTF::utf8_to_ascii($this->location)."_".$this->lang);

I advice you not to use the utf-8 encoded location name as the filename for cache. After the conversions you do you change the cache filename and when you want to used the cached file the reverse conversion might not be the same...
Use the location's id instead to generate the cache file.

So add a new attribute in weatherPlugin class constructor named "locid" (note that I made all attributes required).
public function __construct($location, (bool)$browse_lang, (int)$locid) {

Then do this:
$this->cache_file = $this->cache_path.'/'.$locid.'_'.$this->lang;

I also advise you to use a prefix and get the md5 value for the string for the cache filename.
Example:
$this->cache_file = $this->cache_path.'/'.md5('weather_'.$locid.'_'.$this->lang);

and open weather.php and change this:
$plugin = new $plugin_class($row->location, $cweather->cfg->get('GFBROWSE_LANG', 1));
To this:
$plugin = new $plugin_class($row->location, $cweather->cfg->get('GFBROWSE_LANG', 1), $row->id);

Check if you need to update more files in order to feed the weatherPlugin  constructor with the proper location id.

Related tip:
A cool way to get rid of special characters and tags for a string is to use the php's 5.2+ filter_var function:

$clean = filter_var($unclean_var, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
If your string contains non ascii characters then use only the "LOW" flag.
Title: Re: Weather component (error)
Post by: acampball on April 22, 2011, 08:28:32
New version 1.2 updated on EDC.
Title: Re: Weather component (error)
Post by: eliasbou on April 22, 2011, 20:01:20
With the new version all work OK, thank.  ;)