3
* This file implements the CommentGravatars plugin for Quam Plures
5
* This plugin displays a commentator's gravatar (Globally Recognized Avatar) if they've registered for a
6
* free account with gravatar.com. If not, it displays one of three uniquely generated
7
* avatars (identicons, wavatars or monsterids -- your choice).
9
* Designed as a no muss, no fuss way to add avatars to the comments of your blog without having
10
* to bother with uploading files or doing any template coding.
12
* Works for registered users of your blog as well as visitors.'
14
* Quam Plures - {@link http://quamplures.net/}
15
* Released under GNU GPL License - {@link http://quamplures.net/license.html}
16
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
3
* This file implements the CommentGravatars plugin
5
* This plugin displays a commentator's gravatar (Globally Recognized Avatar) if
6
* they've registered for a free account with gravatar.com. If not, it displays
7
* one of three uniquely generated avatars (identicons, wavatars or monsterids
10
* Designed as a no muss, no fuss way to add avatars to the comments of your blog
11
* without having to bother with uploading files or doing any template coding.
13
* @author {@link http://wonderwinds.com/ Ed Bennett}
14
* @author {@link http://www.bushleaguecritic.com/ Bush League Critic}
15
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
16
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
19
18
* @subpackage CommentGravatars
21
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
20
if(!defined('QP_MAIN_INIT')) die('fail');
42
40
function PluginInit( & $params )
44
42
$this->name = $this->T_('Comment Gravatars');
45
$this->short_desc = $this->T_( 'Simple plugin to display avatars/gravatars for people leaving comments' );
46
$this->long_desc = $this->T_( '<p>This plugin displays a commentator\'s gravatar (Globally Recognized Avatar) if they\'ve registered for a
43
$this->short_desc = $this->T_('Simple plugin to display avatars/gravatars for people leaving comments');
44
$this->long_desc = $this->T_('<p>This plugin displays a commentator\'s gravatar (Globally Recognized Avatar) if they\'ve registered for a
47
45
free account with gravatar.com. If not, it displays one of three uniquely generated avatars (identicons, wavatars or monsterids
48
46
-- your choice).</p><p>Designed for a no muss, no fuss way to add avatars to the comments of your blog without having to bother
49
with uploading files or doing any template coding.</p><p>Works for registered users of your blog as well as visitors.</p>' );
47
with uploading files or doing any template coding.</p><p>Works for registered users of your blog as well as visitors.</p>');
92
* @see Plugin::GetDefaultBlogSettings()
94
function GetDefaultBlogSettings( & $params )
96
$blog_settings = array(
97
'enable_avatars' => array(
98
'label' => $this->T_('Enable Comment Avatars'),
101
'note' => sprintf( $this->T_('Check this to enable the %s plugin for this blog.'), $this->name ),
103
'no_gravatar' => array(
104
'label' => $this->T_('No Gravatar'),
107
'identicon' => $this->T_('Uniquely generated fractal glyph (Identicons)'),
108
'monsterid' => $this->T_('Uniquely generated monster (Monsterids)'),
109
'wavatar' => $this->T_('Uniquely generated face (Wavatars)'),
110
'default' => $this->T_('Gravatar default (Blue \'G\')'),
112
'defaultvalue' => 'identicon',
113
'note' => sprintf( $this->T_('What to display if commentator isn\'t registered at %s'), 'gravatar.com' ),
115
'gravatar_justify' => array(
116
'label' => $this->T_('Display Avatar'),
119
'float:left' => $this->T_('Left of the comment'),
120
'float:right' => $this->T_('Right of the comment'),
122
'defaultvalue' => 'float:left',
123
'note' => $this->T_('Place the gravatar to the left or right of the comment'),
125
'gravatar_size' => array(
126
'label' => $this->T_('Avatar Size'),
129
'40' => $this->T_('40x40 Pixels'),
130
'60' => $this->T_('60x60 Pixels'),
131
'80' => $this->T_('80x80 Pixels'),
133
'defaultvalue' => '60',
134
'note' => $this->T_('What size gravatar image to display'),
136
'gravatar_rating' => array(
137
'label' => $this->T_('Gravatar Rating'),
140
'g' => $this->T_('G-Rated gravatars'),
141
'pg' => $this->T_('PG/G-Rated gravatars'),
142
'r' => $this->T_('R/PG/G-Rated gravatars'),
143
'x' => $this->T_('X/R/PG/G-Rated gravatars'),
145
'defaultvalue' => 'g',
146
'note' => $this->T_('Limit the explicitness of commentators gravatars'),
149
return $blog_settings;
93
154
* This is what makes it all go.
95
156
function display_gravatar( $params )
97
158
// Get the settings from the params and plugin settings
98
159
$tmp_Blog = $params['Comment']->Item->get_Blog();
99
160
$params = array_merge( array(
100
'random' => $this->get_coll_setting( 'no_gravatar', $tmp_Blog ),
101
'rating' => $this->get_coll_setting( 'gravatar_rating', $tmp_Blog ),
102
'before' => '<div style="'.$this->get_coll_setting( 'gravatar_justify', $tmp_Blog ).'">',
161
'random' => $this->get_blog_setting( 'no_gravatar', $tmp_Blog ),
162
'rating' => $this->get_blog_setting( 'gravatar_rating', $tmp_Blog ),
163
'before' => '<div style="'.$this->get_blog_setting( 'gravatar_justify', $tmp_Blog ).'">',
103
164
'after' => '</div>',
104
'size' => $this->get_coll_setting( 'gravatar_size', $tmp_Blog ),
165
'size' => $this->get_blog_setting( 'gravatar_size', $tmp_Blog ),
105
166
'gravatar_title' => ( empty( $params['Comment']->author_User ) ? $params['Comment']->author : $params['Comment']->author_User->get_preferred_name() ),
106
167
'gravatar_email' => ( empty( $params['Comment']->author_User ) ? $params['Comment']->author_email : $params['Comment']->author_User->email ),
109
170
// Build the url to retrieve the correct gravatar from gravatar.com.
110
171
$url = 'http://www.gravatar.com/avatar.php?gravatar_id='.md5( $params['gravatar_email'] );
111
172
$url .= '&rating='.urlencode( $params['rating'] );
112
if ($params['random'] != 'default') {
173
if( $params['random'] != 'default' )
113
175
// If the email address isn't registered at gravatar.com;
114
176
// Return one of three styles of uniquely generated 'identicons'.
115
177
$url .= '&default='.urlencode( $params['random'] );
190
* @see Plugin::GetDefaultBlogSettings()
192
function GetDefaultBlogSettings( & $params )
195
'enable_avatars' => array(
196
'label' => $this->T_('Enable Comment Avatars'),
197
'type' => 'checkbox',
199
'note' => sprintf( $this->T_('Check this to enable the %s plugin for this blog.'), $this->name ),
201
'no_gravatar' => array(
202
'label' => $this->T_('No Gravatar'),
204
'defaultvalue' => 'identicon',
206
'identicon' => $this->T_('Uniquely generated fractal glyph (Identicons)'),
207
'monsterid' => $this->T_('Uniquely generated monster (Monsterids)'),
208
'wavatar' => $this->T_('Uniquely generated face (Wavatars)'),
209
'default' => $this->T_('Gravatar default (Blue \'G\')'),
211
'note' => sprintf($this->T_('What to display if commentator isn\'t registered at %s'),
214
'gravatar_justify' => array(
215
'label' => $this->T_('Display Avatar'),
217
'defaultvalue' => 'float:left',
219
'float:left' => $this->T_('Left of the comment'),
220
'float:right' => $this->T_('Right of the comment'),
222
'note' => $this->T_('Place the gravatar to the left or right of the comment'),
224
'gravatar_size' => array(
225
'label' => $this->T_('Avatar Size'),
227
'defaultvalue' => '60',
229
'40' => $this->T_('40x40 Pixels'),
230
'60' => $this->T_('60x60 Pixels'),
231
'80' => $this->T_('80x80 Pixels'),
233
'note' => $this->T_('What size gravatar image to display'),
235
'gravatar_rating' => array(
236
'label' => $this->T_('Gravatar Rating'),
238
'defaultvalue' => 'g',
240
'g' => $this->T_('G-Rated gravatars'),
241
'pg' => $this->T_('PG/G-Rated gravatars'),
242
'r' => $this->T_('R/PG/G-Rated gravatars'),
243
'x' => $this->T_('X/R/PG/G-Rated gravatars'),
245
'note' => $this->T_('Limit the explicitness of commentators gravatars'),
252
253
* @see Plugin::FilterCommentContent()
254
255
function FilterCommentContent( & $params )
256
if ( ! $this->get_coll_setting( 'enable_avatars', $params['Comment']->Item->get_Blog() ) )
257
if( ! $this->get_blog_setting( 'enable_avatars', $params['Comment']->Item->get_Blog() ) )