Beispiel #1
0
function wppa_breadcrumb($opt = '')
{
    global $wpdb;
    global $wppa_session;
    // See if they need us
    // Check Table II-A1 a and b
    if ($opt == 'optional') {
        $pid = wppa_get_the_page_id();
        $type = $wpdb->get_var($wpdb->prepare("SELECT `post_type` FROM `" . $wpdb->posts . "` WHERE `ID` = %s", $pid));
        wppa_dbg_q('Q-bc1');
        if ($type == 'post' && !wppa_switch('show_bread_posts')) {
            return;
            // Nothing to do here
        }
        if ($type != 'post' && !wppa_switch('show_bread_pages')) {
            return;
            // Nothing to do here
        }
    }
    // Check special cases
    if (wppa('is_single')) {
        return;
    }
    // A single image slideshow needs no navigation
    if (wppa_page('oneofone')) {
        return;
    }
    // Never at a single image page
    if (wppa('is_slideonly')) {
        return;
    }
    // Not when slideonly
    if (wppa_in_widget()) {
        return;
    }
    // Not in a widget
    if (is_feed()) {
        return;
    }
    // Not in a feed
    $thumbhref = '';
    // Any special selection has its own switch
    if (wppa('is_topten') && !wppa_switch('bc_on_topten')) {
        return;
    }
    if (wppa('is_lasten') && !wppa_switch('bc_on_lasten')) {
        return;
    }
    if (wppa('is_comten') && !wppa_switch('bc_on_comten')) {
        return;
    }
    if (wppa('is_featen') && !wppa_switch('bc_on_featen')) {
        return;
    }
    if (wppa('is_related') && !wppa_switch('bc_on_related')) {
        return;
    }
    if (wppa('is_tag') && !wppa_switch('bc_on_tag')) {
        return;
    }
    if (wppa('src') && !wppa_switch('bc_on_search')) {
        return;
    }
    // Get the album number
    $alb = wppa_is_int(wppa('start_album')) ? wppa('start_album') : '0';
    // A single album or all ( all = 0 here )
    $is_albenum = strlen(wppa('start_album')) > '0' && !wppa_is_int(wppa('start_album'));
    wppa_dbg_msg('alb=' . $alb . ', albenum=' . $is_albenum, 'green');
    $virtual = wppa_is_virtual() || wppa('last_albums');
    if (wppa('last_albums')) {
        $alb = wppa('last_albums_parent');
    }
    wppa_dbg_msg('alb=' . $alb . ', albenum=' . $is_albenum . ', l_a=' . wppa('last_albums') . ', l_a_p=' . wppa('last_albums_parent'), 'green');
    // See if the album is a 'stand alone' album
    $separate = wppa_is_separate($alb);
    // See if the album links to slides in stead of thumbnails
    $slide = wppa_get_album_title_linktype($alb) == 'slide' ? '&wppa-slide' : '';
    // See if we link to covers or to contents
    $to_cover = wppa_opt('thumbtype') == 'none' ? '1' : '0';
    // Photo number?
    $photo = wppa('start_photo');
    wppa_dbg_msg('pid=' . $pid . ', type=' . $type . ', alb=' . $alb . ', sep=' . $separate . ', slide=' . $slide . ', t_c=0, ph=' . $photo, 'green');
    // Open the breadcrumb box
    wppa_out('<div' . ' id="wppa-bc-' . wppa('mocc') . '"' . ' class="wppa-nav wppa-box wppa-nav-text" ' . 'style="' . __wcs('wppa-nav') . __wcs('wppa-box') . __wcs('wppa-nav-text') . '" >');
    // Do we need Home?
    if (wppa_switch('show_home')) {
        $value = __(wppa_opt('home_text'));
        $href = wppa_dbg_url(get_bloginfo('url'));
        $title = get_bloginfo('title');
        wppa_bcitem($value, $href, $title, 'b1');
    }
    // Page ( grand )parents ?
    if ($type == 'page' && wppa_switch('show_page')) {
        wppa_crumb_page_ancestors($pid);
    }
    // Do the post/page
    if (wppa_switch('show_page')) {
        $value = __(stripslashes($wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->posts . "` WHERE `post_status` = 'publish' AND `ID` = %s LIMIT 0,1", $pid))));
        wppa_dbg_q('Q-bc2');
        $href = $alb || $virtual || $is_albenum ? wppa_get_permalink($pid, true) : '';
        $title = $type == 'post' ? __('Post:', 'wp-photo-album-plus') . ' ' . $value : __('Page:', 'wp-photo-album-plus') . ' ' . $value;
        wppa_bcitem($value, $href, $title, 'b3');
    }
    // The album ( grand ) parents if not separate
    //		if ( ! $separate ) {
    wppa_crumb_ancestors($alb, $to_cover);
    //		}
    // The album and optional placeholder for photo
    // Supersearch ?
    if (wppa('supersearch')) {
        $value = ' ';
        $ss_data = explode(',', wppa('supersearch'));
        switch ($ss_data['0']) {
            case 'a':
                $value .= ' ' . __('Albums', 'wp-photo-album-plus');
                switch ($ss_data['1']) {
                    case 'c':
                        $value .= ' ' . __('with category:', 'wp-photo-album-plus');
                        break;
                    case 'n':
                        $value .= ' ' . __('with name:', 'wp-photo-album-plus');
                        break;
                    case 't':
                        $value .= ' ' . __('with words:', 'wp-photo-album-plus');
                        break;
                }
                $value .= ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                break;
            case 'p':
                $value .= ' ' . __('Photos', 'wp-photo-album-plus');
                switch ($ss_data['1']) {
                    case 'g':
                        $value .= ' ' . __('with tag:', 'wp-photo-album-plus') . ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                        break;
                    case 'n':
                        $value .= ' ' . __('with name:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 't':
                        $ss_data['3'] = str_replace('...', '***', $ss_data['3']);
                        $value .= ' ' . __('with words:', 'wp-photo-album-plus') . ' <b>' . str_replace('.', '</b> ' . __('and', 'wp-photo-album-plus') . ' <b>', $ss_data['3']) . '</b>';
                        $value = str_replace('***', '...', $value);
                        break;
                    case 'o':
                        $value .= ' ' . __('of owner:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 'i':
                        $label = $wpdb->get_var($wpdb->prepare("SELECT `description` FROM `" . WPPA_IPTC . "` WHERE `tag` = %s AND `photo` = '0'", str_replace('H', '#', $ss_data['2'])));
                        $label = trim($label, ':');
                        $value .= ' ' . __('with iptc tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                    case 'e':
                        $label = $wpdb->get_var($wpdb->prepare("SELECT `description` FROM `" . WPPA_EXIF . "` WHERE `tag` = %s AND `photo` = '0'", str_replace('H', '#', $ss_data['2'])));
                        $label = trim($label, ':');
                        $value .= ' ' . __('with exif tag:', 'wp-photo-album-plus') . ' <b>' . __($label, 'wp-photo-album-plus') . '</b> ' . __('with content:', 'wp-photo-album-plus') . ' <b>' . $ss_data['3'] . '</b>';
                        break;
                }
                break;
        }
        if (wppa('is_slide')) {
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-supersearch=' . stripslashes(wppa('supersearch'));
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-supersearch=' . stripslashes(wppa('supersearch'));
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('src') && !wppa('is_related')) {
        $searchroot = $wppa_session['search_root'];
        if (!$searchroot) {
            $searchroot = '-2';
            // To get 'All albums'
        }
        $albtxt = wppa('is_rootsearch') ? ' <span style="cursor:pointer;" title="' . esc_attr(sprintf(__('Searchresults from album %s and its subalbums', 'wp-photo-album-plus'), wppa_display_root($searchroot))) . '">*</span> ' : '';
        if (wppa('is_slide')) {
            $value = __('Searchstring:', 'wp-photo-album-plus') . ' ' . (isset($wppa_session['display_searchstring']) ? $wppa_session['display_searchstring'] : stripslashes(wppa('searchstring'))) . $albtxt;
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-searchstring=' . stripslashes(str_replace(' ', '+', $wppa_session['use_searchstring']));
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-searchstring=' . stripslashes(str_replace(' ', '+', $wppa_session['use_searchstring']));
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Searchstring:', 'wp-photo-album-plus') . ' ' . (isset($wppa_session['display_searchstring']) ? $wppa_session['display_searchstring'] : stripslashes(wppa('searchstring'))) . $albtxt;
        $href = '';
        $title = isset($wppa_session['display_searchstring']) ? wppa_dss_to_title($wppa_session['display_searchstring']) : '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('calendar')) {
        if (wppa('is_slide')) {
            switch (wppa('calendar')) {
                case 'exifdtm':
                    $value = __('Photos by EXIF date', 'wp-photo-album-plus') . ': ' . wppa('caldate');
                    break;
                case 'timestamp':
                    $value = __('Photos by date of upload', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                    break;
                case 'modified':
                    $value = __('Photos by date last modified', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                    break;
            }
            $thumbhref = '#';
            $title = 'T8';
            wppa_bcitem($value, $thumbhref, $title, 'b8');
        }
        switch (wppa('calendar')) {
            case 'exifdtm':
                $value = __('Photos by EXIF date', 'wp-photo-album-plus') . ': ' . wppa('caldate');
                break;
            case 'timestamp':
                $value = __('Photos by date of upload', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                break;
            case 'modified':
                $value = __('Photos by date last modified', 'wp-photo-album-plus') . ': ' . date('M d D Y', wppa('caldate') * 24 * 60 * 60);
                break;
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_upldr')) {
        $usr = get_user_by('login', wppa('is_upldr'));
        if ($usr) {
            $user = $usr->display_name;
        } else {
            $user = wppa('is_upldr');
        }
        if (wppa('is_slide')) {
            $value = sprintf(__('Photos by %s', 'wp-photo-album-plus'), $user);
            if (wppa('start_album')) {
                $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr') . '&amp;wppa-album=' . wppa('start_album');
                $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr') . '&amp;wppa-album=' . wppa('start_album');
            } else {
                $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr');
                $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-upldr=' . wppa('is_upldr');
            }
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = sprintf(__('Photos by %s', 'wp-photo-album-plus'), $user);
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_topten')) {
        // TopTen
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Top rated photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-topten=' . wppa('topten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-topten=' . wppa('topten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Top rated photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_lasten')) {
        // Lasten
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            if (wppa_switch('lasten_use_modified')) {
                $value = __('Recently modified photos', 'wp-photo-album-plus');
            } else {
                $value = __('Recently uploaded photos', 'wp-photo-album-plus');
            }
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-lasten=' . wppa('lasten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-lasten=' . wppa('lasten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        if (wppa_switch('lasten_use_modified')) {
            $value = __('Recently modified photos', 'wp-photo-album-plus');
        } else {
            $value = __('Recently uploaded photos', 'wp-photo-album-plus');
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_comten')) {
        // Comten
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Recently commented photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-comten=' . wppa('comten_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-comten=' . wppa('comten_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Recently commented photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_featen')) {
        // Featen
        if (wppa('start_album')) {
            $value = $is_albenum ? __('Various albums', 'wp-photo-album-plus') : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Featured photos', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-featen=' . wppa('featen_count') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-featen=' . wppa('featen_count') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Featured photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_related')) {
        // Related photos
        if (wppa('is_slide')) {
            $value = __('Related photos', 'wp-photo-album-plus');
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $href, $title, 'b8', $ajax);
        }
        $value = __('Related photos', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_tag')) {
        // Tagged photos
        if (wppa('is_slide')) {
            $value = __('Tagged photos:', 'wp-photo-album-plus') . '&nbsp;' . str_replace(';', ' ' . __('or', 'wp-photo-album-plus') . ' ', str_replace(',', ' ' . __('and', 'wp-photo-album-plus') . ' ', trim(wppa('is_tag'), ',;')));
            if (wppa_get_get('inv')) {
                $value .= ' (' . __('Inverted', 'wp-photo-album-plus') . ')';
            }
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-tag=' . wppa('is_tag') . '&amp;wppa-album=' . wppa('start_album');
            if (wppa('is_inverse')) {
                $thumbhref .= '&amp;wppa-inv=1';
                $thumbajax .= '&amp;wppa-inv=1';
            }
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Tagged photos:', 'wp-photo-album-plus') . '&nbsp;' . str_replace(';', ' ' . __('or', 'wp-photo-album-plus') . ' ', str_replace(',', ' ' . __('and', 'wp-photo-album-plus') . ' ', trim(wppa('is_tag'), ',;')));
        if (wppa_get_get('inv')) {
            $value .= ' (' . __('Inverted', 'wp-photo-album-plus') . ')';
        }
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('is_cat')) {
        // Categorized albums
        if (wppa('is_slide')) {
            $value = __('Category:', 'wp-photo-album-plus') . '&nbsp;' . wppa('is_cat');
            //str_replace( ';', ' '.__( 'or' ).' ', str_replace( ',', ' '.__( 'and' ).' ', trim( wppa( 'is_tag' ), ',;' ) ) );
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-cat=' . wppa('is_cat') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-cat=' . wppa('is_cat') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Category:', 'wp-photo-album-plus') . '&nbsp;' . wppa('is_cat');
        //str_replace( ';', ' '.__( 'or' ).' ', str_replace( ',', ' '.__( 'and' ).' ', trim( wppa( 'is_tag' ), ',;' ) ) );
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } elseif (wppa('last_albums')) {
        // Recently modified albums( s )
        if (wppa('last_albums_parent')) {
            $value = wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        if (wppa('is_slide')) {
            $value = __('Recently updated albums', 'wp-photo-album-plus');
            $thumbhref = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $thumbajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = __('View the thumbnails', 'wp-photo-album-plus');
            wppa_bcitem($value, $thumbhref, $title, 'b8', $thumbajax);
        }
        $value = __('Recently updated albums', 'wp-photo-album-plus');
        $href = '';
        $title = '';
        wppa_bcitem($value, $href, $title, 'b9');
    } else {
        // Maybe a simple normal standard album???
        if (wppa('is_owner')) {
            $usr = get_user_by('login', wppa('is_owner'));
            if ($usr) {
                $dispname = $usr->display_name;
            } else {
                $dispname = wppa('is_owner');
            }
            // User deleted
            $various = sprintf(__('Various albums by %s', 'wp-photo-album-plus'), $dispname);
        } else {
            $various = __('Various albums', 'wp-photo-album-plus');
        }
        if (wppa('is_slide')) {
            $value = $is_albenum ? $various : wppa_get_album_name($alb);
            $href = wppa_get_permalink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $ajax = wppa_get_ajaxlink() . 'wppa-cover=0&amp;wppa-occur=' . wppa('occur') . '&amp;wppa-album=' . wppa('start_album');
            $title = $is_albenum ? __('Albums:', 'wp-photo-album-plus') . ' ' . wppa('start_album') : __('Album:', 'wp-photo-album-plus') . ' ' . $value;
            wppa_bcitem($value, $href, $title, 'b7', $ajax);
        }
        $value = $is_albenum ? $various : wppa_get_album_name($alb);
        $href = '';
        $title = '';
        $class = 'b10';
        wppa_bcitem($value, $href, $title, $class);
    }
    // 'Go to thumbnail display' - icon
    if (wppa('is_slide') && !wppa('calendar')) {
        if (wppa_switch('bc_slide_thumblink')) {
            //				$pg = ( ( wppa_opt('thumb_page_size' ) == wppa_opt( 'slideshow_pagesize' ) ) && wppa_get_curpage() != '1' ) ? '&wppa-page='.wppa_get_curpage() : '';
            //				$thumbhref .= $pg;
            if ($virtual) {
                if ($thumbhref) {
                    $thumbhref = wppa_trim_wppa_($thumbhref);
                    $fs = wppa_opt('fontsize_nav');
                    if ($fs != '') {
                        $fs += 3;
                    } else {
                        $fs = '15';
                    }
                    // iconsize = fontsize+3, Default to 15
                    $imgs = 'height: ' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none;';
                    wppa_out('<a href="' . $thumbhref . '" title="' . __('Thumbnail view', 'wp-photo-album-plus') . '" class="wppa-nav-text" style="' . __wcs('wppa-nav-text') . 'float:right; cursor:pointer;" ' . 'onmouseover="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'none\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'\')" ' . 'onmouseout="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'none\')" >' . '<img id="wppa-tnv-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="' . $imgs . '" />' . '<img id="wppa-tnvh-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons_hover.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="display:none;' . $imgs . '" />' . '</a>');
                }
            } else {
                $s = wppa('src') ? '&wppa-searchstring=' . urlencode(wppa('searchstring')) : '';
                $onclick = "wppaDoAjaxRender( " . wppa('mocc') . ", '" . wppa_get_album_url_ajax(wppa('start_album'), '0') . "&amp;wppa-photos-only=1" . $s . "', '" . wppa_convert_to_pretty(wppa_get_album_url(wppa('start_album'), '0') . '&wppa-photos-only=1' . $s) . "' )";
                $fs = wppa_opt('fontsize_nav');
                if ($fs != '') {
                    $fs += 3;
                } else {
                    $fs = '15';
                }
                // iconsize = fontsize+3, Default to 15
                $imgs = 'height: ' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none;';
                wppa_out('<a title="' . __('Thumbnail view', 'wp-photo-album-plus') . '" class="wppa-nav-text" style="' . __wcs('wppa-nav-text') . 'float:right; cursor:pointer;" ' . 'onclick="' . $onclick . '" ' . 'onmouseover="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'none\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'\')" ' . 'onmouseout="jQuery(\'#wppa-tnv-' . wppa('mocc') . '\').css(\'display\', \'\'); jQuery(\'#wppa-tnvh-' . wppa('mocc') . '\').css(\'display\', \'none\')" >' . '<img id="wppa-tnv-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="' . $imgs . '" />' . '<img id="wppa-tnvh-' . wppa('mocc') . '" class="wppa-tnv" src="' . wppa_get_imgdir() . 'application_view_icons_hover.png" alt="' . __('Thumbs', 'wp-photo-album-plus') . '" style="display:none;' . $imgs . '" />' . '</a>');
            }
        }
    }
    // Close the breadcrumb box
    wppa_out('<div style="clear:both;" ></div>');
    wppa_out('</div>');
}
function wppa_albums($id = '', $type = '', $size = '', $align = '')
{
    global $wppa_lang;
    global $wppa_locale;
    global $wpdb;
    global $thumbs;
    global $wppa_session;
    // Diagnostics
    wppa_dbg_msg('Entering wppa_albums');
    wppa_dbg_msg('Lang=' . $wppa_lang . ', Locale=' . $wppa_locale . ', Ajax=' . wppa('ajax'));
    wppa_dbg_msg('$wppa_session = ' . serialize($wppa_session));
    // List content filters
    // Data struct:	$wp_filter[$tag][$priority][$idx] = array( 'function' => $function_to_add, 'accepted_args' => $accepted_args );
    if (wppa('debug') && wppa('mocc') == '0') {
        global $wp_filter;
        wppa_dbg_msg('Start content filters', 'green');
        foreach (array_keys($wp_filter['the_content']) as $key) {
            foreach (array_keys($wp_filter['the_content'][$key]) as $key2) {
                $func = is_array($wp_filter['the_content'][$key][$key2]['function']) ? serialize($wp_filter['the_content'][$key][$key2]['function']) : $wp_filter['the_content'][$key][$key2]['function'];
                wppa_dbg_msg('Pri:' . $key . ', func: ' . $func . ', args: ' . $wp_filter['the_content'][$key][$key2]['accepted_args']);
            }
        }
        wppa_dbg_msg('End content filters', 'green');
    }
    // Process a user upload request, if any. Do it here: it may affect this occurences display
    wppa_user_upload();
    // Test for scheduled publications
    wppa_publish_scheduled();
    // First calculate the occurance
    if (wppa('ajax')) {
        if (wppa_get_get('moccur')) {
            wppa('mocc', wppa_get_get('moccur'));
            if (!is_numeric(wppa('mocc'))) {
                wp_die('Security check failure 1');
            }
        } else {
            wppa('mocc', '1');
        }
        wppa('fullsize', wppa_get_get('wppa-size', wppa_get_container_width()));
        if (wppa_get_get('occur')) {
            wppa('occur', wppa_get_get('occur'));
            if (!is_numeric(wppa('occur'))) {
                wp_die('Security check failure 2');
            }
        }
        if (wppa_get_get('woccur')) {
            wppa('widget_occur', wppa_get_get('woccur'));
            wppa('in_widget', true);
            if (!is_numeric(wppa('widget_occur'))) {
                wp_die('Security check failure 3');
            }
        }
    } else {
        wppa('mocc', wppa('mocc') + '1');
        if (wppa_in_widget()) {
            wppa('widget_occur', wppa('widget_occur') + '1');
        } else {
            wppa('occur', wppa('occur') + '1');
        }
    }
    // Set wppa( 'src' ) = true and wppa( 'searchstring' ) if this occurrance processes a search request.
    wppa_test_for_search();
    // There are 3 ways to get here:
    // in order of priority:
    // 1. The given query string applies to this invocation ( occurrance )
    //    This invocation requires the ignorance of the filter results and the interpretation of the querystring.
    if ((wppa_get_get('occur') || wppa_get_get('woccur')) && (wppa_in_widget() && wppa('widget_occur') == wppa_get_get('woccur') || !wppa_in_widget() && wppa('occur') == wppa_get_get('occur')) && !wppa('is_autopage')) {
        // Process query string
        wppa_out(wppa_dbg_msg('Querystring applied', 'brown', false, true));
        wppa('start_album', wppa_get_get('album'));
        wppa('is_cover', wppa_get_get('cover'));
        wppa('is_slide', wppa_get_get('slide') || wppa_get_get('album') !== false && wppa_get_get('photo'));
        if (wppa('is_slide')) {
            wppa('start_photo', wppa_get_get('photo'));
            // Start a slideshow here
        } else {
            wppa('single_photo', wppa_get_get('photo'));
            // Photo is the single photoid
        }
        wppa('is_single', wppa_get_get('single'));
        // Is a one image slideshow
        wppa('topten_count', wppa_force_numeric_else(wppa_get_get('topten'), wppa_opt('topten_count')));
        wppa('is_topten', wppa('topten_count') != '0');
        wppa('lasten_count', wppa_force_numeric_else(wppa_get_get('lasten'), wppa_opt('lasten_count')));
        wppa('is_lasten', wppa('lasten_count') != '0');
        wppa('comten_count', wppa_force_numeric_else(wppa_get_get('comten'), wppa_opt('comten_count')));
        wppa('is_comten', wppa('comten_count') != '0');
        wppa('featen_count', wppa_force_numeric_else(wppa_get_get('featen'), wppa_opt('featen_count')));
        wppa('is_featen', wppa('featen_count') != '0');
        wppa('albums_only', wppa_get_get('albums-only'));
        wppa('photos_only', wppa_get_get('photos-only'));
        wppa('related_count', wppa_force_numeric_else(wppa_get_get('relcount'), wppa_opt('related_count')));
        wppa('is_related', wppa_get_get('rel'));
        if (wppa('is_related') == 'tags') {
            wppa('is_tag', wppa_get_related_data());
            if (wppa('related_count') == '0') {
                wppa('related_count', wppa_opt('related_count'));
            }
        } else {
            wppa('is_tag', trim(strip_tags(wppa_get_get('tag')), ',;'));
        }
        if (wppa('is_related') == 'desc') {
            wppa('src', true);
            if (wppa('related_count') == '0') {
                wppa('related_count', wppa_opt('related_count'));
            }
            wppa('searchstring', str_replace(';', ',', wppa_get_related_data()));
            wppa('photos_only', true);
        }
        if (wppa('is_tag')) {
            wppa_dbg_msg('Is Tag: ' . wppa('is_tag'));
        } else {
            wppa_dbg_msg('Is NOT Tag');
        }
        wppa('page', wppa_get_get('page'));
        if (wppa_get_get('superview')) {
            $wppa_session['superview'] = wppa('is_slide') ? 'slide' : 'thumbs';
            $wppa_session['superalbum'] = wppa('start_album');
            wppa_save_session();
            wppa('photos_only', true);
        }
        wppa('is_upldr', wppa_get_get('upldr'));
        if (wppa('is_upldr')) {
            wppa('photos_only', true);
        }
        wppa('is_owner', wppa_get_get('owner'));
        if (wppa('is_owner')) {
            $albs = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `owner` = %s ", wppa('is_owner')), ARRAY_A);
            wppa_dbg_q('Q-Main-1');
            wppa_cache_album('add', $albs);
            $id = '';
            if ($albs) {
                foreach ($albs as $alb) {
                    $id .= $alb['id'] . '.';
                }
            }
            $id = rtrim($id, '.');
            wppa('start_album', $id);
        }
        wppa('supersearch', strip_tags(wppa_get_get('supersearch')));
        $wppa_session['supersearch'] = wppa('supersearch');
        wppa_save_session();
        if (wppa('supersearch')) {
            $ss_info = explode(',', wppa('supersearch'));
            if ($ss_info['0'] == 'a') {
                wppa('albums_only', true);
            } else {
                wppa('photos_only', true);
            }
        }
        wppa('calendar', strip_tags(wppa_get_get('calendar')));
        wppa('caldate', strip_tags(wppa_get_get('caldate')));
        wppa('is_inverse', wppa_get_get('inv'));
    } elseif ($id != '' || $type != '' || $size != '' || $align != '') {
        // Do NOT Set internal defaults here, they may be set before the call
        // Interprete function args
        if ($type == 'album') {
        } elseif ($type == 'cover') {
            wppa('is_cover', true);
        } elseif ($type == 'slide') {
            wppa('is_slide', true);
        } elseif ($type == 'slideonly') {
            wppa('is_slideonly', true);
        }
        if ($type == 'photo' || $type == 'mphoto' || $type == 'slphoto') {
            // Any type of single photo? id given is photo id
            if ($id) {
                wppa('single_photo', $id);
            }
        } else {
            // Not single photo: id given is album id
            if ($id) {
                wppa('start_album', $id);
            }
        }
    } else {
        if (wppa('bestof')) {
            $args = wppa('bestof_args');
            wppa_bestof_box($args);
            $out = wppa('out');
            wppa_reset_occurrance();
            return $out;
        } elseif (wppa('is_landing') && !wppa('src')) {
            wppa_dbg_msg('Nothing to do...');
            wppa_reset_occurrance();
            return '';
            // Do nothing on a landing page without a querystring while it is also not a search operation
        } elseif (wppa('is_autopage')) {
            $photo = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . WPPA_PHOTOS . "` WHERE `page_id` = %d LIMIT 1", get_the_ID()));
            wppa('single_photo', $photo);
            wppa_dbg_q('Q-main-2');
            if (!wppa('single_photo')) {
                wppa_dbg_msg('No photo found for page ' . get_the_ID(), 'red', 'force');
                wppa_reset_occurrance();
                return '';
                // Give up
            }
            $type = wppa_opt('auto_page_type');
            switch ($type) {
                case 'photo':
                    break;
                case 'mphoto':
                    wppa('is_mphoto', true);
                    break;
                case 'slphoto':
                    wppa('is_slide', true);
                    wppa('start_photo', wppa('single_photo'));
                    wppa('is_single', true);
                    break;
                default:
                    wppa_dbg_msg('Unimplemented type autopage display: ' . $type, 'red', 'force');
            }
        }
    }
    // Convert any keywords and / or names to numbers
    // Search for album keyword
    if (wppa('start_album') && !wppa_is_int(wppa('start_album'))) {
        if (substr(wppa('start_album'), 0, 1) == '#') {
            // Keyword
            $keyword = wppa('start_album');
            if (strpos($keyword, ',')) {
                $keyword = substr($keyword, 0, strpos($keyword, ','));
            }
            switch ($keyword) {
                //	( substr( wppa( 'start_album'], 0, 5 ) ) {
                case '#last':
                    // Last upload
                    $id = wppa_get_youngest_album_id();
                    if (wppa('is_cover')) {
                        // To make sure the ordering sequence is ok.
                        $temp = explode(',', wppa('start_album'));
                        if (isset($temp['1'])) {
                            wppa('last_albums_parent', $temp['1']);
                        } else {
                            wppa('last_albums_parent', '0');
                        }
                        if (isset($temp['2'])) {
                            wppa('last_albums', $temp['2']);
                        } else {
                            wppa('last_albums', false);
                        }
                    } else {
                        // Ordering seq is not important, convert to album enum
                        $temp = explode(',', wppa('start_album'));
                        if (isset($temp['1'])) {
                            $parent = wppa_album_name_to_number($temp['1']);
                        } else {
                            $parent = '0';
                        }
                        if ($parent === false) {
                            return;
                        }
                        if (isset($temp['2'])) {
                            $limit = $temp['2'];
                        } else {
                            $limit = false;
                        }
                        if ($limit) {
                            if ($parent) {
                                if ($limit) {
                                    $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", $parent, $limit);
                                } else {
                                    $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s ORDER BY `timestamp` DESC", $parent);
                                }
                            } else {
                                if ($limit) {
                                    $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC LIMIT %d", $limit);
                                } else {
                                    $q = "SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC";
                                }
                            }
                            $albs = $wpdb->get_results($q, ARRAY_A);
                            wppa_dbg_q('Q-main-3');
                            wppa_cache_album('add', $albs);
                            if (is_array($albs)) {
                                foreach (array_keys($albs) as $key) {
                                    $albs[$key] = $albs[$key]['id'];
                                }
                            }
                            $id = implode('.', $albs);
                        }
                    }
                    break;
                case '#topten':
                    $temp = explode(',', wppa('start_album'));
                    $id = isset($temp[1]) ? $temp[1] : '0';
                    wppa('topten_count', isset($temp[2]) ? $temp[2] : wppa_opt('topten_count'));
                    wppa('is_topten', true);
                    if (wppa('is_cover')) {
                        wppa_dbg_msg('A topten album has no cover. ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Give up this occurence
                    }
                    break;
                case '#lasten':
                    $temp = explode(',', wppa('start_album'));
                    $id = isset($temp[1]) ? $temp[1] : '0';
                    wppa('lasten_count', isset($temp[2]) ? $temp[2] : wppa_opt('lasten_count'));
                    wppa('is_lasten', true);
                    if (wppa('is_cover')) {
                        wppa_dbg_msg('A lasten album has no cover. ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Give up this occurence
                    }
                    break;
                case '#comten':
                    $temp = explode(',', wppa('start_album'));
                    $id = isset($temp[1]) ? $temp[1] : '0';
                    wppa('comten_count', isset($temp[2]) ? $temp[2] : wppa_opt('comten_count'));
                    wppa('is_comten', true);
                    if (wppa('is_cover')) {
                        wppa_dbg_msg('A comten album has no cover. ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Give up this occurence
                    }
                    break;
                case '#featen':
                    $temp = explode(',', wppa('start_album'));
                    $id = isset($temp[1]) ? $temp[1] : '0';
                    wppa('featen_count', isset($temp[2]) ? $temp[2] : wppa_opt('featen_count'));
                    wppa('is_featen', true);
                    if (wppa('is_cover')) {
                        wppa_dbg_msg('A featen album has no cover. ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Give up this occurence
                    }
                    break;
                case '#related':
                    $temp = explode(',', wppa('start_album'));
                    $type = isset($temp[1]) ? $temp[1] : 'tags';
                    // tags is default type
                    wppa('related_count', isset($temp[2]) ? $temp[2] : wppa_opt('related_count'));
                    wppa('is_related', $type);
                    $data = wppa_get_related_data();
                    if ($type == 'tags') {
                        wppa('is_tag', $data);
                    }
                    if ($type == 'desc') {
                        wppa('src', true);
                        wppa('searchstring', str_replace(';', ',', $data));
                        wppa('photos_only', true);
                    }
                    wppa('photos_only', true);
                    $id = '0';
                    break;
                case '#tags':
                    wppa('is_tag', wppa_sanitize_tags(substr(wppa('start_album'), 6), true));
                    $id = '0';
                    wppa('photos_only', true);
                    break;
                case '#cat':
                    $temp = explode(',', wppa('start_album'));
                    $cat = isset($temp[1]) ? $temp[1] : '';
                    $cat = trim(wppa_sanitize_tags($cat), ',');
                    wppa('is_cat', $cat);
                    if (!$cat) {
                        wppa_dbg_msg('Missing cat #cat album spec: ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Forget this occurrance
                    }
                    $albs = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
                    wppa_dbg_q('Q-main-4');
                    wppa_cache_album('add', $albs);
                    $id = '';
                    if ($albs) {
                        foreach ($albs as $alb) {
                            $temp = explode(',', $alb['cats']);
                            if (in_array($cat, $temp)) {
                                $id .= $alb['id'] . '.';
                            }
                        }
                    }
                    $id = rtrim($id, '.');
                    break;
                case '#owner':
                    $temp = explode(',', wppa('start_album'));
                    $owner = isset($temp[1]) ? $temp[1] : '';
                    if ($owner == '#me') {
                        if (is_user_logged_in()) {
                            $owner = wppa_get_user();
                        } else {
                            // User not logged in, ignore shortcode
                            wppa_reset_occurrance();
                            return;
                            // Forget this occurrance
                        }
                    }
                    if (!$owner) {
                        wppa_dbg_msg('Missing owner in #owner album spec: ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Forget this occurrance
                    }
                    $parent = isset($temp[2]) ? wppa_album_name_to_number($temp[2]) : '0';
                    if ($parent === false) {
                        return;
                    }
                    if (!$parent) {
                        $parent = '-1.0';
                    }
                    if ($parent) {
                        // Valid parent spec
                        $parent_arr = explode('.', wppa_expand_enum($parent));
                        $id = wppa_alb_to_enum_children($parent);
                        // Verify all albums are owned by $owner and are directly under a parent album
                        $id = wppa_expand_enum($id);
                        $albs = explode('.', $id);
                        if ($albs) {
                            foreach (array_keys($albs) as $idx) {
                                if (wppa_get_album_item($albs[$idx], 'owner') != $owner || !in_array(wppa_get_album_item($albs[$idx], 'a_parent'), $parent_arr)) {
                                    unset($albs[$idx]);
                                }
                            }
                        }
                        $id = implode('.', $albs);
                        if (!$id) {
                            $id = '-9';
                            // Force nothing found
                            //				wppa_reset_occurrance();
                            //				return;	// No children found
                        }
                    }
                    wppa('is_owner', $owner);
                    break;
                case '#upldr':
                    $temp = explode(',', wppa('start_album'));
                    $owner = isset($temp[1]) ? $temp[1] : '';
                    if ($owner == '#me') {
                        if (is_user_logged_in()) {
                            $owner = wppa_get_user();
                        } else {
                            // User not logged in, ignore shortcode
                            wppa_reset_occurrance();
                            return;
                            // Forget this occurrance
                        }
                    }
                    if (!$owner) {
                        wppa_dbg_msg('Missing owner in #upldr album spec: ' . wppa('start_album'), 'red', 'force');
                        wppa_reset_occurrance();
                        return;
                        // Forget this occurrance
                    }
                    $parent = isset($temp[2]) ? wppa_album_name_to_number($temp[2]) : '0';
                    if ($parent === false) {
                        return;
                    }
                    // parent specified but not a valid value
                    if ($parent) {
                        // Valid parent spec
                        $id = wppa_alb_to_enum_children(wppa_expand_enum($parent));
                        if (!$id) {
                            wppa_reset_occurrance();
                            return;
                            // No children found
                        }
                    } else {
                        // No parent spec
                        $id = '0';
                    }
                    wppa('is_upldr', $owner);
                    wppa('photos_only', true);
                    break;
                case '#all':
                    $id = '-2';
                    break;
                default:
                    wppa_dbg_msg('Unrecognized album keyword found: ' . wppa('start_album'), 'red', 'force');
                    wppa_reset_occurrance();
                    return;
                    // Forget this occurrance
            }
            wppa('start_album', $id);
        }
    }
    // See if the album id is a name and convert it if possible
    wppa('start_album', wppa_album_name_to_number(wppa('start_album')));
    if (wppa('start_album') === false) {
        wppa_reset_occurrance();
        return;
    }
    // Also for parents
    wppa('last_albums_parent', wppa_album_name_to_number(wppa('last_albums_parent')));
    if (wppa('last_albums_parent') === false) {
        wppa_reset_occurrance();
        return;
    }
    // Check if album is valid
    if (strpos(wppa('start_album'), '.') !== false) {
        // Album may be enum
        if (!wppa_series_to_array(wppa('start_album'))) {
            // Syntax error
            wppa_reset_occurrance();
            return;
        }
    } elseif (wppa('start_album') && !is_numeric(wppa('start_album'))) {
        wppa_stx_err('Unrecognized Album identification found: ' . wppa('start_album'));
        wppa_reset_occurrance();
        return;
        // Forget this occurrance
    } elseif (wppa('start_album') > '0') {
        // -2 is #all
        if (!wppa_album_exists(wppa('start_album'))) {
            wppa_stx_err('Album does not exist: ' . wppa('start_album'));
            wppa_reset_occurrance();
            return;
            // Forget this occurrance
        }
    }
    // See if the photo id is a keyword and convert it if possible
    if (wppa('single_photo') && !is_numeric(wppa('single_photo'))) {
        if (substr(wppa('single_photo'), 0, 1) == '#') {
            // Keyword
            switch (wppa('single_photo')) {
                case '#potd':
                    // Photo of the day
                    $t = wppa_get_potd();
                    if (is_array($t)) {
                        $id = $t['id'];
                    } else {
                        $id = '0';
                    }
                    break;
                case '#last':
                    // Last upload
                    $id = wppa_get_youngest_photo_id();
                    break;
                default:
                    wppa_dbg_msg('Unrecognized photo keyword found: ' . wppa('single_photo'), 'red', 'force');
                    wppa_reset_occurrance();
                    return;
                    // Forget this occurrance
            }
            wppa('single_photo', $id);
        }
    }
    // See if the photo id is a name and convert it if possible
    if (wppa('single_photo') && !is_numeric(wppa('single_photo'))) {
        if (substr(wppa('single_photo'), 0, 1) == '$') {
            // Name
            $id = wppa_get_photo_id_by_name(substr(wppa('single_photo'), 1));
            if ($id > '0') {
                wppa('single_photo', $id);
            } else {
                wppa_dbg_msg('Photo name not found: ' . wppa('single_photo'), 'red', 'force');
                wppa_reset_occurrance();
                return;
                // Forget this occurrance
            }
        }
    }
    // Size and align
    if (is_numeric($size)) {
        wppa('fullsize', $size);
    } elseif ($size == 'auto') {
        wppa('auto_colwidth', true);
    }
    if ($align == 'left' || $align == 'center' || $align == 'right') {
        wppa('align', $align);
    }
    // Empty related shortcode?
    if (wppa('is_related')) {
        $thumbs = wppa_get_thumbs();
        if (empty($thumbs)) {
            wppa_errorbox(__('No related photos found.', 'wp-photo-album-plus'));
            $result = wppa('out');
            wppa_reset_occurrance();
            // Forget this occurrance
            return $result;
        }
    }
    // Subsearch or rootsearch?
    if (wppa('occur') == '1' && $wppa_session['has_searchbox'] && !wppa('in_widget')) {
        // Is it a search now?
        if (wppa('src')) {
            // Is the subsearch box checked?
            wppa('is_subsearch', wppa_get_get('subsearch') || wppa_get_post('subsearch'));
            // Is the rootsearch box checked?
            wppa('is_rootsearch', wppa_get_get('rootsearch') || wppa_get_post('rootsearch'));
            // No rootsearch, forget previous root
            if (!wppa('is_rootsearch')) {
                $wppa_session['search_root'] = '0';
                wppa_save_session();
            }
        } else {
            // Find new potential searchroot
            if (isset($_REQUEST['wppa-searchroot'])) {
                wppa('start_album', strval(intval($_REQUEST['wppa-searchroot'])));
            }
            // Update session with new searchroot
            $wppa_session['search_root'] = wppa('start_album');
            wppa_save_session();
        }
        // Update searchroot in search boxes
        $rt = $wppa_session['search_root'];
        if (!$rt) {
            $rt = '0';
        }
        // must be non-empty string
        wppa_add('src_script', 'jQuery(document).ready(function(){wppaUpdateSearchRoot( \'' . esc_js(wppa_display_root($rt)) . '\', ' . $rt . ' )});');
        // If not search forget previous results
        if (!wppa('src')) {
            $wppa_session['use_searchstring'] = '';
            $wppa_session['display_searchstring'] = '';
            wppa_save_session();
            wppa_add('src_script', "\n" . 'jQuery(document).ready(function(){wppaClearSubsearch()});');
        } else {
            // Enable subbox
            wppa_add('src_script', 'jQuery(document).ready(function(){wppaEnableSubsearch()});');
        }
    }
    // Is it url?
    if (wppa('is_url')) {
        if (wppa_photo_exists(wppa('single_photo'))) {
            wppa_out(wppa_get_hires_url(wppa('single_photo')));
        } else {
            wppa_dbg_msg(sprintf('Photo %s not found', wppa('single_photo')), 'red', 'force');
        }
    } elseif (wppa('is_stereobox')) {
        wppa_stereo_box();
    } elseif (wppa('is_searchbox')) {
        wppa_search_box('', wppa('may_sub'), wppa('may_root'));
    } elseif (wppa('is_superviewbox')) {
        wppa_superview_box(wppa('start_album'));
    } elseif (wppa('is_multitagbox')) {
        wppa_multitag_box(wppa('tagcols'), wppa('taglist'));
    } elseif (wppa('is_tagcloudbox')) {
        wppa_tagcloud_box(wppa('taglist'), wppa_opt('tagcloud_min'), wppa_opt('tagcloud_max'));
    } elseif (wppa('is_upload')) {
        wppa_upload_box();
    } elseif (wppa('is_supersearch')) {
        wppa_supersearch_box();
    } elseif (wppa('is_mphoto') == '1') {
        if (wppa('is_autopage')) {
            wppa_auto_page_links('top');
        }
        wppa_mphoto();
        if (wppa('is_autopage')) {
            wppa_auto_page_links('bottom');
        }
    } elseif (wppa_page('oneofone')) {
        if (wppa('is_autopage')) {
            wppa_auto_page_links('top');
        }
        wppa_sphoto();
        if (wppa('is_autopage')) {
            wppa_auto_page_links('bottom');
        }
    } elseif (wppa('is_calendar')) {
        wppa_calendar_box();
    } else {
        if (function_exists('wppa_theme')) {
            if (wppa('is_autopage')) {
                wppa_auto_page_links('top');
            }
            wppa_theme();
            // Call the theme module
            if (wppa('is_autopage')) {
                wppa_auto_page_links('bottom');
            }
        } else {
            wppa_out('<span style="color:red">ERROR: Missing function wppa_theme(), check the installation of WPPA+. Remove customized wppa_theme.php</span>');
        }
        global $wppa_version;
        $expected_version = '6-3-14-000';
        if ($wppa_version != $expected_version) {
            wppa_dbg_msg('WARNING: customized wppa-theme.php is out of rev. Expected version: ' . $expected_version . ' found: ' . $wppa_version, 'red');
        }
    }
    // Done
    $out = str_replace('w#location', wppa('geo'), wppa('out'));
    // Reset
    wppa_reset_occurrance();
    return $out;
}
Beispiel #3
0
function wppa_get_search_html($label = '', $sub = false, $rt = false)
{
    global $wppa_session;
    $wppa_session['has_searchbox'] = true;
    wppa_save_session();
    $page = wppa_get_the_landing_page('wppa_search_linkpage', __('Photo search results', 'wp-photo-album-plus'));
    $pagelink = wppa_dbg_url(get_page_link($page));
    $cansubsearch = $sub && $wppa_session['use_searchstring'];
    $value = $cansubsearch ? '' : wppa_test_for_search(true);
    $root = $wppa_session['search_root'];
    $rootboxset = $root ? '' : 'checked="checked" disabled="disabled"';
    $fontsize = wppa_in_widget() ? 'font-size: 9px;' : '';
    $mocc = wppa('mocc');
    if (!wppa_in_widget()) {
        $label = wppa_opt('search_toptext');
    }
    wppa_dbg_msg('Root=' . $root . ': ' . wppa_get_album_name($root));
    $result = '<form' . ' id="wppa_searchform_' . $mocc . '"' . ' action="' . $pagelink . '"' . ' method="post"' . ' class="widget_search"' . ' >' . '<div>' . $label . '<input' . ' type="text"' . ' class="wppa-search-input"' . ' style="width:60%;"' . ' name="wppa-searchstring"' . ' id="wppa_s-' . $mocc . '"' . ' value="' . $value . '"' . ' />' . '<input' . ' id="wppa_searchsubmit-' . $mocc . '"' . ' type="submit"' . ' name="wppa-search-submit"' . ' value="' . __('Search', 'wp-photo-album-plus') . '"' . ' onclick="if ( document.getElementById( \'wppa_s-' . $mocc . '\' ).value == \'\' ) return false;"' . ' />' . '<input' . ' type="hidden"' . ' name="wppa-searchroot"' . ' class="wppa-search-root-id"' . ' value="' . $root . '"' . ' />' . ($rt ? '<div style="clear:both" ></div>' . '<small class="wppa-search-root" style="margin:0;padding:4px 0 0;" >' . wppa_display_root($root) . '</small>' . '<div style="clear:both;' . $fontsize . '" >
					<input type="checkbox" name="wppa-rootsearch" class="wppa-rootbox" ' . $rootboxset . ' /> ' . wppa_opt('search_in_section') . '</div>' : '') . ($sub ? '<div style="clear:both" ></div>' . '<small class="wppa-display-searchstring" style="margin:0;padding:4px 0 0;" >' . $wppa_session['display_searchstring'] . '</small>' . '<div style="clear:both;' . $fontsize . '" >' . '<input' . ' type="checkbox"' . ' name="wppa-subsearch"' . ' class="wppa-search-sub-box"' . (empty($wppa_session['display_searchstring']) ? ' disabled="disabled"' : '') . ' onchange="wppaSubboxChange(this)"' . ' /> ' . wppa_opt('search_in_results') . '</div>' : '') . '</div>' . '</form>';
    return $result;
}