diff --git a/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/feed.xml.twig b/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/feed.xml.twig index f407ec3..ae35fc1 100644 --- a/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/feed.xml.twig +++ b/src/GergelyPolonkai/FrontBundle/Resources/views/Blog/feed.xml.twig @@ -19,7 +19,7 @@ {{ app.request.scheme }}://{{app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogViewPost', {year: post.createdAt|date('Y'), month: post.createdAt|date('m'), day: post.createdAt|date('d'), slug: post.slug }) }} {{ app.request.scheme }}://{{app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogViewPost', {year: post.createdAt|date('Y'), month: post.createdAt|date('m'), day: post.createdAt|date('d'), slug: post.slug }) }}#comments {{ post.createdAt|date('r') }} - + {{ app.request.scheme }}://{{app.request.host }}{{ path('GergelyPolonkaiFrontBundle_blogViewPost', {year: post.createdAt|date('Y'), month: post.createdAt|date('m'), day: post.createdAt|date('d'), slug: post.slug }) }} {# diff --git a/src/GergelyPolonkai/FrontBundle/Twig/CodeChunk.php b/src/GergelyPolonkai/FrontBundle/Twig/CodeChunk.php index bf65df0..162c272 100644 --- a/src/GergelyPolonkai/FrontBundle/Twig/CodeChunk.php +++ b/src/GergelyPolonkai/FrontBundle/Twig/CodeChunk.php @@ -46,6 +46,7 @@ class CodeChunk extends \Twig_Extension { return array( 'insert_code_chunks' => new \Twig_Filter_Method($this, 'insertCodeChunks', array('is_safe' => array('html'))), + 'remove_code_chunks' => new \Twig_Filter_Method($this, 'removeCodeChunks', array('is_safe' => array('html'))), ); } @@ -106,6 +107,40 @@ class CodeChunk extends \Twig_Extension return $string; } + public function removeCodeChunks($string) + { + $m = array(); + $chunkRepo = $this->doctrine->getRepository('GergelyPolonkaiFrontBundle:CodeChunk'); + + while ( + preg_match( + '/\\[\\$ code:([^:]+):([^ ]+) \\$\\]/i', + $string, $m, PREG_OFFSET_CAPTURE) + ) { + $start = $m[0][1]; + $fullTag = $m[0][0]; + $len = strlen($fullTag); + $replacement = ''; + + $string = substr_replace($string, $replacement, $start, $len); + } + + while ( + preg_match( + '/\\[\\$ code:([^:]+):(.+?) \\$\\]/is', + $string, $m, PREG_OFFSET_CAPTURE) + ) { + $start = $m[0][1]; + $fullTag = $m[0][0]; + $len = strlen($fullTag); + $replacement = ''; + + $string = substr_replace($string, $replacement, $start, $len); + } + + return $string; + } + public function getName() { return "code_chunk";