-
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 emoticons dump command (closes #35), introduced bbcode_clean fi…
- Loading branch information
Showing
10 changed files
with
227 additions
and
53 deletions.
There are no files selected for viewing
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,65 @@ | ||
<?php | ||
|
||
namespace FM\BbcodeBundle\Command; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Helper\HelperInterface; | ||
/** | ||
* | ||
* @author Al Ganiev <[email protected]> | ||
* @copyright 2013 Al Ganiev | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class DumpEmoticonsCommand extends ContainerAwareCommand | ||
{ | ||
/** | ||
* @see Command | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('bbcode:dump') | ||
->setDescription('dump emoticons to public folder'); | ||
} | ||
|
||
/** | ||
* Copies one folder to another | ||
* @param $src | ||
* @param $dst | ||
*/ | ||
private function recurse_copy($src,$dst) { | ||
$dir = opendir($src); | ||
@mkdir($dst); | ||
while(false !== ( $file = readdir($dir)) ) { | ||
if (( $file != '.' ) && ( $file != '..' )) { | ||
if ( is_dir($src . '/' . $file) ) { | ||
$this->recurse_copy($src . '/' . $file,$dst . '/' . $file); | ||
} | ||
else { | ||
copy($src . '/' . $file,$dst . '/' . $file); | ||
} | ||
} | ||
} | ||
closedir($dir); | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\Console\Input\InputInterface $input | ||
* @param \Symfony\Component\Console\Output\OutputInterface $output | ||
* @return int|null|void | ||
*/ | ||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$webFolder = $this->getContainer()->get('kernel')->getRootDir().'/../web/emoticons'; | ||
@mkdir($webFolder); | ||
$emoticonsFolder = $this->getContainer()->get('kernel')->getRootDir().'/../vendor/mjohnson/decoda/emoticons'; | ||
$this->recurse_copy($emoticonsFolder,$webFolder); | ||
|
||
$output->writeln('<comment>Emoticons dumped succesfully</comment>'); | ||
} | ||
|
||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace FM\BbcodeBundle\Composer; | ||
|
||
use Symfony\Component\ClassLoader\ClassCollectionLoader; | ||
use Symfony\Component\Process\Process; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
|
||
/** | ||
* @author Al Ganiev, original by Jordi Boggiano <[email protected]> | ||
*/ | ||
class ScriptHandler | ||
{ | ||
public static function installEmoticons($event) | ||
{ | ||
static::executeCommand($event, 'app', 'bbcode:dump'); | ||
} | ||
|
||
protected static function getPhp() | ||
{ | ||
$phpFinder = new PhpExecutableFinder; | ||
if (!$phpPath = $phpFinder->find()) { | ||
throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again'); | ||
} | ||
|
||
return $phpPath; | ||
} | ||
|
||
protected static function executeCommand($event, $appDir, $cmd, $timeout = 300) | ||
{ | ||
$php = escapeshellarg(self::getPhp()); | ||
$console = escapeshellarg($appDir.'/console'); | ||
if ($event->getIO()->isDecorated()) { | ||
$console.= ' --ansi'; | ||
} | ||
|
||
$process = new Process($php.' '.$console.' '.$cmd, null, null, null, $timeout); | ||
$process->run(function ($type, $buffer) { echo $buffer; }); | ||
if (!$process->isSuccessful()) { | ||
throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd))); | ||
} | ||
} | ||
} |
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,26 +4,26 @@ | |
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; | ||
use Decoda\Filter, | ||
Decoda\Filter\DefaultFilter, | ||
Decoda\Filter\BlockFilter, | ||
Decoda\Filter\CodeFilter, | ||
Decoda\Filter\EmailFilter, | ||
Decoda\Filter\ImageFilter, | ||
Decoda\Filter\ListFilter, | ||
Decoda\Filter\QuoteFilter, | ||
Decoda\Filter\TextFilter, | ||
Decoda\Filter\UrlFilter, | ||
Decoda\Filter\VideoFilter; | ||
use Decoda\Hook\CensorHook, | ||
Decoda\Hook\ClickableHook, | ||
Decoda\Hook\CodeHook, | ||
Decoda\Hook\EmoticonHook, | ||
Decoda\Hook; | ||
|
||
/** | ||
* @author Al Ganiev <[email protected]> | ||
* @copyright 2012 Al Ganiev | ||
* @copyright 2013 Al Ganiev | ||
* @license http://www.opensource.org/licenses/mit-license.php MIT License | ||
*/ | ||
class DecodaManager | ||
|
@@ -162,7 +162,7 @@ protected function applyHook(Decoda $code, $hook) | |
$code->addHook(new ClickableHook()); | ||
break; | ||
case 'emoticon': | ||
$code->addHook(new EmoticonHook()); | ||
$code->addHook(new EmoticonHook(array('path' => '/emoticons/'))); | ||
break; | ||
case 'code': | ||
$code->addHook(new CodeHook()); | ||
|
@@ -194,6 +194,8 @@ public function getResult() | |
|
||
$this->value->setEngine($decodaPhpEngine); | ||
|
||
$this->value->addPath(DECODA.'/config'); | ||
|
||
foreach($this->filters as $filter) | ||
{ | ||
$this->value = $this->applyFilter($this->value, $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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.