Example #1
0
 /**
  * LazyestFolder::list_folders()
  * 
  * @param string $show
  * @param string $text
  * @param string $link
  * @return void
  */
 function list_folders($show = 'visible', $text = 'title', $link = 'frontend')
 {
     global $lg_gallery;
     if ($folders = $this->subfolders($show)) {
         if (0 < count($folders)) {
             foreach ($folders as $folder) {
                 $folder->open();
                 echo "\n<ul>\n";
                 $title = 'title' == $text ? $folder->caption() : htmlentities($folder->dirname());
                 $href = 'frontend' == $link || 'widget' == $link ? $folder->uri($link) : 'admin.php?page=lazyest-filemanager&amp;folder=' . lg_nice_link($folder->curdir);
                 echo "<li><a href=\"{$href}\">{$title}</a> ";
                 if ('admin' == $link) {
                     echo sprintf(__('(%s Images)', 'lazyest-gallery'), $folder->count());
                 }
                 $folder->list_folders($show, $text, $link);
                 echo "</li>\n";
                 echo "</ul>\n";
             }
         }
     }
 }
Example #2
0
 /**
  * LazyestFrontend::admin_bar_menu()
  * Show edit links for gallery in WordPress admin bar
  * 
  * @since 1.1
  * @return void
  */
 function admin_bar_menu()
 {
     global $wp_admin_bar;
     if (!$this->is_gallery()) {
         return;
     }
     if ($this->get_option('new_install') != 'TRUE' && $this->valid() && current_user_can('edit_lazyest_fields')) {
         $wp_admin_bar->add_menu(array('id' => 'lazyest-menu', 'title' => __('Lazyest', 'lazyest-gallery'), 'href' => '#'));
         $wp_admin_bar->add_menu(array('parent' => 'lazyest-menu', 'id' => 'lazyest-gallery-manage', 'title' => __('Manage Gallery', 'lazyest-gallery'), 'href' => admin_url('admin.php?page=lazyest-filemanager')));
         if (current_user_can('edit_lazyest_fields') && !is_search() && ($this->is_folder($this->file) || $this->is_image($this->file))) {
             $wp_admin_bar->add_menu(array('parent' => 'lazyest-gallery-manage', 'title' => __('Edit Folder', 'lazyest-gallery'), 'href' => admin_url('admin.php?page=lazyest-filemanager&amp;folder=' . urlencode($this->currentdir))));
         }
         if (current_user_can('edit_lazyest_fields') && !is_search() && $this->is_image($this->file)) {
             $folder = new LazyestFolder($this->currentdir);
             $filename = basename($this->file);
             $image = $folder->single_image($filename);
             $wp_admin_bar->add_menu(array('parent' => 'lazyest-gallery-manage', 'id' => 'lazyest-gallery-edit-image', 'title' => __('Edit Image', 'lazyest-gallery'), 'href' => admin_url('admin.php?page=lazyest-filemanager&amp;folder=' . urlencode($this->currentdir) . '#' . $image->form_name())));
         }
         if (current_user_can('edit_posts') && 'TRUE' == $this->get_option('allow_comments')) {
             $wp_admin_bar->add_menu(array('parent' => 'lazyest-menu', 'id' => 'lazyest-gallery-edit-comments', 'title' => __('Comments', 'lazyest-gallery'), 'href' => admin_url('admin.php?page=lazyest-filemanager&edit=comments&amp;file=' . lg_nice_link($this->file))));
         }
         if (current_user_can('edit_themes')) {
             $wp_admin_bar->add_menu(array('parent' => 'lazyest-menu', 'id' => 'lazyest-gallery-edit-themes', 'title' => __('Themes', 'lazyest-gallery'), 'href' => admin_url('admin.php?page=lazyest-themesmanager')));
         }
         if (current_user_can('manage_options')) {
             $wp_admin_bar->add_menu(array('parent' => 'lazyest-menu', 'id' => 'lazyest-gallery-settings', 'title' => __('Gallery Settings', 'lazyest-gallery'), 'href' => admin_url('admin.php?page=lazyest-gallery')));
         }
     }
 }
Example #3
0
    /**
     * Lazyest_Widget_Random_Slideshow::form()
     * 
     * @param mixed $instance
     * @return void
     */
    function form($instance)
    {
        $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
        $folder = isset($instance['folder']) ? $instance['folder'] : '';
        $subfolders = isset($instance['subfolders']) ? $instance['subfolders'] : 0;
        $number = isset($instance['number']) ? $instance['number'] : 4;
        if ('' == $folder) {
            $subfolders = 1;
        }
        $options = "<option value='0'";
        if ('' == $folder) {
            $options .= "selected='selected'";
        }
        $options .= ">" . __('All folders', 'lazyest-gallery') . "</option>\n";
        global $lg_gallery;
        $dirlist = $lg_gallery->folders('subfolders', 'visible');
        foreach ($dirlist as $dir) {
            $options .= '<option value="' . lg_nice_link($dir->curdir) . '"';
            if ($folder == $dir->curdir) {
                $options .= 'selected="selected"';
            }
            $options .= ' >' . htmlentities($dir->curdir) . '</option>';
        }
        ?>

		<p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'lazyest-gallery');
        ?>
</label>
			<input id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" class="widefat" value="<?php 
        echo $title;
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('number');
        ?>
"><?php 
        _e('Number of images to show:', 'lazyest-gallery');
        ?>
</label>
			<input id="<?php 
        echo $this->get_field_id('number');
        ?>
" name="<?php 
        echo $this->get_field_name('number');
        ?>
" type="number" min="1" max="16" class="small-text" value="<?php 
        echo $number;
        ?>
" size="3" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('folder');
        ?>
"><?php 
        _e('Select images from folder:', 'lazyest-gallery');
        ?>
</label>
			<select id="<?php 
        echo $this->get_field_id('folder');
        ?>
"  name="<?php 
        echo $this->get_field_name('folder');
        ?>
"><?php 
        echo $options;
        ?>
</select>
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('subfolders');
        ?>
"><?php 
        _e('Include subfolders', 'lazyest-gallery');
        ?>
</label>
			<input id="<?php 
        echo $this->get_field_id('subfolders');
        ?>
" name="<?php 
        echo $this->get_field_name('subfolders');
        ?>
" type="checkbox" value="1" <?php 
        checked($subfolders);
        ?>
 />
		</p>		
		<?php 
    }
Example #4
0
 /**
  * LazyestCommentor::get_file_by_comment_id()
  * 
  * @param mixed $comment_ID
  * @return
  */
 function get_file_by_comment_id($comment_ID)
 {
     global $wpdb, $lg_gallery;
     $commentID = (int) $comment_ID;
     $select = "SELECT * FROM {$wpdb->commentmeta} WHERE comment_id = {$commentID} AND meta_key = 'lazyest';";
     $result = $wpdb->get_row($select, ARRAY_A);
     $file = '';
     if (0 < count($result)) {
         $imgID = (int) $result['meta_value'];
         $file = $lg_gallery->get_file_by_id($imgID);
         if (false !== $file) {
             if (isset($file[0])) {
                 return lg_nice_link($file[0]);
             }
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #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;
 }
Example #6
0
 /**
  * LazyestThumb::src()
  * 
  * @return
  */
 function src()
 {
     global $lg_gallery;
     if (!$this->valid() || !isset($lg_gallery)) {
         return false;
     }
     $thumbfile = $this->loc();
     if ('TRUE' == $lg_gallery->get_option('enable_cache')) {
         if (!file_exists($thumbfile) && 'TRUE' != $lg_gallery->get_option('async_cache')) {
             $this->cache();
         }
         if (file_exists($thumbfile)) {
             return apply_filters('lazyest_gallery_thumb_src', $lg_gallery->address . lg_nice_link($this->folder->curdir . $lg_gallery->get_option('thumb_folder') . $this->image));
         } else {
             if ('TRUE' == $lg_gallery->get_option('async_cache')) {
                 return $lg_gallery->plugin_url . '/images/ajax-img.gif?action=lg_image_request&amp;file=' . lg_nice_link($this->folder->realdir() . $this->image) . '&amp;thumb=1';
             } else {
                 return $lg_gallery->plugin_url . '/images/file_alert.png';
             }
         }
     }
     return admin_url('admin-ajax.php') . '?action=lg_image_request&amp;file=' . lg_nice_link($this->folder->realdir() . $this->image) . '&amp;thumb=1';
 }
Example #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;
 }