Changeset 32 for trunk/lib/App.inc.php


Ignore:
Timestamp:
Dec 11, 2005 7:33:45 PM (18 years ago)
Author:
scdev
Message:
 
File:
1 edited

Legend:

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

    r31 r32  
    8181       
    8282        // For classes that require db tables, do we check that a table exists and create if missing?
    83         'db_create_tables' => null,
     83        'db_create_tables' => true,
    8484
    8585        // The level of error reporting. Don't set this to 0 to suppress messages, instead use display_errors to control display.
     
    366366            $this =& App::getInstance();
    367367        }
    368 
    369         if (!$this->running) {
     368       
     369        $message = trim($message);
     370
     371        if (!$this->running || '' == $message) {
    370372            return false;
    371373        }
     
    543545    /**
    544546     * Sets which query arguments will be carried persistently between requests.
    545      * Values in the _carry_queries array will be copied to URLs (via oHREF()) and
     547     * Values in the _carry_queries array will be copied to URLs (via App::url()) and
    546548     * to hidden input values (via printHiddenSession()).
    547549     *
     
    566568    /**
    567569     * Outputs a fully qualified URL with a query of all the used (ie: not empty)
    568      * keys and values, including optional queries. This allows simple printing of
    569      * links without needing to know which queries to add to it. If cookies are not
     570     * keys and values, including optional queries. This allows mindless retention
     571     * of query arguments across page requests. If cookies are not
    570572     * used, the session id will be propogated in the URL.
    571573     *
    572      * @param  string $url                 The initial url
    573      * @param  mixed  $carry_args          Additional url arguments to carry in the query,
    574      *                                     or FALSE to prevent carrying queries. Can be any of the following formats:
    575      *                                     -array('key1', key2', key3')  <-- to save these keys if in the form data.
    576      *                                     -array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
    577      *                                     -false  <-- To not carry any queries. If URL already has queries those will be retained.
     574     * @param  string $url              The initial url
     575     * @param  mixed  $carry_args       Additional url arguments to carry in the query,
     576     *                                  or FALSE to prevent carrying queries. Can be any of the following formats:
     577     *                                      array('key1', key2', key3')  <-- to save these keys if in the form data.
     578     *                                      array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
     579     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
    578580     *
    579581     * @param  mixed  $always_include_sid  Always add the session id, even if using_trans_sid = true. This is required when
     
    583585     * @return string url with attached queries and, if not using cookies, the session id
    584586     */
    585     function oHREF($url='', $carry_args=null, $always_include_sid=false)
     587    function url($url, $carry_args=null, $always_include_sid=false)
    586588    {
    587589        if (!isset($this) || !is_a($this, 'App')) {
     
    617619       
    618620        // Get the first delimiter that is needed in the url.
    619         $delim = preg_match('/\?/', $url) ? ini_get('arg_separator.output') : '?';
     621        $delim = strpos($url, '?') !== false ? ini_get('arg_separator.output') : '?';
     622
    620623       
    621624        $q = '';
     
    667670        }
    668671    }
     672
     673    /**
     674     * Returns a HTML-friendly URL processed with App::url and & replaced with &amp;
     675     *
     676     * @access  public
     677     * @param   string  $url    Input URL to parse.
     678     * @return  string          URL with App::url() and htmlentities() applied.
     679     * @author  Quinn Comendant <quinn@strangecode.com>
     680     * @since   09 Dec 2005 17:58:45
     681     */
     682    function oHREF($url, $carry_args=null, $always_include_sid=false)
     683    {
     684        if (!isset($this) || !is_a($this, 'App')) {
     685            $this =& App::getInstance();
     686        }
     687       
     688        $url = $this->url($url, $carry_args, $always_include_sid);
     689       
     690        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
     691        $url = preg_replace('/&(?![\w\d#]{1,10};)/', '&amp;', $url);
     692       
     693        return $url;
     694    }
    669695   
    670696    /**
     
    674700     * @param  mixed  $carry_args        Additional url arguments to carry in the query,
    675701     *                                   or FALSE to prevent carrying queries. Can be any of the following formats:
    676      *                                   -array('key1', key2', key3')  <-- to save these keys if in the form data.
    677      *                                   -array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
    678      *                                   -false  <-- To not carry any queries. If URL already has queries those will be retained.
     702     *                                      array('key1', key2', key3')  <-- to save these keys if in the form data.
     703     *                                      array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
     704     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
    679705     */
    680706    function printHiddenSession($carry_args=null)
    681     {   
     707    {
    682708        if (!isset($this) || !is_a($this, 'App')) {
    683709            $this =& App::getInstance();
     
    762788        }
    763789
    764         $url = $this->oHREF($url, $carry_args, $always_include_sid);
     790        $url = $this->url($url, $carry_args, $always_include_sid);
    765791       
    766792        header(sprintf('Location: %s', $url));
Note: See TracChangeset for help on using the changeset viewer.