Exemple #1
0
function wppa_share($opt = '')
{
    if (is_feed()) {
        return;
    }
    $do_it = false;
    if ($opt != 'optional') {
        $do_it = true;
    }
    if (!wppa('is_slideonly')) {
        if (wppa_switch('share_on') && !wppa_in_widget()) {
            $do_it = true;
        }
        if (wppa_switch('share_on_widget') && wppa_in_widget()) {
            $do_it = true;
        }
    }
    if ($do_it) {
        wppa_out('<div' . ' id="wppa-share-' . wppa('mocc') . '"' . ' class="wppa-box wppa-box-text wppa-share"' . ' style="text-align: center; ' . __wcs('wppa-box') . __wcs('wppa-box-text') . __wcs('wppa-share') . '"' . ' >' . '</div>');
    }
}
Exemple #2
0
function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '')
{
    global $wpdb;
    // make sure the photo data ia available
    $thumb = wppa_cache_thumb($id);
    if (!$thumb) {
        return false;
    }
    // Is it a video?
    $is_video = wppa_is_video($id, true);
    // Photo Specific Overrule?
    if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) {
        // Look for a photo specific link
        if ($thumb) {
            // If it is there...
            if ($thumb['linkurl']) {
                // Use it. It superceeds other settings
                $result['url'] = esc_attr($thumb['linkurl']);
                $result['title'] = esc_attr(__(stripslashes($thumb['linktitle'])));
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                $result['onclick'] = '';
                $result['target'] = $thumb['linktarget'];
                return $result;
            }
        }
    }
    $result['target'] = '_self';
    $result['title'] = '';
    $result['onclick'] = '';
    switch ($wich) {
        case 'sphoto':
            $type = wppa_opt('sphoto_linktype');
            $page = wppa_opt('sphoto_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('sphoto_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'mphoto':
            $type = wppa_opt('mphoto_linktype');
            $page = wppa_opt('mphoto_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('mphoto_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'thumb':
            $type = wppa_opt('thumb_linktype');
            $page = wppa_opt('thumb_linkpage');
            if (wppa_switch('thumb_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'topten':
            $type = wppa_opt('topten_widget_linktype');
            $page = wppa_opt('topten_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('topten_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'featen':
            $type = wppa_opt('featen_widget_linktype');
            $page = wppa_opt('featen_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('featen_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'lasten':
            $type = wppa_opt('lasten_widget_linktype');
            $page = wppa_opt('lasten_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('lasten_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'comten':
            $type = wppa_opt('comment_widget_linktype');
            $page = wppa_opt('comment_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('comment_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'sswidget':
            $type = wppa_opt('slideonly_widget_linktype');
            $page = wppa_opt('slideonly_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('sswidget_blank')) {
                $result['target'] = '_blank';
            }
            $result['url'] = '';
            if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') {
                $result['title'] = wppa_zoom_in($id);
                $result['target'] = '';
                return $result;
            }
            break;
        case 'potdwidget':
            $type = wppa_opt('widget_linktype');
            $page = wppa_opt('widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('potd_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'coverimg':
            $type = wppa_opt('coverimg_linktype');
            $page = wppa_opt('coverimg_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('coverimg_blank')) {
                $result['target'] = '_blank';
            }
            if ($type == 'slideshowstartatimage') {
                $result['url'] = wppa_get_slideshow_url($album, $page, $id);
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                return $result;
            }
            break;
        case 'tnwidget':
            $type = wppa_opt('thumbnail_widget_linktype');
            $page = wppa_opt('thumbnail_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('thumbnail_widget_blank')) {
                $result['target'] = '_blank';
            }
            break;
        case 'slideshow':
            $type = wppa_opt('slideshow_linktype');
            //'';
            $page = wppa_opt('slideshow_linkpage');
            $result['url'] = '';
            if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') {
                $result['title'] = wppa_zoom_in($id);
                $result['target'] = '';
                return $result;
            }
            if ($type == 'thumbs') {
                $result['url'] = wppa_get_ss_to_tn_link($page, $id);
                $result['title'] = __('View thumbnails', 'wp-photo-album-plus');
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                if (wppa_switch('slideshow_blank')) {
                    $result['target'] = '_blank';
                }
                return $result;
            }
            if ($type == 'none') {
                return;
            }
            // Continue for 'single'
            break;
        case 'albwidget':
            $type = wppa_opt('album_widget_linktype');
            $page = wppa_opt('album_widget_linkpage');
            if ($page == '0') {
                $page = '-1';
            }
            if (wppa_switch('album_widget_blank')) {
                $result['target'] = '_blank';
            }
            break;
        default:
            return false;
            break;
    }
    if (!$album) {
        $album = wppa('start_album');
    }
    if ($album == '' && !wppa('is_upldr')) {
        /**/
        $album = wppa_get_album_id_by_photo_id($id);
    }
    if (is_numeric($album)) {
        $album_name = wppa_get_album_name($album);
    } else {
        $album_name = '';
    }
    if (!$album) {
        $album = '0';
    }
    if ($wich == 'comten') {
        $album = '0';
    }
    if (wppa('is_tag')) {
        $album = '0';
    }
    if (wppa('supersearch')) {
        $album = '0';
    }
    if (wppa('calendar')) {
        $album = wppa('start_album') ? wppa('start_album') : '0';
    }
    //	if ( wppa( 'is_upldr' ) ) $album = '0';	// probeersel upldr parent
    if ($id) {
        $photo_name = wppa_get_photo_name($id);
    } else {
        $photo_name = '';
    }
    $photo_name_js = esc_js($photo_name);
    $photo_name = esc_attr($photo_name);
    if ($id) {
        $photo_desc = esc_attr(wppa_get_photo_desc($id));
    } else {
        $photo_desc = '';
    }
    $title = __($photo_name, 'wp-photo-album-plus');
    $result['onclick'] = '';
    // Init
    switch ($type) {
        case 'none':
            // No link at all
            return false;
            break;
        case 'file':
            // The plain file
            if ($is_video) {
                $siz = array(wppa_get_videox($id), wppa_get_videoy($id));
                $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                reset($is_video);
                $result['url'] = str_replace('xxx', current($is_video), $result['url']);
            } else {
                $siz = array(wppa_get_photox($id), wppa_get_photoy($id));
                $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
            }
            $result['title'] = $title;
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            return $result;
            break;
        case 'lightbox':
        case 'lightboxsingle':
            if ($is_video) {
                $siz = array(wppa_get_videox($id), wppa_get_videoy($id));
                $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] );
            } else {
                if (wppa_switch('lb_hres')) {
                    $result['url'] = wppa_get_hires_url($id);
                } else {
                    $siz = array(wppa_get_photox($id), wppa_get_photoy($id));
                    $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                }
            }
            $result['title'] = $title;
            $result['is_url'] = false;
            $result['is_lightbox'] = true;
            $result['url'] = wppa_fix_poster_ext($result['url'], $id);
            return $result;
        case 'widget':
            // Defined at widget activation
            $result['url'] = wppa('in_widget_linkurl');
            $result['title'] = esc_attr(wppa('in_widget_linktitle'));
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            return $result;
            break;
        case 'album':
            // The albums thumbnails
        // The albums thumbnails
        case 'content':
            // For album widget
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=0&amp;wppa-cover=0';
                        $result['title'] = '';
                        // $album_name;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                        $result['title'] = $album_name;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
                default:
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&amp;wppa-cover=0';
                        $result['title'] = '';
                        //$album_name;//'a++';
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                        $result['title'] = $album_name;
                        //'a++';
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
            }
            break;
        case 'thumbalbum':
            $album = $thumb['album'];
            $album_name = wppa_get_album_name($album);
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                    $result['title'] = $album_name;
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
                default:
                    $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&amp;wppa-cover=0';
                    $result['title'] = $album_name;
                    //'a++';
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
            }
            break;
        case 'photo':
            // This means: The fullsize photo in a slideshow
        // This means: The fullsize photo in a slideshow
        case 'slphoto':
            // This means: The single photo in the style of a slideshow
            if ($type == 'slphoto') {
                $si = '&amp;wppa-single=1';
            } else {
                $si = '';
            }
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=0&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
                default:
                    if ($noalb) {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    } else {
                        $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&amp;wppa-photo=' . $id . $si;
                        $result['title'] = $title;
                        $result['is_url'] = true;
                        $result['is_lightbox'] = false;
                    }
                    break;
            }
            break;
        case 'single':
            switch ($page) {
                case '-1':
                    return false;
                    break;
                case '0':
                    $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id;
                    $result['title'] = $title;
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
                default:
                    $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id;
                    $result['title'] = $title;
                    $result['is_url'] = true;
                    $result['is_lightbox'] = false;
                    break;
            }
            break;
        case 'same':
            $result['url'] = $lnk;
            $result['title'] = $tit;
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            $result['onclick'] = $onc;
            return $result;
            break;
        case 'fullpopup':
            if ($is_video) {
                // A video can not be printed or downloaded
                $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )');
            } else {
                $wid = wppa_get_photox($id);
                $hig = wppa_get_photoy($id);
                /*
                $imgsize = getimagesize( wppa_get_photo_path( $id ) );
                if ( $imgsize ) {
                	$wid = $imgsize['0'];
                	$hig = $imgsize['1'];
                }
                else {
                	$wid = '0';
                	$hig = '0';
                }
                */
                $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id);
                $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )');
            }
            $result['title'] = $title;
            $result['is_url'] = false;
            $result['is_lightbox'] = false;
            return $result;
            break;
        case 'custom':
            if ($wich == 'potdwidget') {
                $result['url'] = wppa_opt('widget_linkurl');
                $result['title'] = wppa_opt('widget_linktitle');
                $result['is_url'] = true;
                $result['is_lightbox'] = false;
                return $result;
            }
            break;
        case 'slide':
            // for album widget
            $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&amp;slide';
            $result['title'] = '';
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            break;
        case 'autopage':
            if (!wppa_switch('auto_page')) {
                wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force');
                $result['url'] = '';
            } else {
                $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id));
            }
            $result['title'] = '';
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            break;
        case 'plainpage':
            $result['url'] = get_permalink($page);
            $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page));
            $result['is_url'] = true;
            $result['is_lightbox'] = false;
            return $result;
            break;
        default:
            wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red');
            return false;
            break;
    }
    if ($type != 'thumbalbum') {
        if (wppa('calendar')) {
            $result['url'] .= '&amp;wppa-calendar=' . wppa('calendar') . '&amp;wppa-caldate=' . wppa('caldate');
        }
        if (wppa('supersearch')) {
            $result['url'] .= '&amp;wppa-supersearch=' . urlencode(wppa('supersearch'));
        }
        if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) {
            $result['url'] .= '&amp;wppa-searchstring=' . urlencode(wppa('searchstring'));
        }
        if ($wich == 'topten') {
            $result['url'] .= '&amp;wppa-topten=' . wppa_opt('topten_count');
        } elseif (wppa('is_topten')) {
            $result['url'] .= '&amp;wppa-topten=' . wppa('topten_count');
        }
        if ($wich == 'lasten') {
            $result['url'] .= '&amp;wppa-lasten=' . wppa_opt('lasten_count');
        } elseif (wppa('is_lasten')) {
            $result['url'] .= '&amp;wppa-lasten=' . wppa('lasten_count');
        }
        if ($wich == 'comten') {
            $result['url'] .= '&amp;wppa-comten=' . wppa_opt('comten_count');
        } elseif (wppa('is_comten')) {
            $result['url'] .= '&amp;wppa-comten=' . wppa('comten_count');
        }
        if ($wich == 'featen') {
            $result['url'] .= '&amp;wppa-featen=' . wppa_opt('featen_count');
        } elseif (wppa('is_featen')) {
            $result['url'] .= '&amp;wppa-featen=' . wppa('featen_count');
        }
        if (wppa('is_related')) {
            $result['url'] .= '&amp;wppa-rel=' . wppa('is_related') . '&amp;wppa-relcount=' . wppa('related_count');
        } elseif (wppa('is_tag')) {
            $result['url'] .= '&amp;wppa-tag=' . wppa('is_tag');
        }
        if (wppa('is_upldr')) {
            $result['url'] .= '&amp;wppa-upldr=' . wppa('is_upldr');
        }
        if (wppa('is_inverse')) {
            $result['url'] .= '&amp;wppa-inv=1';
        }
    }
    if ($page != '0') {
        // on a different page
        $occur = '1';
        $w = '';
    } else {
        // on the same page, post or widget
        $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur');
        $w = wppa_in_widget() ? 'w' : '';
    }
    $result['url'] .= '&amp;wppa-' . $w . 'occur=' . $occur;
    $result['url'] = wppa_convert_to_pretty($result['url']);
    if ($result['title'] == '') {
        $result['title'] = $tit;
    }
    // If still nothing, try arg
    return $result;
}
function wppa_do_filmthumb($id, $idx, $do_for_feed = false, $glue = false)
{
    $thumb = wppa_cache_thumb($id);
    $result = '';
    $src = wppa_fix_poster_ext(wppa_get_thumb_path($thumb['id']), $thumb['id']);
    $max_size = wppa_opt('thumbsize');
    if (wppa_in_widget()) {
        $max_size /= 2;
    }
    $com_alt = wppa('is_comten') && wppa_switch('comten_alt_display') && !wppa_in_widget();
    $imgattr_a = wppa_get_imgstyle_a($thumb['id'], $src, $max_size, 'optional', 'fthumb');
    $imgstyle = $imgattr_a['style'];
    $imgwidth = $imgattr_a['width'];
    $imgheight = $imgattr_a['height'];
    $cursor = $imgattr_a['cursor'];
    $url = wppa_fix_poster_ext(wppa_get_thumb_url($thumb['id'], '', $imgwidth, $imgheight), $thumb['id']);
    $furl = str_replace('/thumbs', '', $url);
    $events = wppa_get_imgevents('film', $thumb['id'], 'nopopup', $idx);
    $thumbname = wppa_get_photo_name($thumb['id']);
    $target = wppa_switch('film_blank') || $thumb['linktarget'] == '_blank' ? 'target="_blank" ' : '';
    $psotitle = $thumb['linktitle'] ? 'title="' . esc_attr($thumb['linktitle']) . '" ' : '';
    $psourl = wppa_switch('film_overrule') && $thumb['linkurl'] ? 'href="' . $thumb['linkurl'] . '" ' . $target . $psotitle : '';
    $imgalt = wppa_get_imgalt($thumb['id']);
    if (wppa_opt('film_linktype') == 'lightbox') {
        //		$title = esc_attr( wppa_zoom_in( $thumb['id'] ) );
    } else {
        $events .= ' onclick="wppaGotoKeepState( ' . wppa('mocc') . ', ' . $idx . ' )"';
        $events .= ' ondblclick="wppaStartStop( ' . wppa('mocc') . ', -1 )"';
    }
    if (is_feed()) {
        if ($do_for_feed) {
            $style_a = wppa_get_imgstyle_a($thumb['id'], $src, '100', '4', 'thumb');
            $style = $style_a['style'];
            $result .= '<a href="' . get_permalink() . '">' . '<img' . ' src="' . $url . '"' . ' ' . $imgalt . ' title="' . $thumbname . '"' . ' style="' . $style . '"' . ' />' . '</a>';
        }
    } else {
        // If ! $do_for_feed: pre-or post-ambule. To avoid dup id change it in that case
        $tmp = $do_for_feed ? 'film' : 'pre';
        $style = $glue ? 'style="' . wppa_get_thumb_frame_style($glue, 'film') . '"' : '';
        $result .= '<div' . ' id="' . $tmp . '_wppatnf_' . $thumb['id'] . '_' . wppa('mocc') . '"' . ' class="thumbnail-frame"' . ' ' . $style . ' >';
        if ($psourl) {
            // True only when pso activated and data present
            $result .= '<a ' . $psourl . '>';
            // $psourl contains url, target and title
        } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') {
            $title = wppa_get_lbtitle('slide', $thumb['id']);
            $videohtml = esc_attr(wppa_get_video_body($thumb['id']));
            $audiohtml = esc_attr(wppa_get_audio_body($thumb['id']));
            $result .= '<a href="' . $furl . '"' . ($videohtml ? ' data-videohtml="' . $videohtml . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' >';
        }
        if ($tmp == 'pre' && wppa_opt('film_linktype') == 'lightbox') {
            $cursor = 'cursor:default;';
        }
        if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) {
            $result .= '<!--';
        }
        if (wppa_is_video($thumb['id'])) {
            $result .= wppa_get_video_html(array('id' => $thumb['id'], 'width' => $imgattr_a['width'], 'height' => $imgattr_a['height'], 'controls' => false, 'margin_top' => $imgattr_a['margin-top'], 'margin_bottom' => $imgattr_a['margin-bottom'], 'cursor' => $imgattr_a['cursor'], 'events' => $events, 'tagid' => 'wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc')));
        } else {
            $result .= '<img' . ' id="wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc') . '"' . ' class="wppa-' . $tmp . '-' . wppa('mocc') . '"' . ' src="' . $url . '"' . ' ' . $imgalt . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' data-title="' . ($psourl ? esc_attr($thumb['linktitle']) : '') . '"' . ' />';
        }
        if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) {
            $result .= '-->';
        }
        if ($psourl) {
            // True only when pso activated and data present
            $result .= '</a>';
            // $psourl contains url, target and title
        } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') {
            $result .= '</a>';
        }
        $result .= '</div>';
    }
    wppa_out($result);
}
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>');
}
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_shortcodes($xatts, $content = '')
{
    global $wppa;
    global $wppa_postid;
    $atts = shortcode_atts(array('type' => 'generic', 'album' => '', 'photo' => '', 'size' => '', 'align' => '', 'taglist' => '', 'cols' => '', 'sub' => '', 'root' => '', 'calendar' => '', 'all' => '', 'reverse' => ''), $xatts);
    // Find occur
    if (get_the_ID() != $wppa_postid) {
        // New post
        $wppa['occur'] = '0';
        // Init this occurance
        $wppa['fullsize'] = '';
        // Reset at each post
        $wppa_postid = get_the_ID();
        // Remember the post id
    }
    // Set internal defaults
    $wppa['start_album'] = '';
    $wppa['is_cover'] = '0';
    $wppa['is_slide'] = '0';
    $wppa['is_slideonly'] = '0';
    $wppa['is_filmonly'] = '0';
    $wppa['single_photo'] = '';
    $wppa['is_mphoto'] = '0';
    $wppa['film_on'] = '0';
    $wppa['is_landing'] = '0';
    $wppa['start_photo'] = '0';
    // Start a slideshow here
    $wppa['is_single'] = false;
    // Is a one image slideshow
    $wppa['is_upload'] = false;
    $wppa['is_multitagbox'] = false;
    $wppa['is_tagcloudbox'] = false;
    $wppa['taglist'] = '';
    $wppa['tagcols'] = '2';
    $wppa['is_autopage'] = false;
    $wppa['portrait_only'] = false;
    $wppa['shortcode_content'] = $content;
    $wppa['is_url'] = false;
    // Find type
    switch ($atts['type']) {
        case 'landing':
            $wppa['is_landing'] = '1';
        case 'generic':
            break;
        case 'cover':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_cover'] = '1';
            break;
        case 'album':
        case 'content':
            $wppa['start_album'] = $atts['album'];
            break;
        case 'thumbs':
            $wppa['start_album'] = $atts['album'];
            $wppa['photos_only'] = true;
            break;
        case 'covers':
            $wppa['start_album'] = $atts['album'];
            $wppa['albums_only'] = true;
            break;
        case 'slide':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slide'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'slideonly':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slideonly'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'slideonlyf':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slideonly'] = '1';
            $wppa['film_on'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'filmonly':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slideonly'] = '1';
            $wppa['is_filmonly'] = '1';
            $wppa['film_on'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'photo':
            $wppa['single_photo'] = $atts['photo'];
            break;
        case 'mphoto':
            $wppa['single_photo'] = $atts['photo'];
            $wppa['is_mphoto'] = '1';
            break;
        case 'slphoto':
            $wppa['is_slide'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            $wppa['is_single'] = '1';
            break;
        case 'autopage':
            $wppa['is_autopage'] = '1';
            break;
        case 'upload':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_upload'] = true;
            break;
        case 'multitag':
            $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
            $wppa['is_multitagbox'] = true;
            if ($atts['cols']) {
                $wppa['tagcols'] = $atts['cols'];
            }
            break;
        case 'tagcloud':
            $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
            $wppa['is_tagcloudbox'] = true;
            break;
        case 'bestof':
            $wppa['bestof'] = true;
            $wppa['bestof_args'] = $xatts;
            break;
        case 'superview':
            $wppa['is_superviewbox'] = true;
            $wppa['start_album'] = $atts['album'];
            break;
        case 'search':
            $wppa['is_searchbox'] = true;
            $wppa['may_sub'] = $atts['sub'];
            $wppa['may_root'] = $atts['root'];
            break;
        case 'supersearch':
            $wppa['is_supersearch'] = true;
            break;
        case 'calendar':
            if (!wppa_switch('allow_ajax')) {
                wppa_dbg_msg('Shortcode [wppa type="calendar" ...  requires Ajax acive. See Photo Albums -> Settings Table IV-A1.0', 'red', 'force');
                return '';
            }
            $wppa['is_calendar'] = true;
            $wppa['calendar'] = 'timestamp';
            if (in_array($atts['calendar'], array('exifdtm', 'timestamp', 'modified'))) {
                $wppa['calendar'] = $atts['calendar'];
            }
            if ($atts['all']) {
                $wppa['calendarall'] = true;
            }
            $wppa['reverse'] = $atts['reverse'];
            $wppa['start_album'] = $atts['album'];
            break;
        case 'stereo':
            $wppa['is_stereobox'] = true;
            break;
        case 'url':
            $wppa['is_url'] = true;
            $wppa['single_photo'] = $atts['photo'];
            break;
        default:
            wppa_dbg_msg('Invalid type: ' . $atts['type'] . ' in wppa shortcode.', 'red', 'force');
            return '';
    }
    // Count (internally to wppa_albums)
    // Find size
    if ($atts['size'] == 'auto') {
        $wppa['auto_colwidth'] = true;
        $wppa['fullsize'] = '';
    } else {
        $wppa['auto_colwidth'] = false;
        $wppa['fullsize'] = $atts['size'];
    }
    // Find align
    $wppa['align'] = $atts['align'];
    // Ready to render ???
    $do_it = false;
    if (wppa('rendering_enabled')) {
        $do_it = true;
    }
    // NOT in a head section (in a meta tag or so)
    if (wppa_in_widget()) {
        $do_it = true;
    }
    // A widget always works
    if (is_feed()) {
        $do_it = true;
    }
    // A feed has no head section
    if (wppa_switch('render_shortcode_always')) {
        $do_it = true;
    }
    // Always
    if (wppa('debug')) {
        if ($do_it) {
            $msg = 'Doit is on';
        } else {
            $msg = 'Doit is off';
        }
        wppa_dbg_msg($msg);
    }
    // Do it also for url only shortcode
    if ($do_it || $wppa['is_url']) {
        $result = wppa_albums();
        // Get the HTML
    } else {
        $result = '<span style="color:blue; font-weight:bold; ">[WPPA+ Photo display (fsh)]</span>';
        // Or an indicator
    }
    // Reset
    $wppa['start_photo'] = '0';
    // Start a slideshow here
    $wppa['is_single'] = false;
    // Is a one image slideshow
    // Relative urls?
    $result = wppa_make_relative($result);
    // In widget
    if (wppa_in_widget()) {
        if (!wppa_switch('shortcode_at_priority_widget')) {
            return $result;
        }
    } else {
        if (!wppa_switch('shortcode_at_priority')) {
            return $result;
        }
    }
    // Url always immediately
    if ($wppa['is_url']) {
        return $result;
    }
    // New method to prevent damage of the result by content filters that run on higher priorities than do_shortcode.
    // Previous methods, e.g. increasing the do_shortcode priority sometimes fail due to requirements of other plugins/shortcodes.
    // To prevent this, i first asked an enhancement to add a priority argument to add_shortcode(), but the wp boys simply say
    // 'this is not possible'. Everything is possible, they should say that they are not smart enough to implement it.
    // Since there are plans to set the do_shortcode() priority ( currently 11 ) lower than wpautop() ( 10 ), and there are many serious
    // bugs in wpautop() it is now urgent to create a monkey-proof solution to the problem that others destructify the so preciously created
    // shortcode process output.
    //
    // What we do is:
    // 1. Save the result in memory and return a placeholder for the result.
    // 2. Run a contentfilter on the highest possible priority that replaced the placeholder by the original result.
    //
    // It sounds simple, but it took me a few sleepless nights to figure out.
    // Here it goes:
    // Define storage for the results
    global $wppa_shortcode_results;
    // Create a key to identify the result.
    // Any unique key will do, as long as it is not tampered by any content filter.
    // Hopefully everything keeps an unadded shortcode untouched,
    // therefor we wrap the random key in square brackets
    $key = '[' . md5(rand()) . ']';
    // Store
    $wppa_shortcode_results[$key] = $result;
    // Return the placeholder ( = the key ) in stead of $result
    return $key;
}
function wppa_get_text_frame_style($photo_left, $type)
{
    if (wppa_in_widget()) {
        $result = '';
    } else {
        if ($type == 'thumb') {
            $width = wppa_get_cover_width($type, true);
            $width -= 13;
            // margin
            $width -= 2;
            // border
            $width -= wppa_opt('smallsize');
            if ($photo_left) {
                $result = 'style="width:' . $width . 'px; float:right;"';
            } else {
                $result = 'style="width:' . $width . 'px; float:left;"';
            }
        } elseif ($type == 'cover') {
            $width = wppa_get_cover_width($type, true);
            $photo_pos = $photo_left;
            switch ($photo_pos) {
                case 'left':
                    $width -= wppa_get_textframe_delta();
                    //	$width -= 13;	// margin
                    //	$width -= 2; 	// border
                    //	$width -= wppa_opt( 'smallsize' );
                    $result = 'style="width:' . $width . 'px; float:right;' . __wcs('wppa-cover-text-frame') . '"';
                    break;
                case 'right':
                    $width -= wppa_get_textframe_delta();
                    //	$width -= 13;	// margin
                    //	$width -= 2; 	// border
                    //	$width -= wppa_opt( 'smallsize' );
                    $result = 'style="width:' . $width . 'px; float:left;' . __wcs('wppa-cover-text-frame') . '"';
                    break;
                case 'top':
                    //					$width -= 13;
                    $result = 'style="' . __wcs('wppa-cover-text-frame') . '"';
                    //'style="width:'.$width.'px;"';
                    break;
                case 'bottom':
                    //					$width -= 13;
                    $result = 'style="' . __wcs('wppa-cover-text-frame') . '"';
                    //'style="width:'.$width.'px;"';
                    break;
                default:
                    wppa_dbg_msg('Illegal $photo_pos in wppa_get_text_frame_style', 'red');
            }
        } else {
            wppa_dbg_msg('Illegal $type in wppa_get_text_frame_style', 'red');
        }
    }
    return $result;
}
function wppa_comment_html($id, $comment_allowed)
{
    global $wpdb;
    global $current_user;
    global $wppa_first_comment_html;
    $result = '';
    if (wppa_in_widget()) {
        return $result;
    }
    // NOT in a widget
    // Find out who we are either logged in or not
    $vis = is_user_logged_in() ? 'display:none; ' : '';
    if (!$wppa_first_comment_html) {
        $wppa_first_comment_html = true;
        // Find user
        if (wppa_get_post('comname')) {
            wppa('comment_user', wppa_get_post('comname'));
        }
        if (wppa_get_post('comemail')) {
            wppa('comment_email', wppa_get_post('comemail'));
        } elseif (is_user_logged_in()) {
            get_currentuserinfo();
            wppa('comment_user', $current_user->display_name);
            //user_login;
            wppa('comment_email', $current_user->user_email);
        }
    }
    // Loop the comments already there
    $n_comments = 0;
    if (wppa_switch('comments_desc')) {
        $ord = 'DESC';
    } else {
        $ord = '';
    }
    $comments = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . WPPA_COMMENTS . ' WHERE photo = %s ORDER BY id ' . $ord, $id), ARRAY_A);
    wppa_dbg_q('Q-Comm');
    $com_count = count($comments);
    $color = 'darkgrey';
    if (wppa_opt('fontcolor_box')) {
        $color = wppa_opt('fontcolor_box');
    }
    if ($comments && (is_user_logged_in() || !wppa_switch('comment_view_login'))) {
        $result .= '
			<div' . ' id="wppa-comtable-wrap-' . wppa('mocc') . '"' . ' style="display:none;"' . '>' . '<table' . ' id="wppacommentstable-' . wppa('mocc') . '"' . ' class="wppa-comment-form"' . ' style="margin:0; "' . '>' . '<tbody>';
        foreach ($comments as $comment) {
            // Show a comment either when it is approved, or it is pending and mine or i am a moderator
            if ($comment['status'] == 'approved' || current_user_can('wppa_moderate') || current_user_can('wppa_comments') || ($comment['status'] == 'pending' || $comment['status'] == 'spam') && $comment['user'] == wppa('comment_user')) {
                $n_comments++;
                $result .= '
					<tr' . ' class="wppa-comment-' . $comment['id'] . '"' . ' valign="top"' . ' style="border-bottom:0 none; border-top:0 none; border-left: 0 none; border-right: 0 none; "' . ' >' . '<td' . ' valign="top"' . ' class="wppa-box-text wppa-td"' . ' style="vertical-align:top; width:30%; border-width: 0 0 0 0; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . $comment['user'] . ' ' . __('wrote:', 'wp-photo-album-plus') . '<br />' . '<span style="font-size:9px; ">' . wppa_get_time_since($comment['timestamp']) . '</span>';
                // Avatar ?
                if (wppa_opt('comment_gravatar') != 'none') {
                    // Find the default
                    if (wppa_opt('comment_gravatar') != 'url') {
                        $default = wppa_opt('comment_gravatar');
                    } else {
                        $default = wppa_opt('comment_gravatar_url');
                    }
                    // Find the avatar, init
                    $avt = false;
                    $usr = false;
                    // First try to find the user by email address ( works only if email required on comments )
                    if ($comment['email']) {
                        $usr = get_user_by('email', $comment['email']);
                    }
                    // If not found, try to find the user by login name ( works only if login name is equal to display name )
                    if (!$usr) {
                        $usr = get_user_by('login', $comment['user']);
                    }
                    // Still no user, try to find him by display name
                    if (!$usr) {
                        $usr = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE `display_name` = %s", $comment['user']));
                        // Accept this user if he is the only one with this display name
                        if (count($usr) != 1) {
                            $usr = false;
                        }
                    }
                    // If a user is found, see for local Avatar ?
                    if ($usr) {
                        $avt = str_replace("'", "\"", get_avatar($usr->ID, wppa_opt('gravatar_size'), $default));
                    }
                    // Global avatars off ? try myself
                    if (!$avt) {
                        $avt = '
										<img' . ' class="wppa-box-text wppa-td"' . ' src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($comment['email']))) . '.jpg?d=' . urlencode($default) . '&s=' . wppa_opt('gravatar_size') . '"' . ' alt="' . __('Avatar', 'wp-photo-album-plus') . '"' . ' />';
                    }
                    // Compose the html
                    $result .= '
									<div class="com_avatar">' . $avt . '</div>';
                }
                $result .= '</td>';
                $txtwidth = floor(wppa_get_container_width() * 0.7) . 'px';
                $result .= '<td' . ' class="wppa-box-text wppa-td"' . ' style="width:70%; word-wrap:break-word; border-width: 0 0 0 0;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<p' . ' class="wppa-comment-textarea wppa-comment-textarea-' . wppa('mocc') . '"' . ' style="' . 'margin:0;' . 'background-color:transparent;' . 'width:' . $txtwidth . ';' . 'max-height:90px;' . 'overflow:auto;' . 'word-wrap:break-word;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . html_entity_decode(esc_js(stripslashes(wppa_convert_smilies($comment['comment']))));
                if ($comment['status'] != 'approved' && (current_user_can('wppa_moderate') || current_user_can('wppa_comments'))) {
                    if (wppa('no_esc')) {
                        $result .= wppa_moderate_links('comment', $id, $comment['id']);
                    } else {
                        $result .= wppa_html(esc_js(wppa_moderate_links('comment', $id, $comment['id'])));
                    }
                } elseif ($comment['status'] == 'pending' && $comment['user'] == wppa('comment_user')) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __('Awaiting moderation', 'wp-photo-album-plus') . '</span>';
                } elseif ($comment['status'] == 'spam' && $comment['user'] == wppa('comment_user')) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __('Marked as spam', 'wp-photo-album-plus') . '</span>';
                }
                $result .= '</p>' . '</td>' . '</tr>' . '<tr class="wppa-comment-' . $comment['id'] . '">' . '<td colspan="2" style="padding:0">' . '<hr style="background-color:' . $color . '; margin:0;" />' . '</td>' . '</tr>';
            }
        }
        $result .= '</tbody>' . '</table>' . '</div>';
    }
    // See if we are currently in the process of adding/editing this comment
    $is_current = $id == wppa('comment_photo') && wppa('comment_id');
    if ($is_current) {
        $txt = wppa('comment_text');
        $btn = __('Edit!', 'wp-photo-album-plus');
    } else {
        $txt = '';
        $btn = __('Send!', 'wp-photo-album-plus');
    }
    // Prepare the callback url
    $returnurl = wppa_get_permalink();
    $album = wppa_get_get('album');
    if ($album !== false) {
        $returnurl .= 'wppa-album=' . $album . '&';
    }
    $cover = wppa_get_get('cover');
    if ($cover) {
        $returnurl .= 'wppa-cover=' . $cover . '&';
    }
    $slide = wppa_get_get('slide');
    if ($slide !== false) {
        $returnurl .= 'wppa-slide&';
    }
    $occur = wppa_get_get('occur');
    if ($occur) {
        $returnurl .= 'wppa-occur=' . $occur . '&';
    }
    $lasten = wppa_get_get('lasten');
    if ($lasten) {
        $returnurl .= 'wppa-lasten=' . $lasten . '&';
    }
    $topten = wppa_get_get('topten');
    if ($topten) {
        $returnurl .= 'wppa-topten=' . $topten . '&';
    }
    $comten = wppa_get_get('comten');
    if ($comten) {
        $returnurl .= 'wppa-comten=' . $comten . '&';
    }
    $tag = wppa_get_get('tag');
    if ($tag) {
        $returnurl .= 'wppa-tag=' . $tag . '&';
    }
    $returnurl .= 'wppa-photo=' . $id;
    // The comment form
    if ($comment_allowed) {
        $result .= '<div' . ' id="wppa-comform-wrap-' . wppa('mocc') . '"' . ' style="display:none;"' . ' >' . '<form' . ' id="wppa-commentform-' . wppa('mocc') . '"' . ' class="wppa-comment-form"' . ' action="' . $returnurl . '"' . ' method="post"' . ' onsubmit="return wppaValidateComment( ' . wppa('mocc') . ' )"' . ' >' . wp_nonce_field('wppa-nonce-' . wppa('mocc'), 'wppa-nonce-' . wppa('mocc'), false, false) . ($album ? '<input type="hidden" name="wppa-album" value="' . $album . '" />' : '') . ($cover ? '<input type="hidden" name="wppa-cover" value="' . $cover . '" />' : '') . ($slide ? '<input type="hidden" name="wppa-slide" value="' . $slide . '" />' : '') . '<input' . ' type="hidden"' . ' name="wppa-returnurl"' . ' id="wppa-returnurl-' . wppa('mocc') . '"' . ' value="' . $returnurl . '"' . ' />' . ($is_current ? '<input' . ' type="hidden"' . ' id="wppa-comment-edit-' . wppa('mocc') . '"' . ' name="wppa-comment-edit"' . ' value="' . wppa('comment_id') . '"' . ' />' : '') . '<input type="hidden" name="wppa-occur" value="' . wppa('occur') . '" />' . '<table id="wppacommenttable-' . wppa('mocc') . '" style="margin:0;">' . '<tbody>' . '<tr valign="top" style="' . $vis . '">' . '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your name:', 'wp-photo-album-plus') . '</td>' . '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<input' . ' type="text"' . ' name="wppa-comname"' . ' id="wppa-comname-' . wppa('mocc') . '"' . ' style="width:100%; " value="' . wppa('comment_user') . '"' . ' />' . '</td>' . '</tr>';
        if (wppa_switch('comment_email_required')) {
            $result .= '<tr valign="top" style="' . $vis . '">' . '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your email:', 'wp-photo-album-plus') . '</td>' . '<td class="wppa-box-text wppa-td" style="width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . '<input' . ' type="text"' . ' name="wppa-comemail"' . ' id="wppa-comemail-' . wppa('mocc') . '"' . ' style="width:100%;"' . ' value="' . wppa('comment_email') . '"' . ' />' . '</td>' . '</tr>';
        }
        $result .= '<tr valign="top" style="vertical-align:top;">' . '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __('Your comment:', 'wp-photo-album-plus') . '<br />' . wppa('comment_user') . '<br />';
        if (is_user_logged_in() && wppa_opt('comment_captcha') == 'all' || !is_user_logged_in() && wppa_opt('comment_captcha') != 'none') {
            $wid = '20%';
            if (wppa_opt('fontsize_box')) {
                $wid = wppa_opt('fontsize_box') * 1.5 . 'px';
            }
            $captkey = $id;
            if ($is_current) {
                $captkey = $wpdb->get_var($wpdb->prepare('SELECT `timestamp` FROM `' . WPPA_COMMENTS . '` WHERE `id` = %s', wppa('comment_id')));
            }
            wppa_dbg_q('Q-Com-ts');
            $result .= wppa_make_captcha($captkey) . '<input' . ' type="text"' . ' id="wppa-captcha-' . wppa('mocc') . '"' . ' name="wppa-captcha"' . ' style="width:' . $wid . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' />&nbsp;';
        }
        $result .= '<input type="button" name="commentbtn" onclick="wppaAjaxComment( ' . wppa('mocc') . ', ' . $id . ' )" value="' . $btn . '" style="margin:0 4px 0 0;" />' . '<img id="wppa-comment-spin-' . wppa('mocc') . '" src="' . wppa_get_imgdir() . 'wpspin.gif" style="display:none;" />' . '</td>' . '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:70%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >';
        if (wppa_switch('comment_smiley_picker')) {
            $result .= wppa_get_smiley_picker_html('wppa-comment-' . wppa('mocc'));
        }
        $result .= '<textarea' . ' name="wppa-comment"' . ' id="wppa-comment-' . wppa('mocc') . '"' . ' style="height:60px; width:100%; "' . '>' . esc_textarea(stripslashes($txt)) . '</textarea>' . '</td>' . '</tr>' . '</tbody>' . '</table>' . '</form>' . '</div>';
    } else {
        if (wppa_switch('login_links')) {
            $result .= sprintf(__('You must <a href="%s">login</a> to enter a comment', 'wp-photo-album-plus'), site_url('wp-login.php', 'login'));
        } else {
            $result .= __('You must login to enter a comment', 'wp-photo-album-plus');
        }
    }
    $result .= '<div id="wppa-comfooter-wrap-' . wppa('mocc') . '" style="display:block;" >' . '<table id="wppacommentfooter-' . wppa('mocc') . '" class="wppa-comment-form" style="margin:0;">' . '<tbody>' . '<tr style="text-align:center;">' . '<td style="text-align:center; cursor:pointer;' . __wcs('wppa-box-text') . '" >' . '<a onclick="wppaOpenComments( ' . wppa('mocc') . ', -1 ); return false;" >';
    if ($n_comments) {
        $result .= sprintf(_n('%d comment', '%d comments', $n_comments, 'wp-photo-album-plus'), $n_comments);
    } else {
        if ($comment_allowed) {
            $result .= __('Leave a comment', 'wp-photo-album-plus');
        }
    }
    $result .= '</a>' . '</td>' . '</tr>' . '</tbody>' . '</table>' . '</div>' . '<div style="clear:both"></div>';
    return $result;
}
function wppa_get_imgstyle_a($id, $file, $xmax_size, $xvalign = '', $type = '')
{
    $result = array('style' => '', 'width' => '', 'height' => '', 'cursor' => '', 'margin-top' => '', 'margin-bottom' => '');
    // Init
    wppa_cache_thumb($id);
    if (!$id) {
        return $result;
    }
    // no image: no dimensions
    if ($file == '') {
        return $result;
    }
    // no image: no dimensions
    if (wppa_has_audio($id)) {
        $file = wppa_fix_poster_ext($file, $id);
    }
    if (!wppa_is_video($id) && !is_file($file)) {
        wppa_dbg_msg('Please check file ' . $file . ' it is missing while expected. Id=' . $id, 'red');
        return $result;
        // no file: no dimensions ( 2.3.0 )
    }
    if (strpos($file, '/wppa/thumbs/')) {
        $image_attr = wppa_get_imagexy($id, 'thumb');
    } else {
        $image_attr = wppa_get_imagexy($id, 'photo');
    }
    //	if ( wppa_is_video( $id ) ) {
    //		$image_attr = array( '0' => wppa_get_videox( $id ), '1' => wppa_get_videoy( $id ) );
    //	}
    //	else {
    //		$image_attr = array( '0' => wppa_get_photox( $id ), '1' => wppa_get_photoy( $id ) );
    //	}
    if (!$image_attr || !isset($image_attr['0']) || !$image_attr['0'] || !isset($image_attr['1']) || !$image_attr['1']) {
        // File is corrupt
        wppa_dbg_msg('Please check file ' . $file . ' it is corrupted. If it is a thumbnail image,' . ' regenerate them using Table VIII-A4 of the Photo Albums -> Settings admin page.', 'red');
        return $result;
    }
    // Adjust for 'border'
    if ($type == 'fullsize' && !wppa_in_widget()) {
        switch (wppa_opt('fullimage_border_width')) {
            case '':
                $max_size = $xmax_size;
                break;
            case '0':
                $max_size = $xmax_size - '2';
                break;
            default:
                $max_size = $xmax_size - '2' - 2 * wppa_opt('fullimage_border_width');
        }
    } else {
        $max_size = $xmax_size;
    }
    $ratioref = wppa_opt('maxheight') / wppa_opt('fullsize');
    $max_height = round($max_size * $ratioref);
    if ($type == 'fullsize') {
        if (wppa('portrait_only')) {
            $width = $max_size;
            $height = round($width * $image_attr[1] / $image_attr[0]);
        } else {
            if (wppa_is_wider($image_attr[0], $image_attr[1])) {
                $width = $max_size;
                $height = round($width * $image_attr[1] / $image_attr[0]);
            } else {
                $height = round($ratioref * $max_size);
                $width = round($height * $image_attr[0] / $image_attr[1]);
            }
            if ($image_attr[0] < $width && $image_attr[1] < $height) {
                if (!wppa('enlarge')) {
                    $width = $image_attr[0];
                    $height = $image_attr[1];
                }
            }
        }
    } else {
        if ($type == 'cover' && wppa_switch('coversize_is_height') && (wppa_opt('coverphoto_pos') == 'top' || wppa_opt('coverphoto_pos') == 'bottom')) {
            $height = $max_size;
            $width = round($max_size * $image_attr[0] / $image_attr[1]);
        } else {
            if (wppa_is_landscape($image_attr)) {
                $width = $max_size;
                $height = round($max_size * $image_attr[1] / $image_attr[0]);
            } else {
                $height = $max_size;
                $width = round($max_size * $image_attr[0] / $image_attr[1]);
            }
        }
    }
    switch ($type) {
        case 'cover':
            if (wppa_opt('bcolor_img') != '') {
                // There is a border color given
                $result['style'] .= ' border: 1px solid ' . wppa_opt('bcolor_img') . ';';
            } else {
                // No border color: no border
                $result['style'] .= ' border-width: 0px;';
            }
            $result['style'] .= ' width:' . $width . 'px; height:' . $height . 'px;';
            if (wppa_switch('use_cover_opacity') && !is_feed()) {
                $opac = wppa_opt('cover_opacity');
                $result['style'] .= ' opacity:' . $opac / 100 . '; filter:alpha( opacity=' . $opac . ' );';
            }
            if (wppa_opt('coverimg_linktype') == 'lightbox') {
                $result['cursor'] = ' cursor:url( ' . wppa_get_imgdir() . wppa_opt('magnifier') . ' ),pointer;';
            }
            $result['style'] .= 'display:inline;';
            break;
        case 'thumb':
            // Normal
        // Normal
        case 'ttthumb':
            // Topten
        // Topten
        case 'comthumb':
            // Comment widget
        // Comment widget
        case 'fthumb':
            // Filmthumb
        // Filmthumb
        case 'twthumb':
            // Thumbnail widget
        // Thumbnail widget
        case 'ltthumb':
            // Lasten widget
        // Lasten widget
        case 'albthumb':
            // Album widget
            if ($type == 'thumb' && wppa_get_get('hilite') == $id) {
                $result['style'] .= ' border:2px solid blue;box-sizing:border-box;';
            } else {
                $result['style'] .= ' border-width: 0px;';
            }
            $result['style'] .= ' width:' . $width . 'px; height:' . $height . 'px;';
            if ($xvalign == 'optional') {
                $valign = wppa_opt('valign');
            } else {
                $valign = $xvalign;
            }
            if ($valign != 'default') {
                // Center horizontally
                $delta = floor(($max_size - $width) / 2);
                if (is_numeric($valign)) {
                    $delta += $valign;
                }
                if ($delta < '0') {
                    $delta = '0';
                }
                if ($delta > '0') {
                    $result['style'] .= ' margin-left:' . $delta . 'px; margin-right:' . $delta . 'px;';
                }
            }
            switch ($valign) {
                case 'top':
                    $delta = $max_size - $height;
                    if ($delta < '0') {
                        $delta = '0';
                    }
                    $result['style'] .= ' margin-bottom: ' . $delta . 'px;';
                    $result['margin-bottom'] = $delta;
                    break;
                case 'center':
                    $delta = round(($max_size - $height) / 2);
                    if ($delta < '0') {
                        $delta = '0';
                    }
                    $result['style'] .= ' margin-top: ' . $delta . 'px; margin-bottom: ' . $delta . 'px;';
                    $result['margin-top'] = $delta;
                    $result['margin-bottom'] = $delta;
                    break;
                case 'bottom':
                    $delta = $max_size - $height;
                    if ($delta < '0') {
                        $delta = '0';
                    }
                    $result['style'] .= ' margin-top: ' . $delta . 'px;';
                    $result['margin-top'] = $delta;
                    break;
                default:
                    if (is_numeric($valign)) {
                        $delta = $valign;
                        $result['style'] .= ' margin-top: ' . $delta . 'px;';
                        $result['style'] .= ' margin-bottom: ' . $delta . 'px;';
                        $result['margin-top'] = $delta;
                        $result['margin-bottom'] = $delta;
                    }
            }
            if (wppa_switch('use_thumb_opacity') && !is_feed()) {
                $opac = wppa_opt('thumb_opacity');
                $result['style'] .= ' opacity:' . $opac / 100 . '; filter:alpha( opacity=' . $opac . ' );';
            }
            // Cursor
            $linktyp = '';
            switch ($type) {
                case 'thumb':
                    // Normal
                    $linktyp = wppa_opt('thumb_linktype');
                    break;
                case 'ttthumb':
                    // Topten	v
                    $linktyp = wppa_opt('topten_widget_linktype');
                    break;
                case 'comthumb':
                    // Comment widget	v
                    $linktyp = wppa_opt('comment_widget_linktype');
                    break;
                case 'fthumb':
                    // Filmthumb
                    $linktyp = wppa_opt('film_linktype');
                    break;
                case 'twthumb':
                    // Thumbnail widget	v
                    $linktyp = wppa_opt('thumbnail_widget_linktype');
                    break;
                case 'ltthumb':
                    // Lasten widget	v
                    $linktyp = wppa_opt('lasten_widget_linktype');
                    break;
                case 'albthumb':
                    // Album widget
                    $linktyp = wppa_opt('album_widget_linktype');
            }
            if ($linktyp == 'none') {
                $result['cursor'] = ' cursor:default;';
            } elseif ($linktyp == 'lightbox') {
                $result['cursor'] = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('magnifier') . '),pointer;';
            } else {
                $result['cursor'] = ' cursor:pointer;';
            }
            break;
        case 'fullsize':
            if (wppa('auto_colwidth')) {
                // These sizes fit within the rectangle define by Table I-B1,2
                // times 2 for responsive themes,
                // and are supplied for ver 4 browsers as they have undefined natural sizes.
                $result['style'] .= ' max-width:' . $width * 2 . 'px;';
                $result['style'] .= ' max-height:' . $height * 2 . 'px;';
            } else {
                // These sizes fit within the rectangle define by Table I-B1,2
                // and are supplied for ver 4 browsers as they have undefined natural sizes.
                $result['style'] .= ' max-width:' . $width . 'px;';
                $result['style'] .= ' max-height:' . $height . 'px;';
                $result['style'] .= ' width:' . $width . 'px;';
                $result['style'] .= ' height:' . $height . 'px;';
            }
            if (wppa('is_slideonly') == '1') {
                if (wppa('ss_widget_valign') != '') {
                    $valign = wppa('ss_widget_valign');
                } else {
                    $valign = 'fit';
                }
            } elseif ($xvalign == 'optional') {
                $valign = wppa_opt('fullvalign');
            } else {
                $valign = $xvalign;
            }
            // Margin
            if ($valign != 'default') {
                $m_left = '0';
                $m_right = '0';
                $m_top = '0';
                $m_bottom = '0';
                // Center horizontally
                $delta = round(($max_size - $width) / 2);
                if ($delta < '0') {
                    $delta = '0';
                }
                if (wppa('auto_colwidth')) {
                    $m_left = 'auto';
                    $m_right = 'auto';
                } else {
                    $m_left = $delta;
                    $m_right = '0';
                }
                // Position vertically
                if (wppa_in_widget() == 'ss' && wppa('in_widget_frame_height') > '0') {
                    $max_height = wppa('in_widget_frame_height');
                }
                $delta = '0';
                if (!wppa('auto_colwidth') && !wppa_page('oneofone')) {
                    switch ($valign) {
                        case 'top':
                        case 'fit':
                            $delta = '0';
                            break;
                        case 'center':
                            $delta = round(($max_height - $height) / 2);
                            if ($delta < '0') {
                                $delta = '0';
                            }
                            break;
                        case 'bottom':
                            $delta = $max_height - $height;
                            if ($delta < '0') {
                                $delta = '0';
                            }
                            break;
                    }
                }
                $m_top = $delta;
                $result['style'] .= wppa_combine_style('margin', $m_top, $m_left, $m_right, $m_bottom);
            }
            // Border and padding
            if (!wppa_in_widget()) {
                switch (wppa_opt('fullimage_border_width')) {
                    case '':
                        break;
                    case '0':
                        $result['style'] .= ' border: 1px solid ' . wppa_opt('bcolor_fullimg') . ';';
                        break;
                    default:
                        $result['style'] .= ' border: 1px solid ' . wppa_opt('bcolor_fullimg') . ';';
                        $result['style'] .= ' background-color:' . wppa_opt('bgcolor_fullimg') . ';';
                        $result['style'] .= ' padding:' . wppa_opt('fullimage_border_width') . 'px;';
                        // If we do round corners...
                        if (wppa_opt('bradius') > '0') {
                            // then also here
                            $result['style'] .= ' border-radius:' . wppa_opt('fullimage_border_width') . 'px;';
                        }
                }
            }
            break;
        default:
            wppa_out('Error wrong "$type" argument: ' . $type . ' in wppa_get_imgstyle_a');
    }
    $result['width'] = $width;
    $result['height'] = $height;
    return $result;
}
function wppa_test_for_search($at_session_start = false)
{
    global $wppa;
    if (isset($_REQUEST['wppa-searchstring'])) {
        // wppa+ search
        $str = $_REQUEST['wppa-searchstring'];
    } elseif (isset($_REQUEST['searchstring'])) {
        // wppa+ search
        $str = $_REQUEST['searchstring'];
    } elseif (isset($_REQUEST['s'])) {
        // wp search
        $str = $_REQUEST['s'];
    } else {
        // Not search
        $str = '';
    }
    // Sanitize
    $ignore = array('"', "'", '\\', '>', '<', ':', ';', '!', '?', '=', '_', '[', ']', '(', ')', '{', '}');
    $str = wppa_decode_uri_component($str);
    $str = str_replace($ignore, ' ', $str);
    $str = strip_tags($str);
    $str = stripslashes($str);
    $str = trim($str);
    $inter = chr(226) . chr(136) . chr(169);
    $union = chr(226) . chr(136) . chr(170);
    $str = str_replace($inter, ' ', $str);
    $str = str_replace($union, ',', $str);
    while (strpos($str, '  ') !== false) {
        $str = str_replace('  ', ' ', $str);
    }
    // reduce spaces
    while (strpos($str, ',,') !== false) {
        $str = str_replace(',,', ',', $str);
    }
    // reduce commas
    while (strpos($str, ', ') !== false) {
        $str = str_replace(', ', ',', $str);
    }
    // trim commas
    while (strpos($str, ' ,') !== false) {
        $str = str_replace(' ,', ',', $str);
    }
    // trim commas
    // Did we do wppa_initialize_runtime() ?
    if (is_array($wppa) && !$at_session_start) {
        $wppa['searchstring'] = $str;
        if ($wppa['searchstring'] && $wppa['occur'] == '1' && !wppa_in_widget()) {
            $wppa['src'] = true;
        } else {
            $wppa['src'] = false;
        }
        if (isset($_REQUEST['s'])) {
            $wppa['src'] = true;
            global $wppa_session;
            $wppa_session['use_searchstring'] = $str;
            $wppa_session['display_searchstring'] = $str;
            wppa_save_session();
        }
        $result = $str;
    } else {
        $result = $str;
    }
    if ($wppa['src']) {
        switch (wppa_opt('search_display_type')) {
            case 'slide':
                $wppa['is_slide'] = '1';
                break;
            case 'slideonly':
                $wppa['is_slide'] = '1';
                $wppa['is_slideonly'] = '1';
                break;
            default:
                break;
        }
    }
    return $result;
}
function wppa_the_coverphoto($albumid, $image, $src, $photo_pos, $photolink, $title, $imgattr_a, $events)
{
    global $wpdb;
    if (!$image) {
        return;
    }
    if (wppa_has_audio($image['id'])) {
        $src = wppa_fix_poster_ext($src, $image['id']);
    }
    $imgattr = $imgattr_a['style'];
    $imgwidth = $imgattr_a['width'];
    $imgheight = $imgattr_a['height'];
    $frmwidth = $imgwidth + '10';
    // + 2 * 1 border + 2 * 4 padding
    // Find the photo frame style
    if (wppa_in_widget()) {
        $photoframestyle = 'style="text-align:center; "';
    } else {
        switch ($photo_pos) {
            case 'left':
                $photoframestyle = 'style="float:left; margin-right:5px;width:' . $frmwidth . 'px;"';
                break;
            case 'right':
                $photoframestyle = 'style="float:right; margin-left:5px;width:' . $frmwidth . 'px;"';
                break;
            case 'top':
                $photoframestyle = 'style="text-align:center;"';
                break;
            case 'bottom':
                $photoframestyle = 'style="text-align:center;"';
                break;
            default:
                $photoframestyle = '';
                wppa_dbg_msg('Illegal $photo_pos in wppa_the_coverphoto');
        }
    }
    // Open the coverphoto frame
    wppa_out('<div' . ' id="coverphoto_frame_' . $albumid . '_' . wppa('mocc') . '"' . ' class="coverphoto-frame" ' . $photoframestyle . ' >');
    // The link from the coverphoto
    if ($photolink) {
        // If lightbox, we need all the album photos to set up a lightbox set
        if ($photolink['is_lightbox']) {
            $thumbs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($albumid), $albumid), ARRAY_A);
            wppa_dbg_q('Q-CovPlB');
            // Report the query
            wppa_cache_thumb('add', $thumbs);
            // Save rsult in 2nd level cache
            if ($thumbs) {
                foreach ($thumbs as $thumb) {
                    $id = $thumb['id'];
                    $title = wppa_get_lbtitle('cover', $id);
                    if (wppa_is_video($id)) {
                        $siz['0'] = wppa_get_videox($id);
                        $siz['1'] = wppa_get_videoy($id);
                    } else {
                        $siz['0'] = wppa_get_photox($id);
                        $siz['1'] = wppa_get_photoy($id);
                    }
                    $link = wppa_get_photo_url($id, '', $siz['0'], $siz['1']);
                    if (wppa_has_audio($id)) {
                        $link = wppa_fix_poster_ext($link, $id);
                    }
                    $is_video = wppa_is_video($id);
                    $has_audio = wppa_has_audio($id);
                    // Open the anchor tag for lightbox
                    wppa_out("\n\t" . '<a' . ' href="' . $link . '"' . ($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') . '[alw-' . wppa('mocc') . '-' . $albumid . ']"' . ' ' . wppa('lbtitle') . '="' . $title . '"' . ' >');
                    // the cover image
                    if ($id == $image['id']) {
                        if (wppa_is_video($image['id'])) {
                            wppa_out('<video preload="metadata" class="image wppa-img" id="i-' . $image['id'] . '-' . wppa('mocc') . '" title="' . wppa_zoom_in($image['id']) . '" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . $imgattr_a['cursor'] . '" ' . $events . ' >' . wppa_get_video_body($image['id']) . '</video>');
                        } else {
                            wppa_out('<img class="image wppa-img" id="i-' . $image['id'] . '-' . wppa('mocc') . '" title="' . wppa_zoom_in($image['id']) . '" src="' . $src . '" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . $imgattr_a['cursor'] . '" ' . $events . ' ' . wppa_get_imgalt($image['id']) . ' />');
                        }
                    }
                    // Close the lightbox anchor tag
                    wppa_out("\n\t" . '</a>');
                }
            }
        } else {
            $href = $photolink['url'] == '#' ? '' : 'href="' . wppa_convert_to_pretty($photolink['url']) . '" ';
            wppa_out('<a' . ' ' . $href . ' target="' . $photolink['target'] . '"' . ' title="' . $photolink['title'] . '"' . ' onclick="' . $photolink['onclick'] . '"' . ' >');
            // A video?
            if (wppa_is_video($image['id'])) {
                wppa_out('<video preload="metadata" ' . $title . '" class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' >' . wppa_get_video_body($image['id']) . '</video>');
            } else {
                wppa_out('<img src="' . $src . '" ' . wppa_get_imgalt($image['id']) . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' />');
            }
            wppa_out('</a>');
        }
    } else {
        // A video?
        if (wppa_is_video($image['id'])) {
            wppa_out('<video preload="metadata" class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' >' . wppa_get_video_body($image['id']) . '</video>');
        } else {
            wppa_out('<img src="' . $src . '" ' . wppa_get_imgalt($image['id']) . ' class="image wppa-img" width="' . $imgwidth . '" height="' . $imgheight . '" style="' . __wcs('wppa-img') . $imgattr . '" ' . $events . ' />');
        }
    }
    // Close the coverphoto frame
    wppa_out('</div>');
}
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_get_photo_desc($id, $do_shortcodes = false, $do_geo = false)
{
    // Verify args
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_photo_desc( ' . $id . ' )', 'red');
        return '';
    }
    // Get data
    $thumb = wppa_cache_thumb($id);
    $desc = $thumb['description'];
    // Raw data
    $desc = stripslashes($desc);
    // Unescape
    $desc = __($desc, 'wp-photo-album-plus');
    // qTranslate
    // To prevent recursive rendering of scripts or shortcodes:
    $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc);
    // Geo
    if ($thumb['location'] && !wppa_in_widget() && strpos(wppa_opt('custom_content'), 'w#location') !== false && $do_geo == 'do_geo') {
        wppa_do_geo($id, $thumb['location']);
    }
    // Other keywords
    $desc = wppa_translate_photo_keywords($id, $desc);
    // Shortcodes
    if ($do_shortcodes) {
        $desc = do_shortcode($desc);
    } else {
        $desc = strip_shortcodes($desc);
    }
    // Remove shortcodes if not wanted
    $desc = wppa_html($desc);
    // Enable html
    $desc = balanceTags($desc, true);
    // Balance tags
    $desc = wppa_filter_iptc($desc, $id);
    // Render IPTC tags
    $desc = wppa_filter_exif($desc, $id);
    // Render EXIF tags
    $desc = make_clickable($desc);
    // Auto make a tags for links
    $desc = convert_smilies($desc);
    // Make smilies visible
    // CMTooltipGlossary on board?
    $desc = wppa_filter_glossary($desc);
    return $desc;
}
Exemple #14
0
function wppa_get_photo_desc($id, $do_shortcodes = false, $do_geo = false)
{
    // Verify args
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_photo_desc( ' . $id . ' )', 'red');
        return '';
    }
    // Get data
    $thumb = wppa_cache_thumb($id);
    $desc = $thumb['description'];
    // Raw data
    $desc = stripslashes($desc);
    // Unescape
    $desc = __($desc, 'wp-photo-album-plus');
    // qTranslate
    // To prevent recursive rendering of scripts or shortcodes:
    $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc);
    // Geo
    if ($thumb['location'] && !wppa_in_widget() && strpos(wppa_opt('custom_content'), 'w#location') !== false && $do_geo == 'do_geo') {
        wppa_do_geo($id, $thumb['location']);
    }
    // Other keywords
    if (strpos($desc, 'w#') !== false) {
        // Is there any 'w#' ?
        // Keywords
        $desc = str_replace('w#albumname', wppa_get_album_name($thumb['album']), $desc);
        $desc = str_replace('w#albumid', $thumb['album'], $desc);
        $keywords = array('name', 'filename', 'owner', 'id', 'tags', 'views', 'album');
        foreach ($keywords as $keyword) {
            $replacement = __(trim(stripslashes($thumb[$keyword])), 'wp-photo-album-plus');
            if ($keyword == 'tags') {
                $replacement = trim($replacement, ',');
            }
            if ($replacement == '') {
                $replacement = '&lsaquo;' . __('none', 'wp-photo-album-plus') . '&rsaquo;';
            }
            $desc = str_replace('w#' . $keyword, $replacement, $desc);
        }
        $desc = str_replace('w#url', wppa_get_lores_url($id), $desc);
        $desc = str_replace('w#hrurl', esc_attr(wppa_get_hires_url($id)), $desc);
        $desc = str_replace('w#tnurl', wppa_get_tnres_url($id), $desc);
        $desc = str_replace('w#pl', wppa_get_source_pl($id), $desc);
        // Art monkey sizes
        if (strpos($desc, 'w#amx') !== false || strpos($desc, 'w#amy') !== false || strpos($desc, 'w#amfs') !== false) {
            $amxy = wppa_get_artmonkey_size_a($id);
            if (is_array($amxy)) {
                $desc = str_replace('w#amx', $amxy['x'], $desc);
                $desc = str_replace('w#amy', $amxy['y'], $desc);
                $desc = str_replace('w#amfs', $amxy['s'], $desc);
            } else {
                $desc = str_replace('w#amx', 'N.a.', $desc);
                $desc = str_replace('w#amy', 'N.a.', $desc);
                $desc = str_replace('w#amfs', 'N.a.', $desc);
            }
        }
        // Timestamps
        $timestamps = array('timestamp', 'modified');
        foreach ($timestamps as $timestamp) {
            if ($thumb[$timestamp]) {
                $desc = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $thumb[$timestamp]), $desc);
            } else {
                $desc = str_replace('w#' . $timestamp, '&lsaquo;' . __('unknown', 'wp-photo-album-plus') . '&rsaquo;', $desc);
            }
        }
        // Custom data fields
        if (wppa_switch('custom_fields')) {
            $custom = $thumb['custom'];
            $custom_data = $custom ? unserialize($custom) : array('', '', '', '', '', '', '', '', '', '');
            for ($i = '0'; $i < '10'; $i++) {
                if (wppa_opt('custom_caption_' . $i)) {
                    // Field defined
                    if (wppa_switch('custom_visible_' . $i)) {
                        // May be displayed
                        $desc = str_replace('w#cc' . $i, __(wppa_opt('custom_caption_' . $i), 'wp-photo-album-plus') . ':', $desc);
                        // Caption
                        $desc = str_replace('w#cd' . $i, __(stripslashes($custom_data[$i]), 'wp-photo-album-plus'), $desc);
                        // Data
                    } else {
                        // May not be displayed
                        $desc = str_replace('w#cc' . $i, '', $desc);
                        // Remove
                        $desc = str_replace('w#cd' . $i, '', $desc);
                        // Remove
                    }
                } else {
                    // Field not defined
                    $desc = str_replace('w#cc' . $i, '', $desc);
                    // Remove
                    $desc = str_replace('w#cd' . $i, '', $desc);
                    // Remove
                }
            }
        }
    }
    // Shortcodes
    if ($do_shortcodes) {
        $desc = do_shortcode($desc);
    } else {
        $desc = strip_shortcodes($desc);
    }
    // Remove shortcodes if not wanted
    $desc = wppa_html($desc);
    // Enable html
    $desc = balanceTags($desc, true);
    // Balance tags
    $desc = wppa_filter_iptc($desc, $id);
    // Render IPTC tags
    $desc = wppa_filter_exif($desc, $id);
    // Render EXIF tags
    $desc = make_clickable($desc);
    // Auto make a tags for links
    $desc = convert_smilies($desc);
    // Make smilies visible
    // CMTooltipGlossary on board?
    $desc = wppa_filter_glossary($desc);
    return $desc;
}