⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    *     * @access private    * @param mixed   Node id    * @param string  Node 'url' attribute    * @param int     Level in the tree    * @return int    Node type (one of HTML_MENU_ENTRY_* constants)    */    function _findNodeType($nodeId, &$nodeUrl, $level)    {        $nodeUrl = $this->_urlPrefix . ((empty($this->_urlPrefix) || '/' != $nodeUrl{0})? $nodeUrl: substr($nodeUrl, 1));        if ($this->_currentUrl == $nodeUrl) {            // menu item that fits to this url - 'active' menu item            return HTML_MENU_ENTRY_ACTIVE;        } elseif (isset($this->_path[$level]) && $this->_path[$level] == $nodeId) {            // processed menu item is part of the path to the active menu item            return 'urhere' == $this->_menuType? HTML_MENU_ENTRY_BREADCRUMB: HTML_MENU_ENTRY_ACTIVEPATH;        } else {            // not selected, not a part of the path to the active menu item            return HTML_MENU_ENTRY_INACTIVE;        }    }   /**    * Renders the tree menu ('tree' and 'sitemap')    *     * @access private    * @param  array     (sub)menu being rendered    * @param  int       current depth in the tree structure    */    function _renderTree($menu, $level = 0)    {        foreach ($menu as $node_id => $node) {            $type = $this->_findNodeType($node_id, $node['url'], $level);            $this->_renderer->renderEntry($node, $level, $type);            $this->_renderer->finishRow($level);            // follow the subtree if the active menu item is in it or if we want the full menu            if (('sitemap' == $this->_menuType || HTML_MENU_ENTRY_INACTIVE != $type) && isset($node['sub'])) {                $this->_renderTree($node['sub'], $level + 1);            }        }        $this->_renderer->finishLevel($level);        if (0 == $level) {            $this->_renderer->finishMenu($level);        }    }   /**    * Renders the 'urhere' menu    *     * @access private    * @param  array     (sub)menu being rendered    * @param  int       current depth in the tree structure    */    function _renderURHere($menu, $level = 0)    {        foreach ($menu as $node_id => $node) {            $type = $this->_findNodeType($node_id, $node['url'], $level);            if (HTML_MENU_ENTRY_INACTIVE != $type) {                $this->_renderer->renderEntry($node, $level, $type);                // follow the subtree if the active menu item is in it                if (isset($node['sub'])) {                    $this->_renderURHere($node['sub'], $level + 1);                }            }        }        if (0 == $level) {            $this->_renderer->finishRow($level);            $this->_renderer->finishMenu($level);        }    }   /**    * Renders the 'rows' menu    *     * @access private    * @param  array     (sub)menu being rendered    * @param  int       current depth in the tree structure    */    function _renderRows($menu, $level = 0)    {        $submenu = false;        foreach ($menu as $node_id => $node) {            $type = $this->_findNodeType($node_id, $node['url'], $level);            $this->_renderer->renderEntry($node, $level, $type);            // follow the subtree if the active menu item is in it            if (HTML_MENU_ENTRY_INACTIVE != $type && isset($node['sub'])) {                $submenu = $node['sub'];            }        }        // every (sub)menu has its own table        $this->_renderer->finishRow($level);        $this->_renderer->finishMenu($level);        // go deeper if neccessary        if ($submenu) {            $this->_renderRows($submenu, $level + 1);        }    }   /**    * Renders the 'prevnext' menu    *     * @access private    * @param  array     (sub)menu being rendered    * @param  int       current depth in the tree structure    * @param  int       flag indicating whether to finish processing    *                   (0 - continue, 1 - this is "next" node, 2 - stop)    */    function _renderPrevNext($menu, $level = 0, $flagStop = 0)    {        static $last_node = array(), $up_node = array();        foreach ($menu as $node_id => $node) {            if (0 != $flagStop) {                // add this item to the menu and stop recursion - (next >>) node                if ($flagStop == 1) {                    $this->_renderer->renderEntry($node, $level, HTML_MENU_ENTRY_NEXT);                    $flagStop = 2;                }                break;            } else {                $type = $this->_findNodeType($node_id, $node['url'], $level);                if (HTML_MENU_ENTRY_ACTIVE == $type) {                    $flagStop = 1;                    // WARNING: if there's no previous take the first menu entry - you might not like this rule!                    if (0 == count($last_node)) {                        reset($this->_menu);                        list($node_id, $last_node) = each($this->_menu);                    }                    $this->_renderer->renderEntry($last_node, $level, HTML_MENU_ENTRY_PREVIOUS);                    // WARNING: if there's no up take the first menu entry - you might not like this rule!                    if (0 == count($up_node)) {                        reset($this->_menu);                        list($node_id, $up_node) = each($this->_menu);                    }                    $this->_renderer->renderEntry($up_node, $level, HTML_MENU_ENTRY_UPPER);                }            }            // remember the last (<< prev) node            $last_node = $node;            if (isset($node['sub'])) {                if (HTML_MENU_ENTRY_INACTIVE != $type) {                    $up_node = $node;                }                $flagStop = $this->_renderPrevNext($node['sub'], $level + 1, $flagStop);            }        }        if (0 == $level) {            $this->_renderer->finishRow($level);            $this->_renderer->finishMenu($level);        }        return $flagStop;    }   /**    * Returns the path of the current page in the menu 'tree'.    *    * @return   array    path to the selected menu item    * @see      _buildUrlMap(), $_urlMap    */    function getPath()     {        $this->_currentUrl = $this->getCurrentURL();        $this->_buildUrlMap($this->_menu, array());        // If there is no match for the current URL, try to come up with        // the best approximation by shortening the url        while ($this->_currentUrl && !isset($this->_urlMap[$this->_currentUrl])) {            $this->_currentUrl = substr($this->_currentUrl, 0, -1);        }        return isset($this->_urlMap[$this->_currentUrl])? $this->_urlMap[$this->_currentUrl]: array();    }   /**    * Builds the mappings from node url to the 'path' in the menu    *    * @access   private    * @param    array       (sub)menu being processed    * @param    array       path to the (sub)menu    * @return   boolean     true if the path to the current page was found, otherwise false.    * @see      getPath(), $_urlMap    */    function _buildUrlMap($menu, $path)     {        foreach ($menu as $nodeId => $node) {            $url = $this->_urlPrefix . ((empty($this->_urlPrefix) || '/' != $node['url']{0})? $node['url']: substr($node['url'], 1));            $this->_urlMap[$url] = $path;            if ($url == $this->_currentUrl) {                return true;            }            if (isset($node['sub']) &&                 $this->_buildUrlMap($node['sub'], array_merge($path, array($nodeId)))) {                return true;            }        }        return false;    }   /**    * Returns the URL of the currently selected page.    *    * The returned string is used for all test against the URL's    * in the menu structure hash.    *    * @access public    * @return string    */    function getCurrentURL()     {        if (!empty($this->_forcedUrl)) {            return $this->_forcedUrl;        } elseif (isset($_SERVER[$this->_urlEnvVar])) {            return $_SERVER[$this->_urlEnvVar];        } elseif (isset($GLOBALS[$this->_urlEnvVar])) {            return $GLOBALS[$this->_urlEnvVar];        } else {            return '';        }    }   /**    * Forces the given URL to be "current"    *    * @access public    * @param  string    Url to use    */    function forceCurrentUrl($url)    {        $this->_forcedUrl = $url;    }   /**    * Sets the prefix for the URLs in the menu    *     * @param  string    * @access public    */    function setUrlPrefix($prefix)    {        if (('' != $prefix) && ('/' != substr($prefix, -1))) {            $prefix .= '/';        }        $this->_urlPrefix = $prefix;    }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -