-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added experemental support for decoda v4
- Loading branch information
helios
committed
Nov 13, 2012
1 parent
d914913
commit 9062dac
Showing
29 changed files
with
62 additions
and
27 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,22 @@ | |
use FM\BbcodeBundle\Decoda\Decoda; | ||
use FM\BbcodeBundle\Decoda\DecodaPhpEngine; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use mjohnson\decoda\filters\Filter, | ||
mjohnson\decoda\filters\DefaultFilter, | ||
mjohnson\decoda\filters\BlockFilter, | ||
mjohnson\decoda\filters\CodeFilter, | ||
mjohnson\decoda\filters\EmailFilter, | ||
mjohnson\decoda\filters\ImageFilter, | ||
mjohnson\decoda\filters\ListFilter, | ||
mjohnson\decoda\filters\QuoteFilter, | ||
mjohnson\decoda\filters\TextFilter, | ||
mjohnson\decoda\filters\UrlFilter, | ||
mjohnson\decoda\filters\VideoFilter; | ||
use mjohnson\decoda\hooks\CensorHook, | ||
mjohnson\decoda\hooks\ClickableHook, | ||
mjohnson\decoda\hooks\CodeHook, | ||
mjohnson\decoda\hooks\EmoticonHook, | ||
mjohnson\decoda\hooks\Hook; | ||
|
||
/** | ||
* @author Al Ganiev <[email protected]> | ||
|
@@ -33,7 +49,6 @@ public function __construct(Decoda $value, array $filters = array(), array $hook | |
$this->filters = $filters; | ||
$this->hooks = $hooks; | ||
$this->whitelist = $whitelist; | ||
|
||
} | ||
|
||
public static function add_filter($name, $filter){ | ||
|
@@ -49,8 +64,6 @@ public static function add_templatePath( $path ){ | |
static::$extra_paths[] = $path; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Applies filter specified in parameter | ||
* @param \FM\BbcodeBundle\Decoda\Decoda $code | ||
|
@@ -60,43 +73,44 @@ public static function add_templatePath( $path ){ | |
*/ | ||
protected function apply_filter(Decoda $code, $filter) | ||
{ | ||
//default, block, code, email, image, list, quote, text, url, video ] | ||
//default, block, code, email, image, list, quote, text, url, video | ||
if(isset(static::$extra_filters[$filter])){ | ||
$extra_filter = static::$extra_filters[$filter] instanceof \DecodaFilter ? static::$extra_filters[$filter] : new static::$extra_filters[$filter](); | ||
$extra_filter = static::$extra_filters[$filter] instanceof Filter ? static::$extra_filters[$filter] : new static::$extra_filters[$filter](); | ||
$code->addFilter($extra_filter); | ||
return $code; | ||
} | ||
|
||
switch ($filter) { | ||
case 'block': | ||
$code->addFilter(new \BlockFilter()); | ||
$code->addFilter(new BlockFilter()); | ||
break; | ||
case 'code': | ||
$code->addFilter(new \CodeFilter()); | ||
$code->addFilter(new CodeFilter()); | ||
break; | ||
case 'email': | ||
$code->addFilter(new \EmailFilter()); | ||
$code->addFilter(new EmailFilter()); | ||
break; | ||
case 'image': | ||
$code->addFilter(new \ImageFilter()); | ||
$code->addFilter(new ImageFilter()); | ||
break; | ||
case 'list': | ||
$code->addFilter(new \ListFilter()); | ||
$code->addFilter(new ListFilter()); | ||
break; | ||
case 'quote': | ||
$code->addFilter(new \QuoteFilter()); | ||
$code->addFilter(new QuoteFilter()); | ||
break; | ||
case 'text': | ||
$code->addFilter(new \TextFilter()); | ||
$code->addFilter(new TextFilter()); | ||
break; | ||
case 'url': | ||
$code->addFilter(new \UrlFilter()); | ||
$code->addFilter(new UrlFilter()); | ||
break; | ||
case 'video': | ||
$code->addFilter(new \VideoFilter()); | ||
$code->addFilter(new VideoFilter()); | ||
break; | ||
case 'default': | ||
$code->addFilter(new \DefaultFilter()); | ||
$code->addFilter(new DefaultFilter()); | ||
break; | ||
default: | ||
return $code; | ||
} | ||
|
@@ -112,20 +126,20 @@ protected function apply_hook(Decoda $code, $hook) | |
{ | ||
|
||
if(isset(static::$extra_hooks[$hook])){ | ||
$extra_hook = static::$extra_hooks[$hook] instanceof \DecodaHook ? static::$extra_hooks[$hook] : new static::$extra_hooks[$hook](); | ||
$extra_hook = static::$extra_hooks[$hook] instanceof Hook ? static::$extra_hooks[$hook] : new static::$extra_hooks[$hook](); | ||
$code->addFilter($extra_hook); | ||
return $code; | ||
} | ||
|
||
switch ($hook) { | ||
case 'censor': | ||
$code->addHook(new \CensorHook()); | ||
$code->addHook(new CensorHook()); | ||
break; | ||
case 'clickable': | ||
$code->addHook(new \ClickableHook()); | ||
$code->addHook(new ClickableHook()); | ||
break; | ||
case 'emoticon': | ||
$code->addHook(new \EmoticonHook()); | ||
$code->addHook(new EmoticonHook()); | ||
break; | ||
} | ||
return $code; | ||
|
@@ -153,7 +167,7 @@ public function getResult() | |
$decodaPhpEngine->setpath($extraPath); | ||
} | ||
|
||
$this->value->setTemplateEngine($decodaPhpEngine); | ||
$this->value->setEngine($decodaPhpEngine); | ||
|
||
|
||
foreach($this->filters as $filter) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace FM\BbcodeBundle\Decoda\Hook; | ||
|
||
use mjohnson\decoda\hooks\EmoticonHook; | ||
|
||
class EmoticonHook2 extends EmoticonHook | ||
{ | ||
|
||
public function setConfig(array $config) { | ||
$this->_config = $config; | ||
} | ||
|
||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
Tests/FunctionalTestBundle/Resources/views/filters/default.html.twig
100755 → 100644
Empty file.
Empty file modified
0
Tests/FunctionalTestBundle/Resources/views/filters/image.html.twig
100755 → 100644
Empty file.
Empty file modified
0
Tests/FunctionalTestBundle/Resources/views/filters/url.html.twig
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.