Esempio 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;
    }
Esempio 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.'));
 }
Esempio 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;
         }
     }
 }
Esempio n. 4
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     return array(array('listing_id', 'numerical', 'integerOnly' => true), array('file', 'length', 'max' => 255), array('file', 'file', 'allowEmpty' => true, 'types' => 'pdf,doc,docx,xls,xlsx,txt', 'wrongType' => 'Only pdf,doc,docx,xls,xlsx,txt are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than  10 MB. Please upload a smaller file.'), array('id, listing_id, file, created_date', 'safe'));
 }
Esempio n. 5
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     // NOTE: you should only define rules for those attributes that
     // will receive user inputs.
     return array(array('name', 'required'), array('name', 'length', 'max' => 255), array('id, name, order_at, cover, status, course_id, slug, short_description, description', 'safe'), array('imageFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'));
 }
Esempio n. 6
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);
 }
Esempio n. 7
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     // NOTE: you should only define rules for those attributes that
     // will receive user inputs.
     return array(array('title', 'required'), array('external_link', 'validateLink'), array('status, layout_id, user_id, order', 'numerical', 'integerOnly' => true), array('title', 'length', 'max' => 200), array('post_type', 'length', 'max' => 20), array('featured_image', 'length', 'max' => 250), array('slug', 'length', 'max' => 250), array('id, title, show_footer,show_home_page, content, status, layout_id, user_id, post_type, meta_keywords, meta_desc, featured_image, order, created, modified, slug, title_tag, external_link', 'safe'), array('imageFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), '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: &%$#'), array('thumbFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'), array('thumbFile', 'match', 'pattern' => '/^[^\\/?*:&;{}\\\\]+\\.[^\\/?*:;{}\\\\]{3}$/', 'message' => 'Thumb files name cannot include special characters: &%$#'), array('banner', 'file', 'allowEmpty' => true, 'types' => 'jpg, jpeg, gif, png', 'maxSize' => ActiveRecord::getMaxFileSize(), 'wrongType' => 'Only jpg, jpeg, gif, png are allowed.', 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.', 'on' => 'create, update'));
 }
Esempio n. 8
0
 /**
  * @return array validation rules for model attributes.
  */
 public function rules()
 {
     return array(array('listing_id, default', 'numerical', 'integerOnly' => true), array('FileValidate', 'file', 'allowEmpty' => true, 'types' => ProListingPhotos::$AllowFile, 'wrongType' => 'Only ' . ProListingPhotos::$AllowFile . ' are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than 10 MB. Please upload a smaller file.'), array('display_order,id, listing_id, default, image, created_date', 'safe'));
 }