function wppa_album_select_a($args) { global $wpdb; $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true)); // Provide default selection if no selected given if ($args['selected'] === '') { $args['selected'] = wppa_get_last_album(); } // See if selection is valid if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) { $args['selected'] = '0'; } $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order($args['root']), ARRAY_A); // Add to secondary cache if ($albums) { wppa_cache_album('add', $albums); } if ($albums) { // Filter for root if ($args['root']) { $root = $args['root']; switch ($root) { // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )' case '-2': // Generic only foreach (array_keys($albums) as $albidx) { if (wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; case '-1': // Separate only foreach (array_keys($albums) as $albidx) { if (!wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; default: foreach (array_keys($albums) as $albidx) { if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; } } // Filter for must have content if ($args['content']) { foreach (array_keys($albums) as $albidx) { if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) { unset($albums[$albidx]); } } } // Add paths if ($args['path']) { $albums = wppa_add_paths($albums); } else { foreach (array_keys($albums) as $index) { $albums[$index]['name'] = __(stripslashes($albums[$index]['name'])); } } // Sort if ($args['sort']) { $albums = wppa_array_sort($albums, 'name'); } } // Output $result = ''; $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addpleaseselect']) { $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . (is_admin() ? __('- select an album -', 'wppa') : __a('- select an album -')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addnone']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- none ---', 'wppa') : __a('--- none ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- all ---', 'wppa') : __a('--- all ---')) . '</option>'; } $selected = $args['selected'] == '-2' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="-2"' . $selected . ' >' . (is_admin() ? __('--- generic ---', 'wppa') : __a('--- generic ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addblank']) { $result .= '<option value="0"' . $selected . ' >' . '</option>'; } $selected = $args['selected'] == '-99' ? ' selected="selected"' : ''; if ($args['addmultiple']) { $result .= '<option value="-99"' . $selected . ' >' . (is_admin() ? __('--- multiple see below ---', 'wppa') : __a('--- multiple see below ---')) . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addselbox']) { $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- a selection box ---', 'wppa') : __a('--- a selection box ---')) . '</option>'; } if ($albums) { foreach ($albums as $album) { if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } if ($args['selected'] == $album['id'] && !$disabled) { $selected = ' selected="selected"'; } else { $selected = ''; } $ok = true; // Assume this will be in the list if ($args['checkaccess'] && !wppa_have_access($album['id'])) { $ok = false; } if ($args['checkowner'] && wppa_switch('upload_owner_only')) { // Need to check if ($album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---') { // Not 'mine' if (!wppa_user_is('administrator')) { // No admin $ok = false; } } } if ($selected && $args['addselected']) { $ok = true; } if ($ok) { if ($args['addnumbers']) { $number = ' ( ' . $album['id'] . ' )'; } else { $number = ''; } $result .= '<option value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>'; } } } $selected = $args['selected'] == '-1' ? ' selected="selected"' : ''; if ($args['addseparate']) { $result .= '<option value="-1"' . $selected . '>' . (is_admin() ? __('--- separate ---', 'wppa') : __a('--- separate ---')) . '</option>'; } return $result; }
function wppa_crumb_ancestors($alb, $to_cover) { global $wpdb; // Find parent $parent = wppa_get_parentalbumid($alb); if ($parent < '1') { return; } // No parent -> toplevel -> done. wppa_crumb_ancestors($parent, $to_cover); // Find the album specific link type ( content, slide, page or none ) $slide = wppa_get_album_title_linktype($parent) == 'slide' ? '&wppa-slide' : ''; // NOT SLIDE when there are no photos if (!wppa_get_photo_count($parent, 'use_treecounts')) { $slide = ''; } $pagid = $wpdb->get_var($wpdb->prepare("SELECT `cover_linkpage` FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $parent)); wppa_dbg_q('Q-bc3'); $value = wppa_get_album_name($parent); $href = wppa_get_permalink($pagid) . 'wppa-album=' . $parent . '&wppa-cover=' . $to_cover . $slide . '&wppa-occur=' . wppa('occur'); $title = __('Album:', 'wp-photo-album-plus') . ' ' . wppa_get_album_name($parent); $class = 'b20'; wppa_bcitem($value, $href, $title, $class); return; }
function wppa_album_select_a($args) { global $wpdb; $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'addowner' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true, 'checkarray' => false, 'array' => array(), 'optionclass' => '')); // Provide default selection if no selected given if ($args['selected'] === '') { $args['selected'] = wppa_get_last_album(); } // See if selection is valid if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) { $args['selected'] = '0'; } // Get roughly the albums that might be in the selection if ($args['checkarray'] && !empty($args['array'])) { $albums = $wpdb->get_results("SELECT `id`, `name` " . "FROM `" . WPPA_ALBUMS . "` " . "WHERE `id` IN (" . implode(',', $args['array']) . ") " . ($args['checkowner'] && wppa_switch('upload_owner_only') && !wppa_user_is('administrator') ? "AND `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "") . wppa_get_album_order($args['root']), ARRAY_A); } else { $albums = $wpdb->get_results("SELECT `id`, `name` " . "FROM `" . WPPA_ALBUMS . "` " . ($args['checkowner'] && wppa_switch('upload_owner_only') && !wppa_user_is('administrator') ? "WHERE `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "") . wppa_get_album_order($args['root']), ARRAY_A); } /* Can not add to cache because only "SELECT * " can be added // Add to secondary cache if ( $albums ) { wppa_cache_album( 'add', $albums ); } */ if ($albums) { // Filter for root if ($args['root']) { $root = $args['root']; switch ($root) { // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )' case '-2': // Generic only foreach (array_keys($albums) as $albidx) { if (wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; case '-1': // Separate only foreach (array_keys($albums) as $albidx) { if (!wppa_is_separate($albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; default: foreach (array_keys($albums) as $albidx) { if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) { unset($albums[$albidx]); } } break; } } // Filter for must have content if ($args['content']) { foreach (array_keys($albums) as $albidx) { if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) { unset($albums[$albidx]); } } } // Add paths if ($args['path']) { $albums = wppa_add_paths($albums); } else { foreach (array_keys($albums) as $index) { $albums[$index]['name'] = __(stripslashes($albums[$index]['name'])); } } // Sort if ($args['sort']) { $albums = wppa_array_sort($albums, 'name'); } } // Output $result = ''; $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addpleaseselect']) { $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . __('- select an album -', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addnone']) { $result .= '<option value="0"' . $selected . ' >' . __('--- none ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="0"' . $selected . ' >' . __('--- all ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '-2' ? ' selected="selected"' : ''; if ($args['addall']) { $result .= '<option value="-2"' . $selected . ' >' . __('--- generic ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '-3' ? ' selected="selected"' : ''; if ($args['addowner']) { $result .= '<option value="-3"' . $selected . ' >' . __('--- owner/public ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addblank']) { $result .= '<option value="0"' . $selected . ' >' . '</option>'; } $selected = $args['selected'] == '-99' ? ' selected="selected"' : ''; if ($args['addmultiple']) { $result .= '<option value="-99"' . $selected . ' >' . __('--- multiple see below ---', 'wp-photo-album-plus') . '</option>'; } $selected = $args['selected'] == '0' ? ' selected="selected"' : ''; if ($args['addselbox']) { $result .= '<option value="0"' . $selected . ' >' . __('--- a selection box ---', 'wp-photo-album-plus') . '</option>'; } // In case multiple if (strpos($args['selected'], ',') !== false) { $selarr = explode(',', $args['selected']); } else { $selarr = array($args['selected']); } if ($albums) { foreach ($albums as $album) { if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) { $disabled = ' disabled="disabled"'; } else { $disabled = ''; } if (in_array($album['id'], $selarr, true) && !$disabled) { $selected = ' selected="selected"'; } else { $selected = ''; } $ok = true; // Assume this will be in the list if ($args['checkaccess'] && !wppa_have_access($album['id'])) { $ok = false; } /* This is in the query now if ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) ) { // Need to check if ( $album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---' ) { // Not 'mine' if ( ! wppa_user_is( 'administrator' ) ) { // No admin $ok = false; } } } */ /* This is in the query now if ( $args['checkarray'] ) { if ( ! in_array( $album['id'], $args['array'] ) ) { $ok = false; } } */ if ($selected && $args['addselected']) { $ok = true; } if ($ok) { if ($args['addnumbers']) { $number = ' ( ' . $album['id'] . ' )'; } else { $number = ''; } $result .= '<option class="' . $args['optionclass'] . '" value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>'; } } } $selected = $args['selected'] == '-1' ? ' selected="selected"' : ''; if ($args['addseparate']) { $result .= '<option value="-1"' . $selected . '>' . __('--- separate ---', 'wp-photo-album-plus') . '</option>'; } return $result; }
function wppa_subalbumlinks_html($id, $top = true) { global $wpdb; // Do they need us? Anything to display? if (wppa_opt('cover_sublinks_display') == 'none') { return; } // Display type $display_type = wppa_opt('cover_sublinks_display'); // Link type $link_type = wppa_opt('cover_sublinks'); // Init $is_list = $display_type == 'list' || $display_type == 'recursivelist'; $is_recursive = $display_type == 'recursivelist'; $first = true; // Get the children $subs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = " . $id . " " . wppa_get_album_order($id), ARRAY_A); // Only if there are sub-albums if (!empty($subs)) { wppa_out('<div>'); // Local css if ($top) { if ($is_list) { wppa_out('<style scoped="scoped" >' . 'ul, li { margin:0; }' . 'ul {' . 'list-style-type:disc;' . 'list-style-position:inside;' . 'padding:0 0 0 24px;' . '}' . 'li { cursor:pointer; }' . '</style>'); } if ($display_type == 'microthumbs') { wppa_out('<style scoped="scoped" >' . 'img {' . 'max-width:100px;' . 'max-height:50px;' . 'padding:1px;' . 'margin:1px;' . 'background-color:' . wppa_opt('bgcolor_img') . ';' . 'float:left;' . '}' . '</style>'); } } // Start list if required if ($is_list) { wppa_out('<ul class="wppa-cover-sublink-list" style="clear:both;" >'); } else { wppa_out('<div style="clear:both;" ></div>'); } // Process the sub-albums foreach ($subs as $album) { // 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 content 'View' link $albumid = $album['id']; $photocount = wppa_get_photo_count($albumid, 'use_treecounts'); // Thumbnails and covers, show sub-album covers // in case slideshow is requested on an empty album if (wppa_opt('cover_sublinks') == 'content' || !$photocount) { if (wppa_switch('allow_ajax') && !$linkpage) { $href_content = ''; $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )"; } else { $href_content = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage)); $onclick_content = ''; } } else { if (wppa_switch('allow_ajax') && !$linkpage) { $href_content = ''; $onclick_content = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage) . "', '" . wppa_convert_to_pretty($href_content) . "' )"; } else { $href_content = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage)); $onclick_content = ''; } } // Do the output $title = esc_attr(__('View the album', 'wp-photo-album-plus') . ': ' . wppa_get_album_name($album['id'])); switch ($display_type) { case 'list': case 'recursivelist': if ($link_type == 'none') { wppa_out('<li>' . wppa_get_album_name($album['id']) . '</li>'); } else { wppa_out('<li>' . '<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . wppa_get_album_name($album['id']) . '</a>' . '</li>'); } break; case 'enum': if (!$first) { wppa_out(', '); } if ($link_type == 'none') { wppa_out(wppa_get_album_name($album['id'])); } else { wppa_out('<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . wppa_get_album_name($album['id']) . '</a>'); } $first = false; break; case 'microthumbs': $coverphoto_id = wppa_get_coverphoto_id($album['id']); $src = wppa_fix_poster_ext(wppa_get_thumb_url($coverphoto_id), $coverphoto_id); if ($link_type == 'none') { wppa_out('<img' . ' class="wppa-cover-sublink-img"' . ' src="' . $src . '"' . ' alt="' . wppa_get_album_name($album['id']) . '"' . ' />'); } else { wppa_out('<a' . ($href_content ? ' href="' . $href_content . '"' : '') . ($onclick_content ? ' onclick="' . $onclick_content . '"' : '') . ' title="' . $title . '"' . ' >' . '<img' . ' class="wppa-cover-sublink-img"' . ' src="' . $src . '"' . ' alt="' . wppa_get_album_name($album['id']) . '"' . ' />' . '</a>'); } break; } // Go deeper for grandchildren if ($is_recursive) { wppa_subalbumlinks_html($album['id'], false); } } // End list if ($is_list) { wppa_out('</ul>'); } wppa_out('</div>'); } }
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; }
function wppa_album_cover_longdesc($albumid, $multicolresp = false) { global $wppa; 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('wppa_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('wppa_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('wppa_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('wppa_allow_ajax') ? '_self' : $photolink['target']; // Open the album box $wppa['out'] .= wppa_nltab('+') . '<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'] .= wppa_nltab('+') . '<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'] .= wppa_nltab('-') . '</div><!-- covertext-frame -->'; // 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('wppa_show_cover_text')) { $textheight = wppa_opt('wppa_text_frame_height') > '0' ? 'min-height:' . wppa_opt('wppa_text_frame_height') . 'px; ' : ''; $wppa['out'] .= wppa_nltab() . '<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'] .= wppa_nltab() . '<div style="clear:both;"></div>'; // Close the album box $wppa['out'] .= wppa_nltab('-') . '</div><!-- #album-' . $albumid . '-' . $wppa['mocc'] . ' -->'; // Toggle alt/even wppa_toggle_alt(); }