Example #1
0
function wppa_slide_custom($opt = '')
{
    if ($opt == 'optional' && !wppa_switch('custom_on')) {
        return;
    }
    if (wppa('is_slideonly')) {
        return;
    }
    /* Not when slideonly */
    if (is_feed()) {
        return;
    }
    $content = __(stripslashes(wppa_opt('custom_content')));
    // w#albdesc
    if (wppa_is_int(wppa('start_album')) && wppa('start_album') > '0') {
        $content = str_replace('w#albdesc', wppa_get_album_desc(wppa('start_album')), $content);
    } else {
        $content = str_replace('w#albdesc', '', $content);
    }
    // w#fotomoto
    if (wppa_switch('fotomoto_on')) {
        $fontsize = wppa_opt('fotomoto_fontsize');
        if ($fontsize) {
            $s = '<style>.FotomotoToolbarClass{font-size:' . wppa_opt('fotomoto_fontsize') . 'px !important;}</style>';
        } else {
            $s = '';
        }
        $content = str_replace('w#fotomoto', $s . '<div' . ' id="wppa-fotomoto-container-' . wppa('mocc') . '"' . ' class="wppa-fotomoto-container"' . ' >' . '</div>' . '<div' . ' id="wppa-fotomoto-checkout-' . wppa('mocc') . '"' . ' class="wppa-fotomoto-checkout FotomotoToolbarClass"' . ' style="float:right; clear:none;"' . ' >' . '<ul' . ' class="FotomotoBar"' . ' style="list-style:none outside none;"' . ' >' . '<li>' . '<a' . ' onclick="FOTOMOTO.API.checkout(); return false;"' . ' >' . __('Checkout', 'wp-photo-album-plus') . '</a>' . '</li>' . '</ul>' . '</div>' . '<div' . ' style="clear:both;"' . ' >' . '</div>', $content);
    } else {
        $content = str_replace('w#fotomoto', '', $content);
    }
    $content = wppa_html($content);
    wppa_out('<div' . ' id="wppa-custom-' . wppa('mocc') . '"' . ' class="wppa-box wppa-custom"' . ' style="' . __wcs('wppa-box') . __wcs('wppa-custom') . '"' . ' >' . $content . '</div>');
}
Example #2
0
function wppa_album_desc($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('albdesc_on_thumbarea') == $key && wppa('start_album')) {
        $desc = wppa_get_album_desc(wppa('start_album'));
        if ($key == 'top') {
            $result .= '<div' . ' id="wppa-albdesc-' . wppa('mocc') . '"' . ' class="wppa-box-text wppa-black"' . ' style="padding-right:6px;' . __wcs('wppa-box-text') . __wcs('wppa-black') . '"' . ' >' . $desc . '</div>' . '<div style="clear:both" ></div>';
        }
        if ($key == 'bottom') {
            $result .= '<div' . ' id="wppa-albdesc-b-' . wppa('mocc') . '"' . ' class="wppa-box-text wppa-black"' . ' style="clear:both; padding-right:6px;' . __wcs('wppa-box-text') . __wcs('wppa-black') . '"' . ' >' . $desc . '</div>';
        }
    }
    wppa_out($result);
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     global $wppa;
     global $thumb;
     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'] = 'alb';
     $wppa['mocc']++;
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'parent' => 'none', 'name' => 'no', 'skip' => 'yes'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('wppa_album_widget_linktype'), $wppa['links_no_page']) ? '' : wppa_get_the_landing_page('wppa_album_widget_linkpage', __a('Photo Albums'));
     $max = wppa_opt('wppa_album_widget_count');
     if (!$max) {
         $max = '10';
     }
     $parent = $instance['parent'];
     $name = $instance['name'];
     $skip = $instance['skip'];
     if (is_numeric($parent)) {
         $albums = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_ALBUMS . '` WHERE `a_parent` = %s ' . wppa_get_album_order($parent), $parent), ARRAY_A);
     } else {
         switch ($parent) {
             case 'all':
                 $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ' . wppa_get_album_order(), ARRAY_A);
                 break;
             case 'last':
                 $albums = $wpdb->get_results('SELECT * FROM `' . WPPA_ALBUMS . '` ORDER BY `timestamp` DESC', ARRAY_A);
                 break;
             default:
                 wppa_dbg_msg('Error, unimplemented album selection: ' . $parent . ' in Album widget.', 'red', true);
         }
     }
     $widget_content = "\n" . '<!-- WPPA+ album Widget start -->';
     $maxw = wppa_opt('wppa_album_widget_size');
     $maxh = $maxw;
     if ($name == 'yes') {
         $maxh += 18;
     }
     $count = 0;
     if ($albums) {
         foreach ($albums as $album) {
             if ($count < $max) {
                 global $thumb;
                 $imageid = wppa_get_coverphoto_id($album['id']);
                 $image = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $imageid), ARRAY_A);
                 $imgcount = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . WPPA_PHOTOS . ' WHERE `album` = %s', $album['id']));
                 $subalbumcount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $album['id']));
                 $thumb = $image;
                 // Make the HTML for current picture
                 if ($image && ($imgcount > wppa_opt('wppa_min_thumbs') || $subalbumcount)) {
                     $link = wppa_get_imglnk_a('albwidget', $image['id']);
                     $file = wppa_get_thumb_path($image['id']);
                     $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                     $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb');
                     $imgstyle = $imgstyle_a['style'];
                     $width = $imgstyle_a['width'];
                     $height = $imgstyle_a['height'];
                     $cursor = $imgstyle_a['cursor'];
                     if (wppa_switch('wppa_show_albwidget_tooltip')) {
                         $title = esc_attr(strip_tags(wppa_get_album_desc($album['id'])));
                     } else {
                         $title = '';
                     }
                     $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height);
                 } else {
                     $link = '';
                     $file = '';
                     $imgevents = '';
                     $imgstyle = 'width:' . $maxw . ';height:' . $maxh . ';';
                     $width = $maxw;
                     $height = $maxw;
                     // !!
                     $cursor = 'default';
                     $title = sprintf(__a('Upload at least %d photos to this album!', 'wppa_theme'), wppa_opt('wppa_min_thumbs') - $imgcount + 1);
                     if ($imageid) {
                         // The 'empty album has a cover image
                         $file = wppa_get_thumb_path($image['id']);
                         $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'albthumb');
                         $imgstyle = $imgstyle_a['style'];
                         $width = $imgstyle_a['width'];
                         $height = $imgstyle_a['height'];
                         $imgurl = wppa_get_thumb_url($image['id'], '', $width, $height);
                     } else {
                         $imgurl = wppa_get_imgdir() . 'album32.png';
                     }
                 }
                 $imgurl = wppa_fix_poster_ext($imgurl, $image['id']);
                 if ($imgcount > wppa_opt('wppa_min_thumbs') || $skip == 'no') {
                     $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
                     if ($link) {
                         if ($link['is_url']) {
                             // Is a href
                             $widget_content .= "\n\t" . '<a href="' . $link['url'] . '" title="' . $title . '" target="' . $link['target'] . '" >';
                             if (wppa_is_video($image['id'])) {
                                 $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title));
                             } else {
                                 $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >';
                             }
                             $widget_content .= "\n\t" . '</a>';
                         } elseif ($link['is_lightbox']) {
                             $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($album['id']), $album['id']), 'ARRAY_A');
                             if ($thumbs) {
                                 foreach ($thumbs as $thumb) {
                                     $title = wppa_get_lbtitle('alw', $thumb['id']);
                                     if (wppa_is_video($thumb['id'])) {
                                         $siz['0'] = wppa_get_videox($thumb['id']);
                                         $siz['1'] = wppa_get_videoy($thumb['id']);
                                     } else {
                                         //	$siz = getimagesize( wppa_get_photo_path( $thumb['id'] ) );
                                         $siz['0'] = wppa_get_photox($thumb['id']);
                                         $siz['1'] = wppa_get_photoy($thumb['id']);
                                     }
                                     $link = wppa_fix_poster_ext(wppa_get_photo_url($thumb['id'], '', $siz['0'], $siz['1']), $thumb['id']);
                                     $is_video = wppa_is_video($thumb['id']);
                                     $has_audio = wppa_has_audio($thumb['id']);
                                     $widget_content .= "\n\t" . '<a href="' . $link . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($thumb['id'])) . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($thumb['id'])) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('wppa_lightbox_name') . '[alw-' . $wppa['mocc'] . '-' . $album['id'] . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '" >';
                                     if ($thumb['id'] == $image['id']) {
                                         // the cover image
                                         if (wppa_is_video($image['id'])) {
                                             $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => $cursor, 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => wppa_zoom_in($image['id'])));
                                         } else {
                                             $widget_content .= "\n\t\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . $cursor . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >';
                                         }
                                     }
                                     $widget_content .= "\n\t" . '</a>';
                                 }
                             }
                         } else {
                             // Is an onclick unit
                             if (wppa_is_video($image['id'])) {
                                 $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents . ' onclick="' . $link['url'] . '"', 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title));
                             } else {
                                 $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . ' cursor:pointer;" ' . $imgevents . ' onclick="' . $link['url'] . '" ' . wppa_get_imgalt($image['id']) . ' >';
                             }
                         }
                     } else {
                         if (wppa_is_video($image['id'])) {
                             $widget_content .= wppa_get_video_html(array('id' => $image['id'], 'width' => $width, 'height' => $height, 'controls' => false, 'margin_top' => $imgstyle_a['margin-top'], 'margin_bottom' => $imgstyle_a['margin-bottom'], 'cursor' => 'pointer', 'events' => $imgevents, 'tagid' => 'i-' . $image['id'] . '-' . $wppa['mocc'], 'title' => $title));
                         } else {
                             $widget_content .= "\n\t" . '<img id="i-' . $image['id'] . '-' . $wppa['mocc'] . '" title="' . $title . '" src="' . $imgurl . '" width="' . $width . '" height="' . $height . '" style="' . $imgstyle . '" ' . $imgevents . ' ' . wppa_get_imgalt($image['id']) . ' >';
                         }
                     }
                     if ($name == 'yes') {
                         $widget_content .= "\n\t" . '<span style="font-size:' . wppa_opt('wppa_fontsize_widget_thumb') . 'px; min-height:100%;">' . __(stripslashes($album['name'])) . '</span>';
                     }
                     $widget_content .= "\n" . '</div>';
                     $count++;
                 }
             }
         }
     } else {
         $widget_content .= 'There are no albums (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ thumbnail 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;
 }
function wppa_album_cover_longdesc($albumid, $multicolresp = false)
{
    global $cover_count_key;
    global $wpdb;
    $album = wppa_cache_album($albumid);
    if ($multicolresp) {
        $mcr = 'mcr-';
    } else {
        $mcr = '';
    }
    $coverphoto = wppa_get_coverphoto_id($albumid);
    $image = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $coverphoto), ARRAY_A);
    $photocount = wppa_get_photo_count($albumid, true);
    $albumcount = wppa_get_album_count($albumid, true);
    $mincount = wppa_get_mincount();
    $title = '';
    $linkpage = '';
    $href_title = '';
    $href_slideshow = '';
    $href_content = '';
    $onclick_title = '';
    $onclick_slideshow = '';
    $onclick_content = '';
    // See if there is substantial content to the album
    $has_content = $albumcount > '0' || $photocount > $mincount;
    // 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 cover title href, onclick and title
    $title_attr = wppa_get_album_title_attr_a($albumid, $linktype, $linkpage, $has_content, $coverphoto, $photocount);
    $href_title = $title_attr['href'];
    $onclick_title = $title_attr['onclick'];
    $title = $title_attr['title'];
    // Find the slideshow link and onclick
    $href_slideshow = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage));
    if (wppa_switch('allow_ajax') && !$linkpage) {
        $onclick_slideshow = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_slideshow) . "' )";
        $href_slideshow = "#";
    }
    // Find the content 'View' link
    $href_content = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage));
    if (wppa_switch('allow_ajax') && !$linkpage) {
        $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )";
        $href_content = "#";
    }
    // Find the coverphoto link
    if ($coverphoto) {
        $photolink = wppa_get_imglnk_a('coverimg', $coverphoto, $href_title, $title, $onclick_title, '', $albumid);
    } else {
        $photolink = false;
    }
    // Find the coverphoto details
    if ($coverphoto) {
        $path = wppa_get_thumb_path($coverphoto);
        $imgattr_a = wppa_get_imgstyle_a($coverphoto, $path, wppa_opt('smallsize'), '', 'cover');
        $src = wppa_get_thumb_url($coverphoto, '', $imgattr_a['width'], $imgattr_a['height']);
    } else {
        $path = '';
        $imgattr_a = false;
        $src = '';
    }
    // Feed?
    if (is_feed()) {
        $events = '';
    } else {
        $events = wppa_get_imgevents('cover');
    }
    $photo_pos = wppa('coverphoto_pos');
    $style = __wcs('wppa-box') . __wcs('wppa-' . wppa('alt'));
    if (is_feed()) {
        $style .= ' padding:7px;';
    }
    $wid = wppa_get_cover_width('cover');
    $style .= 'width: ' . $wid . 'px;';
    if ($cover_count_key == 'm') {
        $style .= 'margin-left: 8px;';
    } elseif ($cover_count_key == 'r') {
        $style .= 'float:right;';
    } else {
        $style .= 'clear:both;';
    }
    wppa_step_covercount('cover');
    $target = wppa_switch('allow_ajax') ? '_self' : $photolink['target'];
    // Open the album box
    wppa_out('<div' . ' id="album-' . $albumid . '-' . wppa('mocc') . '"' . ' class="' . 'wppa-album-cover-longdesc ' . 'album ' . 'wppa-box ' . 'wppa-cover-box ' . 'wppa-cover-box-' . $mcr . wppa('mocc') . ' ' . 'wppa-' . wppa('alt') . '"' . ' style="' . $style . __wcs('wppa-cover-box') . '"' . ' >');
    // First The Cover photo?
    if ($photo_pos == 'left' || $photo_pos == 'top') {
        wppa_the_coverphoto($albumid, $image, $src, $photo_pos, $photolink, $title, $imgattr_a, $events);
    }
    // Open the Cover text frame
    $textframestyle = wppa_get_text_frame_style($photo_pos, 'cover');
    wppa_out('<div' . ' id="covertext_frame_' . $albumid . '_' . wppa('mocc') . '"' . ' class="' . 'wppa-text-frame-' . wppa('mocc') . ' ' . 'wppa-text-frame ' . 'wppa-cover-text-frame ' . 'wppa-asym-text-frame-' . $mcr . wppa('mocc') . '"' . ' ' . $textframestyle . '>');
    // The Album title
    wppa_the_album_title($albumid, $href_title, $onclick_title, $title, $target);
    // The 'Slideshow'/'Browse' link
    wppa_the_slideshow_browse_link($photocount, $href_slideshow, $onclick_slideshow, $target);
    // The 'View' link
    wppa_album_cover_view_link($albumid, $has_content, $photocount, $albumcount, $mincount, $href_content, $target, $onclick_content);
    // Close the Cover text frame
    wppa_out('</div>');
    // The Cover photo last?
    if ($photo_pos == 'right' || $photo_pos == 'bottom') {
        wppa_the_coverphoto($albumid, $image, $src, $photo_pos, $photolink, $title, $imgattr_a, $events);
    }
    // The Album description
    if (wppa_switch('show_cover_text')) {
        $textheight = wppa_opt('text_frame_height') > '0' ? 'min-height:' . wppa_opt('text_frame_height') . 'px; ' : '';
        wppa_out('<div' . ' id="coverdesc_frame_' . $albumid . '_' . wppa('mocc') . '"' . ' style="clear:both"' . ' >' . '<p' . ' class="wppa-box-text wppa-black wppa-box-text-desc"' . ' style="' . $textheight . __wcs('wppa-box-text') . __wcs('wppa-black') . '"' . ' >' . wppa_get_album_desc($albumid) . '</p>' . '</div>');
    }
    // The sublinks
    wppa_albumcover_sublinks($albumid, wppa_get_cover_width('cover'), $multicolresp);
    // Prepare for closing
    wppa_out('<div style="clear:both;"></div>');
    // Close the album box
    wppa_out('</div>');
    // Toggle alt/even
    wppa_toggle_alt();
}
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 
}
function wppa_slide_custom($opt = '')
{
    global $wppa;
    global $wppa_opt;
    if ($opt == 'optional' && !wppa_switch('wppa_custom_on')) {
        return;
    }
    if ($wppa['is_slideonly'] == '1') {
        return;
    }
    /* Not when slideonly */
    if (is_feed()) {
        return;
    }
    $content = __(stripslashes($wppa_opt['wppa_custom_content']));
    // w#albdesc
    if (is_numeric($wppa['start_album']) && $wppa['start_album'] > '0') {
        $content = str_replace('w#albdesc', wppa_get_album_desc($wppa['start_album']), $content);
    } else {
        $content = str_replace('w#albdesc', '', $content);
    }
    // w#fotomoto
    if (wppa_switch('wppa_fotomoto_on')) {
        $fontsize = $wppa_opt['wppa_fotomoto_fontsize'];
        if ($fontsize) {
            $s = '<style>.FotomotoToolbarClass{font-size:' . $wppa_opt['wppa_fotomoto_fontsize'] . 'px !important;}</style>';
        } else {
            $s = '';
        }
        $content = str_replace('w#fotomoto', $s . '<div' . ' id="wppa-fotomoto-container-' . $wppa['mocc'] . '"' . ' class="wppa-fotomoto-container"' . ' >' . '</div>' . '<div' . ' id="wppa-fotomoto-checkout-' . $wppa['mocc'] . '"' . ' class="wppa-fotomoto-checkout FotomotoToolbarClass"' . ' style="float:right; clear:none;"' . ' >' . '<ul' . ' class="FotomotoBar"' . ' style="list-style:none outside none;"' . ' >' . '<li>' . '<a' . ' onclick="FOTOMOTO.API.checkout(); return false;"' . ' >' . __('Checkout') . '</a>' . '</li>' . '</ul>' . '</div>' . '<div' . ' style="clear:both;"' . ' >' . '</div>', $content);
    } else {
        $content = str_replace('w#fotomoto', '', $content);
    }
    $content = wppa_html($content);
    $wppa['out'] .= wppa_nltab('+') . '<div id="wppa-custom-' . $wppa['mocc'] . '" class="wppa-box wppa-custom" style="' . __wcs('wppa-box') . __wcs('wppa-custom') . '">';
    $wppa['out'] .= wppa_nltab() . $content;
    $wppa['out'] .= wppa_nltab('-') . '</div>';
}
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 
}
function wppa_album_desc($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_albdesc_on_thumbarea') == $key && $wppa['current_album']) {
        $desc = wppa_get_album_desc($wppa['current_album']);
        if ($key == 'top') {
            $result .= '<div id="wppa-albdesc-' . $wppa['mocc'] . '" class="wppa-box-text wppa-black" style="padding-right:6px;' . __wcs('wppa-box-text') . __wcs('wppa-black') . '" >' . $desc . '</div><div style="clear:both" ></div>';
        }
        if ($key == 'bottom') {
            $result .= '<div id="wppa-albdesc-b-' . $wppa['mocc'] . '" class="wppa-box-text wppa-black" style="clear:both; padding-right:6px;' . __wcs('wppa-box-text') . __wcs('wppa-black') . '" >' . $desc . '</div>';
        }
    }
    $wppa['out'] .= $result;
}