init() public method

public init ( )
 public function init()
 {
     parent::init();
     $this->maxFiles = 1;
     $this->maxSize = 20971520;
     if (!empty($this->params)) {
         foreach ($this->params as $prop => $value) {
             if (property_exists($this, $prop)) {
                 $this->{$prop} = $value;
             }
         }
     }
     // turning mime types into strings
     foreach ($this->mimeTypes as $i => $mimeType) {
         if ($mimeType instanceof MimeType) {
             $this->mimeTypes[$i] = $mimeType->name;
         }
     }
     $filesAllowed = !empty($this->mimeTypes);
     $this->mimeTypes = $filesAllowed ? $this->mimeTypes : ['.'];
     /*
      * We placing dot if there is no mimeTypes because for yii FileValidator "no mime types" means
      * that all types is allowed, which is not what we want
      */
     if (!$filesAllowed) {
         $this->wrongExtension = 'File posting is not allowed on this board';
     }
     $this->notArray = 'Attribute is not an array';
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->uploadRequired === null) {
         $this->uploadRequired = Yii::t('yii', 'Please select a correct url.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->notImage === null) {
         $this->notImage = Yii::t('yii', 'The file "{file}" is not an image.');
     }
     if ($this->underDimension === null) {
         $this->underDimension = Yii::t('yii', 'The image "{file}" is too small. At least one dimension should be greater than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->overDimension === null) {
         $this->overDimension = Yii::t('yii', 'The image "{file}" is too large. The width and height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}} each.');
     }
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->notImage === null) {
         $this->notImage = Yii::t('yii', 'The file "{file}" is not an image.');
     }
     if ($this->underWidth === null) {
         $this->underWidth = Yii::t('yii', 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->underHeight === null) {
         $this->underHeight = Yii::t('yii', 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->overWidth === null) {
         $this->overWidth = Yii::t('yii', 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->overHeight === null) {
         $this->overHeight = Yii::t('yii', 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->notImage === null) {
         $this->notImage = Yii::t('yii', 'The file "{file}" is not an image.');
     }
     if ($this->underWidth === null) {
         $this->underWidth = Yii::t('yii', 'The image "{file}" is too small. The width cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->underHeight === null) {
         $this->underHeight = Yii::t('yii', 'The image "{file}" is too small. The height cannot be smaller than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->overWidth === null) {
         $this->overWidth = Yii::t('yii', 'The image "{file}" is too large. The width cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->overHeight === null) {
         $this->overHeight = Yii::t('yii', 'The image "{file}" is too large. The height cannot be larger than {limit, number} {limit, plural, one{pixel} other{pixels}}.');
     }
     if ($this->wrongMimeType === null) {
         $this->wrongMimeType = Yii::t('yii', 'Only files with these mimeTypes are allowed: {mimeTypes}.');
     }
     if (!is_array($this->mimeTypes)) {
         $this->mimeTypes = preg_split('/[\\s,]+/', strtolower($this->mimeTypes), -1, PREG_SPLIT_NO_EMPTY);
     }
 }