Esempio n. 1
0
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;
}
Esempio n. 2
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;
 }
Esempio n. 3
0
 public static function findByUri($uri, $all = false)
 {
     global $__CMS_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, '/');
         $page = self::findBySlug($page_slug, $parent, $all);
         if ($page instanceof Page) {
             // 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;
 }