Yaffs site version 1.1
[yaffs-website] / vendor / ezyang / htmlpurifier / maintenance / flush-definition-cache.php
1 #!/usr/bin/php
2 <?php
3
4 chdir(dirname(__FILE__));
5 require_once 'common.php';
6 assertCli();
7
8 /**
9  * @file
10  * Flushes the definition serial cache. This file should be
11  * called if changes to any subclasses of HTMLPurifier_Definition
12  * or related classes (such as HTMLPurifier_HTMLModule) are made. This
13  * may also be necessary if you've modified a customized version.
14  *
15  * @param Accepts one argument, cache type to flush; otherwise flushes all
16  *      the caches.
17  */
18
19 echo "Flushing cache... \n";
20
21 require_once(dirname(__FILE__) . '/../library/HTMLPurifier.auto.php');
22
23 $config = HTMLPurifier_Config::createDefault();
24
25 $names = array('HTML', 'CSS', 'URI', 'Test');
26 if (isset($argv[1])) {
27     if (in_array($argv[1], $names)) {
28         $names = array($argv[1]);
29     } else {
30         throw new Exception("Cache parameter {$argv[1]} is not a valid cache");
31     }
32 }
33
34 foreach ($names as $name) {
35     echo " - Flushing $name\n";
36     $cache = new HTMLPurifier_DefinitionCache_Serializer($name);
37     $cache->flush($config);
38 }
39
40 echo "Cache flushed successfully.\n";
41
42 // vim: et sw=4 sts=4