Example #1
0
 public static function findByUri($uri, $class = __CLASS__)
 {
     //print "Page::findByUri($uri)";
     $uri = trim($uri, '/');
     $has_behavior = false;
     $urls = array_merge(array(''), explode_uri($uri));
     $url = '';
     $parent = new Page();
     $parent->id(0);
     foreach ($urls as $page_slug) {
         $url = ltrim($url . '/' . $page_slug, '/');
         if ($page = Page::findBySlugAndParentId($page_slug, $parent->id())) {
             if ($page->behaviorId()) {
                 $has_behavior = true;
                 // add a instance of the behavior with the name of the behavior
                 $params = explode_uri(substr($uri, strlen($url)));
                 print_r($params);
                 $page->behavior(Behavior::load($page->behaviorId(), $page, $params));
                 return $page;
             }
         } else {
             break;
         }
         $parent = $page;
     }
     return !$page && $has_behavior ? $parent : $page;
 }
Example #2
0
 private function _displayPage($slug)
 {
     if (!($this->page = Page::findBySlugAndParentId($slug, $this->page->id()))) {
         page_not_found();
     }
 }