function find_page_by_uri($uri) { global $__FROG_CONN__; $uri = trim($uri, '/'); $has_behavior = false; // adding the home root $urls = array_merge(array(''), explode_uri($uri)); $url = ''; $page = new stdClass(); $page->id = 0; $parent = false; foreach ($urls as $page_slug) { $url = ltrim($url . '/' . $page_slug, '/'); if ($page = find_page_by_slug($page_slug, $parent)) { // check for behavior if ($page->behavior_id != '') { // add a instance of the behavior with the name of the behavior $params = explode_uri(substr($uri, strlen($url))); $page->{$page->behavior_id} = Behavior::load($page->behavior_id, $page, $params); return $page; } } else { break; } $parent = $page; } // foreach return !$page && $has_behavior ? $parent : $page; }
private function _displayPage($slug) { if (!($this->page = find_page_by_slug($slug, $this->page))) { page_not_found(); } }