$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', 'a[href|target|title],img[class|src|border|alt|title|hspace|vspace|width|height|align|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|style],br,p[class]'); //$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; } } }