コード例 #1
0
ファイル: UrlRule.php プロジェクト: bigbrush/yii2-cmf
 /**
  * Creates a URL according to the given route and parameters.
  * 
  * @param UrlManager $manager the URL manager
  * @param string $route the route. It should not have slashes at the beginning or the end.
  * @param array $params the parameters
  * @return string|boolean the created URL, or false if this rule cannot be used for creating this URL.
  */
 public function createUrl($manager, $route, $params)
 {
     if ($route === 'pages/page/show') {
         $category = Yii::$app->big->categoryManager->getItem($params['catid']);
         // a category must be selected when creating a page. The category could have been deleted though
         $menu = false;
         if ($category) {
             $route = Route::raw($category, Route::TYPE_CATEGORY);
             $menuManager = Yii::$app->big->menuManager;
             $menu = $menuManager->search('route', $route);
         }
         // check if a menu has been created for the page category
         // if so prepend the menu query to the created url
         // if not prepend the id of this url rule
         if ($menu) {
             $prepend = $menu->getQuery();
         } else {
             $prepend = $this->_id;
         }
         return $prepend . '/' . $params['alias'];
     } elseif ($route === 'pages/category/pages') {
         return $this->_categoryId . '/' . $params['catid'] . '/' . $params['alias'];
     }
     return false;
 }
コード例 #2
0
ファイル: PageFinder.php プロジェクト: bigbrush/yii2-cmf
 /**
  * Registers page content when big performs a search.
  * See [[bigbrush\big\core\Big::search()]] for more information about the search process.
  *
  * @param bigbrush\big\core\SearchEvent $event the event being triggered
  */
 public static function onSearch($event)
 {
     $query = Page::find()->select(['id', 'title', 'category_id', 'alias', 'intro_content', 'created_at'])->orderBy('title')->asArray();
     // adjust query if $event->value is not empty. Then a search for a specific value is being made.
     if (!empty($event->value)) {
         $query->orWhere(['like', 'title', $event->value]);
         $query->orWhere(['like', 'content', $event->value]);
     }
     $items = $query->all();
     foreach ($items as $item) {
         $event->addItem(['title' => $item['title'], 'route' => Route::page($item), 'text' => $item['intro_content'], 'date' => $item['created_at'], 'section' => Yii::t('cms', 'Pages')]);
     }
     // pages categories
     foreach (Yii::$app->big->categoryManager->getItems('pages') as $item) {
         // $event->value is a value being searched for. If set then only include the category when its title matches
         // the search string
         if (!empty($event->value) && strpos($item->title, $event->value) === false) {
             continue;
         }
         // match found so add it in the $event
         $event->addItem(['title' => str_repeat('- ', $item->depth - 1) . $item->title, 'route' => Route::category($item), 'text' => $item->content, 'date' => $item->created_at, 'section' => Yii::t('cms', 'Pages categories')]);
     }
 }
コード例 #3
0
ファイル: edit.php プロジェクト: bigbrush/yii2-cmf
$title = $model->id ? Yii::t('cms', 'Edit {0}', $type) : Yii::t('cms', 'Create {0}', $type);
$this->title = $title;
if (!$model->getIsNewRecord()) {
    $title .= ' <span class="small">[ ' . $model->title . ' ]</span>';
}
$toolbar = Yii::$app->toolbar;
?>

<?php 
$form = ActiveForm::begin();
?>
    
    <?php 
$toolbar->save()->saveStay()->back();
if (!$model->getIsNewRecord()) {
    $url = Yii::$app->getUrlManager()->createUrlFrontend(Route::category($model));
    $toolbar->addButton(Html::a($toolbar->createText('eye', Yii::t('cms', 'Go to category')), $url, $toolbar->createButtonOptions(['target' => '_blank'])));
}
?>

    <h1><?php 
echo $title;
?>
</h1>
    
    <div class="row">
        <div class="col-md-12">
            <?php 
echo Tabs::widget(['items' => [['label' => Yii::t('cms', 'Category'), 'content' => $this->render('_tab_category', ['form' => $form, 'model' => $model, 'parents' => $parents, 'templates' => $templates])], ['label' => Yii::t('cms', 'Publishing'), 'content' => $this->render('_tab_publishing', ['form' => $form, 'model' => $model])], ['label' => Yii::t('cms', 'Images'), 'content' => $this->render('_tab_images', ['form' => $form, 'model' => $model])], ['label' => Yii::t('cms', 'Seo'), 'content' => $this->render('_tab_seo', ['form' => $form, 'model' => $model])], ['label' => Yii::t('cms', 'Info'), 'content' => $this->render('_tab_info', ['form' => $form, 'model' => $model])]]]);
?>
        </div>
コード例 #4
0
ファイル: index.php プロジェクト: bigbrush/yii2-cmf
if ($block->showTitle) {
    ?>
    <h3><?php 
    echo $block->title;
    ?>
</h3>
    <?php 
}
?>

    <?php 
foreach ($pages as $page) {
    ?>
        <div class="page-list-item">
            <?php 
    echo Html::a($page['title'], Route::page($page, '/'));
    ?>
            
            <?php 
    if (!empty($block->model->author_editor)) {
        ?>
            <div class="page-author">
                
                <?php 
        if (!empty($block->model->author_editor_text)) {
            ?>
                <span class="page-author-text">
                    <?php 
            echo $block->model->author_editor_text;
            ?>
                </span>
コード例 #5
0
ファイル: _list.php プロジェクト: bigbrush/yii2-cmf
<?php

/**
 * @link http://www.bigbrush-agency.com/
 * @copyright Copyright (c) 2015 Big Brush Agency ApS
 * @license http://www.bigbrush-agency.com/license/
 */
use yii\helpers\Html;
use bigbrush\cms\modules\pages\components\Route;
$list = [];
foreach ($pages as $page) {
    $list[] = Html::a($page['title'], Route::page($page, '/'));
}
echo Html::ul($list, ['encode' => false]);