Пример #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;
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'topten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'medalsonly' => 'no', 'showowner' => 'no', 'showalbum' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('topten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('topten_widget_linkpage', __('Top Ten Photos', 'wp-photo-album-plus'));
     $albumlinkpage = wppa_get_the_landing_page('topten_widget_album_linkpage', __('Top Ten Photo album', 'wp-photo-album-plus'));
     $max = wppa_opt('topten_count');
     $album = $instance['album'];
     switch ($instance['sortby']) {
         case 'mean_rating':
             $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
             break;
         case 'rating_count':
             $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
             break;
         case 'views':
             $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
             break;
     }
     $display = $instance['display'];
     $meanrat = $instance['meanrat'] == 'yes';
     $ratcount = $instance['ratcount'] == 'yes';
     $viewcount = $instance['viewcount'] == 'yes';
     $includesubs = $instance['includesubs'] == 'yes';
     $albenum = '';
     $medalsonly = $instance['medalsonly'] == 'yes';
     $showowner = $instance['showowner'] == 'yes';
     $showalbum = $instance['showalbum'] == 'yes';
     wppa('medals_only', $medalsonly);
     $likes = wppa_opt('rating_display_type') == 'likes';
     // When likes only, mean rating has no meaning, chan to (rating)(like)count
     if ($likes && $instance['sortby'] == 'mean_rating') {
         $instance['sortby'] = 'rating_count';
     }
     // Album specified?
     if ($album) {
         // All albums ?
         if ($album == '-2') {
             $album = '0';
         }
         // Albums of owner is current logged in user or public?
         if ($album == '-3') {
             $temp = $wpdb->get_results("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `owner` = '--- public ---' OR `owner` = '" . wppa_get_user() . "' ORDER BY `id`", ARRAY_A);
             $album = '';
             if ($temp) {
                 foreach ($temp as $t) {
                     $album .= '.' . $t['id'];
                 }
                 $album = ltrim($album, '.');
             }
         }
         // Including subalbums?
         if ($includesubs) {
             $albenum = wppa_alb_to_enum_children($album);
             $albenum = wppa_expand_enum($albenum);
             $album = str_replace('.', ',', $albenum);
         }
         // Doit
         if ($medalsonly) {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN (" . $album . ") " . "AND `status` IN ( 'gold', 'silver', 'bronze' ) " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         } else {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` IN (" . $album . ") " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         }
     } else {
         if ($medalsonly) {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` IN ( 'gold', 'silver', 'bronze' ) " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         } else {
             $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` " . "ORDER BY " . $sortby . " " . "LIMIT " . $max, ARRAY_A);
         }
     }
     $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->';
     $maxw = wppa_opt('topten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($meanrat) {
         $maxh += $lineheight;
     }
     if ($ratcount) {
         $maxh += $lineheight;
     }
     if ($viewcount) {
         $maxh += $lineheight;
     }
     if ($showowner) {
         $maxh += $lineheight;
     }
     if ($showalbum) {
         $maxh += $lineheight;
     }
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the top rated photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $compressed_albumenum = wppa_compress_enum($albenum);
                 $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('topten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 // Display (owner) ?
                 if ($showowner) {
                     $widget_content .= '<div>(' . $image['owner'] . ')</div>';
                 }
                 // Display (album) ?
                 if ($showalbum) {
                     $href = wppa_convert_to_pretty(wppa_encrypt_url(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1')));
                     $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>';
                 }
                 // Display the rating
                 if ($likes) {
                     $lt = wppa_get_like_title_a($image['id']);
                 }
                 switch ($instance['sortby']) {
                     case 'mean_rating':
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         break;
                     case 'rating_count':
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . ($likes ? $lt['display'] : sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n)) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         break;
                     case 'views':
                         if ($viewcount == 'yes') {
                             $n = $image['views'];
                             $widget_content .= '<div>' . sprintf(_n('%d view', '%d views', $n, 'wp-photo-album-plus'), $n) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $n = wppa_get_rating_count_by_id($image['id']);
                             $widget_content .= '<div>' . ($likes ? $lt['display'] : sprintf(_n('%d vote', '%d votes', $n, 'wp-photo-album-plus'), $n)) . '</div>';
                         }
                         break;
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= __('There are no rated photos (yet)', 'wp-photo-album-plus');
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     //wppa( 'in_widget', false );
     wppa_reset_occurrance();
 }
Пример #3
0
function wppa_breadcrumb($opt = '')
{
    global $wpdb;
    global $wppa_session;
    // See if they need us
    // Check Table II-A1 a and b
    if ($opt == 'optional') {
        $pid = wppa_get_the_page_id();
        $type = $wpdb->get_var($wpdb->prepare("SELECT `post_type` FROM `" . $wpdb->posts . "` WHERE `ID` = %s", $pid));
        wppa_dbg_q('Q-bc1');
        if ($type == 'post' && !wppa_switch('show_bread_posts')) {
            return;
            // Nothing to do here
        }
        if ($type != 'post' && !wppa_switch('show_bread_pages')) {
            return;
            // Nothing to do here
        }
    }
    // Check special cases
    if (wppa('is_single')) {
        return;
    }
    // A single image slideshow needs no navigation
    if (wppa_page('oneofone')) {
        return;
    }
    // Never at a single image page
    if (wppa('is_slideonly')) {
        return;
    }
    // Not when slideonly
    if (wppa_in_widget()) {
        return;
    }
    // Not in a widget
    if (is_feed()) {
        return;
    }
    // Not in a feed
    $thumbhref = '';
    // Any special selection has its own switch
    if (wppa('is_topten') && !wppa_switch('bc_on_topten')) {
        return;
    }
    if (wppa('is_lasten') && !wppa_switch('bc_on_lasten')) {
        return;
    }
    if (wppa('is_comten') && !wppa_switch('bc_on_comten')) {
        return;
    }
    if (wppa('is_featen') && !wppa_switch('bc_on_featen')) {
        return;
    }
    if (wppa('is_related') && !wppa_switch('bc_on_related')) {
        return;
    }
    if (wppa('is_tag') && !wppa_switch('bc_on_tag')) {
        return;
    }
    if (wppa('src') && !wppa_switch('bc_on_search')) {
        return;
    }
    // Get the album number
    $alb = wppa_is_int(wppa('start_album')) ? wppa('start_album') : '0';
    // A single album or all ( all = 0 here )
    $is_albenum = strlen(wppa('start_album')) > '0' && !wppa_is_int(wppa('start_album'));
    wppa_dbg_msg('alb=' . $alb . ', albenum=' . $is_albenum, 'green');
    $virtual = wppa_is_virtual() || wppa('last_albums');
    if (wppa('last_albums')) {
        $alb = wppa('last_albums_parent');
    }
    wppa_dbg_msg('alb=' . $alb . ', albenum=' . $is_albenum . ', l_a=' . wppa('last_albums') . ', l_a_p=' . wppa('last_albums_parent'), 'green');
    // See if the album is a 'stand alone' album
    $separate = wppa_is_separate($alb);
    // See if the album links to slides in stead of thumbnails
    $slide = wppa_get_album_title_linktype($alb) == 'slide' ? '&amp;wppa-slide' : '';
    // See if we link to covers or to contents
    $to_cover = wppa_opt('thumbtype') == 'none' ? '1' : '0';
    // Photo number?
    $photo = wppa('start_photo');
    wppa_dbg_msg('pid=' . $pid . ', type=' . $type . ', alb=' . $alb . ', sep=' . $separate . ', slide=' . $slide . ', t_c=0, ph=' . $photo, 'green');
    // Open the breadcrumb box
    wppa_out('<div' . ' id="wppa-bc-' . wppa('mocc') . '"' . ' class="wppa-nav wppa-box wppa-nav-text" ' . 'style="' . __wcs('wppa-nav') . __wcs('wppa-box') . __wcs('wppa-nav-text') . '" >');
    // Do we need Home?
    if (wppa_switch('show_home')) {
        $value = __(wppa_opt('home_text'));
        $href = wppa_dbg_url(get_bloginfo('url'));
        $title = get_bloginfo('title');
        wppa_bcitem($value, $href, $title, 'b1');
    }
    // Page ( grand )parents ?
    if ($type == 'page' && wppa_switch('show_page')) {
        wppa_crumb_page_ancestors($pid);
    }
    // Do the post/page
    if (wppa_switch('show_page')) {
        $value = __(stripslashes($wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `ID` = %s LIMIT 0,1", $pid))));
        wppa_dbg_q('Q-bc2');
        $href = $alb || $virtual || $is_albenum ? wppa_get_permalink($pid, true) : '';
        $title = $type == 'post' ? __('Post:', 'wp-photo-album-plus') . ' ' . $value : __('Page:', 'wp-photo-album-plus') . ' ' . $value;
        wppa_bcitem($value, $href, $title, 'b3');
    }
    // The album ( grand ) parents if not separate
    //		if ( ! $separate ) {
    wppa_crumb_ancestors($alb, $to_cover);
    //		}
    // The album and optional placeholder for photo
    // Supersearch ?
    if (wppa('supersearch')) {
        $value = ' ';
        $ss_data = explode(',', wppa('supersearch'));
        switch ($ss_data['0']) {
            case 'a':
                $value .= ' ' . __('Albums', 'wp-photo-album-plus');
                switch ($ss_data['1']) {
                    case 'c':
                        $value .= ' ' . __('with category:', 'wp-photo-album-plus');
                        break;
                    case 'n':
                        $value .= ' ' . __('with name:', 'wp-photo-album-plus');
                        break;
                    case 't':
                        $value .= ' ' . __('with words:', 'wp-photo-album-plus');
                        break;
                }
                $value .= ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                break;
            case 'p':
                $value .= ' ' . __('Photos', 'wp-photo-album-plus');
                switch ($ss_data['1']) {
                    case 'g':
                        $value .= ' ' . __('with tag:', 'wp-photo-album-plus') . ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                        break;
                    case 'n':
                        $value .= ' ' . __('with name:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 't':
                        $ss_data['3'] = str_replace('...', '***', $ss_data['3']);
                        $value .= ' ' . __('with words:', 'wp-photo-album-plus') . ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                        $value = str_replace('***', '...', $value);
                        break;
                    case 'o':
                        $value .= ' ' . __('of owner:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 'i':
                        $label = $wpdb->get_var($wpdb->prepare("SELECT `description` FROM `" . WPPA_IPTC . "` WHERE `tag` = %s AND `photo` = '0'", str_replace('H', '#', $ss_data['2'])));
                        $label = trim($label, ':');
                        $value .= ' ' . __('with iptc tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 'e':
                        $label = $wpdb->get_var($wpdb->prepare("SELECT `description` FROM `" . WPPA_EXIF . "` WHERE `tag` = %s AND `photo` = '0'", str_replace('H', '#', $ss_data['2'])));
                        $label = trim($label, ':');
                        $value .= ' ' . __('with exif tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                }
                break;
        }
        if (wppa('is_slide')) {
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-supersearch=' . stripslashes(wppa('supersearch'));
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-supersearch=' . stripslashes(wppa('supersearch'));
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('src') && !wppa('is_related')) {
        $searchroot = $wppa_session['search_root'];
        if (!$searchroot) {
            $searchroot = '-2';
            // To get 'All albums'
        }
        $albtxt = wppa('is_rootsearch') ? ' <span style="cursor:pointer;" title="' . esc_attr(sprintf(__('Searchresults from album %s and its subalbums', 'wp-photo-album-plus'), wppa_display_root($searchroot))) . '">*</span> ' : '';
        if (wppa('is_slide')) {
            $value = __('Searchstring:', 'wp-photo-album-plus') . ' ' . (isset($wppa_session['display_searchstring']) ? $wppa_session['display_searchstring'] : stripslashes(wppa('searchstring'))) . $albtxt;
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-searchstring=' . stripslashes(str_replace(' ', '+', $wppa_session['use_searchstring']));
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-searchstring=' . stripslashes(str_replace(' ', '+', $wppa_session['use_searchstring']));
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Searchstring:', 'wp-photo-album-plus') . ' ' . (isset($wppa_session['display_searchstring']) ? $wppa_session['display_searchstring'] : stripslashes(wppa('searchstring'))) . $albtxt;
        $href = '';
        $title = isset($wppa_session['display_searchstring']) ? wppa_dss_to_title($wppa_session['display_searchstring']) : '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('calendar')) {
        if (wppa('is_slide')) {
            switch (wppa('calendar')) {
                case 'exifdtm':
                    $value = __('Photos by EXIF date', 'wp-photo-album-plus') . ': ' . wppa('caldate');
                    break;
                case 'timestamp':
                    $value = __('Photos by date of upload', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                    break;
                case 'modified':
                    $value = __('Photos by date last modified', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                    break;
            }
            $thumbhref = '#';
            $title = 'T8';
            wppa_bcitem($value, $thumbhref, $title, 'b8');
        }
        switch (wppa('calendar')) {
            case 'exifdtm':
                $value = __('Photos by EXIF date', 'wp-photo-album-plus') . ': ' . wppa('caldate');
                break;
            case 'timestamp':
                $value = __('Photos by date of upload', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                break;
            case 'modified':
                $value = __('Photos by date last modified', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                break;
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_upldr')) {
        $usr = get_user_by('login', wppa('is_upldr'));
        if ($usr) {
            $user = $usr->display_name;
        } else {
            $user = wppa('is_upldr');
        }
        if (wppa('is_slide')) {
            $value = sprintf(__('Photos by %s', 'wp-photo-album-plus'), $user);
            if (wppa('start_album')) {
                $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr') . '&amp;wppa-album=' . wppa('start_album');
                $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr') . '&amp;wppa-album=' . wppa('start_album');
            } else {
                $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr');
                $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr');
            }
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = sprintf(__('Photos by %s', 'wp-photo-album-plus'), $user);
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_topten')) {
        // TopTen
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Top rated photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-topten=' . wppa('topten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-topten=' . wppa('topten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Top rated photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_lasten')) {
        // Lasten
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            if (wppa_switch('lasten_use_modified')) {
                $value = __('Recently modified photos', 'wp-photo-album-plus');
            } else {
                $value = __('Recently uploaded photos', 'wp-photo-album-plus');
            }
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-lasten=' . wppa('lasten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-lasten=' . wppa('lasten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        if (wppa_switch('lasten_use_modified')) {
            $value = __('Recently modified photos', 'wp-photo-album-plus');
        } else {
            $value = __('Recently uploaded photos', 'wp-photo-album-plus');
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_comten')) {
        // Comten
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Recently commented photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-comten=' . wppa('comten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-comten=' . wppa('comten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Recently commented photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_featen')) {
        // Featen
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Featured photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-featen=' . wppa('featen_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-featen=' . wppa('featen_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Featured photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_related')) {
        // Related photos
        if (wppa('is_slide')) {
            $value = __('Related photos', 'wp-photo-album-plus');
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $href, $title, 'b8', $ajax);
        }
        $value = __('Related photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_tag')) {
        // Tagged photos
        if (wppa('is_slide')) {
            $value = __('Tagged photos:', 'wp-photo-album-plus') . '&nbsp;' . str_replace(';', ' ' . __('or', 'wp-photo-album-plus') . ' ', str_replace(',', ' ' . __('and', 'wp-photo-album-plus') . ' ', trim(wppa('is_tag'), ',;')));
            if (wppa_get_get('inv')) {
                $value .= ' (' . __('Inverted', 'wp-photo-album-plus') . ')';
            }
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            if (wppa('is_inverse')) {
                $thumbhref .= '&amp;wppa-inv=1';
                $thumbajax .= '&amp;wppa-inv=1';
            }
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Tagged photos:', 'wp-photo-album-plus') . '&nbsp;' . str_replace(';', ' ' . __('or', 'wp-photo-album-plus') . ' ', str_replace(',', ' ' . __('and', 'wp-photo-album-plus') . ' ', trim(wppa('is_tag'), ',;')));
        if (wppa_get_get('inv')) {
            $value .= ' (' . __('Inverted', 'wp-photo-album-plus') . ')';
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_cat')) {
        // Categorized albums
        if (wppa('is_slide')) {
            $value = __('Category:', 'wp-photo-album-plus') . '&nbsp;' . wppa('is_cat');
            //str_replace( ';', ' '.__( 'or' ).' ', str_replace( ',', ' '.__( 'and' ).' ', trim( wppa( 'is_tag' ), ',;' ) ) );
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-cat=' . wppa('is_cat') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-cat=' . wppa('is_cat') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Category:', 'wp-photo-album-plus') . '&nbsp;' . wppa('is_cat');
        //str_replace( ';', ' '.__( 'or' ).' ', str_replace( ',', ' '.__( 'and' ).' ', trim( wppa( 'is_tag' ), ',;' ) ) );
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('last_albums')) {
        // Recently modified albums( s )
        if (wppa('last_albums_parent')) {
            $value = wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Recently updated albums', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Recently updated albums', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } else {
        // Maybe a simple normal standard album???
        if (wppa('is_owner')) {
            $usr = get_user_by('login', wppa('is_owner'));
            if ($usr) {
                $dispname = $usr->display_name;
            } else {
                $dispname = wppa('is_owner');
            }
            // User deleted
            $various = sprintf(__('Various albums by %s', 'wp-photo-album-plus'), $dispname);
        } else {
            $various = __('Various albums', 'wp-photo-album-plus');
        }
        if (wppa('is_slide')) {
            $value = $is_albenum ? $various : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        $value = $is_albenum ? $various : wppa_get_album_name($alb);
        $href = '';
        $title = '';
        $class = 'b10';
        wppa_bcitem($value, $href, $title, $class);
    }
    // 'Go to thumbnail display' - icon
    if (wppa('is_slide') && !wppa('calendar')) {
        if (wppa_switch('bc_slide_thumblink')) {
            //				$pg = ( ( wppa_opt('thumb_page_size' ) == wppa_opt( 'slideshow_pagesize' ) ) && wppa_get_curpage() != '1' ) ? '&wppa-page='.wppa_get_curpage() : '';
            //				$thumbhref .= $pg;
            if ($virtual) {
                if ($thumbhref) {
                    $thumbhref = wppa_trim_wppa_($thumbhref);
                    $fs = wppa_opt('fontsize_nav');
                    if ($fs != '') {
                        $fs += 3;
                    } else {
                        $fs = '15';
                    }
                    // iconsize = fontsize+3, Default to 15
                    $imgs = 'height: ' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none;';
                    wppa_out('<a href="' . $thumbhref . '" title="' . __('Thumbnail view', 'wp-photo-album-plus') . '" class="wppa-nav-text" style="' . __wcs('wppa-nav-text') . 'float:right; cursor:pointer;" ' . 'onmouseover="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'none\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'\')" ' . 'onmouseout="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'none\')" >' . '<img id="wppa-tnv-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="' . $imgs . '" />' . '<img id="wppa-tnvh-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons_hover.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="display:none;' . $imgs . '" />' . '</a>');
                }
            } else {
                $s = wppa('src') ? '&wppa-searchstring=' . urlencode(wppa('searchstring')) : '';
                $onclick = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax(wppa('start_album'), '0') . "&amp;wppa-photos-only=1" . $s . "', '" . wppa_convert_to_pretty(wppa_get_album_url(wppa('start_album'), '0') . '&wppa-photos-only=1' . $s) . "' )";
                $fs = wppa_opt('fontsize_nav');
                if ($fs != '') {
                    $fs += 3;
                } else {
                    $fs = '15';
                }
                // iconsize = fontsize+3, Default to 15
                $imgs = 'height: ' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none;';
                wppa_out('<a title="' . __('Thumbnail view', 'wp-photo-album-plus') . '" class="wppa-nav-text" style="' . __wcs('wppa-nav-text') . 'float:right; cursor:pointer;" ' . 'onclick="' . $onclick . '" ' . 'onmouseover="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'none\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'\')" ' . 'onmouseout="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'none\')" >' . '<img id="wppa-tnv-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="' . $imgs . '" />' . '<img id="wppa-tnvh-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons_hover.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="display:none;' . $imgs . '" />' . '</a>');
            }
        }
    }
    // Close the breadcrumb box
    wppa_out('<div style="clear:both;" ></div>');
    wppa_out('</div>');
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     require_once dirname(__FILE__) . '/wppa-links.php';
     require_once dirname(__FILE__) . '/wppa-styles.php';
     require_once dirname(__FILE__) . '/wppa-functions.php';
     require_once dirname(__FILE__) . '/wppa-thumbnails.php';
     require_once dirname(__FILE__) . '/wppa-boxes-html.php';
     require_once dirname(__FILE__) . '/wppa-slideshow.php';
     wppa_initialize_runtime();
     wppa('in_widget', 'topten');
     wppa_bump_mocc();
     extract($args);
     $instance = wp_parse_args((array) $instance, array('title' => '', 'sortby' => 'mean_rating', 'title' => '', 'album' => '', 'display' => 'thumbs', 'meanrat' => 'yes', 'ratcount' => 'yes', 'viewcount' => 'yes', 'includesubs' => 'yes', 'showowner' => 'no', 'showalbum' => 'no'));
     $widget_title = apply_filters('widget_title', $instance['title']);
     $page = in_array(wppa_opt('topten_widget_linktype'), wppa('links_no_page')) ? '' : wppa_get_the_landing_page('wppa_topten_widget_linkpage', __('Top Ten Photos', 'wp-photo-album-plus'));
     $albumlinkpage = wppa_get_the_landing_page('wppa_topten_widget_album_linkpage', __('Top Ten Photo album', 'wp-photo-album-plus'));
     $max = wppa_opt('topten_count');
     $album = $instance['album'];
     switch ($instance['sortby']) {
         case 'mean_rating':
             $sortby = '`mean_rating` DESC, `rating_count` DESC, `views` DESC';
             break;
         case 'rating_count':
             $sortby = '`rating_count` DESC, `mean_rating` DESC, `views` DESC';
             break;
         case 'views':
             $sortby = '`views` DESC, `mean_rating` DESC, `rating_count` DESC';
             break;
     }
     $display = $instance['display'];
     $meanrat = $instance['meanrat'] == 'yes';
     $ratcount = $instance['ratcount'] == 'yes';
     $viewcount = $instance['viewcount'] == 'yes';
     $includesubs = $instance['includesubs'] == 'yes';
     $albenum = '';
     $showowner = $instance['showowner'] == 'yes';
     $showalbum = $instance['showalbum'] == 'yes';
     if ($album) {
         if ($album == '-2') {
             $album = '0';
         }
         if ($includesubs) {
             $albenum = wppa_alb_to_enum_children($album);
             $albenum = wppa_expand_enum($albenum);
             $album = str_replace('.', ',', $albenum);
         }
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` IN (" . $album . ") ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A);
         //wppa_log('dbg', "SELECT * FROM `".WPPA_PHOTOS."` WHERE `album` IN (".$album.") ORDER BY " . $sortby . " LIMIT " . $max);
     } else {
         $thumbs = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY " . $sortby . " LIMIT " . $max, ARRAY_A);
     }
     $widget_content = "\n" . '<!-- WPPA+ TopTen Widget start -->';
     $maxw = wppa_opt('topten_size');
     $maxh = $maxw;
     $lineheight = wppa_opt('fontsize_widget_thumb') * 1.5;
     $maxh += $lineheight;
     if ($meanrat) {
         $maxh += $lineheight;
     }
     if ($ratcount) {
         $maxh += $lineheight;
     }
     if ($viewcount) {
         $maxh += $lineheight;
     }
     if ($showowner) {
         $maxh += $lineheight;
     }
     if ($showalbum) {
         $maxh += $lineheight;
     }
     if ($thumbs) {
         foreach ($thumbs as $image) {
             $thumb = $image;
             // Make the HTML for current picture
             if ($display == 'thumbs') {
                 $widget_content .= "\n" . '<div class="wppa-widget" style="width:' . $maxw . 'px; height:' . $maxh . 'px; margin:4px; display:inline; text-align:center; float:left;">';
             } else {
                 $widget_content .= "\n" . '<div class="wppa-widget" >';
             }
             if ($image) {
                 $no_album = !$album;
                 if ($no_album) {
                     $tit = __('View the top rated photos', 'wp-photo-album-plus');
                 } else {
                     $tit = esc_attr(__(stripslashes($image['description'])));
                 }
                 $compressed_albumenum = wppa_compress_enum($albenum);
                 $link = wppa_get_imglnk_a('topten', $image['id'], '', $tit, '', $no_album, $compressed_albumenum);
                 $file = wppa_get_thumb_path($image['id']);
                 $imgstyle_a = wppa_get_imgstyle_a($image['id'], $file, $maxw, 'center', 'ttthumb');
                 $imgurl = wppa_get_thumb_url($image['id'], '', $imgstyle_a['width'], $imgstyle_a['height']);
                 $imgevents = wppa_get_imgevents('thumb', $image['id'], true);
                 $title = $link ? esc_attr(stripslashes($link['title'])) : '';
                 $widget_content .= wppa_get_the_widget_thumb('topten', $image, $album, $display, $link, $title, $imgurl, $imgstyle_a, $imgevents);
                 $widget_content .= "\n\t" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px;">';
                 // Display (owner) ?
                 if ($showowner) {
                     $widget_content .= '<div>(' . $image['owner'] . ')</div>';
                 }
                 // Display (album) ?
                 if ($showalbum) {
                     $href = wppa_convert_to_pretty(wppa_get_album_url($image['album'], $albumlinkpage, 'content', '1'));
                     $widget_content .= '<div>(<a href="' . $href . '" >' . wppa_get_album_name($image['album']) . '</a>)</div>';
                 }
                 $rating = wppa_get_rating_by_id($image['id']);
                 switch ($instance['sortby']) {
                     case 'mean_rating':
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         break;
                     case 'rating_count':
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         break;
                     case 'views':
                         if ($viewcount == 'yes' && $image['views']) {
                             $widget_content .= '<div>' . sprintf(__('Views: %s times', 'wp-photo-album-plus'), $image['views']) . '</div>';
                         }
                         if ($meanrat == 'yes') {
                             $widget_content .= '<div>' . wppa_get_rating_by_id($image['id']) . '</div>';
                         }
                         if ($ratcount == 'yes') {
                             $widget_content .= '<div>' . sprintf(__('%s Votes', 'wp-photo-album-plus'), wppa_get_rating_count_by_id($image['id'])) . '</div>';
                         }
                         break;
                 }
                 $widget_content .= '</div>';
             } else {
                 // No image
                 $widget_content .= __('Photo not found.', 'wp-photo-album-plus');
             }
             $widget_content .= "\n" . '</div>';
         }
     } else {
         $widget_content .= 'There are no rated photos (yet).';
     }
     $widget_content .= '<div style="clear:both"></div>';
     $widget_content .= "\n" . '<!-- WPPA+ TopTen Widget end -->';
     echo "\n" . $before_widget;
     if (!empty($widget_title)) {
         echo $before_title . $widget_title . $after_title;
     }
     echo $widget_content . $after_widget;
     wppa('in_widget', false);
 }
function wppa_subalbumlinks_html($id, $top = true)
{
    global $wpdb;
    // Do they need us? Anything to display?
    if (wppa_opt('cover_sublinks_display') == 'none') {
        return;
    }
    // Display type
    $display_type = wppa_opt('cover_sublinks_display');
    // Link type
    $link_type = wppa_opt('cover_sublinks');
    // Init
    $is_list = $display_type == 'list' || $display_type == 'recursivelist';
    $is_recursive = $display_type == 'recursivelist';
    $first = true;
    // Get the children
    $subs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = " . $id . " " . wppa_get_album_order($id), ARRAY_A);
    // Only if there are sub-albums
    if (!empty($subs)) {
        wppa_out('<div>');
        // Local css
        if ($top) {
            if ($is_list) {
                wppa_out('<style scoped="scoped" >' . 'ul, li { margin:0; }' . 'ul {' . 'list-style-type:disc;' . 'list-style-position:inside;' . 'padding:0 0 0 24px;' . '}' . 'li { cursor:pointer; }' . '</style>');
            }
            if ($display_type == 'microthumbs') {
                wppa_out('<style scoped="scoped" >' . 'img {' . 'max-width:100px;' . 'max-height:50px;' . 'padding:1px;' . 'margin:1px;' . 'background-color:' . wppa_opt('bgcolor_img') . ';' . 'float:left;' . '}' . '</style>');
            }
        }
        // Start list if required
        if ($is_list) {
            wppa_out('<ul class="wppa-cover-sublink-list" style="clear:both;" >');
        } else {
            wppa_out('<div style="clear:both;" ></div>');
        }
        // Process the sub-albums
        foreach ($subs as $album) {
            // What is the albums title linktype
            $linktype = $album['cover_linktype'];
            if (!$linktype) {
                $linktype = 'content';
            }
            // Default
            // What is the albums title linkpage
            $linkpage = $album['cover_linkpage'];
            if ($linkpage == '-1') {
                $linktype = 'none';
            }
            // for backward compatibility
            // Find the content 'View' link
            $albumid = $album['id'];
            $photocount = wppa_get_photo_count($albumid, 'use_treecounts');
            // Thumbnails and covers, show sub-album covers
            // in case slideshow is requested on an empty album
            if (wppa_opt('cover_sublinks') == 'content' || !$photocount) {
                if (wppa_switch('allow_ajax') && !$linkpage) {
                    $href_content = '';
                    $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )";
                } else {
                    $href_content = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage));
                    $onclick_content = '';
                }
            } else {
                if (wppa_switch('allow_ajax') && !$linkpage) {
                    $href_content = '';
                    $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )";
                } else {
                    $href_content = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage));
                    $onclick_content = '';
                }
            }
            // Do the output
            $title = esc_attr(__('View the album', 'wp-photo-album-plus') . ': ' . wppa_get_album_name($album['id']));
            switch ($display_type) {
                case 'list':
                case 'recursivelist':
                    if ($link_type == 'none') {
                        wppa_out('<li>' . wppa_get_album_name($album['id']) . '</li>');
                    } else {
                        wppa_out('<li>' . '<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . wppa_get_album_name($album['id']) . '</a>' . '</li>');
                    }
                    break;
                case 'enum':
                    if (!$first) {
                        wppa_out(', ');
                    }
                    if ($link_type == 'none') {
                        wppa_out(wppa_get_album_name($album['id']));
                    } else {
                        wppa_out('<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . wppa_get_album_name($album['id']) . '</a>');
                    }
                    $first = false;
                    break;
                case 'microthumbs':
                    $coverphoto_id = wppa_get_coverphoto_id($album['id']);
                    $src = wppa_fix_poster_ext(wppa_get_thumb_url($coverphoto_id), $coverphoto_id);
                    if ($link_type == 'none') {
                        wppa_out('<img' . ' class="wppa-cover-sublink-img"' . ' src="' . $src . '"' . ' alt="' . wppa_get_album_name($album['id']) . '"' . ' />');
                    } else {
                        wppa_out('<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . '<img' . ' class="wppa-cover-sublink-img"' . ' src="' . $src . '"' . ' alt="' . wppa_get_album_name($album['id']) . '"' . ' />' . '</a>');
                    }
                    break;
            }
            // Go deeper for grandchildren
            if ($is_recursive) {
                wppa_subalbumlinks_html($album['id'], false);
            }
        }
        // End list
        if ($is_list) {
            wppa_out('</ul>');
        }
        wppa_out('</div>');
    }
}
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     global $wpdb;
     wppa('in_widget', 'potd');
     wppa_bump_mocc();
     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();
     extract($args);
     $widget_title = apply_filters('widget_title', $instance['title']);
     // get the photo  ($image)
     $image = wppa_get_potd();
     // Make the HTML for current picture
     $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->';
     $ali = wppa_opt('potd_align');
     if ($ali != 'none') {
         $align = 'text-align:' . $ali . ';';
     } else {
         $align = '';
     }
     $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px;position:relative;" >';
     if ($image) {
         $id = $image['id'];
         $w = wppa_opt('potd_widget_width');
         $ratio = wppa_get_photoy($id) / wppa_get_photox($id);
         $h = round($w * $ratio);
         $usethumb = wppa_use_thumb_file($id, wppa_opt('potd_widget_width'), '0');
         $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id);
         $name = wppa_get_photo_name($id);
         $page = in_array(wppa_opt('potd_linktype'), wppa('links_no_page')) && !wppa_switch('potd_counter') ? '' : wppa_get_the_landing_page('potd_linkpage', __('Photo of the day', 'wp-photo-album-plus'));
         $link = wppa_get_imglnk_a('potdwidget', $id);
         $is_video = wppa_is_video($id);
         $has_audio = wppa_has_audio($id);
         if ($link['is_lightbox']) {
             $lightbox = ($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') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"';
         } else {
             $lightbox = '';
         }
         if ($link) {
             if ($link['is_lightbox']) {
                 $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('magnifier') . '),pointer;';
                 $title = wppa_zoom_in($id);
                 $ltitle = wppa_get_lbtitle('potd', $id);
             } else {
                 $cursor = ' cursor:pointer;';
                 $title = $link['title'];
                 $ltitle = $title;
             }
         } else {
             $cursor = ' cursor:default;';
             $title = esc_attr(stripslashes(__($image['name'], 'wp-photo-album-plus')));
         }
         // The medal if on top
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top'));
         // The link, if any
         if ($link) {
             $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">';
         }
         // The image
         if (wppa_is_video($id)) {
             $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('potd_linktype') == 'none', 'cursor' => $cursor));
         } else {
             $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . ' />';
         }
         // Close the link
         if ($link) {
             $widget_content .= '</a>';
         }
         // The medal if at the bottom
         $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot'));
         // The counter
         if (wppa_switch('potd_counter')) {
             // If we want this
             $alb = wppa_get_photo_item($id, 'album');
             $c = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = " . $alb) - 1;
             if ($c > 0) {
                 if (wppa_opt('potd_counter_link') == 'thumbs') {
                     $lnk = wppa_get_album_url($alb, $page, 'thumbs', '1');
                 } elseif (wppa_opt('potd_counter_link') == 'slide') {
                     $lnk = wppa_get_slideshow_url($alb, $page, $id, '1');
                 } elseif (wppa_opt('potd_counter_link') == 'single') {
                     $lnk = wppa_encrypt_url(get_permalink($page) . '?occur=1&photo=' . $id);
                     //	wppa_get_image_page_url_by_id( $id, true, false, $page );
                 } else {
                     wppa_log('Err', 'Unimplemented counter link type in wppa-potd-widget: ' . wppa_opt('potd_counter_link'));
                 }
                 $widget_content .= '<a href="' . $lnk . '" >' . '<div style="font-size:12px;position:absolute;right:4px;bottom:4px;" >+' . $c . '</div>' . '</a>';
             }
         }
         // Audio
         if (wppa_has_audio($id)) {
             $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'controls' => true));
         }
     } else {
         // No image
         $widget_content .= __('Photo not found', 'wp-photo-album-plus');
     }
     $widget_content .= "\n" . '</div>';
     // Add subtitle, if any
     if ($image) {
         switch (wppa_opt('potd_subtitle')) {
             case 'none':
                 break;
             case 'name':
                 $widget_content .= '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>';
                 break;
             case 'desc':
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>';
                 break;
             case 'owner':
                 $owner = $image['owner'];
                 $user = get_user_by('login', $owner);
                 $owner = $user->display_name;
                 $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __('By:', 'wp-photo-album-plus') . ' ' . $owner . '</div>';
                 break;
             default:
                 wppa_log('Err', 'Unimplemented potd_subtitle found in wppa-potd-widget: ' . wppa_opt('potd_subtitle'));
         }
     }
     $widget_content .= '<div style="clear:both;" ></div>';
     $widget_content .= "\n" . '<!-- WPPA+ Photo of the day 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);
 }
Пример #7
0
function wppa_get_album_title_attr_a($albumid, $linktype, $linkpage, $has_content, $coverphoto, $photocount)
{
    global $wppa;
    $album = wppa_cache_album($albumid);
    // Init
    $href_title = '';
    $onclick_title = '';
    $title_title = '';
    // Dispatch on linktype when page is not current
    if ($linkpage > 0) {
        switch ($linktype) {
            case 'content':
            case 'thumbs':
            case 'albums':
                if ($has_content) {
                    $href_title = wppa_get_album_url($albumid, $linkpage, $linktype);
                } else {
                    $href_title = get_page_link($album['cover_linkpage']);
                }
                break;
            case 'slide':
                if ($has_content) {
                    $href_title = wppa_get_slideshow_url($albumid, $linkpage);
                } else {
                    $href_title = get_page_link($album['cover_linkpage']);
                }
                break;
            case 'page':
                $href_title = get_page_link($album['cover_linkpage']);
                break;
            case 'none':
                break;
            default:
        }
        $href_title = wppa_convert_to_pretty($href_title);
        $title_title = __a('Link to');
        $title_title .= ' ' . __(get_the_title($album['cover_linkpage']));
    } elseif ($has_content) {
        switch ($linktype) {
            case 'content':
            case 'thumbs':
            case 'albums':
                $href_title = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage, $linktype));
                if (wppa_switch('wppa_allow_ajax')) {
                    $onclick_title = "wppaDoAjaxRender( " . $wppa['mocc'] . ", '" . wppa_get_album_url_ajax($albumid, $linkpage, $linktype) . "', '" . $href_title . "' )";
                    $href_title = "#";
                }
                break;
            case 'slide':
                $href_title = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage));
                if (wppa_switch('wppa_allow_ajax')) {
                    $onclick_title = "wppaDoAjaxRender( " . $wppa['mocc'] . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage, $linktype) . "', '" . $href_title . "' )";
                    $href_title = "#";
                }
                break;
            case 'none':
                break;
            default:
        }
        $title_title = __a('View the album') . ' ' . esc_attr(wppa_qtrans(stripslashes($album['name'])));
    } else {
        // No content on current page/post
        if ($photocount > '0') {
            // coverphotos only
            if ($coverphoto) {
                $href_title = wppa_convert_to_pretty(wppa_get_image_page_url_by_id($coverphoto));
            } else {
                $href_title = '#';
            }
            if (wppa_switch('wppa_allow_ajax')) {
                if ($coverphoto) {
                    $onclick_title = "wppaDoAjaxRender( " . $wppa['mocc'] . ", '" . wppa_get_image_url_ajax_by_id($coverphoto) . "', '" . $href_title . "' )";
                } else {
                    $onclick_title = '';
                }
                $href_title = "#";
            }
            if ($photocount == '1') {
                $title_title = __a('View the cover photo');
            } else {
                $title_title = __a('View the cover photos');
            }
        }
    }
    $title_attr['href'] = $href_title;
    $title_attr['onclick'] = $onclick_title;
    $title_attr['title'] = $title_title;
    return $title_attr;
}