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_get_thumb_masonry($id) { global $wpdb; // Init if (!$id) { wppa_dbg_msg('Please check file wppa-theme.php or any other php file that calls wppa_thumb_masonry(). Argument 1: photo id is missing!', 'red', 'force'); die('Please check your configuration'); } $result = ''; $cont_width = wppa_get_container_width(); $count_cols = ceil($cont_width / wppa_opt('thumbsize')); // Get the photo info $thumb = wppa_cache_thumb($id); // Get the album info $album = wppa_cache_album($thumb['album']); // Get photo info $is_video = wppa_is_video($id); $has_audio = wppa_has_audio($id); $imgsrc = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); if (!wppa_is_video($id) && !is_file($imgsrc)) { $result .= '<div' . ' class=""' . ' style="' . 'font-size:10px;' . 'color:red;' . 'width:' . wppa_opt('thumbsize') . 'px;' . 'position:static;' . 'float:left;' . '"' . ' >' . sprintf(__('Missing thumbnail image #%s', 'wp-photo-album-plus'), $id) . '</div>'; return $result; } $alt = $album['alt_thumbsize'] == 'yes' ? '_alt' : ''; $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, wppa_opt('thumbsize' . $alt), 'optional', 'thumb'); // Verical style ? if (wppa_opt('thumbtype') == 'masonry-v') { $imgwidth = wppa_opt('thumbsize'); $imgheight = $imgwidth * wppa_get_thumbratioyx($id); $imgstyle = 'width:100%; height:auto; margin:0; position:relative; box-sizing:border-box;'; $frame_h = ''; } else { $imgheight = wppa_opt('thumbsize'); $imgwidth = $imgheight * wppa_get_thumbratioxy($id); $imgstyle = 'height:100%;' . 'width:auto;' . 'margin:0;' . 'position:relative;' . 'box-sizing:border-box;' . ''; $frame_h = 'height:100%; '; } // Mouseover effect? if (wppa_switch('use_thumb_opacity')) { $opac = wppa_opt('thumb_opacity'); $imgstyle .= ' opacity:' . $opac / 100 . '; filter:alpha( opacity=' . $opac . ' );'; } // Padding if (wppa_is_int(wppa_opt('tn_margin') / 2)) { $imgstyle .= ' padding:' . wppa_opt('tn_margin') / 2 . 'px;'; } else { $p1 = floor(wppa_opt('tn_margin') / 2); $p2 = ceil(wppa_opt('tn_margin') / 2); $imgstyle .= ' padding:' . $p1 . 'px ' . $p2 . 'px ' . $p2 . 'px ' . $p1 . 'px;'; } // Cursor $cursor = $imgattr_a['cursor']; // Popup ? if (wppa_switch('use_thumb_popup')) { // Landscape? if ($imgwidth > $imgheight) { $popwidth = wppa_opt('popupsize'); $popheight = round($popwidth * $imgheight / $imgwidth); } else { $popheight = wppa_opt('popupsize'); $popwidth = round($popheight * $imgwidth / $imgheight); } } else { $popwidth = $imgwidth; $popheight = $imgheight; } $imgurl = wppa_fix_poster_ext(wppa_get_thumb_url($id, '', $popwidth, $popheight), $id); $events = wppa_get_imgevents('thumb', $id); $imgalt = wppa_get_imgalt($id); // returns something like ' alt="Any text" ' $title = esc_attr(wppa_get_masonry_title($id)); // esc_attr( wppa_get_photo_name( $id ) ); // Feed ? if (is_feed()) { $imgattr_a = wppa_get_imgstyle_a($id, $imgsrc, '100', '4', 'thumb'); $style = $imgattr_a['style']; $result .= '<a href="' . get_permalink() . '">' . '<img' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $style . '"' . ' />' . '</a>'; return; } // Get the image link if (wppa('is_topten')) { $no_album = !wppa('start_album'); if ($no_album) { $tit = __('View the top rated photos', 'wp-photo-album-plus'); } else { $tit = esc_attr(__(stripslashes($thumb['description']))); } $link = wppa_get_imglnk_a('thumb', $id, '', $tit, '', $no_album); } else { $link = wppa_get_imglnk_a('thumb', $id); } // voor parent uplr // Open the thumbframe // Add class wppa-mas-h-{mocc} for ie if horizontal $is_ie_or_chrome = strpos($_SERVER["HTTP_USER_AGENT"], 'Trident') || strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome'); $result .= ' <div' . ' id="thumbnail_frame_masonry_' . $id . '_' . wppa('mocc') . '"' . ($is_ie_or_chrome && wppa_opt('thumbtype') == 'masonry-h' ? ' class="wppa-mas-h-' . wppa('mocc') . '"' : '') . ' style="' . $frame_h . 'position:static;' . 'float:left;' . 'font-size:12px;' . 'line-height:8px;' . 'overflow:hidden;' . 'box-sizing:content-box;' . '" >'; // The medals $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // See if ajax possible if ($link) { if ($link['is_url']) { // is url if (wppa_switch('allow_ajax') && wppa_opt('thumb_linktype') == 'photo' && wppa_opt('thumb_linkpage') == '0' && !wppa_switch('thumb_blank') && !(wppa_switch('thumb_overrule') && $thumb['linkurl']) && !wppa('is_topten') && !wppa('is_lasten') && !wppa('is_comten') && !wppa('is_featen') && !wppa('is_tag') && !wppa('is_upldr') && !wppa('src') && !wppa('supersearch') && (wppa_is_int(wppa('start_album')) || wppa('start_album') == '')) { // Ajax possible // The a img ajax $p = wppa('calendar') ? '' : '&wppa-photo=' . $id; $onclick = 'wppaDoAjaxRender( ' . wppa('mocc') . ', \'' . wppa_get_slideshow_url_ajax(wppa('start_album'), '0') . '&wppa-photo=' . $id . '\', \'' . wppa_convert_to_pretty(wppa_get_slideshow_url(wppa('start_album'), '0') . $p) . '\' )'; // old $onclick = "wppaDoAjaxRender( ".wppa( 'mocc' ).", '".wppa_get_slideshow_url_ajax( wppa( 'start_album' ), '0' ).'&wppa-photo='.$id."', '".wppa_convert_to_pretty( wppa_get_slideshow_url( wppa( 'start_album' ), '0' )."&wppa-photo=".$id )."' )"; $result .= '<a style="position:static;" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { // $result .= '<video preload="metadata" onclick="'.$onclick.'" id="i-'.$id.'-'.wppa( 'mocc' ).'" '.$imgalt.' title="'.$title.'" style="'.$imgstyle.' cursor:pointer;" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => $onclick, 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' onclick="' . $onclick . '"' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . ' cursor:pointer;"' . ' ' . $events . ' />'; } $result .= '</a>'; } else { // non ajax // The a img non ajax $result .= '<a style="position:static;" href="' . $link['url'] . '" target="' . $link['target'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '">'; if ($is_video) { // $result .= '<video preload="metadata" id="i-'.$id.'-'.wppa( 'mocc' ).'" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.' cursor:pointer;" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . 'cursor:pointer;"' . ' ' . $events . ' />'; } $result .= '</a>'; } } elseif ($link['is_lightbox']) { // The a img $title = wppa_get_lbtitle('thumb', $id); $result .= '<a href="' . $link['url'] . '"' . ' target="' . $link['target'] . '"' . ($is_video ? ' data-videohtml="' . esc_attr(wppa_get_video_body($id)) . '"' . ' data-videonatwidth="' . wppa_get_videox($id) . '"' . ' data-videonatheight="' . wppa_get_videoy($id) . '"' : '') . ($has_audio ? ' data-audiohtml="' . esc_attr(wppa_get_audio_body($id)) . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' class="thumb-img"' . ' id="x-' . $id . '-' . wppa('mocc') . '">'; // The image $title = wppa_zoom_in($id); // Video? if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => $cursor, 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' />'; } $result .= '</a>'; } else { // The div img $result .= '<div onclick="' . $link['url'] . '" class="thumb-img" id="x-' . $id . '-' . wppa('mocc') . '" style="height:100%;" >'; // Video? if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => 'cursor:pointer;', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' style="' . $imgstyle . 'cursor:pointer;"' . ' ' . $events . ' />'; } $result .= '</div>'; $result .= '<script type="text/javascript">'; $result .= '/* <![CDATA[ */'; $result .= 'wppaPopupOnclick[' . $id . '] = "' . $link['url'] . '";'; $result .= '/* ]]> */'; $result .= '</script>'; } } else { // no link if (wppa_switch('use_thumb_popup')) { $result .= '<div id="x-' . $id . '-' . wppa('mocc') . '" style="height:100%" >'; if ($is_video) { $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '"' . ' ' . $events . ' />'; } $result .= '</div>'; } else { if ($is_video) { // $result .= '<video preload="metadata" '.$imgalt.' title="'.$title.'" width="'.$imgwidth.'" height="'.$imgheight.'" style="'.$imgstyle.'" '.$events.' >'.wppa_get_video_body( $id ).'</video>'; $result .= wppa_get_video_html(array('id' => $id, 'controls' => false, 'margin_top' => '0', 'margin_bottom' => '0', 'tagid' => 'i-' . $id . '-' . wppa('mocc'), 'cursor' => '', 'events' => $events, 'title' => $title, 'preload' => 'metadata', 'onclick' => '', 'lb' => false, 'class' => '', 'style' => $imgstyle, 'use_thumb' => true)); } else { $result .= '<img' . ' id="i-' . $id . '-' . wppa('mocc') . '"' . ' src="' . $imgurl . '"' . ' ' . $imgalt . ($title ? ' title="' . $title . '"' : '') . ' width="' . $imgwidth . '"' . ' height="' . $imgheight . '"' . ' style="' . $imgstyle . '" ' . $events . ' />'; } } } // The audio when no popup if (wppa_switch('thumb_audio') && wppa_has_audio($id)) { $result .= '<div style="position:relative;z-index:11;">'; // $is_safari = strpos( $_SERVER["HTTP_USER_AGENT"], 'Safari' ); // $cont_h = $is_safari ? 16 : 28; // $audiotop = $imgattr_a['height'] + $imgattr_a['margin-top'] - $cont_h; // if ( ! is_file( $imgsrc ) ) { // Audio without image // $audiotop = wppa_get_audio_control_height(); // $imgwidth = wppa_opt( 'tf_width' ); // $imgheight = wppa_get_audio_control_height(); // } $result .= wppa_get_audio_html(array('id' => $id, 'tagid' => 'a-' . $id . '-' . wppa('mocc'), 'style' => 'width:100%;position:absolute;bottom:0;margin:0;padding:' . wppa_opt('tn_margin') / 2 . 'px;left:0;border:none;z-index:10;')); $result .= '</div>'; } // The medals $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // Close the thumbframe $result .= '</div>'; return $result; }
function wppa_get_album_title_attr_a($albumid, $linktype, $linkpage, $has_content, $coverphoto, $photocount) { global $wppa; $album = wppa_cache_album($albumid); // Init $href_title = ''; $onclick_title = ''; $title_title = ''; // Dispatch on linktype when page is not current if ($linkpage > 0) { switch ($linktype) { case 'content': case 'thumbs': case 'albums': if ($has_content) { $href_title = wppa_get_album_url($albumid, $linkpage, $linktype); } else { $href_title = get_page_link($album['cover_linkpage']); } break; case 'slide': if ($has_content) { $href_title = wppa_get_slideshow_url($albumid, $linkpage); } else { $href_title = get_page_link($album['cover_linkpage']); } break; case 'page': $href_title = get_page_link($album['cover_linkpage']); break; case 'none': break; default: } $href_title = wppa_convert_to_pretty($href_title); $title_title = __a('Link to'); $title_title .= ' ' . __(get_the_title($album['cover_linkpage'])); } elseif ($has_content) { switch ($linktype) { case 'content': case 'thumbs': case 'albums': $href_title = wppa_convert_to_pretty(wppa_get_album_url($albumid, $linkpage, $linktype)); if (wppa_switch('wppa_allow_ajax')) { $onclick_title = "wppaDoAjaxRender( " . $wppa['mocc'] . ", '" . wppa_get_album_url_ajax($albumid, $linkpage, $linktype) . "', '" . $href_title . "' )"; $href_title = "#"; } break; case 'slide': $href_title = wppa_convert_to_pretty(wppa_get_slideshow_url($albumid, $linkpage)); if (wppa_switch('wppa_allow_ajax')) { $onclick_title = "wppaDoAjaxRender( " . $wppa['mocc'] . ", '" . wppa_get_slideshow_url_ajax($albumid, $linkpage, $linktype) . "', '" . $href_title . "' )"; $href_title = "#"; } break; case 'none': break; default: } $title_title = __a('View the album') . ' ' . esc_attr(wppa_qtrans(stripslashes($album['name']))); } else { // No content on current page/post if ($photocount > '0') { // coverphotos only if ($coverphoto) { $href_title = wppa_convert_to_pretty(wppa_get_image_page_url_by_id($coverphoto)); } else { $href_title = '#'; } if (wppa_switch('wppa_allow_ajax')) { if ($coverphoto) { $onclick_title = "wppaDoAjaxRender( " . $wppa['mocc'] . ", '" . wppa_get_image_url_ajax_by_id($coverphoto) . "', '" . $href_title . "' )"; } else { $onclick_title = ''; } $href_title = "#"; } if ($photocount == '1') { $title_title = __a('View the cover photo'); } else { $title_title = __a('View the cover photos'); } } } $title_attr['href'] = $href_title; $title_attr['onclick'] = $onclick_title; $title_attr['title'] = $title_title; return $title_attr; }