Beispiel #1
0
/**
 * lg_list_folders()
 * 
 * @param string $title
 * @return
 */
function lg_list_folders($title)
{
    global $lg_gallery;
    if (!isset($lg_gallery)) {
        return false;
    }
    $disp = 'TRUE' == $lg_gallery->get_option('use_folder_captions') ? 'title' : 'dirname';
    if ($title != '') {
        ?>

    <h2><?php 
        echo $title;
        ?>
</h2>
    <?php 
    }
    $folders = $lg_gallery->folders('root', 'visible');
    if (0 < count($folders)) {
        ?>
<ul><?php 
        foreach ($folders as $folder) {
            $folder->open();
            ?>

      <li><a href="<?php 
            echo $folder->uri('widget');
            ?>
" title="<?php 
            echo $folder->title();
            ?>
"><?php 
            echo lg_html($folder->caption());
            ?>
</a>
      <?php 
            $folder->list_folders('visible', $disp, 'widget');
            ?>

      </li>
      <?php 
        }
        ?>
</ul><?php 
    }
}
Beispiel #2
0
    /**
     * LazyestFrontendFolder::show_slide()
     * Show a single image in slide view
     * 
     * @param string $filename file name of the image to show 
     * @return void
     */
    function show_slide($filename)
    {
        global $lg_gallery, $post;
        if (!$lg_gallery->access_check($this)) {
            return;
        }
        $this->load('slides');
        for ($i = 0; $i < count($this->list); $i++) {
            $image = $this->list[$i];
            if ($image->image == $filename) {
                if (0 == $i) {
                    $previous = end($this->list);
                } else {
                    $previous = $this->list[$i - 1];
                }
                if ($i + 1 == count($this->list)) {
                    $next = $this->list[0];
                } else {
                    $next = $this->list[$i + 1];
                }
                break;
            }
        }
        if (!isset($previous) || !isset($next)) {
            esc_html_e('Something went wrong displaying the slide', 'lazyest-gallery');
            return;
        }
        $slideshowbutton_shortcode = apply_filters('do_lazyest_slideshow_button', $lg_gallery->is_gallery());
        ?>
    		
    <div class="lazyest_image">
    <?php 
        if (in_array($lg_gallery->get_option('on_slide_click'), array('lightbox', 'thickbox'))) {
            // add links for lightbox
            $j = 0;
            while ($j < $i) {
                $dummy = $this->list[$j];
                $onclick = $dummy->on_click();
                $rel = '' != $onclick['rel'] ? 'rel="' . $onclick['rel'] . '"' : '';
                ?>

        <a id="<?php 
                echo $onclick['id'];
                ?>
" class="lg_dummy <?php 
                echo $onclick['class'];
                ?>
" title="<?php 
                echo $onclick['title'];
                ?>
"  href="<?php 
                echo $onclick['href'];
                ?>
" <?php 
                echo $rel;
                ?>
></a>
      <?php 
                $j++;
            }
        }
        $onclick = $image->on_click();
        $rel = '' != $onclick['rel'] ? 'rel="' . $onclick['rel'] . '"' : '';
        if ('nothing' != $lg_gallery->get_option('on_slide_click')) {
            ?>

      <a id="<?php 
            echo $onclick['id'] . $post->ID;
            ?>
" class="slide <?php 
            echo $onclick['class'];
            ?>
" href="<?php 
            echo $onclick['href'];
            ?>
" title="<?php 
            echo $onclick['title'];
            ?>
" <?php 
            echo $rel;
            ?>
>
    <?php 
        }
        ?>
  
        <img class="slide" id="<?php 
        echo $image->html_id();
        ?>
" src="<?php 
        echo $image->src();
        ?>
" alt="<?php 
        echo $image->alt();
        ?>
" />
    <?php 
        if ('nothing' != $lg_gallery->get_option('on_slide_click')) {
            ?>
  	    
      </a>         
    <?php 
        }
        if (in_array($lg_gallery->get_option('on_slide_click'), array('lightbox', 'thickbox'))) {
            // add links for lightbox
            $j = $i + 1;
            while ($j < count($this->list)) {
                $dummy = $this->list[$j];
                $onclick = $dummy->on_click();
                $rel = '' != $onclick['rel'] ? 'rel="' . $onclick['rel'] . '"' : '';
                ?>

        <a id="<?php 
                echo $onclick['id'];
                ?>
" class="lg_dummy <?php 
                echo $onclick['class'];
                ?>
" title="<?php 
                echo $onclick['title'];
                ?>
"  href="<?php 
                echo $onclick['href'];
                ?>
" <?php 
                echo $rel;
                ?>
></a>
      <?php 
                $j++;
            }
        }
        ?>
  
		  <div class="caption"><?php 
        echo lg_html($image->caption());
        ?>
&nbsp;</div>
    <?php 
        if ('' != $image->description) {
            ?>
  
      <div class="description"><?php 
            echo lg_html($image->description());
            ?>
&nbsp;</div>
    <?php 
        }
        do_action('lazyest_frontend_slide', $image);
        ?>
 </div> <!-- lazyest image --> <?php 
        if (1 < count($this->list)) {
            ?>
  		
      <div class="lazyest_navigator" style="width:95%">
      <?php 
            if ('TRUE' == $lg_gallery->get_option('enable_slide_show') && $slideshowbutton_shortcode) {
                ?>

      <a href="<?php 
                echo add_query_arg('lg_show', 'true', $this->uri());
                ?>
" class="lg_slideshow_button"><?php 
                echo __('Slide Show', 'lazyest-gallery');
                ?>
</a>
		  <?php 
            }
            $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", 'prev-page', esc_attr__('Go to the previous slide', 'lazyest-gallery'), esc_url($previous->uri()), '&laquo;');
            $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", 'next-page', esc_attr__('Go to the next slide', 'lazyest-gallery'), esc_url($next->uri()), '&raquo;');
            $output = join("\n", $page_links);
            echo "<div class='tablenav-pages'>{$output}</div>";
            ?>

        <br style="clear: both;"/>
  		</div> 	      
      <?php 
        }
        if ('TRUE' == $lg_gallery->get_option('enable_exif')) {
            $this->show_exif($filename);
        }
    }
Beispiel #3
0
 /**
  * LazyestFolder::caption_div()
  * displays the <div> element in thumbnail view containing the folder caption
  * 
  * @return void
  */
 function caption_div()
 {
     global $lg_gallery;
     $caption_div = sprintf('<div class="lg_thumb_caption">%s<a class="fldrlink" href="%s"><span class="fldrcaption">%s</span></a>', apply_filters('lazyest_before_folder_caption', ''), $this->uri(), lg_html($this->caption()));
     $subfoldernum = false;
     $include = false;
     $foldernum = true;
     $class = 'folder-count';
     $option = $lg_gallery->get_option('count_subfolders');
     switch ($option) {
         case 'separate':
             $subfoldernum = true;
             $class = 'lg_foldernum';
             break;
         case 'include':
             $subfoldernm = false;
             $class = 'lg_folder_allcount';
             break;
         case 'nothing':
             $foldernum = false;
             break;
     }
     if ($foldernum) {
         $caption_div .= sprintf('<br /><span class="%s" id="lg_tc_%s" title="%s">%s %s</span><br />', $class, $this->id, urlencode($this->curdir), $this->count(), esc_html($lg_gallery->get_option('listed_as')));
         if ($subfoldernum) {
             $caption_div .= sprintf('<span class="lg_folder_subcount" id="lg_sc_%s" title="%s"></span>', $this->id, urlencode($this->curdir));
         }
     }
     $caption_div .= sprintf('%s</div>', apply_filters('lazyest_after_folder_caption', ''));
     return $caption_div;
 }
Beispiel #4
0
 /**
  * Lazyest_Widget_Really_Images::get_image()
  * 
  * Response to AJAX request for random image
  * 
  * $_POST['random'] int nth random image
  * A random image is stored and will be used for subsequent requests until it expires
  * 
  * @return string html for thumbnail
  */
 function get_image()
 {
     global $post, $lg_gallery;
     $random = isset($_POST['random']) ? absint($_POST['random']) : -1;
     $nonce = $_POST['_wpnonce'];
     if (!wp_verify_nonce($nonce, 'lazyest_widgets') || -1 == $random) {
         die(0);
     }
     $not_images = get_option('lazyest_not_images');
     if (!$not_images) {
         $not_images = array();
     }
     $response = '0';
     if (-1 != $random && $random <= absint($lg_gallery->get_option('image_indexing'))) {
         if ($buffer = get_transient("lg_random_image_{$random}")) {
             $filevar = $buffer;
         } else {
             $filevar = false;
             $count = 0;
             $tried = array();
             while (!$filevar && $count < $this->retry) {
                 $id = rand(1, absint($lg_gallery->get_option('image_indexing')));
                 if (in_array($id, $tried) || in_array($id, $not_images)) {
                     continue;
                 }
                 $afile = $lg_gallery->get_file_by_id($id);
                 if ($afile && $lg_gallery->is_image($afile[0])) {
                     $filevar = $afile[0];
                 } else {
                     $not_images[] = $id;
                 }
                 $tried[] = $id;
                 $count++;
             }
             set_transient("lg_random_image_{$random}", $filevar, $this->expiration * 60);
         }
         update_option('lazyest_not_images', $not_images);
         if ($filevar) {
             $folder_path = dirname($filevar);
             $image_file = basename($filevar);
             $folder = new LazyestFolder($folder_path);
             if ($folder) {
                 $image = $folder->single_image($image_file, 'thumbs');
                 $response = '<div class="lg_thumb">';
                 $onclick = $image->on_click();
                 $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');
                 $response .= sprintf('<div class="lg_thumb_image"><a id="%s_%s" href="%s" class="%s" rel="%s" title="%s" ><img class="%s" src="%s" alt="%s" /></a></div>', $onclick['id'], $postid, $onclick['href'], $onclick['class'], $onclick['rel'], $image->title(), $class, $image->src(), $image->alt());
                 if ('-1' != $lg_gallery->get_option('captions_length')) {
                     $thumb_caption = '<div class="lg_thumb_caption">';
                     $caption = $image->caption();
                     $max_length = (int) $lg_gallery->get_option('captions_length');
                     if ('0' != $lg_gallery->get_option('captions_length')) {
                         if (strlen($caption) > $max_length) {
                             strip_tags($caption);
                             $caption = substr($caption, 0, $max_length - 1) . '&hellip;';
                         }
                     }
                     $thumb_caption .= sprintf('<span title="%s" >%s</span>', $image->title(), lg_html($caption));
                     $thumb_caption .= '</div>';
                     if ('TRUE' == $lg_gallery->get_option('thumb_description')) {
                         if ('' != $image->description) {
                             $thumb_caption .= sprintf('<div class="thumb_description"><p>%s</p></div>', lg_html($image->description()));
                         }
                         $thumb_caption .= apply_filters('lazyest_thumb_description', '', $image);
                     }
                     $response .= $thumb_caption;
                 }
                 $response .= apply_filters('lazyest_frontend_thumbnail', '', $image);
                 $response .= "</div>\n";
             }
         }
     }
     echo $response;
     die;
 }
 /**
  * LazyestFields::thumb_description()
  * 
  * @param string $description
  * @param LazyestImage $image
  * @return string
  */
 function thumb_description($description, $image)
 {
     if (0 != count($this->fields)) {
         foreach ($this->fields as $field) {
             if ('image' == $field['target']) {
                 $description .= sprintf('<div class="extra-field %s"><p><span class="name">%s</span> <span class="value">%s</span></p></div>', $field['name'], esc_html($field['display']), lg_html($image->get_extra_field($field['name'])));
             }
         }
     }
     return $description;
 }
Beispiel #6
0
 /**
  * LazyestImage::title()
  * 
  * @return
  */
 function title()
 {
     global $lg_gallery;
     $caption = $this->caption();
     $title = strip_tags(lg_html($caption));
     return apply_filters('lazyest_image_title', $title, $this);
 }
Beispiel #7
0
 /**
  * LazyestFolderTable::body_cell()
  * 
  * @param mixed $key
  * @param mixed $value
  * @param mixed $i
  * @return
  */
 function body_cell($key, $value, $i)
 {
     global $lg_gallery;
     $folder = $this->items[$i];
     $title = $this->sortit ? __('Click and Hold to Drag', 'lazyest-gallery') : '';
     switch ($key) {
         case 'draghandle':
             $cell = $this->sortit ? sprintf('<td class="dragHandle" title="%s"></td>', $title) : '';
             break;
         case 'name':
             $edit_url = $folder->user_can('viewer') ? admin_url(sprintf('admin.php?page=lazyest-filemanager&amp;folder=%s', lg_nice_link($folder->curdir))) : '#';
             $cell = sprintf('<td class="lg_foldercell" sorttable_customkey="%s">', strtolower(esc_attr($folder->dirname())));
             $cell .= sprintf('<a title="%s &quot;%s&quot;" class="row-title" href="%s">%s</a>', __('Edit', 'lazyest-galley'), esc_attr(utf8_encode($folder->dirname())), $edit_url, esc_html(utf8_encode($folder->dirname())));
             $cell .= sprintf('<input type="hidden" class="_index" id="index[%s]" name="index[%s]" value="%d" />', $folder->form_name(), $folder->form_name(), $i + 1);
             $cell .= sprintf('<div class="lg_admin_list_folders" title="%s" id="lg_lf_%s"></div>', urlencode($folder->curdir), $folder->id);
             $cell .= '</td>';
             break;
         case 'caption':
             $cell = sprintf('<td sorttable_customkey="%s">%s</td>', esc_attr(strtolower($folder->title())), strip_tags(lg_html($folder->caption())));
             break;
         case 'date':
             $cell = sprintf('<td class="date column-date" sorttable_customkey="%s">%s</td>', $folder->datetime, date(get_option('date_format'), $folder->datetime));
             break;
         case 'hidden':
             $cell = sprintf('<td class="check-column"><p title="%s" class="visibility f%s"></p></span></td>', ucfirst($folder->visibility), $folder->visibility);
             break;
         case 'comments':
             $cell = 'TRUE' == $lg_gallery->get_option('allow_comments') ? sprintf('<td class="num"><div class="post-com-count-wrapper"><a class="post-com-count" href="%s"><span class="comment-count">%s</span></a></div></td>', admin_url(sprintf('admin.php?page=lazyest-filemanager&amp;edit=comments&amp;file=%s', lg_nice_link($folder->curdir))), $lg_gallery->commentor->count_comments($folder->id)) : '';
             break;
         case 'images':
             $cell = sprintf('<td class="num">%d<br /><span title="%s" class="lg_folder_subcount" id="lg_sc_%s"></span></td>', $folder->count(), urlencode($folder->curdir), $folder->id);
             break;
     }
     return $cell;
 }