Example #1
0
 public function run()
 {
     $post = Post::find();
     //选择栏目
     if (!empty($this->short_code)) {
         $post = $post->select(Post::tableName() . '.*')->joinWith(['column' => function ($query) {
             $query->where([Column::tableName() . '.short_code' => $this->short_code]);
         }]);
     }
     //选择类型
     if (!empty($this->type)) {
         if ($this->type == static::TYPE_N) {
             //自动取新
             $post = $post->orderBy(Post::tableName() . '.created_at DESC');
         } elseif ($this->type == static::TYPE_V) {
             //自动取查看最多
             $post = $post->orderBy(Post::tableName() . '.hits DESC');
         } else {
             //后台指定
             $post = $post->andFilterWhere(['like', Post::tableName() . '.flag', $this->type]);
         }
     }
     //限制数量
     $models = $post->active()->limit($this->num)->all();
     //     	fb($models);
     return $this->render('side-post-top', ['title' => $this->title, 'length' => $this->length, 'models' => $models]);
 }
Example #2
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($name)
 {
     if (($model = Column::find()->with('page')->active()->andWhere(['short_code' => trim($name)])->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('该请求对应的页面不存在。');
     }
 }
Example #3
0
 public function run()
 {
     $model = Column::findOne(['short_code' => $this->parent_short_code]);
     $columns = $model->multiSelf;
     //取子列表,仅一层
     if ($columns) {
         return $this->render('side-page', ['title' => $this->title, 'models' => $columns]);
     }
 }
Example #4
0
 /**
  * 新闻列表
  * @param int $id
  * @return string
  */
 public function actionList()
 {
     $column = Column::findOne(['short_code' => Yii::$app->getRequest()->get('name', '')]);
     if (empty($column)) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     //检索与分页
     $query = $column->getImg()->orderBy('publish_at DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['config']['config_site_default_page_size']]]);
     return $this->render('list', ['columnModel' => $column, 'dataProvider' => $dataProvider]);
 }
Example #5
0
 /**
  * 首页
  * @return string
  */
 public function actionIndex()
 {
     $columns = Column::find()->where(['type' => Column::CMS_TYPE_LIST])->active()->orderBy('order ASC')->all();
     //关于我们单页
     $about = Column::find()->where(['short_code' => 'about-brief'])->active()->one();
     //首页主广告
     $mainAdType = AdType::find()->where(['short_code' => 'home_main'])->active()->one();
     //in查询
     $mainAds = $mainAdType->getAd()->active()->orderBy('order ASC')->all();
     //底部广告
     $adBottom = Ad::find()->where(['short_code' => 'home_bottom'])->active()->one();
     //搬家现场,推荐
     $scenes = Img::find()->select(Img::tableName() . '.*')->where(['like', Img::tableName() . '.flag', 'c'])->joinWith(['column' => function ($query) {
         $query->where([Column::tableName() . '.short_code' => 'xianchang']);
     }])->active()->all();
     //搬家现场推荐
     return $this->render('index', ['columns' => $columns, 'about' => $about, 'mainAdType' => $mainAdType, 'mainAds' => $mainAds, 'adBottom' => $adBottom, 'scenes' => $scenes]);
 }
Example #6
0
 public function run()
 {
     if (!empty($this->id)) {
         //自动寻找类型
         $class = 'common\\models\\cms\\' . ucfirst($this->controllerId);
         $all = $class::find();
         //选择栏目
         if (!empty($this->short_code)) {
             $all = $all->select($class::tableName() . '.*')->joinWith(['column' => function ($query) {
                 $query->where([Column::tableName() . '.short_code' => $this->short_code]);
             }]);
         }
         //自动判断
         if ($this->actionId == 'view') {
             //详情
             $model = $class::findOne($this->id);
             //在详情中,直接获取栏目
             $all = $all->andWhere(['column_id' => $model->column_id]);
         } elseif ($this->actionId == 'list') {
             //列表
             $column = Column::findOne($this->id);
             //在列表中,直接获取栏目
             $all = $all->andWhere(['column_id' => $column->id]);
         }
         //选择类型
         if (!empty($this->type)) {
             if ($this->type == static::TYPE_N) {
                 //自动取新
                 $all = $all->orderBy($class::tableName() . '.created_at DESC');
             } elseif ($this->type == static::TYPE_V) {
                 //自动取查看最多
                 $all = $all->orderBy($class::tableName() . '.hits DESC');
             } else {
                 //后台指定
                 $all = $all->andFilterWhere(['like', $class::tableName() . '.flag', $this->type]);
             }
         }
         //限制数量
         $models = $all->active()->limit($this->num)->all();
         return $this->render('side-current-top', ['title' => $this->title, 'length' => $this->length, 'models' => $models, 'type' => $this->controllerId]);
     }
 }
Example #7
0
               </li>
               <li class="active">
                   <?php 
echo Html::a(Yii::t('common', 'View'), 'javascript:;');
?>
               </li>
            </ul>
           
            <div class="tab-content clearfix">
                <div class="tab-pane active cms-class-view">
		            <p>
		                <?php 
echo Html::a(Yii::t('cms', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
		                <?php 
echo Html::a(Yii::t('cms', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('cms', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
		            </p>
		        
		            <?php 
echo DetailView::widget(['model' => $model, 'options' => ['class' => 'table table-hover table-striped table-bordered detail-view'], 'attributes' => ['id', ['attribute' => 'type', 'value' => empty(Column::getType()[$model->type]) ? 'Null' : Column::getType()[$model->type]], ['attribute' => 'parent_id', 'value' => empty($model->mySelf) ? Yii::t('cms', 'Top Column') : $model->mySelf->name], 'name', 'description', 'link_url:url', 'pic_url:url', 'pic_width', 'pic_height', 'seo_title', 'keywords', 'order', ['attribute' => 'status', 'value' => $model->status ? Yii::t('common', 'Yes') : Yii::t('common', 'No')]]]);
?>
                </div>
            </div>
            
        </div>
    </div>
</div>


Example #8
0
    $model->parent_id = $id;
}
$parentIds = ArrayHelper::merge(['0' => Yii::t('cms', 'Top Column')], ArrayHelper::map(General::recursiveObj(Column::find()->orderBy(['order' => SORT_ASC])->all()), 'id', 'name'));
?>

<div class="row cms-class-form">
    <div class="col-md-12">
        <?php 
//广泛布局
$form = ActiveForm::begin(['layout' => 'horizontal', 'fieldConfig' => ['template' => "{label} {beginWrapper} {input} {hint} {error} {endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-2', 'offset' => 'col-sm-offset-2', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '']]]);
?>
        
        <?php 
if ($model->isNewRecord) {
    $model->type = Column::CMS_TYPE_PAGE;
    echo $form->field($model, 'type')->dropDownList(ArrayHelper::merge(Column::getType(), [Column::CMS_TYPE_STRUCT => Yii::t('cms', 'Struct')]));
    echo $form->field($model, 'short_code')->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('cms', 'Used for the frontend call.'))->textInput(['maxlength' => true]);
}
?>
        
        <?php 
echo $form->field($model, 'parent_id')->dropDownList($parentIds);
?>
		
        <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
    
        <?php 
echo $form->field($model, 'keywords')->textInput(['maxlength' => true]);
?>
Example #9
0
                            <?php 
echo Html::a(Yii::t('cms', 'Create Img'), ['create'], ['class' => 'btn btn-success']);
?>
                        </p>
                     -->
            		<?php 
Pjax::begin();
?>
					<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'format' => 'raw', 'value' => function ($model) {
    $length = Yii::$app->params['config']['config_site_title_length'];
    $options = ['style' => ''];
    Html::addCssStyle($options, ['color' => $model->colorval, 'font-weight' => $model->boldval]);
    $title = '<span title="' . $model->title . '" style="' . $options['style'] . '">' . StringHelper::truncate($model->title, $length) . '</span>';
    return Html::a($title, ['update', 'id' => $model->id], ['data-pjax' => '0']);
}], ['attribute' => 'column_id', 'filter' => ArrayHelper::map(Column::find()->where(['type' => Column::CMS_TYPE_IMG])->alive()->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return $model->column->name;
}], ['attribute' => 'flag', 'filter' => ArrayHelper::map(Flag::find()->orderBy('order')->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return $model->flagModel->flag;
}], 'hits', ['attribute' => 'status', 'format' => 'html', 'filter' => [Img::STATUS_YES => Yii::t('cms', 'Yes'), Img::STATUS_NO => Yii::t('cms', 'No')], 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $on = Html::a('<small class="label bg-green">' . Yii::t('common', 'Yes') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    $off = Html::a('<small class="label bg-red">' . Yii::t('common', 'No') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    return $model->status ? $on : $off;
}], 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {delete}', 'header' => Yii::t('common', 'Opration')]]]);
?>
					<?php 
Pjax::end();
?>
     
                </div>
                
Example #10
0
					<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
                        
                    <!-- 
                        <p>
                            <?php 
echo Html::a(Yii::t('cms', 'Create Page'), ['create'], ['class' => 'btn btn-success']);
?>
                        </p>
                     -->
            		<?php 
Pjax::begin();
?>
					<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'column_id', 'format' => 'raw', 'filter' => ArrayHelper::map(Column::find()->where(['type' => Column::CMS_TYPE_PAGE])->alive()->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return Html::a($model->column->name, ['update', 'id' => $model->id], ['data-pjax' => '0']);
}], ['attribute' => 'order', 'format' => 'raw', 'value' => function ($model) {
    return Html::activeTextInput($model, 'order', ['style' => 'width:50px', 'data-id' => $model->id]);
}], ['attribute' => 'status', 'format' => 'html', 'filter' => [Page::STATUS_YES => Yii::t('cms', 'Yes'), Page::STATUS_NO => Yii::t('cms', 'No')], 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $on = Html::a('<small class="label bg-green">' . Yii::t('common', 'Yes') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    $off = Html::a('<small class="label bg-red">' . Yii::t('common', 'No') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    return $model->status ? $on : $off;
}], 'created_at:datetime']]);
?>
					<?php 
Pjax::end();
?>
 
                </div>
                
Example #11
0
    $model->publish_at = date('Y-m-d H:i', $model->publish_at);
    $model->flag = explode(',', $model->flag);
}
$languge = Yii::$app->language;
$this->registerJs("\n// \t\$('input[type=\"checkbox\"].minimal, input[type=\"radio\"].minimal').iCheck({\n// \t\tcheckboxClass: 'icheckbox_minimal-blue',\n// \t\tradioClass: 'icheckbox_minimal-blue'\n// \t});\n\t\n\t//select2\n// \t\$('#download-column_id').select2({\n//         theme: 'classic',\n//         width: '400px',\n//     });\n\n\tvar title = \$('#download-title');\n\tvar colorval = \$('#download-colorval');\n\tvar boldval = \$('#download-boldval');\n\t\$('.title-colorpicker').colorpicker().on('changeColor', function(obColor){\n\t\tvar weight = title.css('font-weight');\n\t\ttitle.css({\"color\": obColor.color.toHex(), \"font-weight\": weight});\n\t\tcolorval.val(obColor.color.toHex());\n\t});\n\t\$('.field-download-title').on('click' ,'.blod', function(){\n\t\tvar color = title.css('color');\n\t\tvar bold = title.css('font-weight');\n\t\tbold = (bold == '700')?'400':'700';\n\t\ttitle.css({\"color\": color, \"font-weight\": bold});\n\t\tboldval.val(bold);\n\t}).on('click' ,'.clear', function(){\n\t\ttitle.css({\"color\": '#333', \"font-weight\": '400'});\n\t\tcolorval.val('#333');\n\t\tboldval.val('400');\n\t});\n\t\t\n\t//时间插件\n\t\$('#download-publish_at').datetimepicker({\n\t\tlanguage:  '{$languge}',\n\t\tformat: 'yyyy-mm-dd hh:ii',// P\n\t\tshowMeridian: 1,//开启上下午选择项\n\t\ttodayBtn:  1,\n\t\ttodayHighlight: 1,\n\t\tautoclose: 1,//选中后,自动关闭\n\t\tpickerPosition: \"top-left\",//面板位置\n// \t\tstartDate: '',//开始日期\n// \t\tendDate: '',//结束日期\n// \t\tstartView: '',//首次显示的是哪个面板:年/月/日/上午下午/时/分\n// \t\tinitialDate: '',//初始化默认日期\n//      weekStart: 1,//显示多少周\n// \t\tforceParse: 0,//强制转化\n// \t\tlinkField: \"mirror_field\",//关联表单\n//      linkFormat: \"yyyy-mm-dd hh:ii\",//关联表单的显示格式\n\t});\n");
?>

<div class="row cms-download-form">
	<div class="col-md-12">
        <?php 
//广泛布局
$form = ActiveForm::begin(['layout' => 'horizontal', 'fieldConfig' => ['template' => "{label} {beginWrapper} {input} {hint} {error} {endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-2', 'offset' => 'col-sm-offset-2', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '']]]);
?>
    	
        <?php 
echo $form->field($model, 'column_id')->dropDownList(ArrayHelper::map(Column::find()->where(['type' => Column::CMS_TYPE_DOWNLOAD])->alive()->all(), 'id', 'name'));
?>
        
        <?php 
//局部布局
echo $form->field($model, 'title', ['horizontalCssClasses' => ['wrapper' => 'col-sm-8'], 'inputTemplate' => '<div class="input-group">{input}<span class="input-group-addon"><span class="color title-colorpicker" title="' . Yii::t('cms', 'Title Color') . '"><i style="background-color: rgb(0, 170, 187);"></i></span> <span class="blod" title="' . Yii::t('cms', 'Title Bold') . '"><i class="fa fa-bold"></i></span> <span class="clear" title="' . Yii::t('cms', 'Clear') . '"><i class="fa fa-eraser"></i></span></span></div>'])->hint('<i class="fa fa-info-circle"></i> ' . Yii::t('cms', 'Title is required'), ['class' => 'help-block error-none'])->textInput(['maxlength' => true, 'style' => !empty($titleOptions) ? $titleOptions['style'] : '']);
//直接对长度限制
?>
	
	    <?php 
echo Html::activeHiddenInput($model, 'colorval');
?>
	    <?php 
echo Html::activeHiddenInput($model, 'boldval');
?>
	
Example #12
0
 /**
  * 一对一
  */
 public function getColumn()
 {
     return $this->hasOne(Column::className(), ['id' => 'column_id']);
 }
Example #13
0
 /**
  * 自联,一对多
  */
 public function getMultiSelf()
 {
     return $this->hasMany(Column::className(), ['parent_id' => 'id']);
 }
Example #14
0
 /**
  * Finds the Column model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Column the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Column::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #15
0
                <div class="tab-pane active cms-class-index">
                
                    <!-- 
                        <p>
                            <?php 
echo Html::a(Yii::t('cms', 'Create Column'), ['create'], ['class' => 'btn btn-success']);
?>
                        </p>
                     -->
            		<?php 
//Pjax::begin()
?>
					<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'name', 'format' => 'html', 'value' => function ($model) {
    $type = !empty(Column::getType()[$model->type]) ? Column::getType()[$model->type] : Yii::t('cms', 'Null');
    $className = empty(Column::getRelativeClass()[$model->type]) ? '' : Column::getRelativeClass()[$model->type];
    $name = $model->name;
    if ($className) {
        $name = Html::a($name, ['/cms/' . strtolower(str_replace('Cms', 'cms-', $className)) . '/index', $className . 'Search[column_id]' => $model->id], ['data-pjax' => '0']);
    }
    return $name . '<i class="type">[' . $type . ']</i>';
}], ['attribute' => 'order', 'format' => 'raw', 'value' => function ($model) {
    return Html::activeTextInput($model, 'order', ['style' => 'width:50px', 'data-id' => $model->id, 'id' => '', 'class' => 'cms-order']);
}], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    $on = Html::a('<small class="label bg-green">' . Yii::t('common', 'Yes') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    $off = Html::a('<small class="label bg-red">' . Yii::t('common', 'No') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    return $model->status ? $on : $off;
}], 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('common', 'Opration'), 'template' => '{add} {update} {delete}', 'buttons' => ['add' => function ($url, $model, $key) {
    $url = ['create', 'id' => $model->id];
    $options = ['title' => Yii::t('cms', 'Add Column'), 'aria-label' => Yii::t('cms', 'Add New Column'), 'data-pjax' => '0'];
    return Html::a('<span class="ion-ios-plus"></span>', $url, $options);