Ignore:
Timestamp:
Jul 27, 2015 7:56:08 AM (9 years ago)
Author:
anonymous
Message:

Improved module maker validation output. Allow disabling cache at run time for ACL. Added ACL getList() method. Improved ACL CLI listing. Fixed app boomerang array initialization. Now retaining identical boomerang URLs if the key is different. Added a maximum boomerang time. Added a way to disable cache per request through a query string. Added validator isDecimal() method. Added disableSelectOptions() HTML method. Added getGravatarURL() method. Change how navigation page array is managed. Updated navigation currentPage() method to test an array of URLs.

File:
1 edited

Legend:

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

    r523 r534  
    4848        'path_delimiter' => ' / ',
    4949        'last_crumb_format' => '%s',
     50        'current_page_url' => null, // This should be set at runtime using, e.g., $_SERVER['REQUEST_URI']
    5051    );
    5152    public $pages = array();
     
    5758    {
    5859        $app =& App::getInstance();
     60
     61        // Define current_page_url here because _SERVER, not a static scalar, cannot be defined in the defaults above.
     62        // Using PHP_SELF for legacy compatability, but it might make sense to override this with REQUEST_URI.
     63        // This could be overwritten by passed params.
     64        $this->_params['current_page_url'] = $_SERVER['PHP_SELF'];
    5965
    6066        if (isset($params) && is_array($params)) {
     
    7278     * @access  public
    7379     * @param   string  $title      The title of the page.
    74      * @param   string  $url        The URL to the page. Set to null to use PHP_SELF.
     80     * @param   string  $url        The URL to the page. Set to null to use REQUEST_URI.
    7581     * @param   array   $vars       Additional page variables.
    7682     */
     
    8187            'head_title' => $title,
    8288            'body_title' => $title,
    83             'url' => is_null($url) ? $_SERVER['PHP_SELF'] : $url,
     89            'url' => is_null($url) ? $this->_params['current_page_url'] : $url,
    8490        );
    85         $this->pages[] = array_merge($page, $vars);
     91        // An "unformed page element" has settings applied (via ->set()) but no page added (via ->add()).
     92        if (empty($this->pages) || isset(end($this->pages)['title'])) {
     93            // There are no unformed page elements; add a whole new page.
     94            $this->pages[] = array_merge($page, $vars);
     95        } else {
     96            // Append the new page to the unformed page element.
     97            $curr_page =& $this->pages[key($this->pages)];
     98            $curr_page = array_merge($curr_page, $page, $vars);
     99        }
    86100    }
    87101
     
    143157    {
    144158        // Set params of current page.
    145         $curr_page =& $this->pages[sizeof($this->pages) - 1];
     159        if (empty($this->pages)) {
     160            // If we're setting a value on an empty pages array, we need to add one "unformed" element first.
     161            $this->pages[] = array();
     162        }
     163        end($this->pages);
     164        $curr_page =& $this->pages[key($this->pages)];
    146165        $curr_page[$key] = $val;
    147166    }
     
    157176    public function get($key, $default='')
    158177    {
    159         $curr_page =& $this->pages[sizeof($this->pages) - 1];
     178        end($this->pages);
     179        $curr_page =& $this->pages[key($this->pages)];
    160180
    161181        switch ($key) {
     
    375395     * @access  public
    376396     *
    377      * @param   string  $test_uri       A URI to test against the current page.
     397     * @param   mixed   $test_uri       A URI, or an array of URIs, to test against the current page.
    378398     * @param   mixed   $true_return    The value to return if the current page matches the test URI.
    379399     * @param   mixed   $false_return   The value to return if the current page does not match the test URI.
     
    387407    {
    388408        $app =& App::getInstance();
     409
     410        // If given an array, test each URI recursively returning TRUE on a first match, or FALSE if none match.
     411        if (is_array($test_uri)) {
     412            foreach ($test_uri as $uri) {
     413                if ($this->currentPage($uri, $true_return, $false_return, $include_query)) {
     414                    return true;
     415                }
     416            }
     417            return false;
     418        }
    389419
    390420        $actual_uri = $include_query ? $_SERVER['REQUEST_URI'] : strtok($_SERVER['REQUEST_URI'], '?');
Note: See TracChangeset for help on using the changeset viewer.