| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: |
|
| 24: | function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array())
|
| 25: | {
|
| 26: | $_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
|
| 27: | switch (gettype($var)) {
|
| 28: | case 'array':
|
| 29: | $results = '<b>Array (' . count($var) . ')</b>';
|
| 30: | if ($depth === $max) {
|
| 31: | break;
|
| 32: | }
|
| 33: | foreach ($var as $curr_key => $curr_val) {
|
| 34: | $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
|
| 35: | '</b> => ' .
|
| 36: | smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
|
| 37: | $depth--;
|
| 38: | }
|
| 39: | break;
|
| 40: | case 'object':
|
| 41: | $object_vars = get_object_vars($var);
|
| 42: | $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
| 43: | if (in_array($var, $objects)) {
|
| 44: | $results .= ' called recursive';
|
| 45: | break;
|
| 46: | }
|
| 47: | if ($depth === $max) {
|
| 48: | break;
|
| 49: | }
|
| 50: | $objects[] = $var;
|
| 51: | foreach ($object_vars as $curr_key => $curr_val) {
|
| 52: | $results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) .
|
| 53: | '</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
|
| 54: | $depth--;
|
| 55: | }
|
| 56: | break;
|
| 57: | case 'boolean':
|
| 58: | case 'NULL':
|
| 59: | case 'resource':
|
| 60: | if (true === $var) {
|
| 61: | $results = 'true';
|
| 62: | } elseif (false === $var) {
|
| 63: | $results = 'false';
|
| 64: | } elseif (null === $var) {
|
| 65: | $results = 'null';
|
| 66: | } else {
|
| 67: | $results = htmlspecialchars((string)$var);
|
| 68: | }
|
| 69: | $results = '<i>' . $results . '</i>';
|
| 70: | break;
|
| 71: | case 'integer':
|
| 72: | case 'float':
|
| 73: | $results = htmlspecialchars((string)$var);
|
| 74: | break;
|
| 75: | case 'string':
|
| 76: | $results = strtr($var, $_replace);
|
| 77: | if (Smarty::$_MBSTRING) {
|
| 78: | if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
| 79: | $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
| 80: | }
|
| 81: | } else {
|
| 82: | if (isset($var[ $length ])) {
|
| 83: | $results = substr($var, 0, $length - 3) . '...';
|
| 84: | }
|
| 85: | }
|
| 86: | $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
| 87: | break;
|
| 88: | case 'unknown type':
|
| 89: | default:
|
| 90: | $results = strtr((string)$var, $_replace);
|
| 91: | if (Smarty::$_MBSTRING) {
|
| 92: | if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
| 93: | $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
| 94: | }
|
| 95: | } else {
|
| 96: | if (strlen($results) > $length) {
|
| 97: | $results = substr($results, 0, $length - 3) . '...';
|
| 98: | }
|
| 99: | }
|
| 100: | $results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
|
| 101: | }
|
| 102: | return $results;
|
| 103: | }
|
| 104: | |