'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( 'i18ns' => array(self::HAS_MANY, 'ReviewI18n', 'id', 'index' => 'lang'), 'i18n' => array(self::HAS_ONE, 'ReviewI18n', 'id', 'condition' => 'lang=\'' . Yii::app()->language . '\''), ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'ID', 'date' => 'Дата', 'image' => 'Фото', ); } /** * 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('reviews_root_id', $this->reviews_root_id); $criteria->compare('date', $this->date, true); return new CActiveDataProvider($this, array( 'criteria' => $criteria, )); } public $image; public function behaviors() { return array( 'imageBehavior' => array( 'class' => 'ImageARBehavior', 'attribute' => 'image', // this must exist 'extension' => 'png, gif, jpg, jpeg', // possible extensions, comma separated 'prefix' => 'owner_', 'relativeWebRootFolder' => 'images/reviews', // this folder must exist 'formats' => array( 'medium' => array( 'suffix' => '_medium', 'process' => array( 'resize' => array(140, null), ), ), 'normal' => array(), ), 'defaultName' => 'default', ), ); } public function getDateRu() { return ($this->date !== null) ? date('d.m.Y', CDateTimeParser::parse($this->date, 'yyyy-MM-dd')) : date('d.m.Y'); } public function setDateRu($value) { $this->date = date('Y-m-d', CDateTimeParser::parse($value, 'dd.MM.yyyy')); } /** * @param Node $node * @return void */ public function setNode($node) { $this->reviews_root_id = $node->data_id; } }