function wppa_get_album_count($id, $use_treecounts = false)
{
    global $wpdb;
    if ($use_treecounts && $id) {
        $treecounts = wppa_treecount_a($id);
        $count = $treecounts['selfalbums'];
    } else {
        $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM " . WPPA_ALBUMS . " WHERE a_parent=%s", $id));
    }
    return $count;
}
    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 ? '&raquo;' : '+') . '</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 ? '&raquo;' : '-') . '</div>';
                    } else {
                        $result .= '
							<div style="width:12px;float:left;" >&nbsp;' . ($a == $ca ? '&raquo;' : '') . '</div>';
                    }
                    $result .= '
							<a href="' . wppa_encrypt_url(wppa_get_permalink($page) . '&amp;wppa-album=' . $a . '&amp;wppa-cover=0&amp;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);
    }
Exemplo n.º 3
0
function wppa_treecount_a($alb)
{
    global $wpdb;
    global $wppa;
    $albums = '0';
    $photos = '1';
    $selfalbums = '3';
    $selfphotos = '4';
    $pendphotos = '5';
    $scheduledphotos = '6';
    // Initial fetch
    if (!isset($wppa['counts'])) {
        $wppa['counts'] = WPPA_MULTISITE_GLOBAL ? get_site_option('wppa_counts', array()) : get_option('wppa_counts', array());
    }
    if (!isset($wppa['treecounts'])) {
        $wppa['treecounts'] = WPPA_MULTISITE_GLOBAL ? get_site_option('wppa_counts_tree', array()) : get_option('wppa_counts_tree', array());
    }
    // See if we have this in cache
    if (isset($wppa['counts'][$alb]) && isset($wppa['treecounts'][$alb])) {
        // Album found
        $result['albums'] = $wppa['treecounts'][$alb][$albums];
        // Use data
        $result['photos'] = $wppa['treecounts'][$alb][$photos];
        $result['selfalbums'] = $wppa['counts'][$alb][$selfalbums];
        $result['selfphotos'] = $wppa['counts'][$alb][$selfphotos];
        $result['pendphotos'] = $wppa['counts'][$alb][$pendphotos];
        $result['scheduledphotos'] = $wppa['counts'][$alb][$scheduledphotos];
        return $result;
        // And return
    } else {
        $albs = $wpdb->get_results($wpdb->prepare("SELECT `id` FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $alb), ARRAY_A);
        $album_count = empty($albs) ? '0' : count($albs);
        $photo_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` <> 'pending' AND `status` <> 'scheduled'", $alb));
        $pend_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'pending'", $alb));
        $sched_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s AND `status` = 'scheduled'", $alb));
        // Result this level
        $result = array('albums' => $album_count, 'photos' => $photo_count, 'selfalbums' => $album_count, 'selfphotos' => $photo_count, 'pendphotos' => $pend_count, 'scheduledphotos' => $sched_count);
        // Subalbums to process?
        if (empty($albs)) {
        } else {
            foreach ($albs as $albm) {
                $subcount = wppa_treecount_a($albm['id']);
                $result['albums'] += $subcount['albums'];
                $result['photos'] += $subcount['photos'];
            }
        }
        // Save to cache
        $wppa['treecounts'][$alb][$albums] = $result['albums'];
        $wppa['treecounts'][$alb][$photos] = $result['photos'];
        $wppa['counts'][$alb][$selfalbums] = $result['selfalbums'];
        $wppa['counts'][$alb][$selfphotos] = $result['selfphotos'];
        $wppa['counts'][$alb][$pendphotos] = $result['pendphotos'];
        $wppa['counts'][$alb][$scheduledphotos] = $result['scheduledphotos'];
        $bret = WPPA_MULTISITE_GLOBAL ? update_site_option('wppa_counts', $wppa['counts']) : update_option('wppa_counts', $wppa['counts']);
        $bret = WPPA_MULTISITE_GLOBAL ? update_site_option('wppa_counts_tree', $wppa['treecounts']) : update_option('wppa_counts_tree', $wppa['treecounts']);
        return $result;
    }
}
function wppa_get_albums()
{
    global $wpdb;
    global $wppa_session;
    wppa_dbg_msg('get_albums entered: ' . wppa('mocc') . ' Start_album=' . wppa('start_album') . ', Cover=' . wppa('is_cover'));
    if (wppa('is_topten')) {
        return false;
    }
    if (wppa('is_lasten')) {
        return false;
    }
    if (wppa('is_comten')) {
        return false;
    }
    if (wppa('is_featen')) {
        return false;
    }
    if (wppa('is_tag')) {
        return false;
    }
    if (wppa('photos_only')) {
        return false;
    }
    if (wppa('src') && wppa_switch('photos_only')) {
        return false;
    }
    if (wppa('is_owner') && !wppa('start_album')) {
        return false;
    }
    // No owner album( s )
    if (wppa('calendar') == 'exifdtm') {
        return false;
    }
    if (wppa('calendar') == 'timestamp') {
        return false;
    }
    if (wppa('calendar') == 'modified') {
        return false;
    }
    // Supersearch?
    if (wppa('supersearch')) {
        $ss_data = explode(',', wppa('supersearch'));
        $data = $ss_data['3'];
        switch ($ss_data['1']) {
            // Category
            case 'c':
                $catlist = wppa_get_catlist();
                if (strpos($data, '.')) {
                    $temp = explode('.', $data);
                    $ids = $catlist[$temp['0']]['ids'];
                    $i = '1';
                    while ($i < count($temp)) {
                        $ids = array_intersect($ids, $catlist[$temp[$i]]['ids']);
                        $i++;
                    }
                } else {
                    $ids = $catlist[$data]['ids'];
                }
                if (empty($ids)) {
                    $ids = array('0');
                    // Dummy
                }
                $query = "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `id` IN (" . implode(',', $ids) . ")";
                $albums = $wpdb->get_results($query, ARRAY_A);
                wppa_dbg_q('Q_SS');
                break;
                // Name. Name is converted to number or enum
            // Name. Name is converted to number or enum
            case 'n':
                $query = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `name` = %s", $data);
                $albums = $wpdb->get_results($query, ARRAY_A);
                wppa_dbg_q('Q_SS');
                break;
                // Text
            // Text
            case 't':
                if (strpos($data, '.')) {
                    $temp = explode('.', $data);
                    $query = $wpdb->prepare("SELECT * FROM `" . WPPA_INDEX . "` WHERE `slug` = %s", $temp['0']);
                    $indexes = $wpdb->get_row($query, ARRAY_A);
                    wppa_dbg_q('Q_SS');
                    $ids = explode('.', wppa_expand_enum($indexes['albums']));
                    $i = '1';
                    while ($i < count($temp)) {
                        $query = $wpdb->prepare("SELECT * FROM `" . WPPA_INDEX . "` WHERE `slug` = %s", $temp[$i]);
                        $indexes = $wpdb->get_row($query, ARRAY_A);
                        wppa_dbg_q('Q_SS');
                        $ids = array_intersect($ids, explode('.', wppa_expand_enum($indexes['albums'])));
                        $i++;
                    }
                } else {
                    $query = $wpdb->prepare("SELECT * FROM `" . WPPA_INDEX . "` WHERE `slug` = %s", $data);
                    $indexes = $wpdb->get_row($query, ARRAY_A);
                    wppa_dbg_q('Q_SS');
                    $ids = explode('.', wppa_expand_enum($indexes['albums']));
                }
                if (empty($ids)) {
                    $ids = array('0');
                    // Dummy
                }
                $query = "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `id` IN (" . implode(',', $ids) . ")";
                $albums = $wpdb->get_results($query, ARRAY_A);
                wppa_dbg_q('Q_SS');
                break;
        }
    } elseif (wppa('src')) {
        $final_array = array();
        $chunks = explode(',', stripslashes(strtolower(wppa('searchstring'))));
        // all chunks
        foreach ($chunks as $chunk) {
            if (strlen(trim($chunk))) {
                $words = wppa_index_raw_to_words($chunk);
                $album_array = array();
                // all words in the searchstring
                foreach ($words as $word) {
                    $word = trim($word);
                    if (strlen($word) > 1) {
                        if (strlen($word) > 10) {
                            $word = substr($word, 0, 10);
                        }
                        if (wppa_switch('wild_front')) {
                            $aidxs = $wpdb->get_results("SELECT `slug`, `albums` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '%" . $word . "%'", ARRAY_A);
                        } else {
                            $aidxs = $wpdb->get_results("SELECT `slug`, `albums` FROM `" . WPPA_INDEX . "` WHERE `slug` LIKE '" . $word . "%'", ARRAY_A);
                        }
                        $albums = '';
                        if ($aidxs) {
                            foreach ($aidxs as $ai) {
                                $albums .= $ai['albums'] . ',';
                            }
                        }
                        $album_array[] = wppa_index_string_to_array(trim($albums, ','));
                    }
                }
                // Must meet all words: intersect photo sets
                foreach (array_keys($album_array) as $idx) {
                    if ($idx > '0') {
                        $album_array['0'] = array_intersect($album_array['0'], $album_array[$idx]);
                    }
                }
                // Save partial result
                if (isset($album_array['0'])) {
                    $final_array = array_merge($final_array, $album_array['0']);
                }
            }
        }
        // Compose WHERE clause
        $selection = " `id` = '0' ";
        foreach (array_keys($final_array) as $p) {
            $selection .= "OR `id` = '" . $final_array[$p] . "' ";
        }
        // Get them
        $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE " . $selection . " " . wppa_get_album_order('0'), ARRAY_A);
        wppa_dbg_q('Q10');
        // Exclusive separate albums?
        if (wppa_switch('excl_sep')) {
            foreach (array_keys($albums) as $idx) {
                if (wppa_is_separate($albums[$idx]['id'])) {
                    unset($albums[$idx]);
                }
            }
        }
        // Rootsearch?
        if (wppa('is_rootsearch')) {
            $root = $wppa_session['search_root'];
            if (is_array($albums)) {
                $c1 = count($albums);
                foreach (array_keys($albums) as $idx) {
                    if (!wppa_is_ancestor($root, $albums[$idx]['id'])) {
                        unset($albums[$idx]);
                    }
                }
                $c2 = count($albums);
                wppa_dbg_msg('Rootsearch albums:' . $c1 . ' -> ' . $c2);
            }
        }
        // Check maximum
        if (is_array($albums) && count($albums) > wppa_opt('max_search_albums') && wppa_opt('max_search_albums') != '0') {
            $alert_text = sprintf(__('There are %s albums found. Only the first %s will be shown. Please refine your search criteria.', 'wp-photo-album-plus'), count($albums), wppa_opt('max_search_albums'));
            wppa_alert($alert_text);
            foreach (array_keys($albums) as $idx) {
                if ($idx >= wppa_opt('max_search_albums')) {
                    unset($albums[$idx]);
                }
            }
        }
        if (is_array($albums)) {
            wppa('any', true);
        }
    } else {
        // Its not search
        $id = wppa('start_album');
        if (!$id) {
            $id = '0';
        }
        // Do the query
        if ($id == '-2') {
            // All albums
            if (wppa('is_cover')) {
                $q = "SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order();
                wppa_dbg_q('Q11d');
                $albums = $wpdb->get_results($q, ARRAY_A);
            } else {
                $albums = false;
            }
        } elseif (wppa('last_albums')) {
            // is_cover = true. For the order sequence, see remark in wppa_albums()
            if (wppa('last_albums_parent')) {
                $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s ORDER BY `timestamp` DESC LIMIT %d", wppa('last_albums_parent'), wppa('last_albums'));
            } else {
                $q = $wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC LIMIT %d", wppa('last_albums'));
            }
            wppa_dbg_q('Q11a');
            $albums = $wpdb->get_results($q, ARRAY_A);
        } elseif (wppa_is_int($id)) {
            if (wppa('is_cover')) {
                $q = $wpdb->prepare('SELECT * FROM ' . WPPA_ALBUMS . ' WHERE `id` = %s', $id);
            } else {
                $q = $wpdb->prepare('SELECT * FROM ' . WPPA_ALBUMS . ' WHERE `a_parent` = %s ' . wppa_get_album_order($id), $id);
            }
            wppa_dbg_q('Q11b');
            $albums = $wpdb->get_results($q, ARRAY_A);
            if (!wppa('is_cover')) {
                wppa_verify_treecounts($id, 'albums', count($albums));
            }
        } elseif (strpos($id, '.') !== false) {
            // Album enum
            $ids = wppa_series_to_array($id);
            if (wppa('is_cover')) {
                $q = "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `id` = " . implode(" OR `id` = ", $ids) . " " . wppa_get_album_order();
            } else {
                $q = "SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = " . implode(" OR `a_parent` = ", $ids) . " " . wppa_get_album_order();
            }
            wppa_dbg_q('Q11c');
            wppa_dbg_msg($q, 'red');
            $albums = $wpdb->get_results($q, ARRAY_A);
        } else {
            $albums = false;
        }
    }
    // Check for empty albums
    if (wppa_switch('skip_empty_albums')) {
        $user = wppa_get_user();
        if (is_array($albums)) {
            foreach (array_keys($albums) as $albumkey) {
                $albumid = $albums[$albumkey]['id'];
                $albumowner = $albums[$albumkey]['owner'];
                $treecount = wppa_treecount_a($albums[$albumkey]['id']);
                $photocount = $treecount['photos'];
                if (!$photocount && !wppa_user_is('administrator') && $user != $albumowner) {
                    unset($albums[$albumkey]);
                }
            }
        }
    }
    // Copy data into secondary cache
    if ($albums) {
        wppa_cache_album('add', $albums);
    }
    wppa('album_count', count($albums));
    return $albums;
}
Exemplo n.º 5
0
function wppa_get_supersearch_html()
{
    global $wpdb;
    global $wppa_session;
    // Init
    $page = wppa_get_the_landing_page('wppa_supersearch_linkpage', __('Photo search results', 'wp-photo-album-plus'));
    $pagelink = wppa_dbg_url(get_page_link($page));
    $fontsize = wppa_in_widget() ? 'font-size: 9px;' : '';
    $query = "SELECT `id`, `name`, `owner` FROM `" . WPPA_ALBUMS . "` ORDER BY `name`";
    $albums = $wpdb->get_results($query, ARRAY_A);
    $query = "SELECT `name` FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `name`";
    $photonames = $wpdb->get_results($query, ARRAY_A);
    $query = "SELECT `owner` FROM `" . WPPA_PHOTOS . "` WHERE `status` <> 'pending' AND `status` <> 'scheduled' ORDER BY `owner`";
    $ownerlist = $wpdb->get_results($query, ARRAY_A);
    $catlist = wppa_get_catlist();
    $taglist = wppa_get_taglist();
    $ss_data = explode(',', $wppa_session['supersearch']);
    if (count($ss_data) < '4') {
        $ss_data = array('', '', '', '');
    }
    $ss_cats = $ss_data['0'] == 'a' && $ss_data['1'] == 'c' ? explode('.', $ss_data['3']) : array();
    $ss_tags = $ss_data['0'] == 'p' && $ss_data['1'] == 'g' ? explode('.', $ss_data['3']) : array();
    $ss_data['3'] = str_replace('...', '***', $ss_data['3']);
    $ss_atxt = $ss_data['0'] == 'a' && $ss_data['1'] == 't' ? explode('.', $ss_data['3']) : array();
    foreach (array_keys($ss_atxt) as $key) {
        $ss_atxt[$key] = str_replace('***', '...', $ss_atxt[$key]);
    }
    $ss_ptxt = $ss_data['0'] == 'p' && $ss_data['1'] == 't' ? explode('.', $ss_data['3']) : array();
    foreach (array_keys($ss_ptxt) as $key) {
        $ss_ptxt[$key] = str_replace('***', '...', $ss_ptxt[$key]);
    }
    $ss_data['3'] = str_replace('***', '...', $ss_data['3']);
    $query = "SELECT `slug` FROM `" . WPPA_INDEX . "` WHERE `albums` <> '' ORDER BY `slug`";
    $albumtxt = $wpdb->get_results($query, ARRAY_A);
    $query = "SELECT `slug` FROM `" . WPPA_INDEX . "` WHERE `photos` <> '' ORDER BY `slug`";
    $phototxt = $wpdb->get_results($query, ARRAY_A);
    $iptclist = wppa_switch('save_iptc') ? $wpdb->get_results("SELECT `tag`, `description` FROM `" . WPPA_IPTC . "` WHERE `photo` = '0' AND `status` <> 'hide' ", ARRAY_A) : array();
    $exiflist = wppa_switch('save_exif') ? $wpdb->get_results("SELECT `tag`, `description` FROM `" . WPPA_EXIF . "` WHERE `photo` = '0' AND `status` <> 'hide' ", ARRAY_A) : array();
    // Check for empty albums
    if (wppa_switch('skip_empty_albums')) {
        $user = wppa_get_user();
        if (is_array($albums)) {
            foreach (array_keys($albums) as $albumkey) {
                $albumid = $albums[$albumkey]['id'];
                $albumowner = $albums[$albumkey]['owner'];
                $treecount = wppa_treecount_a($albums[$albumkey]['id']);
                $photocount = $treecount['photos'];
                if (!$photocount && !wppa_user_is('administrator') && $user != $albumowner) {
                    unset($albums[$albumkey]);
                }
            }
        }
    }
    if (empty($albums)) {
        $albums = array();
    }
    // Compress photonames if partial length search
    if (wppa_opt('ss_name_max')) {
        $maxl = wppa_opt('ss_name_max');
        $last = '';
        foreach (array_keys($photonames) as $key) {
            if (strlen($photonames[$key]['name']) > $maxl) {
                $photonames[$key]['name'] = substr($photonames[$key]['name'], 0, $maxl) . '...';
            }
            if ($photonames[$key]['name'] == $last) {
                unset($photonames[$key]);
            } else {
                $last = $photonames[$key]['name'];
            }
        }
    }
    // Compress phototxt if partial length search
    if (wppa_opt('ss_text_max')) {
        $maxl = wppa_opt('ss_text_max');
        $last = '';
        foreach (array_keys($phototxt) as $key) {
            if (strlen($phototxt[$key]['slug']) > $maxl) {
                $phototxt[$key]['slug'] = substr($phototxt[$key]['slug'], 0, $maxl) . '...';
            }
            if ($phototxt[$key]['slug'] == $last) {
                unset($phototxt[$key]);
            } else {
                $last = $phototxt[$key]['slug'];
            }
        }
    }
    // Remove dup photo owners
    $last = '';
    foreach (array_keys($ownerlist) as $key) {
        if ($ownerlist[$key]['owner'] == $last) {
            unset($ownerlist[$key]);
        } else {
            $last = $ownerlist[$key]['owner'];
        }
    }
    // Make the html
    $id = 'wppa_searchform_' . wppa('mocc');
    $result = '<form' . ' id="' . $id . '"' . ' action="' . $pagelink . '"' . ' method="post"' . ' class="widget_search"' . ' >' . '<input' . ' type="hidden"' . ' id="wppa-ss-pageurl-' . wppa('mocc') . '"' . ' name="wppa-ss-pageurl"' . ' value="' . $pagelink . '"' . ' />';
    // album or photo
    $id = 'wppa-ss-pa-' . wppa('mocc');
    $result .= '<select' . ' id="' . $id . '"' . ' name="wppa-ss-pa"' . ' style="margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="2"' . ' >' . '<option' . ' value="a" ' . ($ss_data['0'] == 'a' ? 'selected="selected" ' : '') . ' >' . __('Albums', 'wp-photo-album-plus') . '</option>' . '<option' . ' value="p" ' . ($ss_data['0'] == 'p' ? 'selected="selected" ' : '') . ' >' . __('Photos', 'wp-photo-album-plus') . '</option>' . '</select>';
    // album
    $id = 'wppa-ss-albumopt-' . wppa('mocc');
    $result .= '<select' . ' id="' . $id . '"' . ' name="wppa-ss-albumopt"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . (!empty($catlist) ? '3' : '2') . '"' . ' >' . (!empty($catlist) ? '<option' . ' value="c"' . ($ss_data['0'] == 'a' && $ss_data['1'] == 'c' ? 'selected="selected" ' : '') . ' >' . __('Category', 'wp-photo-album-plus') . '</option>' : '') . '<option' . ' value="n"' . ($ss_data['0'] == 'a' && $ss_data['1'] == 'n' ? 'selected="selected" ' : '') . ' >' . __('Name', 'wp-photo-album-plus') . '</option>' . '<option' . ' value="t"' . ($ss_data['0'] == 'a' && $ss_data['1'] == 't' ? 'selected="selected" ' : '') . ' >' . __('Text', 'wp-photo-album-plus') . '</option>' . '</select>';
    // album category
    if (!empty($catlist)) {
        $id = 'wppa-ss-albumcat-' . wppa('mocc');
        $result .= '<select' . ' id="' . $id . '"' . ' name="wppa-ss-albumcat"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($catlist), '6') . '"' . ' multiple' . ' title="' . esc_attr(__('CTRL+Click to add/remove option.', 'wp-photo-album-plus')) . "\n" . esc_attr(__('Items must meet all selected options.', 'wp-photo-album-plus')) . '"' . ' >';
        foreach (array_keys($catlist) as $cat) {
            $sel = in_array($cat, $ss_cats);
            $result .= '<option' . ' value="' . $cat . '"' . ' class="' . $id . '"' . ($sel ? ' selected="selected"' : '') . ' >' . $cat . '</option>';
        }
        $result .= '</select>';
    }
    // album name
    $id = 'wppa-ss-albumname-' . wppa('mocc');
    $result .= '<select' . ' id="' . $id . '"' . ' name="wppa-ss-albumname"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($albums), '6') . '"' . ' >';
    foreach ($albums as $album) {
        $name = stripslashes($album['name']);
        $sel = $ss_data['3'] == $name && $ss_data['0'] == 'a' && $ss_data['1'] == 'n';
        $result .= '<option' . ' value="' . esc_attr($name) . '"' . ($sel ? ' selected="selected"' : '') . ' >' . __($name) . '</option>';
    }
    $result .= '</select>';
    // album text
    $id = 'wppa-ss-albumtext-' . wppa('mocc');
    $result .= '
		<select' . ' id="' . $id . '"' . ' name="wppa-ss-albumtext"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($albumtxt), '6') . '"' . ' multiple="multiple"' . ' title="' . esc_attr(__('CTRL+Click to add/remove option.', 'wp-photo-album-plus')) . "\n" . esc_attr(__('Items must meet all selected options.', 'wp-photo-album-plus')) . '"' . ' >';
    foreach ($albumtxt as $txt) {
        $text = $txt['slug'];
        $sel = in_array($text, $ss_atxt);
        $result .= '<option' . ' value="' . $text . '"' . ' class="' . $id . '"' . ($sel ? ' selected="selected"' : '') . ' >' . $text . '</option>';
    }
    $result .= '
		</select>';
    // photo
    $n = '1' + (count($ownerlist) > '1') + !empty($taglist) + '1' + wppa_switch('save_iptc') + wppa_switch('save_exif');
    $result .= '
		<select' . ' id="wppa-ss-photoopt-' . wppa('mocc') . '"' . ' name="wppa-ss-photoopt"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . $n . '"' . ' >' . '<option' . ' value="n"' . ($ss_data['0'] == 'p' && $ss_data['1'] == 'n' ? 'selected="selected" ' : '') . ' >' . __('Name', 'wp-photo-album-plus') . '</option>';
    if (count($ownerlist) > '1') {
        $result .= '<option' . ' value="o"' . ($ss_data['0'] == 'p' && $ss_data['1'] == 'o' ? 'selected="selected" ' : '') . ' >' . __('Owner', 'wp-photo-album-plus') . '</option>';
    }
    if (!empty($taglist)) {
        $result .= '<option' . ' value="g"' . ($ss_data['0'] == 'p' && $ss_data['1'] == 'g' ? 'selected="selected" ' : '') . ' >' . __('Tag', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '<option' . ' value="t"' . ($ss_data['0'] == 'p' && $ss_data['1'] == 't' ? 'selected="selected" ' : '') . ' >' . __('Text', 'wp-photo-album-plus') . '</option>';
    if (wppa_switch('save_iptc')) {
        $result .= '<option' . ' value="i"' . ($ss_data['0'] == 'p' && $ss_data['1'] == 'i' ? 'selected="selected" ' : '') . ' >' . __('Iptc', 'wp-photo-album-plus') . '</option>';
    }
    if (wppa_switch('save_exif')) {
        $result .= '<option' . ' value="e"' . ($ss_data['0'] == 'p' && $ss_data['1'] == 'e' ? 'selected="selected" ' : '') . ' >' . __('Exif', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>';
    // photo name
    $id = 'wppa-ss-photoname-' . wppa('mocc');
    $result .= '
		<select' . ' id="' . $id . '"' . ' name="wppa-ss-photoname"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($photonames), '6') . '"' . ' >';
    foreach ($photonames as $photo) {
        $name = stripslashes($photo['name']);
        $sel = $ss_data['3'] == $name && $ss_data['0'] == 'p' && $ss_data['1'] == 'n';
        $result .= '<option' . ' value="' . esc_attr($name) . '"' . ($sel ? ' selected="selected"' : '') . ' >' . __($name) . '</option>';
    }
    $result .= '
		</select>';
    // photo owner
    $id = 'wppa-ss-photoowner-' . wppa('mocc');
    $result .= '
		<select' . ' id="' . $id . '"' . ' name="wppa-ss-photoowner"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($ownerlist), '6') . '"' . ' >';
    foreach ($ownerlist as $photo) {
        $owner = $photo['owner'];
        $sel = $ss_data['3'] == $owner && $ss_data['0'] == 'p' && $ss_data['1'] == 'o';
        $result .= '<option' . ' value="' . $owner . '"' . ($sel ? ' selected="selected"' : '') . ' >' . $owner . '</option>';
    }
    $result .= '
		</select>';
    // photo tag
    if (!empty($taglist)) {
        $id = 'wppa-ss-phototag-' . wppa('mocc');
        $result .= '
			<select' . ' id="' . $id . '"' . ' name="wppa-ss-phototag"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($taglist), '6') . '"' . ' multiple' . ' title="' . esc_attr(__('CTRL+Click to add/remove option.', 'wp-photo-album-plus')) . "\n" . esc_attr(__('Items must meet all selected options.', 'wp-photo-album-plus')) . '"' . ' >';
        foreach (array_keys($taglist) as $tag) {
            $sel = in_array($tag, $ss_tags);
            $result .= '<option' . ' value="' . $tag . '"' . ' class="' . $id . '"' . ($sel ? ' selected="selected"' : '') . ' >' . $tag . '</option>';
        }
        $result .= '</select>';
    }
    // photo text
    $id = 'wppa-ss-phototext-' . wppa('mocc');
    $result .= '
		<select' . ' id="' . $id . '"' . ' name="wppa-ss-phototext"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($phototxt), '6') . '"' . ' multiple="multiple"' . ' title="' . esc_attr(__('CTRL+Click to add/remove option.', 'wp-photo-album-plus')) . "\n" . esc_attr(__('Items must meet all selected options.', 'wp-photo-album-plus')) . '"' . ' >';
    foreach ($phototxt as $txt) {
        $text = $txt['slug'];
        $sel = in_array($text, $ss_ptxt);
        $result .= '<option' . ' value="' . $text . '"' . ' class="' . $id . '"' . ($sel ? ' selected="selected"' : '') . ' >' . $text . '</option>';
    }
    $result .= '</select>';
    // photo iptc
    $result .= '
		<select' . ' id="wppa-ss-photoiptc-' . wppa('mocc') . '"' . ' name="wppa-ss-photoiptc"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($iptclist), '6') . '"' . ' >';
    $reftag = str_replace('H', '#', $ss_data['2']);
    foreach ($iptclist as $item) {
        $tag = $item['tag'];
        $sel = $reftag == $tag && ($ss_data['0'] = 'p' && $ss_data['1'] == 'i');
        $result .= '<option' . ' value="' . $tag . '"' . ($sel ? ' selected="selected"' : '') . ' >' . __($item['description'], 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>';
    // Iptc items
    $result .= '
		<select' . ' id="wppa-ss-iptcopts-' . wppa('mocc') . '"' . ' name="wppa-ss-iptcopts"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' size="6"' . ' onchange="wppaSuperSearchSelect(' . wppa('mocc') . ')"' . ' >
		</select>';
    // photo exif
    $result .= '
		<select' . ' id="wppa-ss-photoexif-' . wppa('mocc') . '"' . ' name="wppa-ss-photoexif"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' onchange="wppaSuperSearchSelect( ' . wppa('mocc') . ' );"' . ' size="' . min(count($exiflist), '6') . '"' . ' >';
    $reftag = str_replace('H', '#', $ss_data['2']);
    foreach ($exiflist as $item) {
        $tag = $item['tag'];
        $sel = $reftag == $tag && ($ss_data['0'] = 'p' && $ss_data['1'] == 'e');
        $result .= '<option' . ' value="' . $tag . '"' . ($sel ? ' selected="selected"' : '') . ' >' . __($item['description'], 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>';
    // Exif items
    $result .= '
		<select' . ' id="wppa-ss-exifopts-' . wppa('mocc') . '"' . ' name="wppa-ss-exifopts"' . ' style="display:none;margin:2px;padding:0;vertical-align:top;"' . ' size="6"' . ' onchange="wppaSuperSearchSelect(' . wppa('mocc') . ')"' . ' >
		</select>';
    // The spinner
    $result .= '
		<img' . ' id="wppa-ss-spinner-' . wppa('mocc') . '"' . ' src="' . wppa_get_imgdir() . '/wpspin.gif' . '"' . ' style="margin:0 4px;display:none;"' . ' />';
    // The button
    $result .= '
		<input' . ' type="button"' . ' id="wppa-ss-button-' . wppa('mocc') . '"' . ' value="' . __('Submit', 'wp-photo-album-plus') . '"' . ' style="vertical-align:top;margin:2px;"' . ' onclick="wppaSuperSearchSelect(' . wppa('mocc') . ' , true)"' . ' ontouchstart="wppaSuperSearchSelect(' . wppa('mocc') . ' , true)"' . ' />';
    $result .= '
	</form>
	<script type="text/javascript" >
		wppaSuperSearchSelect(' . wppa('mocc') . ');
	</script>';
    return $result;
}
function wppa_album_cover_view_link($albumid, $has_content, $photocount, $albumcount, $mincount, $href_content, $target, $onclick_content)
{
    $album = wppa_cache_album($albumid);
    if (wppa_switch('show_viewlink')) {
        wppa_out('<div class="wppa-box-text wppa-black wppa-info wppa-viewlink">');
        if ($has_content) {
            // Fake photocount to prevent link to empty page
            if (wppa_opt('thumbtype') == 'none') {
                $photocount = '0';
            }
            // Still has content
            if ($photocount > $mincount || $albumcount) {
                // Get treecount data
                if (wppa_switch('show_treecount')) {
                    $treecount = wppa_treecount_a($albumid);
                } else {
                    $treecount = false;
                }
                if ($href_content == '#') {
                    wppa_out('<a onclick="' . $onclick_content . '" title="' . __('View the album', 'wp-photo-album-plus') . ' ' . esc_attr(stripslashes(__($album['name']))) . '" style="cursor:pointer;' . __wcs('wppa-box-text-nocolor') . '" >');
                } else {
                    wppa_out('<a href="' . $href_content . '" target="' . $target . '" onclick="' . $onclick_content . '" title="' . __('View the album', 'wp-photo-album-plus') . ' ' . esc_attr(stripslashes(__($album['name']))) . '" style="cursor:pointer;' . __wcs('wppa-box-text-nocolor') . '" >');
                }
                $text = __('View', 'wp-photo-album-plus');
                if ($albumcount) {
                    if ($albumcount == '1') {
                        $text .= ' 1 ' . __('album', 'wp-photo-album-plus');
                    } else {
                        $text .= ' ' . $albumcount . ' ' . __('albums', 'wp-photo-album-plus');
                    }
                    if ($treecount) {
                        if ($treecount['albums'] > $albumcount) {
                            $text .= ' (' . $treecount['albums'] . ')';
                        }
                    }
                }
                if ($photocount > $mincount && $albumcount) {
                    $text .= ' ' . __('and', 'wp-photo-album-plus');
                }
                if ($photocount > $mincount || $treecount) {
                    if ($photocount <= $mincount) {
                        $photocount = '0';
                    }
                    if ($photocount == '1') {
                        $text .= ' 1 ' . __('photo', 'wp-photo-album-plus');
                    } elseif ($photocount) {
                        $text .= ' ' . $photocount . ' ' . __('photos', 'wp-photo-album-plus');
                    }
                    if ($treecount) {
                        if ($treecount['photos'] > $photocount) {
                            if (!$photocount) {
                                $text .= ', ' . __('photos', 'wp-photo-album-plus');
                            }
                            $text .= ' (' . $treecount['photos'] . ')';
                        }
                    }
                }
                wppa_out(str_replace(' ', '&nbsp;', $text));
                wppa_out('</a>');
            }
        } else {
            wppa_out('&nbsp;');
        }
        wppa_out('</div>');
    }
}
Exemplo n.º 7
0
function wppa_shortcodes($xatts, $content = '')
{
    global $wppa;
    global $wppa_postid;
    global $wppa_api_version;
    global $wppa_revno;
    $atts = shortcode_atts(array('type' => 'generic', 'album' => '', 'photo' => '', 'size' => '', 'align' => '', 'taglist' => '', 'cols' => '', 'sub' => '', 'root' => '', 'calendar' => '', 'all' => '', 'reverse' => '', 'landing' => '', 'admin' => '', 'parent' => '', 'pcount' => '', 'acount' => ''), $xatts);
    // Find occur
    if (get_the_ID() != $wppa_postid) {
        // New post
        $wppa['occur'] = '0';
        // Init this occurance
        $wppa['fullsize'] = '';
        // Reset at each post
        $wppa_postid = get_the_ID();
        // Remember the post id
    }
    // Set internal defaults
    $wppa['start_album'] = '';
    $wppa['is_cover'] = '0';
    $wppa['is_slide'] = '0';
    $wppa['is_slideonly'] = '0';
    $wppa['is_filmonly'] = '0';
    $wppa['single_photo'] = '';
    $wppa['is_mphoto'] = '0';
    $wppa['film_on'] = '0';
    $wppa['is_landing'] = '0';
    $wppa['start_photo'] = '0';
    // Start a slideshow here
    $wppa['is_single'] = false;
    // Is a one image slideshow
    $wppa['is_upload'] = false;
    $wppa['is_multitagbox'] = false;
    $wppa['is_tagcloudbox'] = false;
    $wppa['taglist'] = '';
    $wppa['tagcols'] = '2';
    $wppa['is_autopage'] = false;
    $wppa['portrait_only'] = false;
    $wppa['shortcode_content'] = $content;
    $wppa['is_url'] = false;
    $wppa['forceroot'] = '';
    $wppa['landingpage'] = '';
    $wppa['is_admins_choice'] = false;
    $wppa['admins_choice_users'] = '';
    $wppa['albums_only'] = false;
    $wppa['max_width'] = false;
    // Find type
    switch ($atts['type']) {
        case 'version':
            return $wppa_api_version;
            break;
        case 'dbversion':
            return $wppa_revno;
            break;
        case 'landing':
            $wppa['is_landing'] = '1';
        case 'generic':
            break;
        case 'cover':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_cover'] = '1';
            $wppa['albums_only'] = true;
            break;
        case 'album':
        case 'content':
            $wppa['start_album'] = $atts['album'];
            break;
        case 'thumbs':
            $wppa['start_album'] = $atts['album'];
            $wppa['photos_only'] = true;
            break;
        case 'covers':
            $wppa['start_album'] = $atts['album'];
            $wppa['albums_only'] = true;
            break;
        case 'slide':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slide'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'slideonly':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slideonly'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'slideonlyf':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slideonly'] = '1';
            $wppa['film_on'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'slidef':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slide'] = '1';
            $wppa['film_on'] = '1';
        case 'filmonly':
            $wppa['start_album'] = $atts['album'];
            $wppa['is_slideonly'] = '1';
            $wppa['is_filmonly'] = '1';
            $wppa['film_on'] = '1';
            $wppa['start_photo'] = $atts['photo'];
            break;
        case 'photo':
        case 'sphoto':
            $wppa['single_photo'] = $atts['photo'];
            break;
        case 'mphoto':
            $wppa['single_photo'] = $atts['photo'];
            $wppa['is_mphoto'] = '1';
            break;
        case 'xphoto':
            $wppa['single_photo'] = $atts['photo'];
            $wppa['is_xphoto'] = '1';
            break;
        case 'slphoto':
            $wppa['is_slide'] = '1';
            $wppa['single_photo'] = $atts['photo'];
            $wppa['start_photo'] = $atts['photo'];
            $wppa['is_single'] = '1';
            break;
        case 'autopage':
            $wppa['is_autopage'] = '1';
            break;
        case 'upload':
            if ($atts['parent']) {
                $wppa['start_album'] = wppa_alb_to_enum_children($atts['parent']);
            } else {
                $wppa['start_album'] = $atts['album'];
            }
            $wppa['is_upload'] = true;
            break;
        case 'multitag':
            $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
            $wppa['is_multitagbox'] = true;
            if ($atts['cols']) {
                $wppa['tagcols'] = $atts['cols'];
            }
            break;
        case 'tagcloud':
            $wppa['taglist'] = wppa_sanitize_tags($atts['taglist']);
            $wppa['is_tagcloudbox'] = true;
            break;
        case 'bestof':
            $wppa['bestof'] = true;
            $wppa['bestof_args'] = $xatts;
            break;
        case 'superview':
            $wppa['is_superviewbox'] = true;
            $wppa['start_album'] = $atts['album'];
            break;
        case 'search':
            $wppa['is_searchbox'] = true;
            $wppa['may_sub'] = $atts['sub'];
            if ($atts['root']) {
                if (substr($atts['root'], 0, 1) == '#') {
                    $wppa['forceroot'] = strval(intval(substr($atts['root'], 1)));
                } else {
                    $wppa['may_root'] = $atts['root'];
                }
            }
            $wppa['landingpage'] = $atts['landing'];
            break;
        case 'supersearch':
            $wppa['is_supersearch'] = true;
            break;
        case 'calendar':
            if (!wppa_switch('allow_ajax')) {
                wppa_dbg_msg('Shortcode [wppa type="calendar" ...  requires Ajax acive. See Photo Albums -> Settings Table IV-A1.0', 'red', 'force');
                return '';
            }
            $wppa['is_calendar'] = true;
            $wppa['calendar'] = 'timestamp';
            if (in_array($atts['calendar'], array('exifdtm', 'timestamp', 'modified'))) {
                $wppa['calendar'] = $atts['calendar'];
            }
            if ($atts['all']) {
                $wppa['calendarall'] = true;
            }
            $wppa['reverse'] = $atts['reverse'];
            $wppa['start_album'] = $atts['album'];
            break;
        case 'stereo':
            $wppa['is_stereobox'] = true;
            break;
        case 'url':
            $wppa['is_url'] = true;
            $wppa['single_photo'] = $atts['photo'];
            break;
        case 'choice':
            $wppa['is_admins_choice'] = true;
            $wppa['admins_choice_users'] = $atts['admin'];
            break;
        case 'acount':
        case 'pcount':
            $a = strval(intval($atts['album']));
            $p = strval(intval($atts['parent']));
            $t = $atts['type'];
            if ($a xor $p) {
                $alb = $a ? $a : $p;
                $tc = wppa_treecount_a($alb);
                // Album based count requested
                if ($a) {
                    if ($t == 'acount') {
                        return wppa_get_album_count($alb, true);
                    } else {
                        return wppa_get_photo_count($alb, true);
                    }
                } else {
                    if ($t == 'acount') {
                        return $tc['albums'];
                    } else {
                        return $tc['photos'];
                    }
                }
            } else {
                wppa_dbg_msg('Error in shortcode spec for type="' . $atts['type'] . '": either attribute album="" or parent="" should supply a positive integer', 'red', 'force');
                return;
            }
            break;
        case 'share':
            $result = wppa_get_share_page_html();
            return $result;
            break;
        default:
            wppa_dbg_msg('Invalid type: ' . $atts['type'] . ' in wppa shortcode.', 'red', 'force');
            return '';
    }
    // Count (internally to wppa_albums)
    // Find size
    if ($atts['size'] && is_numeric($atts['size']) && $atts['size'] < 1.0) {
        $wppa['auto_colwidth'] = true;
        $wppa['fullsize'] = $atts['size'];
    } elseif (substr($atts['size'], 0, 4) == 'auto') {
        $wppa['auto_colwidth'] = true;
        $wppa['fullsize'] = '';
        $wppa['max_width'] = substr($atts['size'], 5);
    } else {
        $wppa['auto_colwidth'] = false;
        $wppa['fullsize'] = $atts['size'];
    }
    // Find align
    $wppa['align'] = $atts['align'];
    // Ready to render ???
    $do_it = false;
    if (wppa('rendering_enabled')) {
        $do_it = true;
    }
    // NOT in a head section (in a meta tag or so)
    if (wppa_in_widget()) {
        $do_it = true;
    }
    // A widget always works
    if (is_feed()) {
        $do_it = true;
    }
    // A feed has no head section
    if (wppa_switch('render_shortcode_always')) {
        $do_it = true;
    }
    // Always
    if (wppa('debug')) {
        if ($do_it) {
            $msg = 'Doit is on';
        } else {
            $msg = 'Doit is off';
        }
        wppa_dbg_msg($msg);
    }
    // Do it also for url only shortcode
    if ($do_it || $wppa['is_url']) {
        $result = wppa_albums();
        // Get the HTML
    } else {
        $result = '<span style="color:blue; font-weight:bold; ">[WPPA+ Photo display (fsh)]</span>';
        // Or an indicator
    }
    // Reset
    $wppa['start_photo'] = '0';
    // Start a slideshow here
    $wppa['is_single'] = false;
    // Is a one image slideshow
    // Relative urls?
    $result = wppa_make_relative($result);
    // In widget
    if (wppa_in_widget()) {
        if (!wppa_switch('shortcode_at_priority_widget')) {
            return $result;
        }
    } else {
        if (!wppa_switch('shortcode_at_priority')) {
            return $result;
        }
    }
    // Url always immediately
    if ($wppa['is_url']) {
        return $result;
    }
    // New method to prevent damage of the result by content filters that run on higher priorities than do_shortcode.
    // Previous methods, e.g. increasing the do_shortcode priority sometimes fail due to requirements of other plugins/shortcodes.
    // To prevent this, i first asked an enhancement to add a priority argument to add_shortcode(), but the wp boys simply say
    // 'this is not possible'. Everything is possible, they should say that they are not smart enough to implement it.
    // Since there are plans to set the do_shortcode() priority ( currently 11 ) lower than wpautop() ( 10 ), and there are many serious
    // bugs in wpautop() it is now urgent to create a monkey-proof solution to the problem that others destructify the so preciously created
    // shortcode process output.
    //
    // What we do is:
    // 1. Save the result in memory and return a placeholder for the result.
    // 2. Run a contentfilter on the highest possible priority that replaced the placeholder by the original result.
    //
    // It sounds simple, but it took me a few sleepless nights to figure out.
    // Here it goes:
    // Define storage for the results
    global $wppa_shortcode_results;
    // Create a key to identify the result.
    // Any unique key will do, as long as it is not tampered by any content filter.
    // Hopefully everything keeps an unadded shortcode untouched,
    // therefor we wrap the random key in square brackets
    $key = '[' . md5(rand()) . ']';
    // Store
    $wppa_shortcode_results[$key] = $result;
    // Return the placeholder ( = the key ) in stead of $result
    return $key;
}
function wppa_album_photos_bulk($album)
{
    global $wpdb;
    // Check input
    wppa_vfy_arg('wppa-page');
    // Init
    $count = '0';
    $abort = false;
    if (isset($_POST['wppa-bulk-action'])) {
        check_admin_referer('wppa-bulk', 'wppa-bulk');
        if (isset($_POST['wppa-bulk-photo'])) {
            $ids = $_POST['wppa-bulk-photo'];
            $newalb = isset($_POST['wppa-bulk-album']) ? $_POST['wppa-bulk-album'] : '0';
            $status = isset($_POST['wppa-bulk-status']) ? $_POST['wppa-bulk-status'] : '';
            $owner = isset($_POST['wppa-bulk-owner']) ? $_POST['wppa-bulk-owner'] : '';
            $totcount = count($ids);
            if (!is_numeric($newalb)) {
                wp_die('Security check failure 1');
            }
            if (is_array($ids)) {
                foreach (array_keys($ids) as $id) {
                    $skip = false;
                    switch ($_POST['wppa-bulk-action']) {
                        case 'wppa-bulk-delete':
                            wppa_delete_photo($id);
                            break;
                        case 'wppa-bulk-move-to':
                            if ($newalb) {
                                $photo = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $id), ARRAY_A);
                                if (wppa_switch('void_dups')) {
                                    // Check for already exists
                                    $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb));
                                    if ($exists) {
                                        // Already exists
                                        wppa_error_message(sprintf(__('A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photo['filename'], $newalb));
                                        $skip = true;
                                    }
                                }
                                if ($skip) {
                                    continue;
                                }
                                wppa_flush_treecounts($photo['album']);
                                // Current album
                                wppa_flush_treecounts($newalb);
                                // New album
                                $wpdb->query($wpdb->prepare('UPDATE `' . WPPA_PHOTOS . '` SET `album` = %s WHERE `id` = %s', $newalb, $id));
                                wppa_move_source($photo['filename'], $photo['album'], $newalb);
                            } else {
                                wppa_error_message('Unexpected error #4 in wppa_album_photos_bulk().');
                            }
                            break;
                        case 'wppa-bulk-copy-to':
                            if ($newalb) {
                                $photo = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . WPPA_PHOTOS . ' WHERE `id` = %s', $id), ARRAY_A);
                                if (wppa_switch('void_dups')) {
                                    // Check for already exists
                                    $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `filename` = %s AND `album` = %s", $photo['filename'], $newalb));
                                    if ($exists) {
                                        // Already exists
                                        wppa_error_message(sprintf(__($exists . 'A photo with filename %s already exists in album %s.', 'wp-photo-album-plus'), $photo['filename'], $newalb));
                                        $skip = true;
                                    }
                                }
                                if ($skip) {
                                    continue;
                                }
                                wppa_copy_photo($id, $newalb);
                                wppa_flush_treecounts($newalb);
                            } else {
                                wppa_error_message('Unexpected error #3 in wppa_album_photos_bulk().');
                            }
                            break;
                        case 'wppa-bulk-status':
                            if (!in_array($status, array('publish', 'pending', 'featured', 'scheduled', 'gold', 'silver', 'bronze', 'private'))) {
                                wppa_log('error', 'Unknown status ' . strip_tags($status) . ' found in wppa-photo-admin-autosave.php -> wppa_album_photos_bulk()');
                                $status = 'publish';
                            }
                            if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) {
                                if ($status == 'publish' || $status == 'pending' || wppa_user_is('administrator') || !wppa_switch('ext_status_restricted')) {
                                    $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `status` = '" . $status . "' WHERE `id` = " . $id);
                                    wppa_flush_treecounts($id, wppa_get_photo_item($id, 'album'));
                                } else {
                                    wp_die('Security check failure 2');
                                }
                            } else {
                                wp_die('Security check failure 3');
                            }
                            break;
                        case 'wppa-bulk-owner':
                            if (wppa_user_is('administrator') && wppa_switch('photo_owner_change')) {
                                if ($owner) {
                                    $owner = sanitize_user($owner);
                                    $exists = $wpdb->get_var("SELECT COUNT(*) FROM `" . $wpdb->users . "` WHERE `user_login` = '" . $owner . "'");
                                    if ($exists) {
                                        $wpdb->query("UPDATE `" . WPPA_PHOTOS . "` SET `owner` = '" . $owner . "' WHERE `id` = " . $id);
                                    } else {
                                        wppa_error_message('A user with login name ' . $owner . ' does not exist.');
                                        $skip = true;
                                    }
                                } else {
                                    wp_die('Missing required arg in bulk change owner');
                                }
                            } else {
                                wp_die('Security check failure 4');
                            }
                            break;
                        default:
                            wppa_error_message('Unimplemented bulk action requested in wppa_album_photos_bulk().');
                            break;
                    }
                    if (!$skip) {
                        $count++;
                    }
                    if (wppa_is_time_up()) {
                        wppa_error_message(sprintf(__('Time is out after processing %d out of %d items.', 'wp-photo-album-plus'), $count, $totcount));
                        $abort = true;
                    }
                    if ($abort) {
                        break;
                    }
                }
            } else {
                wppa_error_message('Unexpected error #2 in wppa_album_photos_bulk().');
            }
        } else {
            wppa_error_message('Unexpected error #1 in wppa_album_photos_bulk().');
        }
        if ($count && !$abort) {
            switch ($_POST['wppa-bulk-action']) {
                case 'wppa-bulk-delete':
                    $message = sprintf(__('%d photos deleted.', 'wp-photo-album-plus'), $count);
                    break;
                case 'wppa-bulk-move-to':
                    $message = sprintf(__('%1$s photos moved to album %2$s.', 'wp-photo-album-plus'), $count, $newalb . ': ' . wppa_get_album_name($newalb));
                    break;
                case 'wppa-bulk-copy-to':
                    $message = sprintf(__('%1$s photos copied to album %2$s.', 'wp-photo-album-plus'), $count, $newalb . ': ' . wppa_get_album_name($newalb));
                    break;
                case 'wppa-bulk-status':
                    $message = sprintf(__('Changed status to %1$s on %2$s photos.', 'wp-photo-album-plus'), $status, $count);
                    break;
                case 'wppa-bulk-owner':
                    $message = sprintf(__('Changed owner to %1$s on %2$s photos.', 'wp-photo-album-plus'), $owner, $count);
                    break;
                default:
                    $message = sprintf(__('%d photos processed.', 'wp-photo-album-plus'), $count);
                    break;
            }
            wppa_ok_message($message);
        }
    }
    $pagesize = wppa_opt('photo_admin_pagesize');
    $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1';
    $skip = ($page - '1') * $pagesize;
    $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize;
    if ($album) {
        if ($album == 'search') {
            $count = wppa_get_edit_search_photos('', 'count_only');
            $photos = wppa_get_edit_search_photos($limit);
            $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring']) . '&bulk');
            wppa_show_search_statistics();
        } else {
            $counts = wppa_treecount_a($album);
            $count = $counts['selfphotos'] + $counts['pendphotos'];
            //$wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM `'.WPPA_PHOTOS.'` WHERE `album` = %s', $album ) );
            $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A);
            $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&bulk');
        }
        if ($photos) {
            wppa_admin_page_links($page, $pagesize, $count, $link, '#manage-photos');
            ?>
			<script type="text/javascript" >
				function wppaBulkActionChange( elm, id ) {
					wppa_setCookie( 'wppa_bulk_action',elm.value,365 );
					if ( elm.value == 'wppa-bulk-move-to' || elm.value == 'wppa-bulk-copy-to' ) jQuery( '#wppa-bulk-album' ).css( 'display', 'inline' );
					else jQuery( '#wppa-bulk-album' ).css( 'display', 'none' );
					if ( elm.value == 'wppa-bulk-status' ) jQuery( '#wppa-bulk-status' ).css( 'display', 'inline' );
					else jQuery( '#wppa-bulk-status' ).css( 'display', 'none' );
					if ( elm.value == 'wppa-bulk-owner' ) jQuery( '#wppa-bulk-owner' ).css( 'display', 'inline' );
					else jQuery( '#wppa-bulk-owner' ).css( 'display', 'none' );
				}
				function wppaBulkDoitOnClick() {
					var photos = jQuery( '.wppa-bulk-photo' );
					var count=0;
					for ( i=0; i< photos.length; i++ ) {
						var photo = photos[i];
						if ( photo.checked ) count++;
					}
					if ( count == 0 ) {
						alert( 'No photos selected' );
						return false;
					}
					var action = document.getElementById( 'wppa-bulk-action' ).value;
					switch ( action ) {
						case '':
							alert( 'No action selected' );
							return false;
							break;
						case 'wppa-bulk-delete':
							break;
						case 'wppa-bulk-move-to':
						case 'wppa-bulk-copy-to':
							var album = document.getElementById( 'wppa-bulk-album' ).value;
							if ( album == 0 ) {
								alert( 'No album selected' );
								return false;
							}
							break;
						case 'wppa-bulk-status':
							var status = document.getElementById( 'wppa-bulk-status' ).value;
							if ( status == 0 ) {
								alert( 'No status selected' );
								return false;
							}
							break;
						case 'wppa-bulk-owner':
							var owner = documnet.getElementById( 'wppa-bulk-owner' ).value;
							if ( owner == 0 ) {
								alert( 'No new owner selected' );
								return false;
							}
							break;
						default:
							alert( 'Unimplemented action requested: '+action );
							return false;
							break;

					}
					return true;
				}
				function wppaSetThumbsize( elm ) {
					var thumbsize = elm.value;
					wppa_setCookie( 'wppa_bulk_thumbsize',thumbsize,365 );
					jQuery( '.wppa-bulk-thumb' ).css( 'max-width', thumbsize+'px' );
					jQuery( '.wppa-bulk-thumb' ).css( 'max-height', ( thumbsize/2 )+'px' );
					jQuery( '.wppa-bulk-dec' ).css( 'height', ( thumbsize/2 )+'px' );
				}
				jQuery( document ).ready( function() {
					var action = wppa_getCookie( 'wppa_bulk_action' );
					document.getElementById( 'wppa-bulk-action' ).value = action;
					if ( action == 'wppa-bulk-move-to' || action == 'wppa-bulk-copy-to' ) {
						jQuery( '#wppa-bulk-album' ).css( 'display','inline' );
						document.getElementById( 'wppa-bulk-album' ).value = wppa_getCookie( 'wppa_bulk_album' );
					}
					if ( action == 'wppa-bulk-status' ) {
						jQuery( '#wppa-bulk-status' ).css( 'display','inline' );
						document.getElementById( 'wppa-bulk-status' ).value = wppa_getCookie( 'wppa_bulk_status' );
					}
					if ( action == 'wppa-bulk-owner' ) {
						jQuery( '#wppa-bulk-owner' ).css( 'display','inline' );
						document.getElementById( 'wppa-bulk-owner' ).value = wppa_getCookie( 'wppa_bulk_owner' );
					}
				} );

			</script>
			<form action="<?php 
            echo $link . '&wppa-page=' . $page . '#manage-photos';
            ?>
" method="post" >
				<?php 
            wp_nonce_field('wppa-bulk', 'wppa-bulk');
            ?>
				<h3>
				<span style="font-weight:bold;" ><?php 
            _e('Bulk action:', 'wp-photo-album-plus');
            ?>
</span>
				<select id="wppa-bulk-action" name="wppa-bulk-action" onchange="wppaBulkActionChange( this, 'bulk-album' )" >
					<option value="" ></option>
					<option value="wppa-bulk-delete" ><?php 
            _e('Delete', 'wp-photo-album-plus');
            ?>
</option>
					<option value="wppa-bulk-move-to" ><?php 
            _e('Move to', 'wp-photo-album-plus');
            ?>
</option>
					<option value="wppa-bulk-copy-to" ><?php 
            _e('Copy to', 'wp-photo-album-plus');
            ?>
</option>
					<?php 
            if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) {
                ?>
						<option value="wppa-bulk-status" ><?php 
                _e('Set status to', 'wp-photo-album-plus');
                ?>
</option>
					<?php 
            }
            ?>
					<?php 
            if (wppa_user_is('administrator') && wppa_switch('photo_owner_change')) {
                ?>
						<option value="wppa-bulk-owner" ><?php 
                _e('Set owner to', 'wp-photo-album-plus');
                ?>
</option>
					<?php 
            }
            ?>
				</select>
				<select name="wppa-bulk-album" id="wppa-bulk-album" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_album',this.value,365 );" >
					<?php 
            echo wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $album, 'selected' => '0', 'addpleaseselect' => true));
            ?>
				</select>
				<select name="wppa-bulk-status" id="wppa-bulk-status" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_status',this.value,365 );" >
					<option value="" ><?php 
            _e('- select a status -', 'wp-photo-album-plus');
            ?>
</option>
					<option value="pending" ><?php 
            _e('Pending', 'wp-photo-album-plus');
            ?>
</option>
					<option value="publish" ><?php 
            _e('Publish', 'wp-photo-album-plus');
            ?>
</option>
					<?php 
            if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) {
                $dis = ' disabled';
            } else {
                $dis = '';
            }
            ?>
					<option value="featured"<?php 
            echo $dis;
            ?>
 ><?php 
            _e('Featured', 'wp-photo-album-plus');
            ?>
</option>
					<option value="gold" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Gold', 'wp-photo-album-plus');
            ?>
</option>
					<option value="silver" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Silver', 'wp-photo-album-plus');
            ?>
</option>
					<option value="bronze" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Bronze', 'wp-photo-album-plus');
            ?>
</option>
					<option value="scheduled" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Scheduled', 'wp-photo-album-plus');
            ?>
</option>
					<option value="private" <?php 
            echo $dis;
            ?>
 ><?php 
            _e('Private', 'wp-photo-album-plus');
            ?>
</option>
				</select>
				<!-- Owner -->
				<?php 
            $users = wppa_get_users();
            if (count($users)) {
                ?>
				<select name="wppa-bulk-owner" id="wppa-bulk-owner" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_owner',this.value,365 );">
					<option value="" ><?php 
                _e('- select an owner -', 'wp-photo-album-plus');
                ?>
</option>
					<?php 
                foreach ($users as $user) {
                    echo '<option value="' . $user['user_login'] . '" >' . $user['display_name'] . ' (' . $user['user_login'] . ')</option>';
                }
                ?>
				</select>
				<?php 
            } else {
                ?>
				<input name="wppa-bulk-owner" id="wppa-bulk-owner" style="display:none;" onchange="wppa_setCookie( 'wppa_bulk_owner',this.value,365 );" />
				<?php 
            }
            ?>
				<!-- Submit -->
				<input type="submit" onclick="return wppaBulkDoitOnClick()" class="button-primary" value="<?php 
            _e('Doit!', 'wp-photo-album-plus');
            ?>
" />
				<span style="font-family:sans-serif; font-size:12px; font-style:italic; font-weight:normal;" >
					<?php 
            _e('Pressing this button will reload the page after executing the selected action', 'wp-photo-album-plus');
            ?>
				</span>
				</h3>
				<table class="widefat" >
					<thead style="font-weight:bold;" >
						<td><input type="checkbox" class="wppa-bulk-photo" onchange="jQuery( '.wppa-bulk-photo' ).attr( 'checked', this.checked );" /></td>
						<td><?php 
            _e('ID', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Preview', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Name', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Description', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Status', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Owner', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Remark', 'wp-photo-album-plus');
            ?>
</td>
					</thead>
					<tbody>
						<?php 
            foreach ($photos as $photo) {
                ?>
						<?php 
                $id = $photo['id'];
                ?>
						<tr id="photoitem-<?php 
                echo $photo['id'];
                ?>
" >
							<!-- Checkbox -->
							<td>
								<input type="hidden" id="photo-nonce-<?php 
                echo $photo['id'];
                ?>
" value="<?php 
                echo wp_create_nonce('wppa_nonce_' . $photo['id']);
                ?>
" />
								<input type="checkbox" name="wppa-bulk-photo[<?php 
                echo $photo['id'];
                ?>
]" class="wppa-bulk-photo" />
							</td>
							<!-- ID and delete link -->
							<td><?php 
                echo $photo['id'];
                ?>
								<br /><a onclick="if ( confirm( '<?php 
                _e('Are you sure you want to delete this photo?', 'wp-photo-album-plus');
                ?>
' ) ) wppaAjaxDeletePhoto( <?php 
                echo $photo['id'];
                ?>
, '<td colspan=3 >', '</td>' )" style="color:red;font-weight:bold;"><?php 
                _e('Delete', 'wp-photo-album-plus');
                ?>
</a>
							</td>
							<!-- Preview -->
							<td style="min-width:240px; text-align:center;" >
							<?php 
                if (wppa_is_video($photo['id'])) {
                    ?>
								<a href="<?php 
                    echo str_replace('xxx', 'mp4', wppa_get_photo_url($photo['id']));
                    ?>
" target="_blank" title="Click to see fullsize" >
									<?php 
                    // Animating size changes of a video tag is not a good idea. It will rapidly screw up browser cache and cpu
                    ?>
									<?php 
                    echo wppa_get_video_html(array('id' => $id, 'height' => '60', 'controls' => false, 'tagid' => 'pa-id-' . $id, 'events' => ' onmouseover="jQuery( this ).css( \'height\', \'160\' )" onmouseout="jQuery( this ).css( \'height\', \'60\' )"', 'preload' => 'metadata', 'use_thumb' => true));
                    ?>
					<!--				<video preload="metadata" style="height:60px;" onmouseover="jQuery( this ).css( 'height', '160' )" onmouseout="jQuery( this ).css( 'height', '60' )" >
										<?php 
                    // echo wppa_get_video_body( $photo['id'] )
                    ?>
									</video>	-->
								</a>
							<?php 
                } else {
                    ?>
								<a href="<?php 
                    echo wppa_fix_poster_ext(wppa_get_photo_url($photo['id']), $photo['id']);
                    ?>
" target="_blank" title="Click to see fullsize" >
									<img class="wppa-bulk-thumb" src="<?php 
                    echo wppa_fix_poster_ext(wppa_get_thumb_url($photo['id']), $photo['id']);
                    ?>
" style="height:60px;" onmouseover="jQuery( this ).stop().animate( {height:120}, 100 )" onmouseout="jQuery( this ).stop().animate( {height:60}, 100 )" />
								</a>
							<?php 
                }
                ?>
							</td>
							<td style="width:25%;" >
								<input type="text" style="width:100%;" id="pname-<?php 
                echo $photo['id'];
                ?>
" onchange="wppaAjaxUpdatePhoto( <?php 
                echo $photo['id'];
                ?>
, 'name', this );" value="<?php 
                echo esc_attr(stripslashes($photo['name']));
                ?>
" />
								<?php 
                if (wppa_is_video($photo['id'])) {
                    echo '<br />' . wppa_get_videox($photo['id']) . ' x ' . wppa_get_videoy($photo['id']) . ' px.';
                } else {
                    $sp = wppa_get_source_path($photo['id']);
                    if (is_file($sp)) {
                        $ima = getimagesize($sp);
                        if (is_array($ima)) {
                            echo '<br />' . $ima['0'] . ' x ' . $ima['1'] . ' px.';
                        }
                    }
                }
                ?>
							</td>
							<!-- Description -->
							<td style="width:25%;" >
								<textarea class="wppa-bulk-dec" style="height:50px; width:100%" onchange="wppaAjaxUpdatePhoto( <?php 
                echo $photo['id'];
                ?>
, 'description', this )" ><?php 
                echo stripslashes($photo['description']);
                ?>
</textarea>
							</td>
							<!-- Status -->
							<td>
							<?php 
                if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) {
                    ?>
								<select id="status-<?php 
                    echo $photo['id'];
                    ?>
" onchange="wppaAjaxUpdatePhoto( <?php 
                    echo $photo['id'];
                    ?>
, 'status', this ); wppaPhotoStatusChange( <?php 
                    echo $photo['id'];
                    ?>
 ); ">
									<option value="pending" <?php 
                    if ($photo['status'] == 'pending') {
                        echo 'selected="selected"';
                    }
                    ?>
 ><?php 
                    _e('Pending', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="publish" <?php 
                    if ($photo['status'] == 'publish') {
                        echo 'selected="selected"';
                    }
                    ?>
 ><?php 
                    _e('Publish', 'wp-photo-album-plus');
                    ?>
</option>
									<?php 
                    if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) {
                        $dis = ' disabled';
                    } else {
                        $dis = '';
                    }
                    ?>
									<option value="featured" <?php 
                    if ($photo['status'] == 'featured') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Featured', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="gold" <?php 
                    if ($photo['status'] == 'gold') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Gold', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="silver" <?php 
                    if ($photo['status'] == 'silver') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Silver', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="bronze" <?php 
                    if ($photo['status'] == 'bronze') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Bronze', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="scheduled" <?php 
                    if ($photo['status'] == 'scheduled') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Scheduled', 'wp-photo-album-plus');
                    ?>
</option>
									<option value="private" <?php 
                    if ($photo['status'] == 'private') {
                        echo 'selected="selected"';
                    }
                    echo $dis;
                    ?>
 ><?php 
                    _e('Private', 'wp-photo-album-plus');
                    ?>
</option>
								</select>
							<?php 
                } else {
                    if ($photo['status'] == 'pending') {
                        _e('Pending', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'publish') {
                        _e('Publish', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'featured') {
                        e('Featured');
                    } elseif ($photo['status'] == 'gold') {
                        _e('Gold', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'silver') {
                        _e('Silver', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'bronze') {
                        _e('Bronze', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'scheduled') {
                        _e('Scheduled', 'wp-photo-album-plus');
                    } elseif ($photo['status'] == 'private') {
                        _e('Private', 'wp-photo-album-plus');
                    }
                }
                ?>
							</td>
							<!-- Owner -->
							<td>
								<?php 
                echo $photo['owner'];
                ?>
							</td>
							<!-- Remark -->
							<td id="photostatus-<?php 
                echo $photo['id'];
                ?>
" style="width:25%;" >
								<?php 
                _e('Not modified', 'wp-photo-album-plus');
                ?>
								<script type="text/javascript">wppaPhotoStatusChange( <?php 
                echo $photo['id'];
                ?>
 )</script>
							</td>
						</tr>
						<?php 
            }
            ?>
					</tbody>
					<tfoot style="font-weight:bold;" >
						<td><input type="checkbox" class="wppa-bulk-photo" onchange="jQuery( '.wppa-bulk-photo' ).attr( 'checked', this.checked );" /></td>
						<td><?php 
            _e('ID', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Preview', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Name', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Description', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Status', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Owner', 'wp-photo-album-plus');
            ?>
</td>
						<td><?php 
            _e('Remark', 'wp-photo-album-plus');
            ?>
</td>
					</tfoot>
				</table>
			</form>
			<?php 
            wppa_admin_page_links($page, $pagesize, $count, $link);
        } else {
            if ($page == '1') {
                if (isset($_REQUEST['wppa-searchstring'])) {
                    echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>';
                } else {
                    echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>';
                }
            } else {
                $page_1 = $page - '1';
                echo sprintf(__('Page %d is empty, try <a href="%s" >page %d</a>.', 'wp-photo-album-plus'), $page, $link . '&wppa-page=' . $page_1 . '#manage-photos', $page_1);
            }
        }
    } else {
        wppa_dbg_msg('Missing required argument in wppa_album_photos() 2', 'red', 'force');
    }
}
Exemplo n.º 9
0
function wppa_album_cover_view_link($albumid, $has_content, $photocount, $albumcount, $mincount, $href_content, $target, $onclick_content)
{
    global $wppa;
    $album = wppa_cache_album($albumid);
    if (wppa_switch('wppa_show_viewlink')) {
        $wppa['out'] .= wppa_nltab('+') . '<div class="wppa-box-text wppa-black wppa-info wppa-viewlink">';
        if ($has_content) {
            // Fake photocount to prevent link to empty page
            if (wppa_opt('wppa_thumbtype') == 'none') {
                $photocount = '0';
            }
            // Still has content
            if ($photocount > $mincount || $albumcount) {
                // Get treecount data
                if (wppa_switch('wppa_show_treecount')) {
                    $treecount = wppa_treecount_a($albumid);
                } else {
                    $treecount = false;
                }
                if ($href_content == '#') {
                    $wppa['out'] .= wppa_nltab('+') . '<a onclick="' . $onclick_content . '" title="' . __a('View the album') . ' ' . esc_attr(stripslashes(wppa_qtrans($album['name']))) . '" style="' . __wcs('wppa-box-text-nocolor') . '" >';
                } else {
                    $wppa['out'] .= wppa_nltab('+') . '<a href="' . $href_content . '" target="' . $target . '" onclick="' . $onclick_content . '" title="' . __a('View the album') . ' ' . esc_attr(stripslashes(wppa_qtrans($album['name']))) . '" style="' . __wcs('wppa-box-text-nocolor') . '" >';
                }
                /**/
                $text = __a('View');
                if ($albumcount) {
                    if ($albumcount == '1') {
                        $text .= ' 1 ' . __a('album');
                    } else {
                        $text .= ' ' . $albumcount . ' ' . __a('albums');
                    }
                    if ($treecount) {
                        if ($treecount['albums'] > $albumcount) {
                            $text .= ' (' . $treecount['albums'] . ')';
                        }
                    }
                }
                if ($photocount > $mincount && $albumcount) {
                    $text .= ' ' . __a('and');
                }
                if ($photocount > $mincount || $treecount) {
                    if ($photocount <= $mincount) {
                        $photocount = '0';
                    }
                    if ($photocount == '1') {
                        $text .= ' 1 ' . __a('photo');
                    } elseif ($photocount) {
                        $text .= ' ' . $photocount . ' ' . __a('photos');
                    }
                    if ($treecount) {
                        if ($treecount['photos'] > $photocount) {
                            if (!$photocount) {
                                $text .= ', ' . __a('photos');
                            }
                            $text .= ' (' . $treecount['photos'] . ')';
                        }
                    }
                }
                $wppa['out'] .= str_replace(' ', '&nbsp;', $text);
                /**/
                $wppa['out'] .= wppa_nltab('-') . '</a>';
            }
        } else {
            $wppa['out'] .= '&nbsp;';
        }
        $wppa['out'] .= wppa_nltab('-') . '</div>';
    }
}
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&amp;tab=edit&amp;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 . '&amp;quick';
                    ?>
" class="wppaedit"><?php 
                    _e('Quick', 'wp-photo-album-plus');
                    ?>
</a></td>
								<td><a href="<?php 
                    echo $url . '&amp;bulk#manage-photos';
                    ?>
" class="wppaedit"><?php 
                    _e('Bulk', 'wp-photo-album-plus');
                    ?>
</a></td>
								<td><a href="<?php 
                    echo $url . '&amp;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&amp;tab=edit&amp;edit_id=new&amp;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);
                }
            }
        }
    }
}
function wppa_the_album_title($alb, $href_title, $onclick_title, $title, $target)
{
    $album = wppa_cache_album($alb);
    wppa_out('<h2 class="wppa-title" style="clear:none; ' . __wcs('wppa-title') . '">');
    if ($href_title) {
        if ($href_title == '#') {
            wppa_out('<a onclick="' . $onclick_title . '" title="' . $title . '" class="wppa-title" style="cursor:pointer; ' . __wcs('wppa-title') . '">' . wppa_get_album_name($alb) . '</a>');
        } else {
            wppa_out('<a href="' . $href_title . '" target="' . $target . '" onclick="' . $onclick_title . '" title="' . $title . '" class="wppa-title" style="' . __wcs('wppa-title') . '">' . wppa_get_album_name($alb) . '</a>');
        }
    } else {
        wppa_out(wppa_get_album_name($alb));
    }
    // Photo count?
    if (wppa_opt('count_on_title') != '-none-') {
        if (wppa_opt('count_on_title') == 'self') {
            $cnt = wppa_get_photo_count($alb);
        }
        if (wppa_opt('count_on_title') == 'total') {
            $temp = wppa_treecount_a($alb);
            $cnt = $temp['photos'];
            if (current_user_can('wppa_moderate')) {
                $cnt += $temp['pendphotos'];
            }
        }
        if ($cnt) {
            wppa_out(' <span class="wppa-cover-pcount" >(' . $cnt . ')</span>');
        }
    }
    $fsize = '12';
    if (wppa_is_album_new($alb)) {
        $type = 'new';
    } elseif (wppa_is_album_modified($alb)) {
        $type = 'mod';
    } else {
        $type = '';
    }
    $do_image = !wppa_switch('new_mod_label_is_text');
    if ($type) {
        if ($do_image) {
            wppa_out('<img' . ' src="' . wppa_opt($type . '_label_url') . '"' . ' title="' . __('New!', 'wp-photo-album-plus') . '"' . ' class="wppa-albumnew"' . ' style="border:none;margin:0;padding:0;box-shadow:none;"' . ' alt="' . __('New', 'wp-photo-album-plus') . '"' . ' />');
        } else {
            wppa_out(' <span' . ' style="' . 'display:inline;' . 'box-sizing:border-box;' . 'font-size:' . $fsize . 'px;' . 'line-height:' . $fsize . 'px;' . 'font-family:\'Arial Black\', Gadget, sans-serif;' . 'border-radius:4px;' . 'border-width:2px;' . 'border-style:solid;' . wppa_get_text_medal_color_style($type, '2') . '"' . ' >' . '&nbsp;' . __(wppa_opt($type . '_label_text')) . '&nbsp;' . '</span>');
        }
    }
    wppa_out('</h2>');
}