示例#1
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         //menu
         $id = isset($_GET['id']) ? $_GET['id'] : 0;
         $rootId = $id > 0 ? BlogCatalog::getRootCatalogId($id, BlogCatalog::find()->all()) : 0;
         $allCatalog = BlogCatalog::findAll(['parent_id' => 0]);
         foreach ($allCatalog as $catalog) {
             $item = ['label' => $catalog->title, 'active' => $catalog->id == $rootId];
             if ($catalog->redirect_url) {
                 // redirect to other site
                 $item['url'] = $catalog->redirect_url;
             } else {
                 $item['url'] = Yii::$app->getUrlManager()->createUrl(['/blog/default/catalog/', 'id' => $catalog->id, 'surname' => $catalog->surname]);
             }
             if (!empty($item)) {
                 array_push($this->mainMenu, $item);
             }
         }
         Yii::$app->params['mainMenu'] = $this->mainMenu;
         return true;
         // or false if needed
     } else {
         return false;
     }
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BlogCatalog::find();
     $query->orderBy(['sort_order' => SORT_ASC, 'create_time' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'is_nav' => $this->is_nav, 'sort_order' => $this->sort_order, 'page_size' => $this->page_size, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'template', $this->template])->andFilterWhere(['like', 'redirect_url', $this->redirect_url]);
     return $dataProvider;
 }
示例#3
0
use funson86\blog\models\BlogCatalog;
use kartik\markdown\MarkdownEditor;
use mihaildev\ckeditor\CKEditor;
/* @var $this yii\web\View */
/* @var $model backend\modules\blog\models\BlogPost */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="blog-post-form">

    <?php 
$form = ActiveForm::begin(['options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-5\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

    <?php 
echo $form->field($model, 'catalog_id')->dropDownList(ArrayHelper::map(BlogCatalog::get(0, BlogCatalog::find()->all()), 'id', 'str_label'));
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 128]);
?>

    <?php 
echo $form->field($model, 'brief')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'content')->widget(CKEditor::className(), ['editorOptions' => ['preset' => 'full', 'inline' => false]]);
?>

    <?php 
示例#4
0
 /**
  * Normalizes the user-entered tags.
  */
 public static function getArrayCatalog()
 {
     return ArrayHelper::map(BlogCatalog::find()->all(), 'id', 'title');
 }
 /**
  * Finds the BlogCatalog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BlogCatalog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BlogCatalog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
    ?>
</td>
            <td><?php 
    echo $item['str_label'];
    ?>
</td>
            <td><?php 
    echo $item['sort_order'];
    ?>
</td>
            <td><?php 
    echo $item['template'];
    ?>
</td>
            <td><?php 
    echo BlogCatalog::getOneIsNavLabel($item['is_nav']);
    ?>
</td>
            <td><?php 
    echo \funson86\blog\models\Status::labels()[$item['status']];
    ?>
</td>
            <td>
                <a href="<?php 
    echo \Yii::$app->getUrlManager()->createUrl(['blog/blog-catalog/create', 'parent_id' => $item['id']]);
    ?>
" title="<?php 
    echo Module::t('blog', 'Add Sub Catelog');
    ?>
" data-pjax="0"><span class="glyphicon glyphicon-plus-sign"></span></a>
                <a href="<?php 
示例#7
0
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 255]);
?>

    <?php 
echo $form->field($model, 'surname')->textInput(['maxlength' => 128]);
?>

    <?php 
echo $form->field($model, 'banner')->fileInput();
?>

    <?php 
echo $form->field($model, 'is_nav')->dropDownList(BlogCatalog::getArrayIsNav());
?>

    <?php 
echo $form->field($model, 'sort_order')->textInput();
?>

    <?php 
echo $form->field($model, 'page_size')->textInput();
?>

    <?php 
echo $form->field($model, 'template')->textInput(['maxlength' => 255]);
?>

    <?php 
示例#8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getParent()
 {
     return $this->hasOne(BlogCatalog::className(), ['id' => 'parent_id']);
 }