Пример #1
0
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;
}
Пример #2
0
function wppa_create_wppa_init_js()
{
    global $wppa_api_version;
    global $wppa_lang;
    global $wppa;
    global $wppa_init_js_data;
    // Init
    if (is_numeric(wppa_opt('wppa_fullimage_border_width'))) {
        $fbw = wppa_opt('wppa_fullimage_border_width') + '1';
    } else {
        $fbw = '0';
    }
    // Make content
    $content = '/* -- WPPA+ Runtime parameters
/*
/* Dynamicly Created on ' . date('c') . '
/*
*/
';
    if ((WPPA_DEBUG || wppa_get_get('debug') || WP_DEBUG) && !wppa_switch('wppa_defer_javascript')) {
        $content .= '
	/* Check if wppa.js and jQuery are present */
	if (typeof(_wppaSlides) == \'undefined\') alert(\'There is a problem with your theme. The file wppa.js is not loaded when it is expected (Errloc = wppa_kickoff).\');
	if (typeof(jQuery) == \'undefined\') alert(\'There is a problem with your theme. The jQuery library is not loaded when it is expected (Errloc = wppa_kickoff).\');
';
    }
    /* This goes into wppa.js */
    /* If you add something that uses an element from $wppa_opt[], */
    /* or a function that uses an element from $wppa_opt[], */
    /* add the optionslug to $init_js_critical[] in wppa_update_option in wppa-utils.php !!!!! */
    $content .= '
	wppaVersion = "' . $wppa_api_version . '";
	wppaBackgroundColorImage = "' . wppa_opt('wppa_bgcolor_img') . '";
	wppaPopupLinkType = "' . wppa_opt('wppa_thumb_linktype') . '";
	wppaAnimationType = "' . wppa_opt('wppa_animation_type') . '";
	wppaAnimationSpeed = ' . wppa_opt('wppa_animation_speed') . ';
	wppaThumbnailAreaDelta = ' . wppa_get_thumbnail_area_delta() . ';
	wppaTextFrameDelta = ' . wppa_get_textframe_delta() . ';
	wppaBoxDelta = ' . wppa_get_box_delta() . ';
	wppaSlideShowTimeOut = ' . wppa_opt('wppa_slideshow_timeout') . ';
	wppaPreambule = ' . wppa_get_preambule() . ';
	wppaFilmShowGlue = ' . (wppa_switch('wppa_film_show_glue') ? 'true' : 'false') . ';
	wppaSlideShow = "' . __a('Slideshow') . '";
	wppaStart = "' . __a('Start') . '";
	wppaStop = "' . __a('Stop') . '";
	wppaSlower = "' . __a('Slower') . '";
	wppaFaster = "' . __a('Faster') . '";
	wppaPhoto = "' . __a('Photo') . '";
	wppaOf = "' . __a('of') . '";
	wppaPreviousPhoto = "' . __a('Previous photo') . '";
	wppaNextPhoto = "' . __a('Next photo') . '";
	wppaPrevP = "' . __a('Prev.') . '";
	wppaNextP = "' . __a('Next') . '";
	wppaAvgRating = "' . __a('Average&nbsp;rating') . '";
	wppaMyRating = "' . __a('My&nbsp;rating') . '";
	wppaAvgRat = "' . __a('Avg.') . '";
	wppaMyRat = "' . __a('Mine') . '";
	wppaDislikeMsg = "' . __a('You marked this image as inappropriate.') . '";
	wppaShowDislikeCount = ' . (wppa_switch('wppa_dislike_show_count') ? 'true' : 'false') . ';
	wppaNoDislikes = "' . __a('No dislikes') . '";
	wppa1Dislike = "' . __a('1 dislike') . '";
	wppaDislikes = "' . __a('dislikes') . '";
	wppaIncludingMine = "' . __a('including mine') . '";
	wppaMiniTreshold = ' . (wppa_opt('wppa_mini_treshold') ? wppa_opt('wppa_mini_treshold') : '0') . ';
	wppaRatingOnce = ' . (wppa_switch('wppa_rating_change') || wppa_switch('wppa_rating_multi') ? 'false' : 'true') . ';
	wppaPleaseName = "' . __a('Please enter your name') . '";
	wppaPleaseEmail = "' . __a('Please enter a valid email address') . '";
	wppaPleaseComment = "' . __a('Please enter a comment') . '";
	wppaHideWhenEmpty = ' . (wppa_switch('wppa_hide_when_empty') ? 'true' : 'false') . ';
	wppaBGcolorNumbar = "' . wppa_opt('wppa_bgcolor_numbar') . '";
	wppaBcolorNumbar = "' . wppa_opt('wppa_bcolor_numbar') . '";
	wppaBGcolorNumbarActive = "' . wppa_opt('wppa_bgcolor_numbar_active') . '";
	wppaBcolorNumbarActive = "' . wppa_opt('wppa_bcolor_numbar_active') . '";
	wppaFontFamilyNumbar = "' . wppa_opt('wppa_fontfamily_numbar') . '";
	wppaFontSizeNumbar = "' . wppa_opt('wppa_fontsize_numbar') . 'px";
	wppaFontColorNumbar = "' . wppa_opt('wppa_fontcolor_numbar') . '";
	wppaFontWeightNumbar = "' . wppa_opt('wppa_fontweight_numbar') . '";
	wppaFontFamilyNumbarActive = "' . wppa_opt('wppa_fontfamily_numbar_active') . '";
	wppaFontSizeNumbarActive = "' . wppa_opt('wppa_fontsize_numbar_active') . 'px";
	wppaFontColorNumbarActive = "' . wppa_opt('wppa_fontcolor_numbar_active') . '";
	wppaFontWeightNumbarActive = "' . wppa_opt('wppa_fontweight_numbar_active') . '";
	wppaNumbarMax = "' . wppa_opt('wppa_numbar_max') . '";
	wppaLang = "' . $wppa_lang . '";
	wppaNextOnCallback = ' . (wppa_switch('wppa_next_on_callback') ? 'true' : 'false') . ';
	wppaStarOpacity = ' . wppa_opt('wppa_star_opacity') / '100' . ';
	wppaSlideWrap = ' . (wppa_switch('wppa_slide_wrap') ? 'true' : 'false') . ';
	wppaEmailRequired = ' . (wppa_switch('wppa_comment_email_required') ? 'true' : 'false') . ';
	wppaSlideBorderWidth = ' . $fbw . ';
	wppaAllowAjax = ' . (wppa_switch('wppa_allow_ajax') ? 'true' : 'false') . ';
	wppaUsePhotoNamesInUrls = ' . (wppa_switch('wppa_use_photo_names_in_urls') ? 'true' : 'false') . ';
	wppaThumbTargetBlank = ' . (wppa_switch('wppa_thumb_blank') ? 'true' : 'false') . ';
	wppaRatingMax = ' . wppa_opt('wppa_rating_max') . ';
	wppaRatingDisplayType = "' . wppa_opt('wppa_rating_display_type') . '";
	wppaRatingPrec = ' . wppa_opt('wppa_rating_prec') . ';
	wppaStretch = ' . (wppa_switch('wppa_enlarge') ? 'true' : 'false') . ';
	wppaMinThumbSpace = ' . wppa_opt('wppa_tn_margin') . ';
	wppaThumbSpaceAuto = ' . (wppa_switch('wppa_thumb_auto') ? 'true' : 'false') . ';
	wppaMagnifierCursor = "' . wppa_opt('wppa_magnifier') . '";
	wppaArtMonkyLink = "' . wppa_opt('wppa_art_monkey_link') . '";
	wppaAutoOpenComments = ' . (wppa_switch('wppa_auto_open_comments') ? 'true' : 'false') . ';
	wppaUpdateAddressLine = ' . (wppa_switch('wppa_update_addressline') ? 'true' : 'false') . ';
	wppaFilmThumbTitle = "' . (wppa_opt('wppa_film_linktype') == 'lightbox' ? wppa_zoom_in(false) : __a('Double click to start/stop slideshow running')) . '";
	wppaVoteForMe = "' . __(wppa_opt('wppa_vote_button_text')) . '";
	wppaVotedForMe = "' . __(wppa_opt('wppa_voted_button_text')) . '";
	wppaSlideSwipe = ' . (wppa_switch('wppa_slide_swipe') ? 'true' : 'false') . ';
	wppaMaxCoverWidth = ' . wppa_opt('wppa_max_cover_width') . ';
	wppaDownLoad = "' . __a('Download') . '";
	wppaSlideToFullpopup = ' . (wppa_opt('wppa_slideshow_linktype') == 'fullpopup' ? 'true' : 'false') . '; 
	wppaComAltSize = ' . wppa_opt('wppa_comten_alt_thumbsize') . ';
	wppaBumpViewCount = ' . (wppa_switch('wppa_track_viewcounts') ? 'true' : 'false') . ';
	wppaShareHideWhenRunning = ' . (wppa_switch('wppa_share_hide_when_running') ? 'true' : 'false') . ';
	wppaFotomoto = ' . (wppa_switch('wppa_fotomoto_on') ? 'true' : 'false') . ';
	wppaArtMonkeyButton = ' . (wppa_opt('wppa_art_monkey_display') == 'button' ? 'true' : 'false') . ';
	wppaFotomotoHideWhenRunning = ' . (wppa_switch('wppa_fotomoto_hide_when_running') ? 'true' : 'false') . ';
	wppaCommentRequiredAfterVote = ' . (wppa_switch('wppa_vote_needs_comment') ? 'true' : 'false') . ';
	wppaFotomotoMinWidth = ' . wppa_opt('wppa_fotomoto_min_width') . ';
	wppaShortQargs = ' . (wppa_switch('wppa_use_short_qargs') ? 'true' : 'false') . ';
	wppaOvlHires = ' . (wppa_switch('wppa_lb_hres') ? 'true' : 'false') . ';
	wppaSlideVideoStart = ' . (wppa_switch('start_slide_video') ? 'true' : 'false') . ';
	wppaSlideAudioStart = ' . (wppa_switch('start_slide_audio') ? 'true' : 'false') . ';
	wppaAudioHeight = ' . wppa_get_audio_control_height() . '; 
	wppaRel = "' . (wppa_opt('lightbox_name') == 'wppa' ? 'data-rel' : 'rel') . '";
	';
    // Open file
    $file = @fopen(WPPA_PATH . '/wppa-init.' . $wppa_lang . '.js', 'wb');
    if ($file) {
        // Write file
        fwrite($file, $content);
        // Close file
        fclose($file);
        $wppa_init_js_data = '';
    } else {
        $wppa_init_js_data = '<script type="text/javascript">
/* Warning: file wppa-init.' . $wppa_lang . '.js could not be created */
/* The content is therefor output here */

' . $content . '
</script>
';
    }
}
function wppa_sphoto()
{
    $id = wppa('single_photo');
    $width = wppa_get_container_width();
    $height = floor($width / wppa_get_ratio($id));
    $usethumb = wppa_use_thumb_file($id, $width, $height);
    $src = $usethumb ? wppa_get_thumb_url($id, '', $width, $height) : wppa_get_photo_url($id, '', $width, $height);
    if (wppa_has_audio($id)) {
        $src = wppa_fix_poster_ext($src, $id);
    }
    if (!wppa_in_widget()) {
        wppa_bump_viewcount('photo', $id);
    }
    $autocol = wppa('auto_colwidth') || $width > 0 && $width <= 1.0;
    // The initial width is $width if not autocol, else it should default to initial column width when auto
    // or initial column width * fraction
    if ($autocol) {
        if ($width == 'auto') {
            $contwidth = wppa_opt('initial_colwidth');
        } else {
            $contwidth = wppa_opt('initial_colwidth') * $width;
        }
    } else {
        $contwidth = $width;
    }
    // Open the pseudo container
    wppa_out('<div' . ' id="wppa-container-' . wppa('mocc') . '"' . ' class="' . (wppa('align') ? 'align' . wppa('align') : '') . ' wppa-sphoto-' . wppa('mocc') . '"' . ' style="width:' . $contwidth . 'px;position:relative;"' . ' >');
    // The script for responsive
    wppa_add_js_page_data("\n" . '<script type="text/javascript">');
    if ($autocol) {
        wppa_add_js_page_data("\n" . 'wppaAutoColumnWidth[' . wppa('mocc') . '] = true;');
        if ($width > 0 && $width <= 1.0) {
            wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = ' . $width . ';');
        } else {
            wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = 1.0;');
        }
        wppa_add_js_page_data("\n" . 'wppaColWidth[' . wppa('mocc') . '] = 0;');
    }
    wppa_add_js_page_data("\n" . 'wppaTopMoc = ' . wppa('mocc') . ';');
    wppa_add_js_page_data("\n" . '</script>');
    wppa('portrait_only', true);
    $fis = wppa_get_fullimgstyle_a($id);
    $width = $fis['width'];
    $height = $fis['height'];
    $style = $fis['style'];
    $style .= 'box-sizing:content-box;vertical-align:middle;';
    // The link
    $link = wppa_get_imglnk_a('sphoto', $id);
    if ($link) {
        if ($link['is_lightbox']) {
            $lbtitle = wppa_get_lbtitle('sphoto', $id);
            $videobody = esc_attr(wppa_get_video_body($id));
            $audiobody = esc_attr(wppa_get_audio_body($id));
            $videox = wppa_get_videox($id);
            $videoy = wppa_get_videoy($id);
            wppa_out('<a' . ' href="' . $link['url'] . '"' . ($lbtitle ? ' ' . wppa('lbtitle') . '="' . $lbtitle . '"' : '') . ($videobody ? ' data-videohtml="' . $videobody . '"' : '') . ($audiobody ? ' data-audiohtml="' . $audiobody . '"' : '') . ($videox ? ' data-videonatwidth="' . $videox . '"' : '') . ($videoy ? ' data-videonatheight="' . $videoy . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"' . ($link['target'] ? ' target="' . $link['target'] . '"' : '') . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >');
        } else {
            wppa_out('<a' . ' href="' . $link['url'] . '"' . ' title="' . $link['title'] . '"' . ' target="' . $link['target'] . '"' . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >');
        }
    }
    // The image
    $title = $link ? esc_attr($link['title']) : esc_attr(stripslashes(wppa_get_photo_name($id)));
    if ($link['is_lightbox']) {
        $style .= ' cursor:url( ' . wppa_get_imgdir() . wppa_opt('magnifier') . ' ),pointer;';
        $title = wppa_zoom_in($id);
    }
    if (wppa_is_video($id)) {
        if ($autocol) {
            wppa_out(wppa_get_video_html(array('id' => $id, 'controls' => !$link['is_lightbox'], 'style' => $style, 'class' => 'size-medium wppa-sphoto wppa-simg-' . wppa('mocc'))));
        } else {
            wppa_out(wppa_get_video_html(array('id' => $id, 'width' => $width, 'height' => $height, 'controls' => !$link['is_lightbox'], 'style' => $style, 'class' => 'size-medium wppa-sphoto wppa-simg-' . wppa('mocc'))));
        }
    } else {
        wppa_out('<img' . ' src="' . $src . '"' . ' ' . wppa_get_imgalt($id) . ' class="size-medium wppa-sphoto wppa-simg-' . wppa('mocc') . '"' . ' ' . wppa_get_imgalt($id) . ($title ? ' title="' . $title . '" ' : '') . ' style="' . $style . '"' . ($autocol ? '' : ' width="' . $width . '" height="' . $height . '" ') . '/ >');
    }
    // Close the link
    if ($link) {
        wppa_out('</a>');
    }
    // Add audio?			sphoto
    if (wppa_has_audio($id)) {
        wppa_out('<div style="position:relative;z-index:11;" >');
        $margl = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') + 1;
        $margb = $margl;
        wppa_out(wppa_get_audio_html(array('id' => $id, 'cursor' => 'cursor:pointer;', 'style' => $style . 'position:absolute;' . 'left:' . $margl . 'px;' . 'bottom:' . $margb . 'px;' . 'padding:0;' . 'margin:0;' . 'border:none;' . 'height:' . wppa_get_audio_control_height() . 'px;' . 'border-radius:0;', 'class' => 'size-medium wppa-sphoto wppa-simg-' . wppa('mocc'))));
        wppa_out('</div>');
    }
    // The pseudo container
    wppa_out('</div>');
}
function _wppa_sidebar_page_options()
{
    global $wpdb;
    $options_error = false;
    if (isset($_GET['walbum'])) {
        $walbum = wppa_walbum_sanitize($_GET['walbum']);
        wppa_update_option('wppa_widget_album', $walbum);
    }
    if (isset($_REQUEST['wppa-set-submit'])) {
        if (!wp_verify_nonce($_REQUEST['wppa-update-check'], 'wppa-update-check')) {
            echo 'Trying:' . $_REQUEST['wppa-update-check'];
        }
        if (isset($_POST['wppa-widgettitle'])) {
            wppa_update_option('wppa_widgettitle', $_POST['wppa-widgettitle']);
        }
        if (isset($_POST['wppa-potd-align'])) {
            wppa_update_option('wppa_potd_align', $_POST['wppa-potd-align']);
        }
        if (isset($_POST['wppa-widget-albums'])) {
            wppa_update_option('wppa_widget_album', wppa_walbum_sanitize($_POST['wppa-widget-albums']));
        }
        if (isset($_POST['wppa-widget-photo'])) {
            wppa_update_option('wppa_widget_photo', $_POST['wppa-widget-photo']);
        }
        if (isset($_POST['wppa-widget-method'])) {
            wppa_update_option('wppa_widget_method', $_POST['wppa-widget-method']);
        }
        if (isset($_REQUEST['wppa-widget-period'])) {
            wppa_update_option('wppa_widget_period', $_REQUEST['wppa-widget-period']);
        }
        if (isset($_POST['wppa-widget-subtitle'])) {
            wppa_update_option('wppa_widget_subtitle', $_POST['wppa-widget-subtitle']);
        }
        if (isset($_POST['wppa-widget-linkpage'])) {
            wppa_update_option('wppa_widget_linkpage', $_POST['wppa-widget-linkpage']);
        }
        if (isset($_POST['wppa-widget-linkurl'])) {
            wppa_update_option('wppa_widget_linkurl', $_POST['wppa-widget-linkurl']);
        }
        if (isset($_POST['wppa-widget-linktitle'])) {
            wppa_update_option('wppa_widget_linktitle', $_POST['wppa-widget-linktitle']);
        }
        if (isset($_POST['wppa-widget-linktype'])) {
            wppa_update_option('wppa_widget_linktype', $_POST['wppa-widget-linktype']);
        }
        if (isset($_POST['wppa-widget-status-filter'])) {
            wppa_update_option('wppa_widget_status_filter', $_POST['wppa-widget-status-filter']);
        }
        if (isset($_POST['wppa-potd-offset'])) {
            wppa_update_option('wppa_potd_offset', $_POST['wppa-potd-offset']);
        }
        if (isset($_POST['wppa-potd-widget-width'])) {
            if (wppa_check_numeric($_POST['wppa-potd-widget-width'], '100', __('Widget Photo Width.', 'wp-photo-album-plus'))) {
                wppa_update_option('wppa_potd_widget_width', $_POST['wppa-potd-widget-width']);
            } else {
                $options_error = true;
            }
        }
        if (!$options_error && isset($_POST['wppa-set-submit'])) {
            wppa_update_message(__('Changes Saved. Don\'t forget to activate the widget!', 'wp-photo-album-plus'));
        }
    }
    wppa_initialize_runtime('force');
    ?>
	
	<div class="wrap">
		<?php 
    $iconurl = WPPA_URL . '/images/settings32.png';
    ?>
		<div id="icon-album" class="icon32" style="background: transparent url(<?php 
    echo $iconurl;
    ?>
) no-repeat">
			<br />
		</div>
		<h2><?php 
    _e('Photo of the Day Widget Settings', 'wp-photo-album-plus');
    ?>
</h2>
		
		<?php 
    $action_url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day');
    ?>
		
		<form action="<?php 
    echo $action_url;
    ?>
" method="post">
			<?php 
    echo wp_nonce_field('wppa-update-check', 'wppa-update-check');
    ?>

			<table class="form-table wppa-table wppa-photo-table">
				<tbody>
					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Widget Title:', 'wp-photo-album-plus');
    ?>
</label>
						</th>
						<td>
							<input type="text" name="wppa-widgettitle" id="wppa-widgettitle" value="<?php 
    echo wppa_opt('widgettitle');
    ?>
" />
							<span class="description"><br/><?php 
    _e('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wp-photo-album-plus');
    ?>
</span>
						</td>
					</tr>	
					
					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Widget Photo Width:', 'wp-photo-album-plus');
    ?>
</label>
						</th>
						<td>
							<input type="text" name="wppa-potd-widget-width" id="wppa-potd-widget-width" value="<?php 
    echo wppa_opt('potd_widget_width');
    ?>
" style="width: 50px;" />
							<?php 
    _e('pixels.', 'wp-photo-album-plus');
    echo ' ';
    _e('Horizontal alignment:', 'wp-photo-album-plus');
    ?>
							<select name="wppa-potd-align" id="wppa-potd-align">
								<?php 
    $ali = wppa_opt('potd_align');
    ?>
								<?php 
    $sel = 'selected="selected"';
    ?>
								<option value="none" <?php 
    if ($ali == 'none') {
        echo $sel;
    }
    ?>
><?php 
    _e('--- none ---', 'wp-photo-album-plus');
    ?>
</option>
								<option value="left" <?php 
    if ($ali == 'left') {
        echo $sel;
    }
    ?>
><?php 
    _e('left', 'wp-photo-album-plus');
    ?>
</option>
								<option value="center" <?php 
    if ($ali == 'center') {
        echo $sel;
    }
    ?>
><?php 
    _e('center', 'wp-photo-album-plus');
    ?>
</option>
								<option value="right" <?php 
    if ($ali == 'right') {
        echo $sel;
    }
    ?>
><?php 
    _e('right', 'wp-photo-album-plus');
    ?>
</option>
							</select>
							<span class="description"><br/><?php 
    _e('Enter the desired display width and alignment of the photo in the sidebar.', 'wp-photo-album-plus');
    ?>
</span>
						</td>
					</tr>

					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Use album(s):', 'wp-photo-album-plus');
    ?>
</label>
						</th>
						<td>
							<script type="text/javascript">
							/* <![CDATA[ */
							function wppaCheckWa() {
								document.getElementById('wppa-spin').style.visibility = 'visible';
								document.getElementById('wppa-upd').style.visibility = 'hidden';
								var album = document.getElementById('wppa-wa').value;
								if ( album != 'all' && album != 'sep' && album != 'all-sep' && album != 'topten' && album != 'clr' )
									album = document.getElementById('wppa-was').value + ',' + album;
								var url = "<?php 
    echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day');
    ?>
&walbum=" + album;
								document.location.href = url;
							}
							/* ]]> */
							</script>
							<?php 
    _e('Select:', 'wp-photo-album-plus');
    ?>
<select name="wppa-widget-album" id="wppa-wa" onchange="wppaCheckWa()" ><?php 
    echo wppa_walbum_select(wppa_opt('widget_album'));
    ?>
</select>
							<img id="wppa-spin" src="<?php 
    echo wppa_get_imgdir();
    ?>
wpspin.gif" style="visibility:hidden;"/>
							<?php 
    _e('Or Edit:', 'wp-photo-album-plus');
    ?>
<input type="text" name="wppa-widget-albums" id="wppa-was" value="<?php 
    echo wppa_opt('widget_album');
    ?>
" />
							<input class="button-primary" name="wppa-upd" id="wppa-upd" value="<?php 
    _e('Update thumbnails', 'wp-photo-album-plus');
    ?>
" onclick="wppaCheckWa()" />
							<span class="description"><br/>
								<?php 
    _e('Select or edit the album(s) you want to use the photos of for the widget.', 'wp-photo-album-plus');
    ?>
								<br />
								<?php 
    _e('If you want a <b>- special -</b> selection or get rid of it, you may need to use <b>- start over -</b> first.', 'wp-photo-album-plus');
    ?>
							</span>
						</td>
					</tr>
					<!-- Status filter -->
					<tr valign="top" >
						<th scope="row" >
							<label ><?php 
    _e('Status filter:', 'wp-photo-album-plus');
    ?>
</label>
						</th>
						<td>
							<?php 
    $sel = 'selected="selected"';
    ?>
							<?php 
    $filter = wppa_opt('widget_status_filter');
    ?>
							<select name="wppa-widget-status-filter" >
								<option value="" <?php 
    if ($filter == 'none') {
        echo $sel;
    }
    ?>
><?php 
    _e('- none -', 'wp-photo-album-plus');
    ?>
</option>
								<option value="publish" <?php 
    if ($filter == 'publish') {
        echo $sel;
    }
    ?>
 ><?php 
    _e('Publish', 'wp-photo-album-plus');
    ?>
</option>
								<option value="featured" <?php 
    if ($filter == 'featured') {
        echo $sel;
    }
    ?>
 ><?php 
    _e('Featured', 'wp-photo-album-plus');
    ?>
</option>
								<option value="gold" <?php 
    if ($filter == 'gold') {
        echo $sel;
    }
    ?>
 ><?php 
    _e('Gold', 'wp-photo-album-plus');
    ?>
</option>
								<option value="silver" <?php 
    if ($filter == 'silver') {
        echo $sel;
    }
    ?>
 ><?php 
    _e('Silver', 'wp-photo-album-plus');
    ?>
</option>
								<option value="bronze" <?php 
    if ($filter == 'bronze') {
        echo $sel;
    }
    ?>
 ><?php 
    _e('Bronze', 'wp-photo-album-plus');
    ?>
</option>
								<option value="anymedal" <?php 
    if ($filter == 'anymedal') {
        echo $sel;
    }
    ?>
 ><?php 
    _e('Any medal', 'wp-photo-album-plus');
    ?>
</option>
							</select>
						</td>
					</tr>
					<tr valign="top" >
						<th scope="row">
							<label ><?php 
    _e('Display method:', 'wp-photo-album-plus');
    ?>
</label>
						</th>
						<td>
							<?php 
    $sel = 'selected="selected"';
    ?>
							<?php 
    $method = wppa_opt('widget_method');
    ?>
							<select name="wppa-widget-method" id="wppa-wm" onchange="wppaCheckWidgetMethod()" >
								<option value="1" <?php 
    if ($method == '1') {
        echo $sel;
    }
    ?>
><?php 
    _e('Fixed photo', 'wp-photo-album-plus');
    ?>
</option> 
								<option value="2" <?php 
    if ($method == '2') {
        echo $sel;
    }
    ?>
><?php 
    _e('Random', 'wp-photo-album-plus');
    ?>
</option>
								<option value="3" <?php 
    if ($method == '3') {
        echo $sel;
    }
    ?>
><?php 
    _e('Last upload', 'wp-photo-album-plus');
    ?>
</option>
								<option value="4" <?php 
    if ($method == '4') {
        echo $sel;
    }
    ?>
><?php 
    _e('Change every', 'wp-photo-album-plus');
    ?>
</option>
							</select>
							<?php 
    $period = wppa_opt('widget_period');
    $text = esc_attr(__('The page will now be reloaded', 'wp-photo-album-plus'));
    $onchange = esc_attr('alert(\'' . $text . '\');wppaPotdChangePeriod()');
    ?>
							<script type="text/javascript" >
								function wppaPotdChangePeriod() {
									var url = '<?php 
    echo $action_url;
    ?>
';
									url += '&wppa-set-submit=1';
									url += '&wppa-update-check='+jQuery('#wppa-update-check').val();
									url += '&wppa-widget-period='+jQuery('#wppa-wp').val();
									document.location.href = url;
								}
							</script>
							<select name="wppa-widget-period" id="wppa-wp" onchange="<?php 
    echo $onchange;
    ?>
" >
								<option value="0" <?php 
    if ($period == '0') {
        echo $sel;
    }
    ?>
><?php 
    _e('pageview.', 'wp-photo-album-plus');
    ?>
</option>
								<option value="1" <?php 
    if ($period == '1') {
        echo $sel;
    }
    ?>
><?php 
    _e('hour.', 'wp-photo-album-plus');
    ?>
</option>
								<option value="24" <?php 
    if ($period == '24') {
        echo $sel;
    }
    ?>
><?php 
    _e('day.', 'wp-photo-album-plus');
    ?>
</option>
								<option value="168" <?php 
    if ($period == '168') {
        echo $sel;
    }
    ?>
><?php 
    _e('week.', 'wp-photo-album-plus');
    ?>
</option>
								<option value="736" <?php 
    if ($period == '736') {
        echo $sel;
    }
    ?>
><?php 
    _e('month.', 'wp-photo-album-plus');
    ?>
</option>
								<option value="day-of-week" <?php 
    if ($period == 'day-of-week') {
        echo $sel;
    }
    ?>
><?php 
    _e('day of week is order#', 'wp-photo-album-plus');
    ?>
</option>
								<option value="day-of-month" <?php 
    if ($period == 'day-of-month') {
        echo $sel;
    }
    ?>
><?php 
    _e('day of month is order#', 'wp-photo-album-plus');
    ?>
</option>
								<option value="day-of-year" <?php 
    if ($period == 'day-of-year') {
        echo $sel;
    }
    ?>
><?php 
    _e('day of year is order#', 'wp-photo-album-plus');
    ?>
</option>
							</select>
							<span class="description"><br/><?php 
    _e('Select how the widget should display.', 'wp-photo-album-plus');
    ?>
</span>
							<div class="wppa-order" >
							<?php 
    if (substr(wppa_opt('widget_period'), 0, 7) == 'day-of-') {
        switch (substr(wppa_opt('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);
        }
        echo sprintf(__('Current day# = %s, offset =', 'wp-photo-album-plus'), date_i18n($date_key)) . ' ';
        echo '<select name="wppa-potd-offset" >';
        $day = '0';
        while ($day < $n_days) {
            echo '<option value="' . $day . '" ' . (get_option('wppa_potd_offset', '0') == $day ? 'selected="selected"' : '') . ' >' . $day . '</option>';
            $day++;
        }
        echo '</select>';
        $photo_order = date_i18n($date_key) - get_option('wppa_potd_offset', '0');
        while ($photo_order < '1') {
            $photo_order += $n_days;
        }
        echo '. ' . sprintf(__('Todays photo order# = %s.', 'wp-photo-album-plus'), $photo_order);
        $photo = wppa_get_potd();
        if ($photo) {
            echo ' <img src="' . wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']) . '" style="width:100px;" />';
        } else {
            echo ' ' . __('Not found.', 'wp-photo-album-plus');
        }
    }
    ?>
							</div>
						</td>
					</tr>
<?php 
    $linktype = wppa_opt('widget_linktype');
    if ($linktype != 'custom') {
        ?>
						<tr>
							<th scope="row">
								<label ><?php 
        _e('Link to:', 'wp-photo-album-plus');
        ?>
</label>
							</th>
							<td>
								<?php 
        _e('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wp-photo-album-plus');
        ?>
							</td>
						</tr>
<?php 
    } else {
        ?>
						<tr class="wppa-wlu" >
							<th scope="row">
								<label ><?php 
        _e('Link to:', 'wp-photo-album-plus');
        ?>
</label>
							</th>
							<td>
								<?php 
        _e('Title:', 'wp-photo-album-plus');
        ?>
								<input type="text" name="wppa-widget-linktitle" id="wppa-widget-linktitle" value="<?php 
        echo wppa_opt('widget_linktitle');
        ?>
"style="width:20%" />
								<?php 
        _e('Url:', 'wp-photo-album-plus');
        ?>
								<input type="text"  name="wppa-widget-linkurl" id="wppa-widget-linkurl" value="<?php 
        echo wppa_opt('widget_linkurl');
        ?>
" style="width:50%" />
								<span class="description"><br/><?php 
        _e('Enter the title and the url. Do\'nt forget the HTTP://', 'wp-photo-album-plus');
        ?>
</span>
							</td>
						</tr>
<?php 
    }
    ?>
					<!--<script type="text/javascript">wppaCheckWidgetLink()</script>-->
					<tr>
						<th scope="row">
							<label ><?php 
    _e('Subtitle:', 'wp-photo-album-plus');
    ?>
</label>
						</th>
						<td>
							<?php 
    $subtit = wppa_opt('widget_subtitle');
    ?>
							<select name="wppa-widget-subtitle" id="wppa-st" >
								<option value="none" <?php 
    if ($subtit == 'none') {
        echo $sel;
    }
    ?>
><?php 
    _e('--- none ---', 'wp-photo-album-plus');
    ?>
</option>
								<option value="name" <?php 
    if ($subtit == 'name') {
        echo $sel;
    }
    ?>
><?php 
    _e('Photo Name', 'wp-photo-album-plus');
    ?>
</option>
								<option value="desc" <?php 
    if ($subtit == 'desc') {
        echo $sel;
    }
    ?>
><?php 
    _e('Description', 'wp-photo-album-plus');
    ?>
</option>
								<option value="owner" <?php 
    if ($subtit == 'owner') {
        echo $sel;
    }
    ?>
><?php 
    _e('Owner', 'wp-photo-album-plus');
    ?>
</option>
							</select>
							<span class="description"><br/><?php 
    _e('Select the content of the subtitle.', 'wp-photo-album-plus');
    ?>
</span>	
						</td>
					</tr>
				</tbody>
			</table>
			<p>
				<input type="submit" class="button-primary" name="wppa-set-submit" value="<?php 
    _e('Save Changes', 'wp-photo-album-plus');
    ?>
" />
			</p>
			<?php 
    $alb = wppa_opt('widget_album');
    $opt = wppa_is_int($alb) ? ' ' . wppa_get_photo_order($alb) . ' ' : '';
    $photos = wppa_get_widgetphotos($alb, $opt);
    if (empty($photos)) {
        echo '<p>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</p>';
    } else {
        $curid = wppa_opt('widget_photo');
        // Process photos
        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($photo['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>';
            ?>
						<div style="clear:both;width:100%;margin:3px 0;" >
							<div style="font-size:9px; line-height:10px;float:left;"><?php 
            echo '(#' . $photo['p_order'] . ')';
            ?>
</div>
							<input style="float:right;" type="radio" name="wppa-widget-photo" id="wppa-widget-photo<?php 
            echo $id;
            ?>
" value="<?php 
            echo $id;
            ?>
" <?php 
            if ($id == $curid) {
                echo 'checked="checked"';
            }
            ?>
/>
						</div>
						<div style="clear:both;overflow:auto;height:150px" >
							<div style="font-size:11px; overflow:hidden;"><?php 
            echo wppa_get_photo_name($photo['id']);
            ?>
</div>
							<div style="font-size:9px; line-height:10px;"><?php 
            echo wppa_get_photo_desc($photo['id']);
            ?>
</div>
						</div>
					</div>
					<?php 
        }
        echo '<div class="clear"></div>';
    }
    ?>
			<script type="text/javascript">wppaCheckWidgetMethod();</script>
			<br />
			<p>
				<input type="submit" class="button-primary" name="wppa-set-submit" value="<?php 
    _e('Save Changes', 'wp-photo-album-plus');
    ?>
" />
			</p>
		</form>
	</div>
<?php 
}
Пример #5
0
function _wppa_sidebar_page_options()
{
    global $wpdb;
    $options_error = false;
    if (isset($_GET['walbum'])) {
        $walbum = wppa_walbum_sanitize($_GET['walbum']);
        wppa_update_option('wppa_widget_album', $walbum);
    }
    if (isset($_POST['wppa-set-submit'])) {
        check_admin_referer('$wppa_nonce', WPPA_NONCE);
        if (isset($_POST['wppa-widgettitle'])) {
            wppa_update_option('wppa_widgettitle', $_POST['wppa-widgettitle']);
        }
        if (isset($_POST['wppa-potd-align'])) {
            wppa_update_option('wppa_potd_align', $_POST['wppa-potd-align']);
        }
        if (isset($_POST['wppa-widget-albums'])) {
            wppa_update_option('wppa_widget_album', wppa_walbum_sanitize($_POST['wppa-widget-albums']));
        }
        if (isset($_POST['wppa-widget-photo'])) {
            wppa_update_option('wppa_widget_photo', $_POST['wppa-widget-photo']);
        }
        if (isset($_POST['wppa-widget-method'])) {
            wppa_update_option('wppa_widget_method', $_POST['wppa-widget-method']);
        }
        if (isset($_POST['wppa-widget-period'])) {
            wppa_update_option('wppa_widget_period', $_POST['wppa-widget-period']);
        }
        if (isset($_POST['wppa-widget-subtitle'])) {
            wppa_update_option('wppa_widget_subtitle', $_POST['wppa-widget-subtitle']);
        }
        if (isset($_POST['wppa-widget-linkpage'])) {
            wppa_update_option('wppa_widget_linkpage', $_POST['wppa-widget-linkpage']);
        }
        if (isset($_POST['wppa-widget-linkurl'])) {
            wppa_update_option('wppa_widget_linkurl', $_POST['wppa-widget-linkurl']);
        }
        if (isset($_POST['wppa-widget-linktitle'])) {
            wppa_update_option('wppa_widget_linktitle', $_POST['wppa-widget-linktitle']);
        }
        if (isset($_POST['wppa-widget-linktype'])) {
            wppa_update_option('wppa_widget_linktype', $_POST['wppa-widget-linktype']);
        }
        if (wppa_check_numeric($_POST['wppa-potd-widget-width'], '100', __('Widget Photo Width.'))) {
            wppa_update_option('wppa_potd_widget_width', $_POST['wppa-potd-widget-width']);
        } else {
            $options_error = true;
        }
        if (!$options_error) {
            wppa_update_message(__('Changes Saved. Don\'t forget to activate the widget!', 'wppa'));
        }
    }
    wppa_initialize_runtime('force');
    ?>
	
	<div class="wrap">
		<?php 
    $iconurl = WPPA_URL . '/images/settings32.png';
    ?>
		<div id="icon-album" class="icon32" style="background: transparent url(<?php 
    echo $iconurl;
    ?>
) no-repeat">
			<br />
		</div>
		<h2><?php 
    _e('Photo of the Day Widget Settings', 'wppa');
    ?>
</h2>
		
		<form action="<?php 
    echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day');
    ?>
" method="post">
			<?php 
    wp_nonce_field('$wppa_nonce', WPPA_NONCE);
    ?>

			<table class="form-table wppa-table wppa-photo-table">
				<tbody>
					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Widget Title:', 'wppa');
    ?>
</label>
						</th>
						<td>
							<input type="text" name="wppa-widgettitle" id="wppa-widgettitle" value="<?php 
    echo wppa_opt('widgettitle');
    ?>
" />
							<span class="description"><br/><?php 
    _e('Enter/modify the title for the widget. This is a default and can be overriden at widget activation.', 'wppa');
    ?>
</span>
						</td>
					</tr>	
					
					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Widget Photo Width:', 'wppa');
    ?>
</label>
						</th>
						<td>
							<input type="text" name="wppa-potd-widget-width" id="wppa-potd-widget-width" value="<?php 
    echo wppa_opt('potd_widget_width');
    ?>
" style="width: 50px;" />
							<?php 
    _e('pixels.', 'wppa');
    echo ' ';
    _e('Horizontal alignment:', 'wppa');
    ?>
							<select name="wppa-potd-align" id="wppa-potd-align">
								<?php 
    $ali = wppa_opt('potd_align');
    ?>
								<?php 
    $sel = 'selected="selected"';
    ?>
								<option value="none" <?php 
    if ($ali == 'none') {
        echo $sel;
    }
    ?>
><?php 
    _e('--- none ---', 'wppa');
    ?>
</option>
								<option value="left" <?php 
    if ($ali == 'left') {
        echo $sel;
    }
    ?>
><?php 
    _e('left', 'wppa');
    ?>
</option>
								<option value="center" <?php 
    if ($ali == 'center') {
        echo $sel;
    }
    ?>
><?php 
    _e('center', 'wppa');
    ?>
</option>
								<option value="right" <?php 
    if ($ali == 'right') {
        echo $sel;
    }
    ?>
><?php 
    _e('right', 'wppa');
    ?>
</option>
							</select>
							<span class="description"><br/><?php 
    _e('Enter the desired display width and alignment of the photo in the sidebar.', 'wppa');
    ?>
</span>
						</td>
					</tr>

					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Use album(s):', 'wppa');
    ?>
</label>
						</th>
						<td>
							<script type="text/javascript">
							/* <![CDATA[ */
							function wppaCheckWa() {
								document.getElementById('wppa-spin').style.visibility = 'visible';
								document.getElementById('wppa-upd').style.visibility = 'hidden';
								var album = document.getElementById('wppa-wa').value;
								if ( album != 'all' && album != 'sep' && album != 'all-sep' && album != 'topten' && album != 'clr' )
									album = document.getElementById('wppa-was').value + ',' + album;
								var url = "<?php 
    echo wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_photo_of_the_day');
    ?>
&walbum=" + album;
								document.location.href = url;
							}
							/* ]]> */
							</script>
							<?php 
    _e('Select:', 'wppa');
    ?>
<select name="wppa-widget-album" id="wppa-wa" onchange="wppaCheckWa()" ><?php 
    echo wppa_walbum_select(wppa_opt('widget_album'));
    ?>
</select>
							<img id="wppa-spin" src="<?php 
    echo wppa_get_imgdir();
    ?>
wpspin.gif" style="visibility:hidden;"/>
							<?php 
    _e('Or Edit:', 'wppa');
    ?>
<input type="text" name="wppa-widget-albums" id="wppa-was" value="<?php 
    echo wppa_opt('widget_album');
    ?>
" />
							<input class="button-primary" name="wppa-upd" id="wppa-upd" value="<?php 
    _e('Update thumbnails', 'wppa');
    ?>
" onclick="wppaCheckWa()" />
							<span class="description"><br/>
								<?php 
    _e('Select or edit the album(s) you want to use the photos of for the widget.', 'wppa');
    ?>
								<br />
								<?php 
    _e('If you want a <b>- special -</b> selection or get rid of it, you may need to use <b>- start over -</b> first.', 'wppa');
    ?>
							</span>
						</td>
					</tr>
					<tr valign="top">
						<th scope="row">
							<label ><?php 
    _e('Display method:', 'wppa');
    ?>
</label>
						</th>
						<td>
							<?php 
    $sel = 'selected="selected"';
    ?>
							<?php 
    $method = wppa_opt('widget_method');
    ?>
							<select name="wppa-widget-method" id="wppa-wm" onchange="wppaCheckWidgetMethod()" >
								<option value="1" <?php 
    if ($method == '1') {
        echo $sel;
    }
    ?>
><?php 
    _e('Fixed photo', 'wppa');
    ?>
</option> 
								<option value="2" <?php 
    if ($method == '2') {
        echo $sel;
    }
    ?>
><?php 
    _e('Random', 'wppa');
    ?>
</option>
								<option value="3" <?php 
    if ($method == '3') {
        echo $sel;
    }
    ?>
><?php 
    _e('Last upload', 'wppa');
    ?>
</option>
								<option value="4" <?php 
    if ($method == '4') {
        echo $sel;
    }
    ?>
><?php 
    _e('Change every', 'wppa');
    ?>
</option>
							</select>
							<?php 
    $period = wppa_opt('widget_period');
    ?>
							<select name="wppa-widget-period" id="wppa-wp" >
								<option value="0" <?php 
    if ($period == '0') {
        echo $sel;
    }
    ?>
><?php 
    _e('pageview.', 'wppa');
    ?>
</option>
								<option value="1" <?php 
    if ($period == '1') {
        echo $sel;
    }
    ?>
><?php 
    _e('hour.', 'wppa');
    ?>
</option>
								<option value="24" <?php 
    if ($period == '24') {
        echo $sel;
    }
    ?>
><?php 
    _e('day.', 'wppa');
    ?>
</option>
								<option value="168" <?php 
    if ($period == '168') {
        echo $sel;
    }
    ?>
><?php 
    _e('week.', 'wppa');
    ?>
</option>
								<option value="736" <?php 
    if ($period == '736') {
        echo $sel;
    }
    ?>
><?php 
    _e('month.', 'wppa');
    ?>
</option>
								<option value="day-of-week" <?php 
    if ($period == 'day-of-week') {
        echo $sel;
    }
    ?>
><?php 
    _e('day of week is order#', 'wppa');
    ?>
</option>
								<option value="day-of-month" <?php 
    if ($period == 'day-of-month') {
        echo $sel;
    }
    ?>
><?php 
    _e('day of month is order#', 'wppa');
    ?>
</option>
							</select>
							<span class="description"><br/><?php 
    _e('Select how the widget should display.', 'wppa');
    ?>
</span>								
						</td>
					</tr>
<?php 
    $linktype = wppa_opt('widget_linktype');
    if ($linktype != 'custom') {
        ?>
						<tr>
							<th scope="row">
								<label ><?php 
        _e('Link to:', 'wppa');
        ?>
</label>
							</th>
							<td>
								<?php 
        _e('Links are set on the <b>Photo Albums -> Settings</b> screen.', 'wppa');
        ?>
							</td>
						</tr>
<?php 
    } else {
        ?>
						<tr class="wppa-wlu" >
							<th scope="row">
								<label ><?php 
        _e('Link to:', 'wppa');
        ?>
</label>
							</th>
							<td>
								<?php 
        _e('Title:', 'wppa');
        ?>
								<input type="text" name="wppa-widget-linktitle" id="wppa-widget-linktitle" value="<?php 
        echo wppa_opt('widget_linktitle');
        ?>
"style="width:20%" />
								<?php 
        _e('Url:', 'wppa');
        ?>
								<input type="text"  name="wppa-widget-linkurl" id="wppa-widget-linkurl" value="<?php 
        echo wppa_opt('widget_linkurl');
        ?>
" style="width:50%" />
								<span class="description"><br/><?php 
        _e('Enter the title and the url. Do\'nt forget the HTTP://', 'wppa');
        ?>
</span>
							</td>
						</tr>
<?php 
    }
    ?>
					<!--<script type="text/javascript">wppaCheckWidgetLink()</script>-->
					<tr>
						<th scope="row">
							<label ><?php 
    _e('Subtitle:', 'wppa');
    ?>
</label>
						</th>
						<td>
							<?php 
    $subtit = wppa_opt('widget_subtitle');
    ?>
							<select name="wppa-widget-subtitle" id="wppa-st" onchange="wppaCheckWidgetSubtitle()" >
								<option value="none" <?php 
    if ($subtit == 'none') {
        echo $sel;
    }
    ?>
><?php 
    _e('--- none ---', 'wppa');
    ?>
</option>
								<option value="name" <?php 
    if ($subtit == 'name') {
        echo $sel;
    }
    ?>
><?php 
    _e('Photo Name', 'wppa');
    ?>
</option>
								<option value="desc" <?php 
    if ($subtit == 'desc') {
        echo $sel;
    }
    ?>
><?php 
    _e('Description', 'wppa');
    ?>
</option>
								<option value="owner" <?php 
    if ($subtit == 'owner') {
        echo $sel;
    }
    ?>
><?php 
    _e('Owner', 'wppa');
    ?>
</option>
							</select>
							<span class="description"><br/><?php 
    _e('Select the content of the subtitle.', 'wppa');
    ?>
</span>	
						</td>
					</tr>
				</tbody>
			</table>
			<p>
				<input type="submit" class="button-primary" name="wppa-set-submit" value="<?php 
    _e('Save Changes', 'wppa');
    ?>
" />
			</p>
			<?php 
    $alb = wppa_opt('widget_album');
    $photos = wppa_get_widgetphotos($alb);
    if (empty($photos)) {
        echo '<p>' . __('No photos yet in this album.', 'wppa') . '</p>';
    } else {
        $curid = wppa_opt('widget_photo');
        $wi = wppa_get_minisize() + 24;
        $hi = $wi + 48;
        // Process photos
        foreach ($photos as $photo) {
            $id = $photo['id'];
            // Open container div
            echo '<div' . ' class="photoselect"' . ' style="' . 'width:' . wppa_opt('widget_width') . 'px;' . 'height:' . $hi . 'px;' . 'overflow:hidden;' . '" >';
            // The image if a video
            if (wppa_is_video($id)) {
                echo wppa_get_video_html(array('id' => $id, 'style' => 'width:' . wppa_opt('widget_width') . 'px;'));
            } else {
                echo '<img' . ' src=" ' . wppa_fix_poster_ext(wppa_get_thumb_url($id), $id) . '"' . ' style="' . 'width:' . wppa_opt('widget_width') . 'px;' . '"' . ' alt="' . $photo['name'] . '" />';
                // Audio ?
                if (wppa_has_audio($id)) {
                    echo wppa_get_audio_html(array('id' => $id, 'style' => 'width:' . wppa_opt('widget_width') . 'px;' . 'position:relative;' . 'bottom:' . (wppa_get_audio_control_height() + 4) . 'px;'));
                }
            }
            ?>
						<input type="radio" name="wppa-widget-photo" id="wppa-widget-photo<?php 
            echo $id;
            ?>
" value="<?php 
            echo $id;
            ?>
" <?php 
            if ($id == $curid) {
                echo 'checked="checked"';
            }
            ?>
/>
						<div class="clear"></div>
						<h4 style="position: absolute; top:<?php 
            echo $wi - 12;
            ?>
px; font-size:11px; overflow:hidden;"><?php 
            echo wppa_qtrans(stripslashes($photo['name']));
            ?>
</h4>
						<h6 style="position: absolute; top:<?php 
            echo $wi + 6;
            ?>
px; font-size:9px; line-height:10px;"><?php 
            echo wppa_qtrans(stripslashes($photo['description']));
            ?>
</h6>
						<h5 style="position: absolute; top:<?php 
            echo $wi + 24;
            ?>
px; font-size:9px; line-height:10px;"><?php 
            echo '(#' . $photo['p_order'] . ')';
            ?>
</h5>
						</div><?php 
        }
        echo '<div class="clear"></div>';
    }
    ?>
			<script type="text/javascript">wppaCheckWidgetMethod();</script>
			<script type="text/javascript">wppaCheckWidgetSubtitle();</script>
			<br />
			<p>
				<input type="submit" class="button-primary" name="wppa-set-submit" value="<?php 
    _e('Save Changes', 'wppa');
    ?>
" />
			</p>
		</form>
	</div>
<?php 
}
function wppa_get_picture_html($args)
{
    // Init
    $defaults = array('id' => '0', 'type' => '', 'class' => '');
    $args = wp_parse_args($args, $defaults);
    $id = strval(intval($args['id']));
    $type = $args['type'];
    $class = $args['class'];
    // Check existance of required args
    foreach (array('id', 'type') as $item) {
        if (!$args[$item]) {
            wppa_dbg_msg('Missing ' . $item . ' in call to wppa_get_picture_html()', 'red', 'force');
            return false;
        }
    }
    // Check validity of args
    if (!wppa_photo_exists($id)) {
        wppa_dbg_msg('Photo ' . $id . ' does not exist in call to wppa_get_picture_html(). Type = ' . $type, 'red', 'force');
        return false;
    }
    $types = array('sphoto', 'mphoto', 'xphoto', 'cover', 'thumb', 'ttthumb', 'comthumb', 'fthumb', 'twthumb', 'ltthumb', 'albthumb');
    if (!in_array($type, $types)) {
        wppa_dbg_msg('Unimplemented type ' . $type . ' in call to wppa_get_picture_html()', 'red', 'force');
        return false;
    }
    // Get other data
    $link = wppa_get_imglnk_a($type, $id);
    $isthumb = strpos($type, 'thumb') !== false;
    $file = wppa_fix_poster_ext($isthumb ? wppa_get_thumb_path($id) : wppa_get_photo_path($id), $id);
    $href = wppa_fix_poster_ext($isthumb ? wppa_get_thumb_url($id) : wppa_get_photo_url($id), $id);
    $autocol = wppa('auto_colwidth') || wppa('fullsize') > 0 && wppa('fullsize') <= 1.0;
    $title = $link ? esc_attr($link['title']) : esc_attr(stripslashes(wppa_get_photo_name($id)));
    $alt = wppa_get_imgalt($id);
    // Find image style
    switch ($type) {
        case 'sphoto':
            $style = 'width:100%;margin:0;';
            if (!wppa_in_widget()) {
                switch (wppa_opt('fullimage_border_width')) {
                    case '':
                        $style .= 'padding:0;' . 'border:none;';
                        break;
                    case '0':
                        $style .= 'padding:0;' . 'border:1px solid ' . wppa_opt('bcolor_fullimg') . ';' . 'box-sizing:border-box;';
                        break;
                    default:
                        $style .= 'padding:' . (wppa_opt('fullimage_border_width') - '1') . 'px;' . 'border:1px solid ' . wppa_opt('bcolor_fullimg') . ';' . 'box-sizing:border-box;' . 'background-color:' . wppa_opt('bgcolor_fullimg') . ';';
                        // If we do round corners...
                        if (wppa_opt('bradius') > '0') {
                            // then also here
                            $style .= 'border-radius:' . wppa_opt('fullimage_border_width') . 'px;';
                        }
                }
            }
            break;
        case 'mphoto':
        case 'xphoto':
            $style = 'width:100%;margin:0;padding:0;border:none;';
            break;
        default:
            wppa_dbg_msg('Style for type ' . $type . ' is not implemented yet in wppa_get_picture_html()', 'red', 'force');
            return false;
    }
    if ($link['is_lightbox']) {
        $style .= 'cursor:url( ' . wppa_get_imgdir() . wppa_opt('magnifier') . ' ),pointer;';
        $title = wppa_zoom_in($id);
    }
    // Create the html
    $result = '';
    // The link
    if ($link) {
        // Link is lightbox
        if ($link['is_lightbox']) {
            $lbtitle = wppa_get_lbtitle($type, $id);
            $videobody = esc_attr(wppa_get_video_body($id));
            $audiobody = esc_attr(wppa_get_audio_body($id));
            $videox = wppa_get_videox($id);
            $videoy = wppa_get_videoy($id);
            $result .= '<a' . ' href="' . $link['url'] . '"' . ($lbtitle ? ' ' . wppa('lbtitle') . '="' . $lbtitle . '"' : '') . ($videobody ? ' data-videohtml="' . $videobody . '"' : '') . ($audiobody ? ' data-audiohtml="' . $audiobody . '"' : '') . ($videox ? ' data-videonatwidth="' . $videox . '"' : '') . ($videoy ? ' data-videonatheight="' . $videoy . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '"' . ($link['target'] ? ' target="' . $link['target'] . '"' : '') . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"' . ' >';
        } else {
            $result .= '<a' . (wppa_is_mobile() ? ' ontouchstart="wppaStartTime();" ontouchend="wppaTapLink(\'' . $id . '\',\'' . $link['url'] . '\');" ' : ' onclick="_bumpClickCount( \'' . $id . '\' );window.open(\'' . $link['url'] . '\', \'' . $link['target'] . '\' )"') . ' title="' . $link['title'] . '"' . ' class="thumb-img"' . ' id="a-' . $id . '-' . wppa('mocc') . '"' . ' >';
        }
    }
    // The image
    // Video?
    if (wppa_is_video($id)) {
        $result .= wppa_get_video_html(array('id' => $id, 'controls' => !$link, 'style' => $style, 'class' => $class));
    } else {
        $result .= '<img' . ' id="ph-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $href . '"' . ' ' . wppa_get_imgalt($id) . ($class ? ' class="' . $class . '" ' : '') . ($title ? ' title="' . $title . '" ' : '') . ' style="' . $style . '"' . ' />';
    }
    // Close the link
    if ($link) {
        $result .= '</a>';
    }
    // Add audio?			sphoto
    if (wppa_has_audio($id)) {
        $result .= '<div style="position:relative;z-index:11;" >';
        // Find style for audio controls
        switch ($type) {
            case 'sphoto':
                $pad = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') + 1;
                $bot = wppa_opt('fullimage_border_width') === '' ? 0 : wppa_opt('fullimage_border_width') - 1;
                $style = 'margin:0;' . 'padding:0 ' . $pad . 'px;' . 'bottom:' . $bot . 'px;';
                $class = 'size-medium wppa-sphoto wppa-sphoto-' . wppa('mocc');
                break;
            case 'mphoto':
            case 'xphoto':
                $style = 'margin:0;' . 'padding:0;' . 'bottom:0;';
                $class = 'size-medium wppa-' . $type . ' wppa-' . $type . '-' . wppa('mocc');
                break;
            default:
                $style = 'margin:0;' . 'padding:0;';
                $class = '';
        }
        // Get the html for audio
        $result .= wppa_get_audio_html(array('id' => $id, 'cursor' => 'cursor:pointer;', 'style' => $style . 'position:absolute;' . 'box-sizing:border-box;' . 'width:100%;' . 'border:none;' . 'height:' . wppa_get_audio_control_height() . 'px;' . 'border-radius:0;', 'class' => $class));
        $result .= '</div>';
    }
    // Update statistics
    if (!wppa_in_widget()) {
        wppa_bump_viewcount('photo', $id);
    }
    // Done !
    return $result;
}
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>';
}