示例#1
0
 public static function get_breadcrumb(\Slim\Route $route)
 {
     $app = \Slim\Slim::getInstance();
     $env = $app->environment;
     $pattern = $app->router()->getCurrentRoute()->getPattern();
     if ($pattern == '/medias/:filename') {
         return;
     }
     $breadcrumbs = array();
     $breadcrumbs[] = array('id' => 1, 'text' => 'Home', 'url' => '/index.html');
     $page = PhybridPage::find($env['PATH_INFO'], $app);
     if ($page && $page->id != 'index') {
         $path_array = explode('/', $page->id);
         $findpath = '';
         $idx = 2;
         foreach ($path_array as $path) {
             $findpath .= (!empty($findpath) ? '/' : '') . $path;
             $tmp_page = PhybridPage::find($findpath, $app);
             if (!$tmp_page && $findpath . '/index' != $page->id) {
                 $tmp_page = PhybridPage::find($findpath . '/index', $app);
             }
             if (!$tmp_page) {
                 continue;
             }
             $breadcrumbs[] = array('id' => $idx, 'text' => $tmp_page->header['title'], 'url' => '/' . $tmp_page->id . '.html');
             $idx++;
         }
     } else {
         $params = explode('/', str_replace('/index.html', '', $env['PATH_INFO']));
         if ($pattern == '/:y/:m/:d/:t') {
             $id = str_replace('.html', '', $env['PATH_INFO']);
             $id = substr($id, 1, strlen($id) - 1);
             $post = PhybridPost::find($id, $app);
             $breadcrumbs[] = array('id' => 2, 'text' => $params[1] . '-' . $params[2], 'url' => '/' . $params[1] . '/' . $params[2] . '/index.html');
             if ($post) {
                 $breadcrumbs[] = array('id' => 3, 'text' => $post->header['title'], 'url' => '/' . $params[1] . '/' . $params[2] . '/' . $params[3] . '/' . $params[4]);
             } else {
                 $breadcrumbs[] = array('id' => 3, 'text' => $params[4], 'url' => '/' . $params[1] . '/' . $params[2] . '/' . $params[3] . '/' . $params[4]);
             }
         } else {
             if ($pattern == '/:y/:m/' || $pattern == '/:y/:m/index.html') {
                 $breadcrumbs[] = array('id' => 2, 'text' => $params[1] . '-' . $params[2], 'url' => '/' . $params[1] . '/' . $params[2] . '/index.html');
             } else {
                 if ($pattern == '/pages/:page_no/' || $pattern == '/pages/:page_no/index.html') {
                     $breadcrumbs[] = array('id' => 2, 'text' => 'Page ' . $params[2], 'url' => '/' . $params[1] . '/' . $params[2] . '/index.html');
                 }
             }
         }
     }
     if (count($breadcrumbs) == 1) {
         $breadcrumbs[0]['text'] = 'Home of ' . $env['SITE_NAME'];
     }
     $_SESSION['breadcrumbs'] = $breadcrumbs;
 }
示例#2
0
 static function get_ym($app, $y, $m)
 {
     $env = $app->environment;
     $posts = PhybridPost::find_by_month($y, $m, $app);
     if (!$posts) {
         $app->notFound();
         return;
     }
     $app->render('archive.phtml', array('env' => $env, 'header' => Phybrid::init_header('Archive of ' . $y . '-' . $m), 'posts' => $posts));
 }