<?php

/**
 * This is the model class for table "sport_root_i18n".
 *
 * The followings are the available columns in table 'sport_root_i18n':
 * @property integer $id
 * @property string $lang
 * @property string $page_name
 * @property string $study_title
 * @property string $study_image
 * @property string $study_content
 * @property string $study_button
 * @property string $study_link
 * @property string $awards_content
 * @property string $awards_button
 * @property string $awards_link
 * @property string $champions_content
 * @property string $qualifications_content
 * @property string $team_link
 * @property string $title
 * @property string $keywords
 * @property string $description
 *
 * The followings are the available model relations:
 * @property SportRoot $sportRoot
 */
class SportRootI18n extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return SportRootI18n 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 'sport_root_i18n';
    }

    /**
     * @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('page_name, study_title, study_image, study_button, study_link, awards_button, awards_link, team_link, title', 'length', 'max' => 512),
            array('study_content, awards_content, champions_content, qualifications_content, keywords, description', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, lang, page_name, study_title, study_image, study_content, study_button, study_link, awards_content, awards_button, awards_link, champions_content, qualifications_content, team_link, title, keywords, description', '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(
            'sportRoot' => array(self::BELONGS_TO, 'SportRoot', 'id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'lang' => 'Язык',
            'page_name' => 'Название страницы',

            'study_title' => 'Заголовок блока обучения',
            'study_image' => 'Картинка блока обучения',
            'study_content' => 'Содержимое блока обучения',
            'study_button' => 'Текст кнопки в блоке обучения',
            'awards_content' => 'Содержимое блока наши награды',
            'awards_button' => 'Текст ccылки в блоке наши победы',
            'champions_content' => 'Содержимое блока наши чемпионы',
            'qualifications_content' => 'Содержимое блока квалификации',

            'content' => 'Содержимое страницы',
            'title' => 'Заголовок',
            'keywords' => 'Ключевые слова',
            'description' => 'Описание',

            'study_link' => 'Ссылка на страницу обучение',
            'awards_link' => 'Ссылка на страницу наград',
            'team_link' => 'Ссылка на страницу команды',
        );
    }

    /**
     * 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('lang', $this->lang, true);
        $criteria->compare('page_name', $this->page_name, true);
        $criteria->compare('study_title', $this->study_title, true);
        $criteria->compare('study_image', $this->study_image, true);
        $criteria->compare('study_content', $this->study_content, true);
        $criteria->compare('study_button', $this->study_button, true);
        $criteria->compare('study_link', $this->study_link, true);
        $criteria->compare('awards_content', $this->awards_content, true);
        $criteria->compare('awards_button', $this->awards_button, true);
        $criteria->compare('awards_link', $this->awards_link, true);
        $criteria->compare('champions_content', $this->champions_content, true);
        $criteria->compare('qualifications_content', $this->qualifications_content, true);
        $criteria->compare('team_link', $this->team_link, true);
        $criteria->compare('title', $this->title, true);
        $criteria->compare('keywords', $this->keywords, true);
        $criteria->compare('description', $this->description, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }
}