[pLog-svn] r792 - plugins/trunk/gravatar

mark at devel.plogworld.net mark at devel.plogworld.net
Sat Jan 22 13:51:53 GMT 2005


Author: mark
Date: 2005-01-22 13:51:53 +0000 (Sat, 22 Jan 2005)
New Revision: 792

Modified:
   plugins/trunk/gravatar/plugingravatar.class.php
Log:
Add rating implementation.

Modified: plugins/trunk/gravatar/plugingravatar.class.php
===================================================================
--- plugins/trunk/gravatar/plugingravatar.class.php	2005-01-22 13:04:44 UTC (rev 791)
+++ plugins/trunk/gravatar/plugingravatar.class.php	2005-01-22 13:51:53 UTC (rev 792)
@@ -1,6 +1,6 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+    include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
     include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
 
     /**
@@ -8,42 +8,40 @@
      */
 
 
-class PluginGravatar extends PluginBase {
+    class PluginGravatar extends PluginBase {
 
-  function PluginGravatar()
-  {
-    $this->PluginBase();
-    $this->desc = "<p>Returns the URL of an (gr)avatar for every comment. The image is loaded from Gravatar.com</p>
-                   <p>In order to use, simply include the following:<br/><br/>
-                   <strongs>{\$gravatar->gravatar(\$comment,\$default,\$size)}</strong><br/>
-                   <p>Where \$default is the URL of the default image that will be shown in case there is no gravatar available
-                   or if the user did not give an email address. \$size is the desired size in pixels of the gravatar.</p>
-                   <p>Example:</p>
-                   <pre>
-&lt;img class=\"gravatar\" 
-src=\"{\$gravatar->gravatar(\$comment,\"http://lalah.com/default.png\",40)}\" 
-alt=\"{\$comment->getUsername()}\" 
-title=\"{\$comment->getUsername()}\" 
-width=\"40\" height=\"40\" /&gt;
-</pre>";
-    $this->author = "Dani Armengol";
-    $this->id = "gravatar";
-    $this->locales = Array();
-  }
+        function PluginGravatar()
+        {
+            $this->PluginBase();
+            $this->desc = "<p>Returns the URL of an (gr)avatar for every comment. The image is loaded from Gravatar.com</p>
+                           <p>In order to use, simply include the following:<br/><br/>
+                           <strongs>{\$gravatar->gravatar(\$comment,\$rating,\$default,\$size)}</strong><br/>
+                           <p>Where \$default is the URL of the default image that will be shown in case there is no gravatar available
+                           or if the user did not give an email address. \$size is the desired size in pixels of the gravatar.</p>
+                           <p>Example:</p>
+                           &lt;img class=\"gravatar\" <br/>
+                           src=\"{\$gravatar->gravatar(\$comment,\"R\",\"http://lalah.com/default.png\",40)}\" <br/>
+                           alt=\"{\$comment->getUsername()}\" <br/>
+                           title=\"{\$comment->getUsername()}\" <br/>
+                           width=\"40\" height=\"40\" /&gt;";
+            $this->author = "Dani Armengol";
+            $this->id = "gravatar";
+            $this->locales = Array();
+        }
 
-  function gravatar($comment,$default,$mida)
-  {
-    if($comment->getUserEmail() != "")
-      {
-	$grav_url = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->getUserEmail())."&amp;default=".urlencode($default)."&amp;size=".$mida;
-      }
-    else
-      {
-	$grav_url = $default;
-      }
-    
-    return $grav_url;
-  }
+        function gravatar($comment,$rating,$default,$size)
+        {
+            if($rating != "G" && $rating != "PG" && $rating != "R" && $rating != "X")
+                $rating = "R";
+                
+            if($comment->getUserEmail() != "")
+            {
+	            $grav_url = "http://www.gravatar.com/avatar.php?rating=".$rating."&amp;gravatar_id=".md5($comment->getUserEmail())."&amp;default=".urlencode($default)."&amp;size=".$size;
+            } else {
+	            $grav_url = $default;
+            }
 
-}
+            return $grav_url;
+        }
+    }
 ?>




More information about the pLog-svn mailing list