Exemple #1
0
 /**
  * LazyestFrontend::create_navigation()
  * Show the navigation breadcrumb trail
  * 
  * @uses apply_filters()
  * @uses get_bloginfo()
  * @uses get_the_title()
  * @uses trailingslashit()
  * @return void
  */
 function create_navigation()
 {
     global $post;
     $nav = explode('/', untrailingslashit($this->currentdir));
     $path = pathinfo($this->file);
     $current = '';
     $now_viewing = apply_filters('lazyest_now_viewing', __(' Now viewing: ', 'lazyest-gallery'));
     $sep = $this->_sep();
     $navigator = sprintf('<div class="top_navigator">%s <a href="%s">%s</a> <span class="raquo">%s</span> <a href="%s">%s</a>', $now_viewing, home_url(), get_bloginfo('name'), $sep, $this->uri(), get_the_title($post->ID));
     if ($nav[0] != '') {
         foreach ($nav as $n) {
             $current .= trailingslashit($n);
             $folder = new LazyestFrontendFolder($current);
             $folder->open();
             $navigator .= sprintf(' <span class="raquo">%s</span> <a href="%s">%s</a> ', $sep, $folder->uri(), $folder->title());
             unset($folder);
         }
     }
     if (!is_dir(untrailingslashit($this->root . $this->file))) {
         $folder = new LazyestFolder($this->currentdir);
         if ($folder->valid()) {
             $image = $folder->single_image($path['basename']);
             $navigator .= sprintf(' <span class="raquo">%s</span> <a href="%s">%s</a>', $sep, $image->uri(), $image->title());
         }
         unset($folder);
     }
     $navigator .= "</div>\n";
     echo apply_filters('lazyest_navigator', $navigator);
 }
Exemple #2
0
    /**
     * LazyestUploadTab::insert_folder_shortcode()
     * Form to insert a folder shortcode
     * 
     * @param LazyestFolder $folder
     * @return void
     */
    function insert_folder_shortcode($folder)
    {
        if (!$folder->valid()) {
            esc_html_e('Error opening folder', 'lazyest-gallery');
            return;
        }
        $folder->open();
        $count = $folder->count();
        $selectimages = sprintf('<option value="">%s</option>', esc_html__('Default', 'lazyest-gallery'));
        for ($i = 1; $i <= $count; $i++) {
            $selectimages .= sprintf('<option value="%s">%s</option>', $i, $i);
        }
        $selectcolumns = sprintf('<option value="">%s</option>', esc_html__('Default', 'lazyest-gallery'));
        for ($i = 1; $i <= 10; $i++) {
            $selectcolumns .= sprintf('<option value="%s">%s</option>', $i, $i);
        }
        ?>
  
    <input type="hidden" name="lg_folder" value="<?php 
        echo urlencode($folder->curdir);
        ?>
" />
    <div class="media-item">
    <table class="describe" id="lg_st_<?php 
        echo $folder->id;
        ?>
">
      <thead>
        <tr><th colspan="2"><?php 
        esc_html_e('Folder shortcode', 'lazyest-gallery');
        ?>
</th></tr>            
      </thead>
      <tbody>
        <tr>
          <th class="label" scope="row"><label for="count"><?php 
        esc_html_e('Number of images', 'lazyest-gallery');
        ?>
</label></th>
          <td><select name="count"><?php 
        echo $selectimages;
        ?>
</select></td>            
        </tr>
        <tr>          
          <th class="label" scope="row"><label for="column"><?php 
        esc_html_e('Number of columns', 'lazyest-gallery');
        ?>
</label></th>
          <td><select name="column"><?php 
        echo $selectcolumns;
        ?>
</select></td>            
        </tr>
        <tr>
          <th class="label" scope="row"><label for="paging"><?php 
        esc_html_e('Add pagination', 'lazyest-gallery');
        ?>
</label></th>
          <td><input type="checkbox" name="paging" /></td>
        </tr>
        <tr class="submit">
          <td></td>
          <td>
            <input class="button" type="submit" name="folder_short" value="<?php 
        esc_html_e('Insert as shortcode', 'lazyest-gallery');
        ?>
" />
            <input class="button" type="submit" name="folder_slide" value="<?php 
        esc_html_e('Insert as slide show', 'lazyest-gallery');
        ?>
" />          
          </td>
        </tr>
      </tbody>
      </table>
    </div>
    <?php 
    }
Exemple #3
0
 /**
  * LazyestCommentor::remove_comments()
  * 
  * @param mixed $filevar
  * @return
  */
 function remove_comments($filevar)
 {
     global $lg_gallery;
     $result = true;
     if ($lg_gallery->is_image($filevar)) {
         $folder = new LazyestFolder(dirname($filevar));
         if ($folder->valid()) {
             $folder->load();
             $image = $folder->single_image(basename($filevar));
             $img_ID = (int) $image->id;
         }
         unset($folder);
     } elseif ($lg_gallery->is_folder($filevar)) {
         $folder = new LazyestFolder(dirname($filevar));
         if ($folder->valid()) {
             $folder->open();
             $folder->load();
             foreach ($folder->list as $image) {
                 $this->remove_comments($filevar . $image->image);
             }
             $imgID = (int) $folder->id;
         }
         unset($folder);
     }
     if (isset($img_ID)) {
         $comments = $this->get_comments($img_ID);
         if (0 < count($comments)) {
             foreach ($comments as $comment) {
                 $comment_ID = $comment->comment_ID;
                 if (!wp_delete_comment($comment_ID)) {
                     $result = false;
                 }
             }
         }
     }
     return $result;
 }
Exemple #4
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);
 }
 /**
  * LazyestGallery::is_folder()
  * Test if $filvar points to a folder
  * 
  * @param string $filevar
  * @return
  */
 function is_folder($filevar)
 {
     if ('' == $filevar) {
         return false;
     }
     $filevar = urldecode($filevar);
     $folder = new LazyestFolder($filevar);
     $valid = $folder->valid();
     unset($folder);
     return $valid;
 }
Exemple #6
0
/**
 * lg_insert_image_shortcode()
 * Insert an image shortcode in a post
 * 
 * @since 1.1.0
 * @return void
 */
function lg_insert_image_shortcode()
{
    global $lg_gallery;
    if (isset($_POST['image'])) {
        $file = urldecode($_POST['image']);
        $folder = new LazyestFolder(dirname($file));
        if ($folder->valid()) {
            $image = $folder->single_image(basename($file), 'thumbs');
            require_once $lg_gallery->plugin_dir . '/inc/uploadtab.php';
            $uploadtab = new LazyestUploadTab();
            $uploadtab->insert_image_shortcode($image);
        }
    }
    die;
}