Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fixed the possibility to have a smilies list customizable #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 0 additions & 23 deletions Decoda/Hook/EmoticonHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions Resources/config/emoticons.yml
Original file line number Diff line number Diff line change
@@ -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:'] }
4 changes: 2 additions & 2 deletions Tests/Templating/BbcodeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ public function testEmoticonHook($value, $expected)
public function dataEmoticonHook()
{
return array(
array(':)', '<img src="/emoticons/happy.png" alt="" />'),
array(':)', ':)'),
array(':tester:', '<img src="/emoticons/tester.png" alt="" />'),
array(':url_tester:', '<img src="/foo.gif" alt="" />'),
array(':\\', '<img src="/emoticons/hm.png" alt="" />'),
array(':\\', ':\\'),
//array(':place_holder:', '<img src="/emoticons//foo.gif" alt="" />'), // FIXME Decoda Bug: result => <img src="/emoticons/tongue.png" alt="" />lace_holder:
array(':_lace_holder:', '<img src="/emoticons//foo.gif" alt="" />'),
array(':my_emoticon:', '<img src="/emoticons//my_emoticon.png" alt="" title="my_emoticon" />'),
Expand Down