Changeset 389 for branches/1.1dev/lib


Ignore:
Timestamp:
Oct 6, 2011 3:08:37 AM (13 years ago)
Author:
anonymous
Message:

Added Nav::updatePage().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1dev/lib/Nav.inc.php

    r1 r389  
    5656        $this->pages[] = array(
    5757            'title'     => $title,
    58             'url'       => $url,
     58            'url'       => is_null($url) ? $_SERVER['PHP_SELF'] : $url,
    5959            'features'  => (isset($features) && is_array($features)) ? array_merge($this->default_features, $features) : $this->default_features
    6060        );
     61    }
     62
     63    /**
     64     * Update the title, url, and features for the current page (the last added).
     65     *
     66     * @access  public
     67     *
     68     * @param   string  $title      The title of the page.
     69     * @param   string  $url        The URL to the page. Leave blank (or null) if
     70     *                              page is to not be linked.
     71     * @param   array   $features   Set the features of the current page.
     72     */
     73    function updatePage($title, $url=null, $features=null)
     74    {
     75        if (isset($title)) {
     76            $this->pages[sizeof($this->pages)-1]['title'] = $title;           
     77        }
     78        if (isset($url)) {
     79            $this->pages[sizeof($this->pages)-1]['url'] = $url;           
     80        }
     81        if (isset($features) && is_array($features)) {
     82            $this->pages[sizeof($this->pages)-1]['features'] = array_merge($this->pages[sizeof($this->pages)-1]['features'], $features);           
     83        }
    6184    }
    6285   
     
    78101        }
    79102       
     103        if (!isset($this->pages[sizeof($this->pages)-1]['features']) || !isset($this->pages[$page_id]['features'])) {
     104            $app->logMsg(sprintf('Page not available to set feature: page_id = %s', $page_id), LOG_ERR, __FILE__, __LINE__);
     105            return false;
     106        }
     107       
    80108        if (isset($features) && is_array($features)) {
    81109            // Set features for specified page.
     110            $this->pages[$page_id]['features'] = array_merge($this->pages[$page_id]['features'], $features);
     111            // Store "current page" features.
    82112            $this->pages[sizeof($this->pages)-1]['features'] = array_merge($this->pages[sizeof($this->pages)-1]['features'], $features);
    83             // Store "current page" features.
    84             $this->pages[$page_id]['features'] = array_merge($this->pages[$page_id]['features'], $features);
    85113        }
    86114    }
Note: See TracChangeset for help on using the changeset viewer.