Esempio n. 1
0
 /**
  * Validates the attribute of the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     if ($this->setOnEmpty && !$this->isEmpty($object->{$attribute})) {
         return;
     }
     if (!$object->hasAttribute($this->translitAttribute)) {
         throw new CException(Yii::t('yiiext', 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.', array('{class}' => get_class($object), '{column}' => $this->translitAttribute)));
     }
     $object->{$attribute} = self::latin($object->getAttribute($this->translitAttribute));
 }
Esempio n. 2
0
 /**
  * Validates the attribute of the object.
  * @param CModel $object the object being validated
  * @param string $attribute the attribute being validated
  */
 protected function validateAttribute($object, $attribute)
 {
     if ($this->setOnEmpty && !$this->isEmpty($object->{$attribute})) {
         return;
     }
     if (!$object->hasAttribute($this->translitAttribute)) {
         throw new CException(Yii::t('yiiext', 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.', array('{class}' => get_class($object), '{column}' => $this->translitAttribute)));
     }
     $object->{$attribute} = self::cyrillicToLatin($object->getAttribute($this->translitAttribute));
     if ($this->toLower) {
         $object->{$attribute} = strtolower($object->{$attribute});
     }
     //mb_
     if ($this->replaceSlashes) {
         $object->{$attribute} = preg_replace('#\\/#', '-', $object->{$attribute});
     }
     //mb_
     if ($this->removeNonLatin) {
         $object->{$attribute} = preg_replace('/[^A-Za-z0-9_\\-]/', '', $object->{$attribute});
     }
 }