コード例 #1
0
 /** Delete an image
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     if ($this->_request->isPost()) {
         $id = (int) $this->_request->getPost('id');
         $del = $this->_request->getPost('del');
         if ($del == 'Yes' && $id > 0) {
             $imagedata = $this->_images->getFileName($id);
             $filename = $imagedata['0']['f'];
             $splitf = explode('.', $filename);
             $spf = $splitf['0'];
             $imagedir = $imagedata['0']['imagedir'];
             $imagenumber = $imagedata['0']['imageID'];
             $zoom = './' . $imagedir . 'zoom/' . $spf . '_zdata';
             $thumb = IMAGE_PATH . 'thumbnails/' . $imagenumber . '.jpg';
             $small = './' . $imagedir . 'small/' . $filename;
             $display = './' . $imagedir . 'display/' . $filename;
             $medium = './' . $imagedir . 'medium/' . $filename;
             $original = './' . $imagedir . $filename;
             $where = 'imageID = ' . $id;
             $this->_images->delete($where);
             $this->_helper->solrUpdater->deleteById('images', $id);
             $linked = new FindsImages();
             $wherelinks = array();
             $wherelinks[] = $linked->getAdapter()->quoteInto('image_id = ?', $imagedata['0']['secuid']);
             $linked->delete($wherelinks);
             $this->getFlash()->addMessage('Image and metadata deleted');
             unlink($thumb);
             unlink($display);
             unlink($small);
             unlink($original);
             unlink($medium);
             unlink(strtolower($thumb));
             unlink(strtolower($display));
             unlink(strtolower($small));
             unlink(strtolower($original));
             unlink(strtolower($medium));
             unlink($zoom);
         }
         $this->redirect('/database/myscheme/myimages/');
     } else {
         $id = (int) $this->_request->getParam('id');
         if ((int) $id > 0) {
             $this->view->slide = $this->_images->fetchRow('imageID =' . $id);
         }
     }
 }