/**
  * [buildBreadcrumbs description]
  * @param  [type] $file_url [description]
  * @return [type]           [description]
  */
 private function buildBreadcrumbs($file_url)
 {
     $cacheKey = 'breadcrumbs-' . $file_url;
     $breadcrumbs = $this->module->cache->get($cacheKey);
     if (!$breadcrumbs) {
         $page_parts = explode('/', $file_url);
         $repo = $this->getFlywheelRepo();
         $breadcrumbs = array();
         $i = 0;
         $out = '';
         $crumbs = array();
         foreach ($page_parts as $part) {
             $out = $out . '/' . $page_parts[$i];
             $crumbs[] = substr($out, 1);
             $i++;
         }
         if ($file_url != 'index') {
             Yii::$app->view->params['breadcrumbs'][] = array('label' => Page::title('index'), 'url' => Url::to(array('page/view', 'id' => 'index')));
         }
         foreach ($crumbs as $crumb) {
             $page = $repo->query()->where('url', '==', $crumb)->execute();
             $result = $page->first();
             if ($result != null) {
                 if ($result->url == $crumbs[count($page_parts) - 1]) {
                     Yii::$app->view->params['breadcrumbs'][] = array('label' => $result->title);
                 } else {
                     Yii::$app->view->params['breadcrumbs'][] = array('label' => $result->title, 'url' => Url::to(array('page/view', 'id' => $result->url)));
                 }
             } else {
                 Yii::$app->view->params['breadcrumbs'][] = array('label' => $crumb, 'class' => 'disabled');
             }
         }
         $this->module->cache->set($cacheKey, $breadcrumbs, $this->module->caching_time);
     }
     return $breadcrumbs;
 }
Esempio n. 2
0
File: main.php Progetto: jacmoe/pype
echo Yii::$app->homeUrl;
?>
"><img height="35px" width="80px" src="<?php 
echo $theme->getUrl('/pype.svg');
?>
" alt="Pype" /></a>
                </li>
            </ul>
        </div>
        <div class="top-bar-right">
            <?php 
// foreach(Page::pages('title') as $page) {
//     echo Html::a($page->title, Page::url($page->url)) . ' | ';
// }
echo Html::a('Home', Page::url('index')) . ' | ';
echo Html::a('Docs', Page::url('docs')) . ' | ';
echo Html::a('RSS', Url::to('/rss'));
// $pages = Page::pages();
// $items = array();
// foreach($pages as $page) {
//     $items[] = ['label' => $page->title, 'url' => Page::url($page->url)];
// }
// $module = Yii::$app->controller->module ? Yii::$app->controller->module->id : null;
// echo Nav::widget([
//     'options' => ['class' => 'menu'],
//     'items' => $items,
// ]);
?>
        </div>
    </div>
</header>
Esempio n. 3
0
 /**
  * [paginate description]
  * @return [type] [description]
  */
 public static function paginate($order_by = '', $where = null)
 {
     $offset = \Yii::$app->getRequest()->getQueryParam('page');
     if (isset($offset)) {
         return Page::pages($order_by, $where, 2, $offset - 1);
     } else {
         return Page::pages($order_by, $where, 2);
     }
 }