function wppa_get_statistics() { $count = wppa_get_total_album_count(); $y_id = wppa_get_youngest_album_id(); $y_name = __(wppa_get_album_name($y_id)); $p_id = wppa_get_parentalbumid($y_id); $p_name = __(wppa_get_album_name($p_id)); $result = '<div class="wppa-box wppa-nav" style="text-align: center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . '">'; $result .= __a('There are') . ' ' . $count . ' ' . __a('photo albums. The last album added is') . ' '; $result .= '<a href="' . wppa_get_permalink() . 'wppa-album=' . $y_id . '&wppa-cover=0&wppa-occur=1">' . $y_name . '</a>'; if ($p_id > '0') { $result .= __a(', a subalbum of') . ' '; $result .= '<a href="' . wppa_get_permalink() . 'wppa-album=' . $p_id . '&wppa-cover=0&wppa-occur=1">' . $p_name . '</a>'; } $result .= '.</div>'; return $result; }
function do_album_navigator($parent, $page, $skip, $propclass, $extraclause = '') { global $wpdb; static $level; static $ca; if (!$level) { $level = '1'; if (isset($_REQUEST['wppa-album'])) { $ca = $_REQUEST['wppa-album']; } elseif (isset($_REQUEST['album'])) { $ca = $_REQUEST['album']; } else { $ca = '0'; } $ca = wppa_force_numeric_else($ca, '0'); if ($ca && !wppa_album_exists($ca)) { // wppa_log('dbg', 'Non-existent album '.$ca.' in url. Referrer= '.$_ENV["HTTP_REFERER"].', Request uri= '.$_ENV["REQUEST_URI"]); $ca = '0'; } } else { $level++; } $slide = wppa_opt('album_navigator_widget_linktype') == 'slide' ? '&wppa-slide=1' : ''; $w = $this->get_widget_id(); $p = $parent; $result = ''; $albums = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s " . $extraclause . wppa_get_album_order(max('0', $parent)), $parent), ARRAY_A); if (!empty($albums)) { wppa_cache_album('add', $albums); $result .= '<ul>'; foreach ($albums as $album) { $a = $album['id']; $treecount = wppa_treecount_a($a); if ($treecount['albums'] || $treecount['photos'] > wppa_opt('min_thumbs') || $skip == 'no') { $result .= ' <li class="anw-' . $w . '-' . $p . $propclass . '" style="list-style:none; display:' . ($level == '1' ? '' : 'none') . ';">'; if (wppa_has_children($a)) { $result .= ' <div style="cursor:default;width:12px;float:left;text-align:center;font-weight:bold;" class="anw-' . $w . '-' . $a . '-" onclick="jQuery(\'.anw-' . $w . '-' . $a . '\').css(\'display\',\'\'); jQuery(\'.anw-' . $w . '-' . $a . '-\').css(\'display\',\'none\');" >' . ($a == $ca ? '»' : '+') . '</div> <div style="cursor:default;width:12px;float:left;text-align:center;font-weight:bold;display:none;" class="anw-' . $w . '-' . $a . '" onclick="jQuery(\'.anw-' . $w . '-' . $a . '-\').css(\'display\',\'\'); jQuery(\'.anw-' . $w . '-' . $a . '\').css(\'display\',\'none\'); jQuery(\'.p-' . $w . '-' . $a . '\').css(\'display\',\'none\');" >' . ($a == $ca ? '»' : '-') . '</div>'; } else { $result .= ' <div style="width:12px;float:left;" > ' . ($a == $ca ? '»' : '') . '</div>'; } $result .= ' <a href="' . wppa_encrypt_url(wppa_get_permalink($page) . '&wppa-album=' . $a . '&wppa-cover=0&wppa-occur=1' . $slide) . '">' . wppa_get_album_name($a) . '</a> </li>'; $newpropclass = $propclass . ' p-' . $w . '-' . $p; $result .= '<li class="anw-' . $w . '-' . $p . $propclass . '" style="list-style:none;" >' . $this->do_album_navigator($a, $page, $skip, $newpropclass, $extraclause) . '</li>'; } } $result .= '</ul>'; if ($level == '1' && $ca) { // && $parent != '-1' ) { $result .= '<script type="text/javascript" >'; while ($ca != '0' && $ca != '-1') { $result .= ' jQuery(\'.anw-' . $w . '-' . $ca . '\').css(\'display\',\'\'); jQuery(\'.anw-' . $w . '-' . $ca . '-\').css(\'display\',\'none\');'; $ca = wppa_get_parentalbumid($ca); } $result .= '</script>'; } } $level--; return str_replace('<ul></ul>', '', $result); }
function wppa_get_ss_to_tn_link($page = '0', $id = '0') { global $thumbs; global $thumbs_ids; // Search ? if (wppa('src') && wppa('mocc') == '1' && !wppa('is_related')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-searchstring=' . stripslashes(wppa('searchstring')); } elseif (wppa('is_upldr')) { if (wppa('start_album')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-upldr=' . wppa('is_upldr') . '&wppa-album=' . wppa('start_album'); } else { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-upldr=' . wppa('is_upldr'); } } elseif (wppa('is_topten')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-topten=' . wppa('topten_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_lasten')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-lasten=' . wppa('lasten_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_comten')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-comten=' . wppa('comten_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_featen')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-featen=' . wppa('featen_count') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_tag')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-tag=' . wppa('is_tag') . '&wppa-album=' . wppa('start_album'); } elseif (wppa('is_cat')) { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-cat=' . wppa('is_cat') . '&wppa-album=' . wppa('start_album'); } else { $thumbhref = wppa_get_permalink($page) . 'wppa-cover=0&wppa-occur=' . wppa('occur') . '&wppa-album=' . wppa('start_album'); } // $id is the id. See to what page we have to go $page = '1'; $p = wppa_opt('thumb_page_size'); if ($p) { $i = '0'; foreach ($thumbs_ids as $ti) { // $thumbs_ids is setup in function wppa_prepare_slideshow_pagination() if ($id == $ti) { $page = floor($i / $p) + '1'; } $i++; } if ($page > '1') { $thumbhref .= '&wppa-page=' . $page; } } // Make sure the clicked photos thumb is highligted $thumbhref .= '&wppa-hilite=' . $id; $thumbhref = wppa_convert_to_pretty(wppa_trim_wppa_($thumbhref)); return $thumbhref; }
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_crumb_ancestors($alb, $to_cover) { global $wppa; 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 ) TO BE EXPANDED! ! ! $slide = wppa_get_album_title_linktype($parent) == 'slide' ? '&wppa-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:') . ' ' . wppa_get_album_name($parent); $class = 'b20'; wppa_bcitem($value, $href, $title, $class); return; }
function wppa_bestof_html($args, $widget = true) { // Copletify args $args = wp_parse_args((array) $args, array('page' => '0', 'count' => '1', 'sortby' => 'maxratingcount', 'display' => 'photo', 'period' => 'thisweek', 'maxratings' => 'yes', 'meanrat' => 'yes', 'ratcount' => 'yes', 'linktype' => 'none', 'size' => wppa_opt('widget_width'), 'fontsize' => wppa_opt('fontsize_widget_thumb'), 'lineheight' => wppa_opt('fontsize_widget_thumb') * 1.5, 'height' => '200')); // Make args into seperate vars extract($args); // Validate args if (!in_array($sortby, array('maxratingcount', 'meanrating', 'ratingcount'))) { wppa_dbg_msg('Invalid arg sortby "' . $sortby . '" must be "maxratingcount", "meanrating" or "ratingcount"', 'red', 'force'); } if (!in_array($display, array('photo', 'owner'))) { wppa_dbg_msg('Invalid arg display "' . $display . '" must be "photo" or "owner"', 'red', 'force'); } if (!in_array($period, array('lastweek', 'thisweek', 'lastmonth', 'thismonth', 'lastyear', 'thisyear'))) { wppa_dbg_msg('Invalid arg period "' . $period . '" must be "lastweek", "thisweek", "lastmonth", "thismonth", "lastyear" or "thisyear"', 'red', 'force'); } if (!$widget) { $size = $height; } $result = ''; $data = wppa_get_the_bestof($count, $period, $sortby, $display); if ($display == 'photo') { if (is_array($data)) { foreach (array_keys($data) as $id) { $thumb = wppa_cache_thumb($id); if ($thumb) { $imgsize = array(wppa_get_photox($id), wppa_get_photoy($id)); if ($widget) { $maxw = $size; $maxh = round($maxw * $imgsize['1'] / $imgsize['0']); } else { $maxh = $size; $maxw = round($maxh * $imgsize['0'] / $imgsize['1']); } $totalh = $maxh + $lineheight; if ($maxratings == 'yes') { $totalh += $lineheight; } if ($meanrat == 'yes') { $totalh += $lineheight; } if ($ratcount == 'yes') { $totalh += $lineheight; } if ($widget) { $clear = 'clear:both; '; } else { $clear = ''; } $result .= "\n" . '<div' . ' class="wppa-widget"' . ' style="' . $clear . 'width:' . $maxw . 'px; height:' . $totalh . 'px; margin:4px; display:inline; text-align:center; float:left;"' . ' >'; // The medal if at the top $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'top')); // The link if any if ($linktype != 'none') { switch ($linktype) { case 'owneralbums': $href = wppa_get_permalink($page) . 'wppa-cover=1&wppa-owner=' . $thumb['owner'] . '&wppa-occur=1'; $title = __('See the authors albums', 'wp-photo-album-plus'); break; case 'ownerphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-owner=' . $thumb['owner'] . '&photos-only&wppa-occur=1'; $title = __('See the authors photos', 'wp-photo-album-plus'); break; case 'upldrphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-upldr=' . $thumb['owner'] . '&wppa-occur=1'; $title = __('See all the authors photos', 'wp-photo-album-plus'); break; } $result .= '<a href="' . wppa_convert_to_pretty($href) . '" title="' . $title . '" >'; } // The image $result .= '<img' . ' style="height:' . $maxh . 'px; width:' . $maxw . 'px;"' . ' src="' . wppa_fix_poster_ext(wppa_get_photo_url($id, '', $maxw, $maxh), $id) . '"' . ' ' . wppa_get_imgalt($id) . ' />'; // The /link if ($linktype != 'none') { $result .= '</a>'; } // The medal if near the bottom $result .= wppa_get_medal_html_a(array('id' => $id, 'size' => 'M', 'where' => 'bot')); // The subtitles $result .= "\n\t" . '<div style="font-size:' . $fontsize . 'px; line-height:' . $lineheight . 'px; position:absolute; width:' . $maxw . 'px; ">'; $result .= sprintf(__('Photo by: %s', 'wp-photo-album-plus'), $data[$id]['user']) . '<br />'; if ($maxratings == 'yes') { $n = $data[$id]['maxratingcount']; $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />'; } if ($ratcount == 'yes') { $n = $data[$id]['ratingcount']; $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />'; } if ($meanrat == 'yes') { $m = $data[$id]['meanrating']; $result .= sprintf(__('Rating: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />'; } $result .= '</div>'; $result .= '<div style="clear:both" ></div>'; $result .= "\n" . '</div>'; } else { // No image $result .= '<div>' . sprintf(__('Photo %s not found.', 'wp-photo-album-plus'), $id) . '</div>'; } } } else { $result .= $data; // No array, print message } } else { // Display = owner if (is_array($data)) { $result .= '<ul>'; foreach (array_keys($data) as $author) { $result .= '<li>'; // The link if any if ($linktype != 'none') { switch ($linktype) { case 'owneralbums': $href = wppa_get_permalink($page) . 'wppa-cover=1&wppa-owner=' . $data[$author]['owner'] . '&wppa-occur=1'; $title = __('See the authors albums', 'wp-photo-album-plus'); break; case 'ownerphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-owner=' . $data[$author]['owner'] . '&photos-only&wppa-occur=1'; $title = __('See the authors photos', 'wp-photo-album-plus'); break; case 'upldrphotos': $href = wppa_get_permalink($page) . 'wppa-cover=0&wppa-upldr=' . $data[$author]['owner'] . '&wppa-occur=1'; $title = __('See all the authors photos', 'wp-photo-album-plus'); break; } $result .= '<a href="' . $href . '" title="' . $title . '" >'; } // The name $result .= $author; // The /link if ($linktype != 'none') { $result .= '</a>'; } $result .= '<br/>'; // The subtitles $result .= "\n" . '<div style="font-size:' . wppa_opt('fontsize_widget_thumb') . 'px; line-height:' . $lineheight . 'px; ">'; if ($maxratings == 'yes') { $n = $data[$author]['maxratingcount']; $result .= sprintf(_n('%d max rating', '%d max ratings', $n, 'wp-photo-album-plus'), $n) . '<br />'; } if ($ratcount == 'yes') { $n = $data[$author]['ratingcount']; $result .= sprintf(_n('%d vote', '%d votes', 'wp-photo-album-plus'), $n) . '<br />'; } if ($meanrat == 'yes') { $m = $data[$author]['meanrating']; $result .= sprintf(__('Mean value: %4.2f.', 'wp-photo-album-plus'), $m) . '<br />'; } $result .= '</div>'; $result .= '</li>'; } $result .= '</ul>'; } else { $result .= $data; // No array, print message } } return $result; }