Merge branch 'develop-ascraeus' into develop

* develop-ascraeus:
  [ticket/9758] Clickable avatar in header and renamed class for avatar-img
  [ticket/9758] Remove unnessary if-question for include functions_display
  [ticket/9758] Slims the line 4775 in includes/functions.php
  [ticket/9758] Adds id and changes filter to fix travis CI test
  [ticket/9758] Removed the needless space after first ENDIF
  [ticket/9758] Adding impr. for overall_header display of avatar and username
  [ticket/9758] Fixed bug in mcp_warn.php
  [ticket/9758] Optimises the html code of avatar image in header
  [ticket/9758] Error because of missing functions_display.php fixed
  [ticket/9758] Removed useless if-conditions to include functions.php
  [ticket/9758] Changes class name of new "span" in overall_header.html
  [ticket/9758] Adds global template variable CURRENT_USER_AVATAR
This commit is contained in:
Joas Schilling 2014-03-31 20:31:48 +02:00
commit 2c0b08a890
11 changed files with 107 additions and 111 deletions

View file

@ -4619,6 +4619,92 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
return $hidden; return $hidden;
} }
/**
* Get user avatar
*
* @param array $user_row Row from the users table
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar html
*/
function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false)
{
$row = \phpbb\avatar\manager::clean_row($user_row, 'user');
return phpbb_get_avatar($row, $alt, $ignore_config);
}
/**
* Get group avatar
*
* @param array $group_row Row from the groups table
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar html
*/
function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
{
$row = \phpbb\avatar\manager::clean_row($user_row, 'group');
return phpbb_get_avatar($row, $alt, $ignore_config);
}
/**
* Get avatar
*
* @param array $row Row cleaned by \phpbb\avatar\driver\driver::clean_row
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar html
*/
function phpbb_get_avatar($row, $alt, $ignore_config = false)
{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
global $request;
global $phpbb_container;
if (!$config['allow_avatar'] && !$ignore_config)
{
return '';
}
$avatar_data = array(
'src' => $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config);
$html = '';
if ($driver)
{
$html = $driver->get_custom_html($user, $row, $alt);
if (!empty($html))
{
return $html;
}
$avatar_data = $driver->get_data($row, $ignore_config);
}
else
{
$avatar_data['src'] = '';
}
if (!empty($avatar_data['src']))
{
$html = '<img src="' . $avatar_data['src'] . '" ' .
($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') .
($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
return $html;
}
/** /**
* Generate page header * Generate page header
*/ */
@ -4686,7 +4772,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
if ($user->data['user_id'] != ANONYMOUS) if ($user->data['user_id'] != ANONYMOUS)
{ {
$u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id); $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true, $user->session_id);
$l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']); $l_login_logout = $user->lang['LOGOUT'];
} }
else else
{ {
@ -4830,6 +4916,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
// The following assigns all _common_ variables that may be used at any point in a template. // The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array( $template->assign_vars(array(
'CURRENT_USER_AVATAR' => phpbb_get_user_avatar($user->data),
'SITENAME' => $config['sitename'], 'SITENAME' => $config['sitename'],
'SITE_DESCRIPTION' => $config['site_desc'], 'SITE_DESCRIPTION' => $config['site_desc'],
'PAGE_TITLE' => $page_title, 'PAGE_TITLE' => $page_title,
@ -4859,6 +4946,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'SESSION_ID' => $user->session_id, 'SESSION_ID' => $user->session_id,
'ROOT_PATH' => $web_path, 'ROOT_PATH' => $web_path,
'BOARD_URL' => $board_url, 'BOARD_URL' => $board_url,
'USERNAME_FULL' => get_username_string('full', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
'L_LOGIN_LOGOUT' => $l_login_logout, 'L_LOGIN_LOGOUT' => $l_login_logout,
'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'], 'L_INDEX' => ($config['board_index_text'] !== '') ? $config['board_index_text'] : $user->lang['FORUM_INDEX'],
@ -4875,6 +4963,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
'U_SITE_HOME' => $config['site_home_url'], 'U_SITE_HOME' => $config['site_home_url'],
'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'), 'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.$phpEx"), 'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.$phpEx"),
'U_USER_PROFILE' => get_username_string('profile', $user->data['user_id'], $user->data['username'], $user->data['user_colour']),
'U_MODCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id), 'U_MODCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id),
'U_FAQ' => append_sid("{$phpbb_root_path}faq.$phpEx"), 'U_FAQ' => append_sid("{$phpbb_root_path}faq.$phpEx"),
'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'), 'U_SEARCH_SELF' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=egosearch'),

View file

@ -39,13 +39,6 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
'avatar_height' => $avatar_height, 'avatar_height' => $avatar_height,
); );
if (!function_exists('phpbb_get_avatar'))
{
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
return phpbb_get_avatar($row, $alt, $ignore_config); return phpbb_get_avatar($row, $alt, $ignore_config);
} }

View file

@ -1376,92 +1376,6 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
} }
} }
/**
* Get user avatar
*
* @param array $user_row Row from the users table
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar html
*/
function phpbb_get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false)
{
$row = \phpbb\avatar\manager::clean_row($user_row, 'user');
return phpbb_get_avatar($row, $alt, $ignore_config);
}
/**
* Get group avatar
*
* @param array $group_row Row from the groups table
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar html
*/
function phpbb_get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false)
{
$row = \phpbb\avatar\manager::clean_row($user_row, 'group');
return phpbb_get_avatar($row, $alt, $ignore_config);
}
/**
* Get avatar
*
* @param array $row Row cleaned by \phpbb\avatar\driver\driver::clean_row
* @param string $alt Optional language string for alt tag within image, can be a language key or text
* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP
*
* @return string Avatar html
*/
function phpbb_get_avatar($row, $alt, $ignore_config = false)
{
global $user, $config, $cache, $phpbb_root_path, $phpEx;
global $request;
global $phpbb_container;
if (!$config['allow_avatar'] && !$ignore_config)
{
return '';
}
$avatar_data = array(
'src' => $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
$driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config);
$html = '';
if ($driver)
{
$html = $driver->get_custom_html($user, $row, $alt);
if (!empty($html))
{
return $html;
}
$avatar_data = $driver->get_data($row, $ignore_config);
}
else
{
$avatar_data['src'] = '';
}
if (!empty($avatar_data['src']))
{
$html = '<img src="' . $avatar_data['src'] . '" ' .
($avatar_data['width'] ? ('width="' . $avatar_data['width'] . '" ') : '') .
($avatar_data['height'] ? ('height="' . $avatar_data['height'] . '" ') : '') .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
return $html;
}
/** /**
* Generate a list of archive types available for compressing attachments * Generate a list of archive types available for compressing attachments
* *

View file

@ -174,10 +174,6 @@ class mcp_notes
} }
// Generate the appropriate user information for the user we are looking at // Generate the appropriate user information for the user we are looking at
if (!function_exists('phpbb_get_user_avatar'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
$rank_title = $rank_img = ''; $rank_title = $rank_img = '';
$avatar_img = phpbb_get_user_avatar($userrow); $avatar_img = phpbb_get_user_avatar($userrow);

View file

@ -293,7 +293,7 @@ class mcp_warn
$message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true); $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true);
// Generate the appropriate user information for the user we are looking at // Generate the appropriate user information for the user we are looking at
if (!function_exists('phpbb_get_user_avatar')) if (!function_exists('get_user_rank'))
{ {
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
} }
@ -398,11 +398,10 @@ class mcp_warn
} }
// Generate the appropriate user information for the user we are looking at // Generate the appropriate user information for the user we are looking at
if (!function_exists('phpbb_get_user_avatar')) if (!function_exists('get_user_rank'))
{ {
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
} }
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src);
$avatar_img = phpbb_get_user_avatar($user_row); $avatar_img = phpbb_get_user_avatar($user_row);

View file

@ -338,13 +338,13 @@ function get_user_information($user_id, $user_row)
} }
} }
if (!function_exists('phpbb_get_user_avatar')) $user_row['avatar'] = ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($user_row) : '';
if (!function_exists('get_user_rank'))
{ {
include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
} }
$user_row['avatar'] = ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($user_row) : '';
get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']); get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']);
if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))

View file

@ -515,10 +515,6 @@ class ucp_profile
break; break;
case 'avatar': case 'avatar':
if (!function_exists('phpbb_get_user_avatar'))
{
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
}
add_form_key('ucp_avatar'); add_form_key('ucp_avatar');

View file

@ -91,6 +91,7 @@
<!-- EVENT overall_header_breadcrumb_append --> <!-- EVENT overall_header_breadcrumb_append -->
</li> </li>
<!-- IF S_REGISTERED_USER --><li id="username_logged_in" class="rightside"><!-- IF CURRENT_USER_AVATAR --><a href="{U_USER_PROFILE}" class="header-avatar">{CURRENT_USER_AVATAR}</a> <!-- ENDIF -->{USERNAME_FULL}</li><!-- ENDIF -->
<!-- IF U_EMAIL_TOPIC --><li class="rightside"><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}" class="sendemail">{L_EMAIL_TOPIC}</a></li><!-- ENDIF --> <!-- IF U_EMAIL_TOPIC --><li class="rightside"><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}" class="sendemail">{L_EMAIL_TOPIC}</a></li><!-- ENDIF -->
<!-- IF U_EMAIL_PM --><li class="rightside"><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}" class="sendemail">{L_EMAIL_PM}</a></li><!-- ENDIF --> <!-- IF U_EMAIL_PM --><li class="rightside"><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}" class="sendemail">{L_EMAIL_PM}</a></li><!-- ENDIF -->
<!-- IF U_PRINT_TOPIC --><li class="rightside"><a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}" accesskey="p" class="print">{L_PRINT_TOPIC}</a></li><!-- ENDIF --> <!-- IF U_PRINT_TOPIC --><li class="rightside"><a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}" accesskey="p" class="print">{L_PRINT_TOPIC}</a></li><!-- ENDIF -->

View file

@ -444,6 +444,14 @@ ul.linklist.bulletin li.no-bulletin:before {
display: none !important; display: none !important;
} }
/* Avatar in overall_header.html */
.header-avatar img {
margin-bottom: 2px;
max-height: 25px;
vertical-align: middle;
width: auto;
}
/* Dropdown menu /* Dropdown menu
----------------------------------------*/ ----------------------------------------*/
.dropdown-container { .dropdown-container {

View file

@ -18,7 +18,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
// check for logout link // check for logout link
$crawler = self::request('GET', 'index.php'); $crawler = self::request('GET', 'index.php');
$this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text()); $this->assertContains($this->lang('LOGOUT', 'admin'), $crawler->filter('.navbar')->text());
} }
public function test_login_other() public function test_login_other()
@ -26,7 +26,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->create_user('anothertestuser'); $this->create_user('anothertestuser');
$this->login('anothertestuser'); $this->login('anothertestuser');
$crawler = self::request('GET', 'index.php'); $crawler = self::request('GET', 'index.php');
$this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text()); $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text());
} }
/** /**

View file

@ -60,7 +60,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
$this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser')); $this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser'));
$this->login('notificationtestuser'); $this->login('notificationtestuser');
$crawler = self::request('GET', 'index.php'); $crawler = self::request('GET', 'index.php');
$this->assertContains('notificationtestuser', $crawler->filter('.icon-logout')->text()); $this->assertContains('notificationtestuser', $crawler->filter('#username_logged_in')->text());
// Post a new post that needs approval // Post a new post that needs approval
$this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD'); $this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');