diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-01-10 06:18:35 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-01-10 06:18:35 +0000 |
commit | 9b90b4b0cd464424f3f9a4214d265db69b3691dc (patch) | |
tree | a8e42c5442b5ed06aba7637ba33fcb49af8a833a | |
parent | 5690e58c4577e9b0a29f0c1d95edc7e6715a2cf6 (diff) |
Use the theme's avatar as the default if Gravatar doesn't have one.
-rw-r--r-- | core/libraries/Admin_View.php | 5 | ||||
-rw-r--r-- | core/libraries/Theme_View.php | 5 | ||||
-rw-r--r-- | modules/comment/views/admin_block_recent_comments.html.php | 9 | ||||
-rw-r--r-- | modules/comment/views/admin_comments.html.php | 3 | ||||
-rw-r--r-- | modules/comment/views/comment.html.php | 3 | ||||
-rw-r--r-- | modules/comment/views/comments.html.php | 3 | ||||
-rw-r--r-- | modules/user/models/user.php | 6 |
7 files changed, 21 insertions, 13 deletions
diff --git a/core/libraries/Admin_View.php b/core/libraries/Admin_View.php index dcfbca4a..4a367c94 100644 --- a/core/libraries/Admin_View.php +++ b/core/libraries/Admin_View.php @@ -36,8 +36,9 @@ class Admin_View_Core extends View { $this->set_global('user', user::active()); } - public function url($path) { - return url::file("themes/{$this->theme_name}/$path"); + public function url($path, $absolute_url=false) { + $arg = "themes/{$this->theme_name}/$path"; + return $absolute_url ? url::abs_file($arg) : url::file($arg); } public function display($page_name, $view_class="View") { diff --git a/core/libraries/Theme_View.php b/core/libraries/Theme_View.php index f2059f77..ea39cdfc 100644 --- a/core/libraries/Theme_View.php +++ b/core/libraries/Theme_View.php @@ -38,8 +38,9 @@ class Theme_View_Core extends View { $this->set_global("page_type", $page_type); } - public function url($path) { - return url::file("themes/{$this->theme_name}/$path"); + public function url($path, $absolute_url=false) { + $arg = "themes/{$this->theme_name}/$path"; + return $absolute_url ? url::abs_file($arg) : url::file($arg); } public function item() { 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 |