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


Ignore:
Timestamp:
Nov 17, 2005 3:00:00 AM (19 years ago)
Author:
scdev
Message:

Tons of little updates and bugfixes. CSS updates to templates and core css files. File upload ability to module_maker. Remade Upload interface to use setParam/getParam.

File:
1 edited

Legend:

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

    r19 r20  
    2929    // Instance of database object.
    3030    var $db;
     31   
     32    // Array of query arguments will be carried persistently between requests.
     33    var $_carry_queries = array();
    3134
    3235    // Hash of global application parameters.
     
    4750        'ssl_enabled' => false,
    4851   
    49         // Character set for page output. Set in the Content-Type header and an HTML <meta content-type> tag.
     52        // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag.
    5053        'character_set' => 'utf-8',
    5154
     
    534537   
    535538    /**
     539     * Sets which query arguments will be carried persistently between requests.
     540     * Values in the _carry_queries array will be copied to URLs (via oHREF()) and
     541     * to hidden input values (via printHiddenSession()).
     542     *
     543     * @access  public
     544     * @param   string  $query_key  The key of the query argument to save. 
     545     * @author  Quinn Comendant <quinn@strangecode.com>
     546     * @since   14 Nov 2005 19:24:52
     547     */
     548    function carryQuery($query_key)
     549    {
     550        if (!isset($this) || !is_a($this, 'App')) {
     551            $this =& App::getInstance();
     552        }
     553       
     554        // If not already set, and there is a non-empty value provided in the request...
     555        if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
     556            // Copy the value of the specified query argument into the _carry_queries array.
     557            $this->_carry_queries[$query_key] = getFormData($query_key);
     558        }
     559    }
     560   
     561    /**
    536562     * Outputs a fully qualified URL with a query of all the used (ie: not empty)
    537563     * keys and values, including optional queries. This allows simple printing of
    538564     * links without needing to know which queries to add to it. If cookies are not
    539565     * used, the session id will be propogated in the URL.
    540      *
    541      * @global string $carry_queries       An array of keys to define which values to
    542      *                                     carry through from the POST or GET.
    543      *                                     $carry_queries = array('qry'); for example.
    544566     *
    545567     * @param  string $url                 The initial url
     
    565587            return false;
    566588        }
    567        
    568         static $_using_trans_sid;
    569         global $carry_queries;
    570    
    571         // Save the trans_sid setting.
    572         if (!isset($_using_trans_sid)) {
    573             $_using_trans_sid = ini_get('session.use_trans_sid');
    574         }
    575    
    576         // Initialize the carried queries.
    577         if (!isset($carry_queries['_carry_queries_init'])) {
    578             if (!is_array($carry_queries)) {
    579                 $carry_queries = array($carry_queries);
    580             }
    581             $tmp = $carry_queries;
    582             $carry_queries = array();
    583             foreach ($tmp as $key) {
    584                 if (!empty($key) && getFormData($key, false)) {
    585                     $carry_queries[$key] = getFormData($key);
    586                 }
    587             }
    588             $carry_queries['_carry_queries_init'] = true;
    589         }
    590    
    591         // Get any additional query arguments to add to the $carry_queries array.
    592         // If FALSE is a function argument, DO NOT carry the queries.
     589   
     590        // Get any provided query arguments to include in the final URL.
     591        // If FALSE is a provided here, DO NOT carry the queries.
    593592        $do_carry_queries = true;
    594593        $one_time_carry_queries = array();
     
    611610            }
    612611        }
    613    
     612       
    614613        // Get the first delimiter that is needed in the url.
    615614        $delim = preg_match('/\?/', $url) ? ini_get('arg_separator.output') : '?';
     
    617616        $q = '';
    618617        if ($do_carry_queries) {
    619             // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.
    620             $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));
     618            // Join the global _carry_queries and local one_time_carry_queries.
     619            $query_args = urlEncodeArray(array_merge($this->_carry_queries, $one_time_carry_queries));
    621620            foreach ($query_args as $key=>$val) {
    622621                // Check value is set and value does not already exist in the url.
     
    648647                    &&
    649648                    (
    650                         !$_using_trans_sid
     649                        !ini_get('session.use_trans_sid')
    651650                        || preg_match('!^(http|https)://!i', $url)
    652651                    )
     
    668667     * as hidden form elements for GET_VARS that might be in use.
    669668     *
    670      * @global string $carry_queries     An array of keys to define which values to
    671      *                                   carry through from the POST or GET.
    672      *                                   $carry_queries = array('qry'); for example
    673      *
    674669     * @param  mixed  $carry_args        Additional url arguments to carry in the query,
    675670     *                                   or FALSE to prevent carrying queries. Can be any of the following formats:
     
    679674     */
    680675    function printHiddenSession($carry_args=null)
    681     {
     676    {   
    682677        if (!isset($this) || !is_a($this, 'App')) {
    683678            $this =& App::getInstance();
     
    687682            return false;
    688683        }
    689        
    690         static $_using_trans_sid;
    691         global $carry_queries;
    692    
    693         // Save the trans_sid setting.
    694         if (!isset($_using_trans_sid)) {
    695             $_using_trans_sid = ini_get('session.use_trans_sid');
    696         }
    697        
    698         // Initialize the carried queries.
    699         if (!isset($carry_queries['_carry_queries_init'])) {
    700             if (!is_array($carry_queries)) {
    701                 $carry_queries = array($carry_queries);
    702             }
    703             $tmp = $carry_queries;
    704             $carry_queries = array();
    705             foreach ($tmp as $key) {
    706                 if (!empty($key) && getFormData($key, false)) {
    707                     $carry_queries[$key] = getFormData($key);
    708                 }
    709             }
    710             $carry_queries['_carry_queries_init'] = true;
    711         }
    712    
    713         // Get any additional query names to add to the $carry_queries array
    714         // that are found as function arguments.
    715         // If FALSE is a function argument, DO NOT carry the queries.
     684   
     685        // Get any provided query arguments to include in the final hidden form data.
     686        // If FALSE is a provided here, DO NOT carry the queries.
    716687        $do_carry_queries = true;
    717688        $one_time_carry_queries = array();
     
    737708        // For each existing POST value, we create a hidden input to carry it through a form.
    738709        if ($do_carry_queries) {
    739             // Join the perm and temp carry_queries and filter out the _carry_queries_init element for the final query args.
    740             $query_args = array_diff_assoc(urlEncodeArray(array_merge($carry_queries, $one_time_carry_queries)), array('_carry_queries_init' => true));
     710            // Join the global _carry_queries and local one_time_carry_queries.
     711            // urlencode is not used here, not for form data!
     712            $query_args = array_merge($this->_carry_queries, $one_time_carry_queries);
    741713            foreach ($query_args as $key=>$val) {
    742714                echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
     
    745717       
    746718        // Include the SID if cookies are disabled.
    747         if (!isset($_COOKIE[session_name()]) && !$_using_trans_sid) {
     719        if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) {
    748720            echo '<input type="hidden" name="' . session_name() . '" value="' . session_id() . '" />';
    749721        }
Note: See TracChangeset for help on using the changeset viewer.