mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/16512] Docblock and code adjustments
PHPBB3-16512
This commit is contained in:
parent
da4b446ac6
commit
f340e8ca04
1 changed files with 26 additions and 19 deletions
|
@ -921,12 +921,16 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* make_clickable function
|
* Replaces magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.
|
||||||
*
|
* Cuts down displayed size of link if over 50 chars, turns absolute links
|
||||||
* Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.
|
* into relative versions when the server/script path matches the link
|
||||||
* Cuts down displayed size of link if over 50 chars, turns absolute links
|
*
|
||||||
* into relative versions when the server/script path matches the link
|
* @param string $text Message text to parse URL/email entries
|
||||||
*/
|
* @param bool|string $server_url The server URL. If false, the board URL will be used
|
||||||
|
* @param string $class CSS class selector to add to the parsed URL entries
|
||||||
|
*
|
||||||
|
* @return string A text with parsed URL/email entries
|
||||||
|
*/
|
||||||
function make_clickable($text, $server_url = false, string $class = 'postlink')
|
function make_clickable($text, $server_url = false, string $class = 'postlink')
|
||||||
{
|
{
|
||||||
if ($server_url === false)
|
if ($server_url === false)
|
||||||
|
@ -948,7 +952,7 @@ function make_clickable($text, $server_url = false, string $class = 'postlink')
|
||||||
$magic_url_match_args = array();
|
$magic_url_match_args = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if tne match for this $server_url and $class already exists
|
// Check if the match for this $server_url and $class already exists
|
||||||
$element_exists = false;
|
$element_exists = false;
|
||||||
if (isset($magic_url_match_args[$server_url]))
|
if (isset($magic_url_match_args[$server_url]))
|
||||||
{
|
{
|
||||||
|
@ -967,36 +971,39 @@ function make_clickable($text, $server_url = false, string $class = 'postlink')
|
||||||
if (!$element_exists)
|
if (!$element_exists)
|
||||||
{
|
{
|
||||||
// relative urls for this board
|
// relative urls for this board
|
||||||
$magic_url_match_args[$server_url][] = array(
|
$magic_url_match_args[$server_url][] = [
|
||||||
'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu',
|
'#(^|[\n\t (>.])(' . preg_quote($server_url, '#') . ')/(' . get_preg_expression('relative_url_inline') . ')#iu',
|
||||||
MAGIC_URL_LOCAL,
|
MAGIC_URL_LOCAL,
|
||||||
$local_class,
|
$local_class,
|
||||||
$static_class,
|
$static_class,
|
||||||
);
|
];
|
||||||
|
|
||||||
// matches a xxxx://aaaaa.bbb.cccc. ...
|
// matches a xxxx://aaaaa.bbb.cccc. ...
|
||||||
$magic_url_match_args[$server_url][] = array(
|
$magic_url_match_args[$server_url][] = [
|
||||||
'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu',
|
'#(^|[\n\t (>.])(' . get_preg_expression('url_inline') . ')#iu',
|
||||||
MAGIC_URL_FULL,
|
MAGIC_URL_FULL,
|
||||||
$class,
|
$class,
|
||||||
$static_class,
|
$static_class,
|
||||||
);
|
];
|
||||||
|
|
||||||
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
|
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
|
||||||
$magic_url_match_args[$server_url][] = array(
|
$magic_url_match_args[$server_url][] = [
|
||||||
'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu',
|
'#(^|[\n\t (>])(' . get_preg_expression('www_url_inline') . ')#iu',
|
||||||
MAGIC_URL_WWW,
|
MAGIC_URL_WWW,
|
||||||
$class,
|
$class,
|
||||||
$static_class,
|
$static_class,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($magic_url_match_args[$server_url]['email']))
|
||||||
|
{
|
||||||
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
|
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
|
||||||
$magic_url_match_args[$server_url]['email'] = array(
|
$magic_url_match_args[$server_url]['email'] = [
|
||||||
'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu',
|
'/(^|[\n\t (>])(' . get_preg_expression('email') . ')/iu',
|
||||||
MAGIC_URL_EMAIL,
|
MAGIC_URL_EMAIL,
|
||||||
'',
|
'',
|
||||||
);
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($magic_url_match_args[$server_url] as $magic_args)
|
foreach ($magic_url_match_args[$server_url] as $magic_args)
|
||||||
|
|
Loading…
Add table
Reference in a new issue