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>'); } }
function wppa_smx_photo($stype) { $id = wppa('single_photo'); $width = wppa_get_container_width(); $style = wppa_get_container_style(); // wrapper for maximized auto wppa_container_wrapper('open'); // Open the pseudo container // The container defines size ( fixed pixels or percent ) and position ( left, center, right or default ) of the image wppa_out('<div' . ' id="wppa-container-' . wppa('mocc') . '"' . ' class="' . (wppa('align') ? 'align' . wppa('align') : '') . ' wppa-' . $stype . 'photo' . ' wppa-' . $stype . 'photo-' . wppa('mocc') . ($stype == 'm' || $stype == 'x' ? ' wp-caption' : '') . '"' . ' style="' . $style . '"' . ' >'); // The image html $html = wppa_get_picture_html(array('id' => $id, 'type' => $stype . 'photo', 'class' => 'size-medium wppa-' . $stype . 'photo')); wppa_out($html); // The subext if any if ($stype == 'm' || $stype == 'x') { // The subtitle wppa_out('<p class="wp-caption-text">' . wppa_get_photo_desc($id) . '</p>'); // The rating, only on xphoto when enabled in II-B7 if ($stype == 'x' && wppa_switch('rating_on')) { wppa_out(wppa_get_rating_range_html($id, false, 'wp-caption-text')); } // The share buttons on mphoto if enabled in II-C6, and on xphoto when enabled in II-C1 if (wppa_switch('share_on_mphoto') || $stype == 'x') { wppa_out(wppa_get_share_html($id, 'mphoto', false, true)); } // The commentform on xphoto when enabled in II-B10 if ($stype == 'x' && wppa_switch('show_comments')) { wppa_out('<div id="wppa-comments-' . wppa('mocc') . '" >'); wppa_out(wppa_comment_html($id, !wppa_switch('comment_login') || is_user_logged_in())); wppa_out('</div>'); } } // The pseudo container wppa_out('</div>'); // Wrapper for maximized auto wppa_container_wrapper('close'); }