Extend sm_print_r so you can do:
[squirrelmail.git] / functions / strings.php
index db5ff7c2e61b480d0f9d4e81e6de945d887d1b7d..af51b98745589b3c43d8acdae6e71520e65012ce 100644 (file)
@@ -415,6 +415,49 @@ function TrimArray(&$array) {
     }
 }   
 
     }
 }   
 
+/* returns a link to the compose-page, taking in consideration
+ * the compose_in_new and javascript settings. */
+function makeComposeLink($url, $text = null)
+{
+    global $compose_new_win,$javascript_on;
+
+    if(!$text) {
+        $text = _("Compose");
+    }
+
+    if($compose_new_win != '1') {
+        return makeInternalLink($url, $text, 'right');
+    }
+
+    /* if we can use JS, use the fancy window, else just open a new one HTML-style */
+    if($javascript_on) {
+        sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
+        return '<a href="javascript:void(0)" onclick="comp_in_new(\''.$base_uri.$url.'\')">'. $text.'</a>';
+    }
+
+    return makeInternalLink($url, $text, '_blank');
+}
+
+/** 
+* sm_print_r($some_variable, [$some_other_variable [, ...]]);
+* Debugging function - does the same as print_r, but makes sure special
+* characters are converted to htmlentities first.  This will allow
+* values like <some@email.address> to be displayed.
+* The output is wrapped in <pre> and </pre> tags.
+*/
+function sm_print_r() {
+    ob_start();  // Buffer output
+    foreach(func_get_args() as $var) {
+        print_r($var);
+        echo "\n";
+    }
+    $buffer = ob_get_contents(); // Grab the print_r output
+    ob_end_clean();  // Silently discard the output & stop buffering
+    print "<pre>";
+    print htmlentities($buffer);
+    print "</pre>";
+}
+
 $PHP_SELF = php_self();
 
 ?>
 $PHP_SELF = php_self();
 
 ?>