Example #1
0
 static function photo($database, $plugins, $settings, $path, $albumID = 0, $description = '', $tags = '')
 {
     $info = getimagesize($path);
     $size = filesize($path);
     $photo = new Photo($database, $plugins, $settings, null);
     $nameFile = array(array());
     $nameFile[0]['name'] = $path;
     $nameFile[0]['type'] = $info['mime'];
     $nameFile[0]['tmp_name'] = $path;
     $nameFile[0]['error'] = 0;
     $nameFile[0]['size'] = $size;
     if (!$photo->add($nameFile, $albumID, $description, $tags)) {
         return false;
     }
     return true;
 }
Example #2
0
 static function photo($database, $plugins, $settings, $path, $albumID = 0, $description = '', $tags = '')
 {
     # No need to validate photo type and extension in this function.
     # $photo->add will take care of it.
     $info = getimagesize($path);
     $size = filesize($path);
     $photo = new Photo($database, $plugins, $settings, null);
     $nameFile = array(array());
     $nameFile[0]['name'] = $path;
     $nameFile[0]['type'] = $info['mime'];
     $nameFile[0]['tmp_name'] = $path;
     $nameFile[0]['error'] = 0;
     $nameFile[0]['size'] = $size;
     if (!$photo->add($nameFile, $albumID, $description, $tags)) {
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * Creates an array similar to a file upload array and adds the photo to Lychee.
  * @return boolean Returns true when photo import was successful.
  */
 private function photo($path, $albumID = 0)
 {
     // No need to validate photo type and extension in this function.
     // $photo->add will take care of it.
     $info = getimagesize($path);
     $size = filesize($path);
     $photo = new Photo(null);
     $nameFile = array(array());
     $nameFile[0]['name'] = $path;
     $nameFile[0]['type'] = $info['mime'];
     $nameFile[0]['tmp_name'] = $path;
     $nameFile[0]['error'] = 0;
     $nameFile[0]['size'] = $size;
     $nameFile[0]['error'] = UPLOAD_ERR_OK;
     if ($photo->add($nameFile, $albumID, true) === false) {
         return false;
     }
     return true;
 }
Example #4
0
 private function photo($path, $albumID = 0, $description = '', $tags = '')
 {
     # Check dependencies
     self::dependencies(isset($this->database, $this->plugins, $this->settings, $path));
     # No need to validate photo type and extension in this function.
     # $photo->add will take care of it.
     $info = getimagesize($path);
     $size = filesize($path);
     $photo = new Photo($this->database, $this->plugins, $this->settings, null);
     $nameFile = array(array());
     $nameFile[0]['name'] = $path;
     $nameFile[0]['type'] = $info['mime'];
     $nameFile[0]['tmp_name'] = $path;
     $nameFile[0]['error'] = 0;
     $nameFile[0]['size'] = $size;
     $nameFile[0]['error'] = UPLOAD_ERR_OK;
     if (!$photo->add($nameFile, $albumID, $description, $tags, true)) {
         return false;
     }
     return true;
 }
Example #5
0
 private function upload()
 {
     Module::dependencies(isset($_FILES, $_POST['albumID'], $_POST['tags']));
     $photo = new Photo($this->database, $this->plugins, $this->settings, null);
     echo $photo->add($_FILES, $_POST['albumID'], '', $_POST['tags']);
 }
 /**
  * undocumented function
  *
  * @return void
  * @author 
  **/
 public function store()
 {
     $lokasi = public_path() . '/photos/';
     $validator = $this->storeValid();
     if ($validator->passes()) {
         $input = $this->storeInput();
         $photo = Photo::add($input);
         $file = $_FILES['photo']['tmp_name'];
         // Extension
         $ext = pathinfo($_FILES["photo"]["name"], PATHINFO_EXTENSION);
         if ($photo && move_uploaded_file($_FILES['photo']['tmp_name'], $lokasi . $photo->id . '.' . $ext)) {
             $img = Image::make($lokasi . $photo->id . '.' . $ext);
             if ($ext != 'jpg') {
                 $img->encode('jpg', 75);
                 $img->save($lokasi . $photo->id . '.jpg');
             }
             $img->fit(200);
             $img->save($lokasi . 'thumb_' . $photo->id . '.jpg');
             // Menghapus file lama setelah kita meng-convert-nya ke jpg
             if ($ext != 'jpg') {
                 unlink($lokasi . $photo->id . '.' . $ext);
             }
             return Redirect::route('admin.photo')->withStatuses(['add' => 'Tambah Berhasil!']);
         }
         return Redirect::route('admin.photo.create')->withErrors(['add' => 'Tambah Gagal!'])->withInput();
     }
     return Redirect::route('admin.photo.create')->withErrors($validator)->withInput();
 }