Beispiel #1
0
 public function search($params)
 {
     $query = Catalog::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition($query, 'name_en');
     $this->addCondition($query, 'name_en', true);
     $this->addCondition($query, 'name_zh');
     $this->addCondition($query, 'name_zh', true);
     $this->addCondition($query, 'redirect_url');
     $this->addCondition($query, 'redirect_url', true);
     $this->addCondition($query, 'tpl_page');
     $this->addCondition($query, 'tpl_page', true);
     $this->addCondition($query, 'tpl_list');
     $this->addCondition($query, 'tpl_list', true);
     $this->addCondition($query, 'tpl_content');
     $this->addCondition($query, 'tpl_content', true);
     $this->addCondition($query, 'note');
     $this->addCondition($query, 'note', true);
     $this->addCondition($query, 'note2');
     $this->addCondition($query, 'note2', true);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Catalog::find();
     $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, 'click' => $this->click, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'brief', $this->brief])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'page_type', $this->page_type])->andFilterWhere(['like', 'template_list', $this->template_list])->andFilterWhere(['like', 'template_show', $this->template_show])->andFilterWhere(['like', 'template_page', $this->template_page])->andFilterWhere(['like', 'redirect_url', $this->redirect_url]);
     return $dataProvider;
 }
Beispiel #3
0
 public static function getMainNav($currentId = 0)
 {
     $mainMenu = [['label' => Yii::t('app', 'Home'), 'url' => array('/site/index'), 'active' => 0 == $currentId]];
     $allCatalog = Catalog::find()->where("parent_id=0")->orderBy(['sort_order' => SORT_ASC, 'id' => SORT_ASC])->all();
     foreach ($allCatalog as $catalog) {
         $item = [];
         if ($catalog->redirect_url) {
             // redirect to other site
             $item = ['label' => $catalog->title, 'url' => $catalog->redirect_url, 'active' => $catalog->id == $currentId];
         } else {
             if ('list' == $catalog->page_type) {
                 $item = ['label' => $catalog->title, 'url' => ['/site/list/', 'id' => $catalog->id], 'active' => $catalog->id == $currentId];
             } else {
                 $item = ['label' => $catalog->title, 'url' => ['/site/page/', 'id' => $catalog->id], 'active' => $catalog->id == $currentId];
             }
         }
         if (!empty($item)) {
             array_push($mainMenu, $item);
         }
     }
     return $mainMenu;
 }
Beispiel #4
0
                                editor = K.create('textarea[name="content"]', {
                                        allowFileManager : true
                                });
                        });
JS;
$this->registerJs($js, View::POS_END);
?>

<div class="catalog-form">

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

    <?php 
echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::merge([0 => Yii::t('app', 'Root Catalog')], ArrayHelper::map(Catalog::get(0, Catalog::find()->all()), 'id', 'str_label')));
?>

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

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

    <!--<?php 
/*= $form->field($model, 'content')->widget(letyii\tinymce\Tinymce::className(), [
  'options' => [
      'id' => 'content',
  ],
Beispiel #5
0
 private function getDataSource()
 {
     if ($this->dataSource !== null) {
         return $this->dataSource;
     }
     $_tableName = $this->tableName;
     if ($_tableName == null) {
         $_catalogId = $this->catalogId;
         $catalogModel = Catalog::find($_catalogId);
     }
     $sql = ' select ' . ($this->fields === null ? '*' : $this->fields) . ' from ' . $_tableName;
     if ($this->where !== null) {
         $sql .= ' where ' . $this->where;
     }
     if ($this->order !== null) {
         $sql .= ' order by ' . $this->order;
     }
     if ($this->limit !== null && $this->limit > 0) {
         $sql .= ' limit 0,' . $this->limit;
     }
     //$db=Yii::$app->db;
 }
Beispiel #6
0
    <title><?php 
echo Html::encode($this->title);
?>
</title>
    <?php 
$this->head();
?>
</head>
<body>
    <?php 
$this->beginBody();
?>
    <div class="wrap">
        <?php 
NavBar::begin(['brandLabel' => 'My Company', 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
$menuItems = Catalog::getMainNav(isset($_GET['id']) ? $_GET['id'] : 0);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>

        <div class="container">
        <?php 
echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
        <?php 
echo Alert::widget();
?>
        <?php 
echo $content;
?>
        </div>
Beispiel #7
0
 public function actionShow()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if (0 >= $id) {
         $this->redirect(Yii::$app->homeUrl);
     }
     $show = Show::findOne(['id' => $id]);
     $catalog = Catalog::findOne(['id' => $show->catalog_id]);
     $templatePage = $show->template ? $show->template : $catalog->template_show ? $catalog->template_show : 'show';
     $portlet = Catalog::getCatalogSub2($id, Catalog::find()->all());
     $portletTitle = Catalog::findOne(['id' => Catalog::getRootCatalogId($id, Catalog::find()->all())])->title;
     return $this->render($templatePage, ['catalog' => $catalog, 'show' => $show, 'portlet' => $portlet, 'portletTitle' => $portletTitle]);
 }
Beispiel #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCatalog()
 {
     return $this->hasOne(Catalog::className(), ['id' => 'catalog_id']);
 }
Beispiel #9
0
                                editor = K.create('textarea[name="content"]', {
                                        allowFileManager : true
                                });
                        });
JS;
$this->registerJs($js, View::POS_END);
?>

<div class="show-form">

    <?php 
$form = ActiveForm::begin();
?>

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

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

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

    <?php 
echo $form->field($model, 'content')->textArea(['name' => 'content', 'style' => 'width:800px;height:400px;visibility:hidden;']);
?>

    <?php 
Beispiel #10
0
 /**
  * Finds the Catalog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Catalog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Catalog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }