1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/13713] Fix case for phpBB directory

PHPBB3-13713
This commit is contained in:
lavigor
2018-05-30 22:06:26 +03:00
committed by Marc Alexander
parent 6c42563b4d
commit eec7703d3b
12 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\textformatter\s9e;
class mention_helper
{
/**
* @var string Base URL for a user profile link, uses {USER_ID} as placeholder
*/
protected $user_profile_url;
/**
* @var string Base URL for a group profile link, uses {GROUP_ID} as placeholder
*/
protected $group_profile_url;
/**
* Constructor
*
* @param string $root_path
* @param string $php_ext
*/
public function __construct($root_path, $php_ext)
{
$this->user_profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=viewprofile&u={USER_ID}', false);
$this->group_profile_url = append_sid($root_path . 'memberlist.' . $php_ext, 'mode=group&g={GROUP_ID}', false);
}
/**
* Inject dynamic metadata into MENTION tags in given XML
*
* @param string $xml Original XML
* @return string Modified XML
*/
public function inject_metadata($xml)
{
$user_profile_url = $this->user_profile_url;
$group_profile_url = $this->group_profile_url;
return \s9e\TextFormatter\Utils::replaceAttributes(
$xml,
'MENTION',
function ($attributes) use ($user_profile_url, $group_profile_url)
{
if (isset($attributes['user_id']))
{
$attributes['profile_url'] = str_replace('{USER_ID}', $attributes['user_id'], $user_profile_url);
}
else if (isset($attributes['group_id']))
{
$attributes['profile_url'] = str_replace('{GROUP_ID}', $attributes['group_id'], $group_profile_url);
}
return $attributes;
}
);
}
}