Exemplo n.º 1
0
 /** This method is called when all files are uploaded
  * Will remove any uploaded file which isn't a real picture type
  */
 public function pictureOrRemoveIt()
 {
     $arrFiles = MyFiles::filesFromDir($this->path->tmp);
     foreach ($arrFiles as $file) {
         $file_info = getimagesize($this->path->tmp . $file);
         if (empty($file_info)) {
             MyFiles::deleteFile($this->path->tmp, $file);
         }
     }
     return;
 }
Exemplo n.º 2
0
 public function deleteImage()
 {
     if (!$this->levelAccess || !isset($_POST['gImg'])) {
         return;
     }
     $folds = array($this->path->original, $this->path->images, $this->path->thumbnails);
     $allDeletedSuccessfully = true;
     $imgs = explode(',', $_POST['gImg']);
     foreach ($imgs as $filename) {
         $newOrder = array();
         $newInfo = array();
         foreach ($this->imgsOrder as $fName) {
             if ($fName !== $filename) {
                 $newOrder[] = $fName;
                 $newInfo[$fName] = $this->imgsInfo[$fName];
             }
         }
         foreach ($folds as $folder) {
             if (!MyFiles::deleteFile($folder, $filename)) {
                 $allDeletedSuccessfully = false;
             }
         }
         if ($allDeletedSuccessfully) {
             self::updateImgsOrder($newOrder);
             self::updateImgsInfo($newInfo);
         }
         //remove cover image if original has been deletes
         if (in_array($this->album->cover, $imgs)) {
             $album = $this->album;
             $album->cover = '';
             $album->save();
         }
     }
 }
Exemplo n.º 3
0
 /**
  * This method delete a picture from gallery.
  * First, remove from db, then from hard
  * If successfully remove, will reload new order in $this->imgsOrder
  */
 public function deleteImage()
 {
     $folds = array($this->originalPath, $this->imgsPath, $this->thPath);
     $allDeletedSuccessfully = true;
     $pImg = $_POST['gImg'];
     $newOrder = array();
     foreach ($this->imgsOrder as $fName => $title) {
         if ($fName !== $pImg) {
             $newOrder[$fName] = $title;
         }
     }
     foreach ($folds as $folder) {
         if (!MyFiles::deleteFile($folder, $pImg)) {
             $allDeletedSuccessfully = false;
         }
     }
     if ($allDeletedSuccessfully) {
         $this->updateOrder($newOrder);
     }
 }