Exemple #1
0
 /**
  * LazyestFrontendFolder::empty_link()
  * echo a link to an image
  * 
  * @since 1.1.0
  * @uses esc_attr() 
  * @param LazyestThumb $image
  * @return void
  */
 function empty_link($image)
 {
     $onclick = $image->on_click();
     $rel = '' != $onclick['rel'] ? 'rel="' . $onclick['rel'] . '"' : '';
     printf('<a id="%s" href="%s" class="%s" %s title="%s"></a>', $onclick['id'], $onclick['href'], $onclick['class'], $rel, esc_attr($image->title()));
 }
Exemple #2
0
    /**
     * LazyestUploadTab::insert_image_shortcode()
     * Form to insert an image shortcode
     * 
     * @param LazyestThumb $image
     * @return void
     */
    function insert_image_shortcode($image)
    {
        if (!$image->valid()) {
            esc_html_e('Error retrieving image', 'lazyest-gallery');
            return;
        }
        $onclick = $image->on_click('widget');
        $onclickhref = $onclick['href'];
        $thumburl = $image->src();
        $filename = $image->image;
        list($width, $height, $type, $attr) = getimagesize($image->original());
        $date = $image->datetime;
        $media_dims = "{$width}&nbsp;x&nbsp;{$height}";
        $caption = htmlspecialchars(stripslashes($image->caption), ENT_QUOTES);
        ?>
    
    <input type="hidden" name="lg_folder" value="<?php 
        echo urlencode($image->folder->curdir);
        ?>
" />
    <input type="hidden" name="lg_image" value="<?php 
        echo urlencode($image->image);
        ?>
" />
    <table class="describe">
  		<thead class="media-item-info" id="media-head-<?php 
        echo $image->id;
        ?>
">
    		<tr valign="top">
    			<td class="A1B1" id="thumbnail-head-<?php 
        echo $image->id;
        ?>
">
    		  	<p><a href="<?php 
        echo $onclickhref;
        ?>
" target="_blank"><img class="thumbnail" src="<?php 
        echo $thumburl;
        ?>
" alt="" style="margin-top: 3px" /></a></p>		
    			</td>
    			<td>
      			<p><strong><?php 
        esc_html_e('File name:', 'lazyest-gallery');
        ?>
</strong> <?php 
        esc_html_e($filename);
        ?>
</p>
      			<p><strong><?php 
        esc_html_e('File type:', 'lazyest-gallery');
        ?>
</strong> <?php 
        echo image_type_to_mime_type($type);
        ?>
</p>
      		  <p><strong><?php 
        esc_html_e('Date:', 'lazyest-gallery');
        ?>
</strong> <?php 
        echo date(get_option("date_format"), $date);
        ?>
</p>
      		  <p><strong><?php 
        esc_html_e('Dimensions:', 'lazyest-gallery');
        ?>
</strong> <?php 
        echo $media_dims;
        ?>
</p>
    		  </td>
        </tr>
        <tr class="post_title form-required">
          <th valign="top" class="label" scope="row">
            <label for="short_code_caption">
              <span class="alignleft"><?php 
        esc_html_e('Caption', 'lazyest-gallery');
        ?>
</span><br class="clear" />
            </label>
          </th>
          <td class="field">
            <input type="text" value="<?php 
        echo $caption;
        ?>
" name="short_code_caption" id="short_code_caption[<?php 
        echo $image->id;
        ?>
]" class="text" />
          </td>        
        </tr> 
        <tr class="align">
          <th valign="top" class="label" scope="row">
            <label for="image_align[<?php 
        echo $image->id;
        ?>
]"><span class="alignleft"><?php 
        esc_html_e('Alignment', 'lazyest-gallery');
        ?>
</span><br class="clear" /></label>
          </th>
          <td class="field">
            <input type="radio" value="" id="image-align-none-<?php 
        echo $image->id;
        ?>
" name="image_align" /><label class="align image-align-none-label" for="image-align-none"><?php 
        esc_html_e('None', 'lazyest-gallery');
        ?>
</label>
            <input type="radio" checked="checked" value="left" id="image-align-left" name="image_align" /><label class="align image-align-left-label" for="image-align-left"><?php 
        esc_html_e('Left', 'lazyest-gallery');
        ?>
</label>
            <input type="radio" value="center" id="image-align-center" name="image_align" /><label class="align image-align-center-label" for="image-align-center"><?php 
        esc_html_e('Center', 'lazyest-gallery');
        ?>
</label>
            <input type="radio" value="right" id="image-align-right" name="image_align" /><label class="align image-align-right-label" for="image-align-right-<?php 
        echo $image->id;
        ?>
"><?php 
        esc_html_e('Right', 'lazyest-gallery');
        ?>
</label>
          </td>
		    </tr> 
        <tr class="image-size">    
          <th valign="top" class="label" scope="row">
            <label for="image-size">
              <span class="alignleft"><?php 
        esc_html_e('Size', 'lazyest-gallery');
        ?>
</span><br class="clear" />
            </label>
          </th>
          <td class="field">
            <div class="image-size-item">
              <input type="radio" checked="checked" value="thumb" id="image-size-thumbnail" name="image-size" />
                <label for="image-size-thumbnail"><?php 
        esc_html_e('Thumbnail', 'lazyest-gallery');
        ?>
</label>
            </div>            
            <div class="image-size-item">
              <input type="radio" value="slide" id="image-size-slide" name="image-size" />
                <label for="image-size-slide"><?php 
        esc_html_e('Slide', 'lazyest-gallery');
        ?>
</label>
            </div>
            <div class="image-size-item">
              <input type="radio" value="image" id="image-size-full" name="image-size" />
                <label for="image-size-full"><?php 
        esc_html_e('Full Size', 'lazyest-gallery');
        ?>
</label>
            </div>
          </td>
		    </tr>
        <tr class="submit">
          <td></td>
          <td>
            <input class="button" type="submit" name="image_short" title="<?php 
        esc_html_e('Insert a Lazyest Gallery shortcode', 'lazyest-gallery');
        ?>
" value="<?php 
        echo __('Insert as shortcode', 'lazyest-gallery');
        ?>
" />
          </td>
        </tr>
  		</thead>
  		<tbody>
      </tbody>
    </table>
    <?php 
    }
Exemple #3
0
 /**
  * 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);
 }
Exemple #4
0
 /**
  * LazyestFolder::icon()
  * returns the folder icon as array icon=>img src class=>img class
  * @since 1.0.0
  * @uses untrailingslashit()
  * @return array
  */
 function icon()
 {
     global $lg_gallery;
     $folder_icon = array();
     if (!$this->user_can('viewer')) {
         $folder_icon['icon'] = $lg_gallery->plugin_url . '/images/folder-na.png';
         $folder_icon['class'] = 'category_icon';
         return $folder_icon;
     }
     $dir_parts = explode('/', untrailingslashit($this->curdir));
     $fil = $dir_parts[count($dir_parts) - 1];
     $default_icon = $lg_gallery->plugin_url . '/images/folder-icon.png';
     $the_icon = $default_icon;
     $folder_icon['class'] = 'icon';
     $exts = array('.gif', '.jpg', '.jpeg', '.png');
     $the_ext = '';
     switch ($lg_gallery->get_option('folder_image')) {
         case 'icon':
             $folder_icon['icon'] = $the_icon;
             $stub = $lg_gallery->root . $this->curdir . $fil;
             $stuba = $lg_gallery->address . $this->curdir . $fil;
             foreach ($exts as $ext) {
                 if (file_exists($stub . $ext)) {
                     $the_ext = $ext;
                 }
                 if (file_exists($stub . strtoupper($ext))) {
                     $the_ext = strtoupper($ext);
                 }
             }
             if ('' != $the_ext) {
                 $thumb = new LazyestThumb($this);
                 $thumb->image = $fil . $the_ext;
                 $folder_icon['icon'] = $thumb->src();
                 $folder_icon['class'] = 'category_icon';
             }
             break;
         case 'random_image':
             $folder_icon['icon'] = $default_icon;
             $folder_icon['class'] = 'random_image';
             $sub = 'TRUE' == $lg_gallery->get_option('random_subfolder') ? 'subfolders' : 'root';
             $images = $this->random_image($sub);
             if (0 < count($images)) {
                 $thumb = $images[0];
                 $folder_icon['icon'] = $thumb->src();
             }
             break;
     }
     $folder_icon['class'] .= ' thumb';
     if (isset($thumb) && ('TRUE' != $lg_gallery->get_option('enable_cache') || 'TRUE' == $lg_gallery->get_option('async_cache')) && !file_exists($thumb->loc())) {
         $folder_icon['class'] .= ' lg_ajax';
     }
     unset($thumb);
     return apply_filters('lazyest_folder_icon', $folder_icon, $this->curdir);
 }
Exemple #5
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;
 }