summaryrefslogtreecommitdiff
path: root/framework/Web/THttpUtility.php
diff options
context:
space:
mode:
authorxue <>2005-11-10 12:47:19 +0000
committerxue <>2005-11-10 12:47:19 +0000
commit55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 (patch)
treea0599d5e36fdbb3f1e169ae56bab7d529597e3eb /framework/Web/THttpUtility.php
Initial import of prado framework
Diffstat (limited to 'framework/Web/THttpUtility.php')
-rw-r--r--framework/Web/THttpUtility.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/framework/Web/THttpUtility.php b/framework/Web/THttpUtility.php
new file mode 100644
index 00000000..9d2aa7b2
--- /dev/null
+++ b/framework/Web/THttpUtility.php
@@ -0,0 +1,33 @@
+<?php
+
+class THttpUtility
+{
+ private static $entityTable=null;
+
+ public static function htmlEncode($s)
+ {
+ return htmlspecialchars($s);
+ }
+
+ public static function htmlDecode($s)
+ {
+ if(!self::$entityTable)
+ self::buildEntityTable();
+ return strtr($s,self::$entityTable);
+ }
+
+ private static function buildEntityTable()
+ {
+ self::$entityTable=array_flip(get_html_translation_table(HTML_ENTITIES,ENT_QUOTES));
+ }
+
+ public static function quoteJavaScriptString($js,$forUrl=false)
+ {
+ if($forUrl)
+ return strtr($js,array('%'=>'%25',"\t"=>'\t',"\n"=>'\n',"\r"=>'\r','"'=>'\"','\''=>'\\\'','\\'=>'\\\\'));
+ else
+ return strtr($js,array("\t"=>'\t',"\n"=>'\n',"\r"=>'\r','"'=>'\"','\''=>'\\\'','\\'=>'\\\\'));
+ }
+}
+
+?> \ No newline at end of file