web/lib/Zend/View/Helper/Gravatar.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    65      * Options
    65      * Options
    66      *
    66      *
    67      * @var array
    67      * @var array
    68      */
    68      */
    69     protected $_options = array(
    69     protected $_options = array(
    70         'img_size'    => 80, 
    70         'img_size'    => 80,
    71         'default_img' => self::DEFAULT_MM, 
    71         'default_img' => self::DEFAULT_MM,
    72         'rating'      => self::RATING_G, 
    72         'rating'      => self::RATING_G,
    73         'secure'      => null,
    73         'secure'      => null,
    74     );
    74     );
    75 
    75 
    76     /**
    76     /**
    77      * Email Adress
    77      * Email Adress
   111         return $this;
   111         return $this;
   112     }
   112     }
   113 
   113 
   114     /**
   114     /**
   115      * Configure state
   115      * Configure state
   116      * 
   116      *
   117      * @param  array $options 
   117      * @param  array $options
   118      * @return Zend_View_Helper_Gravatar
   118      * @return Zend_View_Helper_Gravatar
   119      */
   119      */
   120     public function setOptions(array $options)
   120     public function setOptions(array $options)
   121     {
   121     {
   122         foreach ($options as $key => $value) {
   122         foreach ($options as $key => $value) {
   186      */
   186      */
   187     public function setRating($rating)
   187     public function setRating($rating)
   188     {
   188     {
   189         switch ($rating) {
   189         switch ($rating) {
   190             case self::RATING_G:
   190             case self::RATING_G:
   191             case self::RATING_PG: 
   191             case self::RATING_PG:
   192             case self::RATING_R: 
   192             case self::RATING_R:
   193             case self::RATING_X:
   193             case self::RATING_X:
   194                 $this->_options['rating'] = $rating;
   194                 $this->_options['rating'] = $rating;
   195                 break;
   195                 break;
   196             default:
   196             default:
   197                 require_once 'Zend/View/Exception.php';
   197                 require_once 'Zend/View/Exception.php';
   242      * @return Zend_View_Helper_Gravatar
   242      * @return Zend_View_Helper_Gravatar
   243      */
   243      */
   244     public function setSecure($flag)
   244     public function setSecure($flag)
   245     {
   245     {
   246         $this->_options['secure'] = ($flag === null) ? null : (bool) $flag;
   246         $this->_options['secure'] = ($flag === null) ? null : (bool) $flag;
   247         return $this;  
   247         return $this;
   248     }
   248     }
   249 
   249 
   250     /**
   250     /**
   251      * Get an SSL or a No-SSL location
   251      * Get an SSL or a No-SSL location
   252      *
   252      *
   262 
   262 
   263     /**
   263     /**
   264      * Get attribs of image
   264      * Get attribs of image
   265      *
   265      *
   266      * Warning!
   266      * Warning!
   267      * If you set src attrib, you get it, but this value will be overwritten in 
   267      * If you set src attrib, you get it, but this value will be overwritten in
   268      * protected method _setSrcAttribForImg(). And finally your get other src 
   268      * protected method _setSrcAttribForImg(). And finally your get other src
   269      * value!
   269      * value!
   270      *
   270      *
   271      * @return array
   271      * @return array
   272      */
   272      */
   273     public function getAttribs()
   273     public function getAttribs()
   301         return ($this->getSecure() === false) ? self::GRAVATAR_URL : self::GRAVATAR_URL_SECURE;
   301         return ($this->getSecure() === false) ? self::GRAVATAR_URL : self::GRAVATAR_URL_SECURE;
   302     }
   302     }
   303 
   303 
   304     /**
   304     /**
   305      * Get avatar url (including size, rating and default image oprions)
   305      * Get avatar url (including size, rating and default image oprions)
   306      * 
   306      *
   307      * @return string
   307      * @return string
   308      */
   308      */
   309     protected function _getAvatarUrl()
   309     protected function _getAvatarUrl()
   310     {
   310     {
   311         $src = $this->_getGravatarUrl()
   311         $src = $this->_getGravatarUrl()
   334         $attribs['src'] = $this->_getAvatarUrl();
   334         $attribs['src'] = $this->_getAvatarUrl();
   335         $this->setAttribs($attribs);
   335         $this->setAttribs($attribs);
   336     }
   336     }
   337 
   337 
   338     /**
   338     /**
   339      * Return valid image tag 
   339      * Return valid image tag
   340      *
   340      *
   341      * @return string 
   341      * @return string
   342      */
   342      */
   343     public function getImgTag()
   343     public function getImgTag()
   344     {
   344     {
   345         $this->_setSrcAttribForImg();
   345         $this->_setSrcAttribForImg();
   346         $html = '<img'
   346         $html = '<img'
   347               . $this->_htmlAttribs($this->getAttribs())
   347               . $this->_htmlAttribs($this->getAttribs())
   348               . $this->getClosingBracket();
   348               . $this->getClosingBracket();
   349 
   349 
   350         return $html;
   350         return $html;
   351     }
   351     }
   352     
   352 
   353     /**
   353     /**
   354      * Return valid image tag
   354      * Return valid image tag
   355      *
   355      *
   356      * @return string
   356      * @return string
   357      */
   357      */