Commit f2258e76 by Alexander Makarov

Added Purifier and Markdown helpers, added composer.lock

parent 17807874
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
"php": ">=5.3.0", "php": ">=5.3.0",
"michelf/php-markdown": "1.3", "michelf/php-markdown": "1.3",
"twig/twig": "1.12.*", "twig/twig": "1.12.*",
"smarty/smarty": "3.1.*" "smarty/smarty": "3.1.*",
"ezyang/htmlpurifier": "v4.5.0"
} }
} }
{
"_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": [
]
}
<?php
/**
* @copyright Copyright (c) 2008 Yii Software LLC
* @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers;
/**
* Markdown provides an ability to transform markdown into HTML.
*
* Basic usage is the following:
*
* ```php
* $my_html = Markdown::process($my_text);
* ```
*
* If you want to configure the parser:
*
* ```php
* $my_html = Markdown::process($my_text, array(
* 'fn_id_prefix' => 'footnote_',
* ));
* ```
*
* For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/).
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class Markdown extends base\Markdown
{
}
<?php
/**
* @copyright Copyright (c) 2008 Yii Software LLC
* @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers;
/**
* Purifier provides an ability to clean up HTML from any harmful code.
*
* Basic usage is the following:
*
* ```php
* $my_html = Purifier::process($my_text);
* ```
*
* If you want to configure it:
*
* ```php
* $my_html = Purifier::process($my_text, array(
* 'Attr.EnableID' => true,
* ));
* ```
*
* For more details please refer to HTMLPurifier documentation](http://htmlpurifier.org/).
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class Purifier extends base\Purifier
{
}
<?php
/**
* @copyright Copyright (c) 2008 Yii Software LLC
* @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
\Yii::setAlias('@Michelf', \Yii::getAlias('@yii').'/../vendor/michelf/php-markdown/Michelf');
use Michelf\MarkdownExtra;
/**
* Markdown provides an ability to transform markdown into HTML.
*
* Basic usage is the following:
*
* ```php
* $my_html = Markdown::process($my_text);
* ```
*
* If you want to configure the parser:
*
* ```php
* $my_html = Markdown::process($my_text, array(
* 'fn_id_prefix' => 'footnote_',
* ));
* ```
*
* For more details please refer to [PHP Markdown library documentation](http://michelf.ca/projects/php-markdown/).
* @author Alexander Makarov <sam@rmcreative.ru>
* @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);
}
}
<?php
/**
* @copyright Copyright (c) 2008 Yii Software LLC
* @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers\base;
if (!class_exists('HTMLPurifier_Bootstrap', false)) {
require_once(\Yii::getAlias('@yii').'/../vendor/ezyang/htmlpurifier/library'.DIRECTORY_SEPARATOR.'HTMLPurifier.auto.php');
}
/**
* Purifier provides an ability to clean up HTML from any harmful code.
*
* Basic usage is the following:
*
* ```php
* $my_html = Purifier::process($my_text);
* ```
*
* If you want to configure it:
*
* ```php
* $my_html = Purifier::process($my_text, array(
* 'Attr.EnableID' => true,
* ));
* ```
*
* For more details please refer to HTMLPurifier documentation](http://htmlpurifier.org/).
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment