10 defined(
'JPATH_PLATFORM') or die;
36 public static function objectHTMLSafe(&$mixed, $quote_style = ENT_QUOTES, $exclude_keys =
'')
38 if (is_object($mixed))
40 foreach (get_object_vars($mixed) as $k => $v)
42 if (is_array($v) || is_object($v) || $v == null || substr($k, 1, 1) ==
'_')
47 if (is_string($exclude_keys) && $k == $exclude_keys)
51 elseif (is_array($exclude_keys) && in_array($k, $exclude_keys))
56 $mixed->$k = htmlspecialchars($v, $quote_style,
'UTF-8');
70 public static function linkXHTMLSafe($input)
72 $regex =
'href="([^"]*(&(amp;){0})[^"]*)*?"';
74 return preg_replace_callback(
"#$regex#i", array(
'JFilterOutput',
'_ampReplaceCallback'), $input);
87 public static function stringURLSafe($string)
90 $str = str_replace(
'-',
' ', $string);
93 $str = $lang->transliterate($str);
99 $str = preg_replace(
'/(\s|[^A-Za-z0-9\-])+/',
'-', $str);
102 $str = trim($str,
'-');
116 public static function stringURLUnicodeSlug($string)
119 $str = preg_replace(
'/\xE3\x80\x80/',
' ', $string);
124 $str = str_replace(
'-',
' ', $str);
127 $str = preg_replace(
'#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#',
"\x20", $str);
130 $str = str_replace(
'?',
'', $str);
136 $str = preg_replace(
'#\x20+#',
'-', $str);
152 public static function ampReplace($text)
154 $text = str_replace(
'&&',
'*--*', $text);
155 $text = str_replace(
'&#',
'*-*', $text);
156 $text = str_replace(
'&',
'&', $text);
157 $text = preg_replace(
'|&(?![\w]+;)|',
'&', $text);
158 $text = str_replace(
'*-*',
'&#', $text);
159 $text = str_replace(
'*--*',
'&&', $text);
173 public static function _ampReplaceCallback($m)
177 return preg_replace(
'#' . $rx .
'#',
'&', $m[0]);
189 public static function cleanText(&$text)
191 $text = preg_replace(
"'<script[^>]*>.*?</script>'si",
'', $text);
192 $text = preg_replace(
'/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is',
'\2 (\1)', $text);
193 $text = preg_replace(
'/<!--.+?-->/',
'', $text);
194 $text = preg_replace(
'/{.+?}/',
'', $text);
195 $text = preg_replace(
'/ /',
' ', $text);
196 $text = preg_replace(
'/&/',
' ', $text);
197 $text = preg_replace(
'/"/',
' ', $text);
198 $text = strip_tags($text);
199 $text = htmlspecialchars($text, ENT_COMPAT,
'UTF-8');
213 public static function stripImages($string)
215 return preg_replace(
'#(<[/]?img.*>)#U',
'', $string);
227 public static function stripIframes($string)
229 return preg_replace(
'#(<[/]?iframe.*>)#U',
'', $string);