add rudimental support for formatting links and tables to class TextFormatter
This commit is contained in:
parent
89b2bee286
commit
8d9d5c3bd5
1 changed files with 17 additions and 3 deletions
|
|
@ -57,8 +57,22 @@
|
|||
*/
|
||||
public function t($string)
|
||||
{
|
||||
// Remove chars and replace linefeeds
|
||||
$string = nl2br(htmlspecialchars($string));
|
||||
// Remove chars
|
||||
$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
|
||||
$seminarymedia = array();
|
||||
|
|
@ -89,7 +103,7 @@
|
|||
|
||||
|
||||
// Return processed string
|
||||
return $string;
|
||||
return nl2br($string);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue