$value) { $output[$key] = self::sanitize($value); } } else { $output = trim(self::getPurifier()->purify($input)); } return $output; } /** * Interpreta e formatta correttamente i contenuti dell'input. * * @param mixed $input Contenuti * * @return mixed */ public static function parse($input) { $output = null; if (is_array($input)) { foreach ($input as $key => $value) { $output[$key] = self::parse($value); } } elseif (!is_null($input)) { $output = Translator::getFormatter()->parse($input); } return $output; } /** * Restituisce l'istanza di HTMLPurifier in utilizzo. * * @return \HTMLPurifier */ public static function getPurifier() { if (empty(self::$purifier)) { $config = \HTMLPurifier_Config::createDefault(); $config->set('HTML.Allowed', 'br,p[style],b[style],strong[style],i[style],em[style],u[style],strike,a[style|href|title|target],ol[style],ul[style],li[style],hr[style],blockquote[style],img[style|alt|title|width|height|src|align],table[style|width|bgcolor|align|cellspacing|cellpadding|border],tr[style],td[style],th[style],tbody,thead,caption,col,colgroup,span[style],sup'); //$config->set('Cache.SerializerPath', realpath(__DIR__.'/cache/HTMLPurifier')); $config->set('Cache.DefinitionImpl', null); self::$purifier = new \HTMLPurifier($config); } return self::$purifier; } /** * Imposta una proprietà specifica a un valore personalizzato. * * @param string $method * @param string $property * @param mixed $value */ public static function set($method, $property, $value) { if (strtolower($method) == 'post') { self::$post['data'][$property] = $value; } elseif (strtolower($method) == 'get') { self::$get['data'][$property] = $value; } } }