Gravatar.php

Go to the documentation of this file.
00001 <?php
00002 
00032 class Robo47_View_Helper_Gravatar extends Zend_View_Helper_HtmlElement
00033 {
00034 
00038     protected $_service = null;
00039 
00047     public function __construct(Robo47_Service_Gravatar $service = null)
00048     {
00049         $this->setService($service);
00050     }
00051 
00058     public function setService(Robo47_Service_Gravatar $service = null)
00059     {
00060         if (null === $service) {
00061             $service = new Robo47_Service_Gravatar();
00062         }
00063         $this->_service = $service;
00064         return $this;
00065     }
00066 
00072     public function getService()
00073     {
00074         return $this->_service;
00075     }
00076 
00084     public function Gravatar($email, $size = null, $rating = null,
00085         $default = null, $ssl = null, $separator = '&amp;',
00086         array $params = array())
00087     {
00088         $params['src'] = $this->_service->getUri(
00089             $email,
00090             $size,
00091             $rating,
00092             $default,
00093             $ssl,
00094             $separator
00095         );
00096         if (!isset($params['alt'])) {
00097             $params['alt'] = 'Gravatar ' .
00098                 $this->_service->getGravatarHash($email);
00099         }
00100         $image = '<img ';
00101         $image .= $this->_htmlAttribs($params);
00102         $image .= $this->getClosingBracket();
00103         return $image;
00104     }
00105 }