예제 #1
0
 /**
  * @param $ids
  * @param null $fire_events
  * @return mixed
  */
 public function deleteAll($ids, $rid, $fire_events = NULL)
 {
     $_ids = $this->cleanIDs($ids, ',', array(0));
     if (empty($_ids) || is_scalar($_ids)) {
         return false;
     }
     $images = $this->query('SELECT `sg_id`,`sg_image` FROM ' . $this->makeTable($this->table) . ' WHERE `sg_id` IN (' . $this->sanitarIn($_ids) . ')');
     $out = parent::deleteAll($ids, $rid, $fire_events);
     $rows = $this->query("SELECT `template` FROM {$this->makeTable('site_content')} WHERE id={$rid}");
     $template = $this->modx->db->getValue($rows);
     while ($row = $this->modx->db->getRow($images)) {
         $this->deleteThumb($row['sg_image']);
         $this->invokeEvent('OnSimpleGalleryDelete', array('sg_id' => $row['sg_id'], 'filepath' => $this->fs->takeFileDir($row['sg_image']), 'name' => $this->fs->takeFileName($row['sg_image']), 'filename' => $this->fs->takeFileBasename($row['sg_image']), 'ext' => $this->fs->takeFileExt($row['sg_image']), 'mime' => $this->fs->takeFileMIME($row['sg_image']), 'template' => $template, 'sg_rid' => $rid), $fire_events);
     }
     return $out;
 }
예제 #2
0
 /**
  * @param $ids
  * @param null $fire_events
  * @return mixed
  */
 public function deleteAll($ids, $rid, $fire_events = NULL)
 {
     $ids = $this->cleanIDs($ids, ',', array(0));
     if (empty($ids) || is_scalar($ids)) {
         return false;
     }
     $files = $this->query('SELECT `sf_file` FROM ' . $this->makeTable($this->table) . ' WHERE `sf_id` IN (' . $this->sanitarIn($ids) . ')');
     $out = parent::deleteAll($ids, $rid, $fire_events);
     while ($row = $this->modx->db->getRow($files)) {
         $url = $this->fs->relativePath($row['sf_file']);
         if ($this->fs->checkFile($url)) {
             @unlink(MODX_BASE_PATH . $url);
             $dir = $this->fs->takeFileDir($url);
             $iterator = new \FilesystemIterator($dir);
             if (!$iterator->valid()) {
                 $this->fs->rmDir($dir);
             }
         }
     }
     return $out;
 }