View Single Post
Old 01-09-2008, 02:34 AM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,215
Thanks: 90
Wildhoney is on a distinguished road
Default

Version 1.1

I actually decided to work on version 1.1 which contains a cache built in. It recognises the avatar sizes, and will download a fresh copy from the Gravatar server when the current avatar expires. This can easily be changed by opening up the TalkPHP_Gravatar_Cache.php file and modifying the class constant at the top. It is currently set at 5 days.

There are only a couple of additions to the above code that you need to concern yourself with - one of which is you now have to include 2 files. I've separated the classes into 2 classes to make them more manageable. The index.php file shows you how to include the second file, but it's nothing complicated in the least:

php Code:
include_once('./TalkPHP_Gravatar.php');
include_once('./TalkPHP_Gravatar_Cache.php');

The functionality still performs exactly the same as version 1.0 above. There is a directory called /cache/ which should be writeable, so don't forget to set the correct permissions on that. Typically 777.

Last but not least, for the more technically minded, I have added an exception for if the cache class is not TalkPHP_Gravatar_Cache. An exception will be thrown if it isn't to save on any problems. As you shouldn't see this error unless you drastically modify the script, there's really no need to put the class instantiation and method calls in a try and catch block, but it's entirely up to you.
Attached Files
File Type: zip TalkPHP.com_Gravatar.version.1_1.zip (1.4 KB, 138 views)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.

Last edited by Wildhoney : 01-09-2008 at 03:23 AM.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
ciprianmp (06-05-2008)