function &_fetch(&$counter, $params) { $result =& parent::_fetch($counter, $params); $url_parser = new url_parser(PHP_SELF); foreach ($result as $key => $data) { if ($url_parser->compare($data['url'], $url_rest, $query_match)) { if ($url_rest >= 0) { $result[$key]['in_path'] = true; } } } return $result; }
function compare($url, &$rest, &$query_match) { $rest = null; $url_parser = new url_parser($url); $count1 = $this->count_path(); $count2 = $url_parser->count_path(); if (!$count1 || !$count2 || $this->protocol !== $url_parser->protocol || $this->host !== $url_parser->host) { return false; } $query_match = false; if (sizeof($this->_query_items) == sizeof($url_parser->_query_items)) { $query_match = true; foreach ($this->_query_items as $name => $value) { if (!isset($url_parser->query_items[$name]) || $url_parser->query_items[$name] != $this->_query_items[$name]) { $query_match = false; break; } } } for ($i = 0; $i < $count1 && $i < $count2; $i++) { if ($this->_path_elements[$i] != $url_parser->_path_elements[$i]) { return false; } } $rest = $count1 - $count2; return true; }
function &map_url_to_node($url = '', $recursive = false) { if ($this->_node_mapped_by_url) { return $this->_node_mapped_by_url; } $tree =& limb_tree::instance(); if ($url == '') { if (isset($_REQUEST['node_id'])) { $node =& $tree->get_node((int) $_REQUEST['node_id']); $this->_node_mapped_by_url =& $node; return $node; } else { $url = $_SERVER['PHP_SELF']; } } $url_parser = new url_parser(); $url_parser->parse($url); $node =& $tree->get_node_by_path($url_parser->path, '/', $recursive); $this->_node_mapped_by_url =& $node; return $node; }