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_is_ancestor($anc, $xchild) { $child = $xchild; if (is_numeric($anc) && is_numeric($child)) { $parent = wppa_get_parentalbumid($child); while ($parent > '0') { if ($anc == $parent) { return true; } $child = $parent; $parent = wppa_get_parentalbumid($child); } } return false; }
function wppa_flush_treecounts($alb = '') { global $wppa; if ($alb) { $wppa['counts'] = WPPA_MULTISITE_GLOBAL ? get_site_option('wppa_counts', array()) : get_option('wppa_counts', array()); $wppa['treecounts'] = WPPA_MULTISITE_GLOBAL ? get_site_option('wppa_counts_tree', array()) : get_option('wppa_counts_tree', array()); if (isset($wppa['counts'][$alb])) { unset($wppa['counts'][$alb]); $iret = WPPA_MULTISITE_GLOBAL ? update_site_option('wppa_counts', $wppa['counts']) : update_option('wppa_counts', $wppa['counts']); } if (isset($wppa['treecounts'][$alb])) { unset($wppa['treecounts'][$alb]); $uret = WPPA_MULTISITE_GLOBAL ? update_site_option('wppa_counts_tree', $wppa['treecounts']) : update_option('wppa_counts_tree', $wppa['treecounts']); } $parent = wppa_get_parentalbumid($alb); if ($parent > '0') { wppa_flush_treecounts($parent); } } else { $bret = WPPA_MULTISITE_GLOBAL ? delete_site_option('wppa_counts') : delete_option('wppa_counts'); $bret = WPPA_MULTISITE_GLOBAL ? delete_site_option('wppa_counts_tree') : delete_option('wppa_counts_tree'); } }
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_do_albumlist($parent, $nestinglevel, $albums, $seq) { global $wpdb; $alt = true; foreach (array_keys($seq) as $s) { // Obey the global sequence $album = $albums[$s]; if ($album['a_parent'] == $parent) { if (wppa_have_access($album)) { $counts = wppa_treecount_a($album['id']); $pendcount = $counts['pendphotos']; $schedulecount = $counts['scheduledphotos']; $haschildren = wppa_have_accessable_children($album); $class = ''; if ($parent != '0' && $parent != '-1') { $class .= 'wppa-alb-on-' . $parent . ' '; $par = $parent; while ($par != '0' && $par != '-1') { $class .= 'wppa-alb-off-' . $par . ' '; $par = wppa_get_parentalbumid($par); } } if ($alt) { $class .= ' alternate'; } $style = ''; if ($pendcount) { $style .= 'background-color:#ffdddd; '; } // if ( $haschildren ) $style .= 'font-weight:bold; '; if ($parent != '0' && $parent != '-1') { $style .= 'display:none; '; } $onclickon = 'jQuery(\'.wppa-alb-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'\');'; $onclickoff = 'jQuery(\'.wppa-alb-off-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'none\'); checkArrows();'; $indent = $nestinglevel; if ($indent > '5') { $indent = 5; } ?> <tr class="<?php echo $class; ?> " style="<?php echo $style; ?> " > <?php $i = 0; while ($i < $indent) { echo '<td style="padding:2px;" ></td>'; $i++; } ?> <td style="padding:2px; text-align:center;" ><?php if ($haschildren) { ?> <img id="alb-arrow-off-<?php echo $album['id']; ?> " class="alb-arrow-off" style="height:16px; display:none;" src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " onclick="<?php echo $onclickoff; ?> " title="<?php _e('Collapse subalbums', 'wp-photo-album-plus'); ?> " /> <img id="alb-arrow-on-<?php echo $album['id']; ?> " class="alb-arrow-on" style="height:16px;" src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " onclick="<?php echo $onclickon; ?> " title="<?php _e('Expand subalbums', 'wp-photo-album-plus'); ?> " /> <?php } ?> </td> <td style="padding:2px;" ><?php echo $album['id']; ?> </td> <?php $i = $indent; while ($i < 5) { echo '<td style="padding:2px;" ></td>'; $i++; } ?> <td><?php echo esc_attr(__(stripslashes($album['name']))); ?> </td> <td><small><?php echo esc_attr(__(stripslashes($album['description']))); ?> </small></td> <?php if (current_user_can('administrator')) { ?> <td><?php echo $album['owner']; ?> </td> <?php } ?> <td><?php echo $album['a_order']; ?> </td> <td><?php echo wppa_get_album_name($album['a_parent'], 'extended'); ?> </td> <?php $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album['id']); ?> <?php $na = $counts['selfalbums']; ?> <?php $np = $counts['selfphotos']; ?> <?php $nm = $counts['pendphotos']; ?> <?php $ns = $counts['scheduledphotos']; ?> <td><?php echo $na . '/' . $np . '/' . $nm . '/' . $ns; ?> </td> <?php if ($album['owner'] != '--- public ---' || wppa_user_is('administrator')) { ?> <?php $url = wppa_ea_url($album['id']); ?> <td><a href="<?php echo $url; ?> " class="wppaedit"><?php _e('Edit', 'wp-photo-album-plus'); ?> </a></td> <td><a href="<?php echo $url . '&quick'; ?> " class="wppaedit"><?php _e('Quick', 'wp-photo-album-plus'); ?> </a></td> <td><a href="<?php echo $url . '&bulk#manage-photos'; ?> " class="wppaedit"><?php _e('Bulk', 'wp-photo-album-plus'); ?> </a></td> <td><a href="<?php echo $url . '&seq'; ?> " class="wppaedit"><?php _e('Seq', 'wp-photo-album-plus'); ?> </a></td> <?php $url = wppa_ea_url($album['id'], 'del'); ?> <td><a href="<?php echo $url; ?> " class="wppadelete"><?php _e('Delete', 'wp-photo-album-plus'); ?> </a></td> <?php if (wppa_can_create_album()) { $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=new&parent_id=' . $album['id']); if (wppa_switch('confirm_create')) { $onc = 'if (confirm(\'' . __('Are you sure you want to create a subalbum?', 'wp-photo-album-plus') . '\')) document.location=\'' . $url . '\';'; echo '<td><a onclick="' . $onc . '" class="wppacreate">' . __('Create', 'wp-photo-album-plus') . '</a></td>'; } else { echo '<td><a href="' . $url . '" class="wppacreate">' . __('Create', 'wp-photo-album-plus') . '</a></td>'; } } } else { ?> <td></td><td></td><?php if (wppa_can_create_album()) { echo '<td></td'; } ?> <?php } ?> </tr> <?php if ($alt == '') { $alt = ' class="alternate" '; } else { $alt = ''; } if ($haschildren) { wppa_do_albumlist($album['id'], $nestinglevel + '1', $albums, $seq); } } } } }