Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HTMLPurifier.php « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 17c769e9fc407d6d3e8c3ad23bec4cab8f25a958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 * @version $Id$
 *
 * @category Piwik
 * @package Piwik
 */

/**
 * HTML Purifier class wrapper.
 *
 * @package Piwik
 */
class Piwik_HTMLPurifier
{
	static private $instance = null;

	/**
	 * Returns the singleton HTMLPurifier or a mock object
	 *
	 * @return HTMLPurifier|Piwik_HTMLPurifier
	 */
	static public function getInstance()
	{
		if (self::$instance == null)
		{
			if(file_exists(PIWIK_INCLUDE_PATH . '/libs/HTMLPurifier.php'))
			{
				if(!class_exists('HTMLPurifier_Bootstrap', false))
				{
					HTMLPurifier_Bootstrap::registerAutoload();
				}

				$config = HTMLPurifier_Config::createDefault();
				$config->set('Cache.SerializerPath', PIWIK_USER_PATH . '/tmp/purifier');

				self::$instance = new HTMLPurifier($config);
			}
			else
			{
				$c = __CLASS__;
				self::$instance = new $c();
			}
		}
		return self::$instance;
	}

	public function purify($html, $config = null)
	{
		return $html;
	}
}