Beispiel #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);
 }
Beispiel #2
0
 /**
  * Lazyest_Widget_Really_Slideshow::get_image()
  * 
  * @return void
  */
 function get_image()
 {
     global $post, $lg_gallery;
     $nonce = $_POST['_wpnonce'];
     if (!wp_verify_nonce($nonce, 'lazyest_widgets')) {
         die(0);
     }
     $not_images = get_option('lazyest_not_images');
     if (!$not_images) {
         $not_images = array();
     }
     $response = '0';
     $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++;
     }
     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());
             $response .= "</div>\n";
         }
     }
     echo $response;
     die;
 }
Beispiel #3
0
 /**
  * LazyestUploadTab::image_to_editor()
  * 
  * @param mixed $whathtml what to insert, shortcode
  * @return void
  */
 function image_to_editor($whathtml)
 {
     global $lg_gallery;
     $file = urldecode($_POST['lg_folder']);
     $single = urldecode($_POST['lg_image']);
     $folder = new LazyestFolder($file);
     $folder->open();
     $image = $folder->single_image($single, $_POST["image-size"] . 's');
     $onclick = $image->on_click('widget');
     $caption = isset($_POST["short_code_caption"]) ? $_POST["short_code_caption"] : '';
     $html = '';
     switch ($whathtml) {
         case 'shortcode':
             $caption = '' != $caption ? sprintf('caption="%s"', $caption) : $caption;
             $align = isset($_POST["image_align"]) ? sprintf('align="%s"', $_POST["image_align"]) : '';
             $display = sprintf('display="%s"', $_POST["image-size"]);
             $html .= sprintf('[lg_image folder="%s" image="%s" %s %s %s]', $file, $single, $caption, $align, $display);
             break;
     }
     return media_send_to_editor($html);
 }
Beispiel #4
0
    /**
     * LazyestCommentor::edit_comments()
     * 
     * @param mixed $filevar
     * @return void
     */
    function edit_comments($filevar)
    {
        global $lg_gallery;
        switch ($this->comments_from) {
            case 'folder':
                $folder = new LazyestFolder($filevar);
                $folder->open();
                $comments = $this->get_comments($folder->id);
                $caption = $folder->caption;
                break;
            case 'image':
                $folder = new LazyestFolder(dirname($filevar));
                $folder->load('images');
                $image = $folder->single_image(basename($filevar));
                $comments = $this->get_comments($image->id);
                $caption = $image->caption;
                break;
            case 'gallery':
                $comments = $this->get_root_comments();
                $page_id = $lg_gallery->get_option('gallery_id');
                $gallery_page = get_post($page_id);
                $caption = $gallery_page->post_title;
                break;
            case 'all':
            default:
                $page_id = (int) $lg_gallery->get_option('gallery_id');
                $comments = $this->get_approved_comments($page_id);
                $gallery_page = get_post($page_id);
                $caption = $gallery_page->post_title;
                break;
        }
        $do_pagination = false;
        if ($comments) {
            update_comment_cache($comments);
            $comments = array_reverse($comments);
            $comments_table = new LazyestCommentsTable($comments);
            $perpage = 20;
            $total_pages = ceil(count($comments) / $perpage);
            $query_var = 'lg_paged';
            if (isset($paged)) {
                $current = $paged;
            } else {
                $current = isset($_REQUEST[$query_var]) ? absint($_REQUEST[$query_var]) : 0;
                $current = min(max(1, $current), $total_pages);
            }
            $start = ($current - 1) * $perpage + 1;
            $end = min(count($comments), $current * $perpage);
            $do_pagination = 1 < $total_pages;
            if ($do_pagination) {
                $pagination = $lg_gallery->pagination('comments', $comments);
                ?>
      
      <div class="tablenav"><?php 
                echo $pagination;
                ?>
</div>
      <?php 
            }
            ?>
      
  		<br class="clear" />  		
      <?php 
            $comments_table->display();
            ?>

  		<?php 
        }
        if ($do_pagination) {
            ?>
 
    <div class="tablenav"><?php 
            echo $pagination;
            ?>
</div>
    <?php 
        }
        if (isset($folder)) {
            unset($folder);
        }
        unset($comments_table);
    }
Beispiel #5
0
 /**
  * LazyestAdminFolder::copy_image()
  * Copy or move an image to another folder
  * 
  * @return void
  * @since 1.0
  * 
  */
 function copy_image($action = 'copy')
 {
     global $lg_gallery;
     $success = false;
     $get = $action == 'copy' ? $_REQUEST['copy_to'] : $_REQUEST['move_to'];
     $folderfile = urldecode($get);
     $imagefile = urldecode($_REQUEST['image']);
     if ('' == $folderfile || '' == $imagefile) {
         $message = sprintf(__('Cannot find image or folder, please <a href="%s">reload</a> this folder', 'lazyest-gallery'), admin_url('admin.php') . '?page=lazyest-filemanager&folder=' . lg_nice_link($this->curdir));
     } else {
         $to_folderobj = new LazyestFolder($folderfile);
         $to_folderobj->open();
         $to_folderobj->load();
         if (!$to_folderobj->user_can('editor')) {
             $message = sprintf(esc_html__('You have insufficient permissions to copy to folder %s', 'lazyest-gallery'), htmlentities($folderfile));
         } else {
             $to_folder = $lg_gallery->root . $folderfile;
             $from_image = $lg_gallery->root . $imagefile;
             $from_folderobj = new LazyestFolder(dirname($imagefile));
             $from_imageobj = $from_folderobj->single_image(basename($from_image));
             $to_image = $to_folder . basename($from_image);
             if (file_exists($to_image)) {
                 $message = sprintf(esc_html__('Cannot copy, %s already exists in %s', 'lazyest-gallery'), htmlentities(basename($from_image)), htmlentities($folderfile));
             } else {
                 if (!@copy($from_image, $to_image)) {
                     $message = esc_html__('Cannot copy, Something went wrong copying your image. Please check your server permissions', 'lazyest-gallery');
                 } else {
                     if ('move' == $action) {
                         $success = @unlink($from_image);
                         if (!$success) {
                             $message = esc_html__('Cannot move, image is copied instead', 'lazyest-gallery');
                         }
                     } else {
                         $success = true;
                     }
                     if ($success) {
                         $from_imageobj->folder = $to_folderobj;
                         $to_folderobj->list[] = $from_imageobj;
                         $to_folderobj->save();
                         $copymove = $action == 'copy' ? 'copied' : 'moved';
                         $folderlink = '<a href="' . admin_url('admin.php') . '?page=lazyest-filemanager&folder=' . urlencode($folderfile) . '#' . $from_imageobj->form_name() . '">' . htmlentities($folderfile) . '</a>';
                         $message = sprintf(esc_html__('%s successfully %s to %s', 'lazyest-gallery'), htmlentities(basename($from_image)), $copymove, $folderlink);
                     }
                 }
             }
         }
     }
     $lg_gallery->message = $message;
     $lg_gallery->success = $success;
 }
Beispiel #6
0
/**
 * lg_get_the_title()
 * Returns the title for the currently displaying folder or slide page
 * 
 * @since 1.1.0
 * @return string
 */
function lg_get_the_title()
{
    global $lg_gallery;
    $page = get_page($lg_gallery->get_option('gallery_id'));
    $title = esc_html($page->post_title);
    unset($page);
    if (!isset($lg_gallery)) {
        return $title;
    }
    $lg_gallery->valid();
    if ($lg_gallery->is_image($lg_gallery->file)) {
        $folder = new LazyestFolder(dirname($lg_gallery->file));
        $image = $folder->single_image(basename($lg_gallery->file));
        $title = $image->title();
        unset($image, $folder);
    }
    if ($lg_gallery->is_folder($lg_gallery->file)) {
        $folder = new LazyestFolder($lg_gallery->file);
        $folder->open();
        $title = $folder->title();
        unset($folder);
    }
    return $title;
}
Beispiel #7
0
 function body_cell($key, $value, $i)
 {
     global $comment, $lg_gallery;
     // set global $comment so we can use WordPress functions
     $comment = $this->items[$i];
     $comment_ID = $comment->comment_ID;
     // in this table we only shows approved comments
     $comment_status = 'approve';
     $pending_comments = 0;
     switch ($key) {
         case 'author':
             $author_url = get_comment_author_url();
             $cell = '<td class="author column-author">';
             $cell .= sprintf('<strong> %s %s </strong><br />', get_avatar($comment, 32), get_comment_author($comment));
             if (current_user_can('moderate_comments')) {
                 if (!empty($comment->comment_author_email)) {
                     $cell .= get_comment_author_email_link() . '<br />';
                 }
                 $cell .= sprintf('<a href="edit-comments.php?s=%s&amp;mode=detail">%s</a>', get_comment_author_IP($comment), get_comment_author_IP($comment));
             }
             $cell .= '</td>';
             break;
         case 'comment':
             $approve_nonce = esc_html('_wpnonce=' . wp_create_nonce("approve-comment_{$comment_ID}"));
             $del_nonce = esc_html('_wpnonce=' . wp_create_nonce("delete-comment_{$comment_ID}"));
             $postID = $lg_gallery->get_option('gallery_id');
             $cell = '<td class="comment column-comment">';
             $filevar = isset($comment->filevar) ? $comment->filevar : '';
             $uri = trailingslashit($lg_gallery->get_option('gallery_prev'));
             if ('TRUE' != $lg_gallery->get_option('use_permalinks')) {
                 $comment_url = add_query_arg('file', $filevar, $uri);
             } else {
                 $comment_url = trailingslashit($uri . $filevar);
             }
             $comment_url .= '#comment-' . $comment_ID;
             $cell .= '<div class="submitted-on">';
             $cell .= sprintf(__('Submitted on <a href="%1$s">%2$s - %3$s</a>'), esc_url($comment_url), get_comment_date(get_option('date_format')), get_comment_date(get_option('time_format')));
             $cell .= sprintf('<p>%s</p>', apply_filters('comment_text', get_comment_text($comment), $comment));
             if (current_user_can('moderate_comments')) {
                 $cell .= '<div class="row-actions">';
                 $cell .= sprintf('<span class="unapprove"><a href="%s" class="delete:the-comment-list:comment-%s:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive" title="%s">%s</a> | </span>', esc_url("comment.php?action=unapprovecomment&p={$postID}&c={$comment_ID}&{$approve_nonce}"), $comment_ID, esc_attr__('Unapprove this comment'), __('Unapprove'));
                 $cell .= sprintf('<span class="edit"><a href="comment.php?action=editcomment&amp;c=%s" title="%s">%s</a> | </span>', $comment_ID, esc_attr__('Edit comment'), __('Edit'));
                 $cell .= sprintf('<span class="spam"><a href="%s" class="delete:the-comment-list:comment-%s::spam=1 vim-s vim-destructive" title="%s">%s</a> | </span>', esc_url("comment.php?action=spamcomment&p={$postID}&c={$comment_ID}&{$del_nonce}"), $comment_ID, esc_attr__('Mark this comment as spam'), _x('Spam', 'verb'));
                 $cell .= sprintf('<span class="trash"><a href="%s" class="delete:the-comment-list:%s::trash=1 delete vim-d vim-destructive" title="%s">%s</a></span>', esc_url("comment.php?action=trashcomment&p={$postID}&c={$comment_ID}&{$del_nonce}"), $comment_ID, esc_attr__('Move this comment to the trash'), _x('Trash', 'verb'));
             }
             $cell .= '</td>';
             break;
         case 'response':
             $cell = '<td class="response column-response">';
             $edit_title = esc_html__('Gallery', 'lazyest-gallery');
             $edit_url = admin_url('admin.php?page=lazyest-filemanager&folder=');
             $filevar = isset($comment->filevar) ? stripslashes(rawurldecode($comment->filevar)) : $lg_gallery->commentor->get_file_by_comment_id($comment_ID);
             $preview = $lg_gallery->get_option('gallery_prev');
             $class = 'alignright';
             $img_src = trailingslashit($lg_gallery->plugin_url) . 'images/folders.png';
             $img_alt = __('Icon', 'lazyest-gallery');
             $img_title = __('Click to View', 'lazyest-gallery');
             $img_id = 0;
             $img_class = 'lg';
             if ('' !== $filevar) {
                 $edit_url .= $lg_gallery->is_folder($filevar) ? lg_nice_link($filevar) : lg_nice_link(dirname($filevar));
                 if ($lg_gallery->is_folder($filevar)) {
                     $folder = new LazyestFolder($filevar);
                     $folder->open();
                     $edit_title = $folder->title();
                     $preview = $folder->uri();
                     $img_src = trailingslashit($lg_gallery->plugin_url) . 'images/folder-icon.png';
                     $img_id = $folder->id;
                 }
                 if ($lg_gallery->is_image($filevar)) {
                     $folder = new LazyestFolder(dirname($filevar));
                     $image = $folder->single_image(basename($filevar), 'thumbs');
                     $edit_url .= '#' . $image->form_name();
                     $edit_title = $image->title();
                     $onclick = $image->on_click();
                     $preview = $onclick['href'];
                     $class .= ' ' . $onclick['class'];
                     $img_src = $image->src();
                     if ('TRUE' == $lg_gallery->get_option('async_cache') && !file_exists($image->loc())) {
                         $img_class = 'lg_ajax';
                     }
                     $img_alt = $image->alt();
                     $img_id = $image->id;
                 }
             }
             $cell .= '<div class="response-links"><span class="post-com-count-wrapper">';
             $cell .= sprintf('<a href="%s">%s</a><br />', $edit_url, $edit_title);
             $cell .= sprintf('<a href="admin.php?page=lazyest-filemanager&edit=comments&file=%s" title="%s" class="post-com-count"><span class="comment-count">%s</span></a>', $filevar, esc_attr(__('0 pending')), $lg_gallery->commentor->count_comments($img_id));
             $cell .= '</div>';
             $cell .= sprintf('<a target="_blank" href="%s" class="alignright"><img width="32" height="32" src="%s" alt="%s"  title="%s" class="%s" /></a>', $preview, $img_src, $img_alt, $img_title, $img_class);
             $cell .= "</td>\n";
             break;
     }
     return $cell;
 }
Beispiel #8
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;
}