Translate modifier's docs

This commit is contained in:
Ivan Shalganov
2014-01-29 10:01:31 +02:00
parent 5e4b7f3051
commit dc287f08b2
10 changed files with 64 additions and 57 deletions

View File

@@ -51,15 +51,18 @@ class Modifier
*
* @param string $text
* @param string $type
* @param string $charset
* @return string
*/
public static function escape($text, $type = 'html')
public static function escape($text, $type = 'html', $charset = 'UTF-8')
{
switch (strtolower($type)) {
case "url":
return urlencode($text);
case "html";
return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
return htmlspecialchars($text, ENT_COMPAT, $charset);
case "js":
return json_encode($text, 64 | 256); // JSON_UNESCAPED_SLASHES = 64, JSON_UNESCAPED_UNICODE = 256
default:
return $text;
}