From abd9a17fb982a6c3150b0d25c1d9d9dbd4f59b08 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Fri, 27 Jun 2014 20:04:49 +0200 Subject: [PATCH 1/2] Fixed the test to allow a customizable emoticon list --- Tests/Templating/BbcodeExtensionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Templating/BbcodeExtensionTest.php b/Tests/Templating/BbcodeExtensionTest.php index 9225111..b51a2a4 100644 --- a/Tests/Templating/BbcodeExtensionTest.php +++ b/Tests/Templating/BbcodeExtensionTest.php @@ -200,10 +200,10 @@ public function testEmoticonHook($value, $expected) public function dataEmoticonHook() { return array( - array(':)', ''), + array(':)', ':)'), array(':tester:', ''), array(':url_tester:', ''), - array(':\\', ''), + array(':\\', ':\\'), //array(':place_holder:', ''), // FIXME Decoda Bug: result => lace_holder: array(':_lace_holder:', ''), array(':my_emoticon:', ''), From dd4f3ed26cc876a236d750c8c2db9303f49ace83 Mon Sep 17 00:00:00 2001 From: Alexandre Quercia Date: Fri, 27 Jun 2014 17:36:33 +0200 Subject: [PATCH 2/2] Fixed the possibility to have a smilies list customizable --- Decoda/Hook/EmoticonHook.php | 23 ----------------------- DependencyInjection/Configuration.php | 2 +- README.md | 1 + Resources/config/emoticons.yml | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 24 deletions(-) create mode 100644 Resources/config/emoticons.yml diff --git a/Decoda/Hook/EmoticonHook.php b/Decoda/Hook/EmoticonHook.php index 8d507ab..8fd09ad 100644 --- a/Decoda/Hook/EmoticonHook.php +++ b/Decoda/Hook/EmoticonHook.php @@ -161,29 +161,6 @@ public function getEmoticonCollection() $this->collection = new EmoticonCollection(); - // Convert a default decoda emoticons array to an EmoticonCollection - $collection = new EmoticonCollection(); - - if (!$this->getEmoticons()) { - if (null === $this->getParser()) { - $this->setParser(new Decoda()); - } - - $this->startup(); - } - - foreach ($this->getEmoticons() as $name => $smilies) { - $emoticon = new Emoticon(); - foreach ($smilies as $smiley) { - $emoticon->setSmiley($smiley); - } - $collection->add($name, $emoticon); - } - - - $this->collection->addCollection($collection); - - if (null !== $this->options['resource']) { $subCollection = $this->loader->load($this->options['resource'], $this->options['resource_type']); $this->collection->addCollection($subCollection); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index ac1b25e..5a37be9 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -113,7 +113,7 @@ private function addEmoticonSection(ArrayNodeDefinition $rootNode) ->canBeUnset() ->addDefaultsIfNotSet() ->children() - ->scalarNode('resource')->end() + ->scalarNode('resource')->defaultValue('@FMBbcodeBundle/Resources/config/emoticons.yml')->end() ->scalarNode('type')->end() ->scalarNode('path') ->defaultValue('/emoticons/') diff --git a/README.md b/README.md index df55160..b3a621d 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ fm_bbcode: ```yaml # path/to/emoticons.yml imports: + - { resource: '@FMBbcodeBundle/Resources/config/emoticons.yml' } # Add the emoticons configuration from Decoda - { resource: path/to/another/emoticons.yml } emoticons: diff --git a/Resources/config/emoticons.yml b/Resources/config/emoticons.yml new file mode 100644 index 0000000..69b130a --- /dev/null +++ b/Resources/config/emoticons.yml @@ -0,0 +1,17 @@ +emoticons: + angry: { smilies: ['>(', '>:(', '>[', '>:[', ':angry:'] } + aw: { smilies: [':aw:'] } + cool: { smilies: [8), '8]', ':cool:'] } + ecstatic: { smilies: [':D', 8D, ':ecstatic:'] } + furious: { smilies: ['>:D', '><', ':furious:'] } + gah: { smilies: ['D:', ':O', ':gah:'] } + happy: { smilies: [':)', ':]', ':happy:'] } + heart: { smilies: ['<3', ':heart:'] } + hm: { smilies: [':/', ':\', ':hm:'] } + kiss: { smilies: [':3', ':kiss:'] } + meh: { smilies: [':|', '-.-', '<_<', '>_>', ':meh:'] } + mmf: { smilies: [':x', ':X', ':mmf:'] } + sad: { smilies: [':(', ':[', ;(, ';[', ':''(', ':''[', ';''(', ';''[', ':sad:'] } + tongue: { smilies: [':P', ':p', ':tongue:'] } + what: { smilies: [':o', ':?', ':what:'] } + wink: { smilies: [;), ';]', ;D, ':wink:'] }