/** * LazyestAdminFolder::delete_file() * Deletes a file or cache from the folder * * @return void */ function delete_file() { global $lg_gallery; $delete_this = $_REQUEST['file_to_delete']; $cache = isset($_REQUEST['cache']) ? $_REQUEST['cache'] : ''; $waste_it = $lg_gallery->root . $this->curdir . $delete_this; $message = __('Nothing to delete', 'lazyest-gallery'); if (file_exists($waste_it)) { if (!is_dir($waste_it)) { // delete an image if (!$this->hascopy($delete_this)) { if (isset($lg_gallery->commentor)) { $lg_gallery->commentor->remove_comments($this->curdir . $delete_this); } } $success = @unlink($waste_it); // also delete cache $thumb = new LazyestThumb($this); $thumb->image = $delete_this; $waste_cache = $thumb->loc(); if (file_exists($waste_cache)) { @unlink($waste_cache); } unset($thumb); $slide = new LazyestSlide($this); $slide->image = $delete_this; $waste_cache = $slide->loc(); if (file_exists($waste_cache)) { @unlink($waste_cache); } $message = $success ? sprintf(__(' Image %s deleted successfully', 'lazyest-gallery'), $delete_this) : sprintf(__(' Cannot delete %s, please check your server permissions', 'lazyest-gallery'), $delete_this); } else { // delete cache if ('' != $cache) { $success = $lg_gallery->clear_directory($waste_it); $message = $success ? sprintf(__(' %s cache deleted successfully', 'lazyest-gallery'), $delete_this) : sprintf(__(' Cannot delete %s cache, maybe it has already been deleted or have wrong permissions', 'lazyest-gallery'), $delete_this); } } } else { // file does not exist if ('' != $cache) { // but cache should be deleted $success = true; $message = sprintf(__('%s cache deleted successfully', 'lazyest-gallery'), $delete_this); } else { // file not found. deleted in other session? $success = false; $message = sprintf(__('%s does not exist', 'lazyest-gallery'), $delete_this); } } $lg_gallery->message = $message; $lg_gallery->success = $success; }
/** * LazyestAdmin::rebuild_cache() * Creates thumbs and slides per folder * If thumb/slide exists, don't rebuild * * @param int $i key of folder in _build_folders_array() * @return int next key */ function rebuild_cache($fcount, $icount = 0) { $cache_thumbs = 'TRUE' == $this->get_option('enable_cache'); $cache_slides = 'TRUE' == $this->get_option('enable_slides_cache'); $folder_array = get_transient('lg_rebuild_cache_folders'); if (false === $folder_array) { $folder_array = $this->_build_folders_array(); set_transient('lg_rebuild_cache_folders', $folder_array, 300); } $nfcount = $fcount == 0 ? count($folder_array) : $fcount; if ($nfcount < count($folder_array) + 1) { $file = substr($folder_array[$nfcount - 1], strlen($this->root)); $folder = $folder = new LazyestFolder($file); if ($folder->valid()) { $folder->load(); $i = 0; while ($icount < count($folder->list) && $i < 10) { $image = $folder->list[$icount]; if ($cache_thumbs) { $thumb = new LazyestThumb($folder); $thumb->image = $image->image; $thumb->cache(); unset($thumb); } if ($cache_slides) { $slide = new LazyestSlide($folder); $slide->image = $image->image; $slide->cache(); unset($slide); } $i++; $icount++; } if ($icount == count($folder->list)) { $icount = 0; $nfcount = $nfcount - 1; } } } else { $nfcount = 0; } if ($nfcount == 0) { delete_transient('lg_rebuild_cache_folders'); } return array('folder' => $nfcount, 'image' => $icount); }
/** * LazyestThumb::on_click() * * @param string $widget * @return */ function on_click($widget = 'none') { global $lg_gallery; $onclick = LazyestImage::on_click($widget); $onclick['id'] = 'lg_thumb_onclick_' . $onclick['id']; $slide = new LazyestSlide($this->folder); $slide->image = $this->image; switch ($lg_gallery->get_option('on_thumb_click')) { case 'nothing': $onclick['href'] = '#'; break; case 'fullimg': break; case 'slide': $onclick['href'] = $slide->uri($widget); break; case 'lightslide': $onclick['href'] = $slide->src(); $onclick['rel'] = 'lightbox[' . $this->folder->form_name() . ']'; break; case 'thickslide': $onclick['href'] = $slide->src(); $onclick['class'] = 'thickbox'; $onclick['rel'] = $this->folder->form_name(); case 'lightbox': $onclick['rel'] = 'lightbox[' . $this->folder->form_name() . ']'; break; case 'thickbox': $onclick['class'] = 'thickbox'; $onclick['rel'] = $this->folder->form_name(); break; } unset($slide); $onclick = apply_filters('lazyest_thumb_onclick', $onclick, $this); return $onclick; }