public function __construct(&$page, $params)
 {
     /* Execute this behaviour only if page equals the current page.          */
     if (url_match($page->getUri())) {
         if ($child = $page->children(array('limit' => 1))) {
             header('Location: ' . $child->url());
             die;
         }
     } else {
         // find called page
         foreach ($params as $slug) {
             $page = Page::findBySlug($slug, $page);
         }
         // if found
         if ($page instanceof Page) {
             // check for behavior
             if ($page->behavior_id != '') {
                 // add a instance of the behavior with the name of the behavior
                 $page->{$page->behavior_id} = Behavior::load($page->behavior_id, $page, $params);
             }
         } else {
             // not found
             page_not_found($_SERVER['REQUEST_URI']);
         }
     }
 }
Example #2
0
function snippet_menubar($page_submenu)
{
    $out = '';
    $count = count($page_submenu->children(array()));
    if ($count > 0 && $page_submenu->id != 1) {
        //$out .= '<ul>';
    }
    foreach ($page_submenu->children(array()) as $menuPage) {
        //if($menuPage->location=='top'){
        if ($menuPage->location == 'top' && $menuPage->level() == 1) {
            if ($menuPage->type == "link") {
                $out .= '<li ' . (url_match($menuPage->slug) ? ' class="active"' : '') . '>' . $menuPage->extlink($menuPage->title, $menuPage->newwindow == 1 ? ' target="_new"' : '', $menuPage->external_url) . snippet_menubar($menuPage) . '</li>';
            } else {
                $out .= '<li ' . (url_match($menuPage->slug) ? ' class="active"' : '') . '>' . $menuPage->link($menuPage->title, $menuPage->newwindow == 1 ? ' target="_new"' : '') . snippet_menubar($menuPage) . '</li>';
            }
        }
    }
    if ($count > 0 && $page_submenu->id != 1) {
        //$out .= '</ul>';
    }
    return $out;
}
Example #3
0
function find_route($method, $route, \Closure $callback)
{
    if ($_SERVER['REQUEST_METHOD'] === $method) {
        if (!empty($_SERVER['QUERY_STRING'])) {
            $url = substr($_SERVER['REQUEST_URI'], 0, -(strlen($_SERVER['QUERY_STRING']) + 1));
        } else {
            $url = $_SERVER['REQUEST_URI'];
        }
        $params = array();
        if (url_match($route, $url, $params)) {
            before($route);
            \call_user_func_array($callback, $params);
            exit;
        }
    }
}
Example #4
0
rss.xml" />
</head>
<body>
	<div id="page">
		<header>
			<div class="logo">
				<h1><a href="<?php 
echo URL_PUBLIC;
?>
">Howl theme</a></h1>
				<p class="headline">Wolfcms, content managed simplified</p>
			</div>
			<nav class="navigation">
				<ul>
					<li><a<?php 
echo url_match('/') ? ' class="current"' : '';
?>
 href="<?php 
echo URL_PUBLIC;
?>
">Home</a></li>
					<?php 
foreach ($this->find('/')->children() as $menu) {
    ?>
					<li><?php 
    echo $menu->link($menu->title, in_array($menu->slug, explode('/', $this->path())) ? ' class="current"' : null);
    ?>
</li>
					<?php 
}
?>