From fc1144ad2917e87170442c82b8204e240054ae7a Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 25 Aug 2012 23:13:12 +0200 Subject: [PATCH] Removed TwigBBExtension The BBcode stuff will be superseded by HTML created with CKEditor Signed-off-by: Gergely POLONKAI (W00d5t0ck) --- .../Resources/views/Forum/postList.html.twig | 2 +- .../FrontBundle/Twig/TwigBBExtension.php | 133 ------------------ 2 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php diff --git a/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig b/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig index c215648..047498a 100644 --- a/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig +++ b/src/KekRozsak/FrontBundle/Resources/views/Forum/postList.html.twig @@ -51,7 +51,7 @@ -
{{ post.text|bbdecode }}
+
{{ post.text|raw }}
{% endfor %} diff --git a/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php b/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php deleted file mode 100644 index c67689c..0000000 --- a/src/KekRozsak/FrontBundle/Twig/TwigBBExtension.php +++ /dev/null @@ -1,133 +0,0 @@ -container = $container; - } - - public function getFilters() - { - return array( - 'bbdecode' => new \Twig_Filter_Method($this, 'bbdecode', array( - 'is_safe' => array('html'), - )), - ); - } - - public function bbdecode($sentence) - { - $sentence = preg_replace( - '/\\[i\\](.*?)\\[\\/i\\]/im', - '\\1', - preg_replace( - '/\\[b\\](.*?)\\[\\/b\\]/im', - '\\1', - preg_replace( - '/\\[u\\](.*?)\\[\\/u\\]/im', - '\\1', - str_replace( - array("\r\n", "\n", "\r"), - "
", - htmlspecialchars($sentence, ENT_NOQUOTES) - ) - ) - ) - ); - - $m = array(); - - while ( - preg_match( - '/\\[img( (ns|name)="[^"]+"){1,}\\]/i', - $sentence, - $m, - PREG_OFFSET_CAPTURE - ) - ) { - $start = $m[0][1]; - $len = strlen($m[0][0]); - $full_tag = $m[0][0]; - - $ns = (preg_match('/ ns="([^"]+)"/', $full_tag, $ns)) ? trim($ns[1]) : ''; - $name = (preg_match('/ name="([^"]+)"/', $full_tag, $name)) ? trim($name[1]) : ''; - - if ($name == '') { - $sentence = substr_replace($sentence, 'Hibás kép', $start, $len); - } else { - // TODO: Thumbnailing! - $sentence = substr_replace( - $sentence, - '', - $start, - $len - ); - } - } - - while ( - preg_match( - '/\\[link( (url)="[^"]+"){1,}\\](?P.*?)\\[\\/link\\]/i', - $sentence, $m, PREG_OFFSET_CAPTURE) - ) { - $start = $m[0][1]; - $len = strlen($m[0][0]); - $full_tag = $m[0][0]; - - $url = (preg_match('/ url="([^"]+)"/', $full_tag, $url)) ? trim($url[1]) : ''; - $content = ''; - if (array_key_exists('content', $m)) { - $content = trim($m['content'][0]); - } - - if (($url == '') || ($content == '')) { - $sentence = substr_replace($sentence, 'Hibás link', $start, $len); - } else { - $sentence = substr_replace( - $sentence, - '' - . $content - . '', - $start, - $len - ); - } - } - - return $sentence; - } - - public function getName() - { - return 'twig_bb'; - } -}