Changeset 464


Ignore:
Timestamp:
Feb 8, 2014 2:29:30 AM (10 years ago)
Author:
anonymous
Message:

Added jsDump function. Updated Navigation::currentPage so test url and curr url both have the option to exclude the query string.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Navigation.inc.php

    r461 r464  
    279279     * @return  mixed   The value set for $return, TRUE by default.
    280280     */
    281     function currentPage($test_uri, $true_return=true, $false_return=false, $include_query=true)
    282     {
    283         $actual_uri = $include_query ? $_SERVER['REQUEST_URI'] : strtok($_SERVER['REQUEST_URI'], '?');
     281    function currentPage($test_uri, $true_return=true, $false_return=false, $strip_query=false)
     282    {
     283        $actual_uri = $strip_query ? strtok($_SERVER['REQUEST_URI'], '?') : $_SERVER['REQUEST_URI'];
     284        $test_uri = $strip_query ? strtok($test_uri, '?') : $test_uri;
    284285        if (preg_match('/^' . preg_quote(urldecode($test_uri), '/') . '$/i', $actual_uri)) {
    285286            return $true_return;
  • trunk/lib/Utilities.inc.php

    r457 r464  
    3333 * @param  bool  $var_dump Use var_dump instead of print_r.
    3434 */
    35 function dump($var, $display=false, $var_dump=false)
     35function dump($var, $display=false, $var_dump=false, $file, $line)
    3636{
    3737    if (defined('_CLI')) {
     
    5252}
    5353
    54 /**
    55  * Return dump as variable.
    56  *
    57  * @param  mixed $var           Variable to dump.
    58  * @param  bool  $serialize     Remove line-endings. Useful for logging variables.
    59  * @return string Dump of var.
    60  */
     54/*
     55* Log a PHP variable to javascript console. Relies on getDump(), below.
     56*
     57* @access   public
     58* @param    mixed   $var      The variable to dump.
     59* @param    string  $prefix   A short note to print before the output to make identifying output easier.
     60* @param    string  $file     The value of __FILE__.
     61* @param    string  $line     The value of __LINE__.
     62* @return   null
     63* @author   Quinn Comendant <quinn@strangecode.com>
     64*/
     65function jsDump($var, $prefix='jsDump', $file='-', $line='-')
     66{
     67    if (!empty($var)) {
     68        ?>
     69        <script type="text/javascript" charset="utf-8">
     70        /* <![CDATA[ */
     71        window.console && console.log('<?php printf('%s: %s (on line %s of %s)', $prefix, str_replace("'", "\\'", getDump($var, true)), $line, $file); ?>');
     72        /* ]]> */
     73        </script>
     74        <?php
     75    }
     76}
     77
     78/*
     79* Return a string version of any variable, optionally serialized on one line.
     80*
     81* @access   public
     82* @param    mixed   $var        The variable to dump.
     83* @param    bool    $serialize  If true, remove line-endings. Useful for logging variables.
     84* @return   string              The dumped variable.
     85* @author   Quinn Comendant <quinn@strangecode.com>
     86*/
    6187function getDump($var, $serialize=false)
    6288{
Note: See TracChangeset for help on using the changeset viewer.