diff --git a/composer.json b/composer.json index 6a5c383..b797b2f 100644 --- a/composer.json +++ b/composer.json @@ -70,6 +70,7 @@ "php": ">=5.3.0", "michelf/php-markdown": "1.3", "twig/twig": "1.12.*", - "smarty/smarty": "3.1.*" + "smarty/smarty": "3.1.*", + "ezyang/htmlpurifier": "v4.5.0" } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..c269cf3 --- /dev/null +++ b/composer.lock @@ -0,0 +1,212 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "8036953eff9eafbdbd4c431929a1d223", + "packages": [ + { + "name": "ezyang/htmlpurifier", + "version": "v4.5.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "v4.5.0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/v4.5.0", + "reference": "v4.5.0", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "HTMLPurifier": "library/" + }, + "files": [ + "library/HTMLPurifier.composer.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "time": "2013-02-18 00:04:08" + }, + { + "name": "michelf/php-markdown", + "version": "1.3", + "source": { + "type": "git", + "url": "https://github.com/michelf/php-markdown.git", + "reference": "1.3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/michelf/php-markdown/zipball/1.3", + "reference": "1.3", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-lib": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Michelf": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Michel Fortin", + "email": "michel.fortin@michelf.ca", + "homepage": "http://michelf.ca/", + "role": "Developer" + }, + { + "name": "John Gruber", + "homepage": "http://daringfireball.net/" + } + ], + "description": "PHP Markdown", + "homepage": "http://michelf.ca/projects/php-markdown/", + "keywords": [ + "markdown" + ], + "time": "2013-04-11 18:53:11" + }, + { + "name": "smarty/smarty", + "version": "v3.1.13", + "source": { + "type": "svn", + "url": "http://smarty-php.googlecode.com/svn", + "reference": "/tags/v3.1.13/@4699" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "autoload": { + "classmap": [ + "distribution/libs/Smarty.class.php", + "distribution/libs/SmartyBC.class.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0" + ], + "authors": [ + { + "name": "Monte Ohrt", + "email": "monte@ohrt.com" + }, + { + "name": "Uwe Tews", + "email": "uwe.tews@googlemail.com" + }, + { + "name": "Rodney Rehm", + "email": "rodney.rehm@medialize.de" + } + ], + "description": "Smarty - the compiling PHP template engine", + "homepage": "http://www.smarty.net", + "keywords": [ + "templating" + ], + "time": "2013-01-26 12:03:52" + }, + { + "name": "twig/twig", + "version": "v1.12.3", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Twig.git", + "reference": "v1.12.3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.12.3", + "reference": "v1.12.3", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2013-04-08 12:40:11" + } + ], + "packages-dev": [ + + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [ + + ] +} diff --git a/framework/helpers/Markdown.php b/framework/helpers/Markdown.php new file mode 100644 index 0000000..a8fd0c8 --- /dev/null +++ b/framework/helpers/Markdown.php @@ -0,0 +1,33 @@ + 'footnote_', + * )); + * ``` + * + * For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/). + * @author Alexander Makarov + * @since 2.0 + */ +class Markdown extends base\Markdown +{ +} diff --git a/framework/helpers/Purifier.php b/framework/helpers/Purifier.php new file mode 100644 index 0000000..b659531 --- /dev/null +++ b/framework/helpers/Purifier.php @@ -0,0 +1,34 @@ + true, + * )); + * ``` + * + * For more details please refer to HTMLPurifier documentation](http://htmlpurifier.org/). + * + * @author Alexander Makarov + * @since 2.0 + */ +class Purifier extends base\Purifier +{ +} diff --git a/framework/helpers/base/Markdown.php b/framework/helpers/base/Markdown.php new file mode 100644 index 0000000..562403f --- /dev/null +++ b/framework/helpers/base/Markdown.php @@ -0,0 +1,51 @@ + 'footnote_', + * )); + * ``` + * + * For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/). + * @author Alexander Makarov + * @since 2.0 + */ +class Markdown +{ + /** + * @var MarkdownExtra + */ + protected static $markdown; + + public static function process($content, $config = array()) + { + if (static::$markdown===null) { + static::$markdown = new MarkdownExtra(); + } + foreach ($config as $name => $value) { + static::$markdown->{$name} = $value; + } + return static::$markdown->transform($content); + } +} diff --git a/framework/helpers/base/Purifier.php b/framework/helpers/base/Purifier.php new file mode 100644 index 0000000..cc4ab12 --- /dev/null +++ b/framework/helpers/base/Purifier.php @@ -0,0 +1,43 @@ + true, + * )); + * ``` + * + * For more details please refer to HTMLPurifier documentation](http://htmlpurifier.org/). + * + * @author Alexander Makarov + * @since 2.0 + */ +class Purifier +{ + public static function process($content, $config = null) + { + $purifier=\HTMLPurifier::instance($config); + $purifier->config->set('Cache.SerializerPath', \Yii::$app->getRuntimePath()); + return $purifier->purify($content); + } +}