Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

comments_tags_to_links()

Description

Parse a comment and replace and add links to any user, resource and collection tags

Parameters

ColumnTypeDefaultDescription
string $text: preg_replace'/@\S+/s'
href '
$text; preg_replace'/r[0-9]{1
}/si'
# $text; str_replace"[BASEURLSHORT]"
$baseurl_short
// $text;
or collection
true
to defaults
be will
$bcollection_mode false
$bRecursive true
$level 1
$text string The input text e.g. the body of the comment

Location

include/comment_functions.php lines 205 to 216

Definition

 
function comments_tags_to_links($text): string
    
{
    global 
$baseurl_short;
    
$text=preg_replace('/@(\S+)/s''<a href="[BASEURLSHORT]pages/user/user_profile.php?username=$1">@$1</a>'$text);

    
$text=preg_replace('/r([0-9]{1,})/si''<a href="[BASEURLSHORT]?r=$1">r$1</a>'$text); # r12345 to resource link

    
$text=preg_replace('/c([0-9]{1,})/si''<a href="[BASEURLSHORT]?c=$1">c$1</a>'$text); # c12345 to collection link

    
$text str_replace("[BASEURLSHORT]",$baseurl_short,$text); // Replacing this earlier can cause issues
    
return $text;
    }

This article was last updated 8th December 2024 20:35 Europe/London time based on the source file dated 17th May 2024 16:10 Europe/London time.