当前位置: 首页>>代码示例>>PHP>>正文


PHP smarty_modifier_debug_print_var函数代码示例

本文整理汇总了PHP中smarty_modifier_debug_print_var函数的典型用法代码示例。如果您正苦于以下问题:PHP smarty_modifier_debug_print_var函数的具体用法?PHP smarty_modifier_debug_print_var怎么用?PHP smarty_modifier_debug_print_var使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了smarty_modifier_debug_print_var函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_modifier_debug_print_var

/**
 * 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)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array|object
 * @param integer
 * @param integer
 * @return string
 */
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
    $_replace = array("\n" => '<i>\\n</i>', "\r" => '<i>\\r</i>', "\t" => '<i>\\t</i>');
    switch (gettype($var)) {
        case 'array':
            $results = '<b>Array (' . count($var) . ')</b>';
            foreach ($var as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
                $depth--;
            }
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
            foreach ($object_vars as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results = 'true';
            } elseif (false === $var) {
                $results = 'false';
            } elseif (null === $var) {
                $results = 'null';
            } else {
                //$results = htmlspecialchars((string) $var);
                $results = encode_htmlspecialchars((string) $var);
                // web28 2013-01-11 - use encode_htmlentities (PHP5.4 ready)
            }
            $results = '<i>' . $results . '</i>';
            break;
        case 'integer':
        case 'float':
            $results = htmlspecialchars((string) $var);
            break;
        case 'string':
            $results = strtr($var, $_replace);
            if (strlen($var) > $length) {
                $results = substr($var, 0, $length - 3) . '...';
            }
            //$results = htmlspecialchars('"' . $results . '"');
            $results = encode_htmlspecialchars('"' . $results . '"');
            // web28 2013-01-11 - use encode_htmlentities (PHP5.4 ready)
            break;
        case 'unknown type':
        default:
            $results = strtr((string) $var, $_replace);
            if (strlen($results) > $length) {
                $results = substr($results, 0, $length - 3) . '...';
            }
            //$results = htmlspecialchars($results);
            $results = encode_htmlspecialchars($results);
            // web28 2013-01-11 - use encode_htmlentities (PHP5.4 ready)
    }
    return $results;
}
开发者ID:shophelfer,项目名称:shophelfer.com-shop,代码行数:74,代码来源:modifier.debug_print_var.php

示例2: smarty_modifier_debug_print_var

function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
    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);
            $results .= '<br>\\r' . str_repeat('&nbsp;', $depth * 2) . "<b>{$curr_key}</b> =&gt; {$return}";
        }
        return $results;
    } 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);
                $results .= '<br>\\r' . str_repeat('&nbsp;', $depth * 2) . "<b>{$curr_key}</b> =&gt; {$return}";
            }
            return $results;
        } else {
            if (empty($var) && $var != "0") {
                return '<i>empty</i>';
            }
            if (strlen($var) > $length) {
                $results = substr($var, 0, $length - 3) . '...';
            } else {
                $results = $var;
            }
            $results = preg_replace("![\r\t\n]!", " ", $results);
            $results = htmlspecialchars($results);
            return $results;
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:logicalframe,代码行数:33,代码来源:modifier.debug_print_var.php

示例3: smarty_modifier_debug_print_var

/**
 * Smarty debug_print_var modifier plugin
 *
 * Modified version of the default smarty plug-in that prevents endless looping when dealing with assigned
 * objects
 *
 *
 *
 * 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}";
        }
    } elseif (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) {
            if (is_object($curr_val)) {
                $return = '[object ' . get_class($curr_val) . ']';
            } else {
                $return = smarty_modifier_debug_print_var($curr_val, $depth + 1, $length);
            }
            $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . "<b>{$curr_key}</b> =&gt; {$return}";
        }
    } elseif (is_resource($var)) {
        $results = '<i>' . (string) $var . '</i>';
    } elseif (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;
}
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:53,代码来源:modifier.debug_print_var.php

示例4: smarty_modifier_zdebug_print_var

/**
 * Formats variable contents for display in the console.
 *
 * @param array|object $var    What is being modified.
 * @param integer      $depth  Depth to print arrays.
 * @param integer      $length Max length.
 *
 * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
 *
 * @return string
 */
function smarty_modifier_zdebug_print_var($var, $depth = 0, $length = 40)
{
    $_replace = array("\n" => '<i>\\n</i>', "\r" => '<i>\\r</i>', "\t" => '<i>\\t</i>');
    if ($var instanceof Doctrine_Record || $var instanceof Doctrine_Collection) {
        $varname = get_class($var);
        $var = $var->toArray();
    }
    switch (gettype($var)) {
        case 'array':
            $results = '<b>' . (isset($varname) ? "{$varname} Object" : 'Array') . ' (' . count($var) . ')</b>';
            foreach ($var as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
                $depth--;
            }
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
            foreach ($object_vars as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results = 'true';
            } elseif (false === $var) {
                $results = 'false';
            } elseif (null === $var) {
                $results = 'null';
            } else {
                $results = htmlspecialchars((string) $var);
            }
            $results = '<i>' . $results . '</i>';
            break;
        case 'integer':
        case 'float':
            $results = htmlspecialchars((string) $var);
            break;
        case 'string':
            $results = strtr($var, $_replace);
            if (strlen($var) > $length) {
                $results = substr($var, 0, $length - 3) . '...';
            }
            $results = htmlspecialchars('"' . $results . '"');
            break;
        case 'unknown type':
        default:
            $results = strtr((string) $var, $_replace);
            if (strlen($results) > $length) {
                $results = substr($results, 0, $length - 3) . '...';
            }
            $results = htmlspecialchars($results);
    }
    return $results;
}
开发者ID:Silwereth,项目名称:core,代码行数:69,代码来源:modifier.zdebug_print_var.php

示例5: smarty_modifier_debug_print_var

/**
 * Smarty debug_print_var modifier plugin
 *
 * Gallery modification: Filter all (hashed) passwords in smarty's debug output.
 *
 * 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)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array|object
 * @param integer
 * @param integer
 * @param string
 * @return string
 */
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40, $parentKey = '')
{
    $_replace = array("\n" => '<i>\\n</i>', "\r" => '<i>\\r</i>', "\t" => '<i>\\t</i>');
    if (!is_array($var) && !is_object($var) && stristr($parentKey, 'password') !== false) {
        $var = '[Not shown in debug output]';
    }
    switch (gettype($var)) {
        case 'array':
            $results = '<b>Array (' . count($var) . ')</b>';
            foreach ($var as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length, $curr_key);
                $depth--;
            }
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
            foreach ($object_vars as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length, $curr_key);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results = 'true';
            } elseif (false === $var) {
                $results = 'false';
            } elseif (null === $var) {
                $results = 'null';
            } else {
                $results = htmlspecialchars((string) $var);
            }
            $results = '<i>' . $results . '</i>';
            break;
        case 'integer':
        case 'float':
            $results = htmlspecialchars((string) $var);
            break;
        case 'string':
            $results = strtr($var, $_replace);
            if (strlen($var) > $length) {
                $results = substr($var, 0, $length - 3) . '...';
            }
            $results = htmlspecialchars('"' . $results . '"');
            break;
        case 'unknown type':
        default:
            $results = strtr((string) $var, $_replace);
            if (strlen($results) > $length) {
                $results = substr($results, 0, $length - 3) . '...';
            }
            $results = htmlspecialchars($results);
    }
    return $results;
}
开发者ID:justinlyon,项目名称:scc,代码行数:74,代码来源:modifier.debug_print_var.php

示例6: smarty_modifier_debug_print_var

/**
 * 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)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array|object
 * @param integer
 * @param integer
 * @return string
 */
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
    $_replace = array(NEW_LINE => '<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 .= HTML_BR . str_repeat(HTML_NBSP, $depth * 2) . HTML_B_START . strtr($curr_key, $_replace) . "</b> =&gt; {$return}";
        }
    } else {
        if (is_object($var)) {
            $object_vars = get_object_vars($var);
            $results = HTML_B_START . 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 .= HTML_BR . str_repeat(HTML_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;
}
开发者ID:BackupTheBerlios,项目名称:ol-commerce-svn,代码行数:51,代码来源:modifier.debug_print_var.php

示例7: content_52a091bf149fe7_42771250

    function content_52a091bf149fe7_42771250($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_debug_print_var')) {
            include 'C:\\inetpub\\wwwroot\\idrc\\admin\\config\\Smarty\\libs\\plugins\\modifier.debug_print_var.php';
        }
        $_smarty_tpl->_capture_stack[0][] = array('_smarty_debug', 'debug_output', null);
        ob_start();
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title>Smarty Debug Console</title>
<style type="text/css">

body, h1, h2, td, th, p {
    font-family: sans-serif;
    font-weight: normal;
    font-size: 0.9em;
    margin: 1px;
    padding: 0;
}

h1 {
    margin: 0;
    text-align: left;
    padding: 2px;
    background-color: #f0c040;
    color:  black;
    font-weight: bold;
    font-size: 1.2em;
 }

h2 {
    background-color: #9B410E;
    color: white;
    text-align: left;
    font-weight: bold;
    padding: 2px;
    border-top: 1px solid black;
}

body {
    background: black; 
}

p, table, div {
    background: #f0ead8;
} 

p {
    margin: 0;
    font-style: italic;
    text-align: center;
}

table {
    width: 100%;
}

th, td {
    font-family: monospace;
    vertical-align: top;
    text-align: left;
    width: 50%;
}

td {
    color: green;
}

.odd {
    background-color: #eeeeee;
}

.even {
    background-color: #fafafa;
}

.exectime {
    font-size: 0.8em;
    font-style: italic;
}

#table_assigned_vars th {
    color: blue;
}

#table_config_vars th {
    color: maroon;
}

</style>
</head>
<body>

<h1>Smarty Debug Console  -  <?php 
        if (isset($_smarty_tpl->tpl_vars['template_name']->value)) {
            echo smarty_modifier_debug_print_var($_smarty_tpl->tpl_vars['template_name']->value);
        } else {
            ?>
//.........这里部分代码省略.........
开发者ID:jsan4christ,项目名称:idrc-uganda-site,代码行数:101,代码来源:78605e9bb539c38842d0b881b1b2c5959d9863c0.file.debug.tpl.php

示例8: is_array

            $this->_sections['config_vars']['last'] = $this->_sections['config_vars']['iteration'] == $this->_sections['config_vars']['total'];
            ?>
		_smarty_console.document.write("<tr bgcolor=<?php 
            if (!(1 & $this->_sections['config_vars']['index'])) {
                ?>
#eeeeee<?php 
            } else {
                ?>
#fafafa<?php 
            }
            ?>
><td valign=top><tt><font color=maroon>{#<?php 
            echo $this->_tpl_vars['_debug_config_keys'][$this->_sections['config_vars']['index']];
            ?>
#}</font></tt></td><td><tt><font color=green><?php 
            echo is_array($_tmp = smarty_modifier_debug_print_var($this->_tpl_vars['_debug_config_vals'][$this->_sections['config_vars']['index']])) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript');
            ?>
</font></tt></td></tr>");
	<?php 
        }
    } else {
        ?>
		_smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>");	
	<?php 
    }
    ?>
	_smarty_console.document.write("</table>");
	_smarty_console.document.write("</BODY></HTML>");
	_smarty_console.document.close();
</SCRIPT>
<?php 
开发者ID:BackupTheBerlios,项目名称:lesen-svn,代码行数:31,代码来源:%%18^181^181DF2FF%%debug.tpl.php

示例9: smarty_modifier_escape

       <tr class="<?php 
        if ($_smarty_tpl->getVariable('vars')->iteration % 2 == 0) {
            ?>
odd<?php 
        } else {
            ?>
even<?php 
        }
        ?>
">   
       <th><?php 
        echo smarty_modifier_escape($_smarty_tpl->getVariable('vars')->key, 'html');
        ?>
</th>
       <td><?php 
        echo smarty_modifier_debug_print_var($_smarty_tpl->getVariable('vars')->value);
        ?>
</td></tr>
    <?php 
    }
}
?>

</table>
</body>
</html>
<?php 
$_smarty_tpl->assign('debug_output', ob_get_contents());
$_smarty_tpl->smarty->_smarty_vars['capture']['default'] = ob_get_clean();
?>
<script type="text/javascript">
开发者ID:ViniciusFelix,项目名称:ProjetoPadrao,代码行数:31,代码来源:1e34f9f143d06678d63ce583d07357acd576482b.file.debug.tpl.php

示例10: smarty_function_cycle

        $this->_sections['config_vars']['rownum'] = $this->_sections['config_vars']['iteration'];
        $this->_sections['config_vars']['index_prev'] = $this->_sections['config_vars']['index'] - $this->_sections['config_vars']['step'];
        $this->_sections['config_vars']['index_next'] = $this->_sections['config_vars']['index'] + $this->_sections['config_vars']['step'];
        $this->_sections['config_vars']['first'] = $this->_sections['config_vars']['iteration'] == 1;
        $this->_sections['config_vars']['last'] = $this->_sections['config_vars']['iteration'] == $this->_sections['config_vars']['total'];
        ?>
        <tr class="<?php 
        echo smarty_function_cycle(array('values' => "odd,even"), $this);
        ?>
">
            <th>{#<?php 
        echo is_array($_tmp = $this->_tpl_vars['_debug_config_keys'][$this->_sections['config_vars']['index']]) ? $this->_run_mod_handler('escape', true, $_tmp, 'html') : smarty_modifier_escape($_tmp, 'html');
        ?>
#}</th>
            <td><?php 
        echo smarty_modifier_debug_print_var($this->_tpl_vars['_debug_config_vals'][$this->_sections['config_vars']['index']]);
        ?>
</td></tr>
    <?php 
    }
} else {
    ?>
        <tr><td><p>no config vars assigned</p></td></tr>
    <?php 
}
?>
</table>
</body>
</html>
<?php 
$this->_smarty_vars['capture']['default'] = ob_get_contents();
开发者ID:reZo,项目名称:Tiger,代码行数:31,代码来源:%%AE^AE3^AE37346B%%debug.tpl.php

示例11: smarty_modifier_print_array

/**
 * 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)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array|object
 * @param integer
 * @param integer
 * @return string
 */
function smarty_modifier_print_array($var, $depth = 0, $length = 40)
{
    require_once 'modifier.debug_print_var.php';
    switch (gettype($var)) {
        case 'array':
            $results = "array(\n";
            foreach ($var as $curr_key => $curr_val) {
                $depth++;
                $results .= str_repeat('  ', $depth + 1) . "'" . $curr_key . "' => " . smarty_modifier_print_array($curr_val, $depth, $length) . ",\n";
                $depth--;
            }
            $results .= str_repeat('  ', $depth + 1) . ")";
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = get_class($var) . ' Object (' . count($object_vars) . ')';
            foreach ($object_vars as $curr_key => $curr_val) {
                $depth++;
                $results .= str_repeat('', $depth + 1) . '->' . $curr_key . ' = ' . smarty_modifier_debug_print_var($curr_val, $depth, $length);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results .= 'TRUE';
            } elseif (false === $var) {
                $results .= 'FALSE';
            } elseif (null === $var) {
                $results .= '';
            } else {
                $results = $var;
            }
            $results = $results;
            break;
        case 'integer':
        case 'float':
            $results = $var;
            break;
        case 'string':
            if (strlen($var) > $length) {
                $results = substr($var, 0, $length - 3) . '...';
            }
            $results = "'" . $var . "'";
            break;
        case 'unknown type':
        default:
            if (strlen($results) > $length) {
                $results = substr($results, 0, $length - 3) . '...';
            }
            $results = "'" . $var . "'";
    }
    if (empty($var)) {
        if (is_array($var)) {
            $results = "array()";
        } elseif ($var === '0' || $var === 0) {
            $results = 0;
        } else {
            $results = "''";
        }
    }
    return $results;
}
开发者ID:kidaa30,项目名称:yes,代码行数:78,代码来源:modifier.print_array.php

示例12: smarty

 public function smarty($file, $vars = array(), $testing = false)
 {
     global $bp, $ci, $page;
     $debug = !$testing && is_admin(2) && $ci->session->enable_profiler ? true : false;
     if ($debug) {
         $memory = memory_get_usage();
         $start = microtime(true);
         $time = $start - $ci->benchmark->marker['total_execution_time_start'];
     }
     static $smarty = null;
     if (is_null($smarty)) {
         $functions = array('preg_replace', 'number_format', 'implode', 'explode', 'array_keys', 'array_values', 'array_flip', 'array_reverse', 'array_shift', 'array_unshift', 'array_pop', 'array_push', 'array_combine', 'array_merge');
         if ($testing || $this->controller == '#post#') {
             $functions = array_merge(array('is_user', 'is_admin', 'in_group'), $functions);
         }
         $smarty = $page->plugin('Smarty', 'class');
         $smarty->setCompileDir($smarty->getCompileDir() . $page->get('domain'));
         $smarty->assign(array('bp' => new BootstrapClone($bp), 'page' => new PageClone($page, $this->controller == '#post#' ? 'post' : 'blog')));
         $security = new Smarty_Security($smarty);
         $security->php_functions = array_merge(array('isset', 'empty', 'count', 'in_array', 'is_array', 'time', 'nl2br'), $functions);
         // Smarty defaults
         $security->allow_super_globals = false;
         $security->allow_constants = false;
         $smarty->enableSecurity($security);
     }
     unset($vars['bp'], $vars['page']);
     $vars['blog'] = $this->blog;
     $smarty->assign($vars);
     $smarty->setTemplateDir(dirname($file) . '/');
     try {
         $html = $smarty->fetch(basename($file));
         if ($debug) {
             $smarty->loadPlugin('Smarty_Internal_Debug');
             $debug = Smarty_Internal_Debug::display_debug($smarty);
             if (!is_callable('smarty_modifier_debug_print_var')) {
                 include SMARTY_PLUGINS_DIR . 'modifier.debug_print_var.php';
             }
             foreach ($debug['vars'] as $key => $obj) {
                 if (strtolower($obj->scope) == 'global') {
                     unset($debug['vars'][$key]);
                 } else {
                     $debug['vars'][$key] = smarty_modifier_debug_print_var($obj->value, 0, 80);
                 }
             }
             $page->save('Smarty', array('memory' => $memory, 'file' => $file, 'start' => $time, 'time' => microtime(true) - $start, 'vars' => $debug['vars']));
         }
         if (!empty($vars)) {
             $smarty->clearAssign(array_keys($vars));
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
         if ($testing) {
             return htmlspecialchars_decode($error);
         }
         $html = '<p>' . $error . '</p>';
     }
     return $testing ? true : $html;
 }
开发者ID:kikoseijo,项目名称:BootPress,代码行数:58,代码来源:Blog.php

示例13: smarty_modifier_debug_print_var

/**
 * Smarty debug_print_var modifier plugin
 *
 * Type:     modifier<br>
 * Name:     debug_print_var<br>
 * Purpose:  formats variable contents for display in the console
 *
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param array|object $var     variable to be formatted
 * @param integer      $depth   maximum recursion depth if $var is an array
 * @param integer      $length  maximum string length if $var is a string
 * @return string
 */
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40, &$history = array())
{
    foreach ($history as $h) {
        if ((is_object($var) || is_array($var)) && $var === $h) {
            return "RECURSION";
        }
    }
    $history[] =& $var;
    $_replace = array("\n" => '<i>\\n</i>', "\r" => '<i>\\r</i>', "\t" => '<i>\\t</i>');
    switch (gettype($var)) {
        case 'array':
            $results = '<b>Array (' . count($var) . ')</b>';
            foreach ($var as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length, $history);
                $depth--;
            }
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
            foreach ($object_vars as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length, $history);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results = 'true';
            } elseif (false === $var) {
                $results = 'false';
            } elseif (null === $var) {
                $results = 'null';
            } else {
                $results = htmlspecialchars((string) $var);
            }
            $results = '<i>' . $results . '</i>';
            break;
        case 'integer':
        case 'float':
            $results = htmlspecialchars((string) $var);
            break;
        case 'string':
            $results = strtr($var, $_replace);
            if (Smarty::$_MBSTRING) {
                if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
                    $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
                }
            } else {
                if (isset($var[$length])) {
                    $results = substr($var, 0, $length - 3) . '...';
                }
            }
            $results = htmlspecialchars('"' . $results . '"');
            break;
        case 'unknown type':
        default:
            $results = strtr((string) $var, $_replace);
            if (Smarty::$_MBSTRING) {
                if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
                    $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
                }
            } else {
                if (strlen($results) > $length) {
                    $results = substr($results, 0, $length - 3) . '...';
                }
            }
            $results = htmlspecialchars($results);
    }
    return $results;
}
开发者ID:OkayCMS,项目名称:Okay,代码行数:85,代码来源:modifier.debug_print_var.php

示例14: displayDebug


//.........这里部分代码省略.........
        $config_vars = $_config_vars;
        // echo 'assigned_vars<pre>'.print_r($assigned_vars['SCRIPT_NAME'], true).'</pre>';die;
        $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-smarty-debug">';
        $output .= '					<table>
											<tr>
												<th colspan="2">Smarty Debug Console  -  ' . (isset($template_name) && count($template_name) ? $template_name : 'Total Time ' . number_format($execution_time, 5, '.', '')) . '</th>
											</tr>
		';
        if (isset($template_name) && count($template_name)) {
            foreach ($template_name as $template) {
                $output .= '
											<tr>
												<td class="debugtoolbar-table-first"><font color=brown>' . $template['name'] . '</font></td>
												<td>
													<span style="font-size: 0.8em;font-style: italic;">
														' . number_format($template['compile_time'], 5, '.', '') . '
														' . number_format($template['render_time'], 5, '.', '') . '
														' . number_format($template['cache_time'], 5, '.', '') . '
													</span>
												</td>
											</tr>
				';
            }
        }
        $output .= '
											<tr>
												<td class="debugtoolbar-table-title" colspan="2"><strong>Assigned template variables</strong></td>
											</tr>
		';
        foreach ($assigned_vars as $key => $vars) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . $key . '</td>
												<td><pre>' . smarty_modifier_debug_print_var($vars) . '</pre></td>
											</tr>
			';
        }
        $output .= '
											<tr>
												<td class="debugtoolbar-table-title" colspan="2"><trong>Assigned config file variables (outer template scope)</strong></td>
											</tr>
		';
        foreach ($config_vars as $key => $vars) {
            $output .= '
											<tr>
												<td class="debugtoolbar-table-first">' . $key . '</td>
												<td><pre>' . smarty_modifier_debug_print_var($vars) . '</pre></td>
											</tr>
			';
        }
        $output .= '
										</table>
		';
        $output .= '				</div>';
        /* SMARTY DEBUG */
        /* ADMINER */
        if (isset($this->context->employee->id)) {
            $output .= '				<div class="debugtoolbar-tab-pane debugtoolbar-table debugtoolbar-adminer">';
            $output .= '					<table>
											<tr>
												<th>Adminer</th>
											</tr>
		';
            $output .= '
											<tr>
												<td colspan="2">
开发者ID:victorknust,项目名称:debugtoolbar,代码行数:67,代码来源:Controller.php

示例15: smarty_modifier_debug_print_var

/**
 * Smarty debug_print_var modifier plugin
 * Type:     modifier<br>
 * Name:     debug_print_var<br>
 * Purpose:  formats variable contents for display in the console
 *
 * @author Monte Ohrt <monte at ohrt dot com>
 *
 * @param array|object $var     variable to be formatted
 * @param int          $max     maximum recursion depth if $var is an array or object
 * @param int          $length  maximum string length if $var is a string
 * @param int          $depth   actual recursion depth
 * @param array        $objects processed objects in actual depth to prevent recursive object processing
 *
 * @return string
 */
function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array())
{
    $_replace = array("\n" => '\\n', "\r" => '\\r', "\t" => '\\t');
    switch (gettype($var)) {
        case 'array':
            $results = '<b>Array (' . count($var) . ')</b>';
            if ($depth == $max) {
                break;
            }
            foreach ($var as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
                $depth--;
            }
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
            if (in_array($var, $objects)) {
                $results .= ' called recursive';
                break;
            }
            if ($depth == $max) {
                break;
            }
            $objects[] = $var;
            foreach ($object_vars as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results = 'true';
            } elseif (false === $var) {
                $results = 'false';
            } elseif (null === $var) {
                $results = 'null';
            } else {
                $results = htmlspecialchars((string) $var);
            }
            $results = '<i>' . $results . '</i>';
            break;
        case 'integer':
        case 'float':
            $results = htmlspecialchars((string) $var);
            break;
        case 'string':
            $results = strtr($var, $_replace);
            if (Smarty::$_MBSTRING) {
                if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
                    $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
                }
            } else {
                if (isset($var[$length])) {
                    $results = substr($var, 0, $length - 3) . '...';
                }
            }
            $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
            break;
        case 'unknown type':
        default:
            $results = strtr((string) $var, $_replace);
            if (Smarty::$_MBSTRING) {
                if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
                    $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
                }
            } else {
                if (strlen($results) > $length) {
                    $results = substr($results, 0, $length - 3) . '...';
                }
            }
            $results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
    }
    return $results;
}
开发者ID:LEXXiY,项目名称:devschool,代码行数:93,代码来源:modifier.debug_print_var.php


注:本文中的smarty_modifier_debug_print_var函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。