logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

cvs: smarty / NEWS /libs/plugins function.mailto.php: msg#00039

Subject: cvs: smarty / NEWS /libs/plugins function.mailto.php
mohrt           Fri Feb 25 12:08:28 2005 EDT

  Modified files:              
    /smarty     NEWS 
    /smarty/libs/plugins        function.mailto.php 
  Log:
  add javascript_charcode option to mailto
  
  
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.489&r2=1.490&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.489 smarty/NEWS:1.490
--- smarty/NEWS:1.489   Thu Feb 24 09:38:32 2005
+++ smarty/NEWS Fri Feb 25 12:08:27 2005
@@ -1,3 +1,5 @@
+  - add javascript_charcode encoding option to mailto function
+    (monte)
   - add ids to html_radios labels (monte, menulis)
   - fix handling of strip-tags with non-default delimiters (Mark West, messju)
 
http://cvs.php.net/diff.php/smarty/libs/plugins/function.mailto.php?r1=1.14&r2=1.15&ty=u
Index: smarty/libs/plugins/function.mailto.php
diff -u smarty/libs/plugins/function.mailto.php:1.14 
smarty/libs/plugins/function.mailto.php:1.15
--- smarty/libs/plugins/function.mailto.php:1.14        Fri Jan 21 12:46:15 2005
+++ smarty/libs/plugins/function.mailto.php     Fri Feb 25 12:08:28 2005
@@ -20,6 +20,7 @@
  *         - encode = (optional) can be one of:
  *                * none : no encoding (default)
  *                * javascript : encode with javascript
+ *                * javascript_charcode : encode with javascript charcode
  *                * hex : encode with hexidecimal (no javascript)
  *         - cc = (optional) address(es) to carbon copy
  *         - bcc = (optional) address(es) to blind carbon copy
@@ -92,7 +93,7 @@
     $address .= $mail_parm_vals;
 
     $encode = (empty($params['encode'])) ? 'none' : $params['encode'];
-    if (!in_array($encode,array('javascript','hex','none')) ) {
+    if 
(!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) {
         $smarty->trigger_error("mailto: 'encode' parameter must be none, 
javascript or hex");
         return;
     }
@@ -107,6 +108,25 @@
 
         return '<script 
type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
 
+    } elseif ($encode == 'javascript_charcode' ) {
+        $string = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+        for($x = 0, $y = strlen($string); $x < $y; $x++ ) {
+            $ord[] = ord($string[$x]);   
+        }
+
+        $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
+        $_ret .= "<!--\n";
+        $_ret .= "{document.write(String.fromCharCode(";
+        $_ret .= implode(',',$ord);
+        $_ret .= "))";
+        $_ret .= "}\n";
+        $_ret .= "//-->\n";
+        $_ret .= "</script>\n";
+        
+        return $_ret;
+        
+        
     } elseif ($encode == 'hex') {
 
         preg_match('!^(.*)(\?.*)$!',$address,$match);

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>