Skip to content

Commit

Permalink
forget
Browse files Browse the repository at this point in the history
  • Loading branch information
yidashi committed Apr 27, 2016
1 parent 9fe06b4 commit 0d71200
Show file tree
Hide file tree
Showing 529 changed files with 269,562 additions and 53 deletions.
6 changes: 3 additions & 3 deletions backend/controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ public function actionCreate()
$isValid = $model->validate();

if ($isValid) {
$model->save(false);
$model->setTags();
$dataModel->id = $model->id;
$isValid = $dataModel->validate();
if ($isValid) {
$model->save(false);
$model->setTags();
$dataModel->id = $model->id;
$dataModel->save(false);
return $this->redirect(['index']);
}
Expand Down
16 changes: 0 additions & 16 deletions backend/messages/zh-CN/app.php

This file was deleted.

17 changes: 13 additions & 4 deletions backend/views/article/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,31 @@

<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

<?= $form->field($model, 'category_id')->dropDownList(\common\models\Category::getDropDownlist()) ?>

<?php //$form->field($dataModel, 'content')->widget('kucha\ueditor\UEditor', ['options' => ['style' => 'height:500px']]) ?>
<?= $form->field($dataModel, 'content')->widget(\yidashi\markdown\Markdown::className(), ['options' => ['style' => 'height:500px']]) ?>

<?= $form->field($model, 'category_id')->dropDownList(\common\models\Category::getDropDownlist()) ?>

<?= $form->field($model, 'cover')->widget('yidashi\webuploader\Webuploader') ?>

<?= $form->field($model, 'status')->dropDownList([0 => '待审核', 1 => '正常']) ?>
<?= $form->field($model, 'status')->checkboxList([1 => '激活']) ?>

</div>
<div class="tab-pane" id="tab_2">

<?= $form->field($model, 'published_at')->widget(
\trntv\yii\datetime\DateTimeWidget::className(),
[
'phpDatetimeFormat' => 'yyyy-MM-dd HH:mm:ss',
'phpMomentMapping' => ['yyyy-MM-dd HH:mm:ss' => 'YYYY-MM-DD HH:mm:ss'],
'locale' => 'zh-cn'
]
) ?>
<?= $form->field($model, 'desc')->textarea()?>

<?= $form->field($model, 'tagNames')->widget(\common\widgets\tag\Tag::className()) ?>

<?= $form->field($model, 'source')->textInput() ?>

</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? '发布' : '更新', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
Expand Down
4 changes: 2 additions & 2 deletions backend/views/article/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
],
'category',
'author',
'created_at',
'updated_at',
'created_at:datetime',
'updated_at:datetime',
'status',
'cover',
],
Expand Down
2 changes: 2 additions & 0 deletions common/messages/zh-CN/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@
'i18n' => '国际化',
'i18n Message' => '国际化信息',
'i18n Source Message' => '国际化源信息',
'Search' => '搜索',
'Reset' => '重置',
];
2 changes: 1 addition & 1 deletion common/messages/zh-CN/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
'Male' => '男',
'Money' => '余额',
'Signature' => '个性签名',
'Avatar' => '头像'
'Avatar' => '头像',
];
5 changes: 5 additions & 0 deletions common/models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use common\behaviors\PushBehavior;
use common\behaviors\SoftDeleteBehavior;
use common\models\query\ArticleQuery;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveQuery;
Expand Down Expand Up @@ -43,9 +44,12 @@ public function rules()
[['title', 'category_id'], 'required'],
[['status', 'category_id', 'view', 'up', 'down', 'user_id'], 'integer'],
[['category_id', 'status'], 'filter', 'filter' => 'intval'],
['published_at', 'default', 'value' => time()],
[['published_at'], 'filter', 'filter' => 'strtotime', 'skipOnEmpty' => true],
['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_INIT]],
[['category_id'], 'setCategory'],
['category_id', 'exist', 'targetClass' => Category::className(), 'targetAttribute' => 'id'],
[['title', 'category', 'author'], 'string', 'max' => 50],
[['author', 'cover', 'source'], 'string', 'max' => 255],
[['desc', 'tagNames'], 'safe']
Expand All @@ -69,6 +73,7 @@ public function attributeLabels()
'created_at' => Yii::t('common', 'Created At'),
'updated_at' => Yii::t('common', 'Updated At'),
'deleted_at' => '删除时间',
'published_at' => '发布时间',
'status' => '状态',
'cover' => '封面',
'category_id' => '分类',
Expand Down
2 changes: 1 addition & 1 deletion common/models/ArticleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function tableName()
public function rules()
{
return [
[['id', 'content'], 'required'],
[['content'], 'required'],
[['id'], 'integer'],
[['content'], 'string'],
];
Expand Down
2 changes: 1 addition & 1 deletion common/models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public function getLevel()
public function getArticles()
{
return $this->hasMany(Article::className(), ['id' => 'article_id'])
->viaTable('{{%article_tag}}', ['tag_id' => 'id'])->active();
->viaTable('{{%article_tag}}', ['tag_id' => 'id'])->published();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Time: 上午10:19
*/

namespace common\models;
namespace common\models\query;


use common\models\Article;
use yii\db\ActiveQuery;

class ArticleQuery extends ActiveQuery
Expand Down Expand Up @@ -37,4 +38,9 @@ public function active()
{
return $this->normal()->andWhere(['status' => Article::STATUS_ACTIVE]);
}

public function published()
{
return $this->active()->andWhere(['<', 'published_at', time()]);
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"dmstr/yii2-adminlte-asset": "*",
"yiisoft/yii2-composer": "2.0.4",
"yidashi/yii2-bootstrap-markdown": "^1.0",
"mihaildev/yii2-elfinder": "^1.0"
"mihaildev/yii2-elfinder": "^1.0",
"trntv/yii2-datetime-widget": "^1.0.0"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
Expand Down
171 changes: 169 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0d71200

Please sign in to comment.