예제 #1
0
 /**
  * LazyestFrontendFolder::thumb_image()
  * 
  * @since 1.1.0
  * @param LazyestThumb $image
  * @return string code for thumbnail image
  */
 function thumb_image($image)
 {
     global $post, $lg_gallery;
     $onclick = $image->on_click();
     $rel = '' != $onclick['rel'] ? 'rel="' . $onclick['rel'] . '"' : '';
     $class = 'thumb';
     if ('TRUE' != $lg_gallery->get_option('enable_cache') || 'TRUE' == $lg_gallery->get_option('async_cache') && !file_exists($image->loc())) {
         $class .= ' lg_ajax';
     }
     $postid = is_object($post) ? $post->ID : $lg_gallery->get_option('gallery_id');
     $anchor_1 = $anchor_2 = '';
     if ('nothing' != $lg_gallery->get_option('on_thumb_click')) {
         $anchor_1 = sprintf('<a id="%s_%s" href="%s" class="%s" %s title="%s" >', $onclick['id'], $postid, $onclick['href'], $onclick['class'], $rel, $onclick['title']);
         $anchor_2 = '</a>';
     }
     return sprintf('<div class="lg_thumb_image">%s<img class="%s" src="%s" alt="%s" />%s</div>', $anchor_1, $class, $image->src(), $image->alt(), $anchor_2);
 }
예제 #2
0
 /**
  * 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;
 }