summaryrefslogtreecommitdiff
path: root/protected/modules/cms/models/Sitecontent.php
diff options
context:
space:
mode:
Diffstat (limited to 'protected/modules/cms/models/Sitecontent.php')
-rw-r--r--protected/modules/cms/models/Sitecontent.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/protected/modules/cms/models/Sitecontent.php b/protected/modules/cms/models/Sitecontent.php
index 6d8def2..bcd1385 100644
--- a/protected/modules/cms/models/Sitecontent.php
+++ b/protected/modules/cms/models/Sitecontent.php
@@ -27,8 +27,8 @@ class Sitecontent extends CActiveRecord
public function rules()
{
return array(
- array('position, title, language', 'required'),
- array('parent, position, createtime, updatetime', 'numerical', 'integerOnly'=>true),
+ array('position, title, language, depth', 'required'),
+ array('parent, depth, position, createtime, updatetime', 'numerical', 'integerOnly'=>true),
array('title, keywords, description', 'length', 'max'=>255),
array('content, title_url, title_browser', 'safe'),
array('title, keywords, description, content, language', 'safe', 'on'=>'search'),
@@ -38,7 +38,7 @@ class Sitecontent extends CActiveRecord
public function relations()
{
return array(
- 'parent' => array(self::BELONGS_TO, 'Sitecontent', 'parent'),
+ 'oparent' => array(self::BELONGS_TO, 'Sitecontent', 'parent'),
'childs' => array(self::HAS_MANY, 'Sitecontent', 'parent'),
);
}
@@ -57,6 +57,7 @@ class Sitecontent extends CActiveRecord
'createtime' => Yii::t('CmsModule.cms', 'Createtime'),
'updatetime' => Yii::t('CmsModule.cms', 'Updatetime'),
'language' => Yii::t('CmsModule.cms', 'Language'),
+ 'depth' => Yii::t('CmsModule.cms', 'Depth'),
);
}
@@ -74,9 +75,18 @@ class Sitecontent extends CActiveRecord
$criteria->compare('authorid',$this->authorid);
$criteria->compare('createtime',$this->createtime);
$criteria->compare('updatetime',$this->updatetime);
+ //$criteria->compare('depth',$this->depth);
return new CActiveDataProvider('Sitecontent', array(
'criteria'=>$criteria,
));
}
+
+ public function beforeSave() {
+ if ($this->parent > 0){
+ $this->depth = $this->oparent->depth + 1;
+
+ }
+ return parent::beforeSave();
+ }
}