Beispiel #1
0
 function ValidateAdd()
 {
     App::import('Helper', 'Number');
     $Number = new NumberHelper();
     $this->validate = array('title' => array('maxLength' => array('rule' => array('maxLength', 255), 'message' => "Title {$this->name} is too long, please insert less than or equals 255 character."), 'minLength' => array('rule' => array('minLength', 3), 'message' => "Title {$this->name} name is too short, please insert greater than or equals 3 character."), 'notEmpty' => array('rule' => "notEmpty", 'message' => "Please insert {$this->name} title.")), 'description' => array('notEmpty' => array('rule' => "notEmpty", 'message' => "Please insert {$this->name} description.")), 'images' => array('imagewidth' => array('rule' => array('imagewidth', 666), 'message' => 'Please upload image with minimum width is 666px'), 'size' => array('rule' => array('size', 5242880), 'message' => 'Your image size is too big, please upload less than ' . $Number->toReadableSize(5242880) . '.'), 'extension' => array('rule' => array('validateName', array('gif', 'jpeg', 'jpg', 'png')), 'message' => 'Only (*.gif,*.jpeg,*.jpg,*.png) are allowed.'), 'notEmptyImage' => array('rule' => "notEmptyImage", 'message' => 'Please upload {$this->name} images.')));
 }
 /**
  * Wrapper to Number->toReadableSize()
  * 
  * @param integer $length Size in bytes
  */
 static function size($var)
 {
     $number = new NumberHelper();
     return $number->toReadableSize($var);
 }