summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-01-10 06:18:35 +0000
committerBharat Mediratta <bharat@menalto.com>2009-01-10 06:18:35 +0000
commit9b90b4b0cd464424f3f9a4214d265db69b3691dc (patch)
treea8e42c5442b5ed06aba7637ba33fcb49af8a833a /modules
parent5690e58c4577e9b0a29f0c1d95edc7e6715a2cf6 (diff)
Use the theme's avatar as the default if Gravatar doesn't have one.
Diffstat (limited to 'modules')
-rw-r--r--modules/comment/views/admin_block_recent_comments.html.php9
-rw-r--r--modules/comment/views/admin_comments.html.php3
-rw-r--r--modules/comment/views/comment.html.php3
-rw-r--r--modules/comment/views/comments.html.php3
-rw-r--r--modules/user/models/user.php6
5 files changed, 15 insertions, 9 deletions
diff --git a/modules/comment/views/admin_block_recent_comments.html.php b/modules/comment/views/admin_block_recent_comments.html.php
index 2d753bd7..ef48423c 100644
--- a/modules/comment/views/admin_block_recent_comments.html.php
+++ b/modules/comment/views/admin_block_recent_comments.html.php
@@ -2,10 +2,13 @@
<ul>
<? foreach ($comments as $comment): ?>
<li>
+ <img width="40" height="40"
+ src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
+ class="gAvatar" alt="<?= $comment->author_name() ?>" />
<?= date("Y-M-d H:i:s", $comment->created) ?>
- <?= t("{{author_name}} said {{comment_text}}",
- array("author_name" => "<a href=\"#\">$comment->author</a>",
- "comment_text" => "<i>\"" . text::limit_words($comment->text, 50) . "\"</i>")); ?>
+ <?= t("<a href=#>{{author_name}}</a> said <i>{{comment_text}}</i>",
+ array("author_name" => $comment->author_name(),
+ "comment_text" => text::limit_words($comment->text, 50))); ?>
</li>
<? endforeach ?>
</ul>
diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php
index 5b2d2ca4..1cbdcd70 100644
--- a/modules/comment/views/admin_comments.html.php
+++ b/modules/comment/views/admin_comments.html.php
@@ -91,7 +91,8 @@
<input type="checkbox" name="delete_comments[]" value="<?= $comment->id ?>" />
</td>
<td>
- <a href="#"><img width="40" height="40" src="<?= $user->avatar_url(40) ?>"
+ <a href="#"><img width="40" height="40"
+ src="<?= $user->avatar_url(40, $theme->url("images/avatar.jpg")) ?>"
class="gAvatar" alt="<?= $comment->author_name() ?>" /></a>
<br/>
<a href="mailto:<?= $comment->author_email() ?>"
diff --git a/modules/comment/views/comment.html.php b/modules/comment/views/comment.html.php
index 86f635d3..1e502de9 100644
--- a/modules/comment/views/comment.html.php
+++ b/modules/comment/views/comment.html.php
@@ -2,7 +2,8 @@
<li id="gComment-<?= $comment->id; ?>">
<p class="gAuthor">
<a href="#">
- <img width="40" height="40" src="<?= $user->avatar_url(40) ?>"
+ <img width="40" height="40"
+ src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
class="gAvatar" alt="<?= $comment->author_name() ?>" />
</a>
<?= t("on ") . date("Y-M-d H:i:s", $comment->created) ?>
diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php
index b3757a5c..9b5f7056 100644
--- a/modules/comment/views/comments.html.php
+++ b/modules/comment/views/comments.html.php
@@ -5,7 +5,8 @@
<li id="gComment-<?= $comment->id ?>">
<p class="gAuthor">
<a href="#">
- <img width="40" height="40" src="<?= $user->avatar_url(40) ?>"
+ <img width="40" height="40"
+ src="<?= $comment->author()->avatar_url(40, $theme->url("images/avatar.jpg", true)) ?>"
class="gAvatar" alt="<?= $comment->author_name() ?>" />
</a>
<?= t("on {{date}} <a href=#>{{name}}</a> said",
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index 991e02f0..85fa75bb 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -48,8 +48,8 @@ class User_Model extends ORM {
* @param integer $size the target size of the image (default 80px)
* @return string a url
*/
- public function avatar_url($size=80) {
- return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg",
- md5($this->email), $size);
+ public function avatar_url($size=80, $default=null) {
+ return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s",
+ md5($this->email), $size, $default ? "&d=" . urlencode($default) : "");
}
} \ No newline at end of file