From 9b90b4b0cd464424f3f9a4214d265db69b3691dc Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 10 Jan 2009 06:18:35 +0000 Subject: Use the theme's avatar as the default if Gravatar doesn't have one. --- core/libraries/Admin_View.php | 5 +++-- core/libraries/Theme_View.php | 5 +++-- modules/comment/views/admin_block_recent_comments.html.php | 9 ++++++--- modules/comment/views/admin_comments.html.php | 3 ++- modules/comment/views/comment.html.php | 3 ++- modules/comment/views/comments.html.php | 3 ++- 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 @@ 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 @@ - " class="gAvatar" alt="author_name() ?>" />

- " class="gAvatar" alt="author_name() ?>" /> 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 @@

  • - " class="gAvatar" alt="author_name() ?>" /> {{name}} 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 -- cgit v1.2.3