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_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(__(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('sphoto_linktype'); $page = wppa_opt('sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('mphoto_linktype'); $page = wppa_opt('mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('thumb_linktype'); $page = wppa_opt('thumb_linkpage'); if (wppa_switch('thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('topten_widget_linktype'); $page = wppa_opt('topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('featen_widget_linktype'); $page = wppa_opt('featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('lasten_widget_linktype'); $page = wppa_opt('lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('comment_widget_linktype'); $page = wppa_opt('comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('slideonly_widget_linktype'); $page = wppa_opt('slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('widget_linktype'); $page = wppa_opt('widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('coverimg_linktype'); $page = wppa_opt('coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('thumbnail_widget_linktype'); $page = wppa_opt('thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('slideshow_linktype'); //''; $page = wppa_opt('slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __('View thumbnails', 'wp-photo-album-plus'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('album_widget_linktype'); $page = wppa_opt('album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } if (wppa('calendar')) { $album = wppa('start_album') ? wppa('start_album') : '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name, 'wp-photo-album-plus'); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('widget_linkurl'); $result['title'] = wppa_opt('widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('calendar')) { $result['url'] .= '&wppa-calendar=' . wppa('calendar') . '&wppa-caldate=' . wppa('caldate'); } if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } if (wppa('is_inverse')) { $result['url'] .= '&wppa-inv=1'; } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur'); $w = wppa_in_widget() ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
/** @see WP_Widget::widget */ function widget($args, $instance) { global $wpdb; wppa('in_widget', 'potd'); wppa_bump_mocc(); require_once dirname(__FILE__) . '/wppa-links.php'; require_once dirname(__FILE__) . '/wppa-styles.php'; require_once dirname(__FILE__) . '/wppa-functions.php'; require_once dirname(__FILE__) . '/wppa-thumbnails.php'; require_once dirname(__FILE__) . '/wppa-boxes-html.php'; require_once dirname(__FILE__) . '/wppa-slideshow.php'; wppa_initialize_runtime(); extract($args); $widget_title = apply_filters('widget_title', $instance['title']); // get the photo ($image) $image = wppa_get_potd(); // Make the HTML for current picture $widget_content = "\n" . '<!-- WPPA+ Photo of the day Widget start -->'; $ali = wppa_opt('potd_align'); if ($ali != 'none') { $align = 'text-align:' . $ali . ';'; } else { $align = ''; } $widget_content .= "\n" . '<div class="wppa-widget-photo" style="' . $align . ' padding-top:2px;position:relative;" >'; if ($image) { $id = $image['id']; $w = wppa_opt('potd_widget_width'); $ratio = wppa_get_photoy($id) / wppa_get_photox($id); $h = round($w * $ratio); $usethumb = wppa_use_thumb_file($id, wppa_opt('potd_widget_width'), '0'); $imgurl = wppa_fix_poster_ext($usethumb ? wppa_get_thumb_url($id, '', $w, $h) : wppa_get_photo_url($id, '', $w, $h), $id); $name = wppa_get_photo_name($id); $page = in_array(wppa_opt('potd_linktype'), wppa('links_no_page')) && !wppa_switch('potd_counter') ? '' : wppa_get_the_landing_page('potd_linkpage', __('Photo of the day', 'wp-photo-album-plus')); $link = wppa_get_imglnk_a('potdwidget', $id); $is_video = wppa_is_video($id); $has_audio = wppa_has_audio($id); if ($link['is_lightbox']) { $lightbox = ($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') . '"' . ' data-alt="' . esc_attr(wppa_get_imgalt($id, true)) . '"'; } else { $lightbox = ''; } if ($link) { if ($link['is_lightbox']) { $cursor = ' cursor:url(' . wppa_get_imgdir() . wppa_opt('magnifier') . '),pointer;'; $title = wppa_zoom_in($id); $ltitle = wppa_get_lbtitle('potd', $id); } else { $cursor = ' cursor:pointer;'; $title = $link['title']; $ltitle = $title; } } else { $cursor = ' cursor:default;'; $title = esc_attr(stripslashes(__($image['name'], 'wp-photo-album-plus'))); } // The medal if on top $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // The link, if any if ($link) { $widget_content .= "\n\t" . '<a href = "' . $link['url'] . '" target="' . $link['target'] . '" ' . $lightbox . ' ' . wppa('lbtitle') . '="' . $ltitle . '">'; } // The image if (wppa_is_video($id)) { $widget_content .= "\n\t\t" . wppa_get_video_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'title' => $title, 'controls' => wppa_opt('potd_linktype') == 'none', 'cursor' => $cursor)); } else { $widget_content .= '<img' . ' src="' . $imgurl . '"' . ' style="width: ' . wppa_opt('potd_widget_width') . 'px;' . $cursor . '"' . ' ' . wppa_get_imgalt($id) . ($title ? 'title="' . $title . '"' : '') . ' />'; } // Close the link if ($link) { $widget_content .= '</a>'; } // The medal if at the bottom $widget_content .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // The counter if (wppa_switch('potd_counter')) { // If we want this $alb = wppa_get_photo_item($id, 'album'); $c = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = " . $alb) - 1; if ($c > 0) { if (wppa_opt('potd_counter_link') == 'thumbs') { $lnk = wppa_get_album_url($alb, $page, 'thumbs', '1'); } elseif (wppa_opt('potd_counter_link') == 'slide') { $lnk = wppa_get_slideshow_url($alb, $page, $id, '1'); } elseif (wppa_opt('potd_counter_link') == 'single') { $lnk = wppa_encrypt_url(get_permalink($page) . '?occur=1&photo=' . $id); // wppa_get_image_page_url_by_id( $id, true, false, $page ); } else { wppa_log('Err', 'Unimplemented counter link type in wppa-potd-widget: ' . wppa_opt('potd_counter_link')); } $widget_content .= '<a href="' . $lnk . '" >' . '<div style="font-size:12px;position:absolute;right:4px;bottom:4px;" >+' . $c . '</div>' . '</a>'; } } // Audio if (wppa_has_audio($id)) { $widget_content .= wppa_get_audio_html(array('id' => $id, 'width' => wppa_opt('potd_widget_width'), 'controls' => true)); } } else { // No image $widget_content .= __('Photo not found', 'wp-photo-album-plus'); } $widget_content .= "\n" . '</div>'; // Add subtitle, if any if ($image) { switch (wppa_opt('potd_subtitle')) { case 'none': break; case 'name': $widget_content .= '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_name($id) . '</div>'; break; case 'desc': $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . wppa_get_photo_desc($id) . '</div>'; break; case 'owner': $owner = $image['owner']; $user = get_user_by('login', $owner); $owner = $user->display_name; $widget_content .= "\n" . '<div class="wppa-widget-text wppa-potd-text" style="' . $align . '">' . __('By:', 'wp-photo-album-plus') . ' ' . $owner . '</div>'; break; default: wppa_log('Err', 'Unimplemented potd_subtitle found in wppa-potd-widget: ' . wppa_opt('potd_subtitle')); } } $widget_content .= '<div style="clear:both;" ></div>'; $widget_content .= "\n" . '<!-- WPPA+ Photo of the day Widget end -->'; echo "\n" . $before_widget; if (!empty($widget_title)) { echo $before_title . $widget_title . $after_title; } echo $widget_content . $after_widget; wppa('in_widget', false); }
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_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; }