function search($folder_path = null, $filename_pattern = null) { if (!isset($folder_path)) { $folder_path = $this->_base_path; } if (!isset($filename_pattern)) { $filename_pattern = $this->_file_name_pattern; } $results = parent::search($folder_path, $filename_pattern); foreach ($results as $key => $result_file) { if (is_dir($result_file->getPath()) || !is_writable($result_file->getPath()) || strpos($result_file->get_mimetype(), 'image') === 0) { unset($results[$key]); } } return $results; }
function delete() { if ($image_db_id = $this->db_id()) { require_once 'AMP/Content/Image/Image.php'; $image = new AMP_Content_Image(AMP_Registry::getDbcon(), $image_db_id); $image->delete(); AMP_lookup_clear_cached('images'); AMP_lookup_clear_cached('db_images'); } $image_classes = AMP_lookup('image_classes'); foreach ($image_classes as $class => $class_desc) { $path = AMP_image_path($this->getName(), $class); # delete of current copy handled by parent class below if ($path == $this->getPath()) { continue; } if (file_exists($path)) { unlink($path); } } return parent::delete(); }
function clear($key_token = null) { foreach ($this->_index as $authorized_key => $time_stored) { if (isset($key_token) && strpos($authorized_key, $key_token) === FALSE) { continue; } $this->delete($authorized_key); } $file_set = AMPfile_list($this->_path_cache); $this->_load_file(); foreach ($file_set as $file_name => $file_display) { if (!$file_name) { continue; } if (isset($key_token) && strpos($file_name, $key_token) === FALSE) { continue; } $entry_ref = new AMP_System_File($this->_path($file_name)); if ($entry_ref->getTime() + AMP_SYSTEM_CACHE_TIMEOUT < time()) { $entry_ref->delete(); } } }