summaryrefslogtreecommitdiff
path: root/protected/models/CmsPage.php
diff options
context:
space:
mode:
Diffstat (limited to 'protected/models/CmsPage.php')
-rw-r--r--protected/models/CmsPage.php133
1 files changed, 0 insertions, 133 deletions
diff --git a/protected/models/CmsPage.php b/protected/models/CmsPage.php
deleted file mode 100644
index 92acf23..0000000
--- a/protected/models/CmsPage.php
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-
-/**
- * This is the model class for table "{{cms_page}}".
- *
- * The followings are the available columns in table '{{cms_page}}':
- * @property integer $id
- * @property string $content
- * @property string $title
- * @property string $create_time
- * @property string $update_time
- * @property integer $status
- * @property string $slug
- */
-class CmsPage extends CActiveRecord
-{
-
-
- const STATUS_PUBLISHED=1;
- const STATUS_DRAFT=2;
- const STATUS_DELETED=3;
- /**
- * Returns the static model of the specified AR class.
- * @param string $className active record class name.
- * @return CmsPage the static model class
- */
- public static function model($className=__CLASS__)
- {
- return parent::model($className);
- }
-
- /**
- * @return string the associated database table name
- */
- public function tableName()
- {
- return '{{cms_page}}';
- }
-
- /**
- * @return array validation rules for model attributes.
- */
- public function rules()
- {
- // NOTE: you should only define rules for those attributes that
- // will receive user inputs.
- return array(
- array('content, title, status, slug', 'required'),
- array('status', 'numerical', 'integerOnly'=>true),
- array('status', 'in', 'range'=>array(1,2,3)),
- array('title, slug', 'length', 'max'=>255),
- // The following rule is used by search().
- // Please remove those attributes that should not be searched.
- array('id, content, title, create_time, update_time, status, slug', 'safe', 'on'=>'search'),
- //array('title, status', 'safe', 'on'=>'search'),
- );
- }
-
- /**
- * @return array relational rules.
- */
- public function relations()
- {
- // NOTE: you may need to adjust the relation name and the related
- // class name for the relations automatically generated below.
- return array(
- );
- }
-
- /**
- * @return array customized attribute labels (name=>label)
- */
- public function attributeLabels()
- {
- return array(
- 'id' => 'ID',
- 'content' => 'Content',
- 'title' => 'Title',
- 'create_time' => 'Create Time',
- 'update_time' => 'Update Time',
- 'status' => 'Status',
- 'slug' => 'Slug',
- );
- }
-
- /**
- * Retrieves a list of models based on the current search/filter conditions.
- * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
- */
- public function search()
- {
- // Warning: Please modify the following code to remove attributes that
- // should not be searched.
-
- $criteria=new CDbCriteria;
-
- $criteria->compare('id',$this->id);
- $criteria->compare('content',$this->content,true);
- $criteria->compare('title',$this->title,true);
- $criteria->compare('create_time',$this->create_time,true);
- $criteria->compare('update_time',$this->update_time,true);
- $criteria->compare('status',$this->status);
- $criteria->compare('slug',$this->slug,true);
-
- return new CActiveDataProvider($this, array(
- 'criteria'=>$criteria,
- ));
- }
-
- public function getUrl()
- {
- return Yii::app()->createUrl('cms', array(
- 'slug'=>$this->slug,
- ));
- }
-
- protected function beforeSave()
- {
- if(parent::beforeSave())
- {
- if($this->isNewRecord)
- {
- $this->create_time=$this->update_time=new CDbExpression('NOW()');
- //$this->author_id=Yii::app()->user->id;
- }
- else
- $this->update_time=new CDbExpression('NOW()');
- return true;
- }
- else
- return false;
- }
-} \ No newline at end of file