function wppa_album_cover_longdesc($albumid, $multicolresp = false) { global $cover_count_key; global $wpdb; $album = wppa_cache_album($albumid); if ($multicolresp) { $mcr = 'mcr-'; } else { $mcr = ''; } $coverphoto = wppa_get_coverphoto_id($albumid); $image = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $coverphoto), ARRAY_A); $photocount = wppa_get_photo_count($albumid, true); $albumcount = wppa_get_album_count($albumid, true); $mincount = wppa_get_mincount(); $title = ''; $linkpage = ''; $href_title = ''; $href_slideshow = ''; $href_content = ''; $onclick_title = ''; $onclick_slideshow = ''; $onclick_content = ''; // See if there is substantial content to the album $has_content = $albumcount > '0' || $photocount > $mincount; // What is the albums title linktype $linktype = $album['cover_linktype']; if (!$linktype) { $linktype = 'content'; } // Default // What is the albums title linkpage $linkpage = $album['cover_linkpage']; if ($linkpage == '-1') { $linktype = 'none'; } // for backward compatibility // Find the cover title href, onclick and title $title_attr = wppa_get_album_title_attr_a($albumid, $linktype, $linkpage, $has_content, $coverphoto, $photocount); $href_title = $title_attr['href']; $onclick_title = $title_attr['onclick']; $title = $title_attr['title']; // Find the slideshow link and onclick $href_slideshow = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage)); if (wppa_switch('allow_ajax') && !$linkpage) { $onclick_slideshow = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_slideshow) . "' )"; $href_slideshow = "#"; } // Find the content 'View' link $href_content = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage)); if (wppa_switch('allow_ajax') && !$linkpage) { $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )"; $href_content = "#"; } // Find the coverphoto link if ($coverphoto) { $photolink = wppa_get_imglnk_a('coverimg', $coverphoto, $href_title, $title, $onclick_title, '', $albumid); } else { $photolink = false; } // Find the coverphoto details if ($coverphoto) { $path = wppa_get_thumb_path($coverphoto); $imgattr_a = wppa_get_imgstyle_a($coverphoto, $path, wppa_opt('smallsize'), '', 'cover'); $src = wppa_get_thumb_url($coverphoto, '', $imgattr_a['width'], $imgattr_a['height']); } else { $path = ''; $imgattr_a = false; $src = ''; } // Feed? if (is_feed()) { $events = ''; } else { $events = wppa_get_imgevents('cover'); } $photo_pos = wppa('coverphoto_pos'); $style = __wcs('wppa-box') . __wcs('wppa-' . wppa('alt')); if (is_feed()) { $style .= ' padding:7px;'; } $wid = wppa_get_cover_width('cover'); $style .= 'width: ' . $wid . 'px;'; if ($cover_count_key == 'm') { $style .= 'margin-left: 8px;'; } elseif ($cover_count_key == 'r') { $style .= 'float:right;'; } else { $style .= 'clear:both;'; } wppa_step_covercount('cover'); $target = wppa_switch('allow_ajax') ? '_self' : $photolink['target']; // Open the album box wppa_out('<div' . ' id="album-' . $albumid . '-' . wppa('mocc') . '"' . ' class="' . 'wppa-album-cover-longdesc ' . 'album ' . 'wppa-box ' . 'wppa-cover-box ' . 'wppa-cover-box-' . $mcr . wppa('mocc') . ' ' . 'wppa-' . wppa('alt') . '"' . ' style="' . $style . __wcs('wppa-cover-box') . '"' . ' >'); // First The Cover photo? if ($photo_pos == 'left' || $photo_pos == 'top') { wppa_the_coverphoto($albumid, $image, $src, $photo_pos, $photolink, $title, $imgattr_a, $events); } // Open the Cover text frame $textframestyle = wppa_get_text_frame_style($photo_pos, 'cover'); wppa_out('<div' . ' id="covertext_frame_' . $albumid . '_' . wppa('mocc') . '"' . ' class="' . 'wppa-text-frame-' . wppa('mocc') . ' ' . 'wppa-text-frame ' . 'wppa-cover-text-frame ' . 'wppa-asym-text-frame-' . $mcr . wppa('mocc') . '"' . ' ' . $textframestyle . '>'); // The Album title wppa_the_album_title($albumid, $href_title, $onclick_title, $title, $target); // The 'Slideshow'/'Browse' link wppa_the_slideshow_browse_link($photocount, $href_slideshow, $onclick_slideshow, $target); // The 'View' link wppa_album_cover_view_link($albumid, $has_content, $photocount, $albumcount, $mincount, $href_content, $target, $onclick_content); // Close the Cover text frame wppa_out('</div>'); // The Cover photo last? if ($photo_pos == 'right' || $photo_pos == 'bottom') { wppa_the_coverphoto($albumid, $image, $src, $photo_pos, $photolink, $title, $imgattr_a, $events); } // The Album description if (wppa_switch('show_cover_text')) { $textheight = wppa_opt('text_frame_height') > '0' ? 'min-height:' . wppa_opt('text_frame_height') . 'px; ' : ''; wppa_out('<div' . ' id="coverdesc_frame_' . $albumid . '_' . wppa('mocc') . '"' . ' style="clear:both"' . ' >' . '<p' . ' class="wppa-box-text wppa-black wppa-box-text-desc"' . ' style="' . $textheight . __wcs('wppa-box-text') . __wcs('wppa-black') . '"' . ' >' . wppa_get_album_desc($albumid) . '</p>' . '</div>'); } // The sublinks wppa_albumcover_sublinks($albumid, wppa_get_cover_width('cover'), $multicolresp); // Prepare for closing wppa_out('<div style="clear:both;"></div>'); // Close the album box wppa_out('</div>'); // Toggle alt/even wppa_toggle_alt(); }
function wppa_shortcodes($xatts, $content = '') { global $wppa; global $wppa_postid; global $wppa_api_version; global $wppa_revno; $atts = shortcode_atts(array('type' => 'generic', 'album' => '', 'photo' => '', 'size' => '', 'align' => '', 'taglist' => '', 'cols' => '', 'sub' => '', 'root' => '', 'calendar' => '', 'all' => '', 'reverse' => '', 'landing' => '', 'admin' => '', 'parent' => '', 'pcount' => '', 'acount' => ''), $xatts); // Find occur if (get_the_ID() != $wppa_postid) { // New post $wppa['occur'] = '0'; // Init this occurance $wppa['fullsize'] = ''; // Reset at each post $wppa_postid = get_the_ID(); // Remember the post id } // Set internal defaults $wppa['start_album'] = ''; $wppa['is_cover'] = '0'; $wppa['is_slide'] = '0'; $wppa['is_slideonly'] = '0'; $wppa['is_filmonly'] = '0'; $wppa['single_photo'] = ''; $wppa['is_mphoto'] = '0'; $wppa['film_on'] = '0'; $wppa['is_landing'] = '0'; $wppa['start_photo'] = '0'; // Start a slideshow here $wppa['is_single'] = false; // Is a one image slideshow $wppa['is_upload'] = false; $wppa['is_multitagbox'] = false; $wppa['is_tagcloudbox'] = false; $wppa['taglist'] = ''; $wppa['tagcols'] = '2'; $wppa['is_autopage'] = false; $wppa['portrait_only'] = false; $wppa['shortcode_content'] = $content; $wppa['is_url'] = false; $wppa['forceroot'] = ''; $wppa['landingpage'] = ''; $wppa['is_admins_choice'] = false; $wppa['admins_choice_users'] = ''; $wppa['albums_only'] = false; $wppa['max_width'] = false; // Find type switch ($atts['type']) { case 'version': return $wppa_api_version; break; case 'dbversion': return $wppa_revno; break; case 'landing': $wppa['is_landing'] = '1'; case 'generic': break; case 'cover': $wppa['start_album'] = $atts['album']; $wppa['is_cover'] = '1'; $wppa['albums_only'] = true; break; case 'album': case 'content': $wppa['start_album'] = $atts['album']; break; case 'thumbs': $wppa['start_album'] = $atts['album']; $wppa['photos_only'] = true; break; case 'covers': $wppa['start_album'] = $atts['album']; $wppa['albums_only'] = true; break; case 'slide': $wppa['start_album'] = $atts['album']; $wppa['is_slide'] = '1'; $wppa['start_photo'] = $atts['photo']; break; case 'slideonly': $wppa['start_album'] = $atts['album']; $wppa['is_slideonly'] = '1'; $wppa['start_photo'] = $atts['photo']; break; case 'slideonlyf': $wppa['start_album'] = $atts['album']; $wppa['is_slideonly'] = '1'; $wppa['film_on'] = '1'; $wppa['start_photo'] = $atts['photo']; break; case 'slidef': $wppa['start_album'] = $atts['album']; $wppa['is_slide'] = '1'; $wppa['film_on'] = '1'; case 'filmonly': $wppa['start_album'] = $atts['album']; $wppa['is_slideonly'] = '1'; $wppa['is_filmonly'] = '1'; $wppa['film_on'] = '1'; $wppa['start_photo'] = $atts['photo']; break; case 'photo': case 'sphoto': $wppa['single_photo'] = $atts['photo']; break; case 'mphoto': $wppa['single_photo'] = $atts['photo']; $wppa['is_mphoto'] = '1'; break; case 'xphoto': $wppa['single_photo'] = $atts['photo']; $wppa['is_xphoto'] = '1'; break; case 'slphoto': $wppa['is_slide'] = '1'; $wppa['single_photo'] = $atts['photo']; $wppa['start_photo'] = $atts['photo']; $wppa['is_single'] = '1'; break; case 'autopage': $wppa['is_autopage'] = '1'; break; case 'upload': if ($atts['parent']) { $wppa['start_album'] = wppa_alb_to_enum_children($atts['parent']); } else { $wppa['start_album'] = $atts['album']; } $wppa['is_upload'] = true; break; case 'multitag': $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']); $wppa['is_multitagbox'] = true; if ($atts['cols']) { $wppa['tagcols'] = $atts['cols']; } break; case 'tagcloud': $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']); $wppa['is_tagcloudbox'] = true; break; case 'bestof': $wppa['bestof'] = true; $wppa['bestof_args'] = $xatts; break; case 'superview': $wppa['is_superviewbox'] = true; $wppa['start_album'] = $atts['album']; break; case 'search': $wppa['is_searchbox'] = true; $wppa['may_sub'] = $atts['sub']; if ($atts['root']) { if (substr($atts['root'], 0, 1) == '#') { $wppa['forceroot'] = strval(intval(substr($atts['root'], 1))); } else { $wppa['may_root'] = $atts['root']; } } $wppa['landingpage'] = $atts['landing']; break; case 'supersearch': $wppa['is_supersearch'] = true; break; case 'calendar': if (!wppa_switch('allow_ajax')) { wppa_dbg_msg('Shortcode [wppa type="calendar" ... requires Ajax acive. See Photo Albums -> Settings Table IV-A1.0', 'red', 'force'); return ''; } $wppa['is_calendar'] = true; $wppa['calendar'] = 'timestamp'; if (in_array($atts['calendar'], array('exifdtm', 'timestamp', 'modified'))) { $wppa['calendar'] = $atts['calendar']; } if ($atts['all']) { $wppa['calendarall'] = true; } $wppa['reverse'] = $atts['reverse']; $wppa['start_album'] = $atts['album']; break; case 'stereo': $wppa['is_stereobox'] = true; break; case 'url': $wppa['is_url'] = true; $wppa['single_photo'] = $atts['photo']; break; case 'choice': $wppa['is_admins_choice'] = true; $wppa['admins_choice_users'] = $atts['admin']; break; case 'acount': case 'pcount': $a = strval(intval($atts['album'])); $p = strval(intval($atts['parent'])); $t = $atts['type']; if ($a xor $p) { $alb = $a ? $a : $p; $tc = wppa_treecount_a($alb); // Album based count requested if ($a) { if ($t == 'acount') { return wppa_get_album_count($alb, true); } else { return wppa_get_photo_count($alb, true); } } else { if ($t == 'acount') { return $tc['albums']; } else { return $tc['photos']; } } } else { wppa_dbg_msg('Error in shortcode spec for type="' . $atts['type'] . '": either attribute album="" or parent="" should supply a positive integer', 'red', 'force'); return; } break; case 'share': $result = wppa_get_share_page_html(); return $result; break; default: wppa_dbg_msg('Invalid type: ' . $atts['type'] . ' in wppa shortcode.', 'red', 'force'); return ''; } // Count (internally to wppa_albums) // Find size if ($atts['size'] && is_numeric($atts['size']) && $atts['size'] < 1.0) { $wppa['auto_colwidth'] = true; $wppa['fullsize'] = $atts['size']; } elseif (substr($atts['size'], 0, 4) == 'auto') { $wppa['auto_colwidth'] = true; $wppa['fullsize'] = ''; $wppa['max_width'] = substr($atts['size'], 5); } else { $wppa['auto_colwidth'] = false; $wppa['fullsize'] = $atts['size']; } // Find align $wppa['align'] = $atts['align']; // Ready to render ??? $do_it = false; if (wppa('rendering_enabled')) { $do_it = true; } // NOT in a head section (in a meta tag or so) if (wppa_in_widget()) { $do_it = true; } // A widget always works if (is_feed()) { $do_it = true; } // A feed has no head section if (wppa_switch('render_shortcode_always')) { $do_it = true; } // Always if (wppa('debug')) { if ($do_it) { $msg = 'Doit is on'; } else { $msg = 'Doit is off'; } wppa_dbg_msg($msg); } // Do it also for url only shortcode if ($do_it || $wppa['is_url']) { $result = wppa_albums(); // Get the HTML } else { $result = '<span style="color:blue; font-weight:bold; ">[WPPA+ Photo display (fsh)]</span>'; // Or an indicator } // Reset $wppa['start_photo'] = '0'; // Start a slideshow here $wppa['is_single'] = false; // Is a one image slideshow // Relative urls? $result = wppa_make_relative($result); // In widget if (wppa_in_widget()) { if (!wppa_switch('shortcode_at_priority_widget')) { return $result; } } else { if (!wppa_switch('shortcode_at_priority')) { return $result; } } // Url always immediately if ($wppa['is_url']) { return $result; } // New method to prevent damage of the result by content filters that run on higher priorities than do_shortcode. // Previous methods, e.g. increasing the do_shortcode priority sometimes fail due to requirements of other plugins/shortcodes. // To prevent this, i first asked an enhancement to add a priority argument to add_shortcode(), but the wp boys simply say // 'this is not possible'. Everything is possible, they should say that they are not smart enough to implement it. // Since there are plans to set the do_shortcode() priority ( currently 11 ) lower than wpautop() ( 10 ), and there are many serious // bugs in wpautop() it is now urgent to create a monkey-proof solution to the problem that others destructify the so preciously created // shortcode process output. // // What we do is: // 1. Save the result in memory and return a placeholder for the result. // 2. Run a contentfilter on the highest possible priority that replaced the placeholder by the original result. // // It sounds simple, but it took me a few sleepless nights to figure out. // Here it goes: // Define storage for the results global $wppa_shortcode_results; // Create a key to identify the result. // Any unique key will do, as long as it is not tampered by any content filter. // Hopefully everything keeps an unadded shortcode untouched, // therefor we wrap the random key in square brackets $key = '[' . md5(rand()) . ']'; // Store $wppa_shortcode_results[$key] = $result; // Return the placeholder ( = the key ) in stead of $result return $key; }