Ejemplo n.º 1
0
function wppa_get_album_desc($id)
{
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_album_desc( ' . $id . ' )', 'red');
    }
    $album = wppa_cache_album($id);
    $desc = $album['description'];
    // Raw data
    if (!$desc) {
        return '';
    }
    // No content, need no filtering
    $desc = stripslashes($desc);
    // Unescape
    $desc = __($desc);
    // qTranslate
    $desc = wppa_html($desc);
    // Enable html
    $desc = balanceTags($desc, true);
    // Balance tags
    if (strpos($desc, 'w#') !== false) {
        // Is there any 'w#' ?
        // Keywords
        $keywords = array('name', 'owner', 'id', 'views');
        foreach ($keywords as $keyword) {
            $replacement = __(trim(stripslashes($album[$keyword])));
            if ($replacement == '') {
                $replacement = '&lsaquo;' . __a('none', 'wppa') . '&rsaquo;';
            }
            $desc = str_replace('w#' . $keyword, $replacement, $desc);
        }
        // Timestamps
        $timestamps = array('timestamp', 'modified');
        // Identical, there is only timestamp, but it acts as modified
        foreach ($timestamps as $timestamp) {
            if ($album['timestamp']) {
                $desc = str_replace('w#' . $timestamp, wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $album['timestamp']), $desc);
            } else {
                $desc = str_replace('w#' . $timestamp, '&lsaquo;' . __a('unknown') . '&rsaquo;', $desc);
            }
        }
    }
    // To prevent recursive rendering of scripts or shortcodes:
    $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc);
    if (wppa_switch('wppa_allow_foreign_shortcodes_general')) {
        $desc = do_shortcode($desc);
    } else {
        $desc = strip_shortcodes($desc);
    }
    // Convert links and mailto:
    $desc = make_clickable($desc);
    // CMTooltipGlossary on board?
    $desc = wppa_filter_glossary($desc);
    return $desc;
}
Ejemplo n.º 2
0
function wppa_slide_custom($opt = '')
{
    if ($opt == 'optional' && !wppa_switch('custom_on')) {
        return;
    }
    if (wppa('is_slideonly')) {
        return;
    }
    /* Not when slideonly */
    if (is_feed()) {
        return;
    }
    $content = __(stripslashes(wppa_opt('custom_content')));
    // w#albdesc
    if (wppa_is_int(wppa('start_album')) && wppa('start_album') > '0') {
        $content = str_replace('w#albdesc', wppa_get_album_desc(wppa('start_album')), $content);
    } else {
        $content = str_replace('w#albdesc', '', $content);
    }
    // w#fotomoto
    if (wppa_switch('fotomoto_on')) {
        $fontsize = wppa_opt('fotomoto_fontsize');
        if ($fontsize) {
            $s = '<style>.FotomotoToolbarClass{font-size:' . wppa_opt('fotomoto_fontsize') . 'px !important;}</style>';
        } else {
            $s = '';
        }
        $content = str_replace('w#fotomoto', $s . '<div' . ' id="wppa-fotomoto-container-' . wppa('mocc') . '"' . ' class="wppa-fotomoto-container"' . ' >' . '</div>' . '<div' . ' id="wppa-fotomoto-checkout-' . wppa('mocc') . '"' . ' class="wppa-fotomoto-checkout FotomotoToolbarClass"' . ' style="float:right; clear:none;"' . ' >' . '<ul' . ' class="FotomotoBar"' . ' style="list-style:none outside none;"' . ' >' . '<li>' . '<a' . ' onclick="FOTOMOTO.API.checkout(); return false;"' . ' >' . __('Checkout', 'wp-photo-album-plus') . '</a>' . '</li>' . '</ul>' . '</div>' . '<div' . ' style="clear:both;"' . ' >' . '</div>', $content);
    } else {
        $content = str_replace('w#fotomoto', '', $content);
    }
    $content = wppa_html($content);
    wppa_out('<div' . ' id="wppa-custom-' . wppa('mocc') . '"' . ' class="wppa-box wppa-custom"' . ' style="' . __wcs('wppa-box') . __wcs('wppa-custom') . '"' . ' >' . $content . '</div>');
}
function wppa_get_slide_info($index, $id, $callbackid = '')
{
    global $wpdb;
    static $user;
    // Make sure $thumb contains our image data
    $thumb = wppa_cache_thumb($id);
    if (!$user) {
        $user = wppa_get_user();
    }
    $photo = wppa_get_get('photo');
    $ratingphoto = wppa_get_get('rating-id');
    if (!$callbackid) {
        $callbackid = $id;
    }
    // Process a comment if given for this photo
    $comment_request = wppa_get_post('commentbtn') && $id == $photo;
    $comment_allowed = !wppa_switch('comment_login') || is_user_logged_in();
    if (wppa_switch('show_comments') && $comment_request && $comment_allowed) {
        wppa_do_comment($id);
    }
    // Find rating
    if (wppa_switch('rating_on') && !wppa('is_slideonly') && !wppa('is_filmonly')) {
        // Find my ( avg ) rating
        $rats = $wpdb->get_results($wpdb->prepare("SELECT `value` FROM `" . WPPA_RATING . "` " . "WHERE `photo` = %s AND `user` = %s AND `status` = 'publish'", $id, $user), ARRAY_A);
        wppa_dbg_q('Q33v');
        if ($rats) {
            $n = 0;
            $accu = 0;
            foreach ($rats as $rat) {
                $accu += $rat['value'];
                $n++;
            }
            $myrat = $accu / $n;
            $i = wppa_opt('rating_prec');
            $j = $i + '1';
            $myrat = sprintf('%' . $j . '.' . $i . 'f', $myrat);
        } else {
            $myrat = '0';
        }
        // Find the avg rating
        $avgrat = wppa_get_rating_by_id($id, 'nolabel');
        if (!$avgrat) {
            $avgrat = '0';
        }
        $avgrat .= '|' . wppa_get_rating_count_by_id($id);
        // Find the dislike count
        $discount = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `value` = -1 AND `status` = %s", $id, 'publish'));
    } else {
        // Rating off
        $myrat = '0';
        $avgrat = '0';
        $discount = '0';
    }
    // Find comments
    $comment = wppa_switch('show_comments') && !wppa('is_filmonly') && !wppa('is_slideonly') ? wppa_comment_html($id, $comment_allowed) : '';
    // Get the callback url.
    if (wppa_switch('rating_on')) {
        $url = wppa_get_slide_callback_url($callbackid);
        $url = str_replace('&amp;', '&', $url);
        // js use
    } else {
        $url = '';
    }
    // Find link url, link title and link target
    if (wppa_in_widget() == 'ss') {
        $link = wppa_get_imglnk_a('sswidget', $id);
    } else {
        $link = wppa_get_imglnk_a('slideshow', $id);
    }
    $linkurl = $link['url'];
    $linktitle = $link['title'];
    $linktarget = $link['target'];
    // Find full image style and size
    if (wppa('is_filmonly')) {
        $style_a['style'] = '';
        $style_a['width'] = '';
        $style_a['height'] = '';
    } else {
        $style_a = wppa_get_fullimgstyle_a($id);
    }
    // Find image url
    if (wppa_switch('fotomoto_on') && !wppa_is_stereo($id)) {
        $photourl = wppa_get_hires_url($id);
    } elseif (wppa_use_thumb_file($id, $style_a['width'], $style_a['height']) && !wppa_is_stereo($id)) {
        $photourl = wppa_get_thumb_url($id, '', $style_a['width'], $style_a['height']);
    } else {
        $photourl = wppa_get_photo_url($id, '', $style_a['width'], $style_a['height']);
    }
    if (wppa_has_audio($id)) {
        $photourl = wppa_fix_poster_ext($photourl, $id);
    }
    // Find iptc data
    $iptc = wppa_switch('show_iptc') && !wppa('is_slideonly') && !wppa('is_filmonly') ? wppa_iptc_html($id) : '';
    // Find EXIF data
    $exif = wppa_switch('show_exif') && !wppa('is_slideonly') && !wppa('is_filmonly') ? wppa_exif_html($id) : '';
    // Lightbox subtitle
    $doit = false;
    if (wppa_opt('slideshow_linktype') == 'lightbox' || wppa_opt('slideshow_linktype') == 'lightboxsingle') {
        $doit = true;
    }
    // For fullsize
    if (wppa_switch('filmstrip') && wppa_opt('film_linktype') == 'lightbox') {
        // For filmstrip?
        if (!wppa('is_slideonly')) {
            $doit = true;
        }
        // Film below fullsize
        if (wppa('film_on')) {
            $doit = true;
        }
        // Film explicitly on ( slideonlyf )
    }
    if ($doit) {
        $lbtitle = wppa_get_lbtitle('slide', $id);
    } else {
        $lbtitle = '';
    }
    // Name
    if (wppa('is_filmonly')) {
        $name = '';
        $fullname = '';
    } else {
        $name = esc_js(wppa_get_photo_name($id));
        if (!$name) {
            $name = '&nbsp;';
        }
        $fullname = wppa_get_photo_name($id, wppa_switch('show_full_owner'), true, true, wppa_switch('wppa_show_full_name'));
        if (!$fullname) {
            $fullname = '&nbsp;';
        }
    }
    // Shareurl
    if (wppa('is_filmonly') || wppa('is_slideonly')) {
        $shareurl = '';
    } else {
        $shareurl = wppa_get_image_page_url_by_id($id, false, wppa('start_album'));
        $shareurl = wppa_convert_to_pretty($shareurl);
        $shareurl = str_replace('&amp;', '&', $shareurl);
    }
    // Make photo desc, filtered
    $desc = '';
    if ((!wppa('is_slideonly') || wppa('desc_on')) && !wppa('is_filmonly')) {
        $desc .= wppa_get_photo_desc($id, wppa_switch('allow_foreign_shortcodes'), 'do_geo');
        // Foreign shortcodes is handled here
        // Run wpautop on description?
        if (wppa_switch('run_wpautop_on_desc')) {
            $desc = wpautop($desc);
        }
        // And format
        $desc = wppa_html(esc_js(stripslashes($desc)));
        // Remove extra space created by other filters like wpautop
        if (wppa_switch('allow_foreign_shortcodes') && wppa_switch('clean_pbr')) {
            $desc = str_replace(array("<p>", "</p>", "<br>", "<br/>", "<br />"), " ", $desc);
        }
        if (!$desc) {
            $desc = '&nbsp;';
        }
    }
    // Edit photo link
    $editlink = '';
    $dellink = '';
    if (!wppa('is_filmonly') && !wppa('is_slideonly')) {
        if (!wppa_is_user_blacklisted()) {
            if (wppa_user_is('administrator') || current_user_can('wppa_moderate') || wppa_get_user() == wppa_get_photo_owner($id) && wppa_switch('upload_edit')) {
                $editlink = '
					<div style="float:right; margin-right:6px;" >' . '<a' . ' style="color:green;"' . ' onclick="_wppaStop( ' . wppa('mocc') . ' );wppaEditPhoto( ' . wppa('mocc') . ', ' . $thumb['id'] . ' ); return false;"' . ' >' . __('Edit', 'wp-photo-album-plus') . '</a>' . '</div>';
                $dellink = '
					<div style="float:right; margin-right:6px;" >' . '<a' . ' style="color:red;"' . ' onclick="' . '_wppaStop( ' . wppa('mocc') . ' );' . esc_attr('if ( confirm( "' . __('Are you sure you want to remove this photo?', 'wp-photo-album-plus') . '" ) ) ' . 'wppaAjaxRemovePhoto( ' . wppa('mocc') . ', ' . $thumb['id'] . ', true ); return false;') . '"' . '>' . __('Delete', 'wp-photo-album-plus') . '</a>' . '</div>';
            }
        }
    }
    if ($editlink || $dellink) {
        $desc = $editlink . $dellink . '<div style="clear:both"></div>' . $desc;
    }
    if (in_array($thumb['status'], array('pending', 'scheduled'))) {
        $desc .= wppa_html(esc_js(wppa_moderate_links('slide', $id)));
    }
    // Share HTML
    $sharehtml = wppa('is_filmonly') || wppa('is_slideonly') ? '' : wppa_get_share_html($id);
    // Og Description
    $ogdsc = wppa_switch('facebook_comments') && !wppa_in_widget() ? strip_shortcodes(wppa_strip_tags(wppa_html(wppa_get_photo_desc($id)), 'all')) : '';
    $ogdsc = esc_js($ogdsc);
    // Hires url
    $hiresurl = esc_js(wppa_fix_poster_ext(wppa_get_hires_url($id), $id));
    // Video html
    $videohtml = wppa_get_video_body($id);
    // Audio html
    $audiohtml = wppa_get_audio_body($id);
    // Produce final result
    $result = "'" . wppa('mocc') . "','";
    $result .= $index . "','";
    $result .= $photourl . "','";
    $result .= $style_a['style'] . "','";
    $result .= ($videohtml ? wppa_get_videox($id) : $style_a['width']) . "','";
    $result .= ($videohtml ? wppa_get_videoy($id) : $style_a['height']) . "','";
    $result .= $fullname . "','";
    $result .= $name . "','";
    $result .= $desc . "','";
    $result .= $id . "','";
    $result .= $avgrat . "','";
    $result .= $discount . "','";
    $result .= $myrat . "','";
    $result .= $url . "','";
    $result .= $linkurl . "','" . $linktitle . "','" . $linktarget . "','";
    $result .= wppa('in_widget_timeout') . "','";
    $result .= $comment . "','";
    $result .= $iptc . "','";
    $result .= $exif . "','";
    $result .= $lbtitle . "','";
    $result .= $shareurl . "','";
    // Used for history.pushstate()
    $result .= $sharehtml . "','";
    // The content of the SM ( share ) box
    $result .= $ogdsc . "','";
    $result .= $hiresurl . "','";
    $result .= $videohtml . "','";
    $result .= $audiohtml . "'";
    // This is an ingenious line of code that is going to prevent us from very much trouble.
    // Created by OpaJaap on Jan 15 2012, 14:36 local time. Thanx.
    // Make sure there are no linebreaks in the result that would screw up Javascript.
    return str_replace(array("\r\n", "\n", "\r"), " ", $result);
    //	return $result;
}
Ejemplo n.º 4
0
function wppa_get_og_desc($id)
{
    $result = sprintf(__('See this image on %s', 'wp-photo-album-plus'), str_replace('&amp;', __('and', 'wp-photo-album-plus'), get_bloginfo('name'))) . ': ' . strip_shortcodes(wppa_strip_tags(wppa_html(wppa_get_photo_desc($id)), 'all'));
    $result = apply_filters('wppa_get_og_desc', $result);
    return $result;
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
function wppa_get_og_desc($id)
{
    global $thumb;
    wppa_cache_thumb($id);
    $result = sprintf(__a('See this image on %s'), str_replace('&amp;', __a('and'), get_bloginfo('name'))) . ': ' . strip_shortcodes(wppa_strip_tags(wppa_html(wppa_get_photo_desc($id)), 'all'));
    $result = apply_filters('wppa_get_og_desc', $result);
    return $result;
}
Ejemplo n.º 7
0
function wppa_slide_custom($opt = '')
{
    global $wppa;
    global $wppa_opt;
    if ($opt == 'optional' && !wppa_switch('wppa_custom_on')) {
        return;
    }
    if ($wppa['is_slideonly'] == '1') {
        return;
    }
    /* Not when slideonly */
    if (is_feed()) {
        return;
    }
    $content = __(stripslashes($wppa_opt['wppa_custom_content']));
    // w#albdesc
    if (is_numeric($wppa['start_album']) && $wppa['start_album'] > '0') {
        $content = str_replace('w#albdesc', wppa_get_album_desc($wppa['start_album']), $content);
    } else {
        $content = str_replace('w#albdesc', '', $content);
    }
    // w#fotomoto
    if (wppa_switch('wppa_fotomoto_on')) {
        $fontsize = $wppa_opt['wppa_fotomoto_fontsize'];
        if ($fontsize) {
            $s = '<style>.FotomotoToolbarClass{font-size:' . $wppa_opt['wppa_fotomoto_fontsize'] . 'px !important;}</style>';
        } else {
            $s = '';
        }
        $content = str_replace('w#fotomoto', $s . '<div' . ' id="wppa-fotomoto-container-' . $wppa['mocc'] . '"' . ' class="wppa-fotomoto-container"' . ' >' . '</div>' . '<div' . ' id="wppa-fotomoto-checkout-' . $wppa['mocc'] . '"' . ' class="wppa-fotomoto-checkout FotomotoToolbarClass"' . ' style="float:right; clear:none;"' . ' >' . '<ul' . ' class="FotomotoBar"' . ' style="list-style:none outside none;"' . ' >' . '<li>' . '<a' . ' onclick="FOTOMOTO.API.checkout(); return false;"' . ' >' . __('Checkout') . '</a>' . '</li>' . '</ul>' . '</div>' . '<div' . ' style="clear:both;"' . ' >' . '</div>', $content);
    } else {
        $content = str_replace('w#fotomoto', '', $content);
    }
    $content = wppa_html($content);
    $wppa['out'] .= wppa_nltab('+') . '<div id="wppa-custom-' . $wppa['mocc'] . '" class="wppa-box wppa-custom" style="' . __wcs('wppa-box') . __wcs('wppa-custom') . '">';
    $wppa['out'] .= wppa_nltab() . $content;
    $wppa['out'] .= wppa_nltab('-') . '</div>';
}
Ejemplo n.º 8
0
function wppa_get_album_desc($id)
{
    if (!is_numeric($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_get_album_desc( ' . $id . ' )', 'red');
    }
    $album = wppa_cache_album($id);
    $desc = $album['description'];
    // Raw data
    if (!$desc) {
        return '';
    }
    // No content, need no filtering
    $desc = stripslashes($desc);
    // Unescape
    $desc = __($desc, 'wp-photo-album-plus');
    // qTranslate
    $desc = wppa_html($desc);
    // Enable html
    $desc = balanceTags($desc, true);
    // Balance tags
    // Album keywords
    $desc = wppa_translate_album_keywords($id, $desc);
    // To prevent recursive rendering of scripts or shortcodes:
    $desc = str_replace(array('%%wppa%%', '[wppa', '[/wppa]'), array('%-wppa-%', '{wppa', '{/wppa}'), $desc);
    if (wppa_switch('allow_foreign_shortcodes_general')) {
        $desc = do_shortcode($desc);
    } else {
        $desc = strip_shortcodes($desc);
    }
    // Convert links and mailto:
    $desc = make_clickable($desc);
    // CMTooltipGlossary on board?
    $desc = wppa_filter_glossary($desc);
    // Formatting
    switch (wppa_opt('wpautop_on_album_desc')) {
        case 'nil':
            break;
        case 'nl2br':
            $desc = nl2br($desc);
            break;
        case 'wpautop':
            $desc = wpautop($desc);
            break;
        default:
            wppa_log('Err', 'Unimplemented option value: ' . wppa_opt('wpautop_on_album_desc') . ' for wppa_opt( \'wpautop_on_album_desc\' )');
    }
    return $desc;
}
Ejemplo n.º 9
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;
}