<h2>Censoring</h2> <?php $string = 'Decoda uses a pretty awesome censoring system. It censors any word in the censored.txt blacklist file. It tries its best not to censor words within other words, but it can happen. Here are a few examples: f**k shit bitch asshole penis douche And here are the same words, but with different lengths for each letter, and in different cases. fuuCCkk shhiiiitt bITCH assHOLE peeniiss douchhe It will also magically censor words that end with: ing, ed, er f****r shiting bitched Hope it works out, I tried to make it as smart as possible.'; $code = new \mjohnson\decoda\Decoda($string); $code->addHook(new \mjohnson\decoda\hooks\CensorHook()); echo $code->parse();
<?php $code = new \mjohnson\decoda\Decoda(); $code->addFilter(new \mjohnson\decoda\filters\CodeFilter()); $code->addHook(new \mjohnson\decoda\hooks\EmoticonHook()); $code->addHook(new \mjohnson\decoda\hooks\CensorHook()); ?> <h2>Code</h2> <?php $string = "[code]// Constants\ndefine('DECODA', __DIR__ .'/');\n\n// Includes\nspl_autoload_register();\nset_include_path(implode(PATH_SEPARATOR, array(\n\tget_include_path(),\n\tDECODA\n)));[/code]"; $code->reset($string); echo $code->parse(); ?> <h2>Code <span>with filters and hooks</span></h2> <?php $string = "[code]email@domain.com\n\n:] :) :D :/ >[ :p :o >_>\n\n:happy: :aw: :cool: :kiss: :meh: :mmf: :heart:\n\nfuuCCkk shhiiiitt bITCH assHOLE peeniiss douchhe\n\nfucker shiting bitched[/code]"; $code->reset($string); echo $code->parse(); ?> <h2>Code <span>with language attribute</span></h2> <?php $string = '[code="php"]<?php abstract class HookAbstract implements Hook { /**
<?php $code = new \mjohnson\decoda\Decoda(); $code->addFilter(new \mjohnson\decoda\filters\UrlFilter()); $code->addHook(new \mjohnson\decoda\hooks\ClickableHook()); ?> <h2>URL</h2> <?php $string = 'Valid websites: [url]http://domain.com[/url] [url]https://securesite.com[/url] [url]ftp://ftpsite.com[/url] [url]irc://ircsite.com[/url] [url]telnet://telnetsite.com[/url] [url="http://domain.com"]Linked URL[/url] Valid websites (auto-linked with hook): http://domain.com http://sub.domain.com/?with=param http://user:pass@domain.com:80/?with=param Invalid websites: [url]domain.com[/url] [url]www.domain.com[/url] [url]wtf://unsupportedprotocol.com/[/url]'; $code->reset($string); echo $code->parse(); ?>
<h2>Emoticons</h2> <?php $string = 'Decoda also comes with an emoticon system. It will convert any kind of smiley from emoticons.json into a small image. The system will not parse smilies within strings (like URLs) that resemble smilies. Here are a couple: :] :) :D :/ >[ :p :o >_> It also supports the word syntax: :happy: :aw: :cool: :kiss: :meh: :mmf: :heart:'; $code = new \mjohnson\decoda\Decoda($string); $code->addFilter(new \mjohnson\decoda\filters\ImageFilter()); $code->addHook(new \mjohnson\decoda\hooks\EmoticonHook(array('path' => '../emoticons/'))); echo $code->parse();