public function AddGallerySave() { $array_value = array('img' => Input::file('image')); $array_check = array('img' => array('required', 'mimes:png,gif,jpg,jpeg')); $validator = Validator::make($array_value, $array_check); if ($validator->fails()) { $error = $validator->messages()->toArray(); $gallery = Gallery::all(); return View::make('admin.gallery.gallery')->with('gallery_img', $gallery)->with('error_gallery', $error); } else { $path = 'uploadgallery'; $type = Input::file('image')->getClientOriginalExtension(); $imgName = rand(1111111, 9999999) . time() . "." . $type; $upload = Input::file('image')->move($path, $imgName); if ($upload) { $gallery = new Gallery(); $gallery->img = $imgName; $gallery->save(); if ($gallery->save()) { $gallery = Gallery::all(); return View::make('admin.gallery.gallery')->with('gallery_img', $gallery)->with('gallery_ok', ''); } } } }
public function add_gallery() { $this->_checkPermission(); $data = $_POST['gallery']; Flash::set('postdata', $data); $image = $_POST['upload']; $path = str_replace('..', '', $image['path']); $overwrite = false; // verification // if (empty($data['title'])){ // Flash::set('error', __('You have to specify a gallery name!')); // redirect(get_url('gallery/create')); // } // if (empty($data['url'])){ // Flash::set('error', __('You have to specify the URL!')); // redirect(get_url('gallery/create')); // } if (isset($_FILES)) { // no image file selected if (empty($_FILES['upload_file']['name'])) { Flash::set('error', __('You have to select a image to be uploaded!')); redirect(get_url('gallery/create')); } } else { Flash::set('error', __('You have to select a image to be uploaded!')); redirect(get_url('gallery/create')); } $gallery = new Gallery($data); $gallery->created_by_id = AuthUser::getId(); $gallery->created_on = date('Y-m-d H:i:s'); if (!$gallery->save()) { Flash::set('error', __('Gallery is not added!')); redirect(get_url('gallery/create')); } else { if (isset($_FILES)) { $gallery_id = $gallery->lastInsertId(); $file = $this->upload_file($_FILES['upload_file']['name'], FILES_DIR . '/gallery/images/', $_FILES['upload_file']['tmp_name'], $overwrite, $gallery_id); if ($file === false) { Flash::set('error', __('Gallery image has not been uploaded!')); } //Add Image to database $data = $_POST['gallery']; Flash::set('post_data', (object) $data); $gallery = Record::findByIdFrom('Gallery', $gallery_id); if (!$gallery->update('Gallery', array('filename' => $file), 'id=' . $gallery_id)) { Flash::set('error', __('Image has not been updated.')); } else { Flash::set('success', __('Gallery has been updated!')); if (isset($_POST['commit'])) { redirect(get_url('gallery')); } else { redirect(get_url('gallery/view/' . $gallery->id)); } } } Flash::set('success', __('Gallery has been added!')); } redirect(get_url('gallery')); }
/** * Создает новую модель галереи. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Gallery(); if (($data = Yii::app()->getRequest()->getPost('Gallery')) !== null) { $model->setAttributes($data); if ($model->save()) { Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('GalleryModule.gallery', 'Record was created')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create'])); } } $this->render('create', ['model' => $model]); }
public function testFilterGalleryAttributesFromMetaFieldsWhenSaves() { $attributes = ['post_content' => 'Dummy Content.', 'post_title' => 'Dummy Title', 'post_date' => date('Y-m-d H:i:s'), 'pal_user_id' => 1, 'pal_gallery_id' => 1]; $gallery = new Gallery($attributes); $gallery->save(); $attributes = $gallery->getAttributes(); assertThat($attributes, hasKey('post_content')); assertThat($attributes, hasKey('post_title')); assertThat($attributes, hasKey('post_date')); assertThat($attributes, not(hasKey('pal_user_id'))); assertThat($attributes, not(hasKey('pal_gallery_id'))); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Gallery(); if (isset($_POST['Gallery'])) { $model->attributes = $_POST['Gallery']; $model->user_id = Yii::app()->getUser()->getId(); if ($model->save()) { Yii::app()->user->setFlash('success', '创建成功'); $this->redirect(array('update', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Gallery(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Gallery'])) { $model->attributes = $_POST['Gallery']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** Will create new gallery after save if no associated gallery exists */ public function beforeSave($event) { parent::beforeSave($event); if ($event->isValid) { if (empty($this->getOwner()->{$this->idAttribute})) { $gallery = new Gallery(); $gallery->name = $this->name; $gallery->description = $this->description; $gallery->versions = $this->versions; $gallery->save(); $this->getOwner()->{$this->idAttribute} = $gallery->id; } } }
/** * Создает новую модель галереи. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Gallery(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (($data = Yii::app()->getRequest()->getPost('Gallery')) !== null) { $model->setAttributes($data); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('GalleryModule.gallery', 'Record was created')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', array('create'))); } } $this->render('create', array('model' => $model)); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $photos = Input::file('photo'); foreach ($photos as $photo) { $gallery = new Gallery(); $gallery->school_id = $id; $gallery->photo = $photo; try { $gallery->save(); } catch (Exception $exc) { return Response::make($exc->getMessage(), 500); } } }
function save_orderlist($id = FALSE) { if ($_POST) { foreach ($_POST['orderlist'] as $key => $item) { if ($item) { $gallery = new Gallery(@$_POST['orderid'][$key]); $gallery->from_array(array('orderlist' => $item)); $gallery->save(); } } set_notify('success', lang('save_data_complete')); } redirect($_SERVER['HTTP_REFERER']); }
public static function LoadGallery($id) { $id = _xls_number_only($id); if ($id > 1000) { $id = 1000; } $gallery = Gallery::model()->findByPk($id); if (!$gallery) { $gallery = new Gallery(); $gallery->id = $id; $gallery->name = true; $gallery->description = true; $gallery->versions = array('small' => array('resize' => array(200, null)), 'medium' => array('resize' => array(800, null))); $gallery->save(); } return $gallery; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Gallery(); $photos = new GalleryPhoto(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Gallery'])) { $model->attributes = $_POST['Gallery']; if ($photoCover = $model->getCover()) { $model->cover_photo_id = $photoCover->id; } if ($model->save()) { $this->redirect(array('update?id=' . $model->id)); } } $this->render('create', array('model' => $model, 'photos' => $photos)); }
/** * Creates our gallery when POSTed to. Performs snazzy validation. * @return [type] [description] */ public function post_create() { $rules = array('title' => 'required|max:255'); $validation = Validator::make(Input::all(), $rules); if ($validation->fails()) { Messages::add('error', $validation->errors->all()); return Redirect::to('admin/' . $this->views . '/create')->with_input(); } else { $gallery = new Gallery(); $gallery->title = Input::get('title'); $gallery->description = Input::get('description'); $gallery->created_by = $this->data['user']->id; $gallery->save(); Messages::add('success', 'Gallery Added'); return Redirect::to('admin/' . $this->views . ''); } }
function save($cat_id, $id = FALSE) { if ($_POST) { $gallery = new Gallery($id); if ($_FILES['image']['name']) { if ($gallery->id) { $gallery->delete_file($gallery->id, 'uploads/galleries/', 'image'); } $_POST['image'] = $gallery->upload($_FILES['image'], 'uploads/galleries/'); $gallery->thumb('uploads/galleries/thumbs/', 170, 120); } $_POST['user_id'] = $this->session->userdata('id'); $gallery->from_array($_POST); $gallery->save(); set_notify('success', lang('save_data_complete')); } redirect('galleries/admin/galleries/form/' . $cat_id); }
public function post_create() { $new_gallery = array('title' => trim(Input::get('title')), 'slug' => trim(Input::get('slug')), 'visibility' => trim(Input::get('visible'))); // set up rules for new data $rules = array('title' => 'required|min:3|max:128', 'slug' => 'unique:galleries,slug'); // make the validator $v = Validator::make($new_gallery, $rules); if ($v->fails()) { // redirect to form // errors return Redirect::to('user/galleries/create')->with_errors($v)->with_input(); } // create the new post $gallery = new Gallery($new_gallery); $gallery->save(); // add organisations to Organisation_Post foreach (Input::get('organisations') as $org_id) { $gallery->organisations()->attach($org_id); } // redirect to posts return Redirect::to('user/galleries')->with('success', 'A new gallery has been created'); }
public function postAddNewImage() { $data = Input::only('id', 'name', 'category', 'position', 'updatedby', 'slidefile'); if ($data['id']) { $gallery = Gallery::find($data['id']); } else { $gallery = new Gallery(); } $gallery->name = $data['name']; $gallery->category = $data['category']; $gallery->position = $data['position']; $gallery->updatedby = $data['updatedby']; $file = Input::file('slidefile'); if ($file) { $name = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $newfilename = uniqid(md5(rand(00, 9999) . $name)) . '.' . $extension; $image = Image::make($_FILES['slidefile']['tmp_name'])->resize(900, 700)->save('uploads/' . $newfilename, 100); $gallery->imageurl = 'uploads/' . $newfilename; } $gallery->save(); return Redirect::to('/admin/photogallery/list'); }
/** * Process uploaded images. * Save to gallery. * @param Bulletin $model * @param CUploadedFile[] $images */ public static function processImages($model, $images) { if (isset($images) && count($images) > 0) { // configure and save gallery model $gallery = new Gallery(); $gallery->name = false; $gallery->description = false; $gallery->versions = array('small' => array('resize' => array(150, null)), 'medium' => array('resize' => array(800, null))); $gallery->save(); $model->gallery_id = $gallery->id; $model->save(); // go through each uploaded image foreach ($images as $imageFile) { $galleryPhoto = new GalleryPhoto(); $galleryPhoto->gallery_id = $gallery->id; $galleryPhoto->name = ''; $galleryPhoto->description = ''; $galleryPhoto->file_name = $imageFile->getName(); $galleryPhoto->save(); $galleryPhoto->setImage($imageFile->getTempName()); } } }
public function addPhotoGallery() { $images = Input::file('images'); if (empty($images)) { return Redirect::Route('getFMGallery')->with('fail', 'Please choose a picture to upload.'); } else { $iname = str_random(112) . '.' . $images->getClientOriginalExtension(); $move = Image::make($images->getRealPath())->resize('750', '750')->save('images/' . $iname); if ($move) { $getInformation = new Gallery(); $getInformation['img_file'] = $iname; if ($getInformation->save()) { return Redirect::Route('getFMGallery')->with('success', 'Image successfully added.'); } } else { return Redirect::Route('getFMGallery')->with('fail', 'Error Uploading! Please try again.'); } } }
function upload_file($origin, $dest, $tmp_name, $overwrite = false, $aid, $imgtype = "portrait", $imgwidth, $imgheight) { FileManagerController::_checkPermission(); $origin = basename($origin); $full_dest = $dest . $origin; $file_name = $origin; for ($i = 1; file_exists($full_dest); $i++) { if ($overwrite) { unlink($full_dest); continue; } $file_ext = strpos($origin, '.') === false ? '' : '.' . substr(strrchr($origin, '.'), 1); $file_name = substr($origin, 0, strlen($origin) - strlen($file_ext)) . '_' . $i . $file_ext; $full_dest = $dest . $file_name; } // create new directory if (mkdir($dest)) { chmod($dest, 0777); } $file_name = str_replace(' ', '_', $file_name); if (move_uploaded_file($tmp_name, $full_dest)) { //Resized thumbnail w=767 for gallery thumb $thumb_file_name = '767x575_' . $file_name; if ($imgtype == "landscape") { $thumb_url = URL_PUBLIC . 'wolfimage?src=public/gallery/images/' . $aid . '/' . $file_name . '&h=575'; } else { $thumb_url = URL_PUBLIC . 'wolfimage?src=public/gallery/images/' . $aid . '/' . $file_name . '&w=767'; } $thumb_image = FILES_DIR . '/gallery/images/' . $aid . '/' . $thumb_file_name; if (file_put_contents($thumb_image, file_get_contents($thumb_url))) { //Crop resized thumbnail for w=767 for gallery thumb $thumb_url_crop = URL_PUBLIC . 'wolfimage?src=public/gallery/images/' . $aid . '/' . $thumb_file_name . '&w=767&h=575&c=c'; $thumb_image_crop = FILES_DIR . '/gallery/images/' . $aid . '/' . $thumb_file_name; file_put_contents($thumb_image_crop, file_get_contents($thumb_url_crop)); } //Add Image to database $data = $_POST['gallery']; Flash::set('post_data', (object) $data); $oGallery = new Gallery(); $last_seq = $oGallery->getLastGallerySeq($aid); $gallery = new Gallery($data); $gallery->filename = $file_name; $gallery->sequence = $last_seq + 1; if (!$gallery->save()) { Flash::set('error', __('Image could not be added!')); redirect(get_url('gallery')); } else { Flash::set('success', __('Image has been added.')); } // change mode of the dire to 0644 by default chmod($full_dest, 0644); return $file_name; } return false; }
public function postImageGallery($type_id, $post_id, $image_id = 'add') { $all = Input::all(); if ($image_id == 'add') { $rules = array('image' => 'required'); $validator = Validator::make($all, $rules); if ($validator->fails()) { return Redirect::to('/admin/content/' . $type_id . '/' . $post_id . '/#image-' . $image_id)->withErrors($validator)->withInput()->with('error-img' . $image_id, 'Ошибка'); } } if (!is_numeric($post_id)) { return false; } if (is_numeric($image_id)) { $post = Gallery::find($image_id); } else { $post = new Gallery(); $post->post_id = $post_id; } $post->text = $all['text']; $post->alt = $all['alt']; if (!empty($all['image'])) { $path = 'upload/gallery/' . $post_id . '/'; $filename = AdminController::saveImage($all['image'], $path, 250); $post->image = $path . $filename; $post->small_image = $path . 'small/' . $filename; } $post->save(); return Redirect::to('/admin/content/' . $type_id . '/' . $post_id . '/#image-' . $image_id)->with('success-img' . $image_id, 'Изменения сохранены'); }
function galleryUpdateDes() { $gid = isset($_POST['gid']) ? addslashes($_POST['gid']) : 0; if ($gid == 0) { die('No ID'); } $newname = trim(rtrim(isset($_POST['newname']) ? addslashes($_POST['newname']) : '0')); if ($newname == '0') { die('No ID'); } if ($newname == "Click here to enter description") { die('No Update'); } $gal = new Gallery(); $gal->getByID($gid); $gal->gallery_description = trim(rtrim($newname)); $gal->load = 1; $gal->save(); }
/** * [createPhoto function used to upload photo into user's dashboard and save it into database and move it into photogallery folder] * @return message [confirms that he/she added a photo] */ public function createPhoto() { $id = Auth::id(); $profileimg1 = Input::file('img'); $Uploadcount = count($profileimg1); // echo "<pre>"; // print_r($Uploadcount); // exit; $count = 0; foreach ($profileimg1 as $profileimg) { $gallery = new Gallery(); $gallery->user_id = $id; if ($profileimg) { $gallery->photo = $profileimg->getClientOriginalName(); $gallery->save(); if ($profileimg->isValid()) { $profileimg->move(public_path('photogallery'), $id . " " . $profileimg->getClientOriginalName()); $message = "Uploaded Successfully"; } } else { $message = "Please Upload Your Photo"; } $count++; } if ($count == $Uploadcount) { return Redirect::to('users/dashboard')->with('message', $message); } }
/** * SkeliCZ - Enter new addrese into database * * @package SkeliCZ * @author Vitex <*****@*****.**> * @copyright 2009-2016 info@vitexsoftware.cz (G) */ namespace SkeliCZ; require_once 'includes/SkeliInit.php'; $oPage->onlyForAdmin(); $gallerist = new Gallery(); if ($oPage->isPosted()) { $gallerist->setDataValue($gallerist->nameColumn, $oPage->getRequsetValue('title')); if ($gallerist->getDataValue('title')) { $imgId = $gallerist->save(); } $uploaddir = 'images/gallery'; $uploadfile = $uploaddir . basename($_FILES['picture']['name']); if (move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } } $oPage->addItem(new PageTop(_('Editor'))); $gtabs = new \Ease\TWB\Tabs('Gtabs'); $gtabs->addTab(_('Gallery')); $newPicForm = new \Ease\TWB\Form('NewPic'); $newPicForm->addInput(new \Ease\Html\InputTextTag('title'), _('Title')); $newPicForm->addInput(new \Ease\Html\InputFileTag('picture'), _('Picture')); $newPicForm->addInput(new \Ease\Html\InputTextTag('note'), _('Note')); $gtabs->addTab(_('New Picture'), new \Ease\TWB\Panel(_('New Picture'), 'success', $newPicForm));
function galleryUseCarousel() { $gid = isset($_GET['gid']) ? addslashes($_GET['gid']) : '0'; if ($gid == '0') { die("Please provide ID"); } $ck = isset($_GET['ck']) ? addslashes($_GET['ck']) : '0'; $gal = new Gallery(); $gal->getByID($gid); if ($gal->gallery_carousel) { $gal->gallery_carousel = 0; } else { $gal->gallery_carousel = 1; } $gal->load = 1; if ($gal->save()) { echo $gal->gallery_carousel; } else { echo "no"; } }
public function actionAddimage() { if ($this->access > UserAccessTable::FULL_ACCESS) { return 0; } $fileid = $_POST['fileid']; $propertyid = $property_id = Yii::app()->user->getState('property_id'); $images = $this->getImages(); $index = count($images) + 1; $primary = 0; $model = new Gallery(); $model->setAttributes(array('propertyid' => $propertyid, 'index' => $index, 'primary' => $primary, 'fileid' => $fileid)); $result = $model->save(); $resultData = array(); if ($result) { $resultData = $model->getAttributes(); $resultData['file'] = $model->file->getAttributes(); } echo json_encode(array('result' => $result, 'data' => $resultData)); die; }
/** This method is used to save new order of pictures * @param array $order - array list with order to be saved * Before save, the list is serialized * After save, the new order is loaded as array in $this->imgsOrder */ private function updateOrder($order) { $order = serialize($order); $record = $this->gmodel; if ($record === null) { $record = new Gallery(); $record->pid = $this->pid; $record->imgsOrder = $order; if (!$record->save()) { throw new Exception('FBGallery - ' . Yii::t('app', 'Error: I can\'t save to database!')); } } else { $attributes = array("imgsOrder" => $order); $record->saveAttributes($attributes); } //reload image's order $this->imgsOrder = unserialize($order); }
$mcr_errors = array(); if (isset($_GET['showthumbs'])) { // switch the display selector $how = sanitize($_GET['showthumbs']); setOption('album_tab_default_thumbs_' . (is_object($album) ? $album->name : ''), (int) ($how == 'no')); } if (isset($_GET['action'])) { $action = sanitize($_GET['action']); switch ($action) { /** reorder the tag list ******************************************************/ /******************************************************************************/ case 'savealbumorder': XSRFdefender('savealbumorder'); $gallery->setSortDirection(0); $gallery->setSortType('manual'); $gallery->save(); $notify = postAlbumSort(NULL); if (isset($_POST['ids'])) { $action = processAlbumBulkActions(); if (!empty($action)) { $action = '&bulkmessage=' . $action; } } header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit' . $action . '&saved' . $notify); exit; break; case 'savesubalbumorder': XSRFdefender('savealbumorder'); $album = new Album($gallery, $folder); $album->setSubalbumSortType('manual'); $album->setSortDirection('album', 0);