1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Issue #682 and other 'wrong avatar' issues in chatbox, online-menu etc. New $tp->toAvatar() method introduced.

This commit is contained in:
Cameron
2015-02-04 20:36:56 -08:00
parent d3ff0d7333
commit 4572cd7ceb
6 changed files with 82 additions and 10 deletions

View File

@@ -107,12 +107,12 @@ class comment_shortcodes extends e_shortcode
$tp = e107::getParser();
// return $this->var['user_image'];
// $url = $tp->thumbUrl($this->var['user_image']);
// $text = $tp->parseTemplate("{USER_AVATAR=".vartrue($this->var['user_image'],USERIMAGE)."}");
$text = $tp->parseTemplate("{USER_AVATAR=".$this->var['user_id']."}");
$text =
// $text = $tp->parseTemplate("{USER_AVATAR=".$this->var['user_id']."}");
$text = $tp->toAvatar($this->var);
$text .= "<div class='field-help' style='display:none;'>
<div class='left'>";
$text .= "<h2>".$this->sc_username()."</h2>";

View File

@@ -748,7 +748,7 @@ class e_parse extends e_parser
$search = array('&#036;', '&quot;', '<', '>');
$replace = array('$', '"', '&lt;', '&gt;');
$text = str_replace($search, $replace, $text);
if (e_WYSIWYG !== TRUE)
if (e107::wysiwyg() !== true)
{
// fix for utf-8 issue with html_entity_decode(); ???
$text = str_replace("&nbsp;", " ", $text);
@@ -2843,6 +2843,67 @@ class e_parser
/**
* Render an avatar based on supplied user data or current user when missing.
* @param @array - user data from e107_user.
* @return <img> tag of avatar.
*/
public function toAvatar($userData=null)
{
$tp = e107::getParser();
$width = $tp->thumbWidth;
$height = ($tp->thumbHeight !== 0) ? $tp->thumbHeight : "";
if(!isset($userData['user_image']) && USERID)
{
$userData['user_image'] = USERIMAGE;
$userData['user_name'] = USERNAME;
}
$image = varset($userData['user_image']);
$genericImg = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height,true);
if (!empty($image))
{
if(strpos($image,"://")!==false) // Remove Image
{
$img = $image;
}
elseif(substr($image,0,8) == "-upload-")
{
$image = substr($image,8); // strip the -upload- from the beginning.
$img = (file_exists(e_AVATAR_UPLOAD.$image)) ? $tp->thumbUrl(e_AVATAR_UPLOAD.$image,"w=".$width."&h=".$height) : $genericImg;
}
elseif(file_exists(e_AVATAR_DEFAULT.$image)) // User-Uplaoded Image
{
$img = $tp->thumbUrl(e_AVATAR_DEFAULT.$image,"w=".$width."&h=".$height);
}
else // Image Missing.
{
$img = $genericImg;
}
}
else // No image provided - so send generic.
{
$img = $genericImg;
}
$title = (ADMIN) ? $image : $tp->toAttribute($userData['user_name']);
$text = "<img class='img-rounded user-avatar e-tip' title=\"".$title."\" src='".$img."' alt='' style='width:".$width."px; height:".$height."px' />";
// return $img;
return $text;
}
/**
* Display an icon.
* @param string $icon

View File

@@ -112,7 +112,7 @@ if(!class_exists('chatbox_shortcodes'))
function sc_cb_avatar($parm='')
{
return e107::getParser()->parseTemplate("{USER_AVATAR=".vartrue($this->var['user_image'])."}");
return e107::getParser()->toAvatar($this->var); // parseTemplate("{USER_AVATAR=".vartrue($this->var['user_image'])."}");
}
function sc_cb_bullet($parm = '')

View File

@@ -25,7 +25,11 @@ include_lan(e_PLUGIN.'online/languages/'.e_LANGUAGE.'.php');
require_once(e_PLUGIN.'online/online_shortcodes.php');
if (is_readable(THEME.'online_menu_template.php'))
if (is_readable(THEME.'templates/online/online_menu_template.php'))
{
require(THEME.'templates/online/online_menu_template.php');
}
elseif (is_readable(THEME.'online_menu_template.php'))
{
require(THEME.'online_menu_template.php');
}

View File

@@ -17,7 +17,7 @@
global $sc_style;
//##### LASTSEEN MENU ---------------------------------------------------------
$LASTSEEN_TEMPLATE['start'] = "<ul class='lastseen-menu'>";
$LASTSEEN_TEMPLATE['start'] = "<ul class='lastseen-menu '>";
$LASTSEEN_TEMPLATE['item'] = "<li>{LASTSEEN_USERLINK} <small class='muted'>{LASTSEEN_DATE}</small></li>";
$LASTSEEN_TEMPLATE['end'] = "</ul>";
@@ -32,7 +32,7 @@ $sc_style['ONLINE_MEMBERS']['post'] = "</li>";
$sc_style['ONLINE_MEMBERS_LIST']['pre'] = "<ul>";
$sc_style['ONLINE_MEMBERS_LIST']['post'] = "</ul>";
$sc_style['ONLINE_MEMBERS_LIST_EXTENDED']['pre'] = "<ul class='unstyled'>";
$sc_style['ONLINE_MEMBERS_LIST_EXTENDED']['pre'] = "<ul class='unstyled list-unstyled'>";
$sc_style['ONLINE_MEMBERS_LIST_EXTENDED']['post'] = "</ul>";
$sc_style['ONLINE_ONPAGE']['pre'] = "<li>".LAN_ONLINE_3;

View File

@@ -141,7 +141,14 @@ class online_shortcodes
{
if($parm == 'avatar')
{
return e107::getParser()->parseTemplate("{USER_AVATAR=".$this->currentMember['oimage']."}",true);
$userData = array(
'user_image' => $this->currentMember['oimage'],
'user_name' => $this->currentMember['oname']
);
return e107::getParser()->toAvatar($userData);
// return e107::getParser()->parseTemplate("{USER_AVATAR=".$this->currentMember['oimage']."}",true);
}
return "<img src='".e_IMAGE_ABS."admin_images/users_16.png' alt='' style='vertical-align:middle' />";