|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00014 class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef 00015 { 00016 00021 public $single; 00022 00027 public $max; 00028 00033 public function __construct($single, $max = 4) { 00034 $this->single = $single; 00035 $this->max = $max; 00036 } 00037 00038 public function validate($string, $config, $context) { 00039 $string = $this->parseCDATA($string); 00040 if ($string === '') return false; 00041 $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n 00042 $length = count($parts); 00043 $final = ''; 00044 for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) { 00045 if (ctype_space($parts[$i])) continue; 00046 $result = $this->single->validate($parts[$i], $config, $context); 00047 if ($result !== false) { 00048 $final .= $result . ' '; 00049 $num++; 00050 } 00051 } 00052 if ($final === '') return false; 00053 return rtrim($final); 00054 } 00055 00056 } 00057 00058 // vim: et sw=4 sts=4