summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2005-07-12 11:27:54 +0000
commit4f3bce79bfb5851cef9e7bc655c91bb3093cc401 (patch)
tree10a0991fddeb0e075d7fa46e2b40e5dbc64d1e88 /wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php
downloadwordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.gz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.tar.xz
wordpress-mu-4f3bce79bfb5851cef9e7bc655c91bb3093cc401.zip
Initial Import
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php')
-rw-r--r--wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php b/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php
new file mode 100644
index 0000000..b9bb184
--- /dev/null
+++ b/wp-inst/wp-content/smarty-plugins/modifier.debug_print_var.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty debug_print_var modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: debug_print_var<br>
+ * Purpose: formats variable contents for display in the console
+ * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
+ * debug_print_var (Smarty online manual)
+ * @param array|object
+ * @param integer
+ * @param integer
+ * @return string
+ */
+function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
+{
+ $_replace = array("\n"=>'<i>&#92;n</i>', "\r"=>'<i>&#92;r</i>', "\t"=>'<i>&#92;t</i>');
+ if (is_array($var)) {
+ $results = "<b>Array (".count($var).")</b>";
+ foreach ($var as $curr_key => $curr_val) {
+ $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
+ $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> =&gt; $return";
+ }
+ } else if (is_object($var)) {
+ $object_vars = get_object_vars($var);
+ $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
+ foreach ($object_vars as $curr_key => $curr_val) {
+ $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
+ $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
+ }
+ } else if (is_resource($var)) {
+ $results = '<i>'.(string)$var.'</i>';
+ } else if (empty($var) && $var != "0") {
+ $results = '<i>empty</i>';
+ } else {
+ if (strlen($var) > $length ) {
+ $results = substr($var, 0, $length-3).'...';
+ } else {
+ $results = $var;
+ }
+ $results = htmlspecialchars($results);
+ $results = strtr($results, $_replace);
+ }
+ return $results;
+}
+
+/* vim: set expandtab: */
+
+?>