add rudimental support for formatting links and tables to class TextFormatter
This commit is contained in:
parent
0d5f30059d
commit
ee4e4b0345
1 changed files with 17 additions and 3 deletions
|
|
@ -57,8 +57,22 @@
|
||||||
*/
|
*/
|
||||||
public function t($string)
|
public function t($string)
|
||||||
{
|
{
|
||||||
// Remove chars and replace linefeeds
|
// Remove chars
|
||||||
$string = nl2br(htmlspecialchars($string));
|
$string = htmlspecialchars($string, ENT_NOQUOTES);
|
||||||
|
|
||||||
|
// Create tables
|
||||||
|
$string = str_replace('[table]', '</p><table>', $string);
|
||||||
|
$string = str_replace('[/table]', '</table><p>', $string);
|
||||||
|
$string = str_replace('[tr]', '<tr>', $string);
|
||||||
|
$string = str_replace('[/tr]', '</tr>', $string);
|
||||||
|
$string = str_replace('[th]', '<th>', $string);
|
||||||
|
$string = str_replace('[/th]', '</th>', $string);
|
||||||
|
$string = str_replace('[td]', '<td>', $string);
|
||||||
|
$string = str_replace('[/td]', '</td>', $string);
|
||||||
|
|
||||||
|
// Create links
|
||||||
|
$string = preg_replace('!(^|\s)"([^"]+)":(https?://[^\s]+)(\s|$)!i', '$1<a href="$3">$2</a>$4', $string);
|
||||||
|
$string = preg_replace('!(^|\s)(https?://[^\s]+)(\s|$)!i', '$1<a href="$2">$2</a>$4', $string);
|
||||||
|
|
||||||
// Handle Seminarymedia
|
// Handle Seminarymedia
|
||||||
$seminarymedia = array();
|
$seminarymedia = array();
|
||||||
|
|
@ -89,7 +103,7 @@
|
||||||
|
|
||||||
|
|
||||||
// Return processed string
|
// Return processed string
|
||||||
return $string;
|
return nl2br($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue