コード例 #1
0
function wppa_get_statistics()
{
    $count = wppa_get_total_album_count();
    $y_id = wppa_get_youngest_album_id();
    $y_name = __(wppa_get_album_name($y_id));
    $p_id = wppa_get_parentalbumid($y_id);
    $p_name = __(wppa_get_album_name($p_id));
    $result = '<div class="wppa-box wppa-nav" style="text-align: center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . '">';
    $result .= __a('There are') . ' ' . $count . ' ' . __a('photo albums. The last album added is') . ' ';
    $result .= '<a href="' . wppa_get_permalink() . 'wppa-album=' . $y_id . '&amp;wppa-cover=0&amp;wppa-occur=1">' . $y_name . '</a>';
    if ($p_id > '0') {
        $result .= __a(', a subalbum of') . ' ';
        $result .= '<a href="' . wppa_get_permalink() . 'wppa-album=' . $p_id . '&amp;wppa-cover=0&amp;wppa-occur=1">' . $p_name . '</a>';
    }
    $result .= '.</div>';
    return $result;
}
コード例 #2
0
function _wppa_sidebar_page_options()
{
    global $wpdb;
    global $wppa_defaults;
    wppa_set_defaults();
    $onch = 'myReload()';
    // Handle spinner js and declare functions
    echo '<script type="text/javascript" >' . 'var didsome=false;' . 'jQuery(document).ready(function() {' . 'jQuery(\'#wppa-spinner\').css(\'display\', \'none\');' . '});' . 'function myReload() {' . 'jQuery(\'#wppa-spinner\').css(\'display\', \'block\');' . '_wppaRefreshAfter = true;' . '};' . 'function wppaSetFixed(id) {' . 'if (jQuery(\'#wppa-widget-photo-\' + id).attr(\'checked\') == \'checked\' ) {' . '_wppaRefreshAfter = true;' . 'wppaAjaxUpdateOptionValue(\'potd_photo\', id);' . '}' . '};' . '</script>';
    // The spinner
    echo '<img' . ' id="wppa-spinner"' . ' style="position:fixed;top:50%;left:50%;z-index:1000;margin-top:-33px;margin-left:-33px;display:block;"' . ' src="' . wppa_get_imgdir('loader.gif') . '"' . '/>';
    // Open wrapper
    echo '<div class="wrap">';
    // The settings icon
    echo '<img src="' . wppa_get_imgdir('settings32.png') . '" />';
    // The Page title
    echo '<h1 style="display:inline;" >' . __('Photo of the Day (Widget) Settings', 'wp-photo-album-plus') . '</h1>' . __('Changes are updated immediately. The page will reload if required.', 'wp-photo-album-plus') . '<br />&nbsp;';
    // The nonce
    wp_nonce_field('wppa-nonce', 'wppa-nonce');
    // The settings table
    echo '<table class="widefat wppa-table wppa-setting-table">';
    // The header
    echo '<thead style="font-weight: bold; " class="wppa_table_1">' . '<tr>' . '<td>' . __('#', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Name', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Description', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Setting', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Help', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</thead>';
    // Open the table body
    echo '<tbody class="wppa_table" >';
    $name = __('Widget Title:', 'wp-photo-album-plus');
    $desc = __('The title of the widget.', 'wp-photo-album-plus');
    $help = esc_js(__('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wp-photo-album-plus'));
    $slug = 'wppa_potd_title';
    $html = wppa_input($slug, '85%');
    wppa_setting($slug, '1', $name, $desc, $html, $help);
    $name = __('Widget Photo Width:', 'wp-photo-album-plus');
    $desc = __('Enter the desired display width of the photo in the sidebar.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_widget_width';
    $html = wppa_input($slug, '40px', '', __('pixels wide', 'wp-photo-album-plus'));
    wppa_setting($slug, '2', $name, $desc, $html, $help);
    $name = __('Horizontal alignment:', 'wp-photo-album-plus');
    $desc = __('Enter the desired display alignment of the photo in the sidebar.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_align';
    $opts = array(__('--- none ---', 'wp-photo-album-plus'), __('left', 'wp-photo-album-plus'), __('center', 'wp-photo-album-plus'), __('right', 'wp-photo-album-plus'));
    $vals = array('none', 'left', 'center', 'right');
    $html = wppa_select($slug, $opts, $vals);
    wppa_setting($slug, '3', $name, $desc, $html, $help);
    $linktype = wppa_opt('potd_linktype');
    if ($linktype == 'custom') {
        $name = __('Link to:', 'wp-photo-album-plus');
        $desc = __('Enter the url. Do\'nt forget the HTTP://', 'wp-photo-album-plus');
        $help = '';
        $slug = 'wppa_potd_linkurl';
        $html = wppa_input($slug, '85%');
        wppa_setting($slug, '4', $name, $desc, $html, $help);
        $name = __('Link Title:', 'wp-photo-album-plus');
        $desc = __('The balloon text when hovering over the photo.', 'wp-photo-album-plus');
        $help = '';
        $slug = 'wppa_potd_linktitle';
        $html = wppa_input($slug, '85%');
        wppa_setting($slug, '4a', $name, $desc, $html, $help);
    } else {
        $name = __('Link to:', 'wp-photo-album-plus');
        $desc = __('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wp-photo-album-plus');
        $help = '';
        $slug = 'wppa_potd_linkurl';
        $html = '';
        wppa_setting($slug, '4', $name, $desc, $html, $help);
    }
    $name = __('Subtitle:', 'wp-photo-album-plus');
    $desc = __('Select the content of the subtitle.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_subtitle';
    $opts = array(__('--- none ---', 'wp-photo-album-plus'), __('Photo Name', 'wp-photo-album-plus'), __('Description', 'wp-photo-album-plus'), __('Owner', 'wp-photo-album-plus'));
    $vals = array('none', 'name', 'desc', 'owner');
    $html = wppa_select($slug, $opts, $vals);
    wppa_setting($slug, '5', $name, $desc, $html, $help);
    $name = __('Counter:', 'wp-photo-album-plus');
    $desc = __('Display a counter of other photos in the album.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_counter';
    $html = wppa_checkbox($slug);
    wppa_setting($slug, '6', $name, $desc, $html, $help);
    $name = __('Link to:', 'wp-photo-album-plus');
    $desc = __('The counter links to.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_counter_link';
    $opts = array(__('thumbnails', 'wp-photo-album-plus'), __('slideshow', 'wp-photo-album-plus'), __('single image', 'wp-photo-album-plus'));
    $vals = array('thumbs', 'slide', 'single');
    $html = wppa_select($slug, $opts, $vals);
    wppa_setting($slug, '7', $name, $desc, $html, $help);
    $name = __('Type of album(s) to use:', 'wp-photo-album-plus');
    $desc = __('Select physical or virtual.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_album_type';
    $opts = array(__('physical albums', 'wp-photo-album-plus'), __('virtual albums', 'wp-photo-album-plus'));
    $vals = array('physical', 'virtual');
    $html = wppa_select($slug, $opts, $vals, $onch);
    wppa_setting($slug, '8', $name, $desc, $html, $help);
    $name = __('Albums to use:', 'wp-photo-album-plus');
    $desc = __('Select the albums to use for the photo of the day.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_album';
    if (get_option('wppa_potd_album_type') == 'physical') {
        $html = '<select' . ' id="wppa_potd_album"' . ' name="wppa_potd_album"' . ' style="float:left; max-width: 100%;"' . ' multiple="multiple"' . ' onchange="didsome=true;wppaAjaxUpdateOptionValue(\'potd_album\', this, true)"' . ' onmouseout="if(didsome)document.location.reload(true);"' . ' size="10"' . ' >' . wppa_album_select_a(array('path' => true, 'optionclass' => 'potd_album', 'selected' => get_option('wppa_potd_album'))) . '</select>' . '<img id="img_potd_album" class="" src="' . wppa_get_imgdir() . 'star.ico" title="' . __('Setting unmodified', 'wp-photo-album-plus') . '" style="padding:0 4px; float:left; height:16px; width:16px;" />';
        wppa_setting($slug, '9', $name, $desc, $html, $help);
    } else {
        $desc = __('Select the albums to use for the photo of the day.', 'wp-photo-album-plus');
        $opts = array(__('- all albums -', 'wp-photo-album-plus'), __('- all -separate- albums -', 'wp-photo-album-plus'), __('- all albums except -separate-', 'wp-photo-album-plus'), __('- top rated photos -', 'wp-photo-album-plus'));
        $vals = array('all', 'sep', 'all-sep', 'topten');
        $html = wppa_select($slug, $opts, $vals);
        wppa_setting($slug, '9', $name, $desc, $html, $help);
    }
    if (get_option('wppa_potd_album_type') == 'physical') {
        $name = __('Include (grand)children:', 'wp-photo-album-plus');
        $desc = __('Include the photos of all sub albums?', 'wp-photo-album-plus');
        $help = '';
        $slug = 'wppa_potd_include_subs';
        $html = wppa_checkbox($slug, $onch);
        wppa_setting($slug, '9a', $name, $desc, $html, $help);
        $name = __('Inverse selection:', 'wp-photo-album-plus');
        $desc = __('Use any album, except the selection made above.', 'wp-photo-album-plus');
        $help = '';
        $slug = 'wppa_potd_inverse';
        $html = wppa_checkbox($slug, $onch);
        wppa_setting($slug, '9b', $name, $desc, $html, $help);
    }
    $name = __('Status filter:', 'wp-photo-album-plus');
    $desc = __('Use only photos with a certain status.', 'wp-photo-album-plus');
    $help = esc_js(__('Select - none - if you want no filtering on status.', 'wp-photo-album-plus'));
    $slug = 'wppa_potd_status_filter';
    $opts = array(__('- none -', 'wp-photo-album-plus'), __('Publish', 'wp-photo-album-plus'), __('Featured', 'wp-photo-album-plus'), __('Gold', 'wp-photo-album-plus'), __('Silver', 'wp-photo-album-plus'), __('Bronze', 'wp-photo-album-plus'), __('Any medal', 'wp-photo-album-plus'));
    $vals = array('none', 'publish', 'featured', 'gold', 'silver', 'bronze', 'anymedal');
    $html = wppa_select($slug, $opts, $vals);
    wppa_setting($slug, '10', $name, $desc, $html, $help);
    $name = __('Display method:', 'wp-photo-album-plus');
    $desc = __('Select the way a photo will be selected.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_method';
    $opts = array(__('Fixed photo', 'wp-photo-album-plus'), __('Random', 'wp-photo-album-plus'), __('Last upload', 'wp-photo-album-plus'), __('Change every', 'wp-photo-album-plus'));
    $vals = array('1', '2', '3', '4');
    $html = wppa_select($slug, $opts, $vals, $onch);
    wppa_setting($slug, '11', $name, $desc, $html, $help);
    if (get_option('wppa_potd_method') == '4') {
        // Change every
        $name = __('Change every period:', 'wp-photo-album-plus');
        $desc = __('The time period a certain photo is used.', 'wp-photo-album-plus');
        $help = '';
        $slug = 'wppa_potd_period';
        $opts = array(__('pageview.', 'wp-photo-album-plus'), __('hour.', 'wp-photo-album-plus'), __('day.', 'wp-photo-album-plus'), __('week.', 'wp-photo-album-plus'), __('month.', 'wp-photo-album-plus'), __('day of week is order#', 'wp-photo-album-plus'), __('day of month is order#', 'wp-photo-album-plus'), __('day of year is order#', 'wp-photo-album-plus'));
        $vals = array('0', '1', '24', '168', '736', 'day-of-week', 'day-of-month', 'day-of-year');
        $html = wppa_select($slug, $opts, $vals, $onch);
        wppa_setting($slug, '11a', $name, $desc, $html, $help);
        $wppa_widget_period = get_option('wppa_potd_period');
        if (substr($wppa_widget_period, 0, 7) == 'day-of-') {
            switch (substr($wppa_widget_period, 7)) {
                case 'week':
                    $n_days = '7';
                    $date_key = 'w';
                    break;
                case 'month':
                    $n_days = '31';
                    $date_key = 'd';
                    break;
                case 'year':
                    $n_days = '366';
                    $date_key = 'z';
                    break;
            }
            while (get_option('wppa_potd_offset', '0') > $n_days) {
                update_option('wppa_potd_offset', get_option('wppa_potd_offset') - $n_days);
            }
            while (get_option('wppa_potd_offset', '0') < '0') {
                update_option('wppa_potd_offset', get_option('wppa_potd_offset') + $n_days);
            }
            $name = __('Day offset:', 'wp-photo-album-plus');
            $desc = __('The difference between daynumber and photo order number.', 'wp-photo-album-plus');
            $help = '';
            $slug = 'wppa_potd_offset';
            $opts = array();
            $day = '0';
            while ($day < $n_days) {
                $opts[] = $day;
                $day++;
            }
            $vals = $opts;
            $html = '<span style="float:left;" >' . sprintf(__('Current day# = %s, offset =', 'wp-photo-album-plus'), wppa_local_date($date_key)) . '</span> ' . wppa_select($slug, $opts, $vals, $onch);
            $photo_order = wppa_local_date($date_key) - get_option('wppa_potd_offset', '0');
            while ($photo_order < '0') {
                $photo_order += $n_days;
            }
            $html .= sprintf(__('Todays photo order# = %s.', 'wp-photo-album-plus'), $photo_order);
            wppa_setting($slug, '11b', $name, $desc, $html, $help);
        }
    }
    $name = __('Preview', 'wp-photo-album-plus');
    $desc = __('Current "photo of the day":', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_photo';
    $photo = wppa_get_potd();
    if ($photo) {
        $html = '<div style="display:inline-block;width:25%;text-align:center;vertical-align:middle;">' . '<img src="' . wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']) . '" />' . '</div>' . '<div style="display:inline-block;width:75%;text-align:center;vertical-align:middle;" >' . __('Album', 'wp-photo-album-plus') . ': ' . wppa_get_album_name($photo['album']) . '<br />' . __('Uploader', 'wp-photo-album-plus') . ': ' . $photo['owner'] . '</div>';
    } else {
        $html = __('Not found.', 'wp-photo-album-plus');
    }
    wppa_setting($slug, '12', $name, $desc, $html, $help);
    $name = __('Show selection', 'wp-photo-album-plus');
    $desc = __('Show the photos in the current selection.', 'wp-photo-album-plus');
    $help = '';
    $slug = 'wppa_potd_preview';
    $html = wppa_checkbox($slug, $onch);
    wppa_setting($slug, '13', $name, $desc, $html, $help);
    // Cose table body
    echo '</tbody>';
    // Table footer
    echo '<tfoot style="font-weight: bold;" >' . '<tr>' . '<td>' . __('#', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Name', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Description', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Setting', 'wp-photo-album-plus') . '</td>' . '<td>' . __('Help', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</tfoot>' . '</table>';
    // Diagnostic
    //		echo
    //		'Diagnostic: wppa_potd_album = ' . get_option( 'wppa_potd_album' ) . ' wppa_potd_photo = ' . get_option( 'wppa_potd_photo' );
    // Status star must be here for js
    echo '<img' . ' id="img_potd_photo"' . ' src="' . wppa_get_imgdir('star.ico') . '" style="height:12px;display:none;"' . ' />';
    // The potd photo pool
    echo '<table class="widefat wppa-table wppa-setting-table" >';
    // Table header
    echo '<thead>' . '<tr>' . '<td>' . __('Photos in the current selection', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</thead>';
    // Table body
    if (wppa_switch('potd_preview')) {
        echo '<tbody>' . '<tr>' . '<td>';
        // Get the photos
        $alb = wppa_opt('potd_album');
        $opt = wppa_is_int($alb) ? ' ' . wppa_get_photo_order($alb) . ' ' : '';
        $photos = wppa_get_widgetphotos($alb, $opt);
        // Count them
        $cnt = count($photos);
        // Find current
        $curid = wppa_opt('potd_photo');
        // See if we do this
        if (empty($photos)) {
            _e('No photos in the selection', 'wp-photo-album-plus');
        } elseif ($cnt > '5000') {
            echo sprintf(__('There are too many photos in the selection to show a preview ( %d )', 'wp-photo-album-plus'), $cnt);
        } else {
            // Yes, display the pool
            foreach ($photos as $photo) {
                $id = $photo['id'];
                // Open container div
                echo '<div' . ' class="photoselect"' . ' style="' . 'width:180px;' . 'height:300px;' . '" >';
                // Open image container div
                echo '<div' . ' style="' . 'width:180px;' . 'height:135px;' . 'overflow:hidden;' . 'text-align:center;' . '" >';
                // The image if a video
                if (wppa_is_video($id)) {
                    echo wppa_get_video_html(array('id' => $id, 'style' => 'width:180px;'));
                } else {
                    echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'max-width:180px;' . 'max-height:135px;' . 'margin:auto;' . '"' . ' alt="' . esc_attr(wppa_get_photo_name($id)) . '" />';
                    // Audio ?
                    if (wppa_has_audio($id)) {
                        echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:180px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;'));
                    }
                }
                // Close image container div
                echo '</div>';
                // The order# and select radio box
                echo '<div style="clear:both;width:100%;margin:3px 0;position:relative;top:5px;" >' . '<div style="font-size:9px; line-height:10px;float:left;">(#' . $photo['p_order'] . ')</div>';
                if (get_option('wppa_potd_method') == '1') {
                    // Only if fixed photo
                    echo '<input' . ' style="float:right;"' . ' type="radio"' . ' name="wppa-widget-photo"' . ' id="wppa-widget-photo-' . $id . '"' . ' value="' . $id . '"' . ($id == $curid ? 'checked="checked"' : '') . ' onchange="wppaSetFixed(' . $id . ');"' . ' />';
                }
                echo '</div>';
                // The name/desc boxecho
                echo '<div style="clear:both;overflow:hidden;height:150px;position:relative;top:10px;" >' . '<div style="font-size:11px; overflow:hidden;">' . wppa_get_photo_name($id) . '</div>' . '<div style="font-size:9px; line-height:10px;">' . wppa_get_photo_desc($id) . '</div>' . '</div>';
                // Close container
                echo '</div>';
            }
            echo '<div class="clear"></div>';
        }
        // Close the table
        echo '</td>' . '</tr>' . '</tbody>';
    }
    echo '</table>';
    // Close wrap
    echo '</div>';
}
コード例 #3
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'topten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'medalsonly' => 'no', 'showowner' => 'no', 'showalbum' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('topten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('topten_widget_linkpage', __('Top Ten Photos', 'wp-photo-album-plus'));
     $albumlinkpage = wppa_get_the_landing_page('topten_widget_album_linkpage', __('Top Ten Photo album', 'wp-photo-album-plus'));
     $max = wppa_opt('topten_count');
     $album = $instance['album'];
     switch ($instance['sortby']) {
         case 'mean_rating':
             $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
             break;
         case 'rating_count':
             $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
             break;
         case 'views':
             $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
             break;
     }
     $display = $instance['display'];
     $meanrat = $instance['meanrat'] == 'yes';
     $ratcount = $instance['ratcount'] == 'yes';
     $viewcount = $instance['viewcount'] == 'yes';
     $includesubs = $instance['includesubs'] == 'yes';
     $albenum = '';
     $medalsonly = $instance['medalsonly'] == 'yes';
     $showowner = $instance['showowner'] == 'yes';
     $showalbum = $instance['showalbum'] == 'yes';
     wppa('medals_only', $medalsonly);
     $likes = wppa_opt('rating_display_type') == 'likes';
     // When likes only, mean rating has no meaning, chan to (rating)(like)count
     if ($likes && $instance['sortby'] == 'mean_rating') {
         $instance['sortby'] = 'rating_count';
     }
     // Album specified?
     if ($album) {
         // All albums ?
         if ($album == '-2') {
             $album = '0';
         }
         // Albums of owner is current logged in user or public?
         if ($album == '-3') {
             $temp = $wpdb->get_results("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ORDER BY `id`", ARRAY_A);
             $album = '';
             if ($temp) {
                 foreach ($temp as $t) {
                     $album .= '.' . $t['id'];
                 }
                 $album = ltrim($album, '.');
             }
         }
         // Including subalbums?
         if ($includesubs) {
             $albenum = wppa_alb_to_enum_children($album);
             $albenum = wppa_expand_enum($albenum);
             $album = str_replace('.', ',', $albenum);
         }
         // Doit
         if ($medalsonly) {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN (" . $album . ") " . "AND `status` IN ( 'gold', 'silver', 'bronze' ) " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         } else {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN (" . $album . ") " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         }
     } else {
         if ($medalsonly) {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` IN ( 'gold', 'silver', 'bronze' ) " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         } else {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         }
     }
     $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->';
     $maxw = wppa_opt('topten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($meanrat) {
         $maxh += $lineheight;
     }
     if ($ratcount) {
         $maxh += $lineheight;
     }
     if ($viewcount) {
         $maxh += $lineheight;
     }
     if ($showowner) {
         $maxh += $lineheight;
     }
     if ($showalbum) {
         $maxh += $lineheight;
     }
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the top rated photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $compressed_albumenum = wppa_compress_enum($albenum);
                 $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('topten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 // Display (owner) ?
                 if ($showowner) {
                     $widget_content .= '<div>(' . $image['owner'] . ')</div>';
                 }
                 // Display (album) ?
                 if ($showalbum) {
                     $href = wppa_convert_to_pretty(wppa_encrypt_url(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1')));
                     $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>';
                 }
                 // Display the rating
                 if ($likes) {
                     $lt = wppa_get_like_title_a($image['id']);
                 }
                 switch ($instance['sortby']) {
                     case 'mean_rating':
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         break;
                     case 'rating_count':
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . ($likes ? $lt['display'] : sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n)) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         break;
                     case 'views':
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . ($likes ? $lt['display'] : sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n)) . '</div>';
                         }
                         break;
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= __('There are no rated photos (yet)', 'wp-photo-album-plus');
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     //wppa( 'in_widget', false );
     wppa_reset_occurrance();
 }
コード例 #4
0
ファイル: wppa-thumbnails.php プロジェクト: lchen01/STEdwards
function wppa_get_thumb_default($id)
{
    global $wpdb;
    // Validate args
    if (!wppa_is_int($id) || $id < '0') {
        wppa_dbg_msg('Please check file wppa-theme.php or any other php file that calls wppa_get_thumb_default(). Argument 1: photo id is missing or illegal!', 'red', 'force');
        die('Please check your configuration');
    }
    // Initialize
    $result = '';
    // Get the photo info
    $thumb = wppa_cache_thumb($id);
    // Get the album info
    $album = wppa_cache_album($thumb['album']);
    wppa('current_album', $album['id']);
    // Get photo info
    $is_video = wppa_is_video($id);
    $has_audio = wppa_has_audio($id);
    $com_alt = wppa('is_comten') && wppa_switch('comten_alt_display') && !wppa_in_widget();
    $frameattr_a = wppa_get_thumb_frame_style_a();
    $framestyle = $frameattr_a['style'];
    $framewidth = $frameattr_a['width'];
    $frameheight = $frameattr_a['height'];
    // Get class depending of comment alt display
    if ($com_alt) {
        $class = 'thumbnail-frame-comalt thumbnail-frame-comalt-' . wppa('mocc') . ' thumbnail-frame-photo-' . $id;
    } else {
        $class = 'thumbnail-frame thumbnail-frame-' . wppa('mocc') . ' thumbnail-frame-photo-' . $id;
    }
    // If no image to display, die gracefully
    $imgsrc = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id);
    if (!wppa_is_video($id) && !is_file($imgsrc) && !wppa_has_audio($id)) {
        $result .= '<div' . ' class="' . $class . '"' . ' style="' . $framestyle . '; color:red;" >' . 'Missing thumbnail image #' . $id . '</div>';
        return $result;
    }
    // Find image attributes
    $alt = $album['alt_thumbsize'] == 'yes' ? '_alt' : '';
    $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, wppa_opt('thumbsize' . $alt), 'optional', 'thumb');
    $imgstyle = $imgattr_a['style'];
    $imgwidth = $imgattr_a['width'];
    $imgheight = $imgattr_a['height'];
    $imgmargintop = $imgattr_a['margin-top'];
    $imgmarginbottom = $imgattr_a['margin-bottom'];
    // Special case for comment alt display
    if ($com_alt) {
        $imgwidth = wppa_opt('comten_alt_thumbsize');
        $imgheight = round($imgwidth * $imgattr_a['height'] / $imgattr_a['width']);
        $imgstyle .= 'float:left; margin:0 20px 8px 0;width:' . $imgwidth . 'px; height:' . $imgheight . 'px;';
    }
    // Cursor depends on link
    $cursor = $imgattr_a['cursor'];
    // Find the required image sizes
    if (wppa_switch('use_thumb_popup')) {
        // Landscape?
        if ($imgwidth > $imgheight) {
            $popwidth = wppa_opt('popupsize');
            $popheight = round($popwidth * $imgheight / $imgwidth);
        } else {
            $popheight = wppa_opt('popupsize');
            $popwidth = round($popheight * $imgwidth / $imgheight);
        }
    } else {
        $popwidth = $imgwidth;
        $popheight = $imgheight;
    }
    // More image attributes
    $imgurl = wppa_fix_poster_ext(wppa_get_thumb_url($id, '', $popwidth, $popheight), $id);
    $events = wppa_get_imgevents('thumb', $id);
    $imgalt = wppa_get_imgalt($id);
    // returns something like ' alt="Any text" '
    $title = esc_attr(wppa_get_photo_name($id));
    // Feed ?
    if (is_feed()) {
        $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, '100', '4', 'thumb');
        $style = $imgattr_a['style'];
        $result .= '<a href="' . get_permalink() . '">' . '<img src="' . $imgurl . '" ' . $imgalt . ' title="' . $title . '" style="' . $style . '" />' . '</a>';
        return $result;
    }
    // Open Com alt wrapper
    if ($com_alt) {
        $result .= '<div>';
    }
    // Open the thumbframe
    $result .= '<div' . ' id="thumbnail_frame_' . $id . '_' . wppa('mocc') . '"' . ' class="' . $class . '"' . ' style="' . $framestyle . '"' . ' >';
    // Open the image container
    $imgcontheight = $com_alt ? $imgheight : max($imgwidth, $imgheight);
    if (!is_file($imgsrc)) {
        $imgcontheight = 2 * wppa_get_audio_control_height();
    }
    if ($com_alt) {
        $framewidth = $imgwidth + '4';
    }
    $result .= '<div' . ' class="wppa-tn-img-container"' . ' style="' . 'height:' . $imgcontheight . 'px;' . 'width:' . $framewidth . 'px;' . ($com_alt ? 'float:left;' : '') . 'overflow:hidden;"' . '>';
    // The medals if at the top
    $medalsize = $com_alt ? 'S' : 'M';
    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => $medalsize, 'where' => 'top'));
    // The audio when no popup
    if (wppa_switch('thumb_audio') && wppa_has_audio($id) && !$com_alt) {
        $result .= '<div style="position:relative;z-index:11;">';
        $is_safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari');
        $cont_h = $is_safari ? 16 : 28;
        $audiotop = $imgattr_a['height'] + $imgattr_a['margin-top'] - $cont_h;
        if (!is_file($imgsrc)) {
            // Audio without image
            $audiotop = wppa_get_audio_control_height();
            $imgwidth = wppa_opt('tf_width');
            $imgheight = wppa_get_audio_control_height();
        }
        $result .= wppa_get_audio_html(array('id' => $id, 'width' => $imgwidth, 'height' => $cont_h, 'style' => 'position:absolute;top:' . $audiotop . 'px;left:0;border:none;'));
        $result .= '</div>';
    }
    // Get the image link
    if (wppa('is_topten')) {
        $no_album = !wppa('start_album');
        if ($no_album) {
            $tit = __('View the top rated photos', 'wp-photo-album-plus');
        } else {
            $tit = esc_attr(__(stripslashes($thumb['description'])));
        }
        $link = wppa_get_imglnk_a('thumb', $id, '', $tit, '', $no_album);
    } else {
        $link = wppa_get_imglnk_a('thumb', $id);
    }
    // voor parent uplr
    // See if ajax possible
    if ($link) {
        // Is link an url?
        if ($link['is_url']) {
            if (wppa_switch('allow_ajax') && wppa_opt('thumb_linktype') == 'photo' && wppa_opt('thumb_linkpage') == '0' && !wppa_switch('thumb_blank') && !(wppa_switch('thumb_overrule') && $thumb['linkurl']) && !wppa('is_topten') && !wppa('is_lasten') && !wppa('is_comten') && !wppa('is_featen') && !wppa('is_tag') && !wppa('is_upldr') && !wppa('src') && !wppa('supersearch') && (wppa_is_int(wppa('start_album')) || wppa('start_album') == '')) {
                // Ajax	possible
                // The a img ajax
                $p = wppa('calendar') ? '' : '&amp;wppa-photo=' . $id;
                $onclick = 'wppaDoAjaxRender( ' . wppa('mocc') . ', \'' . wppa_get_slideshow_url_ajax(wppa('start_album'), '0') . '&amp;wppa-photo=' . $id . '\', \'' . wppa_convert_to_pretty(wppa_get_slideshow_url(wppa('start_album'), '0') . $p) . '\' )';
                $result .= '<a style="position:static;" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">';
                // Video?
                if ($is_video) {
                    $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => $onclick, 'lb' => false, 'class' => '', 'style' => $imgstyle));
                } else {
                    $result .= '<img' . ' onclick="' . $onclick . '"' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />';
                }
                // Close the a img ajax
                $result .= '</a>';
            } else {
                // The a img non ajax
                $result .= '<a style="position:static;" href="' . $link['url'] . '" target="' . $link['target'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">';
                if ($is_video) {
                    $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle));
                } else {
                    $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '" ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />';
                }
                // Close the img non ajax
                $result .= '</a>';
            }
        } elseif ($link['is_lightbox']) {
            $title = wppa_get_lbtitle('thumb', $id);
            // The a img
            $result .= '<a href="' . $link['url'] . '" target="' . $link['target'] . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '" ' . ' class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">';
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => $cursor, 'events' => $events, 'title' => wppa_zoom_in($id), 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle));
            } else {
                $title = wppa_zoom_in($id);
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' />';
            }
            // Close the a img
            $result .= '</a>';
        } else {
            // is onclick
            // The div img
            $result .= '<div onclick="' . $link['url'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">';
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle));
            } else {
                $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />';
            }
            $result .= '</div>';
            $result .= '<script type="text/javascript">';
            $result .= '/* <![CDATA[ */';
            $result .= 'wppaPopupOnclick[' . $id . '] = "' . $link['url'] . '";';
            $result .= '/* ]]> */';
            $result .= '</script>';
        }
    } else {
        // no link
        if (wppa_switch('use_thumb_popup')) {
            $result .= '<div id="x-' . $id . '-' . wppa('mocc') . '">';
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle));
            } else {
                $result .= '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />';
            }
            $result .= '</div>';
        } else {
            if ($is_video) {
                $result .= wppa_get_video_html(array('id' => $id, 'width' => $imgwidth, 'height' => $imgheight, 'controls' => wppa_switch('thumb_video'), 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle));
            } else {
                $result .= '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />';
            }
        }
    }
    // The medals if near the bottom
    $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => $medalsize, 'where' => 'bot'));
    // Close the image container
    $result .= '</div>';
    /*
    	// The audio when popup
    	if ( wppa_switch( 'use_thumb_popup' ) && wppa_switch( 'thumb_audio' ) && wppa_has_audio( $id ) && ! $com_alt ) {
    		$result .= wppa_get_audio_html( array(
    							'id' 		=> $id,
    							'width'		=> $imgwidth
    							));
    	}
    */
    // Comten alt display?
    if ($com_alt) {
        $result .= '<div' . ' class="wppa-com-alt wppa-com-alt-' . wppa('mocc') . '"' . ' style="' . 'height:' . $imgheight . 'px;' . 'overflow:auto;' . 'margin: 0 0 8px 10px;' . 'border:1px solid ' . wppa_opt('bcolor_alt') . ';' . '"' . ' >';
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s AND `status` = 'approved' ORDER BY `timestamp` DESC", $id), ARRAY_A);
        $first = true;
        if ($comments) {
            foreach ($comments as $com) {
                $result .= '<h6' . ' style="' . 'font-size:10px;' . 'line-height:12px;' . 'font-weight:bold;' . 'padding:' . ($first ? '0' : '6px') . ' 0 0 6px;' . 'margin:0;float:left;' . '"' . '>' . $com['user'] . ' ' . __('wrote', 'wp-photo-album-plus') . ' ' . wppa_get_time_since($com['timestamp']) . ':' . '</h6>' . '<p' . ' style="' . 'font-size:10px;' . 'line-height:12px;' . 'padding:0 0 0 6px;' . 'text-align:left;' . 'margin:0;' . 'clear:left;' . '"' . '>' . html_entity_decode(convert_smilies(stripslashes($com['comment']))) . '</p>';
                $first = false;
            }
        }
        $result .= '</div>';
    } else {
        // Open the subtext container
        $margtop = wppa_switch('align_thumbtext') ? '' : 'margin-top:' . -$imgmarginbottom . 'px;';
        $subtextcontheight = $frameheight - max($imgwidth, $imgheight);
        if (!wppa_switch('align_thumbtext')) {
            $subtextcontheight += $imgmarginbottom;
        }
        $result .= '<div' . ' style="' . 'height:' . $subtextcontheight . 'px;' . 'width:' . $framewidth . 'px;' . 'position:absolute;' . $margtop . 'overflow:hidden;' . '" >';
        // Single button voting system
        if (wppa_opt('rating_max') == '1' && wppa_switch('vote_thumb')) {
            $mylast = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_RATING . '` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $id, wppa_get_user()), ARRAY_A);
            $buttext = $mylast ? __(wppa_opt('voted_button_text'), 'wp-photo-album-plus') : __(wppa_opt('vote_button_text'), 'wp-photo-album-plus');
            $result .= '<input' . ' id="wppa-vote-button-' . wppa('mocc') . '-' . $id . '"' . ' class="wppa-vote-button-thumb"' . ' style="margin:0;"' . ' type="button"' . ' onclick="wppaVoteThumb( ' . wppa('mocc') . ', ' . $id . ' )"' . ' value="' . $buttext . '"' . ' />';
        }
        // Name
        if (wppa_switch('thumb_text_name') || wppa_switch('thumb_text_owner')) {
            $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . wppa_get_photo_name($id, wppa_switch('thumb_text_owner'), false, false, wppa_switch('thumb_text_name')) . '</div>';
        }
        // searching, link to album
        //		if ( wppa( 'src' ) || wppa( 'supersearch' ) || ( ( wppa( 'is_comten') || wppa( 'is_topten' ) || wppa( 'is_lasten' ) || wppa( 'is_featen') ) && wppa( 'start_album' ) != $thumb['album'] ) ) {
        if (wppa_switch('thumb_text_virt_album') && wppa_is_virtual() && wppa('start_album') != $thumb['album']) {
            $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . '<a' . ' href="' . wppa_get_album_url($thumb['album']) . '"' . ' >' . '<span class="wppa-tnpar" >(</span>' . stripslashes(__(wppa_get_album_name($thumb['album']), 'wp-photo-album-plus')) . '<span class="wppa-tnpar" >)</span>' . '</a>' . '</div>';
        }
        // Share
        if (wppa_switch('share_on_thumbs')) {
            $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . wppa_get_share_html($id, 'thumb') . '</div>';
        }
        // Delete and Edit links
        if (wppa_switch('edit_thumb') && !wppa_is_user_blacklisted()) {
            if (wppa_user_is('administrator') || current_user_can('wppa_moderate') || wppa_get_user() == wppa_get_photo_owner($id) && wppa_switch('upload_edit')) {
                $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . '<a' . ' style="color:red;cursor:pointer;"' . ' onclick="' . esc_attr('if ( confirm( "' . __('Are you sure you want to remove this photo?', 'wp-photo-album-plus') . '" ) ) wppaAjaxRemovePhoto( ' . wppa('mocc') . ', ' . $id . ', false ); return false;') . '"' . ' >' . __('Delete', 'wp-photo-album-plus') . '</a>' . '&nbsp;' . '<a' . ' style="color:green;cursor:pointer;"' . ' onclick="wppaEditPhoto( ' . wppa('mocc') . ', ' . $id . ' ); return false;"' . ' >' . __('Edit', 'wp-photo-album-plus') . '</a>' . '</div>';
            }
        }
        // Description
        if (wppa_switch('thumb_text_desc') || $thumb['status'] == 'pending' || $thumb['status'] == 'scheduled') {
            $desc = '';
            if ($thumb['status'] == 'pending' || $thumb['status'] == 'scheduled') {
                $desc .= wppa_moderate_links('thumb', $id);
            }
            $desc .= wppa_get_photo_desc($id, wppa_switch('allow_foreign_shortcodes_thumbs'));
            $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . $desc . '</div>';
        }
        // Rating
        if (wppa_switch('thumb_text_rating')) {
            $rating = wppa_get_rating_by_id($id);
            if ($rating && wppa_switch('show_rating_count')) {
                $rating .= ' ( ' . wppa_get_rating_count_by_id($id) . ' )';
            }
            $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . $rating . '</div>';
        }
        // Comcount
        if (wppa_switch('thumb_text_comcount')) {
            $comcount = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `photo` = " . $id);
            if ($comcount) {
                $result .= '<div' . ' class="wppa-thumb-text"' . ' style="' . __wcs('wppa-thumb-text') . '"' . ' >' . sprintf(_n('%d comment', '%d comments', $comcount, 'wp-photo-album-plus'), $comcount) . '</div>';
            }
        }
        // Viewcount
        if (wppa_switch('thumb_text_viewcount')) {
            $result .= '<div' . ' class="wppa-thumb-text"' . ' style="clear:both;' . __wcs('wppa-thumb-text') . '"' . ' >' . sprintf(_n('%d view', '%d views', $thumb['views'], 'wp-photo-album-plus'), $thumb['views']) . '</div>';
        }
        // Close the subtext container
        $result .= '</div>';
    }
    // if ! $com_alt
    // Close the thumbframe
    $result .= '</div>';
    if ($com_alt) {
        $result .= '</div>';
    }
    return $result;
}
コード例 #5
0
function wppa_make_tinymce_dialog()
{
    global $wpdb;
    // Prepare albuminfo
    $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC", ARRAY_A);
    if (wppa_switch('hier_albsel')) {
        $albums = wppa_add_paths($albums);
        $albums = wppa_array_sort($albums, 'name');
    }
    // Prepare photoinfo
    $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A);
    // Get Tags/cats
    $tags = wppa_get_taglist();
    $cats = wppa_get_catlist();
    // Make the html
    $result = '<div id="wppagallery-form">' . '<style type="text/css">' . '#wppagallery-table tr, #wppagallery-table th, #wppagallery-table td {' . 'padding: 2px; 0;' . '}' . '</style>' . '<table id="wppagallery-table" class="form-table">' . '<tr >' . '<th><label for="wppagallery-top-type">' . __('Type of WPPA display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-top-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a display type', 'wp-photo-album-plus') . ' --</option>' . '<option value="galerytype" style="color:#070" >' . __('A gallery with covers and/or thumbnails', 'wp-photo-album-plus') . '</option>' . '<option value="slidestype" style="color:#070" >' . __('A slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="singletype" style="color:#070" >' . __('A single image', 'wp-photo-album-plus') . '</option>' . '<option value="searchtype" style="color:#070" >' . __('A search/selection box', 'wp-photo-album-plus') . '</option>' . '<option value="misceltype" style="color:#070" >' . __('An other box type', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-galery-type-tr" style="display:none;" >' . '<th><label for="wppagallery-galery-type">' . __('Type of gallery display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-galery-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a gallery type', 'wp-photo-album-plus') . ' --</option>' . '<option value="cover" style="color:#070" >' . __('The cover(s) of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="content" style="color:#070" >' . __('The content of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="covers" style="color:#070" >' . __('The covers of the subalbums of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="thumbs" style="color:#070" >' . __('The thumbnails of specific album(s)', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-slides-type-tr" style="display:none;" >' . '<th><label for="wppagallery-slides-type">' . __('Type of slideshow:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-slides-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a slideshow type', 'wp-photo-album-plus') . ' --</option>' . '<option value="slide" style="color:#070" >' . __('A fully featured slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="slideonly" style="color:#070" >' . __('A slideshow without supporting boxes', 'wp-photo-album-plus') . '</option>' . '<option value="slideonlyf" style="color:#070" >' . __('A slideshow with a filmstrip only', 'wp-photo-album-plus') . '</option>' . '<option value="filmonly" style="color:#070" >' . __('A filmstrip only', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-single-type-tr" style="display:none;" >' . '<th><label for="wppagallery-single-type">' . __('Type of single image:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-single-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a single image type', 'wp-photo-album-plus') . ' --</option>' . '<option value="photo" style="color:#070" >' . __('A plain single photo', 'wp-photo-album-plus') . '</option>' . '<option value="mphoto" style="color:#070" >' . __('A single photo with caption', 'wp-photo-album-plus') . '</option>' . '<option value="slphoto" style="color:#070" >' . __('A single photo in the style of a slideshow', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-search-type-tr" style="display:none;" >' . '<th><label for="wppagallery-search-type">' . __('Type of search:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-search-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a search type', 'wp-photo-album-plus') . ' --</option>' . '<option value="search" style="color:#070" >' . __('A search box', 'wp-photo-album-plus') . '</option>' . '<option value="supersearch" style="color:#070" >' . __('A supersearch box', 'wp-photo-album-plus') . '</option>' . '<option value="tagcloud" style="color:#070" >' . __('A tagcloud box', 'wp-photo-album-plus') . '</option>' . '<option value="multitag" style="color:#070" >' . __('A multitag box', 'wp-photo-album-plus') . '</option>' . '<option value="superview" style="color:#070" >' . __('A superview box', 'wp-photo-album-plus') . '</option>' . '<option value="calendar" style="color:#070" >' . __('A calendar box', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-miscel-type-tr" style="display:none;" >' . '<th><label for="wppagallery-miscel-type">' . __('Type miscellaneous:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-miscel-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a miscellaneous display', 'wp-photo-album-plus') . ' --</option>' . '<option value="generic">' . __('A generic albums display', 'wp-photo-album-plus') . '</option>' . '<option value="upload">' . __('An upload box', 'wp-photo-album-plus') . '</option>' . '<option value="landing">' . __('A landing page shortcode', 'wp-photo-album-plus') . '</option>' . '<option value="stereo">' . __('A 3D stereo settings box', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-type-tr" style="display:none;" >' . '<th><label for="wppagallery-album-type">' . __('Kind of selection:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a type of selection to be used', 'wp-photo-album-plus') . ' --</option>' . '<option value="real">' . __('One or more wppa+ albums', 'wp-photo-album-plus') . '</option>' . '<option value="virtual">' . __('A special selection', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-virt-tr" style="display:none;" >' . '<th><label for="wppagallery-album-virt">' . __('The selection to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-virt" name="album" class="wppagallery-album" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a virtual album', 'wp-photo-album-plus') . ' --</option>' . '<option value="#last" >' . __('The most recently modified album', 'wp-photo-album-plus') . '</option>' . '<option value="#topten" >' . __('The top rated photos', 'wp-photo-album-plus') . '</option>' . '<option value="#lasten" >' . __('The most recently uploaded photos', 'wp-photo-album-plus') . '</option>' . '<option value="#featen" >' . __('A random selection of featured photos', 'wp-photo-album-plus') . '</option>' . '<option value="#comten" >' . __('The most recently commented photos', 'wp-photo-album-plus') . '</option>' . '<option value="#tags" >' . __('Photos that have certain tags', 'wp-photo-album-plus') . '</option>' . '<option value="#cat" >' . __('Albums tagged with a certain category', 'wp-photo-album-plus') . '</option>' . '<option value="#owner" >' . __('Photos in albums owned by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#upldr" >' . __('Photos uploaded by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#all" >' . __('All photos in the system', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-virt-cover-tr" style="display:none;" >' . '<th><label for="wppagallery-album-virt-cover">' . __('The selection to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-virt-cover" name="album" class="wppagallery-album" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a virtual album', 'wp-photo-album-plus') . ' --</option>' . '<option value="#last" >' . __('The most recently modified album', 'wp-photo-album-plus') . '</option>' . '<option value="#owner" >' . __('Albums owned by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#cat" >' . __('Albums tagged with a certain category', 'wp-photo-album-plus') . '</option>' . '<option value="#all" >' . __('All albums in the system', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-real-tr" style="display:none;" >' . '<th><label for="wppagallery-album-real">' . __('The Album(s) to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-real" style="max-width:400px;" name="album" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option id="wppagallery-album-0" value="0" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select one or more albums', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album-r" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-realopt-tr" style="display:none;" >' . '<th><label for="wppagallery-album-realopt">' . __('The Album(s) to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-realopt" style="max-width:400px;" name="album" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option id="wppagallery-album-0" class="wppagallery-album-ropt" value="0" selected="selected" style="color:#070" >-- ' . __('All albums', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album-ropt" style="color:#070" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-owner-tr" style="display:none" >' . '<th><label for="wppagallery-owner">' . __('The album owner:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-owner" name="owner" class="wppagallery-owner" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a user', 'wp-photo-album-plus') . ' --</option>' . '<option value="#me" >-- ' . __('The logged in visitor', 'wp-photo-album-plus') . ' --</option>';
    $users = wppa_get_users();
    if ($users) {
        foreach ($users as $user) {
            $result .= '<option value="' . $user['user_login'] . '" >' . $user['display_name'] . '</option>';
        }
    } else {
        // Too many
        $result .= '<option value="xxx" >-- ' . __('Too many users, edit manually', 'wp-photo-album-plus') . ' --</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-owner-parent-tr" style="display:none;" >' . '<th><label for="wppagallery-owner-parent">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-owner-parent" style="color:#070;max-width:400px;" name="parentalbum" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option value="" selected="selected" >-- ' . __('No parent specification', 'wp-photo-album-plus') . ' --</option>';
        // Generic
        $result .= '<option value="0" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album-p" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-parent-tr" style="display:none;" >' . '<th><label for="wppagallery-album-parent">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-parent-parent" style="color:#070;max-width:400px;" name="parentalbum" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option id="wppagallery-album-0" value="0" selected="selected" style="color:#700" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-count-tr" style="display:none;" >' . '<th><label for="wppagallery-album-count">' . __('Max Albums:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-album-count" type="text" style="color:#070;" value="1" onchange="wppaGalleryEvaluate()" />' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-count-tr" style="display:none;" >' . '<th><label for="wppagallery-photo-count">' . __('Max Photos:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-photo-count" type="text" style="color:#070;" value="1" onchange="wppaGalleryEvaluate()" />' . '</td>' . '</tr>' . '<tr id="wppagallery-albumcat-tr" style="display:none;" >' . '<th><label for="wppagallery-albumcat">' . __('The cat the albums should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-albumcat" style="color:#700;" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >' . __('--- please select category ---', 'wp-photo-album-plus') . '</option>';
    if ($cats) {
        foreach (array_keys($cats) as $cat) {
            $result .= '<option value="' . $cat . '" >' . $cat . '</option>';
        }
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-tr" style="display:none;" >' . '<th><label for="wppagallery-photo" class="wppagallery-photo" >' . __('The Photo to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-photo" name="photo" class="wppagallery-photo" onchange="wppaGalleryEvaluate()" >';
    if ($photos) {
        // Please select
        $result .= '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a photo', 'wp-photo-album-plus') . ' --</option>';
        // Most recent 100 photos
        foreach ($photos as $photo) {
            $name = stripslashes(__($photo['name'], 'wp-photo-album-plus'));
            if (strlen($name) > '50') {
                $name = substr($name, '0', '50') . '...';
            }
            if (get_option('wppa_file_system') == 'flat') {
                $result .= '<option value="' . wppa_fix_poster_ext($photo['id'] . '.' . $photo['ext'], $photo['id']) . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            } else {
                $result .= '<option value="' . wppa_fix_poster_ext(wppa_expand_id($photo['id']) . '.' . $photo['ext'], $photo['id']) . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            }
        }
        $result .= '<option value="#last" >-- ' . __('The most recently uploaded photo', 'wp-photo-album-plus') . ' --</option>' . '<option value="#potd" >-- ' . __('The photo of the day', 'wp-photo-album-plus') . ' --</option>';
    } else {
        $result .= '<option value="0" >' . __('There are no photos yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '<br />' . '<small style="display:none;" class="wppagallery-photo" >' . __('Specify the photo to be used', 'wp-photo-album-plus') . '<br />' . __('You can select from a maximum of 100 most recently added photos', 'wp-photo-album-plus') . '<br />' . '</small>' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-preview-tr" style="display:none;" >' . '<th><label for="wppagallery-photo-preview" >' . __('Preview image:', 'wp-photo-album-plus') . '</label></th>' . '<td id="wppagallery-photo-preview" style="text-align:center;" >' . '</td >' . '</tr>' . '<tr id="wppagallery-phototags-tr" style="display:none;" >' . '<th><label for="wppagallery-phototags">' . __('The tags the photos should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-phototags" style="color:#700;" multiple="multiple" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >' . __('--- please select tag(s) ---', 'wp-photo-album-plus') . '</option>';
    if ($tags) {
        foreach (array_keys($tags) as $tag) {
            $result .= '<option class="wppagallery-phototags" value="' . $tag . '" >' . $tag . '</option>';
        }
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-search-tr" style="display:none;" >' . '<th><label>' . __('Additional features:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-sub" type="checkbox" name="sub" onchange="wppaGalleryEvaluate()"/>' . __('Enable Subsearch', 'wp-photo-album-plus') . '&nbsp;' . '<input id="wppagallery-root" type="checkbox" name="root" onchange="wppaGalleryEvaluate()"/>' . __('Enable Rootsearch', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr id="wppagallery-taglist-tr" style="display:none;" >' . '<th><label>' . __('Additional features:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-alltags" type="checkbox" checked="checked" name="alltags" onchange="wppaGalleryEvaluate()"/>' . __('Enable all tags', 'wp-photo-album-plus') . '&nbsp;' . '<select id="wppagallery-seltags" style="color:#070; display:none;" name="seltags" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($tags) {
        '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select the tags to show', 'wp-photo-album-plus') . ' --</option>';
        foreach (array_keys($tags) as $tag) {
            $result .= '<option class="wppagallery-taglist-tags" value="' . $tag . '"style="color:#700" >' . $tag . '</option>';
        }
    } else {
        '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('There are no tags', 'wp-photo-album-plus') . ' --</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-super-tr" style="display:none;" >' . '<th><label for="wppagallery-album-super">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-super-parent" style="color:#070;max-width:400px;" name="parentalbum" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option value="" selected="selected" style="color:#700" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-calendar-tr" style="display:none;" >' . '<th><label for="wppagallery-calendar">' . __('Calendar type:', 'wp-photo-album-plus') . '</lable></th>' . '<td>' . '<select id="wppagallery-calendar-type" style="color:#070;max-width:400px;" onchange="wppaGalleryEvaluate()" >' . '<option value="exifdtm" >' . __('By EXIF date', 'wp-photo-album-plus') . '</option>' . '<option value="timestamp" >' . __('By date of upload', 'wp-photo-album-plus') . '</option>' . '<option value="modified" >' . __('By date last modified', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<input type="checkbox" id="wppagallery-calendar-reverse" onchange="wppaGalleryEvaluate()" >' . __('Last date first', 'wp-photo-album-plus') . '&nbsp;&nbsp;' . '<input type="checkbox" id="wppagallery-calendar-allopen" onchange="wppaGalleryEvaluate()" >' . __('Initially display all', 'wppw', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-size">' . __('The size of the display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input type="text" id="wppagallery-size" value="" style="color:#070;" onchange="wppaGalleryEvaluate();"/>' . '<br />' . '<small>' . __('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus') . ' ' . __('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus') . '<br />' . __('Leave this blank for default size', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-align">' . __('Horizontal alignment:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-align" name="align" style="color:#070;" onchange="wppaGalleryEvaluate();">' . '<option value="none" >' . __('--- none ---', 'wp-photo-album-plus') . '</option>' . '<option value="left" >' . __('left', 'wp-photo-album-plus') . '</option>' . '<option value="center" >' . __('center', 'wp-photo-album-plus') . '</option>' . '<option value="right" >' . __('right', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the alignment to be used or --- none ---', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '</table>' . '<div id="wppagallery-shortcode-preview-container" >' . '<input type="text" id="wppagallery-shortcode-preview" style="background-color:#ddd; width:100%; height:26px;" value="[wppa]Any comment[/wppa]" />' . '</div>' . '<div><small>' . __('This is a preview of the shortcode that is being generated. You may edit the comment', 'wp-photo-album-plus') . '</small></div>' . '<p class="submit">' . '<input type="button" id="wppagallery-submit" class="button-primary" value="' . __('Insert Gallery', 'wp-photo-album-plus') . '" name="submit" />&nbsp;' . '<input type="button" id="wppagallery-submit-notok" class="button-secundary" value="' . __('insert Gallery', 'wp-photo-album-plus') . '" onclick="alert(\'' . esc_js(__('Please complete the shortcode specs', 'wp-photo-album-plus')) . '\')" />&nbsp;' . '</p>' . '</div>' . '<script type="text/javascript" >wppaGalleryEvaluate();</script>';
    return $result;
}
コード例 #6
0
function wppa_insert_photo($file = '', $alb = '', $name = '', $desc = '', $porder = '0', $id = '0', $linkurl = '', $linktitle = '')
{
    global $wpdb;
    global $warning_given_small;
    $album = wppa_cache_album($alb);
    if (!wppa_allow_uploads($alb)) {
        if (is_admin() && !wppa('ajax')) {
            wppa_error_message(sprintf(__('Album %s is full', 'wp-photo-album-plus'), wppa_get_album_name($alb)));
        } else {
            wppa_alert(sprintf(__('Album %s is full', 'wp-photo-album-plus'), wppa_get_album_name($alb)));
        }
        return false;
    }
    if ($file != '' && $alb != '') {
        // Get the name if not given
        if ($name == '') {
            $name = basename($file);
        }
        // Sanitize name
        $filename = wppa_sanitize_file_name($name);
        $name = wppa_sanitize_photo_name($name);
        // If not dups allowed and its already here, quit
        if (isset($_POST['wppa-nodups']) || wppa_switch('void_dups')) {
            $exists = wppa_file_is_in_album($filename, $alb);
            if ($exists) {
                if (isset($_POST['del-after-p'])) {
                    unlink($file);
                    $msg = __('Photo %s already exists in album number %s. Removed from depot.', 'wp-photo-album-plus');
                } else {
                    $msg = __('Photo %s already exists in album number %s.', 'wp-photo-album-plus');
                }
                wppa_warning_message(sprintf($msg, $name, $alb));
                return false;
            }
        }
        // Verify file exists
        if (!wppa('is_remote') && !file_exists($file)) {
            if (!is_dir(dirname($file))) {
                wppa_error_message('Error: Directory ' . dirname($file) . ' does not exist.');
                return false;
            }
            if (!is_writable(dirname($file))) {
                wppa_error_message('Error: Directory ' . dirname($file) . ' is not writable.');
                return false;
            }
            wppa_error_message('Error: File ' . $file . ' does not exist.');
            return false;
        }
        //		else {
        //			wppa_ok_message( 'Good: File '.$file.' exists.' );
        //		}
        // Get and verify the size
        $img_size = getimagesize($file);
        if ($img_size) {
            if (wppa_check_memory_limit('', $img_size['0'], $img_size['1']) === false) {
                wppa_error_message(sprintf(__('ERROR: Attempt to upload a photo that is too large to process (%s).', 'wp-photo-album-plus'), $name) . wppa_check_memory_limit());
                wppa('ajax_import_files_error', __('Too big', 'wp-photo-album-plus'));
                return false;
            }
            if (!$warning_given_small && ($img_size['0'] < wppa_get_minisize() && $img_size['1'] < wppa_get_minisize())) {
                wppa_warning_message(__('WARNING: You are uploading photos that are too small. Photos must be larger than the thumbnail size and larger than the coverphotosize.', 'wp-photo-album-plus'));
                wppa('ajax_import_files_error', __('Too small', 'wp-photo-album-plus'));
                $warning_given_small = true;
            }
        } else {
            wppa_error_message(__('ERROR: Unable to retrieve image size of', 'wp-photo-album-plus') . ' ' . $name . ' ' . __('Are you sure it is a photo?', 'wp-photo-album-plus'));
            wppa('ajax_import_files_error', __('No imagesize', 'wp-photo-album-plus'));
            return false;
        }
        // Get ext based on mimetype, regardless of ext
        switch ($img_size[2]) {
            // mime type
            case 1:
                $ext = 'gif';
                break;
            case 2:
                $ext = 'jpg';
                break;
            case 3:
                $ext = 'png';
                break;
            default:
                wppa_error_message(__('Unsupported mime type encountered:', 'wp-photo-album-plus') . ' ' . $img_size[2] . '.');
                return false;
        }
        // Get an id if not yet there
        if ($id == '0') {
            $id = wppa_nextkey(WPPA_PHOTOS);
        }
        // Get opt deflt desc if empty
        if ($desc == '' && wppa_switch('apply_newphoto_desc')) {
            $desc = stripslashes(wppa_opt('newphoto_description'));
        }
        // Reset rating
        $mrat = '0';
        // Find ( new ) owner
        $owner = wppa_get_user();
        // Validate album
        if (!is_numeric($alb) || $alb < '1') {
            wppa_error_message(__('Album not known while trying to add a photo', 'wp-photo-album-plus'));
            return false;
        }
        if (!wppa_have_access($alb)) {
            wppa_error_message(sprintf(__('Album %s does not exist or is not accessable while trying to add a photo', 'wp-photo-album-plus'), $alb));
            return false;
        }
        $status = wppa_switch('upload_moderate') && !current_user_can('wppa_admin') ? 'pending' : 'publish';
        // Add photo to db
        $id = wppa_create_photo_entry(array('id' => $id, 'album' => $alb, 'ext' => $ext, 'name' => $name, 'p_order' => $porder, 'description' => $desc, 'linkurl' => $linkurl, 'linktitle' => $linktitle, 'owner' => $owner, 'status' => $status, 'filename' => $filename));
        if (!$id) {
            wppa_error_message(__('Could not insert photo.', 'wp-photo-album-plus'));
        } else {
            // Save the source
            wppa_save_source($file, $filename, $alb);
            wppa_flush_treecounts($alb);
            wppa_update_album(array('id' => $alb, 'modified' => time()));
            wppa_flush_upldr_cache('photoid', $id);
        }
        // Make the photo files
        if (wppa_make_the_photo_files($file, $id, $ext)) {
            // Repair photoname if not supplied and not standard
            wppa_set_default_name($id, $name);
            // Tags
            wppa_set_default_tags($id);
            // Index
            wppa_index_add('photo', $id);
            // and add watermark ( optionally ) to fullsize image only
            wppa_add_watermark($id);
            // also to thumbnail?
            if (wppa_switch('watermark_thumbs')) {
                wppa_create_thumbnail($id);
            }
            // Is it a default coverimage?
            wppa_check_coverimage($id);
            return $id;
        }
    } else {
        wppa_error_message(__('ERROR: Unknown file or album.', 'wp-photo-album-plus'));
        return false;
    }
}
コード例 #7
0
function wppa_verify_treecounts($alb, $key, $count)
{
    $treecounts = wppa_treecount_a($alb);
    $need_a = false;
    $need_p = false;
    // Number of albums ( $count ) equal to subalbums ( 'selfalbums' ) ?
    if ('albums' == $key) {
        if ($treecounts['selfalbums'] != $count) {
            // Faulty data
            $need_a = true;
        }
    }
    // Number of photos ( $count ) equal to photos in this album ( 'selfphotos' ( + opts ) )?
    if ('photos' == $key) {
        if (current_user_can('wppa_moderate')) {
            if ($treecounts['selfphotos'] + $treecounts['pendphotos'] + $treecounts['scheduledphotos'] != $count) {
                // Faulty data
                $need_p = true;
            }
        } else {
            if ($treecounts['selfphotos'] != $count) {
                // Faulty data
                $need_p = true;
            }
        }
    }
    // If no sub-albums, total number of photos should be equal to photos in this album ( 'selfphotos' )
    if (!$treecounts['selfalbums'] && $treecounts['photos'] != $treecounts['selfphotos']) {
        $need_p = true;
    }
    // Need recalc for reason albums fault?
    if ($need_a) {
        wppa_flush_treecounts($alb);
        wppa_log('Fix', 'Treecounts albums for album #' . $alb . ' (' . wppa_get_album_name($alb) . ')');
    }
    // Need recalc for reason photos fault?
    if ($need_p) {
        wppa_flush_treecounts($albumid);
        wppa_log('Fix', 'Treecounts photos for album #' . $alb . ' (' . wppa_get_album_name($alb) . ')');
    }
}
コード例 #8
0
function wppa_do_frontend_file_upload($file, $alb)
{
    global $wpdb;
    // Log upload attempt
    wppa_log('Upl', 'FE Upload attempt of file ' . $file['name'] . ', size=' . filesize($file['tmp_name']));
    $album = wppa_cache_album($alb);
    if (!wppa_allow_uploads($alb) || !wppa_allow_user_uploads()) {
        wppa_alert(__('Max uploads reached', 'wp-photo-album-plus'));
        return false;
    }
    if ($file['error'] != '0') {
        wppa_alert(__('Error during upload', 'wp-photo-album-plus'));
        return false;
    }
    $imgsize = getimagesize($file['tmp_name']);
    if (!is_array($imgsize)) {
        wppa_alert(__('Uploaded file is not an image', 'wp-photo-album-plus'));
        return false;
    }
    if ($imgsize[2] < 1 || $imgsize[2] > 3) {
        wppa_alert(sprintf(__('Only gif, jpg and png image files are supported. Returned filetype = %d.', 'wp-photo-album-plus'), $imagesize[2]));
        return false;
    }
    $ms = wppa_opt('upload_fronend_maxsize');
    if ($ms) {
        // Max size configured
        if ($imgsize[0] > $ms || $imgsize[0] > $ms) {
            wppa_alert(sprintf(__('Uploaded file is larger than the allowed maximum of %d x %d pixels.', 'wp-photo-album-plus'), $ms, $ms));
            return false;
        }
    }
    if (wppa_switch('void_dups')) {
        // Check for already exists
        if (wppa_file_is_in_album(wppa_sanitize_file_name($file['name']), $alb)) {
            wppa_alert(sprintf(__('Uploaded file %s already exists in this album.', 'wp-photo-album-plus'), wppa_sanitize_file_name($file['name'])));
            return false;
        }
    }
    $mayupload = wppa_check_memory_limit('', $imgsize[0], $imgsize[1]);
    if ($mayupload === false) {
        $maxsize = wppa_check_memory_limit(false);
        if (is_array($maxsize)) {
            wppa_alert(sprintf(__('The image is too big. Max photo size: %d x %d (%2.1f MegaPixel)', 'wp-photo-album-plus'), $maxsize['maxx'], $maxsize['maxy'], $maxsize['maxp'] / (1024 * 1024)));
            return false;
        }
    }
    switch ($imgsize[2]) {
        // mime type
        case 1:
            $ext = 'gif';
            break;
        case 2:
            $ext = 'jpg';
            break;
        case 3:
            $ext = 'png';
            break;
    }
    if (wppa_get_post('user-name')) {
        $name = wppa_get_post('user-name');
    } else {
        $name = $file['name'];
    }
    $name = wppa_sanitize_photo_name($name);
    $desc = balanceTags(wppa_get_post('user-desc'), true);
    $linktarget = '_self';
    $status = wppa_switch('upload_moderate') && !current_user_can('wppa_admin') ? 'pending' : 'publish';
    $filename = wppa_sanitize_file_name($file['name']);
    $id = wppa_create_photo_entry(array('album' => $alb, 'ext' => $ext, 'name' => $name, 'description' => $desc, 'status' => $status, 'filename' => $filename));
    if (!$id) {
        wppa_alert(__('Could not insert photo into db.', 'wp-photo-album-plus'));
        return false;
    } else {
        wppa_save_source($file['tmp_name'], $filename, $alb);
        wppa_update_album(array('id' => $alb, 'modified' => time()));
        wppa_flush_treecounts($alb);
        wppa_flush_upldr_cache('photoid', $id);
    }
    if (wppa_make_the_photo_files($file['tmp_name'], $id, $ext)) {
        // Repair photoname if not standard
        if (!wppa_get_post('user-name')) {
            wppa_set_default_name($id, $file['name']);
        }
        // Custom data
        if (wppa_switch('fe_custom_fields')) {
            $custom_data = array('', '', '', '', '', '', '', '', '', '');
            for ($i = '0'; $i < '10'; $i++) {
                if (isset($_POST['wppa-user-custom-' . $i])) {
                    $custom_data[$i] = strip_tags($_POST['wppa-user-custom-' . $i]);
                }
            }
            wppa_update_photo(array('id' => $id, 'custom' => serialize($custom_data)));
        }
        // Default tags
        wppa_set_default_tags($id);
        // Custom tags
        $tags = wppa_get_photo_item($id, 'tags');
        $oldt = $tags;
        for ($i = '1'; $i < '4'; $i++) {
            if (isset($_POST['wppa-user-tags-' . $i])) {
                // Existing tags
                $tags .= ',' . implode(',', $_POST['wppa-user-tags-' . $i]);
            }
        }
        if (isset($_POST['wppa-new-tags'])) {
            // New tags
            $newt = $_POST['wppa-new-tags'];
            $tags .= ',' . $newt;
        } else {
            $newt = '';
        }
        $tags = wppa_sanitize_tags(str_replace(array('\'', '"'), ',', wppa_filter_iptc(wppa_filter_exif($tags, $id), $id)));
        if ($tags != $oldt) {
            // Added tag(s)
            wppa_update_photo(array('id' => $id, 'tags' => $tags));
        }
        // Index
        wppa_index_add('photo', $id);
        // Tags
        if ($tags) {
            wppa_clear_taglist();
            // Forces recreation
        }
        // and add watermark ( optionally ) to fullsize image only
        wppa_add_watermark($id);
        // Also to thumbnail?
        if (wppa_switch('watermark_thumbs')) {
            wppa_create_thumbnail($id);
            // create new thumb
        }
        // Is it a default coverimage?
        wppa_check_coverimage($id);
        // Mail
        if (wppa_switch('upload_notify')) {
            $to = get_bloginfo('admin_email');
            $subj = sprintf(__('New photo uploaded: %s', 'wp-photo-album-plus'), $name);
            $cont['0'] = sprintf(__('User %1$s uploaded photo %2$s into album %3$s', 'wp-photo-album-plus'), wppa_get_user(), $id, wppa_get_album_name($alb));
            if (wppa_switch('upload_moderate') && !current_user_can('wppa_admin')) {
                $cont['1'] = __('This upload requires moderation', 'wp-photo-album-plus');
                $cont['2'] = '<a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Moderate manage photo', 'wp-photo-album-plus') . '</a>';
            } else {
                $cont['1'] = __('Details:', 'wp-photo-album-plus');
                $cont['1'] .= ' <a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Manage photo', 'wp-photo-album-plus') . '</a>';
            }
            wppa_send_mail($to, $subj, $cont, $id);
        }
        return true;
    } else {
        return false;
    }
}
コード例 #9
0
function wppa_write_photo_file($photo)
{
    global $wppa_zip;
    global $wppa_temp;
    global $wppa_temp_idx;
    if ($photo) {
        $fname = WPPA_DEPOT_PATH . '/' . $photo['id'] . '.pmf';
        $file = fopen($fname, 'wb');
        $err = false;
        if ($file) {
            if (fwrite($file, "name=" . $photo['name'] . "\n") !== FALSE) {
                if (fwrite($file, "desc=" . wppa_nl_to_txt($photo['description']) . "\n") !== FALSE) {
                    if (fwrite($file, "pord=" . $photo['p_order'] . "\n") !== FALSE) {
                        if (fwrite($file, "albm=" . wppa_get_album_name($photo['album'], 'raw') . "\n") !== FALSE) {
                            if (fwrite($file, "lnku=" . $photo['linkurl'] . "\n") !== FALSE) {
                                if (fwrite($file, "lnkt=" . $photo['linktitle'] . "\n") !== FALSE) {
                                    /*													
                                    					ext tinytext NOT NULL, 
                                    					mean_rating tinytext NOT NULL,
                                    					linktarget tinytext NOT NULL,
                                    					owner text NOT NULL,
                                    					timestamp tinytext NOT NULL,
                                    					status tinytext NOT NULL,
                                    					rating_count bigint(20) NOT NULL default '0',
                                    					tags tinytext NOT NULL,
                                    					alt tinytext NOT NULL,
                                    					filename tinytext NOT NULL,
                                    					modified tinytext NOT NULL,
                                    					location tinytext NOT NULL,
                                    */
                                } else {
                                    $err = true;
                                }
                            } else {
                                $err = true;
                            }
                        } else {
                            $err = true;
                        }
                    } else {
                        $err = true;
                    }
                } else {
                    $err = true;
                }
            } else {
                $err = true;
            }
            if ($err) {
                wppa_error_message(sprintf(__('Cannot write to file %s.', 'wp-photo-album-plus'), $fname));
                fclose($file);
                return false;
            } else {
                fclose($file);
                if ($wppa_zip) {
                    $wppa_zip->addFile($fname, basename($fname));
                }
                $wppa_temp[$wppa_temp_idx] = $fname;
                $wppa_temp_idx++;
            }
        } else {
            wppa_error_message(__('Could not open photo output file.', 'wp-photo-album-plus'));
            return false;
        }
    } else {
        wppa_error_message(__('Could not read photo data.', 'wp-photo-album-plus'));
        return false;
    }
    return true;
}
コード例 #10
0
function wppa_album_photos_bulk($album)
{
    global $wpdb;
    // Check input
    wppa_vfy_arg('wppa-page');
    // Init
    $count = '0';
    $abort = false;
    if (isset($_POST['wppa-bulk-action'])) {
        check_admin_referer('wppa-bulk', 'wppa-bulk');
        if (isset($_POST['wppa-bulk-photo'])) {
            $ids = $_POST['wppa-bulk-photo'];
            $newalb = isset($_POST['wppa-bulk-album']) ? $_POST['wppa-bulk-album'] : '0';
            $status = isset($_POST['wppa-bulk-status']) ? $_POST['wppa-bulk-status'] : '';
            $owner = isset($_POST['wppa-bulk-owner']) ? $_POST['wppa-bulk-owner'] : '';
            $totcount = count($ids);
            if (!is_numeric($newalb)) {
                wp_die('Security check failure 1');
            }
            if (is_array($ids)) {
                foreach (array_keys($ids) as $id) {
                    $skip = false;
                    switch ($_POST['wppa-bulk-action']) {
                        case 'wppa-bulk-delete':
                            wppa_delete_photo($id);
                            break;
                        case 'wppa-bulk-move-to':
                            if ($newalb) {
                                $photo = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $id), ARRAY_A);
                                if (wppa_switch('void_dups')) {
                                    // Check for already exists
                                    $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb));
                                    if ($exists) {
                                        // Already exists
                                        wppa_error_message(sprintf(__('A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photo['filename'], $newalb));
                                        $skip = true;
                                    }
                                }
                                if ($skip) {
                                    continue;
                                }
                                wppa_flush_treecounts($photo['album']);
                                // Current album
                                wppa_flush_treecounts($newalb);
                                // New album
                                $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `album` = %s WHERE `id` = %s', $newalb, $id));
                                wppa_move_source($photo['filename'], $photo['album'], $newalb);
                            } else {
                                wppa_error_message('Unexpected error #4 in wppa_album_photos_bulk().');
                            }
                            break;
                        case 'wppa-bulk-copy-to':
                            if ($newalb) {
                                $photo = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $id), ARRAY_A);
                                if (wppa_switch('void_dups')) {
                                    // Check for already exists
                                    $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb));
                                    if ($exists) {
                                        // Already exists
                                        wppa_error_message(sprintf(__($exists . 'A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photo['filename'], $newalb));
                                        $skip = true;
                                    }
                                }
                                if ($skip) {
                                    continue;
                                }
                                wppa_copy_photo($id, $newalb);
                                wppa_flush_treecounts($newalb);
                            } else {
                                wppa_error_message('Unexpected error #3 in wppa_album_photos_bulk().');
                            }
                            break;
                        case 'wppa-bulk-status':
                            if (!in_array($status, array('publish', 'pending', 'featured', 'scheduled', 'gold', 'silver', 'bronze', 'private'))) {
                                wppa_log('error', 'Unknown status ' . strip_tags($status) . ' found in wppa-photo-admin-autosave.php -> wppa_album_photos_bulk()');
                                $status = 'publish';
                            }
                            if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) {
                                if ($status == 'publish' || $status == 'pending' || wppa_user_is('administrator') || !wppa_switch('ext_status_restricted')) {
                                    $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `status` = '" . $status . "' WHERE `id` = " . $id);
                                    wppa_flush_treecounts($id, wppa_get_photo_item($id, 'album'));
                                } else {
                                    wp_die('Security check failure 2');
                                }
                            } else {
                                wp_die('Security check failure 3');
                            }
                            break;
                        case 'wppa-bulk-owner':
                            if (wppa_user_is('administrator') && wppa_switch('photo_owner_change')) {
                                if ($owner) {
                                    $owner = sanitize_user($owner);
                                    $exists = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->users . "` WHERE `user_login` = '" . $owner . "'");
                                    if ($exists) {
                                        $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `owner` = '" . $owner . "' WHERE `id` = " . $id);
                                    } else {
                                        wppa_error_message('A user with login name ' . $owner . ' does not exist.');
                                        $skip = true;
                                    }
                                } else {
                                    wp_die('Missing required arg in bulk change owner');
                                }
                            } else {
                                wp_die('Security check failure 4');
                            }
                            break;
                        default:
                            wppa_error_message('Unimplemented bulk action requested in wppa_album_photos_bulk().');
                            break;
                    }
                    if (!$skip) {
                        $count++;
                    }
                    if (wppa_is_time_up()) {
                        wppa_error_message(sprintf(__('Time is out after processing %d out of %d items.', 'wp-photo-album-plus'), $count, $totcount));
                        $abort = true;
                    }
                    if ($abort) {
                        break;
                    }
                }
            } else {
                wppa_error_message('Unexpected error #2 in wppa_album_photos_bulk().');
            }
        } else {
            wppa_error_message('Unexpected error #1 in wppa_album_photos_bulk().');
        }
        if ($count && !$abort) {
            switch ($_POST['wppa-bulk-action']) {
                case 'wppa-bulk-delete':
                    $message = sprintf(__('%d photos deleted.', 'wp-photo-album-plus'), $count);
                    break;
                case 'wppa-bulk-move-to':
                    $message = sprintf(__('%1$s photos moved to album %2$s.', 'wp-photo-album-plus'), $count, $newalb . ': ' . wppa_get_album_name($newalb));
                    break;
                case 'wppa-bulk-copy-to':
                    $message = sprintf(__('%1$s photos copied to album %2$s.', 'wp-photo-album-plus'), $count, $newalb . ': ' . wppa_get_album_name($newalb));
                    break;
                case 'wppa-bulk-status':
                    $message = sprintf(__('Changed status to %1$s on %2$s photos.', 'wp-photo-album-plus'), $status, $count);
                    break;
                case 'wppa-bulk-owner':
                    $message = sprintf(__('Changed owner to %1$s on %2$s photos.', 'wp-photo-album-plus'), $owner, $count);
                    break;
                default:
                    $message = sprintf(__('%d photos processed.', 'wp-photo-album-plus'), $count);
                    break;
            }
            wppa_ok_message($message);
        }
    }
    $pagesize = wppa_opt('photo_admin_pagesize');
    $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1';
    $skip = ($page - '1') * $pagesize;
    $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize;
    if ($album) {
        if ($album == 'search') {
            $count = wppa_get_edit_search_photos('', 'count_only');
            $photos = wppa_get_edit_search_photos($limit);
            $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring']) . '&bulk');
            wppa_show_search_statistics();
        } else {
            $counts = wppa_treecount_a($album);
            $count = $counts['selfphotos'] + $counts['pendphotos'];
            //$wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ) );
            $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A);
            $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&bulk');
        }
        if ($photos) {
            wppa_admin_page_links($page, $pagesize, $count, $link, '#manage-photos');
            ?>
			<script type="text/javascript" >
				function wppaBulkActionChange( elm, id ) {
					wppa_setCookie( 'wppa_bulk_action',elm.value,365 );
					if ( elm.value == 'wppa-bulk-move-to' || elm.value == 'wppa-bulk-copy-to' ) jQuery( '#wppa-bulk-album' ).css( 'display', 'inline' );
					else jQuery( '#wppa-bulk-album' ).css( 'display', 'none' );
					if ( elm.value == 'wppa-bulk-status' ) jQuery( '#wppa-bulk-status' ).css( 'display', 'inline' );
					else jQuery( '#wppa-bulk-status' ).css( 'display', 'none' );
					if ( elm.value == 'wppa-bulk-owner' ) jQuery( '#wppa-bulk-owner' ).css( 'display', 'inline' );
					else jQuery( '#wppa-bulk-owner' ).css( 'display', 'none' );
				}
				function wppaBulkDoitOnClick() {
					var photos = jQuery( '.wppa-bulk-photo' );
					var count=0;
					for ( i=0; i< photos.length; i++ ) {
						var photo = photos[i];
						if ( photo.checked ) count++;
					}
					if ( count == 0 ) {
						alert( 'No photos selected' );
						return false;
					}
					var action = document.getElementById( 'wppa-bulk-action' ).value;
					switch ( action ) {
						case '':
							alert( 'No action selected' );
							return false;
							break;
						case 'wppa-bulk-delete':
							break;
						case 'wppa-bulk-move-to':
						case 'wppa-bulk-copy-to':
							var album = document.getElementById( 'wppa-bulk-album' ).value;
							if ( album == 0 ) {
								alert( 'No album selected' );
								return false;
							}
							break;
						case 'wppa-bulk-status':
							var status = document.getElementById( 'wppa-bulk-status' ).value;
							if ( status == 0 ) {
								alert( 'No status selected' );
								return false;
							}
							break;
						case 'wppa-bulk-owner':
							var owner = documnet.getElementById( 'wppa-bulk-owner' ).value;
							if ( owner == 0 ) {
								alert( 'No new owner selected' );
								return false;
							}
							break;
						default:
							alert( 'Unimplemented action requested: '+action );
							return false;
							break;

					}
					return true;
				}
				function wppaSetThumbsize( elm ) {
					var thumbsize = elm.value;
					wppa_setCookie( 'wppa_bulk_thumbsize',thumbsize,365 );
					jQuery( '.wppa-bulk-thumb' ).css( 'max-width', thumbsize+'px' );
					jQuery( '.wppa-bulk-thumb' ).css( 'max-height', ( thumbsize/2 )+'px' );
					jQuery( '.wppa-bulk-dec' ).css( 'height', ( thumbsize/2 )+'px' );
				}
				jQuery( document ).ready( function() {
					var action = wppa_getCookie( 'wppa_bulk_action' );
					document.getElementById( 'wppa-bulk-action' ).value = action;
					if ( action == 'wppa-bulk-move-to' || action == 'wppa-bulk-copy-to' ) {
						jQuery( '#wppa-bulk-album' ).css( 'display','inline' );
						document.getElementById( 'wppa-bulk-album' ).value = wppa_getCookie( 'wppa_bulk_album' );
					}
					if ( action == 'wppa-bulk-status' ) {
						jQuery( '#wppa-bulk-status' ).css( 'display','inline' );
						document.getElementById( 'wppa-bulk-status' ).value = wppa_getCookie( 'wppa_bulk_status' );
					}
					if ( action == 'wppa-bulk-owner' ) {
						jQuery( '#wppa-bulk-owner' ).css( 'display','inline' );
						document.getElementById( 'wppa-bulk-owner' ).value = wppa_getCookie( 'wppa_bulk_owner' );
					}
				} );

			</script>
			<form action="<?php 
            echo $link . '&wppa-page=' . $page . '#manage-photos';
            ?>
" method="post" >
				<?php 
            wp_nonce_field('wppa-bulk', 'wppa-bulk');
            ?>
				<h3>
				<span style="font-weight:bold;" ><?php 
            _e('Bulk action:', 'wp-photo-album-plus');
            ?>
</span>
				<select id="wppa-bulk-action" name="wppa-bulk-action" onchange="wppaBulkActionChange( this, 'bulk-album' )" >
					<option value="" ></option>
					<option value="wppa-bulk-delete" ><?php 
            _e('Delete', 'wp-photo-album-plus');
            ?>
</option>
					<option value="wppa-bulk-move-to" ><?php 
            _e('Move to', 'wp-photo-album-plus');
            ?>
</option>
					<option value="wppa-bulk-copy-to" ><?php 
            _e('Copy to', 'wp-photo-album-plus');
            ?>
</option>
					<?php 
            if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) {
                ?>
						<option value="wppa-bulk-status" ><?php 
                _e('Set status to', 'wp-photo-album-plus');
                ?>
</option>
					<?php 
            }
            ?>
					<?php 
            if (wppa_user_is('administrator') && wppa_switch('photo_owner_change')) {
                ?>
						<option value="wppa-bulk-owner" ><?php 
                _e('Set owner to', 'wp-photo-album-plus');
                ?>
</option>
					<?php 
            }
            ?>
				</select>
				<select name="wppa-bulk-album" id="wppa-bulk-album" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_album',this.value,365 );" >
					<?php 
            echo wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $album, 'selected' => '0', 'addpleaseselect' => true));
            ?>
				</select>
				<select name="wppa-bulk-status" id="wppa-bulk-status" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_status',this.value,365 );" >
					<option value="" ><?php 
            _e('- select a status -', 'wp-photo-album-plus');
            ?>
</option>
					<option value="pending" ><?php 
            _e('Pending', 'wp-photo-album-plus');
            ?>
</option>
					<option value="publish" ><?php 
            _e('Publish', 'wp-photo-album-plus');
            ?>
</option>
					<?php 
            if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) {
                $dis = ' disabled';
            } else {
                $dis = '';
            }
            ?>
					<option value="featured"<?php 
            echo $dis;
            ?>
 ><?php 
            _e('Featured', 'wp-photo-album-plus');
            ?>
</option>
					<option value="gold" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Gold', 'wp-photo-album-plus');
            ?>
</option>
					<option value="silver" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Silver', 'wp-photo-album-plus');
            ?>
</option>
					<option value="bronze" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Bronze', 'wp-photo-album-plus');
            ?>
</option>
					<option value="scheduled" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Scheduled', 'wp-photo-album-plus');
            ?>
</option>
					<option value="private" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Private', 'wp-photo-album-plus');
            ?>
</option>
				</select>
				<!-- Owner -->
				<?php 
            $users = wppa_get_users();
            if (count($users)) {
                ?>
				<select name="wppa-bulk-owner" id="wppa-bulk-owner" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_owner',this.value,365 );">
					<option value="" ><?php 
                _e('- select an owner -', 'wp-photo-album-plus');
                ?>
</option>
					<?php 
                foreach ($users as $user) {
                    echo '<option value="' . $user['user_login'] . '" >' . $user['display_name'] . ' (' . $user['user_login'] . ')</option>';
                }
                ?>
				</select>
				<?php 
            } else {
                ?>
				<input name="wppa-bulk-owner" id="wppa-bulk-owner" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_owner',this.value,365 );" />
				<?php 
            }
            ?>
				<!-- Submit -->
				<input type="submit" onclick="return wppaBulkDoitOnClick()" class="button-primary" value="<?php 
            _e('Doit!', 'wp-photo-album-plus');
            ?>
" />
				<span style="font-family:sans-serif; font-size:12px; font-style:italic; font-weight:normal;" >
					<?php 
            _e('Pressing this button will reload the page after executing the selected action', 'wp-photo-album-plus');
            ?>
				</span>
				</h3>
				<table class="widefat" >
					<thead style="font-weight:bold;" >
						<td><input type="checkbox" class="wppa-bulk-photo" onchange="jQuery( '.wppa-bulk-photo' ).attr( 'checked', this.checked );" /></td>
						<td><?php 
            _e('ID', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Preview', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Name', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Description', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Status', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Owner', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Remark', 'wp-photo-album-plus');
            ?>
</td>
					</thead>
					<tbody>
						<?php 
            foreach ($photos as $photo) {
                ?>
						<?php 
                $id = $photo['id'];
                ?>
						<tr id="photoitem-<?php 
                echo $photo['id'];
                ?>
" >
							<!-- Checkbox -->
							<td>
								<input type="hidden" id="photo-nonce-<?php 
                echo $photo['id'];
                ?>
" value="<?php 
                echo wp_create_nonce('wppa_nonce_' . $photo['id']);
                ?>
" />
								<input type="checkbox" name="wppa-bulk-photo[<?php 
                echo $photo['id'];
                ?>
]" class="wppa-bulk-photo" />
							</td>
							<!-- ID and delete link -->
							<td><?php 
                echo $photo['id'];
                ?>
								<br /><a onclick="if ( confirm( '<?php 
                _e('Are you sure you want to delete this photo?', 'wp-photo-album-plus');
                ?>
' ) ) wppaAjaxDeletePhoto( <?php 
                echo $photo['id'];
                ?>
, '<td colspan=3 >', '</td>' )" style="color:red;font-weight:bold;"><?php 
                _e('Delete', 'wp-photo-album-plus');
                ?>
</a>
							</td>
							<!-- Preview -->
							<td style="min-width:240px; text-align:center;" >
							<?php 
                if (wppa_is_video($photo['id'])) {
                    ?>
								<a href="<?php 
                    echo str_replace('xxx', 'mp4', wppa_get_photo_url($photo['id']));
                    ?>
" target="_blank" title="Click to see fullsize" >
									<?php 
                    // Animating size changes of a video tag is not a good idea. It will rapidly screw up browser cache and cpu
                    ?>
									<?php 
                    echo wppa_get_video_html(array('id' => $id, 'height' => '60', 'controls' => false, 'tagid' => 'pa-id-' . $id, 'events' => ' onmouseover="jQuery( this ).css( \'height\', \'160\' )" onmouseout="jQuery( this ).css( \'height\', \'60\' )"', 'preload' => 'metadata', 'use_thumb' => true));
                    ?>
					<!--				<video preload="metadata" style="height:60px;" onmouseover="jQuery( this ).css( 'height', '160' )" onmouseout="jQuery( this ).css( 'height', '60' )" >
										<?php 
                    // echo wppa_get_video_body( $photo['id'] )
                    ?>
									</video>	-->
								</a>
							<?php 
                } else {
                    ?>
								<a href="<?php 
                    echo wppa_fix_poster_ext(wppa_get_photo_url($photo['id']), $photo['id']);
                    ?>
" target="_blank" title="Click to see fullsize" >
									<img class="wppa-bulk-thumb" src="<?php 
                    echo wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']);
                    ?>
" style="height:60px;" onmouseover="jQuery( this ).stop().animate( {height:120}, 100 )" onmouseout="jQuery( this ).stop().animate( {height:60}, 100 )" />
								</a>
							<?php 
                }
                ?>
							</td>
							<td style="width:25%;" >
								<input type="text" style="width:100%;" id="pname-<?php 
                echo $photo['id'];
                ?>
" onchange="wppaAjaxUpdatePhoto( <?php 
                echo $photo['id'];
                ?>
, 'name', this );" value="<?php 
                echo esc_attr(stripslashes($photo['name']));
                ?>
" />
								<?php 
                if (wppa_is_video($photo['id'])) {
                    echo '<br />' . wppa_get_videox($photo['id']) . ' x ' . wppa_get_videoy($photo['id']) . ' px.';
                } else {
                    $sp = wppa_get_source_path($photo['id']);
                    if (is_file($sp)) {
                        $ima = getimagesize($sp);
                        if (is_array($ima)) {
                            echo '<br />' . $ima['0'] . ' x ' . $ima['1'] . ' px.';
                        }
                    }
                }
                ?>
							</td>
							<!-- Description -->
							<td style="width:25%;" >
								<textarea class="wppa-bulk-dec" style="height:50px; width:100%" onchange="wppaAjaxUpdatePhoto( <?php 
                echo $photo['id'];
                ?>
, 'description', this )" ><?php 
                echo stripslashes($photo['description']);
                ?>
</textarea>
							</td>
							<!-- Status -->
							<td>
							<?php 
                if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) {
                    ?>
								<select id="status-<?php 
                    echo $photo['id'];
                    ?>
" onchange="wppaAjaxUpdatePhoto( <?php 
                    echo $photo['id'];
                    ?>
, 'status', this ); wppaPhotoStatusChange( <?php 
                    echo $photo['id'];
                    ?>
 ); ">
									<option value="pending" <?php 
                    if ($photo['status'] == 'pending') {
                        echo 'selected="selected"';
                    }
                    ?>
 ><?php 
                    _e('Pending', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="publish" <?php 
                    if ($photo['status'] == 'publish') {
                        echo 'selected="selected"';
                    }
                    ?>
 ><?php 
                    _e('Publish', 'wp-photo-album-plus');
                    ?>
</option>
									<?php 
                    if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) {
                        $dis = ' disabled';
                    } else {
                        $dis = '';
                    }
                    ?>
									<option value="featured" <?php 
                    if ($photo['status'] == 'featured') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Featured', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="gold" <?php 
                    if ($photo['status'] == 'gold') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Gold', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="silver" <?php 
                    if ($photo['status'] == 'silver') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Silver', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="bronze" <?php 
                    if ($photo['status'] == 'bronze') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Bronze', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="scheduled" <?php 
                    if ($photo['status'] == 'scheduled') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Scheduled', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="private" <?php 
                    if ($photo['status'] == 'private') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Private', 'wp-photo-album-plus');
                    ?>
</option>
								</select>
							<?php 
                } else {
                    if ($photo['status'] == 'pending') {
                        _e('Pending', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'publish') {
                        _e('Publish', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'featured') {
                        e('Featured');
                    } elseif ($photo['status'] == 'gold') {
                        _e('Gold', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'silver') {
                        _e('Silver', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'bronze') {
                        _e('Bronze', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'scheduled') {
                        _e('Scheduled', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'private') {
                        _e('Private', 'wp-photo-album-plus');
                    }
                }
                ?>
							</td>
							<!-- Owner -->
							<td>
								<?php 
                echo $photo['owner'];
                ?>
							</td>
							<!-- Remark -->
							<td id="photostatus-<?php 
                echo $photo['id'];
                ?>
" style="width:25%;" >
								<?php 
                _e('Not modified', 'wp-photo-album-plus');
                ?>
								<script type="text/javascript">wppaPhotoStatusChange( <?php 
                echo $photo['id'];
                ?>
 )</script>
							</td>
						</tr>
						<?php 
            }
            ?>
					</tbody>
					<tfoot style="font-weight:bold;" >
						<td><input type="checkbox" class="wppa-bulk-photo" onchange="jQuery( '.wppa-bulk-photo' ).attr( 'checked', this.checked );" /></td>
						<td><?php 
            _e('ID', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Preview', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Name', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Description', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Status', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Owner', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Remark', 'wp-photo-album-plus');
            ?>
</td>
					</tfoot>
				</table>
			</form>
			<?php 
            wppa_admin_page_links($page, $pagesize, $count, $link);
        } else {
            if ($page == '1') {
                if (isset($_REQUEST['wppa-searchstring'])) {
                    echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>';
                } else {
                    echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>';
                }
            } else {
                $page_1 = $page - '1';
                echo sprintf(__('Page %d is empty, try <a href="%s" >page %d</a>.', 'wp-photo-album-plus'), $page, $link . '&wppa-page=' . $page_1 . '#manage-photos', $page_1);
            }
        }
    } else {
        wppa_dbg_msg('Missing required argument in wppa_album_photos() 2', 'red', 'force');
    }
}
コード例 #11
0
function wppa_the_album_title($alb, $href_title, $onclick_title, $title, $target)
{
    global $wppa;
    $album = wppa_cache_album($alb);
    $wppa['out'] .= wppa_nltab('+') . '<h2 class="wppa-title" style="clear:none; ' . __wcs('wppa-title') . '">';
    if ($href_title) {
        if ($href_title == '#') {
            $wppa['out'] .= wppa_nltab() . '<a onclick="' . $onclick_title . '" title="' . $title . '" class="wppa-title" style="cursor:pointer; ' . __wcs('wppa-title') . '">' . wppa_get_album_name($alb) . '</a>';
        } else {
            $wppa['out'] .= wppa_nltab() . '<a href="' . $href_title . '" target="' . $target . '" onclick="' . $onclick_title . '" title="' . $title . '" class="wppa-title" style="' . __wcs('wppa-title') . '">' . wppa_get_album_name($alb) . '</a>';
        }
    } else {
        $wppa['out'] .= wppa_get_album_name($alb);
    }
    if (wppa_is_album_new($alb)) {
        $wppa['out'] .= wppa_nltab() . '<img src="' . WPPA_URL . '/images/new.png" title="' . __a('New!') . '" class="wppa-albumnew" style="border:none; margin:0; padding:0; box-shadow:none; " alt="' . __a('New') . '" />';
    }
    $wppa['out'] .= wppa_nltab('-') . '</h2>';
}
コード例 #12
0
function wppa_do_albumlist($parent, $nestinglevel, $albums, $seq)
{
    global $wpdb;
    $alt = true;
    foreach (array_keys($seq) as $s) {
        // Obey the global sequence
        $album = $albums[$s];
        if ($album['a_parent'] == $parent) {
            if (wppa_have_access($album)) {
                $counts = wppa_treecount_a($album['id']);
                $pendcount = $counts['pendphotos'];
                $schedulecount = $counts['scheduledphotos'];
                $haschildren = wppa_have_accessable_children($album);
                $class = '';
                if ($parent != '0' && $parent != '-1') {
                    $class .= 'wppa-alb-on-' . $parent . ' ';
                    $par = $parent;
                    while ($par != '0' && $par != '-1') {
                        $class .= 'wppa-alb-off-' . $par . ' ';
                        $par = wppa_get_parentalbumid($par);
                    }
                }
                if ($alt) {
                    $class .= ' alternate';
                }
                $style = '';
                if ($pendcount) {
                    $style .= 'background-color:#ffdddd; ';
                }
                //	if ( $haschildren ) $style .= 'font-weight:bold; ';
                if ($parent != '0' && $parent != '-1') {
                    $style .= 'display:none; ';
                }
                $onclickon = 'jQuery(\'.wppa-alb-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'\');';
                $onclickoff = 'jQuery(\'.wppa-alb-off-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'none\'); checkArrows();';
                $indent = $nestinglevel;
                if ($indent > '5') {
                    $indent = 5;
                }
                ?>

						<tr class="<?php 
                echo $class;
                ?>
" style="<?php 
                echo $style;
                ?>
" >
							<?php 
                $i = 0;
                while ($i < $indent) {
                    echo '<td style="padding:2px;" ></td>';
                    $i++;
                }
                ?>
							<td style="padding:2px; text-align:center;" ><?php 
                if ($haschildren) {
                    ?>
								<img id="alb-arrow-off-<?php 
                    echo $album['id'];
                    ?>
" class="alb-arrow-off" style="height:16px; display:none;" src="<?php 
                    echo wppa_get_imgdir() . 'backarrow.gif';
                    ?>
" onclick="<?php 
                    echo $onclickoff;
                    ?>
" title="<?php 
                    _e('Collapse subalbums', 'wp-photo-album-plus');
                    ?>
" />
								<img id="alb-arrow-on-<?php 
                    echo $album['id'];
                    ?>
" class="alb-arrow-on" style="height:16px;" src="<?php 
                    echo wppa_get_imgdir() . 'arrow.gif';
                    ?>
" onclick="<?php 
                    echo $onclickon;
                    ?>
" title="<?php 
                    _e('Expand subalbums', 'wp-photo-album-plus');
                    ?>
" />
							<?php 
                }
                ?>
</td>
							<td style="padding:2px;" ><?php 
                echo $album['id'];
                ?>
</td>
							<?php 
                $i = $indent;
                while ($i < 5) {
                    echo '<td style="padding:2px;" ></td>';
                    $i++;
                }
                ?>
							<td><?php 
                echo esc_attr(__(stripslashes($album['name'])));
                ?>
</td>
							<td><small><?php 
                echo esc_attr(__(stripslashes($album['description'])));
                ?>
</small></td>
							<?php 
                if (current_user_can('administrator')) {
                    ?>
								<td><?php 
                    echo $album['owner'];
                    ?>
</td>
							<?php 
                }
                ?>
							<td><?php 
                echo $album['a_order'];
                ?>
</td>
							<td><?php 
                echo wppa_get_album_name($album['a_parent'], 'extended');
                ?>
</td>
							<?php 
                $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id=' . $album['id']);
                ?>
							<?php 
                $na = $counts['selfalbums'];
                ?>
							<?php 
                $np = $counts['selfphotos'];
                ?>
							<?php 
                $nm = $counts['pendphotos'];
                ?>
							<?php 
                $ns = $counts['scheduledphotos'];
                ?>
							<td><?php 
                echo $na . '/' . $np . '/' . $nm . '/' . $ns;
                ?>
</td>
							<?php 
                if ($album['owner'] != '--- public ---' || wppa_user_is('administrator')) {
                    ?>
								<?php 
                    $url = wppa_ea_url($album['id']);
                    ?>
								<td><a href="<?php 
                    echo $url;
                    ?>
" class="wppaedit"><?php 
                    _e('Edit', 'wp-photo-album-plus');
                    ?>
</a></td>
								<td><a href="<?php 
                    echo $url . '&amp;quick';
                    ?>
" class="wppaedit"><?php 
                    _e('Quick', 'wp-photo-album-plus');
                    ?>
</a></td>
								<td><a href="<?php 
                    echo $url . '&amp;bulk#manage-photos';
                    ?>
" class="wppaedit"><?php 
                    _e('Bulk', 'wp-photo-album-plus');
                    ?>
</a></td>
								<td><a href="<?php 
                    echo $url . '&amp;seq';
                    ?>
" class="wppaedit"><?php 
                    _e('Seq', 'wp-photo-album-plus');
                    ?>
</a></td>

								<?php 
                    $url = wppa_ea_url($album['id'], 'del');
                    ?>
								<td><a href="<?php 
                    echo $url;
                    ?>
" class="wppadelete"><?php 
                    _e('Delete', 'wp-photo-album-plus');
                    ?>
</a></td>
								<?php 
                    if (wppa_can_create_album()) {
                        $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&amp;tab=edit&amp;edit_id=new&amp;parent_id=' . $album['id']);
                        if (wppa_switch('confirm_create')) {
                            $onc = 'if (confirm(\'' . __('Are you sure you want to create a subalbum?', 'wp-photo-album-plus') . '\')) document.location=\'' . $url . '\';';
                            echo '<td><a onclick="' . $onc . '" class="wppacreate">' . __('Create', 'wp-photo-album-plus') . '</a></td>';
                        } else {
                            echo '<td><a href="' . $url . '" class="wppacreate">' . __('Create', 'wp-photo-album-plus') . '</a></td>';
                        }
                    }
                } else {
                    ?>
							<td></td><td></td><?php 
                    if (wppa_can_create_album()) {
                        echo '<td></td';
                    }
                    ?>
							<?php 
                }
                ?>
						</tr>
						<?php 
                if ($alt == '') {
                    $alt = ' class="alternate" ';
                } else {
                    $alt = '';
                }
                if ($haschildren) {
                    wppa_do_albumlist($album['id'], $nestinglevel + '1', $albums, $seq);
                }
            }
        }
    }
}
コード例 #13
0
function wppa_album_sequence($parent)
{
    global $wpdb;
    // Get the albums
    $albumorder = wppa_get_album_order($parent);
    $is_descending = strpos($albumorder, 'DESC') !== false;
    $albums = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `a_parent` = %s ' . $albumorder, $parent), ARRAY_A);
    // Anything to do here ?
    if (empty($albums)) {
        return;
    }
    // Check my access rights
    foreach ($albums as $album) {
        if (!wppa_have_access($album['id'])) {
            return;
        }
    }
    // Check album order
    if (!strpos($albumorder, 'a_order')) {
        if ($parent == '0') {
            echo '<br />';
            _e('You can edit top-level album sequence order here when you set the album order to "Order #" or "Order # desc" in Table IV-D1.');
        } else {
            _e('You can edit sub-album sequence order here when you set the album order to "Order #" or "Order # desc" in the "Sub album sort order:" selection box above.');
        }
        return;
    }
    echo '<h2>' . __('Manage album order', 'wp-photo-album-plus') . ' - ' . '<small>' . '<i>' . __('Change sequence order by drag and drop, or use the up/down arrows.', 'wp-photo-album-plus') . '</i>' . ' ' . __('Do not leave this page unless the bar is entirely green.', 'wp-photo-album-plus') . '</small>' . '</h2>';
    echo '<table>' . '<thead>' . '<tr>' . '<th>' . __('Color', 'wp-photo-album-plus') . '</th>' . '<th>' . __('Meaning', 'wp-photo-album-plus') . '</th>' . '</tr>' . '</thead>' . '<tbody>' . '<tr>' . '<td>' . '<div style="background-color:green;height:12px;" ></div>' . '</td>' . '<td>' . __('Up to date', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td>' . '<div style="background-color:yellow;height:12px;" ></div>' . '</td>' . '<td>' . __('Updating', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td>' . '<div style="background-color:orange;height:12px;" ></div>' . '</td>' . '<td>' . __('Needs update', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td>' . '<div style="background-color:red;height:12px;" ></div>' . '</td>' . '<td>' . __('Error', 'wp-photo-album-plus') . '</td>' . '</tr>' . '</tbody>' . '</table>';
    ?>
		<style>
			.sortable-placeholder-albums {
				width: 100%;
				height: 60px;
				margin: 5px;
				border: 1px dotted #cccccc;
				border-radius:3px;
				float: left;
			}
			.ui-state-default-albums {
				position: relative;
				width: 100%;
				height: 60px;
				margin: 5px;
				border: 1px solid #cccccc;
				border-radius:3px;
				float: left;
			}
			.ui-state-default-albums td {
				padding:0;
				line-height:12px;
				text-align:center;
			}
		</style>
		<script>
			jQuery( function() {
				jQuery( "#sortable-albums" ).sortable( {
					cursor: 		"move",
					placeholder: 	"sortable-placeholder-albums",
					stop: 			function( event, ui ) { wppaDoRenumber(); }
				} );
			} );
			var wppaRenumberPending = false;
			var wppaAjaxInProgress 	= 0;

			function wppaDoRenumber() {

				// Busy?
				if ( wppaAjaxInProgress > 0 ) {
					wppaRenumberPending = true;
				}

				// Not busy
				else {
					_wppaDoRenumber();
				}
			}

			function _wppaDoRenumber() {

				// Init
				var ids = jQuery( ".wppa-sort-item-albums" );
				var seq = jQuery( ".wppa-sort-seqn-albums" );
				var descend = <?php 
    if ($is_descending) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
;

				// Mark needs update
				var idx = 0;
				while ( idx < ids.length ) {
					var newvalue;
					if ( descend ) newvalue = ids.length - idx;
					else newvalue = idx + 1;
					var oldvalue = seq[idx].value;
					var album = ids[idx].value;
					if ( newvalue != oldvalue ) {
						jQuery( '#wppa-pb-'+idx ).css({backgroundColor:'orange'});
					}
					idx++;
				}

				// Process
				var idx = 0;
				while ( idx < ids.length ) {
					var newvalue;
					if ( descend ) newvalue = ids.length - idx;
					else newvalue = idx + 1;
					var oldvalue = seq[idx].value;
					var album = ids[idx].value;
					if ( newvalue != oldvalue ) {
						wppaDoSeqUpdateAlbum( album, newvalue );
						jQuery( '#wppa-pb-'+idx ).css({backgroundColor:'yellow'});
						wppaLastAlbum = album;
					}
					idx++;
				}
			}

			function wppaDoSeqUpdateAlbum( album, seqno ) {

				var data = 	'action=wppa' +
							'&wppa-action=update-album' +
							'&album-id=' + album +
							'&item=a_order' +
							'&wppa-nonce=' + document.getElementById( 'album-nonce-' + album ).value +
							'&value=' + seqno;
				var xmlhttp = new XMLHttpRequest();

				xmlhttp.onreadystatechange = function() {
					if ( xmlhttp.readyState == 4 && xmlhttp.status != 404 ) {
						var ArrValues = xmlhttp.responseText.split( "||" );
						if ( ArrValues[0] != '' ) {
							alert( 'The server returned unexpected output:\n' + ArrValues[0] );
						}
						switch ( ArrValues[1] ) {
							case '0':	// No error
								var i = seqno - 1;
								var descend = <?php 
    if ($is_descending) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
;
								if ( descend ) {
									i = <?php 
    echo count($albums);
    ?>
 - seqno;
								}
								jQuery( '#wppa-album-seqno-' + album ).html( seqno );
								if ( wppaRenumberPending ) {
									jQuery( '#wppa-pb-'+i ).css({backgroundColor:'orange'});
								}
								else {
									jQuery( '#wppa-pb-'+i ).css({backgroundColor:'green'});
								}
								if ( wppaLastAlbum = album ) {
									wppaRenumberBusy = false;
								}
								break;
							default:	// Any error
								jQuery( '#wppa-album-seqno-' + album ).html( '<span style="color"red" >Err:' + ArrValues[1] + '</span>' );
								break;
						}
						wppaAjaxInProgress--;

						// No longer busy?
						if ( wppaAjaxInProgress == 0 ) {

							if ( wppaRenumberPending ) {

								// Redo
								wppaRenumberPending = false;
								wppaDoRenumber();
							}
						}
					}
				}
				xmlhttp.open( 'POST',wppaAjaxUrl,true );
				xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
				xmlhttp.send( data );
				wppaAjaxInProgress++;

				jQuery( "#wppa-sort-seqn-albums-" + album ).attr( 'value', seqno );	// set hidden value to new value to prevent duplicate action
				var spinnerhtml = '<img src="' + wppaImageDirectory + 'spinner.gif' + '" />';
				jQuery( '#wppa-album-seqno-' + album ).html( spinnerhtml );
			}
		</script>

		<br />

		<div id="wppa-progbar" style="width:100%;height:12px;" >
			<?php 
    $c = count($albums);
    $l = 100 / $c;
    $i = 0;
    while ($i < $c) {
        echo '<div' . ' id="wppa-pb-' . $i . '"' . ' style="display:inline;float:left;background-color:green;height:12px;width:' . $l . '%;"' . ' >' . '</div>';
        $i++;
    }
    ?>
		</div>

		<br />

		<div class="widefat" style="max-width:600px;" >
			<div id="sortable-albums">
				<?php 
    foreach ($albums as $album) {
        $cover_photo_id = wppa_get_coverphoto_id($album['id']);
        echo '
					<div' . ' id="albumitem-' . $album['id'] . '"' . ' class="ui-state-default-albums"' . ' style="background-color:#eeeeee;cursor:move;"' . ' >' . '<div' . ' style="height:100%;width:25%;float:left;text-align:center;overflow:hidden;" >';
        if (wppa_is_video($cover_photo_id)) {
            echo wppa_get_video_html(array('id' => $cover_photo_id, 'height' => '50', 'margin_top' => '5', 'margin_bottom' => '5', 'controls' => false));
        } else {
            echo '<img' . ' class="wppa-cover-image"' . ' src="' . wppa_fix_poster_ext(wppa_get_thumb_url(wppa_get_coverphoto_id($album['id'])), $cover_photo_id) . '"' . ' style="max-height:50px; margin: 5px;"' . ' />';
        }
        echo '</div>' . '<div style="height:100%;width:40%;float:left;font-size:12px;overflow:hidden;" >' . '<b>' . wppa_get_album_name($album['id']) . '</b>' . '<br />' . wppa_get_album_desc($album['id']) . '</div>' . '<div style="float:right;width:10%;" >' . '<table>' . '<tr><td>' . '<img' . ' src="' . wppa_get_imgdir('up.png') . '"' . ' title="' . esc_attr(__('To top', 'wp-photo-album-plus')) . '"' . ' style="cursor:pointer;"' . ' onclick="' . 'jQuery( \'#albumitem-' . $album['id'] . '\' ).parent().prepend(jQuery( \'#albumitem-' . $album['id'] . '\' ));' . 'wppaDoRenumber();' . '"' . ' />' . '</td></tr>' . '<tr><td>' . '<img' . ' src="' . wppa_get_imgdir('up.png') . '"' . ' title="' . esc_attr(__('One up', 'wp-photo-album-plus')) . '"' . ' style="cursor:pointer;width:24px;"' . ' onclick="' . 'jQuery( \'#albumitem-' . $album['id'] . '\' ).prev().before(jQuery( \'#albumitem-' . $album['id'] . '\' ));' . 'wppaDoRenumber();' . '"' . ' />' . '</td></tr>' . '<tr><td>' . '<img' . ' src="' . wppa_get_imgdir('down.png') . '"' . ' title="' . esc_attr(__('One down', 'wp-photo-album-plus')) . '"' . ' style="cursor:pointer;width:24px;"' . ' onclick="' . 'jQuery( \'#albumitem-' . $album['id'] . '\' ).next().after(jQuery( \'#albumitem-' . $album['id'] . '\' ));' . 'wppaDoRenumber();' . '"' . ' />' . '</td></tr>' . '<tr><td>' . '<img' . ' src="' . wppa_get_imgdir('down.png') . '"' . ' title="' . esc_attr(__('To bottom', 'wp-photo-album-plus')) . '"' . ' style="cursor:pointer;"' . ' onclick="' . 'jQuery( \'#albumitem-' . $album['id'] . '\' ).parent().append(jQuery( \'#albumitem-' . $album['id'] . '\' ));' . 'wppaDoRenumber();' . '"' . ' />' . '</td></tr>' . '</table>' . '</div>' . '<div style="float:right; width:25%;" >' . '<span style=""> ' . __('Id:', 'wp-photo-album-plus') . ' ' . $album['id'] . '</span>' . '<span style=""> - ' . __('Ord:', 'wp-photo-album-plus') . '</span>' . '<span id="wppa-album-seqno-' . $album['id'] . '" > ' . $album['a_order'] . '</span>' . '<br />' . '<a href="' . wppa_ea_url($album['id']) . '" style="position:absolute;bottom:0;" >' . __('Edit', 'wp-photo-album-plus') . '</a>' . '</div>' . '<input type="hidden" id="album-nonce-' . $album['id'] . '" value="' . wp_create_nonce('wppa_nonce_' . $album['id']) . '" />' . '<input type="hidden" class="wppa-sort-item-albums" value="' . $album['id'] . '" />' . '<input type="hidden" class="wppa-sort-seqn-albums" id="wppa-sort-seqn-albums-' . $album['id'] . '" value="' . $album['a_order'] . '" />' . '</div>';
    }
    ?>
			</div>
			<div style="clear:both;"></div>
		</div>
		<?php 
}
コード例 #14
0
function wppa_album_sequence($parent)
{
    global $wpdb;
    // Get the albums
    $albumorder = wppa_get_album_order($parent);
    $is_descending = strpos($albumorder, 'DESC') !== false;
    $albums = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `a_parent` = %s ' . $albumorder, $parent), ARRAY_A);
    // Anything to do here ?
    if (empty($albums)) {
        return;
    }
    // Check my access rights
    foreach ($albums as $album) {
        if (!wppa_have_access($album['id'])) {
            return;
        }
    }
    // Check album order
    if (!strpos($albumorder, 'a_order')) {
        if ($parent == '0') {
            echo '<br />';
            _e('You can edit top-level album sequence order here when you set the album order to "Order #" or "Order # desc" in Table IV-D1.');
        } else {
            _e('You can edit sub-album sequence order here when you set the album order to "Order #" or "Order # desc" in the "Sub album sort order:" selection box above.');
        }
        return;
    }
    echo '<h2>' . __('Manage album order', 'wp-photo-album-plus') . ' - ' . '<small><i>' . __('Change sequence order by drag and drop', 'wp-photo-album-plus') . '</i></small>' . '</h2>';
    ?>
		<style>
			.sortable-placeholder-albums {
				width: 100%;
				height: 60px;
				margin: 5px;
				border: 1px dotted #cccccc;
				border-radius:3px;
				float: left;
			}
			.ui-state-default-albums {
				position: relative;
				width: 100%;
				height: 60px;
				margin: 5px;
				border: 1px solid #cccccc;
				border-radius:3px;
				float: left;
			}
		</style>
		<script>
			jQuery( function() {
				jQuery( "#sortable-albums" ).sortable( {
					cursor: "move",
					placeholder: "sortable-placeholder-albums",
					stop: function( event, ui ) {
						var ids = jQuery( ".wppa-sort-item-albums" );
						var seq = jQuery( ".wppa-sort-seqn-albums" );
						var idx = 0;
						var descend = <?php 
    if ($is_descending) {
        echo 'true';
    } else {
        echo 'false';
    }
    ?>
;
						while ( idx < ids.length ) {
							var newvalue;
							if ( descend ) newvalue = ids.length - idx;
							else newvalue = idx + 1;
							var oldvalue = seq[idx].value;
							var album = ids[idx].value;
							if ( newvalue != oldvalue ) {
								wppaDoSeqUpdateAlbum( album, newvalue );
							}
							idx++;
						}
					}
				} );
			} );
			function wppaDoSeqUpdateAlbum( album, seqno ) {
				var data = 	'action=wppa' +
							'&wppa-action=update-album' +
							'&album-id=' + album +
							'&item=a_order' +
							'&wppa-nonce=' + document.getElementById( 'album-nonce-' + album ).value +
							'&value=' + seqno;
				var xmlhttp = new XMLHttpRequest();

				xmlhttp.onreadystatechange = function() {
					if ( xmlhttp.readyState == 4 && xmlhttp.status != 404 ) {
						var ArrValues = xmlhttp.responseText.split( "||" );
						if ( ArrValues[0] != '' ) {
							alert( 'The server returned unexpected output:\n' + ArrValues[0] );
						}
						switch ( ArrValues[1] ) {
							case '0':	// No error
								jQuery( '#wppa-album-seqno-' + album ).html( seqno );
								break;
							default:	// Any error
								jQuery( '#wppa-album-seqno-' + album ).html( '<span style="color"red" >Err:' + ArrValues[1] + '</span>' );
								break;
						}
					}
				}
				xmlhttp.open( 'POST',wppaAjaxUrl,true );
				xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" );
				xmlhttp.send( data );
				jQuery( "#wppa-sort-seqn-albums-" + album ).attr( 'value', seqno );	// set hidden value to new value to prevent duplicate action
				var spinnerhtml = '<img src="' + wppaImageDirectory + 'wpspin.gif' + '" />';
				jQuery( '#wppa-album-seqno-' + album ).html( spinnerhtml );
			}
		</script>

		<div class="widefat" style="max-width:500px;" >
			<div id="sortable-albums">
				<?php 
    foreach ($albums as $album) {
        echo '
					<div' . ' id="albumitem-' . $album['id'] . '"' . ' class="ui-state-default-albums"' . ' style="background-color:#eeeeee;cursor:move;"' . ' >' . '<div' . ' style="height:100%;width:25%;float:left;text-align:center;overflow:hidden;" >' . '<img' . ' class="wppa-cover-image"' . ' src="' . wppa_fix_poster_ext(wppa_get_thumb_url(wppa_get_coverphoto_id($album['id'])), wppa_get_coverphoto_id($album['id'])) . '"' . ' style="max-height:50px; margin: 5px;"' . ' />' . '</div>' . '<div style="height:100%;width:50%;float:left;font-size:12px;overflow:hidden;" >' . '<b>' . wppa_get_album_name($album['id']) . '</b>' . '<br />' . wppa_get_album_desc($album['id']) . '</div>' . '<div style="float:right; width:25%;" >' . '<span style=""> ' . __('Id:', 'wp-photo-album-plus') . ' ' . $album['id'] . '</span>' . '<span style=""> - ' . __('Ord:', 'wp-photo-album-plus') . '</span>' . '<span id="wppa-album-seqno-' . $album['id'] . '" > ' . $album['a_order'] . '</span>' . '<br />' . '<a href="' . wppa_ea_url($album['id']) . '" style="position:absolute;bottom:0;" >' . __('Edit', 'wp-photo-album-plus') . '</a>' . '</div>' . '<input type="hidden" id="album-nonce-' . $album['id'] . '" value="' . wp_create_nonce('wppa_nonce_' . $album['id']) . '" />' . '<input type="hidden" class="wppa-sort-item-albums" value="' . $album['id'] . '" />' . '<input type="hidden" class="wppa-sort-seqn-albums" id="wppa-sort-seqn-albums-' . $album['id'] . '" value="' . $album['a_order'] . '" />' . '</div>';
    }
    ?>
			</div>
			<div style="clear:both;"></div>
		</div>
		<?php 
}
コード例 #15
0
function wppa_translate_photo_keywords($id, $text)
{
    $result = $text;
    // Is there any 'w#' ?
    if (strpos($result, 'w#') !== false) {
        $thumb = wppa_cache_thumb($id);
        // Keywords
        $result = str_replace('w#albumname', wppa_get_album_name($thumb['album']), $result);
        $result = str_replace('w#albumid', $thumb['album'], $result);
        $keywords = array('name', 'filename', 'owner', 'id', 'tags', 'views', 'album');
        foreach ($keywords as $keyword) {
            $replacement = __(trim(stripslashes($thumb[$keyword])), 'wp-photo-album-plus');
            if ($keyword == 'tags') {
                $replacement = trim($replacement, ',');
            }
            if ($replacement == '') {
                $replacement = '&lsaquo;' . __('none', 'wp-photo-album-plus') . '&rsaquo;';
            }
            $result = str_replace('w#' . $keyword, $replacement, $result);
        }
        $result = str_replace('w#url', wppa_get_lores_url($id), $result);
        $result = str_replace('w#hrurl', esc_attr(wppa_get_hires_url($id)), $result);
        $result = str_replace('w#tnurl', wppa_get_tnres_url($id), $result);
        $result = str_replace('w#pl', wppa_get_source_pl($id), $result);
        $result = str_replace('w#rating', wppa_get_rating_by_id($id, 'nolabel'), $result);
        $user = get_user_by('login', $thumb['owner']);
        if ($user) {
            $result = str_replace('w#displayname', $user->display_name, $result);
        } else {
            $owner = wppa_get_photo_item($id, 'owner');
            if (strpos($owner, '.') == false && strpos($owner, ':') == false) {
                // Not an ip, a deleted user
                $result = str_replace('w#displayname', __('Nomen Nescio', 'wp-photo-album-plus'), $result);
            } else {
                // An ip
                $result = str_replace('w#displayname', __('Anonymus', 'wp-photo-album-plus'), $result);
            }
        }
        // Art monkey sizes
        if (strpos($result, 'w#amx') !== false || strpos($result, 'w#amy') !== false || strpos($result, 'w#amfs') !== false) {
            $amxy = wppa_get_artmonkey_size_a($id);
            if (is_array($amxy)) {
                $result = str_replace('w#amx', $amxy['x'], $result);
                $result = str_replace('w#amy', $amxy['y'], $result);
                $result = str_replace('w#amfs', $amxy['s'], $result);
            } else {
                $result = str_replace('w#amx', 'N.a.', $result);
                $result = str_replace('w#amy', 'N.a.', $result);
                $result = str_replace('w#amfs', 'N.a.', $result);
            }
        }
        // Timestamps
        $timestamps = array('timestamp', 'modified');
        foreach ($timestamps as $timestamp) {
            if ($thumb[$timestamp]) {
                $result = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $thumb[$timestamp]), $result);
            } else {
                $result = str_replace('w#' . $timestamp, '&lsaquo;' . __('unknown', 'wp-photo-album-plus') . '&rsaquo;', $result);
            }
        }
        // Custom data fields
        if (wppa_switch('custom_fields')) {
            $custom = $thumb['custom'];
            $custom_data = $custom ? unserialize($custom) : array('', '', '', '', '', '', '', '', '', '');
            for ($i = '0'; $i < '10'; $i++) {
                if (wppa_opt('custom_caption_' . $i)) {
                    // Field defined
                    if (wppa_switch('custom_visible_' . $i)) {
                        // May be displayed
                        $result = str_replace('w#cc' . $i, __(wppa_opt('custom_caption_' . $i), 'wp-photo-album-plus') . ':', $result);
                        // Caption
                        $result = str_replace('w#cd' . $i, __(stripslashes($custom_data[$i]), 'wp-photo-album-plus'), $result);
                        // Data
                    } else {
                        // May not be displayed
                        $result = str_replace('w#cc' . $i, '', $result);
                        // Remove
                        $result = str_replace('w#cd' . $i, '', $result);
                        // Remove
                    }
                } else {
                    // Field not defined
                    $result = str_replace('w#cc' . $i, '', $result);
                    // Remove
                    $result = str_replace('w#cd' . $i, '', $result);
                    // Remove
                }
            }
        }
    }
    return $result;
}
コード例 #16
0
function wppa_subalbumlinks_html($id, $top = true)
{
    global $wpdb;
    // Do they need us? Anything to display?
    if (wppa_opt('cover_sublinks_display') == 'none') {
        return;
    }
    // Display type
    $display_type = wppa_opt('cover_sublinks_display');
    // Link type
    $link_type = wppa_opt('cover_sublinks');
    // Init
    $is_list = $display_type == 'list' || $display_type == 'recursivelist';
    $is_recursive = $display_type == 'recursivelist';
    $first = true;
    // Get the children
    $subs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = " . $id . " " . wppa_get_album_order($id), ARRAY_A);
    // Only if there are sub-albums
    if (!empty($subs)) {
        wppa_out('<div>');
        // Local css
        if ($top) {
            if ($is_list) {
                wppa_out('<style scoped="scoped" >' . 'ul, li { margin:0; }' . 'ul {' . 'list-style-type:disc;' . 'list-style-position:inside;' . 'padding:0 0 0 24px;' . '}' . 'li { cursor:pointer; }' . '</style>');
            }
            if ($display_type == 'microthumbs') {
                wppa_out('<style scoped="scoped" >' . 'img {' . 'max-width:100px;' . 'max-height:50px;' . 'padding:1px;' . 'margin:1px;' . 'background-color:' . wppa_opt('bgcolor_img') . ';' . 'float:left;' . '}' . '</style>');
            }
        }
        // Start list if required
        if ($is_list) {
            wppa_out('<ul class="wppa-cover-sublink-list" style="clear:both;" >');
        } else {
            wppa_out('<div style="clear:both;" ></div>');
        }
        // Process the sub-albums
        foreach ($subs as $album) {
            // What is the albums title linktype
            $linktype = $album['cover_linktype'];
            if (!$linktype) {
                $linktype = 'content';
            }
            // Default
            // What is the albums title linkpage
            $linkpage = $album['cover_linkpage'];
            if ($linkpage == '-1') {
                $linktype = 'none';
            }
            // for backward compatibility
            // Find the content 'View' link
            $albumid = $album['id'];
            $photocount = wppa_get_photo_count($albumid, 'use_treecounts');
            // Thumbnails and covers, show sub-album covers
            // in case slideshow is requested on an empty album
            if (wppa_opt('cover_sublinks') == 'content' || !$photocount) {
                if (wppa_switch('allow_ajax') && !$linkpage) {
                    $href_content = '';
                    $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )";
                } else {
                    $href_content = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage));
                    $onclick_content = '';
                }
            } else {
                if (wppa_switch('allow_ajax') && !$linkpage) {
                    $href_content = '';
                    $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )";
                } else {
                    $href_content = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage));
                    $onclick_content = '';
                }
            }
            // Do the output
            $title = esc_attr(__('View the album', 'wp-photo-album-plus') . ': ' . wppa_get_album_name($album['id']));
            switch ($display_type) {
                case 'list':
                case 'recursivelist':
                    if ($link_type == 'none') {
                        wppa_out('<li>' . wppa_get_album_name($album['id']) . '</li>');
                    } else {
                        wppa_out('<li>' . '<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . wppa_get_album_name($album['id']) . '</a>' . '</li>');
                    }
                    break;
                case 'enum':
                    if (!$first) {
                        wppa_out(', ');
                    }
                    if ($link_type == 'none') {
                        wppa_out(wppa_get_album_name($album['id']));
                    } else {
                        wppa_out('<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . wppa_get_album_name($album['id']) . '</a>');
                    }
                    $first = false;
                    break;
                case 'microthumbs':
                    $coverphoto_id = wppa_get_coverphoto_id($album['id']);
                    $src = wppa_fix_poster_ext(wppa_get_thumb_url($coverphoto_id), $coverphoto_id);
                    if ($link_type == 'none') {
                        wppa_out('<img' . ' class="wppa-cover-sublink-img"' . ' src="' . $src . '"' . ' alt="' . wppa_get_album_name($album['id']) . '"' . ' />');
                    } else {
                        wppa_out('<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . '<img' . ' class="wppa-cover-sublink-img"' . ' src="' . $src . '"' . ' alt="' . wppa_get_album_name($album['id']) . '"' . ' />' . '</a>');
                    }
                    break;
            }
            // Go deeper for grandchildren
            if ($is_recursive) {
                wppa_subalbumlinks_html($album['id'], false);
            }
        }
        // End list
        if ($is_list) {
            wppa_out('</ul>');
        }
        wppa_out('</div>');
    }
}
コード例 #17
0
ファイル: wppa-breadcrumb.php プロジェクト: lchen01/STEdwards
function wppa_crumb_ancestors($alb, $to_cover)
{
    global $wpdb;
    // Find parent
    $parent = wppa_get_parentalbumid($alb);
    if ($parent < '1') {
        return;
    }
    // No parent -> toplevel -> done.
    wppa_crumb_ancestors($parent, $to_cover);
    // Find the album specific link type ( content, slide, page or none )
    $slide = wppa_get_album_title_linktype($parent) == 'slide' ? '&amp;wppa-slide' : '';
    // NOT SLIDE when there are no photos
    if (!wppa_get_photo_count($parent, 'use_treecounts')) {
        $slide = '';
    }
    $pagid = $wpdb->get_var($wpdb->prepare("SELECT `cover_linkpage` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent));
    wppa_dbg_q('Q-bc3');
    $value = wppa_get_album_name($parent);
    $href = wppa_get_permalink($pagid) . 'wppa-album=' . $parent . '&amp;wppa-cover=' . $to_cover . $slide . '&amp;wppa-occur=' . wppa('occur');
    $title = __('Album:', 'wp-photo-album-plus') . ' ' . wppa_get_album_name($parent);
    $class = 'b20';
    wppa_bcitem($value, $href, $title, $class);
    return;
}
コード例 #18
0
function wppa_ajax_callback()
{
    global $wpdb;
    global $wppa_session;
    wppa('ajax', true);
    wppa('error', '0');
    wppa('out', '');
    $wppa_session['page']--;
    $wppa_session['ajax']++;
    wppa_save_session();
    // ALTHOUGH IF WE ARE HERE AS FRONT END VISITOR, is_admin() is true.
    // So, $wppa_opt switches are 'yes' or 'no' and not true or false.
    // So, always use the function wppa_switch( $slug ) to test on a bool setting
    // Globally check query args to prevent php injection
    $wppa_args = array('album', 'photo', 'slide', 'cover', 'occur', 'woccur', 'searchstring', 'topten', 'lasten', 'comten', 'featen', 'single', 'photos-only', 'debug', 'relcount', 'upldr', 'owner', 'rootsearch');
    foreach ($_REQUEST as $arg) {
        if (in_array(str_replace('wppa-', '', $arg), $wppa_args)) {
            if (strpos($arg, '<?') !== false) {
                die('Security check failure #91');
            }
            if (strpos($arg, '?>') !== false) {
                die('Security check failure #92');
            }
        }
    }
    wppa_vfy_arg('wppa-action', true);
    wppa_vfy_arg('photo-id');
    wppa_vfy_arg('comment-id');
    wppa_vfy_arg('moccur');
    wppa_vfy_arg('comemail', true);
    wppa_vfy_arg('comname', true);
    wppa_vfy_arg('tag', true);
    $wppa_action = $_REQUEST['wppa-action'];
    switch ($wppa_action) {
        case 'getssiptclist':
            $tag = str_replace('H', '#', $_REQUEST['tag']);
            $mocc = $_REQUEST['moccur'];
            $oldvalue = '';
            if (strpos($wppa_session['supersearch'], ',') !== false) {
                $ss_data = explode(',', $wppa_session['supersearch']);
                if (count($ss_data) == '4') {
                    if ($ss_data['0'] == 'p') {
                        if ($ss_data['1'] == 'i') {
                            if ($ss_data['2'] == $_REQUEST['tag']) {
                                $oldvalue = $ss_data['3'];
                            }
                        }
                    }
                }
            }
            $iptcdata = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_IPTC . "` WHERE `photo` > '0' AND `tag` = %s ORDER BY `description`", $tag), ARRAY_A);
            $last = '';
            $any = false;
            if (is_array($iptcdata)) {
                foreach ($iptcdata as $item) {
                    $desc = sanitize_text_field($item['description']);
                    $desc = str_replace(array(chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7)), '', $desc);
                    if ($desc != $last) {
                        $sel = $oldvalue && $oldvalue == $desc ? 'selected="selected"' : '';
                        if ($sel) {
                            echo 'selected:' . $oldvalue;
                        }
                        $ddesc = strlen($desc) > '32' ? substr($desc, 0, 30) . '...' : $desc;
                        echo '<option' . ' value="' . esc_attr($desc) . '"' . ' class="wppa-iptclist-' . $mocc . '"' . ' ' . $sel . ' >' . $ddesc . '</option>';
                        $last = $desc;
                        $any = true;
                    }
                }
            }
            if (!$any) {
                $query = $wpdb->prepare("DELETE FROM `" . WPPA_IPTC . "` WHERE `photo` = '0' AND `tag` = %s", $tag);
                $wpdb->query($query);
                //				wppa_log( 'dbg', $query );
            }
            wppa_exit();
            break;
        case 'getssexiflist':
            $tag = str_replace('H', '#', $_REQUEST['tag']);
            $mocc = $_REQUEST['moccur'];
            $oldvalue = '';
            if (strpos($wppa_session['supersearch'], ',') !== false) {
                $ss_data = explode(',', $wppa_session['supersearch']);
                if (count($ss_data) == '4') {
                    if ($ss_data['0'] == 'p') {
                        if ($ss_data['1'] == 'e') {
                            if ($ss_data['2'] == $_REQUEST['tag']) {
                                $oldvalue = $ss_data['3'];
                            }
                        }
                    }
                }
            }
            $exifdata = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_EXIF . "` WHERE `photo` > '0' AND `tag` = %s ORDER BY `description`", $tag), ARRAY_A);
            $last = '';
            $any = false;
            if (is_array($exifdata)) {
                foreach ($exifdata as $item) {
                    $desc = sanitize_text_field($item['description']);
                    $desc = str_replace(array(chr(0), chr(1), chr(2), chr(3), chr(4), chr(5), chr(6), chr(7)), '', $desc);
                    if ($desc != $last) {
                        $sel = $oldvalue && $oldvalue == $desc ? 'selected="selected"' : '';
                        $ddesc = strlen($desc) > '32' ? substr($desc, 0, 30) . '...' : $desc;
                        echo '<option' . ' value="' . esc_attr($desc) . '"' . ' class="wppa-exiflist-' . $mocc . '"' . ' ' . $sel . ' >' . $ddesc . '</option>';
                        $last = $desc;
                        $any = true;
                    }
                }
            }
            if (!$any) {
                $query = $wpdb->prepare("DELETE FROM `" . WPPA_EXIF . "` WHERE `photo` = '0' AND `tag` = %s", $tag);
                $wpdb->query($query);
                //				wppa_log( 'dbg', $query );
            }
            wppa_exit();
            break;
        case 'front-edit':
            if (!isset($_REQUEST['photo-id'])) {
                die('Missing required argument');
            }
            $photo = $_REQUEST['photo-id'];
            $ok = false;
            if (current_user_can('wppa_admin')) {
                $ok = true;
            }
            if (wppa_get_user() == wppa_get_photo_owner($photo) && (current_user_can('wppa_upload') || is_user_logged_in() && wppa_switch('upload_edit'))) {
                $ok = true;
            }
            if (!$ok) {
                die('You do not have sufficient rights to do this');
            }
            require_once 'wppa-photo-admin-autosave.php';
            wppa('front_edit', true);
            echo '	<div style="padding-bottom:4px;height:24px;" >
						<span style="color:#777;" >
							<i>' . __('All modifications are instantly updated on the server. The <b style="color:#070" >Remark</b> field keeps you informed on the actions taken at the background.', 'wp-photo-album-plus') . '</i>
						</span>
						<input id="wppa-fe-exit" type="button" style="float:right;color:red;font-weight:bold;" onclick="window.opener.location.reload( true );window.close();" value="' . __('Exit & Refresh', 'wp-photo-album-plus') . '" />
						<div id="wppa-fe-count" style="float:right;" ></div>
					</div><div style="clear:both;"></div>';
            wppa_album_photos('', $photo);
            wppa_exit();
            break;
        case 'do-comment':
            // Security check
            $mocc = $_REQUEST['moccur'];
            $nonce = $_REQUEST['wppa-nonce'];
            if (!wp_verify_nonce($nonce, 'wppa-nonce-' . $mocc)) {
                _e('Security check failure', 'wp-photo-album-plus');
                wppa_exit();
            }
            // Correct the fact that this is a non-admin operation, if it is only
            if (is_admin()) {
                require_once 'wppa-non-admin.php';
            }
            wppa('mocc', $_REQUEST['moccur']);
            wppa('comment_photo', isset($_REQUEST['photo-id']) ? $_REQUEST['photo-id'] : '0');
            wppa('comment_id', isset($_REQUEST['comment-edit']) ? $_REQUEST['comment-edit'] : '0');
            $comment_allowed = !wppa_switch('comment_login') || is_user_logged_in();
            if (wppa_switch('show_comments') && $comment_allowed) {
                //				if ( wppa_switch( 'search_comments' ) ) wppa_index_remove( 'photo', $_REQUEST['photo-id'] );
                wppa_do_comment($_REQUEST['photo-id']);
                // Process the comment
                if (wppa_switch('search_comments')) {
                    wppa_index_update('photo', $_REQUEST['photo-id']);
                }
            }
            wppa('no_esc', true);
            echo wppa_comment_html($_REQUEST['photo-id'], $comment_allowed);
            // Retrieve the new commentbox content
            wppa_exit();
            break;
        case 'import':
            require_once 'wppa-upload.php';
            _wppa_page_import();
            wppa_exit();
            break;
        case 'approve':
            $iret = '0';
            if (!current_user_can('wppa_moderate') && !current_user_can('wppa_comments')) {
                _e('You do not have the rights to moderate photos this way', 'wp-photo-album-plus');
                wppa_exit();
            }
            if (isset($_REQUEST['photo-id']) && current_user_can('wppa_moderate')) {
                $iret = $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `status` = 'publish' WHERE `id` = %s", $_REQUEST['photo-id']));
                wppa_flush_upldr_cache('photoid', $_REQUEST['photo-id']);
                $alb = $wpdb->get_var($wpdb->prepare("SELECT `album` FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $_REQUEST['photo-id']));
                wppa_clear_taglist();
                wppa_flush_treecounts($alb);
            }
            if (isset($_REQUEST['comment-id'])) {
                $iret = $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_COMMENTS . "` SET `status` = 'approved' WHERE `id` = %s", $_REQUEST['comment-id']));
            }
            if ($iret) {
                echo 'OK';
            } else {
                if (isset($_REQUEST['photo-id'])) {
                    if (current_user_can('wppa_moderate')) {
                        echo sprintf(__('Failed to update stutus of photo %s', 'wp-photo-album-plus'), $_REQUEST['photo-id']) . "\n" . __('Please refresh the page', 'wp-photo-album-plus');
                    } else {
                        _e('Security check failure', 'wp-photo-album-plus');
                    }
                }
                if (isset($_REQUEST['comment-id'])) {
                    echo sprintf(__('Failed to update stutus of comment %s', 'wp-photo-album-plus'), $_REQUEST['comment-id']) . "\n" . __('Please refresh the page', 'wp-photo-album-plus');
                }
            }
            wppa_exit();
        case 'remove':
            if (isset($_REQUEST['photo-id'])) {
                // Remove photo
                if (wppa_user_is('administrator') || current_user_can('wppa_moderate') || wppa_get_user() == wppa_get_photo_owner($_REQUEST['photo-id']) && wppa_switch('upload_edit')) {
                    // Frontend delete?
                    wppa_delete_photo($_REQUEST['photo-id']);
                    echo 'OK||' . __('Photo removed', 'wp-photo-album-plus');
                    wppa_exit();
                }
            }
            if (!current_user_can('wppa_moderate') && !current_user_can('wppa_comments')) {
                _e('You do not have the rights to moderate photos this way', 'wp-photo-album-plus');
                wppa_exit();
            }
            if (isset($_REQUEST['photo-id'])) {
                // Remove photo
                if (!current_user_can('wppa_moderate')) {
                    _e('Security check failure', 'wp-photo-album-plus');
                    wppa_exit();
                }
                wppa_delete_photo($_REQUEST['photo-id']);
                echo 'OK||' . __('Photo removed', 'wp-photo-album-plus');
                wppa_exit();
            }
            if (isset($_REQUEST['comment-id'])) {
                // Remove comment
                $iret = $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_COMMENTS . "` WHERE `id`= %s", $_REQUEST['comment-id']));
                if ($iret) {
                    echo 'OK||' . __('Comment removed', 'wp-photo-album-plus');
                } else {
                    _e('Could not remove comment', 'wp-photo-album-plus');
                }
                wppa_exit();
            }
            _e('Unexpected error', 'wp-photo-album-plus');
            wppa_exit();
        case 'downloadalbum':
            // Feature enabled?
            if (!wppa_switch('allow_download_album')) {
                echo '||ER||' . __('This feature is not enabled on this website', 'wp-photo-album-plus');
                wppa_exit();
            }
            // Validate args
            $alb = $_REQUEST['album-id'];
            $status = "`status` <> 'pending' AND `status` <> 'scheduled'";
            if (!is_user_logged_in()) {
                $status .= " AND `status` <> 'private'";
            }
            $photos = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND ( ( " . $status . " ) OR owner = %s ) " . wppa_get_photo_order($alb), $alb, wppa_get_user()), ARRAY_A);
            if (!$photos) {
                echo '||ER||' . __('The album is empty', 'wp-photo-album-plus');
                wppa_exit();
            }
            // Remove obsolete files
            wppa_delete_obsolete_tempfiles();
            // Open zipfile
            if (!class_exists('ZipArchive')) {
                echo '||ER||' . __('Unable to create zip archive', 'wp-photo-album-plus');
                wppa_exit();
            }
            $zipfilename = wppa_get_album_name($alb);
            $zipfilename = wppa_sanitize_file_name($zipfilename . '.zip');
            // Remove illegal chars
            $zipfilepath = WPPA_UPLOAD_PATH . '/temp/' . $zipfilename;
            if (is_file($zipfilepath)) {
                //		unlink( $zipfilepath );	// Debug
            }
            $wppa_zip = new ZipArchive();
            $iret = $wppa_zip->open($zipfilepath, 1);
            if ($iret !== true) {
                echo '||ER||' . sprintf(__('Unable to create zip archive. code = %s', 'wp-photo-album-plus'), $iret);
                wppa_exit();
            }
            // Add photos to zip
            $stop = false;
            foreach ($photos as $p) {
                if (wppa_is_time_up()) {
                    wppa_log('obs', 'Time up during album to zip creation');
                    $stop = true;
                } else {
                    $id = $p['id'];
                    if (!wppa_is_multi($id)) {
                        $source = wppa_switch('download_album_source') && is_file(wppa_get_source_path($id)) ? wppa_get_source_path($id) : wppa_get_photo_path($id);
                        if (is_file($source)) {
                            $dest = $p['filename'] ? wppa_sanitize_file_name($p['filename']) : wppa_sanitize_file_name(wppa_strip_ext($p['name']) . '.' . $p['ext']);
                            $dest = wppa_fix_poster_ext($dest, $id);
                            $iret = $wppa_zip->addFile($source, $dest);
                            // To prevent too may files open, and to have at least a file when there are too many photos, close and re-open
                            $wppa_zip->close();
                            $wppa_zip->open($zipfilepath);
                            // wppa_log( 'dbg', 'Added ' . basename($source) . ' to ' . basename($zipfilepath));
                        }
                    }
                }
                if ($stop) {
                    break;
                }
            }
            // Close zip and return
            $zipcount = $wppa_zip->numFiles;
            $wppa_zip->close();
            // A zip is created
            $desturl = WPPA_UPLOAD_URL . '/temp/' . $zipfilename;
            echo $desturl . '||OK||';
            if ($zipcount != count($photos)) {
                echo sprintf(__('Only %s out of %s photos could be added to the zipfile', 'wp-photo-album-plus'), $zipcount, count($photos));
            }
            wppa_exit();
            break;
        case 'getalbumzipurl':
            $alb = $_REQUEST['album-id'];
            $zipfilename = wppa_get_album_name($alb);
            $zipfilename = wppa_sanitize_file_name($zipfilename . '.zip');
            // Remove illegal chars
            $zipfilepath = WPPA_UPLOAD_PATH . '/temp/' . $zipfilename;
            $zipfileurl = WPPA_UPLOAD_URL . '/temp/' . $zipfilename;
            if (is_file($zipfilepath)) {
                echo $zipfileurl;
            } else {
                echo 'ER';
            }
            wppa_exit();
            break;
        case 'makeorigname':
            $photo = $_REQUEST['photo-id'];
            $from = $_REQUEST['from'];
            if ($from == 'fsname') {
                $type = wppa_opt('art_monkey_link');
            } elseif ($from == 'popup') {
                $type = wppa_opt('art_monkey_popup_link');
            } else {
                echo '||7||' . __('Unknown source of request', 'wp-photo-album-plus');
                wppa_exit();
            }
            $data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $photo), ARRAY_A);
            if ($data) {
                // The photo is supposed to exist
                // Make the name
                if ($data['filename']) {
                    $name = $data['filename'];
                } else {
                    $name = __($data['name'], 'wp-photo-album-plus');
                }
                $name = wppa_sanitize_file_name($name);
                // Remove illegal chars
                $name = preg_replace('/\\.[^.]*$/', '', $name);
                // Remove file extension
                if (strlen($name) == '0') {
                    echo '||1||' . __('Empty filename', 'wp-photo-album-plus');
                    wppa_exit();
                }
                // Make the file
                if (wppa_switch('artmonkey_use_source')) {
                    if (is_file(wppa_get_source_path($photo))) {
                        $source = wppa_get_source_path($photo);
                    } else {
                        $source = wppa_get_photo_path($photo);
                    }
                } else {
                    $source = wppa_get_photo_path($photo);
                }
                $source = wppa_fix_poster_ext($source, $photo);
                // Fix the extension for mm items.
                if ($data['ext'] == 'xxx') {
                    $data['ext'] = wppa_get_ext($source);
                }
                $dest = WPPA_UPLOAD_PATH . '/temp/' . $name . '.' . $data['ext'];
                $zipfile = WPPA_UPLOAD_PATH . '/temp/' . $name . '.zip';
                $tempdir = WPPA_UPLOAD_PATH . '/temp';
                if (!is_dir($tempdir)) {
                    @mkdir($tempdir);
                }
                if (!is_dir($tempdir)) {
                    echo '||2||' . __('Unable to create tempdir', 'wp-photo-album-plus');
                    wppa_exit();
                }
                // Remove obsolete files
                wppa_delete_obsolete_tempfiles();
                // Make the files
                if ($type == 'file') {
                    copy($source, $dest);
                    $ext = $data['ext'];
                } elseif ($type == 'zip') {
                    if (!class_exists('ZipArchive')) {
                        echo '||8||' . __('Unable to create zip archive', 'wp-photo-album-plus');
                        wppa_exit();
                    }
                    $ext = 'zip';
                    $wppa_zip = new ZipArchive();
                    $wppa_zip->open($zipfile, 1);
                    $wppa_zip->addFile($source, basename($dest));
                    $wppa_zip->close();
                } else {
                    echo '||6||' . __('Unknown type', 'wp-photo-album-plus');
                    wppa_exit();
                }
                $desturl = WPPA_UPLOAD_URL . '/temp/' . $name . '.' . $ext;
                echo '||0||' . $desturl;
                // No error: return url
                wppa_exit();
            } else {
                echo '||9||' . __('The photo does no longer exist', 'wp-photo-album-plus');
                wppa_exit();
            }
            wppa_exit();
            break;
        case 'tinymcedialog':
            $result = wppa_make_tinymce_dialog();
            echo $result;
            wppa_exit();
            break;
        case 'bumpviewcount':
            $nonce = $_REQUEST['wppa-nonce'];
            if (wp_verify_nonce($nonce, 'wppa-check')) {
                wppa_bump_viewcount('photo', $_REQUEST['wppa-photo']);
            } else {
                _e('Security check failure', 'wp-photo-album-plus');
            }
            wppa_exit();
            break;
        case 'rate':
            // Get commandline args
            $photo = $_REQUEST['wppa-rating-id'];
            $rating = $_REQUEST['wppa-rating'];
            $occur = $_REQUEST['wppa-occur'];
            $index = $_REQUEST['wppa-index'];
            $nonce = $_REQUEST['wppa-nonce'];
            // Make errortext
            $errtxt = __('An error occurred while processing you rating request.', 'wp-photo-album-plus');
            $errtxt .= "\n" . __('Maybe you opened the page too long ago to recognize you.', 'wp-photo-album-plus');
            $errtxt .= "\n" . __('You may refresh the page and try again.', 'wp-photo-album-plus');
            $wartxt = __('Althoug an error occurred while processing your rating, your vote has been registered.', 'wp-photo-album-plus');
            $wartxt .= "\n" . __('However, this may not be reflected in the current pageview', 'wp-photo-album-plus');
            // Check on validity
            if (!wp_verify_nonce($nonce, 'wppa-check')) {
                echo '0||100||' . $errtxt;
                wppa_exit();
                // Nonce check failed
            }
            if (wppa_opt('rating_max') == '1' && $rating != '1') {
                echo '0||106||' . $errtxt . ':' . $rating;
                wppa_exit();
                // Value out of range
            } elseif (wppa_opt('rating_max') == '5' && !in_array($rating, array('-1', '1', '2', '3', '4', '5'))) {
                echo '0||106||' . $errtxt . ':' . $rating;
                wppa_exit();
                // Value out of range
            } elseif (wppa_opt('rating_max') == '10' && !in_array($rating, array('-1', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'))) {
                echo '0||106||' . $errtxt . ':' . $rating;
                wppa_exit();
                // Value out of range
            }
            // Get other data
            if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $photo))) {
                echo '0||999||' . __('Photo has been removed.', 'wp-photo-album-plus');
                wppa_exit();
            }
            $user = wppa_get_user();
            $mylast = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_RATING . '` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $photo, $user), ARRAY_A);
            $myavgrat = '0';
            // Init
            // Rate own photo?
            if (wppa_get_photo_item($photo, 'owner') == $user && !wppa_switch('allow_owner_votes')) {
                echo '0||900||' . __('Sorry, you can not rate your own photos', 'wp-photo-album-plus');
                wppa_exit();
            }
            // Already a pending one?
            $pending = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `user` = %s AND `status` = %s", $photo, $user, 'pending'));
            // Has user motivated his vote?
            $hascommented = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s AND `user` = %s", $photo, wppa_get_user('display')));
            if ($pending) {
                if (!$hascommented) {
                    echo '0||900||' . __('Please enter a comment.', 'wp-photo-album-plus');
                    wppa_exit();
                } else {
                    $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_RATING . "` SET `status` = 'publish' WHERE `photo` = %s AND `user` = %s", $photo, $user));
                }
            }
            if (wppa_switch('vote_needs_comment')) {
                $ratingstatus = $hascommented ? 'publish' : 'pending';
            } else {
                $ratingstatus = 'publish';
            }
            // When done, we have to echo $occur.'||'.$photo.'||'.$index.'||'.$myavgrat.'||'.$allavgrat.'||'.$discount.||.$hascommented.||.$message;
            // So we have to do: process rating and find new $myavgrat, $allavgrat and $discount ( $occur, $photo and $index are known )
            // Case 0: Illegal second vote. Frontend takes care of this, but a hacker could enter an ajaxlink manually
            if ($mylast && (!(wppa_switch('rating_change') || wppa_switch('rating_multi')) || $mylast['value'] < '0' || $mylast['value'] > '0' && $rating == '-1')) {
                echo '0||109||' . __('Security check failure.', 'wp-photo-album-plus');
                wppa_exit();
            }
            // Case 1: value = -1 this is a legal dislike vote
            if ($rating == '-1') {
                // Add my dislike
                $iret = wppa_create_rating_entry(array('photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus));
                if (!$iret) {
                    echo '0||101||' . $errtxt;
                    wppa_exit();
                    // Fail on storing vote
                }
                // Add points
                wppa_add_credit_points(wppa_opt('cp_points_rating'), __('Photo rated', 'wp-photo-album-plus'), $photo, $rating);
                wppa_dislike_check($photo);
                // Check for email to be sent every .. dislikes
                if (!is_file(wppa_get_thumb_path($photo))) {
                    // Photo is removed
                    echo $occur . '||' . $photo . '||' . $index . '||-1||-1|0||' . wppa_opt('dislike_delete');
                    wppa_exit();
                }
            } elseif (!$mylast) {
                // Add my vote
                $iret = wppa_create_rating_entry(array('photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus));
                if (!$iret) {
                    echo '0||102||' . $errtxt;
                    wppa_exit();
                    // Fail on storing vote
                }
                // Add points
                wppa_add_credit_points(wppa_opt('cp_points_rating'), __('Photo rated', 'wp-photo-album-plus'), $photo, $rating);
            } elseif (wppa_switch('rating_change')) {
                // Votechanging is allowed
                $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_RATING . '` SET `value` = %s WHERE `photo` = %s AND `user` = %s LIMIT 1', $rating, $photo, $user));
                if ($iret === false) {
                    echo '0||103||' . $errtxt;
                    wppa_exit();
                    // Fail on update
                }
            } elseif (wppa_switch('rating_multi')) {
                // Rating multi is allowed
                $iret = wppa_create_rating_entry(array('photo' => $photo, 'value' => $rating, 'user' => $user, 'status' => $ratingstatus));
                if (!$iret) {
                    echo '0||104||' . $errtxt;
                    wppa_exit();
                    // Fail on storing vote
                }
            } else {
                // Should never get here....
                echo '0||110||' . __('Unexpected error', 'wp-photo-album-plus');
                wppa_exit();
            }
            // Compute my avg rating
            $myrats = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_RATING . '`  WHERE `photo` = %s AND `user` = %s AND `status` = %s ', $photo, $user, 'publish'), ARRAY_A);
            if ($myrats) {
                $sum = 0;
                $cnt = 0;
                foreach ($myrats as $rat) {
                    if ($rat['value'] == '-1') {
                        $sum += wppa_opt('dislike_value');
                    } else {
                        $sum += $rat['value'];
                    }
                    $cnt++;
                }
                $myavgrat = $sum / $cnt;
                $i = wppa_opt('rating_prec');
                $j = $i + '1';
                $myavgrat = sprintf('%' . $j . '.' . $i . 'f', $myavgrat);
            } else {
                $myavgrat = '0';
            }
            // Compute new allavgrat
            $ratings = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . WPPA_RATING . ' WHERE `photo` = %s AND `status` = %s', $photo, 'publish'), ARRAY_A);
            if ($ratings) {
                $sum = 0;
                $cnt = 0;
                foreach ($ratings as $rat) {
                    if ($rat['value'] == '-1') {
                        $sum += wppa_opt('dislike_value');
                    } else {
                        $sum += $rat['value'];
                    }
                    $cnt++;
                }
                $allavgrat = $sum / $cnt;
                if ($allavgrat == '10') {
                    $allavgrat = '9.99999999';
                }
                // For sort order reasons text field
            } else {
                $allavgrat = '0';
            }
            // Store it in the photo info
            $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `mean_rating` = %s WHERE `id` = %s', $allavgrat, $photo));
            if ($iret === false) {
                echo '0||106||' . $wartxt;
                wppa_exit();
                // Fail on save
            }
            // Compute rating_count and store in the photo info
            $ratcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s", $photo));
            if ($ratcount !== false) {
                $iret = $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `rating_count` = %s WHERE `id` = %s", $ratcount, $photo));
                if ($iret === false) {
                    echo '0||107||' . $wartxt;
                    wppa_exit();
                    // Fail on save
                }
            }
            // Format $allavgrat for output
            $allavgratcombi = $allavgrat . '|' . $ratcount;
            // Compute dsilike count
            $discount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `value` = -1 AND `status` = %s", $photo, 'publish'));
            if ($discount === false) {
                echo '0||108||' . $wartxt;
                wppa_exit();
                // Fail on save
            }
            // Test for possible medal
            wppa_test_for_medal($photo);
            // Success!
            wppa_clear_cache();
            if (wppa_switch('vote_needs_comment') && !$hascommented) {
                $message = __("Please explain your vote in a comment.\nYour vote will be discarded if you don't.\n\nAfter completing your comment,\nyou can refresh the page to see\nyour vote became effective.", 'wp-photo-album-plus');
            } else {
                $message = '';
            }
            echo $occur . '||' . $photo . '||' . $index . '||' . $myavgrat . '||' . $allavgratcombi . '||' . $discount . '||' . $hascommented . '||' . $message;
            break;
        case 'render':
            $tim_1 = microtime(true);
            $nq_1 = get_num_queries();
            // Correct the fact that this is a non-admin operation, if it is
            if (is_admin()) {
                require_once 'wppa-non-admin.php';
            }
            wppa_load_theme();
            // Register geo shortcode if google-maps-gpx-vieuwer is on board. GPX does it in wp_head(), what is not done in an ajax call
            //			if ( function_exists( 'gmapv3' ) ) add_shortcode( 'map', 'gmapv3' );
            // Get the post we are working for
            if (isset($_REQUEST['wppa-fromp'])) {
                $p = $_REQUEST['wppa-fromp'];
                if (wppa_is_int($p)) {
                    $GLOBALS['post'] = get_post($p);
                }
            }
            // Render
            echo wppa_albums();
            $tim_2 = microtime(true);
            $nq_2 = get_num_queries();
            $mem = memory_get_peak_usage(true) / 1024 / 1024;
            $msg = sprintf('WPPA Ajax render: db queries: WP:%d, WPPA+: %d in %4.2f seconds, using %4.2f MB memory max', $nq_1, $nq_2 - $nq_1, $tim_2 - $tim_1, $mem);
            echo '<script type="text/javascript">wppaConsoleLog( \'' . $msg . '\', \'force\' )</script>';
            break;
        case 'delete-photo':
            $photo = $_REQUEST['photo-id'];
            $nonce = $_REQUEST['wppa-nonce'];
            // Check validity
            if (!wp_verify_nonce($nonce, 'wppa_nonce_' . $photo)) {
                echo '||0||' . __('You do not have the rights to delete a photo', 'wp-photo-album-plus');
                wppa_exit();
                // Nonce check failed
            }
            if (!is_numeric($photo)) {
                echo '||0||' . __('Security check failure', 'wp-photo-album-plus');
                wppa_exit();
                // Nonce check failed
            }
            $album = $wpdb->get_var($wpdb->prepare('SELECT `album` FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo));
            wppa_delete_photo($photo);
            wppa_clear_cache();
            echo '||1||<span style="color:red" >' . sprintf(__('Photo %s has been deleted', 'wp-photo-album-plus'), $photo) . '</span>';
            echo '||';
            $a = wppa_allow_uploads($album);
            if (!$a) {
                echo 'full';
            } else {
                echo 'notfull||' . $a;
            }
            break;
        case 'update-album':
            $album = $_REQUEST['album-id'];
            $nonce = $_REQUEST['wppa-nonce'];
            $item = $_REQUEST['item'];
            $value = $_REQUEST['value'];
            $value = wppa_decode($value);
            // Check validity
            if (!wp_verify_nonce($nonce, 'wppa_nonce_' . $album)) {
                echo '||0||' . __('You do not have the rights to update album information', 'wp-photo-album-plus') . $nonce;
                wppa_exit();
                // Nonce check failed
            }
            switch ($item) {
                case 'clear_ratings':
                    $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s', $album), ARRAY_A);
                    if ($photos) {
                        foreach ($photos as $photo) {
                            $iret1 = $wpdb->query($wpdb->prepare('DELETE FROM `' . WPPA_RATING . '` WHERE `photo` = %s', $photo['id']));
                            $iret2 = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `mean_rating` = %s WHERE `id` = %s', '', $photo['id']));
                        }
                    }
                    if ($photos && $iret1 !== false && $iret2 !== false) {
                        echo '||97||' . __('<b>Ratings cleared</b>', 'wp-photo-album-plus') . '||' . __('No ratings for this photo.', 'wp-photo-album-plus');
                    } elseif ($photos) {
                        echo '||1||' . __('An error occurred while clearing ratings', 'wp-photo-album-plus');
                    } else {
                        echo '||97||' . __('<b>No photos in this album</b>', 'wp-photo-album-plus') . '||' . __('No ratings for this photo.', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'set_deftags':
                    // to be changed for large albums
                    $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s', $album), ARRAY_A);
                    $deftag = $wpdb->get_var($wpdb->prepare('SELECT `default_tags` FROM `' . WPPA_ALBUMS . '` WHERE `id` = %s', $album));
                    if (is_array($photos)) {
                        foreach ($photos as $photo) {
                            $tags = wppa_sanitize_tags(wppa_filter_iptc(wppa_filter_exif($deftag, $photo['id']), $photo['id']));
                            $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `tags` = %s WHERE `id` = %s', $tags, $photo['id']));
                            wppa_index_update('photo', $photo['id']);
                        }
                    }
                    if ($photos && $iret !== false) {
                        echo '||97||' . __('<b>Tags set to defaults</b> (reload)', 'wp-photo-album-plus');
                    } elseif ($photos) {
                        echo '||1||' . __('An error occurred while setting tags', 'wp-photo-album-plus');
                    } else {
                        echo '||97||' . __('<b>No photos in this album</b>', 'wp-photo-album-plus');
                    }
                    wppa_clear_taglist();
                    wppa_exit();
                    break;
                case 'add_deftags':
                    $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s', $album), ARRAY_A);
                    $deftag = $wpdb->get_var($wpdb->prepare('SELECT `default_tags` FROM `' . WPPA_ALBUMS . '` WHERE `id` = %s', $album));
                    if (is_array($photos)) {
                        foreach ($photos as $photo) {
                            $tags = wppa_sanitize_tags(wppa_filter_iptc(wppa_filter_exif($photo['tags'] . ',' . $deftag, $photo['id']), $photo['id']));
                            $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `tags` = %s WHERE `id` = %s', $tags, $photo['id']));
                            wppa_index_update('photo', $photo['id']);
                        }
                    }
                    if ($photos && $iret !== false) {
                        echo '||97||' . __('<b>Tags added width defaults</b> (reload)', 'wp-photo-album-plus');
                    } elseif ($photos) {
                        echo '||1||' . __('An error occurred while adding tags', 'wp-photo-album-plus');
                    } else {
                        echo '||97||' . __('<b>No photos in this album</b>', 'wp-photo-album-plus');
                    }
                    wppa_clear_taglist();
                    wppa_exit();
                    break;
                case 'name':
                    $value = trim(strip_tags($value));
                    if (!wppa_sanitize_file_name($value)) {
                        // Empty album name is not allowed
                        $value = 'Album-#' . $album;
                        echo '||5||' . sprintf(__('Album name may not be empty.<br />Reset to <b>%s</b>', 'wp-photo-album-plus'), $value);
                    }
                    $itemname = __('Name', 'wp-photo-album-plus');
                    break;
                case 'description':
                    $itemname = __('Description', 'wp-photo-album-plus');
                    if (wppa_switch('check_balance')) {
                        $value = str_replace(array('<br/>', '<br>'), '<br />', $value);
                        if (balanceTags($value, true) != $value) {
                            echo '||3||' . __('Unbalanced tags in album description!', 'wp-photo-album-plus');
                            wppa_exit();
                        }
                    }
                    $value = trim($value);
                    break;
                case 'a_order':
                    $itemname = __('Album order #', 'wp-photo-album-plus');
                    break;
                case 'main_photo':
                    $itemname = __('Cover photo', 'wp-photo-album-plus');
                    break;
                case 'a_parent':
                    $itemname = __('Parent album', 'wp-photo-album-plus');
                    wppa_flush_treecounts($album);
                    // Myself and my parents
                    wppa_flush_treecounts($value);
                    // My new parent
                    break;
                case 'p_order_by':
                    $itemname = __('Photo order', 'wp-photo-album-plus');
                    break;
                case 'alt_thumbsize':
                    $itemname = __('Use Alt thumbsize', 'wp-photo-album-plus');
                    break;
                case 'cover_type':
                    $itemname = __('Cover Type', 'wp-photo-album-plus');
                    break;
                case 'cover_linktype':
                    $itemname = __('Link type', 'wp-photo-album-plus');
                    break;
                case 'cover_linkpage':
                    $itemname = __('Link to', 'wp-photo-album-plus');
                    break;
                case 'owner':
                    $itemname = __('Owner', 'wp-photo-album-plus');
                    if ($value != '--- public ---' && !get_user_by('login', $value)) {
                        echo '||4||' . sprintf(__('User %s does not exist', 'wp-photo-album-plus'), $value);
                        wppa_exit();
                    }
                    break;
                case 'upload_limit_count':
                    wppa_ajax_check_range($value, false, '0', false, __('Upload limit count', 'wp-photo-album-plus'));
                    if (wppa('error')) {
                        wppa_exit();
                    }
                    $oldval = $wpdb->get_var($wpdb->prepare('SELECT `upload_limit` FROM ' . WPPA_ALBUMS . ' WHERE `id` = %s', $album));
                    $temp = explode('/', $oldval);
                    $value = $value . '/' . $temp[1];
                    $item = 'upload_limit';
                    $itemname = __('Upload limit count', 'wp-photo-album-plus');
                    break;
                case 'upload_limit_time':
                    $oldval = $wpdb->get_var($wpdb->prepare('SELECT `upload_limit` FROM ' . WPPA_ALBUMS . ' WHERE `id` = %s', $album));
                    $temp = explode('/', $oldval);
                    $value = $temp[0] . '/' . $value;
                    $item = 'upload_limit';
                    $itemname = __('Upload limit time', 'wp-photo-album-plus');
                    break;
                case 'default_tags':
                    $value = wppa_sanitize_tags($value, false, true);
                    $itemname = __('Default tags', 'wp-photo-album-plus');
                    break;
                case 'cats':
                    $value = wppa_sanitize_cats($value);
                    wppa_clear_catlist();
                    $itemname = __('Categories', 'wp-photo-album-plus');
                    break;
                case 'suba_order_by':
                    $itemname = __('Sub albums sort order', 'wp-photo-album-plus');
                    break;
                case 'year':
                case 'month':
                case 'day':
                case 'hour':
                case 'min':
                    $itemname = __('Schedule date/time', 'wp-photo-album-plus');
                    $scheduledtm = $wpdb->get_var($wpdb->prepare("SELECT `scheduledtm` FROM`" . WPPA_ALBUMS . "` WHERE `id` = %s", $album));
                    if (!$scheduledtm) {
                        $scheduledtm = wppa_get_default_scheduledtm();
                    }
                    $temp = explode(',', $scheduledtm);
                    if ($item == 'year') {
                        $temp[0] = $value;
                    }
                    if ($item == 'month') {
                        $temp[1] = $value;
                    }
                    if ($item == 'day') {
                        $temp[2] = $value;
                    }
                    if ($item == 'hour') {
                        $temp[3] = $value;
                    }
                    if ($item == 'min') {
                        $temp[4] = $value;
                    }
                    $scheduledtm = implode(',', $temp);
                    wppa_update_album(array('id' => $album, 'scheduledtm' => $scheduledtm));
                    echo '||0||' . sprintf(__('<b>%s</b> of album %s updated', 'wp-photo-album-plus'), $itemname, $album);
                    wppa_exit();
                    break;
                case 'setallscheduled':
                    $scheduledtm = $wpdb->get_var($wpdb->prepare("SELECT `scheduledtm` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $album));
                    if ($scheduledtm) {
                        $iret = $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `status` = 'scheduled', `scheduledtm` = %s WHERE `album` = %s", $scheduledtm, $album));
                        echo '||0||' . __('All photos set to scheduled per date', 'wp-photo-album-plus') . ' ( ' . $iret . ' ) ' . wppa_format_scheduledtm($scheduledtm);
                    }
                    wppa_exit();
                    break;
                default:
                    $itemname = $item;
            }
            $query = $wpdb->prepare('UPDATE ' . WPPA_ALBUMS . ' SET `' . $item . '` = %s WHERE `id` = %s', $value, $album);
            $iret = $wpdb->query($query);
            if ($iret !== false) {
                if ($item == 'name' || $item == 'description' || $item == 'cats') {
                    wppa_index_update('album', $album);
                }
                if ($item == 'name') {
                    wppa_create_pl_htaccess();
                }
                echo '||0||' . sprintf(__('<b>%s</b> of album %s updated', 'wp-photo-album-plus'), $itemname, $album);
                if ($item == 'upload_limit') {
                    echo '||';
                    $a = wppa_allow_uploads($album);
                    if (!$a) {
                        echo 'full';
                    } else {
                        echo 'notfull||' . $a;
                    }
                }
            } else {
                echo '||2||' . sprintf(__('An error occurred while trying to update <b>%s</b> of album %s', 'wp-photo-album-plus'), $itemname, $album);
                echo '<br>' . __('Press CTRL+F5 and try again.', 'wp-photo-album-plus');
            }
            wppa_clear_cache();
            wppa_exit();
            break;
        case 'update-comment-status':
            $photo = $_REQUEST['wppa-photo-id'];
            $nonce = $_REQUEST['wppa-nonce'];
            $comid = $_REQUEST['wppa-comment-id'];
            $comstat = $_REQUEST['wppa-comment-status'];
            // Check validity
            if (!wp_verify_nonce($nonce, 'wppa_nonce_' . $photo)) {
                echo '||0||' . __('You do not have the rights to update comment status', 'wp-photo-album-plus') . $nonce;
                wppa_exit();
                // Nonce check failed
            }
            //			if ( wppa_switch( 'search_comments' ) ) wppa_index_remove( 'photo', $photo );
            $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_COMMENTS . '` SET `status` = %s WHERE `id` = %s', $comstat, $comid));
            if (wppa_switch('search_comments')) {
                wppa_index_update('photo', $photo);
            }
            if ($iret !== false) {
                echo '||0||' . sprintf(__('Status of comment #%s updated', 'wp-photo-album-plus'), $comid);
            } else {
                echo '||1||' . sprintf(__('Error updating status comment #%s', 'wp-photo-album-plus'), $comid);
            }
            wppa_exit();
            break;
        case 'watermark-photo':
            $photo = $_REQUEST['photo-id'];
            $nonce = $_REQUEST['wppa-nonce'];
            // Check validity
            if (!wp_verify_nonce($nonce, 'wppa_nonce_' . $photo)) {
                echo '||1||' . __('You do not have the rights to change photos', 'wp-photo-album-plus');
                wppa_exit();
                // Nonce check failed
            }
            wppa_cache_thumb($photo);
            if (wppa_add_watermark($photo)) {
                if (wppa_switch('watermark_thumbs')) {
                    wppa_create_thumbnail($photo);
                    // create new thumb
                }
                echo '||0||' . __('Watermark applied', 'wp-photo-album-plus');
                wppa_exit();
            } else {
                echo '||1||' . __('An error occured while trying to apply a watermark', 'wp-photo-album-plus');
                wppa_exit();
            }
        case 'update-photo':
            $photo = $_REQUEST['photo-id'];
            $nonce = $_REQUEST['wppa-nonce'];
            $item = $_REQUEST['item'];
            $value = isset($_REQUEST['value']) ? $_REQUEST['value'] : '';
            $value = wppa_decode($value);
            // Check validity
            if (!wp_verify_nonce($nonce, 'wppa_nonce_' . $photo)) {
                echo '||0||' . __('You do not have the rights to update photo information', 'wp-photo-album-plus');
                wppa_exit();
                // Nonce check failed
            }
            if (substr($item, 0, 20) == 'wppa_watermark_file_' || substr($item, 0, 19) == 'wppa_watermark_pos_') {
                wppa_update_option($item, $value);
                echo '||0||' . sprintf(__('%s updated to %s.', 'wp-photo-album-plus'), $item, $value);
                wppa_exit();
            }
            switch ($item) {
                case 'exifdtm':
                    $format = '0000:00:00 00:00:00';
                    $err = '0';
                    // Length ok?
                    if (strlen($value) != 19) {
                        $err = '1';
                    }
                    // Check on digits, colons and space
                    for ($i = 0; $i < 19; $i++) {
                        $d = substr($value, $i, 1);
                        $f = substr($format, $i, 1);
                        switch ($f) {
                            case '0':
                                if (!in_array($d, array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))) {
                                    $err = '2';
                                }
                                break;
                            case ':':
                            case ' ':
                                if ($d != $f) {
                                    $err = '3';
                                }
                                break;
                        }
                    }
                    // Check on values if format correct, report first error only
                    if (!$err) {
                        $temp = explode(':', str_replace(' ', ':', $value));
                        if ($temp['0'] < '1970') {
                            $err = '11';
                        }
                        // Before UNIX epoch
                        if (!$err && $temp['0'] > date('Y')) {
                            $err = '12';
                        }
                        // Future
                        if (!$err && $temp['1'] < '1') {
                            $err = '13';
                        }
                        // Before january
                        if (!$err && $temp['1'] > '12') {
                            $err = '14';
                        }
                        // After december
                        if (!$err && $temp['2'] < '1') {
                            $err = '15';
                        }
                        // Before first of month
                        if (!$err && $temp['2'] > '31') {
                            $err = '17';
                        }
                        // After 31st ( forget about feb and months with 30 days )
                        if (!$err && $temp['3'] < '1') {
                            $err = '18';
                        }
                        // Before first hour
                        if (!$err && $temp['3'] > '24') {
                            $err = '19';
                        }
                        // Hour > 24
                        if (!$err && $temp['4'] < '1') {
                            $err = '20';
                        }
                        // Min < 1
                        if (!$err && $temp['4'] > '59') {
                            $err = '21';
                        }
                        // Min > 59
                        if (!$err && $temp['5'] < '1') {
                            $err = '22';
                        }
                        // Sec < 1
                        if (!$err && $temp['5'] > '59') {
                            $err = '23';
                        }
                        // Sec > 59
                    }
                    if ($err) {
                        echo '||1||' . sprintf(__('Format error %s. Must be yyyy:mm:dd hh:mm:ss', 'wp-photo-album-plus'), $err);
                    } else {
                        wppa_update_photo(array('id' => $photo, 'exifdtm' => $value));
                        echo '||0||' . __('Exif date/time updated', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'lat':
                    if (!is_numeric($value) || $value < '-90.0' || $value > '90.0') {
                        echo '||1||' . __('Enter a value > -90 and < 90', 'wp-photo-album-plus');
                        wppa_exit();
                    }
                    $photodata = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $photo), ARRAY_A);
                    $geo = $photodata['location'] ? $photodata['location'] : '///';
                    $geo = explode('/', $geo);
                    $geo = wppa_format_geo($value, $geo['3']);
                    $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `location` = %s WHERE `id` = %s', $geo, $photo));
                    if ($iret) {
                        echo '||0||' . __('Lattitude updated', 'wp-photo-album-plus');
                    } else {
                        echo '||1||' . __('Could not update lattitude', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'lon':
                    if (!is_numeric($value) || $value < '-180.0' || $value > '180.0') {
                        echo '||1||' . __('Enter a value > -180 and < 180', 'wp-photo-album-plus');
                        wppa_exit();
                    }
                    $photodata = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $photo), ARRAY_A);
                    $geo = $photodata['location'] ? $photodata['location'] : '///';
                    $geo = explode('/', $geo);
                    $geo = wppa_format_geo($geo['2'], $value);
                    $iret = $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `location` = %s WHERE `id` = %s', $geo, $photo));
                    if ($iret) {
                        echo '||0||' . __('Longitude updated', 'wp-photo-album-plus');
                    } else {
                        echo '||1||' . __('Could not update longitude', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'remake':
                    if (wppa_remake_files('', $photo)) {
                        wppa_bump_photo_rev();
                        wppa_bump_thumb_rev();
                        echo '||0||' . __('Photo files remade', 'wp-photo-album-plus');
                    } else {
                        echo '||2||' . __('Could not remake files', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'remakethumb':
                    if (wppa_create_thumbnail($photo)) {
                        echo '||0||' . __('Thumbnail remade', 'wp-photo-album-plus');
                    } else {
                        echo '||0||' . __('Could not remake thumbnail', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'rotright':
                case 'rot180':
                case 'rotleft':
                    switch ($item) {
                        case 'rotleft':
                            $angle = '90';
                            $dir = __('left', 'wp-photo-album-plus');
                            break;
                        case 'rot180':
                            $angle = '180';
                            $dir = __('180&deg;', 'wp-photo-album-plus');
                            break;
                        case 'rotright':
                            $angle = '270';
                            $dir = __('right', 'wp-photo-album-plus');
                            break;
                    }
                    wppa('error', wppa_rotate($photo, $angle));
                    if (!wppa('error')) {
                        wppa_update_modified($photo);
                        wppa_bump_photo_rev();
                        wppa_bump_thumb_rev();
                        echo '||0||' . sprintf(__('Photo %s rotated %s', 'wp-photo-album-plus'), $photo, $dir);
                    } else {
                        echo '||' . wppa('error') . '||' . sprintf(__('An error occurred while trying to rotate photo %s', 'wp-photo-album-plus'), $photo);
                    }
                    wppa_exit();
                    break;
                case 'moveto':
                    $photodata = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $photo), ARRAY_A);
                    if (wppa_switch('void_dups')) {
                        // Check for already exists
                        $exists = wppa_file_is_in_album($photodata['filename'], $value);
                        if ($exists) {
                            // Already exists
                            echo '||3||' . sprintf(__('A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photodata['filename'], $value);
                            wppa_exit();
                            break;
                        }
                    }
                    wppa_flush_treecounts($photodata['album']);
                    // Current album
                    wppa_flush_treecounts($value);
                    // New album
                    $iret = $wpdb->query($wpdb->prepare('UPDATE ' . WPPA_PHOTOS . ' SET `album` = %s WHERE `id` = %s', $value, $photo));
                    if ($iret !== false) {
                        wppa_move_source($photodata['filename'], $photodata['album'], $value);
                        echo '||99||' . sprintf(__('Photo %s has been moved to album %s (%s)', 'wp-photo-album-plus'), $photo, wppa_get_album_name($value), $value);
                    } else {
                        echo '||3||' . sprintf(__('An error occurred while trying to move photo %s', 'wp-photo-album-plus'), $photo);
                    }
                    wppa_exit();
                    break;
                case 'copyto':
                    $photodata = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $photo), ARRAY_A);
                    if (wppa_switch('void_dups')) {
                        // Check for already exists
                        $exists = wppa_file_is_in_album($photodata['filename'], $value);
                        if ($exists) {
                            // Already exists
                            echo '||4||' . sprintf(__('A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photodata['filename'], $value);
                            wppa_exit();
                            break;
                        }
                    }
                    wppa('error', wppa_copy_photo($photo, $value));
                    wppa_flush_treecounts($value);
                    // New album
                    if (!wppa('error')) {
                        echo '||0||' . sprintf(__('Photo %s copied to album %s (%s)', 'wp-photo-album-plus'), $photo, wppa_get_album_name($value), $value);
                    } else {
                        echo '||4||' . sprintf(__('An error occurred while trying to copy photo %s', 'wp-photo-album-plus'), $photo);
                        echo '<br>' . __('Press CTRL+F5 and try again.', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'status':
                    if (!current_user_can('wppa_moderate') && !current_user_can('wppa_admin')) {
                        die('Security check failure #78');
                    }
                    wppa_flush_treecounts(wppa_get_photo_item($photo, 'album'));
                    // $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) ) );
                // $wpdb->get_var( $wpdb->prepare( "SELECT `album` FROM `".WPPA_PHOTOS."` WHERE `id` = %s", $photo ) ) );
                case 'owner':
                case 'name':
                case 'description':
                case 'p_order':
                case 'linkurl':
                case 'linktitle':
                case 'linktarget':
                case 'tags':
                case 'alt':
                case 'videox':
                case 'videoy':
                    switch ($item) {
                        case 'name':
                            $value = strip_tags($value);
                            $itemname = __('Name', 'wp-photo-album-plus');
                            break;
                        case 'description':
                            $itemname = __('Description', 'wp-photo-album-plus');
                            if (wppa_switch('check_balance')) {
                                $value = str_replace(array('<br/>', '<br>'), '<br />', $value);
                                if (balanceTags($value, true) != $value) {
                                    echo '||3||' . __('Unbalanced tags in photo description!', 'wp-photo-album-plus');
                                    wppa_exit();
                                }
                            }
                            break;
                        case 'p_order':
                            $itemname = __('Photo order #', 'wp-photo-album-plus');
                            break;
                        case 'owner':
                            $usr = get_user_by('login', $value);
                            if (!$usr) {
                                echo '||4||' . sprintf(__('User %s does not exists', 'wp-photo-album-plus'), $value);
                                wppa_exit();
                            }
                            $value = $usr->user_login;
                            // Correct possible case mismatch
                            wppa_flush_upldr_cache('photoid', $photo);
                            // Current owner
                            wppa_flush_upldr_cache('username', $value);
                            // New owner
                            $itemname = __('Owner', 'wp-photo-album-plus');
                            break;
                        case 'linkurl':
                            $itemname = __('Link url', 'wp-photo-album-plus');
                            break;
                        case 'linktitle':
                            $itemname = __('Link title', 'wp-photo-album-plus');
                            break;
                        case 'linktarget':
                            $itemname = __('Link target', 'wp-photo-album-plus');
                            break;
                        case 'tags':
                            $value = wppa_sanitize_tags($value, false, true);
                            $value = wppa_sanitize_tags(wppa_filter_iptc(wppa_filter_exif($value, $photo), $photo));
                            wppa_clear_taglist();
                            $itemname = __('Photo Tags', 'wp-photo-album-plus');
                            break;
                        case 'status':
                            wppa_clear_taglist();
                            wppa_flush_upldr_cache('photoid', $photo);
                            $itemname = __('Status', 'wp-photo-album-plus');
                            break;
                        case 'alt':
                            $itemname = __('HTML Alt', 'wp-photo-album-plus');
                            $value = strip_tags(stripslashes($value));
                            break;
                        case 'videox':
                            $itemname = __('Video width', 'wp-photo-album-plus');
                            if (!wppa_is_int($value) || $value < '0') {
                                echo '||3||' . __('Please enter an integer value >= 0', 'wp-photo-album-plus');
                                wppa_exit();
                            }
                            break;
                        case 'videoy':
                            $itemname = __('Video height', 'wp-photo-album-plus');
                            if (!wppa_is_int($value) || $value < '0') {
                                echo '||3||' . __('Please enter an integer value >= 0', 'wp-photo-album-plus');
                                wppa_exit();
                            }
                            break;
                        default:
                            $itemname = $item;
                    }
                    //				if ( $item == 'name' || $item == 'description' || $item == 'tags' ) wppa_index_quick_remove( 'photo', $photo );
                    $iret = $wpdb->query($wpdb->prepare('UPDATE ' . WPPA_PHOTOS . ' SET `' . $item . '` = %s WHERE `id` = %s', $value, $photo));
                    if ($item == 'name' || $item == 'description' || $item == 'tags') {
                        wppa_index_update('photo', $photo);
                    }
                    if ($item == 'status' && $value != 'scheduled') {
                        wppa_update_photo(array('id' => $photo, 'scheduledtm' => ''));
                    }
                    if ($item == 'status') {
                        wppa_flush_treecounts(wppa_get_photo_item($photo, 'album'));
                    }
                    if ($iret !== false) {
                        wppa_update_modified($photo);
                        if (wppa_is_video($photo)) {
                            echo '||0||' . sprintf(__('<b>%s</b> of video %s updated', 'wp-photo-album-plus'), $itemname, $photo);
                        } else {
                            echo '||0||' . sprintf(__('<b>%s</b> of photo %s updated', 'wp-photo-album-plus'), $itemname, $photo);
                        }
                    } else {
                        echo '||2||' . sprintf(__('An error occurred while trying to update <b>%s</b> of photo %s', 'wp-photo-album-plus'), $itemname, $photo);
                        echo '<br>' . __('Press CTRL+F5 and try again.', 'wp-photo-album-plus');
                        wppa_exit();
                    }
                    break;
                case 'year':
                case 'month':
                case 'day':
                case 'hour':
                case 'min':
                    $itemname = __('Schedule date/time', 'wp-photo-album-plus');
                    $scheduledtm = $wpdb->get_var($wpdb->prepare("SELECT `scheduledtm` FROM`" . WPPA_PHOTOS . "` WHERE `id` = %s", $photo));
                    if (!$scheduledtm) {
                        $scheduledtm = wppa_get_default_scheduledtm();
                    }
                    $temp = explode(',', $scheduledtm);
                    if ($item == 'year') {
                        $temp[0] = $value;
                    }
                    if ($item == 'month') {
                        $temp[1] = $value;
                    }
                    if ($item == 'day') {
                        $temp[2] = $value;
                    }
                    if ($item == 'hour') {
                        $temp[3] = $value;
                    }
                    if ($item == 'min') {
                        $temp[4] = $value;
                    }
                    $scheduledtm = implode(',', $temp);
                    wppa_update_photo(array('id' => $photo, 'scheduledtm' => $scheduledtm, 'status' => 'scheduled'));
                    wppa_flush_treecounts($wpdb->get_var($wpdb->prepare("SELECT `album` FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $photo)));
                    wppa_flush_upldr_cache('photoid', $photo);
                    if (wppa_is_video($photo)) {
                        echo '||0||' . sprintf(__('<b>%s</b> of video %s updated', 'wp-photo-album-plus'), $itemname, $photo);
                    } else {
                        echo '||0||' . sprintf(__('<b>%s</b> of photo %s updated', 'wp-photo-album-plus'), $itemname, $photo);
                    }
                    break;
                case 'custom_0':
                case 'custom_1':
                case 'custom_2':
                case 'custom_3':
                case 'custom_4':
                case 'custom_5':
                case 'custom_6':
                case 'custom_7':
                case 'custom_8':
                case 'custom_9':
                    $index = substr($item, -1);
                    $custom = wppa_get_photo_item($photo, 'custom');
                    if ($custom) {
                        $custom_data = unserialize($custom);
                    } else {
                        $custom_data = array('', '', '', '', '', '', '', '', '', '');
                    }
                    $custom_data[$index] = strip_tags($value);
                    $custom = serialize($custom_data);
                    wppa_update_photo(array('id' => $photo, 'custom' => $custom, 'modified' => time()));
                    wppa_index_update('photo', $photo);
                    echo '||0||' . sprintf(__('<b>Custom field %s</b> of photo %s updated', 'wp-photo-album-plus'), wppa_opt('custom_caption_' . $index), $photo);
                    break;
                case 'file':
                    // Check on upload error
                    if ($_FILES['photo']['error']) {
                        echo '||' . $_FILES['photo']['error'] . '||' . __('<b>Error during upload.</b>', 'wp-photo-album-plus');
                        wppa_exit();
                    }
                    // Save new source
                    wppa_save_source($_FILES['photo']['tmp_name'], wppa_get_photo_item($photo, 'filename'), wppa_get_photo_item($photo, 'album'));
                    // Make the files
                    $bret = wppa_make_the_photo_files($_FILES['photo']['tmp_name'], $photo, strtolower(wppa_get_ext($_FILES['photo']['name'])));
                    if ($bret) {
                        // Update timestamps and sizes
                        $alb = wppa_get_photo_item($photo, 'album');
                        wppa_update_album(array('id' => $alb, 'modified' => time()));
                        wppa_update_photo(array('id' => $photo, 'modified' => time(), 'thumbx' => '0', 'thumby' => '0', 'photox' => '0', 'photoy' => '0'));
                        // Report success
                        echo '||0||' . __('Photo files updated.', 'wp-photo-album-plus');
                    } else {
                        // Report fail
                        echo '||1||' . __('Could not update files.', 'wp-photo-album-plus');
                    }
                    wppa_exit();
                    break;
                case 'stereo':
                    $t = microtime(true);
                    wppa_update_photo(array('id' => $photo, 'stereo' => $value));
                    wppa_create_stereo_images($photo);
                    wppa_create_thumbnail($photo);
                    $t = microtime(true) - $t;
                    echo '||0||' . sprintf(__('Stereo mode updated in %d milliseconds', 'wp-photo-album-plus'), floor($t * 1000));
                    wppa_exit();
                    break;
                default:
                    echo '||98||This update action is not implemented yet( ' . $item . ' )';
                    wppa_exit();
            }
            wppa_clear_cache();
            break;
            // The wppa-settings page calls ajax with $wppa_action == 'update-option';
        // The wppa-settings page calls ajax with $wppa_action == 'update-option';
        case 'update-option':
            // Verify that we are legally here
            $nonce = $_REQUEST['wppa-nonce'];
            if (!wp_verify_nonce($nonce, 'wppa-nonce')) {
                echo '||1||' . __('You do not have the rights to update settings', 'wp-photo-album-plus');
                wppa_exit();
                // Nonce check failed
            }
            // Initialize
            $old_minisize = wppa_get_minisize();
            // Remember for later, maybe we do something that requires regen
            $option = $_REQUEST['wppa-option'];
            // The option to be processed
            $value = isset($_REQUEST['value']) ? wppa_decode($_REQUEST['value']) : '';
            // The new value, may also contain & # and +
            $value = stripslashes($value);
            $value = trim($value);
            // Remaove surrounding spaces
            $alert = '';
            // Init the return string data
            wppa('error', '0');
            //
            $title = '';
            //
            // If it is a font family, change all double quotes into single quotes as this destroys much more than you would like
            if (strpos($option, 'wppa_fontfamily_') !== false) {
                $value = str_replace('"', "'", $value);
            }
            $option = wppa_decode($option);
            // Dispatch on option
            if (substr($option, 0, 16) == 'wppa_iptc_label_') {
                $tag = substr($option, 16);
                $q = $wpdb->prepare("UPDATE `" . WPPA_IPTC . "` SET `description`=%s WHERE `tag`=%s AND `photo`='0'", $value, $tag);
                $bret = $wpdb->query($q);
                // Produce the response text
                if ($bret) {
                    $output = '||0||' . $tag . ' updated to ' . $value . '||';
                } else {
                    $output = '||1||Failed to update ' . $tag . '||';
                }
                echo $output;
                wppa_exit();
            } elseif (substr($option, 0, 17) == 'wppa_iptc_status_') {
                $tag = substr($option, 17);
                $q = $wpdb->prepare("UPDATE `" . WPPA_IPTC . "` SET `status`=%s WHERE `tag`=%s AND `photo`='0'", $value, $tag);
                $bret = $wpdb->query($q);
                // Produce the response text
                if ($bret) {
                    $output = '||0||' . $tag . ' updated to ' . $value . '||';
                } else {
                    $output = '||1||Failed to update ' . $tag . '||';
                }
                echo $output;
                wppa_exit();
            } elseif (substr($option, 0, 16) == 'wppa_exif_label_') {
                $tag = substr($option, 16);
                $q = $wpdb->prepare("UPDATE `" . WPPA_EXIF . "` SET `description`=%s WHERE `tag`=%s AND `photo`='0'", $value, $tag);
                $bret = $wpdb->query($q);
                // Produce the response text
                if ($bret) {
                    $output = '||0||' . $tag . ' updated to ' . $value . '||';
                } else {
                    $output = '||1||Failed to update ' . $tag . '||';
                }
                echo $output;
                wppa_exit();
            } elseif (substr($option, 0, 17) == 'wppa_exif_status_') {
                $tag = substr($option, 17);
                $q = $wpdb->prepare("UPDATE `" . WPPA_EXIF . "` SET `status`=%s WHERE `tag`=%s AND `photo`='0'", $value, $tag);
                $bret = $wpdb->query($q);
                // Produce the response text
                if ($bret) {
                    $output = '||0||' . $tag . ' updated to ' . $value . '||';
                } else {
                    $output = '||1||Failed to update ' . $tag . '||';
                }
                echo $output;
                wppa_exit();
            } elseif (substr($option, 0, 5) == 'caps-') {
                // Is capability setting
                global $wp_roles;
                //$R = new WP_Roles;
                $setting = explode('-', $option);
                if ($value == 'yes') {
                    $wp_roles->add_cap($setting[2], $setting[1]);
                    echo '||0||' . __('Capability granted', 'wp-photo-album-plus') . '||';
                    wppa_exit();
                } elseif ($value == 'no') {
                    $wp_roles->remove_cap($setting[2], $setting[1]);
                    echo '||0||' . __('Capability withdrawn', 'wp-photo-album-plus') . '||';
                    wppa_exit();
                } else {
                    echo '||1||Invalid value: ' . $value . '||';
                    wppa_exit();
                }
            } else {
                switch ($option) {
                    case 'wppa_colwidth':
                        //	 ??	  fixed   low	high	title
                        wppa_ajax_check_range($value, 'auto', '100', false, __('Column width.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_initial_colwidth':
                        wppa_ajax_check_range($value, false, '100', false, __('Initial width.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_fullsize':
                        wppa_ajax_check_range($value, false, '100', false, __('Full size.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_maxheight':
                        wppa_ajax_check_range($value, false, '100', false, __('Max height.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_thumbsize':
                        wppa_ajax_check_range($value, false, '50', false, __('Thumbnail size.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_tf_width':
                        wppa_ajax_check_range($value, false, '50', false, __('Thumbnail frame width', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_tf_height':
                        wppa_ajax_check_range($value, false, '50', false, __('Thumbnail frame height', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_tn_margin':
                        wppa_ajax_check_range($value, false, '0', false, __('Thumbnail Spacing', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_min_thumbs':
                        wppa_ajax_check_range($value, false, '0', false, __('Photocount treshold.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_thumb_page_size':
                        wppa_ajax_check_range($value, false, '0', false, __('Thumb page size.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_smallsize':
                        wppa_ajax_check_range($value, false, '50', false, __('Cover photo size.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_album_page_size':
                        wppa_ajax_check_range($value, false, '0', false, __('Album page size.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_topten_count':
                        wppa_ajax_check_range($value, false, '2', false, __('Number of TopTen photos', 'wp-photo-album-plus'), '40');
                        break;
                    case 'wppa_topten_size':
                        wppa_ajax_check_range($value, false, '32', false, __('Widget image thumbnail size', 'wp-photo-album-plus'), wppa_get_minisize());
                        break;
                    case 'wppa_max_cover_width':
                        wppa_ajax_check_range($value, false, '150', false, __('Max Cover width', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_text_frame_height':
                        wppa_ajax_check_range($value, false, '0', false, __('Minimal description height', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_cover_minheight':
                        wppa_ajax_check_range($value, false, '0', false, __('Minimal cover height', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_head_and_text_frame_height':
                        wppa_ajax_check_range($value, false, '0', false, __('Minimal text frame height', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_bwidth':
                        wppa_ajax_check_range($value, '', '0', false, __('Border width', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_bradius':
                        wppa_ajax_check_range($value, '', '0', false, __('Border radius', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_box_spacing':
                        wppa_ajax_check_range($value, '', '-20', '100', __('Box spacing', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_popupsize':
                        $floor = wppa_opt('thumbsize');
                        $temp = wppa_opt('smallsize');
                        if ($temp > $floor) {
                            $floor = $temp;
                        }
                        wppa_ajax_check_range($value, false, $floor, wppa_opt('fullsize'), __('Popup size', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_fullimage_border_width':
                        wppa_ajax_check_range($value, '', '0', false, __('Fullsize border width', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_lightbox_bordersize':
                        wppa_ajax_check_range($value, false, '0', false, __('Lightbox Bordersize', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_ovl_border_width':
                        wppa_ajax_check_range($value, false, '0', '16', __('Lightbox Borderwidth', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_ovl_border_radius':
                        wppa_ajax_check_range($value, false, '0', '16', __('Lightbox Borderradius', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_comment_count':
                        wppa_ajax_check_range($value, false, '2', '40', __('Number of Comment widget entries', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_comment_size':
                        wppa_ajax_check_range($value, false, '32', wppa_get_minisize(), __('Comment Widget image thumbnail size', 'wp-photo-album-plus'), wppa_get_minisize());
                        break;
                    case 'wppa_thumb_opacity':
                        wppa_ajax_check_range($value, false, '0', '100', __('Opacity.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_cover_opacity':
                        wppa_ajax_check_range($value, false, '0', '100', __('Opacity.', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_star_opacity':
                        wppa_ajax_check_range($value, false, '0', '50', __('Opacity.', 'wp-photo-album-plus'));
                        break;
                        //				case 'wppa_filter_priority':
                        //					wppa_ajax_check_range( $value, false, wppa_opt( 'shortcode_priority' ), false, __( 'Filter priority' ,'wp-photo-album-plus' ) );
                        //					break;
                        //				case 'wppa_shortcode_priority':
                        //					wppa_ajax_check_range( $value, false, '0', wppa_opt( 'filter_priority' ) - '1', __( 'Shortcode_priority', 'wp-photo-album-plus' ) );
                        //					break;
                    //				case 'wppa_filter_priority':
                    //					wppa_ajax_check_range( $value, false, wppa_opt( 'shortcode_priority' ), false, __( 'Filter priority' ,'wp-photo-album-plus' ) );
                    //					break;
                    //				case 'wppa_shortcode_priority':
                    //					wppa_ajax_check_range( $value, false, '0', wppa_opt( 'filter_priority' ) - '1', __( 'Shortcode_priority', 'wp-photo-album-plus' ) );
                    //					break;
                    case 'wppa_gravatar_size':
                        wppa_ajax_check_range($value, false, '10', '256', __('Avatar size', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_watermark_opacity':
                        wppa_ajax_check_range($value, false, '0', '100', __('Watermark opacity', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_watermark_opacity_text':
                        wppa_ajax_check_range($value, false, '0', '100', __('Watermark opacity', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_ovl_txt_lines':
                        wppa_ajax_check_range($value, 'auto', '0', '24', __('Number of text lines', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_ovl_opacity':
                        wppa_ajax_check_range($value, false, '0', '100', __('Overlay opacity', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_upload_limit_count':
                        wppa_ajax_check_range($value, false, '0', false, __('Upload limit', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_dislike_mail_every':
                        wppa_ajax_check_range($value, false, '0', false, __('Notify inappropriate', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_dislike_set_pending':
                        wppa_ajax_check_range($value, false, '0', false, __('Dislike pending', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_dislike_delete':
                        wppa_ajax_check_range($value, false, '0', false, __('Dislike delete', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_max_execution_time':
                        wppa_ajax_check_range($value, false, '0', '900', __('Max execution time', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_cp_points_comment':
                    case 'wppa_cp_points_rating':
                    case 'wppa_cp_points_upload':
                        wppa_ajax_check_range($value, false, '0', false, __('Cube Points points', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_jpeg_quality':
                        wppa_ajax_check_range($value, false, '20', '100', __('JPG Image quality', 'wp-photo-album-plus'));
                        if (wppa_cdn('admin') == 'cloudinary' && !wppa('out')) {
                            wppa_delete_derived_from_cloudinary();
                        }
                        break;
                    case 'wppa_imgfact_count':
                        wppa_ajax_check_range($value, false, '1', '24', __('Number of coverphotos', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_dislike_value':
                        wppa_ajax_check_range($value, false, '-10', '0', __('Dislike value', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_slideshow_pagesize':
                        wppa_ajax_check_range($value, false, '0', false, __('Slideshow pagesize', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_pagelinks_max':
                        wppa_ajax_check_range($value, false, '0', false, __('Max Pagelinks', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_start_pause_symbol_size':
                        wppa_ajax_check_range($value, false, '0', false, __('Start/pause symbol size', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_start_pause_symbol_bradius':
                        wppa_ajax_check_range($value, false, '0', false, __('Start/pause symbol border radius', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_stop_symbol_size':
                        wppa_ajax_check_range($value, false, '0', false, __('Stop symbol size', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_stop_symbol_bradius':
                        wppa_ajax_check_range($value, false, '0', false, __('Stop symbol border radius', 'wp-photo-album-plus'));
                        break;
                    case 'wppa_rating_clear':
                        $iret1 = $wpdb->query('TRUNCATE TABLE ' . WPPA_RATING);
                        $iret2 = $wpdb->query('UPDATE ' . WPPA_PHOTOS . ' SET mean_rating="0", rating_count="0" WHERE id > -1');
                        if ($iret1 !== false && $iret2 !== false) {
                            delete_option('wppa_' . WPPA_RATING . '_lastkey');
                            $title = __('Ratings cleared', 'wp-photo-album-plus');
                        } else {
                            $title = __('Could not clear ratings', 'wp-photo-album-plus');
                            $alert = $title;
                            wppa('error', '1');
                        }
                        break;
                    case 'wppa_viewcount_clear':
                        $iret = $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `views` = '0'") && $wpdb->query("UPDATE `" . WPPA_ALBUMS . "` SET `views` = '0'");
                        if ($iret !== false) {
                            $title = __('Viewcounts cleared', 'wp-photo-album-plus');
                        } else {
                            $title = __('Could not clear viewcounts', 'wp-photo-album-plus');
                            $alert = $title;
                            wppa('error', '1');
                        }
                        break;
                    case 'wppa_iptc_clear':
                        $iret = $wpdb->query('TRUNCATE TABLE ' . WPPA_IPTC);
                        if ($iret !== false) {
                            delete_option('wppa_' . WPPA_IPTC . '_lastkey');
                            $title = __('IPTC data cleared', 'wp-photo-album-plus');
                            $alert = __('Refresh this page to clear table X', 'wp-photo-album-plus');
                            update_option('wppa_index_need_remake', 'yes');
                        } else {
                            $title = __('Could not clear IPTC data', 'wp-photo-album-plus');
                            $alert = $title;
                            wppa('error', '1');
                        }
                        break;
                    case 'wppa_exif_clear':
                        $iret = $wpdb->query('TRUNCATE TABLE ' . WPPA_EXIF);
                        if ($iret !== false) {
                            delete_option('wppa_' . WPPA_EXIF . '_lastkey');
                            $title = __('EXIF data cleared', 'wp-photo-album-plus');
                            $alert = __('Refresh this page to clear table XI', 'wp-photo-album-plus');
                            update_option('wppa_index_need_remake', 'yes');
                        } else {
                            $title = __('Could not clear EXIF data', 'wp-photo-album-plus');
                            $alert = $title;
                            wppa('error', '1');
                        }
                        break;
                    case 'wppa_recup':
                        $result = wppa_recuperate_iptc_exif();
                        echo '||0||' . __('Recuperation performed', 'wp-photo-album-plus') . '||' . $result;
                        wppa_exit();
                        break;
                    case 'wppa_bgcolor_thumbnail':
                        $value = trim(strtolower($value));
                        if (strlen($value) != '7' || substr($value, 0, 1) != '#') {
                            wppa('error', '1');
                        } else {
                            for ($i = 1; $i < 7; $i++) {
                                if (!in_array(substr($value, $i, 1), array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'))) {
                                    wppa('error', '1');
                                }
                            }
                        }
                        if (!wppa('error')) {
                            $old_minisize--;
                        } else {
                            $alert = __('Illegal format. Please enter a 6 digit hexadecimal color value. Example: #77bbff', 'wp-photo-album-plus');
                        }
                        break;
                    case 'wppa_thumb_aspect':
                        $old_minisize--;
                        // Trigger regen message
                        break;
                    case 'wppa_rating_max':
                        if ($value == '5' && wppa_opt('rating_max') == '10') {
                            $rats = $wpdb->get_results('SELECT `id`, `value` FROM `' . WPPA_RATING . '`', ARRAY_A);
                            if ($rats) {
                                foreach ($rats as $rat) {
                                    $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_RATING . '` SET `value` = %s WHERE `id` = %s', $rat['value'] / 2, $rat['id']));
                                }
                            }
                        }
                        if ($value == '10' && wppa_opt('rating_max') == '5') {
                            $rats = $wpdb->get_results('SELECT `id`, `value` FROM `' . WPPA_RATING . '`', ARRAY_A);
                            if ($rats) {
                                foreach ($rats as $rat) {
                                    $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_RATING . '` SET `value` = %s WHERE `id` = %s', $rat['value'] * 2, $rat['id']));
                                }
                            }
                        }
                        update_option('wppa_rerate_status', 'Required');
                        $alert .= __('You just changed a setting that requires the recalculation of ratings.', 'wp-photo-album-plus');
                        $alert .= ' ' . __('Please run the appropriate action in Table VIII.', 'wp-photo-album-plus');
                        wppa_update_option($option, $value);
                        wppa('error', '0');
                        break;
                    case 'wppa_newphoto_description':
                        if (wppa_switch('check_balance') && balanceTags($value, true) != $value) {
                            $alert = __('Unbalanced tags in photo description!', 'wp-photo-album-plus');
                            wppa('error', '1');
                        } else {
                            wppa_update_option($option, $value);
                            wppa('error', '0');
                            $alert = '';
                            wppa_index_compute_skips();
                        }
                        break;
                    case 'wppa_keep_source':
                        $dir = wppa_opt('source_dir');
                        if (!is_dir($dir)) {
                            @mkdir($dir);
                        }
                        if (!is_dir($dir) || !is_writable($dir)) {
                            wppa('error', '1');
                            $alert = sprintf(__('Unable to create or write to %s', 'wp-photo-album-plus'), $dir);
                        }
                        break;
                    case 'wppa_source_dir':
                        $olddir = wppa_opt('source_dir');
                        $value = rtrim($value, '/');
                        if (strpos($value . '/', WPPA_UPLOAD_PATH . '/') !== false) {
                            wppa('error', '1');
                            $alert = sprintf(__('Source can not be inside the wppa folder.', 'wp-photo-album-plus'));
                        } else {
                            $dir = $value;
                            if (!is_dir($dir)) {
                                @mkdir($dir);
                            }
                            if (!is_dir($dir) || !is_writable($dir)) {
                                wppa('error', '1');
                                $alert = sprintf(__('Unable to create or write to %s', 'wp-photo-album-plus'), $dir);
                            } else {
                                @rmdir($olddir);
                                // try to remove when empty
                            }
                        }
                        break;
                    case 'wppa_newpag_content':
                        if (strpos($value, 'w#album') === false) {
                            $alert = __('The content must contain w#album', 'wp-photo-album-plus');
                            wppa('error', '1');
                        }
                        break;
                    case 'wppa_gpx_shortcode':
                        if (strpos($value, 'w#lat') === false || strpos($value, 'w#lon') === false) {
                            $alert = __('The content must contain w#lat and w#lon', 'wp-photo-album-plus');
                            wppa('error', '1');
                        }
                        break;
                    case 'wppa_i_responsive':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_colwidth', 'auto');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_colwidth', '640');
                        }
                        break;
                    case 'wppa_i_downsize':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_resize_on_upload', 'yes');
                            if (wppa_opt('resize_to') == '0') {
                                wppa_update_option('wppa_resize_to', '1024x768');
                            }
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_resize_on_upload', 'no');
                        }
                        break;
                    case 'wppa_i_source':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_keep_source_admin', 'yes');
                            wppa_update_option('wppa_keep_source_frontend', 'yes');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_keep_source_admin', 'no');
                            wppa_update_option('wppa_keep_source_frontend', 'no');
                        }
                        break;
                    case 'wppa_i_userupload':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_user_upload_on', 'yes');
                            wppa_update_option('wppa_user_upload_login', 'yes');
                            wppa_update_option('wppa_owner_only', 'yes');
                            wppa_update_option('wppa_upload_moderate', 'yes');
                            wppa_update_option('wppa_upload_edit', 'yes');
                            wppa_update_option('wppa_upload_notify', 'yes');
                            wppa_update_option('wppa_grant_an_album', 'yes');
                            $grantparent = wppa_opt('grant_parent');
                            if (!wppa_album_exists($grantparent)) {
                                $id = wppa_create_album_entry(array('name' => __('Members', 'wp-photo-album-plus'), 'description' => __('Parent of the member albums', 'wp-photo-album-plus'), 'a_parent' => '-1', 'upload_limit' => '0/0'));
                                if ($id) {
                                    wppa_index_add('album', $id);
                                    wppa_update_option('wppa_grant_parent', $id);
                                }
                                $my_post = array('post_title' => __('Members', 'wp-photo-album-plus'), 'post_content' => '[wppa type="content" album="' . $id . '"][/wppa]', 'post_status' => 'publish', 'post_type' => 'page');
                                $pagid = wp_insert_post($my_post);
                            }
                            wppa_update_option('wppa_alt_is_restricted', 'yes');
                            wppa_update_option('wppa_link_is_restricted', 'yes');
                            wppa_update_option('wppa_covertype_is_restricted', 'yes');
                            wppa_update_option('wppa_porder_restricted', 'yes');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_user_upload_on', 'no');
                        }
                        break;
                    case 'wppa_i_rating':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_rating_on', 'yes');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_rating_on', 'no');
                        }
                        break;
                    case 'wppa_i_comment':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_show_comments', 'yes');
                            wppa_update_option('wppa_comment_moderation', 'all');
                            wppa_update_option('wppa_comment_notify', 'admin');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_show_comments', 'no');
                        }
                        break;
                    case 'wppa_i_share':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_share_on', 'yes');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_share_on', 'no');
                        }
                        break;
                    case 'wppa_i_iptc':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_show_iptc', 'yes');
                            wppa_update_option('wppa_save_iptc', 'yes');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_show_iptc', 'no');
                            wppa_update_option('wppa_save_iptc', 'no');
                        }
                        break;
                    case 'wppa_i_exif':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_show_exif', 'yes');
                            wppa_update_option('wppa_save_exif', 'yes');
                        }
                        if ($value == 'no') {
                            wppa_update_option('wppa_show_exif', 'no');
                            wppa_update_option('wppa_save_exif', 'no');
                        }
                        break;
                    case 'wppa_i_gpx':
                        if ($value == 'yes') {
                            $custom_content = wppa_opt('custom_content');
                            if (strpos($custom_content, 'w#location') === false) {
                                $custom_content = $custom_content . ' w#location';
                                wppa_update_option('wppa_custom_content', $custom_content);
                            }
                            if (!wppa_switch('custom_on')) {
                                wppa_update_option('wppa_custom_on', 'yes');
                            }
                            if (wppa_opt('gpx_implementation') == 'none') {
                                wppa_update_option('wppa_gpx_implementation', 'wppa-plus-embedded');
                            }
                        }
                        break;
                    case 'wppa_i_fotomoto':
                        if ($value == 'yes') {
                            $custom_content = wppa_opt('custom_content');
                            if (strpos($custom_content, 'w#fotomoto') === false) {
                                $custom_content = 'w#fotomoto ' . $custom_content;
                                wppa_update_option('wppa_custom_content', $custom_content);
                            }
                            if (!wppa_switch('custom_on')) {
                                wppa_update_option('wppa_custom_on', 'yes');
                            }
                            wppa_update_option('wppa_fotomoto_on', 'yes');
                            wppa_update_option('wppa_custom_on', 'yes');
                        }
                        break;
                    case 'wppa_i_video':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_enable_video', 'yes');
                        } else {
                            wppa_update_option('wppa_enable_video', 'no');
                        }
                        break;
                    case 'wppa_i_audio':
                        if ($value == 'yes') {
                            wppa_update_option('wppa_enable_audio', 'yes');
                        } else {
                            wppa_update_option('wppa_enable_audio', 'no');
                        }
                        break;
                    case 'wppa_i_done':
                        $value = 'done';
                        break;
                    case 'wppa_search_tags':
                    case 'wppa_search_cats':
                    case 'wppa_search_comments':
                        update_option('wppa_index_need_remake', 'yes');
                        break;
                    case 'wppa_blacklist_user':
                        // Does user exist?
                        $value = trim($value);
                        $user = get_user_by('login', $value);
                        // seems to be case insensitive
                        if ($user && $user->user_login === $value) {
                            $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `status` = 'pending' WHERE `owner` = %s", $value));
                            $black_listed_users = get_option('wppa_black_listed_users', array());
                            if (!in_array($value, $black_listed_users)) {
                                $black_listed_users[] = $value;
                                update_option('wppa_black_listed_users', $black_listed_users);
                            }
                            $alert = esc_js(sprintf(__('User %s has been blacklisted.', 'wp-photo-album-plus'), $value));
                        } else {
                            $alert = esc_js(sprintf(__('User %s does not exist.', 'wp-photo-album-plus'), $value));
                        }
                        $value = '';
                        break;
                    case 'wppa_un_blacklist_user':
                        $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `status` = 'publish' WHERE `owner` = %s", $value));
                        $black_listed_users = get_option('wppa_black_listed_users', array());
                        if (in_array($value, $black_listed_users)) {
                            foreach (array_keys($black_listed_users) as $usr) {
                                if ($black_listed_users[$usr] == $value) {
                                    unset($black_listed_users[$usr]);
                                }
                            }
                            update_option('wppa_black_listed_users', $black_listed_users);
                        }
                        $value = '0';
                        break;
                    case 'wppa_fotomoto_on':
                        if ($value == 'yes') {
                            $custom_content = wppa_opt('custom_content');
                            if (strpos($custom_content, 'w#fotomoto') === false) {
                                $custom_content = 'w#fotomoto ' . $custom_content;
                                wppa_update_option('wppa_custom_content', $custom_content);
                                $alert = __('The content of the Custom box has been changed to display the Fotomoto toolbar.', 'wp-photo-album-plus') . ' ';
                            }
                            if (!wppa_switch('custom_on')) {
                                wppa_update_option('wppa_custom_on', 'yes');
                                $alert .= __('The display of the custom box has been enabled', 'wp-photo-album-plus');
                            }
                        }
                        break;
                    case 'wppa_gpx_implementation':
                        if ($value != 'none') {
                            $custom_content = wppa_opt('custom_content');
                            if (strpos($custom_content, 'w#location') === false) {
                                $custom_content = $custom_content . ' w#location';
                                wppa_update_option('wppa_custom_content', $custom_content);
                                $alert = __('The content of the Custom box has been changed to display maps.', 'wp-photo-album-plus') . ' ';
                            }
                            if (!wppa_switch('custom_on')) {
                                wppa_update_option('wppa_custom_on', 'yes');
                                $alert .= __('The display of the custom box has been enabled', 'wp-photo-album-plus');
                            }
                        }
                        break;
                    case 'wppa_regen_thumbs_skip_one':
                        $last = get_option('wppa_regen_thumbs_last', '0');
                        $skip = $last + '1';
                        update_option('wppa_regen_thumbs_last', $skip);
                        break;
                    case 'wppa_remake_skip_one':
                        $last = get_option('wppa_remake_last', '0');
                        $skip = $last + '1';
                        update_option('wppa_remake_last', $skip);
                        break;
                    case 'wppa_errorlog_purge':
                        @unlink(WPPA_CONTENT_PATH . '/wppa-depot/admin/error.log');
                        break;
                    case 'wppa_pl_dirname':
                        $value = wppa_sanitize_file_name($value);
                        $value = trim($value, ' /');
                        if (!$value) {
                            wppa('error', '714');
                            wppa_out(__('This value can not be empty', 'wp-photo-album-plus'));
                        } else {
                            wppa_create_pl_htaccess($value);
                        }
                        break;
                    case 'wppa_new_tag_value':
                        $value = wppa_sanitize_tags($value, false, true);
                        break;
                    case 'wppa_up_tagselbox_content_1':
                    case 'wppa_up_tagselbox_content_2':
                    case 'wppa_up_tagselbox_content_3':
                        $value = wppa_sanitize_tags($value);
                        break;
                    case 'wppa_wppa_set_shortcodes':
                        $value = str_replace(' ', '', $value);
                        break;
                    case 'wppa_enable_video':
                        // if off: set all statusses of videos to pending
                        break;
                    default:
                        wppa('error', '0');
                        $alert = '';
                }
            }
            if (wppa('error')) {
                if (!$title) {
                    $title = sprintf(__('Failed to set %s to %s', 'wp-photo-album-plus'), $option, $value);
                }
                if (!$alert) {
                    $alert .= wppa('out');
                }
            } else {
                wppa_update_option($option, $value);
                if (!$title) {
                    $title = sprintf(__('Setting %s updated to %s', 'wp-photo-album-plus'), $option, $value);
                }
            }
            // Save possible error
            $error = wppa('error');
            // Something to do after changing the setting?
            wppa_initialize_runtime(true);
            // force reload new values
            // .htaccess
            wppa_create_wppa_htaccess();
            // Thumbsize
            $new_minisize = wppa_get_minisize();
            if ($old_minisize != $new_minisize) {
                update_option('wppa_regen_thumbs_status', 'Required');
                $alert .= __('You just changed a setting that requires the regeneration of thumbnails.', 'wp-photo-album-plus');
                $alert .= ' ' . __('Please run the appropriate action in Table VIII.', 'wp-photo-album-plus');
            }
            // Produce the response text
            $output = '||' . $error . '||' . esc_attr($title) . '||' . esc_js($alert);
            echo $output;
            wppa_clear_cache();
            wppa_exit();
            break;
            // End update-option
        // End update-option
        case 'maintenance':
            $slug = $_POST['slug'];
            $nonce = $_REQUEST['wppa-nonce'];
            if (!wp_verify_nonce($nonce, 'wppa-nonce')) {
                echo 'Security check failure||' . $slug . '||Error||0';
                wppa_exit();
            }
            echo wppa_do_maintenance_proc($slug);
            wppa_exit();
            break;
        case 'maintenancepopup':
            $slug = $_POST['slug'];
            $nonce = $_REQUEST['wppa-nonce'];
            if (!wp_verify_nonce($nonce, 'wppa-nonce')) {
                echo 'Security check failure||' . $slug . '||Error||0';
                wppa_exit();
            }
            echo wppa_do_maintenance_popup($slug);
            wppa_exit();
            break;
        case 'do-fe-upload':
            if (is_admin()) {
                require_once 'wppa-non-admin.php';
            }
            wppa_user_upload();
            echo wppa('out');
            wppa_exit();
            break;
        case 'sanitizetags':
            $tags = isset($_GET['tags']) ? $_GET['tags'] : '';
            $album = isset($_GET['album']) ? $_GET['album'] : '0';
            $deftags = $album ? wppa_get_album_item($album, 'default_tags') : '';
            $tags = $deftags ? $tags . ',' . $deftags : $tags;
            echo wppa_sanitize_tags($tags, false, true);
            wppa_exit();
            break;
        case 'destroyalbum':
            $album = isset($_GET['album']) ? $_GET['album'] : '0';
            if (!$album) {
                _e('Missing album id', 'wp-photo-album-plus');
                wppa_exit();
            }
            $nonce = isset($_GET['nonce']) ? $_GET['nonce'] : '';
            if (!$nonce || !wp_verify_nonce($nonce, 'wppa_nonce_' . $album)) {
                echo 'Security check failure #798';
                wppa_exit();
            }
            // May I?
            $imay = true;
            if (!wppa_switch('user_destroy_on')) {
                $may = false;
            }
            if (wppa_switch('user_create_login')) {
                if (!is_user_logged_in()) {
                    $may = false;
                }
                // Must login
            }
            if (!wppa_have_access($album)) {
                $may = false;
                // No album access
            }
            if (wppa_is_user_blacklisted()) {
                $may = false;
            }
            if (!$imay) {
                _e('You do not have the rights to delete this album', 'wp-photo-album-plus');
                wppa_exit();
            }
            // I may
            require_once 'wppa-album-admin-autosave.php';
            wppa_del_album($album, '');
            wppa_exit();
            break;
        default:
            // Unimplemented $wppa-action
            die('-1');
    }
    wppa_exit();
}
コード例 #19
0
function wppa_backend_upload_mail($id, $alb, $name)
{
    $owner = wppa_get_user();
    if ($owner == 'admin') {
        return;
    }
    // Admin does not send mails to himself
    if (wppa_switch('upload_backend_notify')) {
        $to = get_bloginfo('admin_email');
        $subj = sprintf(__('New photo uploaded: %s', 'wp-photo-album-plus'), wppa_sanitize_file_name($name));
        $cont['0'] = sprintf(__('User %1$s uploaded photo %2$s into album %3$s', 'wp-photo-album-plus'), $owner, $id, wppa_get_album_name($alb));
        if (wppa_switch('upload_moderate') && !current_user_can('wppa_admin')) {
            $cont['1'] = __('This upload requires moderation', 'wp-photo-album-plus');
            $cont['2'] = '<a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Moderate manage photo', 'wp-photo-album-plus') . '</a>';
        } else {
            $cont['1'] = __('Details:', 'wp-photo-album-plus');
            $cont['1'] .= ' <a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Manage photo', 'wp-photo-album-plus') . '</a>';
        }
        wppa_send_mail($to, $subj, $cont, $id);
    }
}
コード例 #20
0
ファイル: wppa-boxes-html.php プロジェクト: lchen01/STEdwards
function wppa_album_name($key)
{
    // Virtual albums have no name
    if (wppa_is_virtual()) {
        return;
    }
    // Album enumerations have no name
    if (strlen(wppa('start_album')) > '0' && !wppa_is_int(wppa('start_album'))) {
        return;
    }
    $result = '';
    if (wppa_opt('albname_on_thumbarea') == $key && wppa('start_album')) {
        $name = wppa_get_album_name(wppa('start_album'));
        if ($key == 'top') {
            $result .= '<h3' . ' id="wppa-albname-' . wppa('mocc') . '"' . ' class="wppa-box-text wppa-black"' . ' style="padding-right:6px; margin:0; ' . __wcs('wppa-box-text') . __wcs('wppa-black') . '"' . ' >' . $name . '</h3>' . '<div style="clear:both" ></div>';
        }
        if ($key == 'bottom') {
            $result .= '<h3' . ' id="wppa-albname-b-' . wppa('mocc') . '"' . ' class="wppa-box-text wppa-black"' . ' style="clear:both; padding-right:6px; margin:0; ' . __wcs('wppa-box-text') . __wcs('wppa-black') . '"' . ' >' . $name . '</h3>';
        }
    }
    wppa_out($result);
}
コード例 #21
0
function wppa_make_tinymce_dialog()
{
    global $wpdb;
    $result = '<div id="wppagallery-form">' . '<div style="height:158px; background-color:#eee; overflow:auto; margin-top:10px;" >' . '<div id="wppagallery-album-preview" style="text-align:center;font-size:48px; line-height:21px; color:#fff;" class="wppagallery-album" ><br /><br /><br />' . __('Album Preview', 'wp-photo-album-plus') . '<br /><span style="font-size:12px; color:#777" ><br/>' . __('A maximum of 100 photos can be previewd', 'wp-photo-album-plus') . '</span></div>' . '<div id="wppagallery-photo-preview" style="text-align:center;font-size:48px; line-height:21px; color:#fff; display:none;" class="wppagallery-photo" ><br /><br /><br />' . __('Photo Preview', 'wp-photo-album-plus') . '</div>' . '</div>' . '<table id="wppagallery-table" class="form-table">' . '<tr>' . '<th><label for="wppagallery-type">' . __('Type of Gallery display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-type" name="type" onchange="wppaGalleryTypeChange(this.value)">' . '<option value="cover">' . __('The cover of an album', 'wp-photo-album-plus') . '</option>' . '<option value="album">' . __('The sub-albums and/or thumbnails in an album', 'wp-photo-album-plus') . '</option>' . '<option value="slide">' . __('A slideshow of the photos in an album', 'wp-photo-album-plus') . '</option>' . '<option value="slideonly">' . __('A slideshow without supporting boxes', 'wp-photo-album-plus') . '</option>' . '<option value="slideonlyf">' . __('A slideshow with a filmstrip only', 'wp-photo-album-plus') . '</option>' . '<option value="photo">' . __('A single photo', 'wp-photo-album-plus') . '</option>' . '<option value="mphoto">' . __('A single photo with caption', 'wp-photo-album-plus') . '</option>' . '<option value="slphoto">' . __('A single photo in the style of a slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="generic">' . __('A generic albums display', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the type of gallery', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-help" style="display:none;" >' . '<th><label for="wppagallery-album" class="wppagallery-help" >' . __('Explanation:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . __('Use this gallerytype to display all the top-level album covers.', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr class="wppagallery-album" >' . '<th><label for="wppagallery-album" class="wppagallery-album" >' . __('The Album to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album" name="album" style=width:270px;" class="wppagallery-album" onchange="wppaGalleryAlbumChange(this.value); wppaTinyMceAlbumPreview(this.value)">';
    $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC", ARRAY_A);
    if ($albums) {
        if (wppa_switch('wppa_hier_albsel')) {
            $albums = wppa_add_paths($albums);
        } else {
            foreach (array_keys($albums) as $index) {
                $albums[$index]['name'] = __(stripslashes($albums[$index]['name']), 'wp-photo-album-plus');
            }
        }
        // Sort
        $albums = wppa_array_sort($albums, 'name');
        $result .= '<option value="0" disabled="disabled" selected="selected" >' . __('Please select an album', 'wp-photo-album-plus') . '</option>';
        // All standard albums
        foreach ($albums as $album) {
            $value = $album['id'];
            $alb = $album['id'];
            $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($alb) . " LIMIT 100", $alb), ARRAY_A);
            if ($photos) {
                foreach ($photos as $photo) {
                    $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                    $value .= '|' . $photo_id . '.' . $photo['ext'];
                }
            } else {
                $value .= '|';
            }
            $note = ' (' . $album['id'] . ')';
            if (count($photos) <= wppa_opt('min_thumbs')) {
                $note .= ' *';
            }
            $result .= '<option value="' . $value . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . $note . '</option>';
        }
        // #last
        $value = '#last';
        $alb = $albums[0]['id'];
        $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($alb) . " LIMIT 100", $alb), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value="' . $value . '" >' . __('- The latest created album -', 'wp-photo-album-plus') . '</option>';
        // #topten
        $value = '#topten';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `mean_rating` DESC LIMIT " . wppa_opt('topten_count'), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- The top rated photos ---', 'wp-photo-album-plus') . '</option>';
        // #lasten
        $value = '#lasten';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT " . wppa_opt('lasten_count'), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- The most recently uploaded photos ---', 'wp-photo-album-plus') . '</option>';
        // #featen
        $value = '#featen';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND() DESC LIMIT " . wppa_opt('featen_count'), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- A random selection of featured photos ---', 'wp-photo-album-plus') . '</option>';
        // #comten
        $value = '#comten';
        $comments = $wpdb->get_results("SELECT `id`, `photo` FROM `" . WPPA_COMMENTS . "` ORDER BY `timestamp` DESC", ARRAY_A);
        $photos = false;
        $done = array();
        if ($comments) {
            foreach ($comments as $comment) {
                if (count($done) < wppa_opt('comten_count') && !in_array($comment['photo'], $done)) {
                    $done[] = $comment['photo'];
                    $photos[] = $wpdb->get_row("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `id` = " . $comment['photo'], ARRAY_A);
                }
            }
        }
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- The most recently commented photos ---', 'wp-photo-album-plus') . '</option>';
        // #tags
        $value = '#tags';
        $result .= '<option value = "' . $value . '" >' . __('--- Photos that have certain tags ---', 'wp-photo-album-plus') . '</option>';
        // #all
        $value = '#all';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` " . wppa_get_photo_order('0') . " LIMIT 100", ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- All photos in the system ---', 'wp-photo-album-plus') . '</option>';
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '<input type="text" id="wppagallery-alb" name="alb" value="" style="width:50px; display:none; background-color:#ddd;" class="wppagallery-extra" title="Enter albumnumber if not systemwide" />' . '<input type="text" id="wppagallery-cnt" name="cnt" value="" style="width:50px; display:none; background-color:#ddd;" class="wppagallery-extra" title="Enter count if not default" />' . '<br />' . '<small class="wppagallery-album" >' . __('Specify the album to be used or --- A special selection of photos ---', 'wp-photo-album-plus') . '<br />' . __('In an upload box, the album is optional. When no album is specified: a selection box will be displayed of the albums the user has the right to upload.', 'wp-photo-album-plus') . '<br />' . __('* Album contains less than the minimun number of photos', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-photo" style="display:none;" >' . '<th><label for="wppagallery-photo" style="display:none;" class="wppagallery-photo" >' . __('The Photo to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-photo" name="photo" style="display:none;" class="wppagallery-photo" onchange="wppaTinyMcePhotoPreview(this.value)" >';
    $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A);
    if ($photos) {
        $result .= '<option value="0" disabled="disabled" selected="selected" >' . __('Please select a photo', 'wp-photo-album-plus') . '</option>';
        foreach ($photos as $photo) {
            $name = stripslashes(__($photo['name'], 'wp-photo-album-plus'));
            if (strlen($name) > '50') {
                $name = substr($name, '0', '50') . '...';
            }
            if (get_option('wppa_file_system') == 'flat') {
                $result .= '<option value="' . $photo['id'] . '.' . $photo['ext'] . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            } else {
                $result .= '<option value="' . wppa_expand_id($photo['id']) . '.' . $photo['ext'] . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            }
        }
        $result .= '<option value="#last" >' . __('--- The most recently uploaded photo ---', 'wp-photo-album-plus') . '</option>' . '<option value="#potd" >' . __('--- The photo of the day ---', 'wp-photo-album-plus') . '</option>';
    } else {
        $result .= '<option value="0" >' . __('There are no photos yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '<br />' . '<small style="display:none;" class="wppagallery-photo" >' . __('Specify the photo to be used', 'wp-photo-album-plus') . '<br />' . __('You can select from a maximum of 100 most recently added photos', 'wp-photo-album-plus') . '<br />' . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-tags" style="display:none;" >' . '<th><label for="wppagallery-tags">' . __('The tags the photos should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-tags" multiple="multiple">' . '<option value="" >' . __('--- please select tag(s) ---', 'wp-photo-album-plus') . '</option>';
    $tags = wppa_get_taglist();
    if ($tags) {
        foreach (array_keys($tags) as $tag) {
            $result .= '<option value="' . $tag . '" >' . $tag . '</option>';
        }
    }
    $result .= '</select>' . '<div><input type="checkbox" id="wppagallery-andor" />&nbsp;<small>' . __('If you want that the photos have all the selected tags, check this box. Leave it unchecked if the photo must have atleast only one of the selected tags', 'wp-photo-album-plus') . '</small></div>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-size">' . __('The size of the display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input type="text" id="wppagallery-size" value="" />' . '<br />' . '<small>' . __('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus') . ' ' . __('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus') . '<br />' . __('Leave this blank for default size', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-align">' . __('Horizontal alignment:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-align" name="align" >' . '<option value="none" >' . __('--- none ---', 'wp-photo-album-plus') . '</option>' . '<option value="left" >' . __('left', 'wp-photo-album-plus') . '</option>' . '<option value="center" >' . __('center', 'wp-photo-album-plus') . '</option>' . '<option value="right" >' . __('right', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the alignment to be used or --- none ---', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '</table>' . '<p class="submit">' . '<input type="button" id="wppagallery-submit" class="button-primary" value="' . __('Insert Gallery', 'wp-photo-album-plus') . '" name="submit" />&nbsp;' . '</p>' . '</div>';
    return $result;
}
コード例 #22
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'topten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'showowner' => 'no', 'showalbum' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('topten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_topten_widget_linkpage', __('Top Ten Photos', 'wp-photo-album-plus'));
     $albumlinkpage = wppa_get_the_landing_page('wppa_topten_widget_album_linkpage', __('Top Ten Photo album', 'wp-photo-album-plus'));
     $max = wppa_opt('topten_count');
     $album = $instance['album'];
     switch ($instance['sortby']) {
         case 'mean_rating':
             $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
             break;
         case 'rating_count':
             $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
             break;
         case 'views':
             $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
             break;
     }
     $display = $instance['display'];
     $meanrat = $instance['meanrat'] == 'yes';
     $ratcount = $instance['ratcount'] == 'yes';
     $viewcount = $instance['viewcount'] == 'yes';
     $includesubs = $instance['includesubs'] == 'yes';
     $albenum = '';
     $showowner = $instance['showowner'] == 'yes';
     $showalbum = $instance['showalbum'] == 'yes';
     if ($album) {
         if ($album == '-2') {
             $album = '0';
         }
         if ($includesubs) {
             $albenum = wppa_alb_to_enum_children($album);
             $albenum = wppa_expand_enum($albenum);
             $album = str_replace('.', ',', $albenum);
         }
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` IN (" . $album . ") ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A);
         //wppa_log('dbg', "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` IN (".$album.") ORDER BY " . $sortby . " LIMIT " . $max);
     } else {
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A);
     }
     $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->';
     $maxw = wppa_opt('topten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($meanrat) {
         $maxh += $lineheight;
     }
     if ($ratcount) {
         $maxh += $lineheight;
     }
     if ($viewcount) {
         $maxh += $lineheight;
     }
     if ($showowner) {
         $maxh += $lineheight;
     }
     if ($showalbum) {
         $maxh += $lineheight;
     }
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the top rated photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $compressed_albumenum = wppa_compress_enum($albenum);
                 $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('topten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 // Display (owner) ?
                 if ($showowner) {
                     $widget_content .= '<div>(' . $image['owner'] . ')</div>';
                 }
                 // Display (album) ?
                 if ($showalbum) {
                     $href = wppa_convert_to_pretty(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1'));
                     $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>';
                 }
                 $rating = wppa_get_rating_by_id($image['id']);
                 switch ($instance['sortby']) {
                     case 'mean_rating':
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         break;
                     case 'rating_count':
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         break;
                     case 'views':
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         break;
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found.', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= 'There are no rated photos (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
コード例 #23
0
ファイル: wppa-links.php プロジェクト: lchen01/STEdwards
function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '')
{
    global $wpdb;
    // make sure the photo data ia available
    $thumb = wppa_cache_thumb($id);
    if (!$thumb) {
        return false;
    }
    // Is it a video?
    $is_video = wppa_is_video($id, true);
    // Photo Specific Overrule?
    if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) {
        // Look for a photo specific link
        if ($thumb) {
            // If it is there...
            if ($thumb['linkurl']) {
                // Use it. It superceeds other settings
                $result['url'] = esc_attr($thumb['linkurl']);
                $result['title'] = esc_attr(__(stripslashes($thumb['linktitle'])));
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                $result['onclick'] = '';
                $result['target'] = $thumb['linktarget'];
                return $result;
            }
        }
    }
    $result['target'] = '_self';
    $result['title'] = '';
    $result['onclick'] = '';
    switch ($wich) {
        case 'sphoto':
            $type = wppa_opt('sphoto_linktype');
            $page = wppa_opt('sphoto_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('sphoto_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'mphoto':
            $type = wppa_opt('mphoto_linktype');
            $page = wppa_opt('mphoto_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('mphoto_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'thumb':
            $type = wppa_opt('thumb_linktype');
            $page = wppa_opt('thumb_linkpage');
            if (wppa_switch('thumb_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'topten':
            $type = wppa_opt('topten_widget_linktype');
            $page = wppa_opt('topten_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('topten_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'featen':
            $type = wppa_opt('featen_widget_linktype');
            $page = wppa_opt('featen_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('featen_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'lasten':
            $type = wppa_opt('lasten_widget_linktype');
            $page = wppa_opt('lasten_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('lasten_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'comten':
            $type = wppa_opt('comment_widget_linktype');
            $page = wppa_opt('comment_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('comment_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'sswidget':
            $type = wppa_opt('slideonly_widget_linktype');
            $page = wppa_opt('slideonly_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('sswidget_blank')) {
                $result['target'] = '_blank';
            }
            $result['url'] = '';
            if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') {
                $result['title'] = wppa_zoom_in($id);
                $result['target'] = '';
                return $result;
            }
            break;
        case 'potdwidget':
            $type = wppa_opt('widget_linktype');
            $page = wppa_opt('widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('potd_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'coverimg':
            $type = wppa_opt('coverimg_linktype');
            $page = wppa_opt('coverimg_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('coverimg_blank')) {
                $result['target'] = '_blank';
            }
            if ($type == 'slideshowstartatimage') {
                $result['url'] = wppa_get_slideshow_url($album, $page, $id);
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                return $result;
            }
            break;
        case 'tnwidget':
            $type = wppa_opt('thumbnail_widget_linktype');
            $page = wppa_opt('thumbnail_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('thumbnail_widget_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'slideshow':
            $type = wppa_opt('slideshow_linktype');
            //'';
            $page = wppa_opt('slideshow_linkpage');
            $result['url'] = '';
            if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') {
                $result['title'] = wppa_zoom_in($id);
                $result['target'] = '';
                return $result;
            }
            if ($type == 'thumbs') {
                $result['url'] = wppa_get_ss_to_tn_link($page, $id);
                $result['title'] = __('View thumbnails', 'wp-photo-album-plus');
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                if (wppa_switch('slideshow_blank')) {
                    $result['target'] = '_blank';
                }
                return $result;
            }
            if ($type == 'none') {
                return;
            }
            // Continue for 'single'
            break;
        case 'albwidget':
            $type = wppa_opt('album_widget_linktype');
            $page = wppa_opt('album_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('album_widget_blank')) {
                $result['target'] = '_blank';
            }
            break;
        default:
            return false;
            break;
    }
    if (!$album) {
        $album = wppa('start_album');
    }
    if ($album == '' && !wppa('is_upldr')) {
        /**/
        $album = wppa_get_album_id_by_photo_id($id);
    }
    if (is_numeric($album)) {
        $album_name = wppa_get_album_name($album);
    } else {
        $album_name = '';
    }
    if (!$album) {
        $album = '0';
    }
    if ($wich == 'comten') {
        $album = '0';
    }
    if (wppa('is_tag')) {
        $album = '0';
    }
    if (wppa('supersearch')) {
        $album = '0';
    }
    if (wppa('calendar')) {
        $album = wppa('start_album') ? wppa('start_album') : '0';
    }
    //	if ( wppa( 'is_upldr' ) ) $album = '0';	// probeersel upldr parent
    if ($id) {
        $photo_name = wppa_get_photo_name($id);
    } else {
        $photo_name = '';
    }
    $photo_name_js = esc_js($photo_name);
    $photo_name = esc_attr($photo_name);
    if ($id) {
        $photo_desc = esc_attr(wppa_get_photo_desc($id));
    } else {
        $photo_desc = '';
    }
    $title = __($photo_name, 'wp-photo-album-plus');
    $result['onclick'] = '';
    // Init
    switch ($type) {
        case 'none':
            // No link at all
            return false;
            break;
        case 'file':
            // The plain file
            if ($is_video) {
                $siz = array(wppa_get_videox($id), wppa_get_videoy($id));
                $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                reset($is_video);
                $result['url'] = str_replace('xxx', current($is_video), $result['url']);
            } else {
                $siz = array(wppa_get_photox($id), wppa_get_photoy($id));
                $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
            }
            $result['title'] = $title;
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            return $result;
            break;
        case 'lightbox':
        case 'lightboxsingle':
            if ($is_video) {
                $siz = array(wppa_get_videox($id), wppa_get_videoy($id));
                $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] );
            } else {
                if (wppa_switch('lb_hres')) {
                    $result['url'] = wppa_get_hires_url($id);
                } else {
                    $siz = array(wppa_get_photox($id), wppa_get_photoy($id));
                    $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                }
            }
            $result['title'] = $title;
            $result['is_url'] = false;
            $result['is_lightbox'] = true;
            $result['url'] = wppa_fix_poster_ext($result['url'], $id);
            return $result;
        case 'widget':
            // Defined at widget activation
            $result['url'] = wppa('in_widget_linkurl');
            $result['title'] = esc_attr(wppa('in_widget_linktitle'));
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            return $result;
            break;
        case 'album':
            // The albums thumbnails
        // The albums thumbnails
        case 'content':
            // For album widget
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=0&amp;wppa-cover=0';
                        $result['title'] = '';
                        // $album_name;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                        $result['title'] = $album_name;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
                default:
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&amp;wppa-cover=0';
                        $result['title'] = '';
                        //$album_name;//'a++';
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                        $result['title'] = $album_name;
                        //'a++';
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
            }
            break;
        case 'thumbalbum':
            $album = $thumb['album'];
            $album_name = wppa_get_album_name($album);
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                    $result['title'] = $album_name;
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
                default:
                    $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                    $result['title'] = $album_name;
                    //'a++';
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
            }
            break;
        case 'photo':
            // This means: The fullsize photo in a slideshow
        // This means: The fullsize photo in a slideshow
        case 'slphoto':
            // This means: The single photo in the style of a slideshow
            if ($type == 'slphoto') {
                $si = '&amp;wppa-single=1';
            } else {
                $si = '';
            }
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=0&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
                default:
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
            }
            break;
        case 'single':
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id;
                    $result['title'] = $title;
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
                default:
                    $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id;
                    $result['title'] = $title;
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
            }
            break;
        case 'same':
            $result['url'] = $lnk;
            $result['title'] = $tit;
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            $result['onclick'] = $onc;
            return $result;
            break;
        case 'fullpopup':
            if ($is_video) {
                // A video can not be printed or downloaded
                $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )');
            } else {
                $wid = wppa_get_photox($id);
                $hig = wppa_get_photoy($id);
                /*
                $imgsize = getimagesize( wppa_get_photo_path( $id ) );
                if ( $imgsize ) {
                	$wid = $imgsize['0'];
                	$hig = $imgsize['1'];
                }
                else {
                	$wid = '0';
                	$hig = '0';
                }
                */
                $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id);
                $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )');
            }
            $result['title'] = $title;
            $result['is_url'] = false;
            $result['is_lightbox'] = false;
            return $result;
            break;
        case 'custom':
            if ($wich == 'potdwidget') {
                $result['url'] = wppa_opt('widget_linkurl');
                $result['title'] = wppa_opt('widget_linktitle');
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                return $result;
            }
            break;
        case 'slide':
            // for album widget
            $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&amp;slide';
            $result['title'] = '';
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            break;
        case 'autopage':
            if (!wppa_switch('auto_page')) {
                wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force');
                $result['url'] = '';
            } else {
                $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id));
            }
            $result['title'] = '';
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            break;
        case 'plainpage':
            $result['url'] = get_permalink($page);
            $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page));
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            return $result;
            break;
        default:
            wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red');
            return false;
            break;
    }
    if ($type != 'thumbalbum') {
        if (wppa('calendar')) {
            $result['url'] .= '&amp;wppa-calendar=' . wppa('calendar') . '&amp;wppa-caldate=' . wppa('caldate');
        }
        if (wppa('supersearch')) {
            $result['url'] .= '&amp;wppa-supersearch=' . urlencode(wppa('supersearch'));
        }
        if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) {
            $result['url'] .= '&amp;wppa-searchstring=' . urlencode(wppa('searchstring'));
        }
        if ($wich == 'topten') {
            $result['url'] .= '&amp;wppa-topten=' . wppa_opt('topten_count');
        } elseif (wppa('is_topten')) {
            $result['url'] .= '&amp;wppa-topten=' . wppa('topten_count');
        }
        if ($wich == 'lasten') {
            $result['url'] .= '&amp;wppa-lasten=' . wppa_opt('lasten_count');
        } elseif (wppa('is_lasten')) {
            $result['url'] .= '&amp;wppa-lasten=' . wppa('lasten_count');
        }
        if ($wich == 'comten') {
            $result['url'] .= '&amp;wppa-comten=' . wppa_opt('comten_count');
        } elseif (wppa('is_comten')) {
            $result['url'] .= '&amp;wppa-comten=' . wppa('comten_count');
        }
        if ($wich == 'featen') {
            $result['url'] .= '&amp;wppa-featen=' . wppa_opt('featen_count');
        } elseif (wppa('is_featen')) {
            $result['url'] .= '&amp;wppa-featen=' . wppa('featen_count');
        }
        if (wppa('is_related')) {
            $result['url'] .= '&amp;wppa-rel=' . wppa('is_related') . '&amp;wppa-relcount=' . wppa('related_count');
        } elseif (wppa('is_tag')) {
            $result['url'] .= '&amp;wppa-tag=' . wppa('is_tag');
        }
        if (wppa('is_upldr')) {
            $result['url'] .= '&amp;wppa-upldr=' . wppa('is_upldr');
        }
        if (wppa('is_inverse')) {
            $result['url'] .= '&amp;wppa-inv=1';
        }
    }
    if ($page != '0') {
        // on a different page
        $occur = '1';
        $w = '';
    } else {
        // on the same page, post or widget
        $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur');
        $w = wppa_in_widget() ? 'w' : '';
    }
    $result['url'] .= '&amp;wppa-' . $w . 'occur=' . $occur;
    $result['url'] = wppa_convert_to_pretty($result['url']);
    if ($result['title'] == '') {
        $result['title'] = $tit;
    }
    // If still nothing, try arg
    return $result;
}
コード例 #24
0
function wppa_grant_albums($xparent = false)
{
    global $wpdb;
    static $grant_parents;
    static $my_albs_parents;
    static $owner;
    static $user;
    // Feature enabled?
    if (!wppa_switch('grant_an_album')) {
        return false;
    }
    // Owners only?
    if (!wppa_switch('owner_only')) {
        return false;
    }
    // User logged in?
    if (!is_user_logged_in()) {
        return false;
    }
    // Can user upload?
    if (!current_user_can('wppa_upload') && !wppa_switch('user_upload_on')) {
        return false;
    }
    // Init
    $albums_created = array();
    // Get required data if not done already
    // First get the grant parent album(s)
    if (!is_array($grant_parents)) {
        switch (wppa_opt('grant_parent_sel_method')) {
            case 'selectionbox':
                // Album ids are and expanded enumeration sep by , in the setting
                $grant_parents = explode(',', wppa_opt('grant_parent'));
                if (!is_array($grant_parents)) {
                    $grant_parents = array('0');
                }
                break;
            case 'category':
                // The option hold a category
                $grant_parents = $wpdb->get_col("SELECT `id` " . "FROM `" . WPPA_ALBUMS . "` " . "WHERE `cats` LIKE '%," . wppa_opt('grant_parent') . ",%'");
                break;
            case 'indexsearch':
                $temp = $wpdb->get_var("SELECT `albums` " . "FROM `" . WPPA_INDEX . "` " . "WHERE `slug` = '" . wppa_opt('grant_parent') . "'");
                $grant_parents = explode('.', wppa_expand_enum($temp));
                break;
        }
    }
    if (!$owner) {
        $owner = wppa_get_user('login');
        // The current users login name
    }
    if (!is_array($my_albs_parents)) {
        $query = $wpdb->prepare("SELECT DISTINCT `a_parent` FROM `" . WPPA_ALBUMS . "` WHERE `owner` = %s", $owner);
        $my_albs_parents = $wpdb->get_col($query);
        if (!is_array($my_albs_parents)) {
            $my_albs_parents = array();
        }
    }
    if (!$user) {
        $user = wppa_get_user(wppa_opt('grant_name'));
        // The current users name as how the album should be named
    }
    // If a parent is given and it is not a grant parent, quit
    if ($xparent && !in_array($xparent, $grant_parents)) {
        return false;
    }
    // If a parent is given, it will now be a grant parent (see directly above), only create the granted album inside this parent.
    if ($xparent) {
        $parents = array($xparent);
    } else {
        $parents = $grant_parents;
    }
    // Parent independant album data
    $name = $user;
    $desc = __('Default photo album for', 'wp-photo-album-plus') . ' ' . $user;
    // May be multiple granted parents. Check for all parents.
    foreach ($parents as $parent) {
        // Create only grant album if: parent is either -1 or existing
        if ($parent == '-1' || wppa_album_exists($parent)) {
            if (!in_array($parent, $my_albs_parents, true)) {
                // make an album for this user
                $id = wppa_create_album_entry(array('name' => $name, 'description' => $desc, 'a_parent' => $parent));
                if ($id) {
                    wppa_log('Obs', 'Album ' . wppa_get_album_name($parent) . '(' . $parent . ')' . ' -> ' . $id . ' for ' . $user . ' created.');
                    $albums_created[] = $id;
                    // Add this parent to the array of my albums parents
                    $my_albs_parents[] = $parent;
                } else {
                    wppa_log('Err', 'Could not create subalbum of ' . $parent . ' for ' . $user);
                }
                wppa_flush_treecounts($parent);
                wppa_index_add('album', $id);
            }
        }
    }
    // Remake permalink redirects
    if (!empty($albums_created)) {
        wppa_create_pl_htaccess();
    }
    return $albums_created;
}
コード例 #25
0
function _wppa_comment_admin()
{
    global $wpdb;
    $continue = true;
    // Check input
    wppa_vfy_arg('tab', true);
    wppa_vfy_arg('edit_id');
    wppa_vfy_arg('wppa-page');
    wppa_vfy_arg('commentid');
    wppa_vfy_arg('delete_id');
    if (isset($_GET['tab'])) {
        if ($_GET['tab'] == 'edit') {
            $id = $_GET['edit_id'];
            $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_COMMENTS . " WHERE id = %s LIMIT 1", $id), ARRAY_A);
            if ($comment) {
                ?>
			<div class="wrap">
				<?php 
                $iconurl = WPPA_URL . '/img/comment.png';
                ?>
				<div id="icon-album" class="icon32" style="background: transparent url(<?php 
                echo $iconurl;
                ?>
) no-repeat">
					<br />
				</div>
				<h2><?php 
                _e('Photo Albums -> Edit Comment', 'wp-photo-album-plus');
                ?>
</h2>
				<?php 
                $action = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments');
                if (isset($_GET['wppa-page'])) {
                    $action .= '&compage=' . strval(intval($_GET['wppa-page']));
                }
                if (isset($_GET['commentid'])) {
                    $action .= '&commentid=' . strval(intval($_GET['commentid']));
                }
                ?>
				<form action="<?php 
                echo $action;
                ?>
" method="post">

					<?php 
                wp_nonce_field('$wppa_nonce', WPPA_NONCE);
                ?>
					<input type="hidden" name="edit_comment" value="<?php 
                echo $comment['id'];
                ?>
" />
					<table class="form-table albumtable">
						<tbody>
							<tr style="vertical-align:top" >
								<th>
									<?php 
                $photo = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_PHOTOS . " WHERE id =  %s", $comment['photo']), "ARRAY_A");
                ?>
									<?php 
                $url = wppa_fix_poster_ext(wppa_get_thumb_url($comment['photo']), $comment['photo']);
                ?>
									<img src="<?php 
                echo $url;
                ?>
" />
								</th>
								<td>
									<?php 
                echo __($photo['name']) . '<br/><br/>' . __(stripslashes($photo['description']));
                ?>
								</td>
							</tr>
							<tr>
								<th scope="row"><label ><?php 
                _e('Photo:', 'wp-photo-album-plus');
                ?>
</label></th>
								<td><?php 
                echo $comment['photo'];
                ?>
</td>
							</tr>
							<tr>
								<th scope="row"><label ><?php 
                _e('Album:', 'wp-photo-album-plus');
                ?>
</label></th>
								<td><?php 
                echo wppa_get_album_name($photo['album']);
                ?>
								</td>
							</tr>
							<tr>
								<th scope="row"><label ><?php 
                _e('User:'******'wp-photo-album-plus');
                ?>
</label></th>
								<td><input style="width:300px;" type="text" name="user" value="<?php 
                echo $comment['user'];
                ?>
" /></td>
							</tr>
							<tr>
								<th scope="row"><label ><?php 
                _e('Email:', 'wp-photo-album-plus');
                ?>
</label></th>
								<td><input style="width:300px;" type="text" name="email" value="<?php 
                echo $comment['email'];
                ?>
" /></td>
							</tr>
							<tr>
								<th scope="row"><label><?php 
                _e('Comment:', 'wp-photo-album-plus');
                ?>
</label></th>
								<td><textarea style="width:300px; height:150px;" name="comment"><?php 
                echo esc_textarea(stripslashes($comment['comment']));
                ?>
</textarea></td>
							</tr>
						</tbody>
					</table>
					<p>
						<input type="submit" class="button-primary" name="wppa_submit" value="<?php 
                _e('Save Changes', 'wp-photo-album-plus');
                ?>
" />
					</p>
				</form>
			<?php 
            }
            $continue = false;
        }
        if ($_GET['tab'] == 'delete') {
            $id = strval(intval($_GET['delete_id']));
            $photo = $wpdb->get_var($wpdb->prepare("SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s", $id));
            $iret = $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_COMMENTS . "` WHERE `id` = %s LIMIT 1", $id));
            if ($iret !== false) {
                if (wppa_switch('search_comments')) {
                    wppa_index_update('photo', $photo);
                }
                wppa_update_message(__('Comment deleted', 'wp-photo-album-plus'));
            } else {
                wppa_error_message('Error deleting comment');
            }
            $continue = true;
        }
    }
    if ($continue) {
        // Update anything or do bulkaction
        if (isset($_POST['wppa_submit'])) {
            // Security check
            check_admin_referer('$wppa_nonce', WPPA_NONCE);
            // Updates
            $iret = true;
            if (isset($_POST['wppa_comadmin_show'])) {
                wppa_update_option('wppa_comadmin_show', $_POST['wppa_comadmin_show']);
            }
            if (isset($_POST['wppa_comadmin_linkpage'])) {
                wppa_update_option('wppa_comadmin_linkpage', $_POST['wppa_comadmin_linkpage']);
            }
            if (isset($_POST['wppa_comadmin_order'])) {
                wppa_update_option('wppa_comadmin_order', $_POST['wppa_comadmin_order']);
            }
            if (isset($_POST['edit_comment'])) {
                $iret = wppa_edit_comment($_POST['edit_comment']);
            }
            // Bulk actions
            if (isset($_POST['bulkaction'])) {
                switch ($_POST['bulkaction']) {
                    case 'approveall':
                        $coms_to_proc = $wpdb->get_results("SELECT `id` FROM `" . WPPA_COMMENTS . "` WHERE status = 'pending'", ARRAY_A);
                        $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'approved' WHERE status = 'pending'";
                        if ($wpdb->query($query) === false) {
                            wppa_error_message(__('Could not bulk update status', 'wp-photo-album-plus'));
                            $iret = false;
                        } else {
                            if ($coms_to_proc) {
                                foreach ($coms_to_proc as $item) {
                                    wppa_send_comment_approved_email($item['id']);
                                }
                            }
                            $iret = true;
                        }
                        break;
                    case 'spamall':
                        $query = "UPDATE " . WPPA_COMMENTS . " SET status = 'spam' WHERE status = 'pending'";
                        if ($wpdb->query($query) === false) {
                            wppa_error_message(__('Could not bulk update status', 'wp-photo-album-plus'));
                            $iret = false;
                        } else {
                            $iret = true;
                        }
                        break;
                    case 'delspam':
                        $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status = 'spam'";
                        if ($wpdb->query($query) === false) {
                            wppa_error_message(__('Could not bulk delete spam', 'wp-photo-album-plus'));
                            $iret = false;
                        }
                        break;
                }
            }
            if ($iret) {
                wppa_update_message(__('Changes Saved', 'wp-photo-album-plus'));
            }
            // Clear (super)cache
            wppa_clear_cache();
        }
        // Submit
        // Delete trash
        $query = "DELETE FROM " . WPPA_COMMENTS . " WHERE status = 'trash'";
        $wpdb->query($query);
        // Initialize normal display
        $wppa_comadmin_linkpage = get_option('wppa_comadmin_linkpage', '0');
        if ($wppa_comadmin_linkpage) {
            $exists = $wpdb->get_var("SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `ID` = " . $wppa_comadmin_linkpage);
            if (!$exists) {
                $wppa_comadmin_linkpage = '0';
                update_option('wppa_comadmin_linkpage', '0');
            }
        }
        $moderating = isset($_REQUEST['commentid']);
        ?>
		<div class="wrap">
			<?php 
        $iconurl = WPPA_URL . '/img/comment.png';
        ?>
			<div id="icon-album" class="icon32" style="background: transparent url(<?php 
        echo $iconurl;
        ?>
) no-repeat">
				<br />
			</div>
			<h2>
				<?php 
        if ($moderating) {
            _e('Photo Albums -> Moderate Comment', 'wp-photo-album-plus');
        } else {
            _e('Photo Albums -> Comment admin', 'wp-photo-album-plus');
        }
        ?>
			</h2>

			<?php 
        if (!wppa_switch('show_comments')) {
            _e('<h3>The Comment system is not activated</h3><p>To activate: check Table II item 18 on the <b>Photo Albums -> Settings</b> screen and press <b>Save Changes</b>', 'wp-photo-album-plus');
        }
        ?>

			<?php 
        if (!$moderating) {
            ?>
			<!-- Statistics -->
			<table>
				<tbody>
					<tr>
						<td><h3 style="margin:0; color:#777777;"><?php 
            _e('Total:', 'wp-photo-album-plus');
            ?>
</h3></td>
						<td><h3 style="margin:0;"><?php 
            $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "`");
            echo $count;
            ?>
</h3></td>
					</tr>
					<tr>
						<td><h3 style="margin:0; color:green;"><?php 
            _e('Approved:', 'wp-photo-album-plus');
            ?>
</h3></td>
						<td><h3 style="margin:0;"><?php 
            $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'approved'");
            echo $count;
            ?>
</h3></td>
					</tr>
					<tr>
						<td><h3 style="margin:0; color:#e66f00;"><?php 
            _e('Pending:', 'wp-photo-album-plus');
            ?>
</h3></td>
						<td><h3 style="margin:0;"><?php 
            $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'");
            echo $count;
            ?>
</h3></td>
					</tr>
					<tr>
						<td><h3 style="margin:0; color:red;"><?php 
            _e('Spam:', 'wp-photo-album-plus');
            ?>
</h3></td>
						<td><h3 style="margin:0;"><?php 
            $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'spam'");
            echo $count;
            ?>
</h3></td>
					</tr>
					<?php 
            if (wppa_opt('spam_maxage') != 'none') {
                ?>
					<tr>
						<td><h3 style="margin:0; color:red;"><?php 
                _e('Auto deleted spam:', 'wp-photo-album-plus');
                ?>
</h3></td>
						<td><h3 style="margin:0;"><?php 
                echo get_option('wppa_spam_auto_delcount', '0');
                ?>
</h3></td>
					</tr>
					<?php 
            }
            ?>
				</tbody>
			</table>
			<!-- end statistics -->

			<!-- Settings -->
			<div style="border:1px solid #ccc; padding:4px; margin:4px 0" >
				<h3><?php 
            _e('Settings', 'wp-photo-album-plus');
            ?>
</h3>
				<form action="<?php 
            echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments');
            ?>
" method="post">
					<p>
						<?php 
            wp_nonce_field('$wppa_nonce', WPPA_NONCE);
            _e('Linkpage:', 'wp-photo-album-plus');
            ?>
						<select name="wppa_comadmin_linkpage">
							<option value="0" <?php 
            if ($wppa_comadmin_linkpage == '0') {
                echo 'selected="selected"';
            }
            ?>
 disabled="disabled" ><?php 
            _e('--- Please select a page ---', 'wp-photo-album-plus');
            ?>
</option>
							<?php 
            $query = "SELECT `ID`, `post_title`, `post_content` FROM `" . $wpdb->posts . "` WHERE `post_type` = 'page' AND `post_status` = 'publish' ORDER BY `post_title` ASC";
            $pages = $wpdb->get_results($query, ARRAY_A);
            if ($pages) {
                foreach ($pages as $page) {
                    if (stripos($page['post_content'], '%%wppa%%') !== false || stripos($page['post_content'], '[wppa') !== false) {
                        if ($wppa_comadmin_linkpage == $page['ID']) {
                            $sel = 'selected="selected"';
                        } else {
                            $sel = '';
                        }
                        echo '<option value="' . $page['ID'] . '" ' . $sel . '>' . __($page['post_title'], 'wp-photo-album-plus') . '</option>';
                    }
                }
            }
            ?>
						</select>
						<?php 
            _e('You can see the photo and all its comments on the selected page by clicking on the thumbnail image', 'wp-photo-album-plus');
            ?>
					</p>
					<?php 
            $comment_show = wppa_opt('comadmin_show');
            ?>
					<p>
						<?php 
            _e('Display status:', 'wp-photo-album-plus');
            ?>
						<select name="wppa_comadmin_show">
							<option value="all" <?php 
            if ($comment_show == 'all') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('all', 'wp-photo-album-plus');
            ?>
</option>
							<option value="pending" <?php 
            if ($comment_show == 'pending') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('pending', 'wp-photo-album-plus');
            ?>
</option>
							<option value="approved" <?php 
            if ($comment_show == 'approved') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('approved', 'wp-photo-album-plus');
            ?>
</option>
							<option value="spam" <?php 
            if ($comment_show == 'spam') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('spam', 'wp-photo-album-plus');
            ?>
</option>
						</select>
						<?php 
            $comment_order = wppa_opt('comadmin_order');
            ?>
						<?php 
            _e('Display order:', 'wp-photo-album-plus');
            ?>
						<select name="wppa_comadmin_order">
							<option value="timestamp" <?php 
            if ($comment_order == 'timestamp') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('timestamp', 'wp-photo-album-plus');
            ?>
</option>
							<option value="photo" <?php 
            if ($comment_order == 'photo') {
                echo 'selected="selected"';
            }
            ?>
><?php 
            _e('photo', 'wp-photo-album-plus');
            ?>
</option>
						</select>
						<?php 
            _e('Bulk action:', 'wp-photo-album-plus');
            ?>
						<select name="bulkaction">
							<option value=""><?php 
            ?>
</option>
							<option value="approveall"><?php 
            _e('Approve all pending', 'wp-photo-album-plus');
            ?>
</option>
							<option value="spamall"><?php 
            _e('Move all pending to spam', 'wp-photo-album-plus');
            ?>
</option>
							<option value="delspam"><?php 
            _e('Delete all spam', 'wp-photo-album-plus');
            ?>
</option>
						</select>
						<input type="submit" class="button-primary" name="wppa_submit" value="<?php 
            _e('Save Settings / Perform bulk action', 'wp-photo-album-plus');
            ?>
" />
					</p>
				</form>
			</div>
			<!-- End Settings -->

			<?php 
        }
        if ($moderating) {
            $pagesize = '1';
            $where = " WHERE `id` = '" . $_REQUEST['commentid'] . "'";
            $order = '';
            $curpage = '1';
            $limit = '';
        } else {
            $pagsize = wppa_opt('comment_admin_pagesize');
            $where = $comment_show == 'all' ? '' : " WHERE `status` = '" . $comment_show . "'";
            $order = " ORDER BY `" . $comment_order . "`";
            if ($comment_order == 'timestamp') {
                $order .= " DESC";
            }
            if (isset($_GET['wppa-page'])) {
                $curpage = strval(intval($_GET['wppa-page']));
                $offset = (strval(intval($_GET['wppa-page'])) - 1) * $pagsize;
                $limit = " LIMIT " . $offset . "," . $pagsize;
            } else {
                $limit = ' LIMIT 0,' . $pagsize;
                $curpage = '1';
            }
            if ($pagsize == '0') {
                $limit = '';
            }
            // Paginating is off
            $nitems = $wpdb->get_var("SELECT COUNT(*) FROM " . WPPA_COMMENTS . $where);
            $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments');
            wppa_admin_page_links($curpage, $pagsize, $nitems, $link);
        }
        ?>
			<table class="widefat">
				<thead style="font-weight: bold" class="">
					<tr>
						<th scope="col"><?php 
        _e('Photo', 'wp-photo-album-plus');
        ?>
<br />
										<?php 
        _e('(Album)', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('#', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('IP', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('User', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Email', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Time since', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Comment', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col" style="width: 130px;" ><?php 
        _e('Status', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Edit', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Delete', 'wp-photo-album-plus');
        ?>
</th>
					</tr>
				</thead>
				<tbody class="wppa_table_1">
					<?php 
        $comments = $wpdb->get_results("SELECT * FROM `" . WPPA_COMMENTS . "`" . $where . $order . $limit, ARRAY_A);
        if ($comments) {
            foreach ($comments as $com) {
                ?>
							<tr>
								<?php 
                $photo = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . WPPA_PHOTOS . " WHERE id = %s", $com['photo']), 'ARRAY_A');
                if ($photo) {
                    $alb = $photo['album'];
                    $pname = __($photo['name'], 'wp-photo-album-plus');
                    $albname = '(' . wppa_get_album_name($alb) . ')';
                } else {
                    $alb = '';
                    $pname = '';
                    $albname = '';
                }
                if ($wppa_comadmin_linkpage == '0') {
                    ?>
									<td style="text-align:center">
										<img src="<?php 
                    echo wppa_fix_poster_ext(wppa_get_thumb_url($com['photo']), $com['photo']);
                    ?>
" style="max-height:64px;max-width:64px;" />
										<br />
										<?php 
                    echo $albname;
                    ?>
									</td><?php 
                } else {
                    $url = get_page_link($wppa_comadmin_linkpage);
                    if (strpos($url, '?')) {
                        $url .= '&';
                    } else {
                        $url .= '?';
                    }
                    $url .= 'wppa-album=' . $alb . '&wppa-photo=' . $com['photo'] . '&wppa-occur=1';
                    ?>
									<td style="text-align:center">
										<a href="<?php 
                    echo $url;
                    ?>
" target="_blank">
											<img title="<?php 
                    _e('Click to see the fullsize photo and all comments', 'wp-photo-album-plus');
                    ?>
" src="<?php 
                    echo wppa_fix_poster_ext(wppa_get_thumb_url($com['photo']), $com['photo']);
                    ?>
" style="max-height:64px;max-width:64px;" />
										</a>
										<br />
										<?php 
                    echo $albname;
                    ?>
									</td><?php 
                }
                ?>
								<td><?php 
                echo $com['photo'];
                ?>
</td>
								<td><?php 
                echo $com['ip'];
                ?>
</td>
								<td><?php 
                echo $com['user'];
                ?>
</td>
								<td><?php 
                if ($com['email']) {
                    $subject = str_replace(' ', '%20', sprintf(__('Reply to your comment on photo: %s on %s', 'wp-photo-album-plus'), $pname, get_bloginfo('name')));
                    echo '<a href="mailto:' . $com['email'] . '?Subject=' . $subject . '" title="' . __('Reply', 'wp-photo-album-plus') . '" >' . $com['email'] . '</a>';
                } else {
                    echo $com['email'];
                }
                ?>
								</td>
								<td><?php 
                echo wppa_get_time_since($com['timestamp']);
                ?>
</td>
								<td><?php 
                echo stripslashes($com['comment']);
                ?>
</td>
								<td>
									<input type="hidden" id="photo-nonce-<?php 
                echo $com['photo'];
                ?>
" value="<?php 
                echo wp_create_nonce('wppa_nonce_' . $com['photo']);
                ?>
" />
									<select name="status['<?php 
                echo $com['id'];
                ?>
']" onchange="jQuery('#wppa-comment-spin-<?php 
                echo $com['id'];
                ?>
').css('visibility', 'visible'); wppaAjaxUpdateCommentStatus(<?php 
                echo $com['photo'];
                ?>
, <?php 
                echo $com['id'];
                ?>
, this.value)">
										<option value="pending" 	<?php 
                if ($com['status'] == 'pending') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('Pending', 'wp-photo-album-plus');
                ?>
</option>
										<option value="approved" 	<?php 
                if ($com['status'] == 'approved') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('Approved', 'wp-photo-album-plus');
                ?>
</option>
										<option value="spam" 		<?php 
                if ($com['status'] == 'spam') {
                    echo 'selected="selected"';
                }
                ?>
><?php 
                _e('Spam', 'wp-photo-album-plus');
                ?>
</option>
									</select>
									<img id="wppa-comment-spin-<?php 
                echo $com['id'];
                ?>
" src="<?php 
                echo wppa_get_imgdir() . 'spinner.gif';
                ?>
" style="visibility:hidden" />
								</td>
								<?php 
                $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments&tab=edit&edit_id=' . $com['id']);
                if (isset($_GET['wppa-page'])) {
                    $url .= '&compage=' . strval(intval($_GET['wppa-page']));
                }
                if (isset($_GET['commentid'])) {
                    $url .= '&commentid=' . strval(intval($_GET['commentid']));
                }
                ?>
								<?php 
                $delurl = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_manage_comments&tab=delete&delete_id=' . $com['id']);
                ?>
								<td style="color:green; cursor:pointer;" onclick="document.location='<?php 
                echo $url;
                ?>
'"><b><?php 
                _e('Edit', 'wp-photo-album-plus');
                ?>
</b></td>
								<td style="color:red; cursor:pointer;" onclick="if (confirm('<?php 
                _e('Are you sure you want to delete this comment?', 'wp-photo-album-plus');
                ?>
')) document.location = '<?php 
                echo $delurl;
                ?>
';"><b><?php 
                _e('Delete', 'wp-photo-album-plus');
                ?>
</b></td>
							</tr>
						<?php 
            }
        }
        ?>
				</tbody>
				<tfoot style="font-weight: bold" class="">
					<tr>
						<th scope="col"><?php 
        _e('Photo', 'wp-photo-album-plus');
        ?>
<br />
										<?php 
        _e('(Album)', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('#', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('IP', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('User', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Email', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Time since', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Comment', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Status', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Edit', 'wp-photo-album-plus');
        ?>
</th>
						<th scope="col"><?php 
        _e('Delete', 'wp-photo-album-plus');
        ?>
</th>
					</tr>
				</tfoot>
			</table>
			<?php 
        if (!$moderating) {
            wppa_admin_page_links($curpage, $pagsize, $nitems, $link);
        }
        ?>
		</form>
	</div>
	<?php 
    }
}
コード例 #26
0
function wppa_crumb_ancestors($alb, $to_cover)
{
    global $wppa;
    global $wpdb;
    // Find parent
    $parent = wppa_get_parentalbumid($alb);
    if ($parent < '1') {
        return;
    }
    // No parent -> toplevel -> done.
    wppa_crumb_ancestors($parent, $to_cover);
    // Find the album specific link type ( content, slide, page or none ) TO BE EXPANDED! ! !
    $slide = wppa_get_album_title_linktype($parent) == 'slide' ? '&amp;wppa-slide' : '';
    $pagid = $wpdb->get_var($wpdb->prepare("SELECT `cover_linkpage` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent));
    wppa_dbg_q('Q-bc3');
    $value = wppa_get_album_name($parent);
    $href = wppa_get_permalink($pagid) . 'wppa-album=' . $parent . '&amp;wppa-cover=' . $to_cover . $slide . '&amp;wppa-occur=' . $wppa['occur'];
    $title = __('Album:') . ' ' . wppa_get_album_name($parent);
    $class = 'b20';
    wppa_bcitem($value, $href, $title, $class);
    return;
}
コード例 #27
0
    function do_album_navigator($parent, $page, $skip, $propclass, $extraclause = '')
    {
        global $wpdb;
        static $level;
        static $ca;
        if (!$level) {
            $level = '1';
            if (isset($_REQUEST['wppa-album'])) {
                $ca = $_REQUEST['wppa-album'];
            } elseif (isset($_REQUEST['album'])) {
                $ca = $_REQUEST['album'];
            } else {
                $ca = '0';
            }
            $ca = wppa_force_numeric_else($ca, '0');
            if ($ca && !wppa_album_exists($ca)) {
                //				wppa_log('dbg', 'Non-existent album '.$ca.' in url. Referrer= '.$_ENV["HTTP_REFERER"].', Request uri= '.$_ENV["REQUEST_URI"]);
                $ca = '0';
            }
        } else {
            $level++;
        }
        $slide = wppa_opt('album_navigator_widget_linktype') == 'slide' ? '&amp;wppa-slide=1' : '';
        $w = $this->get_widget_id();
        $p = $parent;
        $result = '';
        $albums = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s " . $extraclause . wppa_get_album_order(max('0', $parent)), $parent), ARRAY_A);
        if (!empty($albums)) {
            wppa_cache_album('add', $albums);
            $result .= '<ul>';
            foreach ($albums as $album) {
                $a = $album['id'];
                $treecount = wppa_treecount_a($a);
                if ($treecount['albums'] || $treecount['photos'] > wppa_opt('min_thumbs') || $skip == 'no') {
                    $result .= '
						<li class="anw-' . $w . '-' . $p . $propclass . '" style="list-style:none; display:' . ($level == '1' ? '' : 'none') . ';">';
                    if (wppa_has_children($a)) {
                        $result .= '
							<div style="cursor:default;width:12px;float:left;text-align:center;font-weight:bold;" class="anw-' . $w . '-' . $a . '-" onclick="jQuery(\'.anw-' . $w . '-' . $a . '\').css(\'display\',\'\'); jQuery(\'.anw-' . $w . '-' . $a . '-\').css(\'display\',\'none\');" >' . ($a == $ca ? '&raquo;' : '+') . '</div>
							<div style="cursor:default;width:12px;float:left;text-align:center;font-weight:bold;display:none;" class="anw-' . $w . '-' . $a . '" onclick="jQuery(\'.anw-' . $w . '-' . $a . '-\').css(\'display\',\'\'); jQuery(\'.anw-' . $w . '-' . $a . '\').css(\'display\',\'none\'); jQuery(\'.p-' . $w . '-' . $a . '\').css(\'display\',\'none\');" >' . ($a == $ca ? '&raquo;' : '-') . '</div>';
                    } else {
                        $result .= '
							<div style="width:12px;float:left;" >&nbsp;' . ($a == $ca ? '&raquo;' : '') . '</div>';
                    }
                    $result .= '
							<a href="' . wppa_encrypt_url(wppa_get_permalink($page) . '&amp;wppa-album=' . $a . '&amp;wppa-cover=0&amp;wppa-occur=1' . $slide) . '">' . wppa_get_album_name($a) . '</a>
						</li>';
                    $newpropclass = $propclass . ' p-' . $w . '-' . $p;
                    $result .= '<li class="anw-' . $w . '-' . $p . $propclass . '" style="list-style:none;" >' . $this->do_album_navigator($a, $page, $skip, $newpropclass, $extraclause) . '</li>';
                }
            }
            $result .= '</ul>';
            if ($level == '1' && $ca) {
                // && $parent != '-1' ) {
                $result .= '<script type="text/javascript" >';
                while ($ca != '0' && $ca != '-1') {
                    $result .= '
								jQuery(\'.anw-' . $w . '-' . $ca . '\').css(\'display\',\'\'); jQuery(\'.anw-' . $w . '-' . $ca . '-\').css(\'display\',\'none\');';
                    $ca = wppa_get_parentalbumid($ca);
                }
                $result .= '</script>';
            }
        }
        $level--;
        return str_replace('<ul></ul>', '', $result);
    }
コード例 #28
0
function wppa_do_frontend_file_upload($file, $alb)
{
    global $wpdb;
    global $wppa_supported_video_extensions;
    global $wppa_supported_audio_extensions;
    // Log upload attempt
    wppa_log('Upl', 'FE Upload attempt of file ' . $file['name'] . ', size=' . filesize($file['tmp_name']));
    $album = wppa_cache_album($alb);
    // Legal here?
    if (!wppa_allow_uploads($alb) || !wppa_allow_user_uploads()) {
        wppa_alert(__('Max uploads reached', 'wp-photo-album-plus'));
        return false;
    }
    // No error during upload?
    if ($file['error'] != '0') {
        wppa_alert(__('Error during upload', 'wp-photo-album-plus'));
        return false;
    }
    // Find the filename
    $filename = wppa_sanitize_file_name($file['name']);
    $filename = wppa_strip_ext($filename);
    // See if this filename with any extension already exists in this album
    $id = $wpdb->get_var("SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `filename` LIKE '" . $filename . ".%' AND `album` = " . $alb);
    // Addition to an av item?
    if ($id) {
        $is_av = wppa_get_photo_item($id, 'ext') == 'xxx';
    } else {
        $is_av = false;
    }
    // see if audio / video and process
    if (wppa_switch('enable_video') && wppa_switch('user_upload_video_on') && in_array(strtolower(wppa_get_ext($file['name'])), $wppa_supported_video_extensions) || wppa_switch('enable_audio') && wppa_switch('user_upload_audio_on') && in_array(strtolower(wppa_get_ext($file['name'])), $wppa_supported_audio_extensions)) {
        $is_av = true;
        // Find the name
        if (wppa_get_post('user-name')) {
            $name = wppa_get_post('user-name');
        } else {
            $name = $file['name'];
        }
        $name = wppa_sanitize_photo_name($name);
        $filename .= '.xxx';
        // update entry
        if ($id) {
            wppa_update_photo(array('id' => $id, 'ext' => 'xxx', 'filename' => $filename));
        }
        // Add new entry
        if (!$id) {
            $id = wppa_create_photo_entry(array('album' => $alb, 'filename' => $filename, 'ext' => 'xxx', 'name' => $name, 'description' => balanceTags(wppa_get_post('user-desc'), true)));
            if (!$id) {
                wppa_alert(__('Could not insert media into db.', 'wp-photo-album-plus'));
                return false;
            }
        }
        // Housekeeping
        wppa_update_album(array('id' => $alb, 'modified' => time()));
        wppa_flush_treecounts($alb);
        wppa_flush_upldr_cache('photoid', $id);
        // Add video filetype
        $ext = strtolower(wppa_get_ext($file['name']));
        $newpath = wppa_strip_ext(wppa_get_photo_path($id)) . '.' . $ext;
        copy($file['tmp_name'], $newpath);
        // Repair name if not standard
        if (!wppa_get_post('user-name')) {
            wppa_set_default_name($id, $file['name']);
        }
        // tags
        wppa_fe_add_tags($id);
        // custom
        wppa_fe_add_custom($id);
        // Done!
        return $id;
    }
    // If not already an existing audio / video; Forget the id from a previously found item with the same filename.
    if (!$is_av) {
        $id = false;
    }
    // Is it an image?
    $imgsize = getimagesize($file['tmp_name']);
    if (!is_array($imgsize)) {
        wppa_alert(__('Uploaded file is not an image', 'wp-photo-album-plus'));
        return false;
    }
    // Is it a supported image filetype?
    if ($imgsize[2] != IMAGETYPE_GIF && $imgsize[2] != IMAGETYPE_JPEG && $imgsize[2] != IMAGETYPE_PNG) {
        wppa_alert(sprintf(__('Only gif, jpg and png image files are supported. Returned info = %s.', 'wp-photo-album-plus'), wppa_serialize($imgsize)), false, false);
        return false;
    }
    // Is it not too big?
    $ms = wppa_opt('upload_fronend_maxsize');
    if ($ms) {
        // Max size configured
        if ($imgsize[0] > $ms || $imgsize[1] > $ms) {
            wppa_alert(sprintf(__('Uploaded file is larger than the allowed maximum of %d x %d pixels.', 'wp-photo-album-plus'), $ms, $ms));
            return false;
        }
    }
    // Check for already exists
    if (wppa_switch('void_dups')) {
        if (wppa_file_is_in_album(wppa_sanitize_file_name($file['name']), $alb)) {
            wppa_alert(sprintf(__('Uploaded file %s already exists in this album.', 'wp-photo-album-plus'), wppa_sanitize_file_name($file['name'])));
            return false;
        }
    }
    // Check for max memory needed to rocess image?
    $mayupload = wppa_check_memory_limit('', $imgsize[0], $imgsize[1]);
    if ($mayupload === false) {
        $maxsize = wppa_check_memory_limit(false);
        if (is_array($maxsize)) {
            wppa_alert(sprintf(__('The image is too big. Max photo size: %d x %d (%2.1f MegaPixel)', 'wp-photo-album-plus'), $maxsize['maxx'], $maxsize['maxy'], $maxsize['maxp'] / (1024 * 1024)));
            return false;
        }
    }
    // Find extension from mimetype
    switch ($imgsize[2]) {
        // mime type
        case 1:
            $ext = 'gif';
            break;
        case 2:
            $ext = 'jpg';
            break;
        case 3:
            $ext = 'png';
            break;
    }
    // Did the user supply a photoname?
    if (wppa_get_post('user-name')) {
        $name = wppa_get_post('user-name');
    } else {
        $name = $file['name'];
    }
    // Sanitize input
    $name = wppa_sanitize_photo_name($name);
    $desc = balanceTags(wppa_get_post('user-desc'), true);
    // If BlogIt! and no descrption given, use name field - this is for the shortcode used: typ"mphoto"
    if (!$desc && isset($_POST['wppa-blogit'])) {
        $desc = 'w#name';
    }
    // Find status and other needed data
    $linktarget = '_self';
    $status = wppa_switch('upload_moderate') && !current_user_can('wppa_admin') ? 'pending' : 'publish';
    if (wppa_switch('fe_upload_private')) {
        $status = 'private';
    }
    $filename = wppa_sanitize_file_name($file['name']);
    // Create new entry if this is not a posterfile
    if (!$is_av) {
        $id = wppa_create_photo_entry(array('album' => $alb, 'ext' => $ext, 'name' => $name, 'description' => $desc, 'status' => $status, 'filename' => $filename));
    }
    if (!$id) {
        wppa_alert(__('Could not insert photo into db.', 'wp-photo-album-plus'));
        return false;
    } else {
        wppa_save_source($file['tmp_name'], $filename, $alb);
        wppa_make_o1_source($id);
        wppa_update_album(array('id' => $alb, 'modified' => time()));
        wppa_flush_treecounts($alb);
        wppa_flush_upldr_cache('photoid', $id);
    }
    if (wppa_make_the_photo_files($file['tmp_name'], $id, $ext)) {
        // Repair photoname if not standard
        if (!wppa_get_post('user-name')) {
            wppa_set_default_name($id, $file['name']);
        }
        // Custom data
        wppa_fe_add_custom($id);
        // Add tags
        wppa_fe_add_tags($id);
        // and add watermark ( optionally ) to fullsize image only
        wppa_add_watermark($id);
        // Also to thumbnail?
        if (wppa_switch('watermark_thumbs')) {
            wppa_create_thumbnail($id);
            // create new thumb
        }
        // Is it a default coverimage?
        wppa_check_coverimage($id);
        // Mail
        if (wppa_switch('upload_notify')) {
            $to = get_bloginfo('admin_email');
            $subj = sprintf(__('New photo uploaded: %s', 'wp-photo-album-plus'), $name);
            $cont['0'] = sprintf(__('User %1$s uploaded photo %2$s into album %3$s', 'wp-photo-album-plus'), wppa_get_user(), $id, wppa_get_album_name($alb));
            if (wppa_switch('upload_moderate') && !current_user_can('wppa_admin')) {
                $cont['1'] = __('This upload requires moderation', 'wp-photo-album-plus');
                $cont['2'] = '<a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Moderate manage photo', 'wp-photo-album-plus') . '</a>';
            } else {
                $cont['1'] = __('Details:', 'wp-photo-album-plus');
                $cont['1'] .= ' <a href="' . get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=pmod&photo=' . $id . '" >' . __('Manage photo', 'wp-photo-album-plus') . '</a>';
            }
            wppa_send_mail($to, $subj, $cont, $id);
        }
        return $id;
    }
    return false;
}
コード例 #29
0
function wppa_get_photo_desc($id, $do_shortcodes = false, $do_geo = false)
{
    // Verify args
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_photo_desc( ' . $id . ' )', 'red');
        return '';
    }
    // Get data
    $thumb = wppa_cache_thumb($id);
    $desc = $thumb['description'];
    // Raw data
    $desc = stripslashes($desc);
    // Unescape
    $desc = __($desc);
    // qTranslate
    // To prevent recursive rendering of scripts or shortcodes:
    $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc);
    // Geo
    if ($thumb['location'] && !wppa('in_widget') && strpos(wppa_opt('custom_content'), 'w#location') !== false && $do_geo == 'do_geo') {
        wppa_do_geo($id, $thumb['location']);
    }
    // Other keywords
    if (strpos($desc, 'w#') !== false) {
        // Is there any 'w#' ?
        // Keywords
        $desc = str_replace('w#albumname', wppa_get_album_name($thumb['album']), $desc);
        $desc = str_replace('w#albumid', $thumb['album'], $desc);
        $keywords = array('name', 'filename', 'owner', 'id', 'tags', 'views', 'album');
        foreach ($keywords as $keyword) {
            $replacement = __(trim(stripslashes($thumb[$keyword])));
            if ($replacement == '') {
                $replacement = '&lsaquo;' . __a('none', 'wppa') . '&rsaquo;';
            }
            $desc = str_replace('w#' . $keyword, $replacement, $desc);
        }
        $desc = str_replace('w#url', wppa_get_lores_url($id), $desc);
        $desc = str_replace('w#hrurl', esc_attr(wppa_get_hires_url($id)), $desc);
        $desc = str_replace('w#tnurl', wppa_get_tnres_url($id), $desc);
        $desc = str_replace('w#pl', wppa_get_source_pl($id), $desc);
        // Art monkey sizes
        if (strpos($desc, 'w#amx') !== false || strpos($desc, 'w#amy') !== false || strpos($desc, 'w#amfs') !== false) {
            $amxy = wppa_get_artmonkey_size_a($id);
            if (is_array($amxy)) {
                $desc = str_replace('w#amx', $amxy['x'], $desc);
                $desc = str_replace('w#amy', $amxy['y'], $desc);
                $desc = str_replace('w#amfs', $amxy['s'], $desc);
            } else {
                $desc = str_replace('w#amx', 'N.a.', $desc);
                $desc = str_replace('w#amy', 'N.a.', $desc);
                $desc = str_replace('w#amfs', 'N.a.', $desc);
            }
        }
        // Timestamps
        $timestamps = array('timestamp', 'modified');
        foreach ($timestamps as $timestamp) {
            if ($thumb[$timestamp]) {
                $desc = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $thumb[$timestamp]), $desc);
            } else {
                $desc = str_replace('w#' . $timestamp, '&lsaquo;' . __a('unknown') . '&rsaquo;', $desc);
            }
        }
        // Custom data fields
        if (wppa_switch('custom_fields')) {
            $custom = $thumb['custom'];
            $custom_data = $custom ? unserialize($custom) : array('', '', '', '', '', '', '', '', '', '');
            for ($i = '0'; $i < '10'; $i++) {
                if (wppa_opt('custom_caption_' . $i)) {
                    // Field defined
                    if (wppa_switch('custom_visible_' . $i)) {
                        // May be displayed
                        $desc = str_replace('w#cc' . $i, __(wppa_opt('custom_caption_' . $i)) . ':', $desc);
                        // Caption
                        $desc = str_replace('w#cd' . $i, __(stripslashes($custom_data[$i])), $desc);
                        // Data
                    } else {
                        // May not be displayed
                        $desc = str_replace('w#cc' . $i, '', $desc);
                        // Remove
                        $desc = str_replace('w#cd' . $i, '', $desc);
                        // Remove
                    }
                } else {
                    // Field not defined
                    $desc = str_replace('w#cc' . $i, '', $desc);
                    // Remove
                    $desc = str_replace('w#cd' . $i, '', $desc);
                    // Remove
                }
            }
        }
    }
    // Shortcodes
    if ($do_shortcodes) {
        $desc = do_shortcode($desc);
    } else {
        $desc = strip_shortcodes($desc);
    }
    // Remove shortcodes if not wanted
    $desc = wppa_html($desc);
    // Enable html
    $desc = balanceTags($desc, true);
    // Balance tags
    $desc = wppa_filter_iptc($desc, $id);
    // Render IPTC tags
    $desc = wppa_filter_exif($desc, $id);
    // Render EXIF tags
    $desc = make_clickable($desc);
    // Auto make a tags for links
    $desc = convert_smilies($desc);
    // Make smilies visible
    // CMTooltipGlossary on board?
    $desc = wppa_filter_glossary($desc);
    return $desc;
}
コード例 #30
0
function wppa_album_name($key)
{
    global $wppa;
    global $wpdb;
    if ($wppa['is_upldr']) {
        return;
    }
    if ($wppa['is_comten']) {
        return;
    }
    if ($wppa['is_lasten']) {
        return;
    }
    if ($wppa['is_featen']) {
        return;
    }
    if ($wppa['supersearch']) {
        return;
    }
    if ($wppa['searchstring']) {
        return;
    }
    if ($wppa['is_tag']) {
        return;
    }
    if (strlen($wppa['start_album']) > '0' && !wppa_is_int($wppa['start_album'])) {
        return;
    }
    // Album enumeration
    $result = '';
    if (wppa_opt('wppa_albname_on_thumbarea') == $key && $wppa['current_album']) {
        $name = wppa_get_album_name($wppa['current_album']);
        if ($key == 'top') {
            $result .= '<h3 id="wppa-albname-' . $wppa['mocc'] . '" class="wppa-box-text wppa-black" style="padding-right:6px; margin:0; ' . __wcs('wppa-box-text') . __wcs('wppa-black') . '" >' . $name . '</h3><div style="clear:both" ></div>';
        }
        if ($key == 'bottom') {
            $result .= '<h3 id="wppa-albname-b-' . $wppa['mocc'] . '" class="wppa-box-text wppa-black" style="clear:both; padding-right:6px; margin:0; ' . __wcs('wppa-box-text') . __wcs('wppa-black') . '" >' . $name . '</h3>';
        }
    }
    $wppa['out'] .= $result;
}