<?php
class ExportTranslationForm extends CFormModel {
	public $language, $zip, $force;

	public function rules() {
		return array(
			array('language', 'required'),
			array('force', 'required', 'on'=>'import'),
			array('language', 'existsLanguage'),
			array('zip', 'file', 'types'=>'zip', 'on'=>'import'),
		);
	}

	public function existsLanguage() {
		if($this -> hasErrors()) {
			return false;
		}
		if(!Language::model()->issetLang($this->language)) {
			$this->addError("language", Yii::t("language", "The language {Language} doesn't exists in the system", array(
				"{Language}" => $this->language,
			)));
		}
	}

    public function attributeLabels() {
        return array(
            'language'=>Yii::t("language", "Language"),
            "force"=>Yii::t("language", "Forced import"),
            "zip"=>Yii::t("language", "Zip file (translations)"),
        );
    }
}