|
@@ -1,8 +1,10 @@
|
|
|
<?php
|
|
|
|
|
|
namespace common\models;
|
|
|
+
|
|
|
use common\behaviors\CommentBehavior;
|
|
|
use common\behaviors\MetaBehavior;
|
|
|
+use common\behaviors\PositionBehavior;
|
|
|
use yii\behaviors\TimestampBehavior;
|
|
|
use yii\helpers\HtmlPurifier;
|
|
|
use yii\helpers\StringHelper;
|
|
@@ -19,6 +21,7 @@ use yii\helpers\StringHelper;
|
|
|
* @property integer $markdown
|
|
|
* @property string $type
|
|
|
* @property string $estate
|
|
|
+ * @property int $sort
|
|
|
*/
|
|
|
class Policy extends \yii\db\ActiveRecord
|
|
|
{
|
|
@@ -49,11 +52,12 @@ class Policy extends \yii\db\ActiveRecord
|
|
|
public function rules()
|
|
|
{
|
|
|
return [
|
|
|
- [['content', 'title', 'summary', 'type','cengci', 'estate'], 'required'],
|
|
|
- [['content'], 'string'],
|
|
|
- [['filter','cengci'], 'string'],
|
|
|
+ [['content', 'title', 'summary', 'type', 'cengci', 'estate'], 'required'],
|
|
|
+ [['sort'], 'integer'],
|
|
|
+ [['content', 'filter', 'cengci'], 'string'],
|
|
|
['markdown', 'default', 'value' => $this->getIsMarkdown()],
|
|
|
[['use_layout'], 'in', 'range' => [0, 1]],
|
|
|
+ [['sort'], 'default', 'value' => 0],
|
|
|
[['title'], 'string', 'max' => 50],
|
|
|
[['author'], 'string', 'max' => 50],
|
|
|
// ['content', 'filterHtml']
|
|
@@ -94,11 +98,12 @@ class Policy extends \yii\db\ActiveRecord
|
|
|
'summary' => '摘要',
|
|
|
'content' => '详情',
|
|
|
'title' => '标题',
|
|
|
- 'author'=>'作者',
|
|
|
- 'type'=>'类型',//类型:0 匹配,1 查询
|
|
|
- 'cengci'=>'层次',
|
|
|
- 'estate'=>'产业',
|
|
|
- 'created_at'=>'发布时间'
|
|
|
+ 'author' => '作者',
|
|
|
+ 'type' => '类型',//类型:0 匹配,1 查询
|
|
|
+ 'cengci' => '层次',
|
|
|
+ 'estate' => '产业',
|
|
|
+ 'created_at' => '发布时间',
|
|
|
+ 'sort' => '排序',
|
|
|
];
|
|
|
}
|
|
|
|
|
@@ -118,7 +123,14 @@ class Policy extends \yii\db\ActiveRecord
|
|
|
],
|
|
|
[
|
|
|
'class' => CommentBehavior::className()
|
|
|
- ]
|
|
|
+ ],
|
|
|
+ 'positionBehavior' => [
|
|
|
+ 'class' => PositionBehavior::className(),
|
|
|
+ 'positionAttribute' => 'sort',
|
|
|
+ 'groupAttributes' => [
|
|
|
+ 'estate'
|
|
|
+ ],
|
|
|
+ ],
|
|
|
];
|
|
|
}
|
|
|
|
|
@@ -126,9 +138,9 @@ class Policy extends \yii\db\ActiveRecord
|
|
|
{
|
|
|
$model = $this->getMetaModel();
|
|
|
|
|
|
- $title = $model->title ? : $this->title;
|
|
|
- $author = $model->author ? : $this->author;
|
|
|
- $description = $model->description ? : StringHelper::truncate(strip_tags($this->content), 150);
|
|
|
+ $title = $model->title ?: $this->title;
|
|
|
+ $author = $model->author ?: $this->author;
|
|
|
+ $description = $model->description ?: StringHelper::truncate(strip_tags($this->content), 150);
|
|
|
|
|
|
return [$title, $author, $description, $model->keywords];
|
|
|
}
|