public function profileCover() { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('cover-image', 'img/user/covers/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/user/covers/original/{$imageName}"; $destination = "img/user/covers/edited/"; // Make the avatar version $imageUploader->resize($fileLocation, 1000, $destination, $imageName); $_POST['cover-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } if ($this->totalErrors == 0) { $result = $this->model->changeCover(); // If the result was good if ($result) { // Redirect the user to login header('Location: index.php?page=profile'); $this->userSuccess = 'Successfully changed your info'; } else { $this->userFail = 'Info not updated'; } } }
public function renderDeleteLogo() { $imageUploader = new \ImageUploader(NULL); // delete logo from server filesystem $imageUploader->deleteImage($this->settings["logo"]); // delete logo from database $this->context->settings->deleteBy(array("name" => "logo")); $this->flashMessage("Logo bylo smazáno."); $this->redirect('WebSettings:Default'); }
public function invokeHandler(User $user, $pid) { if ($user->isValid()) { global $RDb; $image = $RDb->fetch("select * from files where id=%d", $pid); $upload_handler = new ImageUploader(array('user_token' => $user->getToken()), false); $upload_handler->delete_file($image->id, $image->name); } header('Location: ' . CONTEXT_PATH . 'home'); }
public function add() { $this->set('title_for_layout', 'Add Book'); if ($this->request->isPost()) { if ($this->Author->find('first', array('conditions' => array('id_author' => $this->request->data['id_author'])))) { if (!$this->Book->find('first', array('conditions' => array('id_book' => $this->request->data['id_book'])))) { if (isset($this->params['form']['image']['name']) && !empty($this->params['form']['image']['name'])) { $new_name = $this->params['form']['image']['name']; $uploader = new ImageUploader(IMAGE_UPLOAD_PATH_BOOK, $this->params['form']['image'], $this->request->data('id_user'), $this->img_check_pattern); $upload_result = $uploader->upload(); if (!$upload_result) { $upload_image_err = $uploader->get_error_message(); $msg = "You can not upload images。"; $this->set('errors_image', $upload_image_err); } else { $img = $this->request->data('id_user') . '.' . $this->img_check_pattern['ext']; $this->User->save(array('id_user' => $this->request->data('id_user'), 'avatar' => $img)); } if ($this->Wrote->save(array('id_author' => $this->request->data('id_author'), 'id_book' => $this->request->data('id_book')))) { $remain = $this->request->data('price') * (100 - $this->request->data('remain')) / 100; if (!$this->request->data('adult')) { $adult = 0; } else { $adult = $this->request->data('adult'); } if (!$this->request->data('ebook')) { $adult = 0; } else { $adult = $this->request->data('ebook'); } if ($this->request->data('book')) { $adult = 1; } else { $adult = $this->request->data('book'); } if ($this->Book->save(array('id_book' => $this->request->data('id_book'), 'name' => $this->request->data('name'), 'description' => $this->request->data('description'), 'descriptionpro' => $this->request->data('descriptionpro'), 'description404' => $this->request->data('description404'), 'sale' => $this->request->data('remain'), 'price' => $this->request->data('price'), 'remain' => $remain, 'adult' => $this->request->data('adult'), 'ebook' => $this->request->data('ebook'), 'book' => $this->request->data('book')))) { $this->Session->setFlash(GlobalVar::get_html_success("Add Book succeed")); $this->redirect(ADMIN_ROOT_URL . 'adminbook/index'); exit; } else { $this->Session->setFlash(GlobalVar::get_html_error("This author's id not existed ")); exit; } } else { $this->Session->setFlash(GlobalVar::get_html_error("This author's id not existed ")); exit; } } } } else { $this->Session->setFlash(GlobalVar::get_html_error("This author's id not existed ")); exit; } } }
public function processRecipe() { // If there is a file if (isset($_FILES['recipe-image']) && $_FILES['recipe-image']['name'] != '') { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('recipe-image', 'img/recipes/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/recipes/original/{$imageName}"; $destination = "img/recipes/cover/"; // Make the recipe_image version $imageUploader->resize($fileLocation, 1000, $destination, $imageName); // Make thumbnail $destination = "img/recipes/thumbnail/"; $imageUploader->resize($fileLocation, 230, $destination, $imageName); $_POST['recipe-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } } if ($this->totalErrors == 0) { $result = $this->model->updateRecipe(); // If the result was good if ($result) { // Redirect the user to login header('Location: index.php?page=recipe&recipeid=' . $_GET['recipeid']); $this->userSuccess = 'Successfully changed your info'; } else { $this->userFail = 'Info not updated'; } } }
public function executeUpload(sfWebRequest $request) { $result = 'All broken :('; try { //@todo: added CSRF check; $files = $request->getFiles(); $fileData = array_pop($files); $validator = new sfValidatorFile(array('max_size' => 1024 * 1024, 'mime_types' => array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'application/octet-stream'))); $file = $validator->clean($fileData); $file instanceof sfValidatedFile; $uploader = new ImageUploader(); $uploaded = $uploader->login()->upload($file->getTempName()); $photo = new Photo(); $photo->name = $uploaded->image; $photo->thumb = $uploaded->thumb; $photo->save(); $result = array('id' => $photo->getId(), 'image' => $uploaded->image, 'thumb' => $uploaded->thumb); } catch (Exception $e) { $result = $e->getMessage(); } return $this->renderText(json_encode($result)); }
/** * Upload images and save new urls * @return bool */ public function save($post) { $excludePostTypes = self::getOption('exclude_post_types'); if (is_array($excludePostTypes) && in_array($post->post_type, $excludePostTypes)) { return false; } global $wpdb; $content = $post->post_content; $images = $this->findAllImageUrls($content); if ($images === null) { return false; } foreach ($images as $image) { $uploader = new ImageUploader($image['url'], $image['alt'], $post); if ($uploader->validate() && $uploader->save()) { $url = parse_url($uploader->url); $base_url = $uploader->getHostUrl() == null ? null : "http://{$uploader->getHostUrl()}"; $image_url = $base_url . $url['path']; $content = preg_replace('/' . preg_quote($image['url'], '/') . '/', $image_url, $content); $content = preg_replace('/alt=["\']' . preg_quote($image['alt'], '/') . '["\']/', "alt='{$uploader->getAlt()}'", $content); } } return $wpdb->update($wpdb->posts, array('post_content' => $content), array('ID' => $post->ID)) ? true : false; }
/** * * @param array $file e.g. $_FILES['photo'] * @return ConversationAttachment */ public function addAttachment($file) { $systemFilename = self::findNewFileName($this->config->uploadDir); $attachsImgUpConfig = $this->config->imageUploaderConfig; $attachsImgUpConfig->uploadDir = $this->config->uploadDir; if (in_array($file["type"], $attachsImgUpConfig->acceptedMimeTypes->toArray())) { ImageUploader::upload($file, $systemFilename, $attachsImgUpConfig); } else { FileUploader::upload($file, $systemFilename, $this->config->uploadDir); } $qb = new QueryBuilder(); $qb->insert(Tbl::get('TBL_CONVERSATION_ATTACHEMENTS'))->values(array('system_filename' => $systemFilename, 'filename' => $file['name'], 'mime_type' => $file['type'])); $attachmentId = $this->query->exec($qb->getSQL())->getLastInsertId(); $filter = new ConversationAttachmentFilter(); $filter->setId($attachmentId); return $this->getAttachment($filter); }
public function processChangeInfo() { $firstname = $_POST['first-name']; $lastname = $_POST['last-name']; $bio = $_POST['bio']; if (strlen($firstname) > 40) { $this->firstnameError = 'First name is too long please abbreviate or use a nickname. 40 Character max.'; $this->totalErrors++; } if (strlen($lastname) > 40) { $this->lastnameError = 'Last name is too long please abbreviate or use a nickname. 40 Character max.'; $this->totalErrors++; } if (strlen($bio) > 400) { $this->bioError = 'Your description is too long please abbreviate. 400 Character max.'; $this->totalErrors++; } if (isset($_FILES['profile-image']) && $_FILES['profile-image']['name'] != '') { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('profile-image', 'img/user/avatar/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/user/avatar/original/{$imageName}"; $destination = "img/user/avatar/edited/"; // Make the recipe_image version $imageUploader->resize($fileLocation, 110, $destination, $imageName); // Make thumbnail $destination = "img/user/avatar/icon/"; $imageUploader->resize($fileLocation, 34, $destination, $imageName); $_POST['profile-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } } if ($this->totalErrors == 0) { $this->model->updateInfo(); $this->detailsSuccess = 'Your details have been updated successfully.'; } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for id field // $editor = new TextEdit('id_edit'); $editColumn = new CustomEditColumn('Id', 'id', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for sqlname field // $editor = new TextEdit('sqlname_edit'); $editor->SetSize(100); $editor->SetMaxLength(100); $editColumn = new CustomEditColumn('Sqlname', 'sqlname', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for sqlcontent field // $editor = new ImageUploader('sqlcontent_edit'); $editor->SetShowImage(false); $editColumn = new FileUploadingColumn('Sqlcontent', 'sqlcontent', $editor, $this->dataset, false, false, 'GE_webreport_sqlGrid_sqlcontent_handler_insert'); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for username field // $editor = new TextEdit('username_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('Username', 'username', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for email field // $editor = new TextEdit('email_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('Email', 'email', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for password field // $editor = new TextEdit('password_edit'); $editor->SetPasswordMode(true); $editColumn = new CustomEditColumn('Password', 'password', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for dept_id field // $editor = new ComboBox('dept_id_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $editColumn = new CustomEditColumn('Department', 'dept_id', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for position field // $editor = new TextEdit('position_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('Position', 'position', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for emp_number field // $editor = new TextEdit('emp_number_edit'); $editor->SetSize(20); $editor->SetMaxLength(20); $editColumn = new CustomEditColumn('Employee No', 'emp_number', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for picture field // $editor = new ImageUploader('picture_edit'); $editor->SetShowImage(true); $editColumn = new UploadFileToFolderColumn('Picture', 'picture', $editor, $this->dataset, false, false, 'images'); $editColumn->OnCustomFileName->AddListener('picture_GenerateFileName_insert', $this); $editColumn->SetReplaceUploadedFileIfExist(true); $editColumn->SetGenerationImageThumbnails('picture', 'images', Delegate::CreateFromMethod($this, 'picture_Thumbnail_GenerateFileName_insert'), new ImageFitByHeightResizeFilter(100)); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
public function processRecipe() { $recipeTitle = trim($_POST['recipe-title']); $recipeDirections = trim($_POST['recipe-directions']); $recipeTime = trim($_POST['cook-time']); $recipeServes = trim($_POST['serves']); $recipeVideo = trim($_POST['recipe-video']); $this->recipeTitle = $recipeTitle; $this->recipeDirections = $recipeDirections; $this->recipeTime = $recipeTime; $this->recipeVideo = $recipeVideo; if (strlen($recipeTitle) > 40) { $this->recipeTitleError = 'Recipe name is too long, 45 characters max.'; $this->totalErrors++; } elseif (strlen($recipeTitle) == 0) { $this->recipeTitleError = 'Recipe title is required.'; $this->totalErrors++; } if (strlen($recipeDirections) > 2000) { $this->recipeDirectionsError = 'Recipe directions is too long please shorten, 2000 characters max.'; $this->totalErrors++; } elseif (strlen($recipeDirections) == 0) { $this->recipeDirectionsError = 'Recipe directions is required.'; $this->totalErrors++; } if (strlen($recipeTime) > 3) { $this->recipeTimeError = 'Please enter up to 3 digits.'; $this->totalErrors++; } else { if ($recipeTime == '') { $this->recipeTimeError = 'Please enter a time.'; $this->totalErrors++; } elseif (!preg_match('/^[0-9]{1,3}$/', $recipeTime)) { $this->recipeTimeError = 'Use only numbers. With a maximum of 3 digits.'; $this->totalErrors++; } } if ($_FILES['cover-image']['name'] == '') { $this->userImageError = 'You must upload an image with your recipe.'; $this->totalErrors++; } else { // If there is a file if (isset($_FILES['cover-image']) && $_FILES['cover-image']['name'] != '') { require 'vendor/ImageUploader.php'; // Create instance of the Image Uploader $imageUploader = new ImageUploader(); // Attempt to upload the file $result = $imageUploader->upload('cover-image', 'img/recipes/original/'); // If the upload was a success if ($result == true) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/recipes/original/{$imageName}"; $destination = "img/recipes/cover/"; // Make the recipe_image version $imageUploader->resize($fileLocation, 1000, $destination, $imageName); // Make thumbnail $destination = "img/recipes/thumbnail/"; $imageUploader->resize($fileLocation, 230, $destination, $imageName); $_POST['cover-image'] = $imageName; } else { // Something went wrong $this->totalErrors++; $this->userImageError = $imageUploader->errorMessage; } } } if ($this->totalErrors == 0) { $this->model->addRecipe(); } }
public function add() { $this->set('title_for_layout', ' Add User'); $success_message = ''; if ($this->request->isPost()) { if (isset($this->data['cancel'])) { $this->redirect(ADMIN_ROOT_URL . 'adminusers/index'); return; } if (isset($this->data['adduser'])) { if (isset($this->params['form']['image']['name']) && !empty($this->params['form']['image']['name'])) { $new_name = $this->params['form']['image']['name']; $uploader = new ImageUploader(IMAGE_UPLOAD_PATH_USER, $this->params['form']['image'], $this->request->data('id_user'), $this->img_check_pattern); $upload_result = $uploader->upload(); if (!$upload_result) { $upload_image_err = $uploader->get_error_message(); $msg = "You can not upload images。"; $this->set('errors_image', $upload_image_err); } else { $img = $this->request->data('id_user') . '.' . $this->img_check_pattern['ext']; $this->User->save(array('id_user' => $this->request->data('id_user'), 'avatar' => $img)); } } if ($this->User->save(array('id_user' => $this->request->data('id_user'), 'username' => $this->request->data('username'), 'password' => sha1($this->request->data('password')), 'birth' => $this->request->data('birth'), 'mail' => $this->request->data('mail'), 'sex' => $this->request->data('gender'), 'mail' => $this->request->data('mail'), 'facebook' => $this->request->data('facebook'), 'balance' => $this->request->data('balance'), 'created' => $this->request->data('created'), 'nearest' => $this->request->data('nearest')))) { $success_message = 'Add succeed。'; $this->Session->setFlash(GlobalVar::get_html_success($success_message)); } else { $success_message = 'Add failed。'; $this->Session->setFlash(GlobalVar::get_html_success($success_message)); } } } }
<?php if (isset($_REQUEST['submit'])) { require 'class.imageupload.php'; //$image = new ImageUloader($max_size, $max_width, $max_height, $upload_dir) $image = new ImageUploader(26, 200, 150, 'images/avatar/'); //1. maximum image size in kb(kilo byte), 2. maximum image width //3. maximum image height, 4. upload dir $image->setImage('input_field_name'); //name of your input image field name if (!$image->checkSize()) { //check image size $errors[] = "File size is Big"; } if (!$image->checkHeight()) { //check image height $errors[] = "File height is Big"; } if (!$image->checkWidth()) { //check image width $errors[] = "File width is Big"; } if (!$image->checkExt()) { //check image extension $errors[] = "File ext is not supported"; } if (!isset($errors)) { $image->setImageName($userid); //set image name $image->deleteExisting(); $image->upload();
public function deletePhoto(UserPhoto $photo, $uploadDir = null) { if (empty($photo->id)) { throw new InvalidArgumentException("UserPhoto object has no id!"); } if (empty($photo->userId)) { $photo = $this->getPhoto($photo->id); } ImageUploader::deleteImage($photo->fileName, $uploadDir); if (Reg::get('packageMgr')->isPluginLoaded("Image", "ImageCache")) { Reg::get(ConfigManager::getConfig("Image", "ImageCache")->Objects->ImageCache)->clearImageCache($photo->fileName); } if (Reg::get('packageMgr')->isPluginLoaded("Image", "ImageModificator")) { Reg::get(ConfigManager::getConfig("Image", "ImageModificator")->Objects->ImageModificator)->deleteCropSettings($photo->fileName); } $this->deletPhotoFromDB($photo); }
public function deletePhoto(UserPhoto $photo, $uploadDir = null) { if (empty($photo->id)) { throw new InvalidArgumentException("UserPhoto object has no id!"); } if (empty($photo->userId)) { $photo = $this->getPhoto($photo->id); } ImageUploader::deleteImage($photo->fileName, $uploadDir); if (Reg::get('packageMgr')->isPluginLoaded("Image", "ImageCache")) { Reg::get(ConfigManager::getConfig("Image", "ImageCache")->Objects->ImageCache)->clearImageCache($photo->fileName); } if (Reg::get('packageMgr')->isPluginLoaded("Image", "ImageModificator")) { Reg::get(ConfigManager::getConfig("Image", "ImageModificator")->Objects->ImageModificator)->deleteCropSettings($photo->fileName); } $this->query->exec("DELETE FROM `" . Tbl::get('TBL_USERS_PHOTOS') . "` \n\t\t\t\t\t\t\t\tWHERE `id` = '{$photo->id}' LIMIT 1"); $this->correctDefaultPhoto($photo->userId); }
private function processUpdateFile() { $fileNameUpdate = trim($_POST['file-name']); $fileTypeUpdate = $_POST['file-type-upload-dropdown']; $fileTagUpdate = $_POST['tag-checkbox']; $fileDescriptionUpdate = trim($_POST['file-description']); $this->fileNameUpdate = $fileNameUpdate; $this->fileTypeUpdate = $fileTypeUpdate; $this->fileTagUpdate = $fileTagUpdate; $this->fileDescriptionUpdate = $fileDescriptionUpdate; //Validation if ($fileNameUpdate == '') { $this->fileNameUpdateError = 'Required'; $this->totalErrors++; } elseif (strlen($fileNameUpdate) > 30 || strlen($fileNameUpdate) < 3) { $this->fileNameUpdateError = 'Job Title must be between 3 and 30 characters.'; $this->totalErrors++; } elseif (!preg_match('/^[\\w0-9_\\-. ]{3,20}$/', $fileNameUpdate)) { $this->fileNameUpdateError = 'Use only letters, numbers, hyphens underscore and periods.'; $this->totalErrors++; } $FileTypeUpdate = $_POST['file-type-upload-dropdown']; if (!is_numeric($FileTypeUpdate)) { $this->fileTypeUpdateError = 'Something Wrong'; $this->totalErrors++; } if ($fileDescriptionUpdate == '') { $this->fileDescriptionUpdateError = 'Required'; $this->totalErrors++; } elseif (strlen($fileDescriptionUpdate) > 2000 || strlen($fileDescriptionUpdate) < 3) { $this->fileDescriptionUpdateError = 'Job Title must be between 3 and 2000 characters. you have gone over by' . (strlen($fileDescription) - 2000); $this->totalErrors++; } elseif (!preg_match('/^[\\w0-9_\\-. ]{3,2000}$/', $fileDescriptionUpdate)) { $this->fileDescriptionUpdateError = 'Use only letters, numbers, hyphens underscore and periods.'; $this->totalErrors++; } // Only if the user has seleted some checkboxes if (isset($fileTagUpdate)) { // Loop through each checkbox and make sure they are a number foreach ($fileTagUpdate as $tagUpdate) { // If it is not a number if (!is_numeric($uploadTag)) { $this->totalErrors++; $this->tagUpdateError = 'Something wrong with checkboxes'; } } } //attempt to upload the image if ($this->totalErrors == 0 && isset($_FILES['file-image']) && $_FILES['file-image']['name'] != '') { //Require the image uploader require_once 'vendor/ImageUploader.php'; //create instance of the image uploader $imageUploader = new ImageUploader(); //Attempt to upload the image $result = $imageUploader->upload('file-image', 'img/file-images/original/'); //if upload was success if ($result) { //get the file name $imageName = $imageUploader->getImageName(); //Prepare the variables $fileLocation = "img/file-images/original/{$imageName}"; //Prepare the preview version $previewDestination = "img/file-images/preview/"; $imageUploader->resize($fileLocation, 400, $previewDestination, $imageName); //Make the thumbnail version $thumbnailDestination = "img/file-images/thumbnail/"; $imageUploader->resize($fileLocation, 200, $thumbnailDestination, $imageName); $_POST['newFileImage'] = $imageName; } else { //Something went wrong $this->totalErrors++; $this->fileImageUpdateError = $imageUploader->errorMessage; } } if ($this->totalErrors == 0) { $result = $this->model->updateFile(); //if result was good if ($result) { $this->fileUpdateSuccess = 'Successfully updated your file'; } else { $this->fileUpdateFail = 'File not updated'; } } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for report_style_id field // $editor = new TextEdit('report_style_id_edit'); $editColumn = new CustomEditColumn('Report Style Id', 'report_style_id', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for type field // $editor = new TextEdit('type_edit'); $editor->SetSize(6); $editor->SetMaxLength(6); $editColumn = new CustomEditColumn('Type', 'type', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for field field // $editor = new TextEdit('field_edit'); $editColumn = new CustomEditColumn('Field', 'field', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for group field // $editor = new TextEdit('group_edit'); $editColumn = new CustomEditColumn('Group', 'group', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for style_str field // $editor = new ImageUploader('style_str_edit'); $editor->SetShowImage(false); $editColumn = new FileUploadingColumn('Style Str', 'style_str', $editor, $this->dataset, false, false, 'GE_webreport_styleGrid_style_str_handler_insert'); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for uniq field // $editor = new TextEdit('uniq_edit'); $editColumn = new CustomEditColumn('Uniq', 'uniq', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for repname field // $editor = new TextAreaEdit('repname_edit', 50, 8); $editColumn = new CustomEditColumn('Repname', 'repname', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for styletype field // $editor = new TextEdit('styletype_edit'); $editor->SetSize(40); $editor->SetMaxLength(40); $editColumn = new CustomEditColumn('Styletype', 'styletype', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
public function renderDeleteImage($id) { $item = $this->context->moduleCarouselBootstrap3Model->find($id); $this->loadModule($item->page_page_modules_id); // delete image $imageUploader = new \ImageUploader(array(), "module" . $this->moduleName . "/" . $this->module->page_id); $imageUploader->deleteImage($item->image); // delete item from db $item->update(array('image' => NULL)); $this->flashMessage('Obrázek byl smazán.'); $this->redirect($this->module->class_name . ':edit', array('id' => $item->id, 'parent_page_id' => $this->params['parent_page_id'])); }
private function processAddStaff() { $this->firstName = trim($_POST['first-name']); $this->lastName = trim($_POST['last-name']); $this->jobTitle = trim($_POST['job-title']); $this->bio = trim($_POST['bio']); // Validate the form to make sure the user has provided all the appropriate fields if (strlen($this->firstName) < 2) { $this->firstNameError = 'First name needs to be at least 2 characters.'; } elseif (strlen($this->firstName > 20)) { $this->firstNameError = 'First name is limited to 20 characters.'; } elseif (!preg_match('/^[\\w.\\-\\s]{2,20}$/', $this->firstName)) { $this->firstNameError = 'First Name is limited to letters, hyphens and fullstops.'; } if (strlen($this->lastName) < 2) { $this->lastNameError = 'Last name needs to be at least 2 characters.'; } elseif (strlen($this->lastName > 20)) { $this->lastNameError = 'Last name is limited to 20 characters.'; } elseif (!preg_match('/^[\\w.\\-\\s]{2,20}$/', $this->lastName)) { $this->lastNameError = 'Last Name can only include letters, hyphens & fullstops.'; } if (strlen($this->jobTitle == '')) { $this->jobTitleError = 'Job Title is required'; } elseif (strlen($this->jobTitle) > 30) { $this->jobTitleError = 'Job title is limited to 30 characters'; } elseif (!preg_match('/^[\\w\\- \\.]{2,30}$/', $this->jobTitle)) { $this->jobTitleError = 'Job Title can only include letters, hyphens & fullstops'; } if (strlen($this->bio > 200)) { $this->bioError = 'Bio is limited to 200 characters. You have ' . (strlen($this->bio) - 200); } elseif (!preg_match('/^[\\w\\s\\-\\.]{2,200}$/', $this->bio)) { $this->bioError = 'Bio can only include letters, hyphens & fullstops'; } // Make life easier $file = $_FILES['profile-image']; $imageName = $file['name']; // if the user has not provided an image // first brackets['source']second brackets['What field we want'] if ($imageName == '') { $this->profileImageError = 'Required'; } elseif ($this->firstNameError == '' && $this->lastNameError == '' && $this->jobTitleError == '' && $this->bioError == '') { // require the image upload class require 'vendor/ImageUploader.php'; // Instantiate the class $imageUploader = new ImageUploader(); // Mkae new filename based oon the staff members name $fileName = $this->firstName . '-' . $this->lastName; // Upload the image and make sure all went well $result = $imageUploader->upload('profile-image', 'img/staff/original/', $fileName); // If something went wrong if (!$result) { $this->profileImageError = $imageUploader->errorMessage; } else { $newImage = $imageUploader->getImageName(); $imageUploader->resizeImage('img/staff/original/' . $newImage, 320, 'img/staff/thumbnails/', $newImage); } // If there are no errors then insert a new staff member if ($this->profileImageError == '') { $result = $this->model->addNewStaff($newImage); // if success if ($result) { $this->staffSuccessMessage = 'Success'; } else { $this->staffErrorMessage = 'Something went wrong in the Database'; } } } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for username field // $editor = new TextEdit('username_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('Username', 'username', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for email field // $editor = new TextEdit('email_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('Email', 'email', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for password field // $editor = new TextEdit('password_edit'); $editor->SetPasswordMode(true); $editColumn = new CustomEditColumn('Password', 'password', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for dept_id field // $editor = new ComboBox('dept_id_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset(new MyConnectionFactory(), GetConnectionOptions(), '`department`'); $field = new IntegerField('DEPT_ID', null, null, true); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('DEPARTMENT'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('MANAGER'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('DIRECTOR'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new StringField('LOCATION'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new StringField('PHONE_NO'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->SetOrderBy('DEPARTMENT', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn('Department', 'dept_id', $editor, $this->dataset, 'DEPT_ID', 'DEPARTMENT', $lookupDataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for position field // $editor = new TextEdit('position_edit'); $editor->SetSize(50); $editor->SetMaxLength(50); $editColumn = new CustomEditColumn('Position', 'position', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for emp_number field // $editor = new TextEdit('emp_number_edit'); $editor->SetSize(20); $editor->SetMaxLength(20); $editColumn = new CustomEditColumn('Employee No', 'emp_number', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for picture field // $editor = new ImageUploader('picture_edit'); $editor->SetShowImage(true); $editColumn = new UploadFileToFolderColumn('Picture', 'picture', $editor, $this->dataset, false, false, 'images'); $editColumn->OnCustomFileName->AddListener('picture_GenerateFileName_insert', $this); $editColumn->SetReplaceUploadedFileIfExist(true); $editColumn->SetGenerationImageThumbnails('picture', 'images', Delegate::CreateFromMethod($this, 'picture_Thumbnail_GenerateFileName_insert'), new ImageFitByHeightResizeFilter(100)); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for rpt_id field // $editor = new TextEdit('rpt_id_edit'); $editColumn = new CustomEditColumn('Rpt Id', 'rpt_id', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_name field // $editor = new TextEdit('rpt_name_edit'); $editor->SetSize(100); $editor->SetMaxLength(100); $editColumn = new CustomEditColumn('Rpt Name', 'rpt_name', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_title field // $editor = new TextAreaEdit('rpt_title_edit', 50, 8); $editColumn = new CustomEditColumn('Rpt Title', 'rpt_title', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_cdate field // $editor = new DateTimeEdit('rpt_cdate_edit', false, 'Y-m-d H:i:s', GetFirstDayOfWeek()); $editColumn = new CustomEditColumn('Rpt Cdate', 'rpt_cdate', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_mdate field // $editor = new DateTimeEdit('rpt_mdate_edit', false, 'Y-m-d H:i:s', GetFirstDayOfWeek()); $editColumn = new CustomEditColumn('Rpt Mdate', 'rpt_mdate', $editor, $this->dataset); $editColumn->SetAllowSetToNull(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_content field // $editor = new ImageUploader('rpt_content_edit'); $editor->SetShowImage(false); $editColumn = new FileUploadingColumn('Rpt Content', 'rpt_content', $editor, $this->dataset, false, false, 'GE_webreportsGrid_rpt_content_handler_insert'); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_owner field // $editor = new TextEdit('rpt_owner_edit'); $editor->SetSize(100); $editor->SetMaxLength(100); $editColumn = new CustomEditColumn('Rpt Owner', 'rpt_owner', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_status field // $editor = new TextEdit('rpt_status_edit'); $editor->SetSize(10); $editor->SetMaxLength(10); $editColumn = new CustomEditColumn('Rpt Status', 'rpt_status', $editor, $this->dataset); $editColumn->SetAllowSetToDefault(true); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for rpt_type field // $editor = new TextEdit('rpt_type_edit'); $editor->SetSize(10); $editor->SetMaxLength(10); $editColumn = new CustomEditColumn('Rpt Type', 'rpt_type', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
<?php require "../src/ImageUploader.php"; try { $imageUploader = new ImageUploader("../upload", "random_salt"); // An optional custom callback to process the uploaded image using GD library $img_filter = IMG_FILTER_GRAYSCALE; $custom_callback = function (&$image) use($img_filter) { imagefilter($image, $img_filter); }; $res = $imageUploader->upload($_FILES["my_image"], "my_id", $custom_callback); var_dump($res); } catch (Exception $e) { var_dump($e); }
public function edit($id = null) { $this->set('title_for_layout', ' Edit Author'); $success_message = ''; if ($this->request->isPost()) { if (isset($this->data['cancel'])) { $this->redirect(ADMIN_ROOT_URL . 'adminauthor/index'); return; } if (isset($this->data['editauthor'])) { if (isset($this->params['form']['image']['name']) && !empty($this->params['form']['image']['name'])) { $new_name = $this->params['form']['image']['name']; $uploader = new ImageUploader(IMAGE_UPLOAD_PATH_AUTHOR, $this->params['form']['image'], $id, $this->img_check_pattern); $upload_result = $uploader->upload(); if (!$upload_result) { $upload_image_err = $uploader->get_error_message(); $msg = "You can not upload images。"; $this->set('errors_image', $upload_image_err); } else { $img = $id . '.' . $this->img_check_pattern['ext']; $this->Author->save(array('id_author' => $id, 'img' => $img)); } } $this->Author->save(array('id_author' => $id, 'name' => $this->request->data('name'), 'biography' => $this->request->data('biography'))); $success_message = 'Update succeed。'; $this->Session->setFlash(GlobalVar::get_html_success($success_message)); } } $authorupdate = $this->Author->find('first', array('conditions' => array('id_author' => $id))); $this->set('Author', $authorupdate); }
<?php if (isset($_REQUEST['targetPath']) && strlen($_REQUEST['targetPath']) > 0) { $dbInsTbl = ""; $dbInsCol = ""; $dbInsId = ""; $prefix = ""; if (isset($_REQUEST['filePrefix']) && strlen($_REQUEST['filePrefix']) > 0) { $prefix = $_REQUEST['filePrefix']; } if (isset($_REQUEST['DbInsertTable']) && strlen($_REQUEST['DbInsertTable']) > 0 && isset($_REQUEST['DbInsertCol']) && strlen($_REQUEST['DbInsertCol']) > 0 && isset($_REQUEST['DbInsertId']) && strlen($_REQUEST['DbInsertId']) > 0) { $dbInsTbl = $_REQUEST['DbInsertTable']; $dbInsCol = $_REQUEST['DbInsertCol']; $dbInsId = $_REQUEST['DbInsertId']; } $imgUploader = new ImageUploader($_REQUEST['targetPath'], $prefix, $dbInsTbl, $dbInsCol, $dbInsId); $imgUploader->show(); }
private function saveMainImage($product_id) { $files = $this->request->getFiles(); if ($files["main_image"]) { if (0 === $files["main_image"]->error) { $imageUploader = new \ImageUploader($files, "module" . $this->moduleName . "/" . $this->module->id . "/" . $product_id, true, true); $uploadedImages = $imageUploader->startUpload(); $this->createAdditionalThumbnail($uploadedImages[0]["name"], $uploadedImages[0]["extension"], $product_id); if (true === isset($uploadedImages[0]["error"])) { $this->flashMessage("Error '" . $uploadedImages[0]["error"] . "' while uploading file '" . $uploadedImages[0]["original"] . "'."); } else { $data["product_id"] = $product_id; $data["filename"] = $uploadedImages[0]["name"]; $data["file_extension"] = $uploadedImages[0]["extension"]; $this->db->insertMainImage($data); } } } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for FOTO_ID field // $editor = new TextEdit('foto_id_edit'); $editColumn = new CustomEditColumn('FOTO ID', 'FOTO_ID', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for RUTA field // $editor = new ImageUploader('ruta_edit'); $editor->SetShowImage(false); $editColumn = new FileUploadingColumn('RUTA', 'RUTA', $editor, $this->dataset, false, false, 'GE_FOTOGrid_RUTA_handler_insert'); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for USERNAME field // $editor = new ComboBox('username_edit', $this->GetLocalizerCaptions()->GetMessageString('PleaseSelect')); $lookupDataset = new TableDataset(new OracleConnectionFactory(), GetConnectionOptions(), '"GE"."PERSONA"'); $field = new StringField('USERNAME'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, true); $field = new StringField('ES_ADMIN'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new DateField('NACIMIENTO'); $lookupDataset->AddField($field, false); $field = new StringField('PRIMER_APELLIDO'); $lookupDataset->AddField($field, false); $field = new StringField('SEGUNDO_APELLIDO'); $lookupDataset->AddField($field, false); $field = new StringField('NOMBRE'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new IntegerField('GENERO_ID'); $lookupDataset->AddField($field, false); $field = new IntegerField('CIUDAD_ID'); $lookupDataset->AddField($field, false); $field = new StringField('SLOGAN'); $lookupDataset->AddField($field, false); $field = new DateField('FEC_CREACION'); $lookupDataset->AddField($field, false); $field = new StringField('USUARIO_CREACION'); $lookupDataset->AddField($field, false); $field = new DateField('FEC_ULTIMA_MOD'); $lookupDataset->AddField($field, false); $field = new StringField('USUARIO_ULTIMA_MOD'); $lookupDataset->AddField($field, false); $field = new StringField('EMAIL'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $field = new StringField('CLAVE'); $field->SetIsNotNull(true); $lookupDataset->AddField($field, false); $lookupDataset->SetOrderBy('ES_ADMIN', GetOrderTypeAsSQL(otAscending)); $editColumn = new LookUpEditColumn('USERNAME', 'USERNAME', $editor, $this->dataset, 'USERNAME', 'ES_ADMIN', $lookupDataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); // // Edit column for TITULO field // $editor = new TextEdit('titulo_edit'); $editor->SetSize(40); $editor->SetMaxLength(40); $editColumn = new CustomEditColumn('TITULO', 'TITULO', $editor, $this->dataset); $validator = new RequiredValidator(StringUtils::Format($this->GetLocalizerCaptions()->GetMessageString('RequiredValidationMessage'), $this->RenderText($editColumn->GetCaption()))); $editor->GetValidatorCollection()->AddValidator($validator); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }
private function processAdditionalInfo() { // Validation if (strlen($_POST['first-name']) < 2) { $this->userFirstNameError = 'Needs to be at least 2 characters.'; $this->totalErrors++; } elseif (strlen($_POST['first-name']) > 20) { $this->userFirstNameError = 'Needs to be at most 20 characters.'; $this->totalErrors++; } elseif (!preg_match('/^[a-zA-Z \\-]{2,20}$/', $_POST['first-name'])) { $this->userFirstNameError = 'Can only use characters of the alphabet, spaces and hyphens.'; $this->totalErrors++; } if (strlen($_POST['last-name']) < 2) { $this->userLastNameError = 'Needs to be at least 2 characters.'; $this->totalErrors++; } elseif (strlen($_POST['last-name']) > 20) { $this->userLastNameError = 'Needs to be at most 20 characters.'; $this->totalErrors++; } elseif (!preg_match('/^[a-zA-Z \\-]{2,20}$/', $_POST['last-name'])) { $this->userLastNameError = 'Can only use characters of the alphabet, spaces and hyphens.'; $this->totalErrors++; } if (strlen($_POST['last-name']) > 2000) { $this->userBioError = 'Needs to be at most 2000 characters.'; $this->totalErrors++; } // Attemp to upload the image if ($this->totalErrors == 0 && isset($_FILES['profile-image']) && $_FILES['profile-image']['name'] != '') { //require image uploader require 'vendor/ImageUploader.php'; // Create an instance $imageUploader = new ImageUploader(); // Attemp to upload the file $result = $imageUploader->upload('profile-image', 'img/profile-images/original/'); // If the upload was a success if ($result) { // Get the file name $imageName = $imageUploader->getImageName(); // Prepare the variables $fileLocation = "img/profile-images/original/{$imageName}"; $fileDestination = "img/profile-images/avatar/"; // Make the avatar version $imageUploader->resize($fileLocation, 320, $fileDestination, $imageName); // Make icons $fileDestination = "img/profile-images/icon/"; $imageUploader->resize($fileLocation, 32, $fileDestination, $imageName); $_POST['newUserImage'] = $imageName; } else { // Something went wrong $this->userImageError = $imageUploader->errorMessage; $this->totalErrors++; } } elseif (isset($_FILES['profile-image']) && $_FILES['profile-image']['name'] == '') { $_POST['newUserImage'] = 'default.png'; } if ($this->totalErrors == 0) { $result = $this->model->additionalInfo(); //If the result was good if ($result) { $this->userSuccess = 'Account has been updated'; } else { $this->userFail = 'You have entered the same information'; } } }
protected function AddInsertColumns(Grid $grid) { // // Edit column for image field // $editor = new ImageUploader('image_edit'); $editor->SetShowImage(true); $editColumn = new UploadFileToFolderColumn('Image', 'image', $editor, $this->dataset, false, false, 'ckupload'); $editColumn->OnCustomFileName->AddListener('image_GenerateFileName_insert', $this); $editColumn->SetReplaceUploadedFileIfExist(true); $this->ApplyCommonColumnEditProperties($editColumn); $grid->AddInsertColumn($editColumn); if ($this->GetSecurityInfo()->HasAddGrant()) { $grid->SetShowAddButton(true); $grid->SetShowInlineAddButton(false); } else { $grid->SetShowInlineAddButton(false); $grid->SetShowAddButton(false); } }