Ejemplo n.º 1
0
	 * @return Banners the static model class
	 */
    public static function getAdsBannerByType($type)
    {
        $model = self::model()->findAll(array('condition' => 'status = 1 AND banner_type = ' . $type, 'order' => 'created_date'));
        return $model;
    }
Ejemplo n.º 2
0
 public function rules()
 {
     return array(array('limit, offset, sort, key', 'safe'), array('title, name_for_slug, phone, email_not_login, ' . 'agent_cea, location_id, updatedCea, agreeTerm', 'required', 'on' => 'register', 'message' => 'This is required field'), array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements(), 'on' => 'register'), array('uploadPhoto, uploadNricFront, uploadNricBack', 'file', 'on' => 'register', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSizeImage(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'));
 }
Ejemplo n.º 3
0
 public static function validateFileUpload($file, $attribute, $type)
 {
     if ($type = 'image') {
         $mime = array('jpg', 'gif', 'png', 'jpeg');
     }
     if ($type = 'file') {
         $mime = array('doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'txt' => 'text/plain');
     }
     if ($file["error"][$attribute][0] > 0) {
         return "File error ";
     } else {
         $type = explode("/", $file["type"][$attribute][0]);
         $size = $file["size"][$attribute][0];
         $errType = 'File is not allowed';
         $errMaxFile = 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.';
         if ($type == 'image') {
             if (!in_array(strtolower($type[1]), $mime)) {
                 return $errType;
             }
         }
         if ($type == 'file') {
             if (!in_array($type[1], $mime)) {
                 return $errType;
             }
         }
         if ($size > ActiveRecord::getMaxFileSizeImage()) {
             return $errMaxFile;
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     $rules = array(array('imageFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSizeImage(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'), array('imageFile', 'match', 'pattern' => '/^[^\\/?*:&;{}\\\\]+\\.[^\\/?*:;{}\\\\]{3}$/', 'message' => 'Image files name cannot include special characters: &%$#'));
     return array_merge(parent::rules(), $rules);
 }