summaryrefslogtreecommitdiff
path: root/protected/modules/cms/models/Sitecontent.php
diff options
context:
space:
mode:
authorPatrick Seeger <pseeger@ccwn.org>2012-05-18 23:49:50 +0200
committerPatrick Seeger <pseeger@ccwn.org>2012-05-18 23:49:50 +0200
commit8f75b966aa7376e2febe42f0d39257a8b3eec667 (patch)
treea20e255e9d4e749a44811c7b6e525b9c112f2270 /protected/modules/cms/models/Sitecontent.php
parent06d036c59abbca0b851dd2d820cf57f51514e86d (diff)
menustruktur optimiert
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();
+ }
}