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

' . $content . '
</script>
';
    }
}
コード例 #3
0
ファイル: wppa-links.php プロジェクト: lchen01/STEdwards
function wppa_page_links($npages = '1', $curpage = '1', $slide = false)
{
    if ($npages < '2') {
        return;
    }
    // Nothing to display
    if (is_feed()) {
        return;
    }
    // Compose the Previous and Next Page urls
    // Get the main link
    $link_url = wppa_get_permalink();
    $ajax_url = wppa_get_ajaxlink();
    // cover
    if (wppa_get_get('cover')) {
        $ic = wppa_get_get('cover');
    } else {
        if (wppa('is_cover') == '1') {
            $ic = '1';
        } else {
            $ic = '0';
        }
    }
    $extra_url = 'wppa-cover=' . $ic;
    // occur
    $occur = wppa_in_widget() ? wppa_get_get('woccur') : wppa_get_get('occur');
    $ref_occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur');
    // album
    if (($occur == $ref_occur || wppa('ajax')) && wppa_get_get('album')) {
        $alb = wppa_get_get('album');
    } elseif (wppa('start_album')) {
        $alb = wppa('start_album');
    } else {
        $alb = '0';
    }
    $extra_url .= '&amp;wppa-album=' . $alb;
    // slide or photo
    if ($slide) {
        $extra_url .= '&amp;wppa-slide=1';
    } elseif (wppa_get_get('photo')) {
        $extra_url .= '&amp;wppa-photo=' . wppa_get_get('photo');
    }
    // occur
    if (!wppa('ajax')) {
        $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur');
        $w = wppa_in_widget() ? 'w' : '';
        $extra_url .= '&amp;wppa-' . $w . 'occur=' . $occur;
    } else {
        if (wppa_get_get('occur')) {
            $occur = wppa_get_get('occur');
            $extra_url .= '&amp;wppa-occur=' . strval(intval($occur));
        } elseif (wppa_get_get('woccur')) {
            $occur = wppa_get_get('woccur');
            $extra_url .= '&amp;wppa-woccur=' . strval(intval($occur));
        } else {
            $extra_url .= '&amp;wppa-occur=' . wppa('occur');
            // Should never get here?
        }
    }
    // Topten?
    if (wppa('is_topten')) {
        $extra_url .= '&amp;wppa-topten=' . wppa('topten_count');
    }
    // Lasten?
    if (wppa('is_lasten')) {
        $extra_url .= '&amp;wppa-lasten=' . wppa('lasten_count');
    }
    // Comten?
    if (wppa('is_comten')) {
        $extra_url .= '&amp;wppa-comten=' . wppa('comten_count');
    }
    // Featen?
    if (wppa('is_featen')) {
        $extra_url .= '&amp;wppa-featen=' . wppa('featen_count');
    }
    // Tag?
    if (wppa('is_tag') && !wppa('is_related')) {
        $extra_url .= '&amp;wppa-tag=' . wppa('is_tag');
    }
    // Search?
    if (wppa('src') && !wppa('is_related')) {
        $extra_url .= '&amp;wppa-searchstring=' . urlencode(wppa('searchstring'));
    }
    // Supersearch?
    if (wppa('supersearch')) {
        $extra_url .= '&amp;wppa-supersearch=' . urlencode(wppa('supersearch'));
    }
    // Related
    if (wppa('is_related')) {
        $extra_url .= '&amp;wppa-rel=' . wppa('is_related') . '&amp;wppa-relcount=' . wppa('related_count');
    }
    // Uploader?
    if (wppa('is_upldr')) {
        $extra_url .= '&amp;wppa-upldr=' . wppa('is_upldr');
    }
    // Calendar ?
    if (wppa('calendar')) {
        $extra_url .= '&amp;wppa-calendar=' . wppa('calendar') . '&amp;wppa-caldate=' . wppa('caldate');
    }
    // Photos only?
    if (wppa('photos_only')) {
        $extra_url .= '&amp;wppa-photos-only=1';
    }
    // Albums only?
    if (wppa('albums_only')) {
        $extra_url .= '&amp;wppa-albums-only=1';
    }
    // Inverse?
    if (wppa('is_inverse')) {
        $extra_url .= '&amp;wppa-inv=1';
    }
    // Almost ready
    $link_url .= $extra_url;
    $ajax_url .= $extra_url;
    // Compress
    $link_url = wppa_trim_wppa_($link_url);
    $ajax_url = wppa_trim_wppa_($ajax_url);
    // Adjust display range
    $from = 1;
    $to = $npages;
    if ($npages > wppa_opt('pagelinks_max')) {
        $delta = floor(wppa_opt('pagelinks_max') / 2);
        $from = $curpage - $delta;
        $to = $curpage + $delta;
        while ($from < '1') {
            $from++;
            $to++;
        }
        while ($to > $npages) {
            $from--;
            $to--;
        }
    }
    // Doit
    wppa_out("\n" . '<div class="wppa-nav-text wppa-box wppa-nav" style="clear:both; text-align:center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . '" >');
    $vis = $curpage == '1' ? 'visibility: hidden;' : '';
    wppa_out('<div style="float:left; text-align:left; ' . $vis . '">');
    wppa_out('<span class="wppa-arrow" style="' . __wcs('wppa-arrow') . 'cursor: default;">&laquo;&nbsp;</span>');
    if (wppa_switch('wppa_allow_ajax')) {
        wppa_out('<a style="cursor:pointer;" onclick="wppaDoAjaxRender(' . wppa('mocc') . ', \'' . $ajax_url . '&amp;wppa-page=' . ($curpage - 1) . '\', \'' . wppa_convert_to_pretty($link_url . '&amp;wppa-page=' . ($curpage - 1)) . '\')" >' . __('Previous', 'wp-photo-album-plus') . '</a>');
    } else {
        wppa_out('<a style="cursor:pointer;" href="' . $link_url . '&amp;wppa-page=' . ($curpage - 1) . '" >' . __('Previous', 'wp-photo-album-plus') . '</a>');
    }
    wppa_out('</div><!-- #prev-page -->');
    $vis = $curpage == $npages ? 'visibility: hidden;' : '';
    wppa_out('<div style="float:right; text-align:right; ' . $vis . '">');
    if (wppa_switch('wppa_allow_ajax')) {
        wppa_out('<a style="cursor:pointer;" onclick="wppaDoAjaxRender(' . wppa('mocc') . ', \'' . $ajax_url . '&amp;wppa-page=' . ($curpage + 1) . '\', \'' . wppa_convert_to_pretty($link_url . '&amp;wppa-page=' . ($curpage + 1)) . '\')" >' . __('Next', 'wp-photo-album-plus') . '</a>');
    } else {
        wppa_out('<a style="cursor:pointer;" href="' . $link_url . '&amp;wppa-page=' . ($curpage + 1) . '" >' . __('Next', 'wp-photo-album-plus') . '</a>');
    }
    wppa_out('<span class="wppa-arrow" style="' . __wcs('wppa-arrow') . 'cursor: default;">&nbsp;&raquo;</span>');
    wppa_out('</div><!-- #next-page -->');
    // The numbered pagelinks ?
    if (wppa_opt('pagelinks_max')) {
        if ($from > '1') {
            wppa_out('.&nbsp;.&nbsp;.&nbsp;');
        }
        for ($i = $from; $i <= $to; $i++) {
            if ($curpage == $i) {
                wppa_out('<div class="wppa-mini-box wppa-alt wppa-black" style="display:inline; text-align:center; ' . __wcs('wppa-mini-box') . __wcs('wppa-alt') . __wcs('wppa-black') . ' text-decoration: none; cursor: default; font-weight:normal; " >');
                wppa_out('&nbsp;' . $i . '&nbsp;');
                wppa_out('</div>');
            } else {
                wppa_out('<div class="wppa-mini-box wppa-even" style="display:inline; text-align:center; ' . __wcs('wppa-mini-box') . __wcs('wppa-even') . '" >');
                if (!$slide && wppa_switch('wppa_allow_ajax') || $slide && wppa_switch('wppa_slideshow_page_allow_ajax')) {
                    wppa_out('<a style="cursor:pointer;" onclick="wppaDoAjaxRender(' . wppa('mocc') . ', \'' . $ajax_url . '&amp;wppa-page=' . $i . '\', \'' . wppa_convert_to_pretty($link_url . '&amp;wppa-page=' . $i) . '\')">&nbsp;' . $i . '&nbsp;</a>');
                } else {
                    wppa_out('<a style="cursor:pointer;" href="' . $link_url . '&amp;wppa-page=' . $i . '">&nbsp;' . $i . '&nbsp;</a>');
                }
                wppa_out('</div>');
            }
        }
        if ($to < $npages) {
            wppa_out('&nbsp;.&nbsp;.&nbsp;.');
        }
    } else {
        wppa_out($curpage . '/' . $npages);
    }
    wppa_out('</div><!-- #prevnext-a-' . wppa('mocc') . ' -->');
}
コード例 #4
0
ファイル: wppa-slideshow.php プロジェクト: lchen01/STEdwards
function wppa_slide_filmstrip($opt = '')
{
    // A single image slideshow needs no navigation
    if (wppa('is_single')) {
        return;
    }
    $do_it = false;
    // Init
    if (is_feed()) {
        $do_it = true;
    } else {
        // Not a feed
        if ($opt != 'optional') {
            $do_it = true;
        } else {
            // optional
            if (wppa_switch('wppa_filmstrip')) {
                // optional and option on
                if (!wppa('is_slideonly')) {
                    $do_it = true;
                }
                // always except slideonly
            }
            if (wppa('film_on')) {
                $do_it = true;
            }
            // explicitly turned on
        }
    }
    if (!$do_it) {
        return;
    }
    // Don't do it
    $t = -microtime(true);
    $alb = wppa_get_get('album');
    $thumbs = wppa_get_thumbs();
    if (!$thumbs || count($thumbs) < 1) {
        return;
    }
    $preambule = wppa_get_preambule();
    $width = (wppa_opt('tf_width') + wppa_opt('tn_margin')) * (count($thumbs) + 2 * $preambule);
    $width += wppa_opt('tn_margin') + 2;
    $topmarg = wppa_opt('thumbsize') / 2 - 16;
    $height = wppa_opt('thumbsize') + wppa_opt('tn_margin');
    $height1 = wppa_opt('thumbsize');
    $marg = '42';
    // 32
    $fs = '24';
    $fw = '42';
    if (wppa_in_widget()) {
        $width /= 2;
        $topmarg /= 2;
        $height /= 2;
        $height1 /= 2;
        $marg = '21';
        $fs = '12';
        $fw = '21';
    }
    $conw = wppa_get_container_width();
    if ($conw < 1) {
        $conw *= 640;
    }
    $w = $conw - (2 * 6 + 2 * 42 + 2 * wppa_opt('bwidth'));
    /* 2*padding + 2*arrows + 2*border */
    if (wppa_in_widget()) {
        $w = $conw - (2 * 6 + 2 * 21 + 2 * wppa_opt('bwidth'));
    }
    /* 2*padding + 2*arrow + 2*border */
    $IE6 = 'width: ' . $w . 'px;';
    $pagsiz = round($w / (wppa_opt('thumbsize') + wppa_opt('tn_margin')));
    if (wppa_in_widget()) {
        $pagsiz = round($w / (wppa_opt('thumbsize') / 2 + wppa_opt('tn_margin') / 2));
    }
    wppa_add_js_page_data('<script type="text/javascript">');
    wppa_add_js_page_data('wppaFilmPageSize[' . wppa('mocc') . '] = ' . $pagsiz . ';');
    wppa_add_js_page_data('</script>');
    if (is_feed()) {
        wppa_out('<div style="' . __wcs('wppa-box') . __wcs('wppa-nav') . '">');
    } else {
        wppa_out('<div' . ' class="wppa-box wppa-nav"' . ' style="text-align:center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . 'height:' . $height . 'px;"' . ' >' . '<div' . ' style="float:left; text-align:left; cursor:pointer; margin-top:' . $topmarg . 'px; width: ' . $fw . 'px; font-size: ' . $fs . 'px;"' . ' >' . '<a' . ' class="wppa-prev-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="prev-film-arrow-' . wppa('mocc') . '"' . ' onclick="wppaFirst(' . wppa('mocc') . ');"' . ' title="' . __('First', 'wp-photo-album-plus') . '"' . ' >' . '&laquo;' . '</a>' . '<a' . ' class="wppa-prev-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="prev-film-arrow-1-' . wppa('mocc') . '"' . ' onclick="wppaPrev(' . wppa('mocc') . ');"' . ' title="' . __('Previous', 'wp-photo-album-plus') . '"' . ' >' . '&lsaquo;' . '</a>' . '</div>' . '<div' . ' style="float:right; text-align:right; cursor:pointer; margin-top:' . $topmarg . 'px; width: ' . $fw . 'px; font-size: ' . $fs . 'px;"' . ' >' . '<a' . ' class="wppa-next-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="next-film-arrow-1-' . wppa('mocc') . '"' . ' onclick="wppaNext(' . wppa('mocc') . ');"' . ' title="' . __('Next', 'wp-photo-album-plus') . '"' . ' >' . '&rsaquo;' . '</a>' . '<a' . ' class="wppa-next-' . wppa('mocc') . ' wppa-arrow"' . ' style="' . __wcs('wppa-arrow') . '"' . ' id="next-film-arrow-' . wppa('mocc') . '"' . ' onclick="wppaLast(' . wppa('mocc') . ');"' . ' title="' . __('Last', 'wp-photo-album-plus') . '"' . ' >' . '&raquo;' . '</a>' . '</div>' . '<div' . ' id="filmwindow-' . wppa('mocc') . '"' . ' class="filmwindow"' . ' style="' . $IE6 . ' position:absolute; display: block; height:' . $height . 'px; margin: 0 0 0 ' . $marg . 'px; overflow:hidden;"' . ' >' . '<div' . ' id="wppa-filmstrip-' . wppa('mocc') . '"' . ' style="height:' . $height1 . 'px; width:' . $width . 'px; max-width:' . $width . 'px;margin-left: -100px;"' . ' >');
    }
    wppa_out('<style type="text/css" scoped >' . '.thumbnail-frame { ' . wppa_get_thumb_frame_style(false, 'film') . ' }' . '.wppa-filmthumb-active { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }' . '</style>');
    $cnt = count($thumbs);
    $start = $cnt - $preambule;
    $end = $cnt;
    $idx = $start;
    // Preambule
    while ($idx < $end) {
        $glue = $cnt == $idx + 1 ? true : false;
        $ix = $idx;
        while ($ix < 0) {
            $ix += $cnt;
        }
        $thumb = $thumbs[$ix];
        wppa_do_filmthumb($thumb['id'], $ix, false, $glue);
        $idx++;
    }
    // Real thumbs
    $idx = 0;
    foreach ($thumbs as $tt) {
        $thumb = $tt;
        $glue = $cnt == $idx + 1 ? true : false;
        wppa_do_filmthumb($thumb['id'], $idx, true, $glue);
        $idx++;
    }
    // Postambule
    $start = '0';
    $end = $preambule;
    $idx = $start;
    while ($idx < $end) {
        $ix = $idx;
        while ($ix >= $cnt) {
            $ix -= $cnt;
        }
        $thumb = $thumbs[$ix];
        wppa_do_filmthumb($thumb['id'], $ix, false);
        $idx++;
    }
    if (is_feed()) {
        wppa_out('</div>');
    } else {
        wppa_out('</div>');
        wppa_out('</div>');
        wppa_out('</div>');
    }
    $t += microtime(true);
    wppa_dbg_msg('Filmstrip took ' . $t . ' seconds.');
}
コード例 #5
0
function wppa_get_get($index)
{
    static $wppa_get_get_cache;
    // Found this already?
    if (isset($wppa_get_get_cache[$index])) {
        return $wppa_get_get_cache[$index];
    }
    // See if set
    if (isset($_GET['wppa-' . $index])) {
        // New syntax first
        $result = $_GET['wppa-' . $index];
    } elseif (isset($_GET[$index])) {
        // Old syntax
        $result = $_GET[$index];
    } else {
        return false;
    }
    // Not set
    if ($result == 'nil') {
        return false;
    }
    // Nil simulates not set
    if (!strlen($result)) {
        $result = '1';
    }
    // Set but no value
    // Sanitize
    $result = strip_tags($result);
    if (strpos($result, '<?') !== false) {
        die('Security check failure #191');
    }
    if (strpos($result, '?>') !== false) {
        die('Security check failure #192');
    }
    // Post processing needed?
    if ($index == 'photo' && !wppa_is_int($result)) {
        // Encrypted?
        $result = wppa_decrypt_photo($result);
        // By name?
        $result = wppa_get_photo_id_by_name($result, wppa_get_album_id_by_name(wppa_get_get('album')));
        if (!$result) {
            return false;
        }
        // Non existing photo, treat as not set
    }
    if ($index == 'album') {
        // Encrypted?
        $result = wppa_decrypt_album($result);
        if (!wppa_is_int($result)) {
            $temp = wppa_get_album_id_by_name($result);
            if (wppa_is_int($temp) && $temp > '0') {
                $result = $temp;
            } elseif (!wppa_series_to_array($result)) {
                $result = false;
            }
        }
    }
    // Save in cache
    $wppa_get_get_cache[$index] = $result;
    return $result;
}
コード例 #6
0
function wppa_get_randseed($type = '')
{
    global $wppa_session;
    static $volatile_randseed;
    static $randseed_modified;
    // This randseed is for the page only
    if ($type == 'page') {
        if ($volatile_randseed) {
            $randseed = $volatile_randseed;
        } else {
            $volatile_randseed = time() % 7487;
            $randseed = $volatile_randseed;
        }
    } elseif ($type == 'session') {
        $randseed = $wppa_session['id'];
        //session_randseed'];
    } else {
        if (isset($wppa_session['randseed']) && !$randseed_modified) {
            $old_album = isset($wppa_session['albumspec']) ? $wppa_session['albumspec'] : false;
            $new_album = wppa_get_get('album');
            if ($new_album === false || $old_album && $old_album != $new_album) {
                unset($wppa_session['randseed']);
                // Forget randseed
            }
        }
        if (isset($wppa_session['randseed'])) {
            $randseed = $wppa_session['randseed'];
        } else {
            $randseed = time() % 4721;
            $wppa_session['randseed'] = $randseed;
            // Save old album for later
            $wppa_session['albumspec'] = wppa_get_get('album');
            $randseed_modified = true;
        }
    }
    return $randseed;
}
コード例 #7
0
ファイル: wppa-breadcrumb.php プロジェクト: lchen01/STEdwards
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>');
}
コード例 #8
0
function wppa_container($action)
{
    global $wppa_version;
    // The theme version ( wppa_theme.php )
    global $wppa_microtime;
    global $wppa_microtime_cum;
    global $wppa_err_displayed;
    global $wppa_loadtime;
    global $wppa_initruntimetime;
    static $wppa_numqueries;
    static $auto;
    global $blog_id;
    if (is_feed()) {
        return;
    }
    // Need no container in RSS feeds
    if ($action == 'open') {
        $wppa_numqueries = get_num_queries();
        // Open the container
        if (!wppa('ajax')) {
            //			wppa( 'out' ) .= '<!-- Start WPPA+ generated code'.( is_multisite() ? ', Multi site, id='.$blog_id : ', Single site' ).' -->';
            //			if ( wppa( 'shortcode_content' ) ) {
            //				wppa( 'out' ) .= '<!-- ' . wppa( 'shortcode_content' ) . ' -->';
            //			}
            wppa_out('<div' . ' id="wppa-container-' . wppa('mocc') . '"' . ' style="' . wppa_get_container_style() . '"' . ' class="' . 'wppa-container' . ' ' . 'wppa-container-' . wppa('mocc') . ' ' . 'wppa-rev-' . wppa('revno') . ' ' . 'wppa-prevrev-' . wppa_opt('prevrev') . ' ' . 'wppa-theme-' . $wppa_version . ' ' . 'wppa-api-' . wppa('api_version') . '"' . ' >');
        }
        // Spinner for Ajax
        if (wppa_switch('allow_ajax')) {
            if (!wppa_in_widget()) {
                wppa_out('<img' . ' id="wppa-ajax-spin-' . wppa('mocc') . '"' . ' src="' . wppa_get_imgdir() . 'loader.gif"' . ' alt="spinner"' . ' style="' . 'box-shadow:none;' . 'z-index:1010;' . 'position:fixed;' . 'top:50%;' . 'margin-top:-32px;' . 'left:50%;' . 'margin-left:-32px;' . 'display:none;' . '"' . ' />');
            }
        }
        // Start timer if in debug mode
        if (wppa('debug')) {
            $wppa_microtime = -microtime(true);
            wppa_dbg_q('init');
        }
        if (wppa('mocc') == '1') {
            wppa_dbg_msg('Plugin load time :' . substr($wppa_loadtime, 0, 5) . 's.');
            wppa_dbg_msg('Init runtime time :' . substr($wppa_initruntimetime, 0, 5) . 's.');
            wppa_dbg_msg('Num queries before wppa :' . get_num_queries());
        }
        /* Check if wppa.js and jQuery are present */
        if (!$wppa_err_displayed && (WPPA_DEBUG || wppa_get_get('debug') || WP_DEBUG) && !wppa_switch('defer_javascript')) {
            wppa_out('<script type="text/javascript">/* <![CDATA[ */');
            wppa_out("if ( typeof( _wppaSlides ) == 'undefined' ) " . "alert( 'There is a problem with your theme. The file wppa.js is not loaded when it is expected ( Errloc = wppa_container ).' );");
            wppa_out("if ( typeof( jQuery ) == 'undefined' ) " . "alert( 'There is a problem with your theme. The jQuery library is not loaded when it is expected ( Errloc = wppa_container ).' );");
            wppa_out("/* ]]> */</script>");
            $wppa_err_displayed = true;
        }
        /* Check if init is properly done */
        if (!wppa_opt('fullsize')) {
            wppa_out('<script type="text/javascript">/* <![CDATA[ */');
            wppa_out("alert( 'The initialisation of wppa+ is not complete yet. " . "You will probably see division by zero errors. " . "Please run Photo Albums -> Settings admin page Table VIII-A1. ( Errloc = wppa_container ).' );");
            wppa_out("/* ]]> */</script>");
        }
        // Nonce field check for rating security
        if (wppa('mocc') == '1') {
            if (wppa_get_get('rating')) {
                $nonce = wppa_get_get('nonce');
                $ok = wp_verify_nonce($nonce, 'wppa-check');
                if ($ok) {
                    wppa_dbg_msg('Rating nonce ok');
                    if (!is_user_logged_in()) {
                        sleep(2);
                    }
                } else {
                    die('<b>' . __('ERROR: Illegal attempt to enter a rating.', 'wp-photo-album-plus') . '</b>');
                }
            }
        }
        // Nonce field check for comment security
        if (wppa('mocc') == '1') {
            if (wppa_get_post('comment')) {
                $nonce = wppa_get_post('nonce');
                $ok = wp_verify_nonce($nonce, 'wppa-check');
                if ($ok) {
                    wppa_dbg_msg('Comment nonce ok');
                    if (!is_user_logged_in()) {
                        sleep(2);
                    }
                } else {
                    die('<b>' . __('ERROR: Illegal attempt to enter a comment.', 'wp-photo-album-plus') . '</b>');
                }
            }
        }
        wppa_out(wppa_nonce_field('wppa-check', 'wppa-nonce', false, false));
        if (wppa_page('oneofone')) {
            wppa('portrait_only', true);
        }
        wppa('alt', 'alt');
        // Javascript occurrence dependant stuff
        wppa_add_js_page_data("\n" . '<script type="text/javascript">');
        // wppa( 'auto_colwidth' ) is set by the filter or by wppa_albums in case called directly
        // wppa_opt( 'colwidth' ) is the option setting
        // script or call has precedence over option setting
        // so: if set by script or call: auto, else if set by option: auto
        $auto = false;
        $contw = wppa_get_container_width();
        if (wppa('auto_colwidth')) {
            $auto = true;
        } elseif (wppa_opt('colwidth') == 'auto') {
            $auto = true;
        } elseif ($contw > 0 && $contw <= 1.0) {
            $auto = true;
        }
        if ($auto) {
            wppa_add_js_page_data("\n" . 'wppaAutoColumnWidth[' . wppa('mocc') . '] = true;');
            if ($contw > 0 && $contw <= 1.0) {
                wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = ' . $contw . ';');
            } else {
                wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = 1.0;');
            }
            wppa_add_js_page_data("\n" . 'wppaColWidth[' . wppa('mocc') . '] = 0;');
        } else {
            wppa_add_js_page_data("\n" . 'wppaAutoColumnWidth[' . wppa('mocc') . '] = false;');
            wppa_add_js_page_data("\n" . 'wppaColWidth[' . wppa('mocc') . '] = ' . wppa_get_container_width() . ';');
        }
        wppa_add_js_page_data("\n" . 'wppaTopMoc = ' . wppa('mocc') . ';');
        if (wppa_opt('thumbtype') == 'masonry-v') {
            wppa_add_js_page_data("\n" . 'wppaMasonryCols[' . wppa('mocc') . '] = ' . ceil(wppa_get_container_width() / wppa_opt('thumbsize')) . ';');
        } else {
            wppa_add_js_page_data("\n" . 'wppaMasonryCols[' . wppa('mocc') . '] = 0;');
        }
        if (wppa('src_script')) {
            wppa_add_js_page_data("\n" . wppa('src_script'));
        }
        // Aspect ratio and fullsize
        if (wppa_in_widget() == 'ss' && is_numeric(wppa('in_widget_frame_width')) && wppa('in_widget_frame_width') > '0') {
            $asp = wppa('in_widget_frame_height') / wppa('in_widget_frame_width');
            $fls = wppa('in_widget_frame_width');
        } else {
            $asp = wppa_opt('maxheight') / wppa_opt('fullsize');
            $fls = wppa_opt('fullsize');
        }
        wppa_add_js_page_data("\n" . 'wppaAspectRatio[' . wppa('mocc') . '] = ' . $asp . ';');
        wppa_add_js_page_data("\n" . 'wppaFullSize[' . wppa('mocc') . '] = ' . $fls . ';');
        // last minute change: fullvalign with border needs a height correction in slideframe
        if (wppa_opt('fullimage_border_width') != '' && !wppa_in_widget()) {
            $delta = (1 + wppa_opt('fullimage_border_width')) * 2;
        } else {
            $delta = 0;
        }
        wppa_add_js_page_data("\n" . 'wppaFullFrameDelta[' . wppa('mocc') . '] = ' . $delta . ';');
        // last minute change: script %%size != default colwidth
        $temp = wppa_get_container_width() - (2 * 6 + 2 * 36 + 2 * wppa_opt('bwidth'));
        if (wppa_in_widget()) {
            $temp = wppa_get_container_width() - (2 * 6 + 2 * 18 + 2 * wppa_opt('bwidth'));
        }
        wppa_add_js_page_data("\n" . 'wppaFilmStripLength[' . wppa('mocc') . '] = ' . $temp . ';');
        // last minute change: filmstrip sizes and related stuff. In widget: half size.
        $temp = wppa_opt('tf_width') + wppa_opt('tn_margin');
        if (wppa_in_widget()) {
            $temp /= 2;
        }
        wppa_add_js_page_data("\n" . 'wppaThumbnailPitch[' . wppa('mocc') . '] = ' . $temp . ';');
        $temp = wppa_opt('tn_margin') / 2;
        if (wppa_in_widget()) {
            $temp /= 2;
        }
        wppa_add_js_page_data("\n" . 'wppaFilmStripMargin[' . wppa('mocc') . '] = ' . $temp . ';');
        $temp = 2 * 6 + 2 * 42 + 2 * wppa_opt('bwidth');
        if (wppa_in_widget()) {
            $temp = 2 * 6 + 2 * 21 + 2 * wppa_opt('bwidth');
        }
        wppa_add_js_page_data("\n" . 'wppaFilmStripAreaDelta[' . wppa('mocc') . '] = ' . $temp . ';');
        if (wppa_in_widget()) {
            wppa_add_js_page_data("\n" . 'wppaIsMini[' . wppa('mocc') . '] = true;');
        } else {
            wppa_add_js_page_data("\n" . 'wppaIsMini[' . wppa('mocc') . '] = false;');
        }
        $target = false;
        if (wppa_in_widget() == 'ss' && wppa_switch('sswidget_blank')) {
            $target = true;
        }
        if (!wppa_in_widget() && wppa_switch('slideshow_blank')) {
            $target = true;
        }
        if ($target) {
            wppa_add_js_page_data("\n" . 'wppaSlideBlank[' . wppa('mocc') . '] = true;');
        } else {
            wppa_add_js_page_data("\n" . 'wppaSlideBlank[' . wppa('mocc') . '] = false;');
        }
        wppa_add_js_page_data("\n" . 'wppaLightBox[' . wppa('mocc') . '] = "xxx";');
        // If this occur is a slideshow, determine if its link is to lightbox. This may differ between normal slideshow or ss widget
        $is_slphoto = wppa('is_slide') && wppa('start_photo') && wppa('is_single');
        if ('ss' == wppa_in_widget() || wppa_page('slide') || $is_slphoto) {
            $ss_linktype = 'ss' == wppa_in_widget() ? wppa_opt('slideonly_widget_linktype') : wppa_opt('slideshow_linktype');
            switch ($ss_linktype) {
                case 'file':
                    $lbkey = 'file';
                    // gives anchor tag with rel="file"
                    break;
                case 'lightbox':
                case 'lightboxsingle':
                    $lbkey = wppa_opt('lightbox_name');
                    // gives anchor tag with rel="lightbox" or the like
                    break;
                default:
                    $lbkey = '';
                    // results in omitting the anchor tag
                    break;
            }
            wppa_add_js_page_data("\n" . 'wppaLightBox[' . wppa('mocc') . '] = "' . $lbkey . '";' . "\n" . 'wppaConsoleLog("mocc:' . wppa('mocc') . ' lbkey:"+wppaLightBox[' . wppa('mocc') . '] );');
            wppa_add_js_page_data("\n" . 'wppaLightboxSingle[' . wppa('mocc') . '] = ' . (wppa_opt('slideshow_linktype') == 'lightboxsingle' ? 'true' : 'false') . ';');
        }
        wppa_add_js_page_data("\n" . '</script>');
    } elseif ($action == 'close') {
        if (wppa_page('oneofone')) {
            wppa('portrait_only', false);
        }
        if (!wppa_in_widget()) {
            wppa_out('<div style="clear:both;"></div>');
        }
        // Add diagnostic <p> if debug is 1
        if (wppa('debug') == '1' && wppa('mocc') == '1') {
            wppa_out('<p id="wppa-debug-' . wppa('mocc') . '" style="font-size:9px; color:#070; line-size:12px;" ></p>');
        }
        // Init lightbox intermediate to facillitate premature clicks to lightbox when not yet document.complete
        wppa_out("\n" . '<script type="text/javascript" >if ( typeof(wppaInitOverlay) != "undefined" ) { wppaInitOverlay(); }</script>');
        if (!wppa('ajax')) {
            wppa_out('<div id="wppa-container-' . wppa('mocc') . '-end" ></div>');
            wppa_out('</div>');
        }
        if (wppa('debug')) {
            $laptim = $wppa_microtime + microtime(true);
            $wppa_numqueries = get_num_queries() - $wppa_numqueries;
            if (!is_numeric($wppa_microtime_cum)) {
                $wppa_mcrotime_cum = '0';
            }
            $wppa_microtime_cum += $laptim;
            wppa_dbg_msg('Time elapsed occ ' . wppa('mocc') . ':' . substr($laptim, 0, 5) . 's. Tot:' . substr($wppa_microtime_cum, 0, 5) . 's.');
            wppa_dbg_msg('Number of queries occ ' . wppa('mocc') . ':' . $wppa_numqueries, 'green');
            wppa_dbg_q('print');
        }
    } else {
        wppa_out("\n" . '<span style="color:red;">Error, wppa_container() called with wrong argument: ' . $action . '. Possible values: \'open\' or \'close\'</span>');
    }
}
コード例 #9
0
function wppa_session_start()
{
    global $wpdb;
    global $wppa_session;
    // If the session table does not yet exist on activation
    if (!wppa_table_exists(WPPA_SESSION)) {
        $wppa_session['id'] = '0';
        return false;
    }
    $lifetime = 3600;
    // Sessions expire after one hour
    $expire = time() - $lifetime;
    // Is session already started?
    $session = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_SESSION . "` WHERE `session` = %s AND `status` = 'valid' LIMIT 1", wppa_get_session_id()), ARRAY_A);
    // Started but expired?
    if ($session) {
        if ($session['timestamp'] < $expire) {
            $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_SESSION . "` SET `status` = 'expired' WHERE `id` = %s", $session['id']));
            $session = false;
        }
    }
    // Get data if valid session exists
    $data = $session ? $session['data'] : false;
    // No valid session exists, start new
    if ($data === false) {
        $iret = wppa_create_session_entry(array());
        if (!$iret) {
            // Failed, retry after 1 sec.
            sleep(1);
            $iret = wppa_create_session_entry(array());
            if (!$iret) {
                wppa_log('Err', 'Unable to create session for user ' . wppa_get_user());
                // Give up
                return false;
            } else {
                wppa_log('Obs', 'Session ' . $iret . ' created after 1 retry for user ' . wppa_get_user());
            }
        }
        $wppa_session = array();
        $wppa_session['page'] = '0';
        $wppa_session['ajax'] = '0';
        $wppa_session['id'] = $iret;
        $wppa_session['user'] = wppa_get_user();
    } else {
        $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_SESSION . "` SET `count` = %s WHERE `id` = %s", $session['count'] + '1', $session['id']));
        $data_arr = unserialize($data);
        if (is_array($data_arr)) {
            $wppa_session = $data_arr;
        } else {
            $wppa_session = array();
        }
    }
    // Get info for root and sub search
    if (isset($_REQUEST['wppa-search-submit'])) {
        $wppa_session['rootbox'] = wppa_get_get('rootsearch') || wppa_get_post('rootsearch');
        $wppa_session['subbox'] = wppa_get_get('subsearch') || wppa_get_post('subsearch');
        if ($wppa_session['subbox']) {
            if (isset($wppa_session['use_searchstring'])) {
                $t = explode(',', $wppa_session['use_searchstring']);
                foreach (array_keys($t) as $idx) {
                    $t[$idx] .= ' ' . wppa_test_for_search('at_session_start');
                    $t[$idx] = trim($t[$idx]);
                    $v = explode(' ', $t[$idx]);
                    $t[$idx] = implode(' ', array_unique($v));
                }
                $wppa_session['use_searchstring'] = ' ' . implode(',', array_unique($t));
            } else {
                $wppa_session['use_searchstring'] = wppa_test_for_search('at_session_start');
            }
        } else {
            $wppa_session['use_searchstring'] = wppa_test_for_search('at_session_start');
        }
        if (isset($wppa_session['use_searchstring'])) {
            $wppa_session['use_searchstring'] = trim($wppa_session['use_searchstring'], ' ,');
            $wppa_session['display_searchstring'] = str_replace(',', ' &#8746 ', str_replace(' ', ' &#8745 ', $wppa_session['use_searchstring']));
        }
    }
    // Add missing defaults
    $defaults = array('has_searchbox' => false, 'rootbox' => false, 'search_root' => '', 'subbox' => false, 'use_searchstring' => '', 'display_searchstring' => '', 'supersearch' => '', 'superview' => 'thumbs', 'superalbum' => '0', 'page' => '0', 'ajax' => '0', 'user' => '', 'id' => '0', 'uris' => array(), 'isrobot' => false);
    $wppa_session = wp_parse_args($wppa_session, $defaults);
    ksort($wppa_session);
    $wppa_session['page']++;
    if (isset($_SERVER['REQUEST_URI'])) {
        $wppa_session['uris'][] = date_i18n("g:i") . ' ' . $_SERVER['REQUEST_URI'];
        if (stripos($_SERVER['REQUEST_URI'], '/robots.txt') !== false) {
            $wppa_session['isrobot'] = true;
        }
    }
    wppa_save_session();
    return true;
}
コード例 #10
0
ファイル: wppa-boxes-html.php プロジェクト: lchen01/STEdwards
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;
}
コード例 #11
0
function wppa_slide_filmstrip($opt = '')
{
    global $wppa;
    global $wppa_opt;
    global $thumb;
    // A single image slideshow needs no navigation
    if ($wppa['is_single']) {
        return;
    }
    $do_it = false;
    // Init
    if (is_feed()) {
        $do_it = true;
    } else {
        // Not a feed
        if ($opt != 'optional') {
            $do_it = true;
        } else {
            // optional
            if (wppa_switch('wppa_filmstrip')) {
                // optional and option on
                if (!$wppa['is_slideonly']) {
                    $do_it = true;
                }
                // always except slideonly
            }
            if ($wppa['film_on']) {
                $do_it = true;
            }
            // explicitly turned on
        }
    }
    if (!$do_it) {
        return;
    }
    // Don't do it
    $t = -microtime(true);
    $alb = wppa_get_get('album');
    // To be tested: // Album id is in $wppa['start_album']
    $thumbs = wppa_get_thumbs($alb);
    if (!$thumbs || count($thumbs) < 1) {
        return;
    }
    $preambule = wppa_get_preambule();
    $width = ($wppa_opt['wppa_tf_width'] + $wppa_opt['wppa_tn_margin']) * (count($thumbs) + 2 * $preambule);
    $width += $wppa_opt['wppa_tn_margin'] + 2;
    $topmarg = $wppa_opt['wppa_thumbsize'] / 2 - 16;
    $height = $wppa_opt['wppa_thumbsize'] + $wppa_opt['wppa_tn_margin'];
    $height1 = $wppa_opt['wppa_thumbsize'];
    $marg = '42';
    // 32
    $fs = '24';
    $fw = '42';
    if ($wppa['in_widget']) {
        $width /= 2;
        $topmarg /= 2;
        $height /= 2;
        $height1 /= 2;
        $marg = '21';
        $fs = '12';
        $fw = '21';
    }
    $conw = wppa_get_container_width();
    if ($conw < 1) {
        $conw *= 640;
    }
    $w = $conw - (2 * 6 + 2 * 42 + 2 * $wppa_opt['wppa_bwidth']);
    /* 2*padding + 2*arrows + 2*border */
    if ($wppa['in_widget']) {
        $w = $conw - (2 * 6 + 2 * 21 + 2 * $wppa_opt['wppa_bwidth']);
    }
    /* 2*padding + 2*arrow + 2*border */
    $IE6 = 'width: ' . $w . 'px;';
    $pagsiz = round($w / ($wppa_opt['wppa_thumbsize'] + $wppa_opt['wppa_tn_margin']));
    if ($wppa['in_widget']) {
        $pagsiz = round($w / ($wppa_opt['wppa_thumbsize'] / 2 + $wppa_opt['wppa_tn_margin'] / 2));
    }
    wppa_add_js_page_data('<script type="text/javascript">');
    //		$wppa['out'] .= wppa_nltab('+').'/* <![CDATA[ */';
    wppa_add_js_page_data('wppaFilmPageSize[' . $wppa['mocc'] . '] = ' . $pagsiz . ';');
    //		$wppa['out'] .= wppa_nltab('-').'/* ]]> */';
    wppa_add_js_page_data('</script>');
    if (is_feed()) {
        $wppa['out'] .= wppa_nltab() . '<div style="' . __wcs('wppa-box') . __wcs('wppa-nav') . '">';
    } else {
        $wppa['out'] .= wppa_nltab('+') . '<div class="wppa-box wppa-nav" style="text-align:center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . 'height:' . $height . 'px;">';
        $wppa['out'] .= wppa_nltab() . '<div style="float:left; text-align:left; cursor:pointer; margin-top:' . $topmarg . 'px; width: ' . $fw . 'px; font-size: ' . $fs . 'px;">';
        $wppa['out'] .= wppa_nltab() . '<a class="wppa-prev-' . $wppa['mocc'] . ' wppa-arrow" style="' . __wcs('wppa-arrow') . '" id="prev-film-arrow-' . $wppa['mocc'] . '" onclick="wppaFirst(' . $wppa['mocc'] . ');" title="' . __a('First', 'wppa_theme') . '" >&laquo;</a>';
        $wppa['out'] .= wppa_nltab() . '<a class="wppa-prev-' . $wppa['mocc'] . ' wppa-arrow" style="' . __wcs('wppa-arrow') . '" id="prev-film-arrow-1-' . $wppa['mocc'] . '" onclick="wppaPrev(' . $wppa['mocc'] . ');" title="' . __a('Previous', 'wppa_theme') . '" >&lsaquo;</a>';
        $wppa['out'] .= wppa_nltab() . '</div>';
        $wppa['out'] .= wppa_nltab() . '<div style="float:right; text-align:right; cursor:pointer; margin-top:' . $topmarg . 'px; width: ' . $fw . 'px; font-size: ' . $fs . 'px;">';
        $wppa['out'] .= wppa_nltab() . '<a class="wppa-next-' . $wppa['mocc'] . ' wppa-arrow" style="' . __wcs('wppa-arrow') . '" id="next-film-arrow-1-' . $wppa['mocc'] . '" onclick="wppaNext(' . $wppa['mocc'] . ');" title="' . __a('Next', 'wppa_theme') . '" >&rsaquo;</a>';
        $wppa['out'] .= wppa_nltab() . '<a class="wppa-next-' . $wppa['mocc'] . ' wppa-arrow" style="' . __wcs('wppa-arrow') . '" id="next-film-arrow-' . $wppa['mocc'] . '" onclick="wppaLast(' . $wppa['mocc'] . ');" title="' . __a('Last', 'wppa_theme') . '" >&raquo;</a>';
        $wppa['out'] .= wppa_nltab() . '</div>';
        $wppa['out'] .= wppa_nltab() . '<div id="filmwindow-' . $wppa['mocc'] . '" class="filmwindow" style="' . $IE6 . ' position:absolute; display: block; height:' . $height . 'px; margin: 0 0 0 ' . $marg . 'px; overflow:hidden;">';
        $wppa['out'] .= wppa_nltab('+') . '<div id="wppa-filmstrip-' . $wppa['mocc'] . '" style="height:' . $height1 . 'px; width:' . $width . 'px; margin-left: -100px;">';
    }
    $cnt = count($thumbs);
    $start = $cnt - $preambule;
    $end = $cnt;
    $idx = $start;
    /* #wppa-container-'.$wppa['mocc'].' */
    $wppa['out'] .= '
			<style type="text/css" scoped >
				 .thumbnail-frame { ' . wppa_get_thumb_frame_style(false, 'film') . ' }
				.wppa-filmthumb-active { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
			</style>';
    while ($idx < $end) {
        $glue = $cnt == $idx + 1 ? true : false;
        $ix = $idx;
        while ($ix < 0) {
            $ix += $cnt;
        }
        $thumb = $thumbs[$ix];
        wppa_do_filmthumb($ix, false, $glue);
        $idx++;
    }
    $idx = 0;
    foreach ($thumbs as $tt) {
        $thumb = $tt;
        $glue = $cnt == $idx + 1 ? true : false;
        wppa_do_filmthumb($idx, true, $glue);
        $idx++;
    }
    $start = '0';
    $end = $preambule;
    $idx = $start;
    while ($idx < $end) {
        $ix = $idx;
        while ($ix >= $cnt) {
            $ix -= $cnt;
        }
        $thumb = $thumbs[$ix];
        wppa_do_filmthumb($ix, false);
        $idx++;
    }
    if (is_feed()) {
        $wppa['out'] .= wppa_nltab('-') . '</div>';
    } else {
        $wppa['out'] .= wppa_nltab('-') . '</div>';
        $wppa['out'] .= wppa_nltab('-') . '</div>';
        $wppa['out'] .= wppa_nltab('-') . '</div>';
    }
    $t += microtime(true);
    wppa_dbg_msg('Filmstrip took ' . $t . ' seconds.');
}
コード例 #12
0
function wppa_session_start()
{
    global $wpdb;
    global $wppa_session;
    // If the session table does not yet exist on activation
    if (!wppa_table_exists(WPPA_SESSION)) {
        $wppa_session['id'] = '0';
        return false;
    }
    // Cleanup first
    $lifetime = 3600;
    // Sessions expire after one hour
    $savetime = 3600;
    // Save session data for 1 hour
    $expire = time() - $lifetime;
    $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_SESSION . "` SET `status` = 'expired' WHERE `timestamp` < %s", $expire));
    $purge = time() - $savetime;
    $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_SESSION . "` WHERE `timestamp` < %s", $purge));
    // Is session already started?
    $session = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_SESSION . "` WHERE `session` = %s AND `status` = 'valid' LIMIT 1", wppa_get_session_id()), ARRAY_A);
    $data = $session ? $session['data'] : false;
    // Not started yet, setup session
    if ($data === false) {
        $iret = false;
        $tries = '0';
        while (!$iret && $tries < '10') {
            $iret = wppa_create_session_entry(array());
            if (!$iret) {
                sleep(1);
                $tries++;
            }
        }
        if ($tries > '3' && $iret) {
            wppa_log('Debug', 'It took ' . $tries . ' retries to start session ' . $iret);
        }
        if (!$iret) {
            wppa_log('Error', 'Unable to create session.');
            return false;
        }
        $wppa_session = array();
        $wppa_session['page'] = '0';
        $wppa_session['ajax'] = '0';
        $wppa_session['id'] = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . WPPA_SESSION . "` WHERE `session` = %s LIMIT 1", wppa_get_session_id()));
        $wppa_session['user'] = wppa_get_user();
    } else {
        $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_SESSION . "` SET `count` = %s WHERE `id` = %s", $session['count'] + '1', $session['id']));
        $data_arr = unserialize($data);
        if (is_array($data_arr)) {
            $wppa_session = $data_arr;
        } else {
            $wppa_session = array();
        }
    }
    // Get info for root and sub search
    if (isset($_REQUEST['wppa-search-submit'])) {
        $wppa_session['rootbox'] = wppa_get_get('rootsearch') || wppa_get_post('rootsearch');
        $wppa_session['subbox'] = wppa_get_get('subsearch') || wppa_get_post('subsearch');
        if ($wppa_session['subbox']) {
            if (isset($wppa_session['use_searchstring'])) {
                $t = explode(',', $wppa_session['use_searchstring']);
                foreach (array_keys($t) as $idx) {
                    $t[$idx] .= ' ' . wppa_test_for_search('at_session_start');
                    $t[$idx] = trim($t[$idx]);
                    $v = explode(' ', $t[$idx]);
                    $t[$idx] = implode(' ', array_unique($v));
                }
                $wppa_session['use_searchstring'] = ' ' . implode(',', array_unique($t));
            } else {
                $wppa_session['use_searchstring'] = wppa_test_for_search('at_session_start');
            }
        } else {
            $wppa_session['use_searchstring'] = wppa_test_for_search('at_session_start');
        }
        if (isset($wppa_session['use_searchstring'])) {
            $wppa_session['use_searchstring'] = trim($wppa_session['use_searchstring'], ' ,');
            $wppa_session['display_searchstring'] = str_replace(',', ' &#8746 ', str_replace(' ', ' &#8745 ', $wppa_session['use_searchstring']));
        }
    }
    // Add missing defaults
    $defaults = array('has_searchbox' => false, 'rootbox' => false, 'search_root' => '', 'subbox' => false, 'use_searchstring' => '', 'display_searchstring' => '', 'supersearch' => '', 'superview' => 'thumbs', 'superalbum' => '0', 'page' => '0', 'ajax' => '0', 'user' => '', 'id' => $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . WPPA_SESSION . "` WHERE `session` = %s LIMIT 1", wppa_get_session_id())));
    $wppa_session = wp_parse_args($wppa_session, $defaults);
    ksort($wppa_session);
    $wppa_session['page']++;
    wppa_save_session();
    return true;
}
コード例 #13
0
function wppa_comment_html($id, $comment_allowed)
{
    global $wpdb;
    global $wppa;
    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() ? $vis = '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('wppa_fontcolor_box')) {
        $color = wppa_opt('wppa_fontcolor_box');
    }
    if ($comments) {
        $result .= '<div id="wppa-comtable-wrap-' . $wppa['mocc'] . '" style="display:none;" >';
        $result .= '<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; " >';
                $result .= '<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') . '" >';
                $result .= $comment['user'] . ' ' . __a('wrote:');
                $result .= '<br /><span style="font-size:9px; ">' . wppa_get_time_since($comment['timestamp']) . '</span>';
                if (wppa_opt('wppa_comment_gravatar') != 'none') {
                    // Find the default
                    if (wppa_opt('wppa_comment_gravatar') != 'url') {
                        $default = wppa_opt('wppa_comment_gravatar');
                    } else {
                        $default = wppa_opt('wppa_comment_gravatar_url');
                    }
                    // Find the avatar
                    $avt = '';
                    $usr = get_user_by('login', $comment['user']);
                    if ($usr) {
                        // Local Avatar ?
                        $avt = str_replace("'", "\"", get_avatar($usr->ID, wppa_opt('wppa_gravatar_size'), $default));
                    }
                    if ($avt == '') {
                        // Global avatars off, try myself
                        $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('wppa_gravatar_size') . '" alt="' . __a('Avatar') . '" />';
                    }
                    // 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;" >' . __a('Awaiting moderation') . '</span>';
                } elseif ($comment['status'] == 'spam' && $comment['user'] == $wppa['comment_user']) {
                    $result .= '<br /><span style="color:red; font-size:9px;" >' . __a('Marked as spam') . '</span>';
                }
                $result .= '</p>';
                $result .= '</td>';
                $result .= '</tr>';
                $result .= '<tr class="wppa-comment-' . $comment['id'] . '"><td colspan="2" style="padding:0"><hr style="background-color:' . $color . '; margin:0;" /></td></tr>';
            }
        }
        $result .= '</tbody></table>';
        $result .= '</div>';
    }
    // See if we are currently in the process of adding/editing this comment
    $is_current = $id == $wppa['comment_photo'] && $wppa['comment_id'];
    // $debugtext=' ( id='.$id.', comment_photo='.$wppa['comment_photo'].', comment_id='.$wppa['comment_id'].' )';
    if ($is_current) {
        $txt = $wppa['comment_text'];
        $btn = __a('Edit!');
    } else {
        $txt = '';
        $btn = __a('Send!');
    }
    // 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;" >';
        $result .= '<form id="wppa-commentform-' . $wppa['mocc'] . '" class="wppa-comment-form" action="' . $returnurl . '" method="post" style="" onsubmit="return wppaValidateComment( ' . $wppa['mocc'] . ' )">';
        $result .= wp_nonce_field('wppa-nonce-' . wppa('mocc'), 'wppa-nonce-' . wppa('mocc'), false, false);
        //, $alb );
        if ($album) {
            $result .= '<input type="hidden" name="wppa-album" value="' . $album . '" />';
        }
        if ($cover) {
            $result .= '<input type="hidden" name="wppa-cover" value="' . $cover . '" />';
        }
        if ($slide) {
            $result .= '<input type="hidden" name="wppa-slide" value="' . $slide . '" />';
        }
        $result .= '<input type="hidden" name="wppa-returnurl" id="wppa-returnurl-' . wppa('mocc') . '" value="' . $returnurl . '" />';
        if ($is_current) {
            $result .= '<input type="hidden" id="wppa-comment-edit-' . $wppa['mocc'] . '" name="wppa-comment-edit" value="' . $wppa['comment_id'] . '" />';
        }
        $result .= '<input type="hidden" name="wppa-occur" value="' . $wppa['occur'] . '" />';
        $result .= '<table id="wppacommenttable-' . $wppa['mocc'] . '" style="margin:0;">';
        $result .= '<tbody>';
        $result .= '<tr valign="top" style="' . $vis . '">';
        $result .= '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your name:') . '</td>';
        $result .= '<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>';
        $result .= '</tr>';
        if (wppa_switch('comment_email_required')) {
            $result .= '<tr valign="top" style="' . $vis . '">';
            $result .= '<td class="wppa-box-text wppa-td" style="width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your email:') . '</td>';
            $result .= '<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>';
            $result .= '</tr>';
        }
        $result .= '<tr valign="top" style="vertical-align:top;">';
        $result .= '<td valign="top" class="wppa-box-text wppa-td" style="vertical-align:top; width:30%; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >' . __a('Your comment:') . '<br />' . $wppa['comment_user'] . '<br />';
        if (wppa_switch('comment_captcha')) {
            $wid = '20%';
            if (wppa_opt('wppa_fontsize_box')) {
                $wid = wppa_opt('wppa_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;';
        }
        // orig							$result .= '<input type="submit" name="commentbtn" value="'.$btn.'" style="margin:0;" /></td>';
        $result .= '<input type="button" name="commentbtn" onclick="wppaAjaxComment( ' . $wppa['mocc'] . ', ' . $id . ' )" value="' . $btn . '" style="margin:0 4px 0 0;" />';
        $result .= '<img id="wppa-comment-spin-' . $wppa['mocc'] . '" src="' . wppa_get_imgdir() . 'wpspin.gif" style="display:none;" />';
        $result .= '</td>';
        $result .= '<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( 'use_wp_editor' ) ) {
        								$quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' );
        								ob_start();
        								wp_editor( stripslashes( $txt ), 'wppacomment'.wppa_alfa_id( $id ), array( 'wpautop' => false, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
        								$editor = ob_get_clean();
        								$result .= str_replace( "'", '"', $editor );
        							}
        							else {
        /**/
        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>';
        /*							}
        /* */
        $result .= '</td>';
        $result .= '</tr>';
        $result .= '</tbody>';
        $result .= '</table>';
        $result .= '</form>';
        // $result.=$debugtext;
        $result .= '</div>';
    } else {
        if (wppa_switch('login_links')) {
            $result .= sprintf(__a('You must <a href="%s">login</a> to enter a comment'), site_url('wp-login.php', 'login'));
        } else {
            $result .= __a('You must login to enter a comment');
        }
    }
    $result .= '<div id="wppa-comfooter-wrap-' . $wppa['mocc'] . '" style="display:block;" >';
    $result .= '<table id="wppacommentfooter-' . $wppa['mocc'] . '" class="wppa-comment-form" style="margin:0;">';
    $result .= '<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;">';
    // wppaStartStop( '.$wppa['mocc'].', -1 ); return false;">';
    if ($n_comments) {
        $result .= sprintf(__a('%d comments'), $n_comments);
    } else {
        if ($comment_allowed) {
            $result .= __a('Leave a comment');
        }
    }
    $result .= '</a></td></tr></tbody></table>';
    $result .= '</div><div style="clear:both"></div>';
    return $result;
}