Permalink
Browse files

Simplify code and fix system notice in Timeline

Notice was triggered when avatars are disabled due to a strict-type
comparison (array() !== false).

Fixes #17492
  • Loading branch information...
dregad committed Jul 6, 2014
1 parent 440ac7c commit f0885d9e82cc019558a8b1a4bfe8434e7d7bc28b
Showing with 8 additions and 13 deletions.
  1. +8 −13 core/classes/TimelineEvent.class.php
@@ -103,22 +103,17 @@ public function format_timestamp( $p_timestamp ) {
public function html_start() {
$t_avatar = user_get_avatar( $this->user_id, 32 );
- if( $t_avatar !== false ) {
- $t_html = '<div class="entry">';
+ if( !empty( $t_avatar ) ) {
+ $t_class = 'entry';
+ $t_src = 'src="' . $t_avatar[0] . '" ';
} else {
- $t_html = '<div class="entry-no-avatar">';
+ $t_class = 'entry-no-avatar';
+ $t_src = '';
}
- if( $t_avatar !== false ) {
- $t_avatar_url = $t_avatar[0];
- $t_html .= '<img class="avatar" src="' . $t_avatar_url . '"/>';
- } else {
- $t_html .= '<img class="avatar" />';
- }
-
- $t_html .= '<div class="timestamp">' . $this->format_timestamp( $this->timestamp ) . '</div>';
+ $t_html = '<div class="%s"><img class="avatar" %s/><div class="timestamp">%s</div>';
- return $t_html;
+ return sprintf( $t_html, $t_class, $t_src, $this->format_timestamp( $this->timestamp ) );
}
/**
@@ -128,4 +123,4 @@ public function html_start() {
public function html_end() {
return '</div>';
}
-}
+}

0 comments on commit f0885d9

Please sign in to comment.