function wppa_make_tinymce_dialog()
{
    global $wpdb;
    // Prepare albuminfo
    $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC", ARRAY_A);
    if (wppa_switch('hier_albsel')) {
        $albums = wppa_add_paths($albums);
        $albums = wppa_array_sort($albums, 'name');
    }
    // Prepare photoinfo
    $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A);
    // Get Tags/cats
    $tags = wppa_get_taglist();
    $cats = wppa_get_catlist();
    // Make the html
    $result = '<div id="wppagallery-form">' . '<style type="text/css">' . '#wppagallery-table tr, #wppagallery-table th, #wppagallery-table td {' . 'padding: 2px; 0;' . '}' . '</style>' . '<table id="wppagallery-table" class="form-table">' . '<tr >' . '<th><label for="wppagallery-top-type">' . __('Type of WPPA display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-top-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a display type', 'wp-photo-album-plus') . ' --</option>' . '<option value="galerytype" style="color:#070" >' . __('A gallery with covers and/or thumbnails', 'wp-photo-album-plus') . '</option>' . '<option value="slidestype" style="color:#070" >' . __('A slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="singletype" style="color:#070" >' . __('A single image', 'wp-photo-album-plus') . '</option>' . '<option value="searchtype" style="color:#070" >' . __('A search/selection box', 'wp-photo-album-plus') . '</option>' . '<option value="misceltype" style="color:#070" >' . __('An other box type', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-galery-type-tr" style="display:none;" >' . '<th><label for="wppagallery-galery-type">' . __('Type of gallery display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-galery-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a gallery type', 'wp-photo-album-plus') . ' --</option>' . '<option value="cover" style="color:#070" >' . __('The cover(s) of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="content" style="color:#070" >' . __('The content of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="covers" style="color:#070" >' . __('The covers of the subalbums of specific album(s)', 'wp-photo-album-plus') . '</option>' . '<option value="thumbs" style="color:#070" >' . __('The thumbnails of specific album(s)', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-slides-type-tr" style="display:none;" >' . '<th><label for="wppagallery-slides-type">' . __('Type of slideshow:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-slides-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a slideshow type', 'wp-photo-album-plus') . ' --</option>' . '<option value="slide" style="color:#070" >' . __('A fully featured slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="slideonly" style="color:#070" >' . __('A slideshow without supporting boxes', 'wp-photo-album-plus') . '</option>' . '<option value="slideonlyf" style="color:#070" >' . __('A slideshow with a filmstrip only', 'wp-photo-album-plus') . '</option>' . '<option value="filmonly" style="color:#070" >' . __('A filmstrip only', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-single-type-tr" style="display:none;" >' . '<th><label for="wppagallery-single-type">' . __('Type of single image:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-single-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a single image type', 'wp-photo-album-plus') . ' --</option>' . '<option value="photo" style="color:#070" >' . __('A plain single photo', 'wp-photo-album-plus') . '</option>' . '<option value="mphoto" style="color:#070" >' . __('A single photo with caption', 'wp-photo-album-plus') . '</option>' . '<option value="slphoto" style="color:#070" >' . __('A single photo in the style of a slideshow', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-search-type-tr" style="display:none;" >' . '<th><label for="wppagallery-search-type">' . __('Type of search:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-search-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a search type', 'wp-photo-album-plus') . ' --</option>' . '<option value="search" style="color:#070" >' . __('A search box', 'wp-photo-album-plus') . '</option>' . '<option value="supersearch" style="color:#070" >' . __('A supersearch box', 'wp-photo-album-plus') . '</option>' . '<option value="tagcloud" style="color:#070" >' . __('A tagcloud box', 'wp-photo-album-plus') . '</option>' . '<option value="multitag" style="color:#070" >' . __('A multitag box', 'wp-photo-album-plus') . '</option>' . '<option value="superview" style="color:#070" >' . __('A superview box', 'wp-photo-album-plus') . '</option>' . '<option value="calendar" style="color:#070" >' . __('A calendar box', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-miscel-type-tr" style="display:none;" >' . '<th><label for="wppagallery-miscel-type">' . __('Type miscellaneous:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-miscel-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a miscellaneous display', 'wp-photo-album-plus') . ' --</option>' . '<option value="generic">' . __('A generic albums display', 'wp-photo-album-plus') . '</option>' . '<option value="upload">' . __('An upload box', 'wp-photo-album-plus') . '</option>' . '<option value="landing">' . __('A landing page shortcode', 'wp-photo-album-plus') . '</option>' . '<option value="stereo">' . __('A 3D stereo settings box', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-type-tr" style="display:none;" >' . '<th><label for="wppagallery-album-type">' . __('Kind of selection:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-type" name="type" onchange="wppaGalleryEvaluate()">' . '<option value="" selected="selected" disabled="disabled" style="color:#700" >-- ' . __('Please select a type of selection to be used', 'wp-photo-album-plus') . ' --</option>' . '<option value="real">' . __('One or more wppa+ albums', 'wp-photo-album-plus') . '</option>' . '<option value="virtual">' . __('A special selection', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-virt-tr" style="display:none;" >' . '<th><label for="wppagallery-album-virt">' . __('The selection to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-virt" name="album" class="wppagallery-album" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a virtual album', 'wp-photo-album-plus') . ' --</option>' . '<option value="#last" >' . __('The most recently modified album', 'wp-photo-album-plus') . '</option>' . '<option value="#topten" >' . __('The top rated photos', 'wp-photo-album-plus') . '</option>' . '<option value="#lasten" >' . __('The most recently uploaded photos', 'wp-photo-album-plus') . '</option>' . '<option value="#featen" >' . __('A random selection of featured photos', 'wp-photo-album-plus') . '</option>' . '<option value="#comten" >' . __('The most recently commented photos', 'wp-photo-album-plus') . '</option>' . '<option value="#tags" >' . __('Photos that have certain tags', 'wp-photo-album-plus') . '</option>' . '<option value="#cat" >' . __('Albums tagged with a certain category', 'wp-photo-album-plus') . '</option>' . '<option value="#owner" >' . __('Photos in albums owned by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#upldr" >' . __('Photos uploaded by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#all" >' . __('All photos in the system', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-virt-cover-tr" style="display:none;" >' . '<th><label for="wppagallery-album-virt-cover">' . __('The selection to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-virt-cover" name="album" class="wppagallery-album" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a virtual album', 'wp-photo-album-plus') . ' --</option>' . '<option value="#last" >' . __('The most recently modified album', 'wp-photo-album-plus') . '</option>' . '<option value="#owner" >' . __('Albums owned by a certain user', 'wp-photo-album-plus') . '</option>' . '<option value="#cat" >' . __('Albums tagged with a certain category', 'wp-photo-album-plus') . '</option>' . '<option value="#all" >' . __('All albums in the system', 'wp-photo-album-plus') . '</option>' . '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-real-tr" style="display:none;" >' . '<th><label for="wppagallery-album-real">' . __('The Album(s) to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-real" style="max-width:400px;" name="album" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option id="wppagallery-album-0" value="0" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select one or more albums', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album-r" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-realopt-tr" style="display:none;" >' . '<th><label for="wppagallery-album-realopt">' . __('The Album(s) to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-realopt" style="max-width:400px;" name="album" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option id="wppagallery-album-0" class="wppagallery-album-ropt" value="0" selected="selected" style="color:#070" >-- ' . __('All albums', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album-ropt" style="color:#070" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-owner-tr" style="display:none" >' . '<th><label for="wppagallery-owner">' . __('The album owner:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-owner" name="owner" class="wppagallery-owner" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a user', 'wp-photo-album-plus') . ' --</option>' . '<option value="#me" >-- ' . __('The logged in visitor', 'wp-photo-album-plus') . ' --</option>';
    $users = wppa_get_users();
    if ($users) {
        foreach ($users as $user) {
            $result .= '<option value="' . $user['user_login'] . '" >' . $user['display_name'] . '</option>';
        }
    } else {
        // Too many
        $result .= '<option value="xxx" >-- ' . __('Too many users, edit manually', 'wp-photo-album-plus') . ' --</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-owner-parent-tr" style="display:none;" >' . '<th><label for="wppagallery-owner-parent">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-owner-parent" style="color:#070;max-width:400px;" name="parentalbum" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option value="" selected="selected" >-- ' . __('No parent specification', 'wp-photo-album-plus') . ' --</option>';
        // Generic
        $result .= '<option value="0" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album-p" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-parent-tr" style="display:none;" >' . '<th><label for="wppagallery-album-parent">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-parent-parent" style="color:#070;max-width:400px;" name="parentalbum" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option id="wppagallery-album-0" value="0" selected="selected" style="color:#700" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-count-tr" style="display:none;" >' . '<th><label for="wppagallery-album-count">' . __('Max Albums:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-album-count" type="text" style="color:#070;" value="1" onchange="wppaGalleryEvaluate()" />' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-count-tr" style="display:none;" >' . '<th><label for="wppagallery-photo-count">' . __('Max Photos:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-photo-count" type="text" style="color:#070;" value="1" onchange="wppaGalleryEvaluate()" />' . '</td>' . '</tr>' . '<tr id="wppagallery-albumcat-tr" style="display:none;" >' . '<th><label for="wppagallery-albumcat">' . __('The cat the albums should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-albumcat" style="color:#700;" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >' . __('--- please select category ---', 'wp-photo-album-plus') . '</option>';
    if ($cats) {
        foreach (array_keys($cats) as $cat) {
            $result .= '<option value="' . $cat . '" >' . $cat . '</option>';
        }
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-tr" style="display:none;" >' . '<th><label for="wppagallery-photo" class="wppagallery-photo" >' . __('The Photo to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-photo" name="photo" class="wppagallery-photo" onchange="wppaGalleryEvaluate()" >';
    if ($photos) {
        // Please select
        $result .= '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select a photo', 'wp-photo-album-plus') . ' --</option>';
        // Most recent 100 photos
        foreach ($photos as $photo) {
            $name = stripslashes(__($photo['name'], 'wp-photo-album-plus'));
            if (strlen($name) > '50') {
                $name = substr($name, '0', '50') . '...';
            }
            if (get_option('wppa_file_system') == 'flat') {
                $result .= '<option value="' . wppa_fix_poster_ext($photo['id'] . '.' . $photo['ext'], $photo['id']) . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            } else {
                $result .= '<option value="' . wppa_fix_poster_ext(wppa_expand_id($photo['id']) . '.' . $photo['ext'], $photo['id']) . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            }
        }
        $result .= '<option value="#last" >-- ' . __('The most recently uploaded photo', 'wp-photo-album-plus') . ' --</option>' . '<option value="#potd" >-- ' . __('The photo of the day', 'wp-photo-album-plus') . ' --</option>';
    } else {
        $result .= '<option value="0" >' . __('There are no photos yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '<br />' . '<small style="display:none;" class="wppagallery-photo" >' . __('Specify the photo to be used', 'wp-photo-album-plus') . '<br />' . __('You can select from a maximum of 100 most recently added photos', 'wp-photo-album-plus') . '<br />' . '</small>' . '</td>' . '</tr>' . '<tr id="wppagallery-photo-preview-tr" style="display:none;" >' . '<th><label for="wppagallery-photo-preview" >' . __('Preview image:', 'wp-photo-album-plus') . '</label></th>' . '<td id="wppagallery-photo-preview" style="text-align:center;" >' . '</td >' . '</tr>' . '<tr id="wppagallery-phototags-tr" style="display:none;" >' . '<th><label for="wppagallery-phototags">' . __('The tags the photos should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-phototags" style="color:#700;" multiple="multiple" onchange="wppaGalleryEvaluate()">' . '<option value="" disabled="disabled" selected="selected" style="color:#700" >' . __('--- please select tag(s) ---', 'wp-photo-album-plus') . '</option>';
    if ($tags) {
        foreach (array_keys($tags) as $tag) {
            $result .= '<option class="wppagallery-phototags" value="' . $tag . '" >' . $tag . '</option>';
        }
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-search-tr" style="display:none;" >' . '<th><label>' . __('Additional features:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-sub" type="checkbox" name="sub" onchange="wppaGalleryEvaluate()"/>' . __('Enable Subsearch', 'wp-photo-album-plus') . '&nbsp;' . '<input id="wppagallery-root" type="checkbox" name="root" onchange="wppaGalleryEvaluate()"/>' . __('Enable Rootsearch', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr id="wppagallery-taglist-tr" style="display:none;" >' . '<th><label>' . __('Additional features:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input id="wppagallery-alltags" type="checkbox" checked="checked" name="alltags" onchange="wppaGalleryEvaluate()"/>' . __('Enable all tags', 'wp-photo-album-plus') . '&nbsp;' . '<select id="wppagallery-seltags" style="color:#070; display:none;" name="seltags" multiple="multiple" onchange="wppaGalleryEvaluate()">';
    if ($tags) {
        '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('Please select the tags to show', 'wp-photo-album-plus') . ' --</option>';
        foreach (array_keys($tags) as $tag) {
            $result .= '<option class="wppagallery-taglist-tags" value="' . $tag . '"style="color:#700" >' . $tag . '</option>';
        }
    } else {
        '<option value="" disabled="disabled" selected="selected" style="color:#700" >-- ' . __('There are no tags', 'wp-photo-album-plus') . ' --</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-album-super-tr" style="display:none;" >' . '<th><label for="wppagallery-album-super">' . __('Parent album:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album-super-parent" style="color:#070;max-width:400px;" name="parentalbum" onchange="wppaGalleryEvaluate()">';
    if ($albums) {
        // Please select
        $result .= '<option value="" selected="selected" style="color:#700" >-- ' . __('The generic parent', 'wp-photo-album-plus') . ' --</option>';
        // All standard albums
        foreach ($albums as $album) {
            $id = $album['id'];
            $result .= '<option class="wppagallery-album" value="' . $id . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $id . ')</option>';
        }
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '</td>' . '</tr>' . '<tr id="wppagallery-calendar-tr" style="display:none;" >' . '<th><label for="wppagallery-calendar">' . __('Calendar type:', 'wp-photo-album-plus') . '</lable></th>' . '<td>' . '<select id="wppagallery-calendar-type" style="color:#070;max-width:400px;" onchange="wppaGalleryEvaluate()" >' . '<option value="exifdtm" >' . __('By EXIF date', 'wp-photo-album-plus') . '</option>' . '<option value="timestamp" >' . __('By date of upload', 'wp-photo-album-plus') . '</option>' . '<option value="modified" >' . __('By date last modified', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<input type="checkbox" id="wppagallery-calendar-reverse" onchange="wppaGalleryEvaluate()" >' . __('Last date first', 'wp-photo-album-plus') . '&nbsp;&nbsp;' . '<input type="checkbox" id="wppagallery-calendar-allopen" onchange="wppaGalleryEvaluate()" >' . __('Initially display all', 'wppw', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-size">' . __('The size of the display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input type="text" id="wppagallery-size" value="" style="color:#070;" onchange="wppaGalleryEvaluate();"/>' . '<br />' . '<small>' . __('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus') . ' ' . __('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus') . '<br />' . __('Leave this blank for default size', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-align">' . __('Horizontal alignment:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-align" name="align" style="color:#070;" onchange="wppaGalleryEvaluate();">' . '<option value="none" >' . __('--- none ---', 'wp-photo-album-plus') . '</option>' . '<option value="left" >' . __('left', 'wp-photo-album-plus') . '</option>' . '<option value="center" >' . __('center', 'wp-photo-album-plus') . '</option>' . '<option value="right" >' . __('right', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the alignment to be used or --- none ---', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '</table>' . '<div id="wppagallery-shortcode-preview-container" >' . '<input type="text" id="wppagallery-shortcode-preview" style="background-color:#ddd; width:100%; height:26px;" value="[wppa]Any comment[/wppa]" />' . '</div>' . '<div><small>' . __('This is a preview of the shortcode that is being generated. You may edit the comment', 'wp-photo-album-plus') . '</small></div>' . '<p class="submit">' . '<input type="button" id="wppagallery-submit" class="button-primary" value="' . __('Insert Gallery', 'wp-photo-album-plus') . '" name="submit" />&nbsp;' . '<input type="button" id="wppagallery-submit-notok" class="button-secundary" value="' . __('insert Gallery', 'wp-photo-album-plus') . '" onclick="alert(\'' . esc_js(__('Please complete the shortcode specs', 'wp-photo-album-plus')) . '\')" />&nbsp;' . '</p>' . '</div>' . '<script type="text/javascript" >wppaGalleryEvaluate();</script>';
    return $result;
}
function wppa_make_tinymce_dialog()
{
    global $wpdb;
    $result = '<div id="wppagallery-form">' . '<div style="height:158px; background-color:#eee; overflow:auto; margin-top:10px;" >' . '<div id="wppagallery-album-preview" style="text-align:center;font-size:48px; line-height:21px; color:#fff;" class="wppagallery-album" ><br /><br /><br />' . __('Album Preview', 'wp-photo-album-plus') . '<br /><span style="font-size:12px; color:#777" ><br/>' . __('A maximum of 100 photos can be previewd', 'wp-photo-album-plus') . '</span></div>' . '<div id="wppagallery-photo-preview" style="text-align:center;font-size:48px; line-height:21px; color:#fff; display:none;" class="wppagallery-photo" ><br /><br /><br />' . __('Photo Preview', 'wp-photo-album-plus') . '</div>' . '</div>' . '<table id="wppagallery-table" class="form-table">' . '<tr>' . '<th><label for="wppagallery-type">' . __('Type of Gallery display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-type" name="type" onchange="wppaGalleryTypeChange(this.value)">' . '<option value="cover">' . __('The cover of an album', 'wp-photo-album-plus') . '</option>' . '<option value="album">' . __('The sub-albums and/or thumbnails in an album', 'wp-photo-album-plus') . '</option>' . '<option value="slide">' . __('A slideshow of the photos in an album', 'wp-photo-album-plus') . '</option>' . '<option value="slideonly">' . __('A slideshow without supporting boxes', 'wp-photo-album-plus') . '</option>' . '<option value="slideonlyf">' . __('A slideshow with a filmstrip only', 'wp-photo-album-plus') . '</option>' . '<option value="photo">' . __('A single photo', 'wp-photo-album-plus') . '</option>' . '<option value="mphoto">' . __('A single photo with caption', 'wp-photo-album-plus') . '</option>' . '<option value="slphoto">' . __('A single photo in the style of a slideshow', 'wp-photo-album-plus') . '</option>' . '<option value="generic">' . __('A generic albums display', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the type of gallery', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-help" style="display:none;" >' . '<th><label for="wppagallery-album" class="wppagallery-help" >' . __('Explanation:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . __('Use this gallerytype to display all the top-level album covers.', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr class="wppagallery-album" >' . '<th><label for="wppagallery-album" class="wppagallery-album" >' . __('The Album to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-album" name="album" style=width:270px;" class="wppagallery-album" onchange="wppaGalleryAlbumChange(this.value); wppaTinyMceAlbumPreview(this.value)">';
    $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "` ORDER BY `timestamp` DESC", ARRAY_A);
    if ($albums) {
        if (wppa_switch('wppa_hier_albsel')) {
            $albums = wppa_add_paths($albums);
        } else {
            foreach (array_keys($albums) as $index) {
                $albums[$index]['name'] = __(stripslashes($albums[$index]['name']), 'wp-photo-album-plus');
            }
        }
        // Sort
        $albums = wppa_array_sort($albums, 'name');
        $result .= '<option value="0" disabled="disabled" selected="selected" >' . __('Please select an album', 'wp-photo-album-plus') . '</option>';
        // All standard albums
        foreach ($albums as $album) {
            $value = $album['id'];
            $alb = $album['id'];
            $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($alb) . " LIMIT 100", $alb), ARRAY_A);
            if ($photos) {
                foreach ($photos as $photo) {
                    $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                    $value .= '|' . $photo_id . '.' . $photo['ext'];
                }
            } else {
                $value .= '|';
            }
            $note = ' (' . $album['id'] . ')';
            if (count($photos) <= wppa_opt('min_thumbs')) {
                $note .= ' *';
            }
            $result .= '<option value="' . $value . '" >' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . $note . '</option>';
        }
        // #last
        $value = '#last';
        $alb = $albums[0]['id'];
        $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($alb) . " LIMIT 100", $alb), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value="' . $value . '" >' . __('- The latest created album -', 'wp-photo-album-plus') . '</option>';
        // #topten
        $value = '#topten';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `mean_rating` DESC LIMIT " . wppa_opt('topten_count'), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- The top rated photos ---', 'wp-photo-album-plus') . '</option>';
        // #lasten
        $value = '#lasten';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT " . wppa_opt('lasten_count'), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- The most recently uploaded photos ---', 'wp-photo-album-plus') . '</option>';
        // #featen
        $value = '#featen';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `status` = 'featured' ORDER BY RAND() DESC LIMIT " . wppa_opt('featen_count'), ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- A random selection of featured photos ---', 'wp-photo-album-plus') . '</option>';
        // #comten
        $value = '#comten';
        $comments = $wpdb->get_results("SELECT `id`, `photo` FROM `" . WPPA_COMMENTS . "` ORDER BY `timestamp` DESC", ARRAY_A);
        $photos = false;
        $done = array();
        if ($comments) {
            foreach ($comments as $comment) {
                if (count($done) < wppa_opt('comten_count') && !in_array($comment['photo'], $done)) {
                    $done[] = $comment['photo'];
                    $photos[] = $wpdb->get_row("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` WHERE `id` = " . $comment['photo'], ARRAY_A);
                }
            }
        }
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- The most recently commented photos ---', 'wp-photo-album-plus') . '</option>';
        // #tags
        $value = '#tags';
        $result .= '<option value = "' . $value . '" >' . __('--- Photos that have certain tags ---', 'wp-photo-album-plus') . '</option>';
        // #all
        $value = '#all';
        $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` " . wppa_get_photo_order('0') . " LIMIT 100", ARRAY_A);
        if ($photos) {
            foreach ($photos as $photo) {
                $photo_id = wppa_opt('file_system') == 'tree' ? wppa_expand_id($photo['id']) : $photo['id'];
                $value .= '|' . $photo_id . '.' . $photo['ext'];
            }
        } else {
            $value .= '|';
        }
        $result .= '<option value = "' . $value . '" >' . __('--- All photos in the system ---', 'wp-photo-album-plus') . '</option>';
    } else {
        $result .= '<option value="0" >' . __('There are no albums yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '<input type="text" id="wppagallery-alb" name="alb" value="" style="width:50px; display:none; background-color:#ddd;" class="wppagallery-extra" title="Enter albumnumber if not systemwide" />' . '<input type="text" id="wppagallery-cnt" name="cnt" value="" style="width:50px; display:none; background-color:#ddd;" class="wppagallery-extra" title="Enter count if not default" />' . '<br />' . '<small class="wppagallery-album" >' . __('Specify the album to be used or --- A special selection of photos ---', 'wp-photo-album-plus') . '<br />' . __('In an upload box, the album is optional. When no album is specified: a selection box will be displayed of the albums the user has the right to upload.', 'wp-photo-album-plus') . '<br />' . __('* Album contains less than the minimun number of photos', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-photo" style="display:none;" >' . '<th><label for="wppagallery-photo" style="display:none;" class="wppagallery-photo" >' . __('The Photo to be used:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-photo" name="photo" style="display:none;" class="wppagallery-photo" onchange="wppaTinyMcePhotoPreview(this.value)" >';
    $photos = $wpdb->get_results("SELECT `id`, `name`, `album`, `ext` FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC LIMIT 100", ARRAY_A);
    if ($photos) {
        $result .= '<option value="0" disabled="disabled" selected="selected" >' . __('Please select a photo', 'wp-photo-album-plus') . '</option>';
        foreach ($photos as $photo) {
            $name = stripslashes(__($photo['name'], 'wp-photo-album-plus'));
            if (strlen($name) > '50') {
                $name = substr($name, '0', '50') . '...';
            }
            if (get_option('wppa_file_system') == 'flat') {
                $result .= '<option value="' . $photo['id'] . '.' . $photo['ext'] . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            } else {
                $result .= '<option value="' . wppa_expand_id($photo['id']) . '.' . $photo['ext'] . '" >' . $name . ' (' . wppa_get_album_name($photo['album']) . ')' . '</option>';
            }
        }
        $result .= '<option value="#last" >' . __('--- The most recently uploaded photo ---', 'wp-photo-album-plus') . '</option>' . '<option value="#potd" >' . __('--- The photo of the day ---', 'wp-photo-album-plus') . '</option>';
    } else {
        $result .= '<option value="0" >' . __('There are no photos yet', 'wp-photo-album-plus') . '</option>';
    }
    $result .= '</select>' . '<br />' . '<small style="display:none;" class="wppagallery-photo" >' . __('Specify the photo to be used', 'wp-photo-album-plus') . '<br />' . __('You can select from a maximum of 100 most recently added photos', 'wp-photo-album-plus') . '<br />' . '</small>' . '</td>' . '</tr>' . '<tr class="wppagallery-tags" style="display:none;" >' . '<th><label for="wppagallery-tags">' . __('The tags the photos should have:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-tags" multiple="multiple">' . '<option value="" >' . __('--- please select tag(s) ---', 'wp-photo-album-plus') . '</option>';
    $tags = wppa_get_taglist();
    if ($tags) {
        foreach (array_keys($tags) as $tag) {
            $result .= '<option value="' . $tag . '" >' . $tag . '</option>';
        }
    }
    $result .= '</select>' . '<div><input type="checkbox" id="wppagallery-andor" />&nbsp;<small>' . __('If you want that the photos have all the selected tags, check this box. Leave it unchecked if the photo must have atleast only one of the selected tags', 'wp-photo-album-plus') . '</small></div>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-size">' . __('The size of the display:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<input type="text" id="wppagallery-size" value="" />' . '<br />' . '<small>' . __('Specify the horizontal size in pixels or <span style="color:blue" >auto</span>.', 'wp-photo-album-plus') . ' ' . __('A value less than <span style="color:blue" >100</span> will automaticly be interpreted as a <span style="color:blue" >percentage</span> of the available space.', 'wp-photo-album-plus') . '<br />' . __('Leave this blank for default size', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '<tr>' . '<th><label for="wppagallery-align">' . __('Horizontal alignment:', 'wp-photo-album-plus') . '</label></th>' . '<td>' . '<select id="wppagallery-align" name="align" >' . '<option value="none" >' . __('--- none ---', 'wp-photo-album-plus') . '</option>' . '<option value="left" >' . __('left', 'wp-photo-album-plus') . '</option>' . '<option value="center" >' . __('center', 'wp-photo-album-plus') . '</option>' . '<option value="right" >' . __('right', 'wp-photo-album-plus') . '</option>' . '</select>' . '<br />' . '<small>' . __('Specify the alignment to be used or --- none ---', 'wp-photo-album-plus') . '</small>' . '</td>' . '</tr>' . '</table>' . '<p class="submit">' . '<input type="button" id="wppagallery-submit" class="button-primary" value="' . __('Insert Gallery', 'wp-photo-album-plus') . '" name="submit" />&nbsp;' . '</p>' . '</div>';
    return $result;
}
function wppa_album_select_a($args)
{
    global $wpdb;
    $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true));
    // Provide default selection if no selected given
    if ($args['selected'] === '') {
        $args['selected'] = wppa_get_last_album();
    }
    // See if selection is valid
    if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) {
        $args['selected'] = '0';
    }
    $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` " . wppa_get_album_order($args['root']), ARRAY_A);
    // Add to secondary cache
    if ($albums) {
        wppa_cache_album('add', $albums);
    }
    if ($albums) {
        // Filter for root
        if ($args['root']) {
            $root = $args['root'];
            switch ($root) {
                // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )'
                case '-2':
                    // Generic only
                    foreach (array_keys($albums) as $albidx) {
                        if (wppa_is_separate($albums[$albidx]['id'])) {
                            unset($albums[$albidx]);
                        }
                    }
                    break;
                case '-1':
                    // Separate only
                    foreach (array_keys($albums) as $albidx) {
                        if (!wppa_is_separate($albums[$albidx]['id'])) {
                            unset($albums[$albidx]);
                        }
                    }
                    break;
                default:
                    foreach (array_keys($albums) as $albidx) {
                        if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) {
                            unset($albums[$albidx]);
                        }
                    }
                    break;
            }
        }
        // Filter for must have content
        if ($args['content']) {
            foreach (array_keys($albums) as $albidx) {
                if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) {
                    unset($albums[$albidx]);
                }
            }
        }
        // Add paths
        if ($args['path']) {
            $albums = wppa_add_paths($albums);
        } else {
            foreach (array_keys($albums) as $index) {
                $albums[$index]['name'] = __(stripslashes($albums[$index]['name']));
            }
        }
        // Sort
        if ($args['sort']) {
            $albums = wppa_array_sort($albums, 'name');
        }
    }
    // Output
    $result = '';
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addpleaseselect']) {
        $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . (is_admin() ? __('- select an album -', 'wppa') : __a('- select an album -')) . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addnone']) {
        $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- none ---', 'wppa') : __a('--- none ---')) . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addall']) {
        $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- all ---', 'wppa') : __a('--- all ---')) . '</option>';
    }
    $selected = $args['selected'] == '-2' ? ' selected="selected"' : '';
    if ($args['addall']) {
        $result .= '<option value="-2"' . $selected . ' >' . (is_admin() ? __('--- generic ---', 'wppa') : __a('--- generic ---')) . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addblank']) {
        $result .= '<option value="0"' . $selected . ' >' . '</option>';
    }
    $selected = $args['selected'] == '-99' ? ' selected="selected"' : '';
    if ($args['addmultiple']) {
        $result .= '<option value="-99"' . $selected . ' >' . (is_admin() ? __('--- multiple see below ---', 'wppa') : __a('--- multiple see below ---')) . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addselbox']) {
        $result .= '<option value="0"' . $selected . ' >' . (is_admin() ? __('--- a selection box ---', 'wppa') : __a('--- a selection box ---')) . '</option>';
    }
    if ($albums) {
        foreach ($albums as $album) {
            if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) {
                $disabled = ' disabled="disabled"';
            } else {
                $disabled = '';
            }
            if ($args['selected'] == $album['id'] && !$disabled) {
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $ok = true;
            // Assume this will be in the list
            if ($args['checkaccess'] && !wppa_have_access($album['id'])) {
                $ok = false;
            }
            if ($args['checkowner'] && wppa_switch('upload_owner_only')) {
                // Need to check
                if ($album['owner'] != wppa_get_user() && $album['owner'] != '--- public ---') {
                    // Not 'mine'
                    if (!wppa_user_is('administrator')) {
                        // No admin
                        $ok = false;
                    }
                }
            }
            if ($selected && $args['addselected']) {
                $ok = true;
            }
            if ($ok) {
                if ($args['addnumbers']) {
                    $number = ' ( ' . $album['id'] . ' )';
                } else {
                    $number = '';
                }
                $result .= '<option value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>';
            }
        }
    }
    $selected = $args['selected'] == '-1' ? ' selected="selected"' : '';
    if ($args['addseparate']) {
        $result .= '<option value="-1"' . $selected . '>' . (is_admin() ? __('--- separate ---', 'wppa') : __a('--- separate ---')) . '</option>';
    }
    return $result;
}
예제 #4
0
function wppa_display_root($id)
{
    $all = __('All albums', 'wp-photo-album-plus');
    if (!$id || $id == '-2') {
        return $all;
    }
    $album = wppa_cache_album($id);
    if (!$album) {
        return '';
    }
    $albums = array();
    $albums[] = $album;
    $albums = wppa_add_paths($albums);
    return $albums[0]['name'];
}
function wppa_album_select_a($args)
{
    global $wpdb;
    $args = wp_parse_args($args, array('exclude' => '', 'selected' => '', 'disabled' => '', 'addpleaseselect' => false, 'addnone' => false, 'addall' => false, 'addgeneric' => false, 'addblank' => false, 'addselected' => false, 'addseparate' => false, 'addselbox' => false, 'addowner' => false, 'disableancestors' => false, 'checkaccess' => false, 'checkowner' => false, 'checkupload' => false, 'addmultiple' => false, 'addnumbers' => false, 'path' => false, 'root' => false, 'content' => false, 'sort' => true, 'checkarray' => false, 'array' => array(), 'optionclass' => ''));
    // Provide default selection if no selected given
    if ($args['selected'] === '') {
        $args['selected'] = wppa_get_last_album();
    }
    // See if selection is valid
    if ($args['selected'] == $args['exclude'] || $args['checkupload'] && !wppa_allow_uploads($args['selected']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $args['selected'])) {
        $args['selected'] = '0';
    }
    // Get roughly the albums that might be in the selection
    if ($args['checkarray'] && !empty($args['array'])) {
        $albums = $wpdb->get_results("SELECT `id`, `name` " . "FROM `" . WPPA_ALBUMS . "` " . "WHERE `id` IN (" . implode(',', $args['array']) . ") " . ($args['checkowner'] && wppa_switch('upload_owner_only') && !wppa_user_is('administrator') ? "AND `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "") . wppa_get_album_order($args['root']), ARRAY_A);
    } else {
        $albums = $wpdb->get_results("SELECT `id`, `name` " . "FROM `" . WPPA_ALBUMS . "` " . ($args['checkowner'] && wppa_switch('upload_owner_only') && !wppa_user_is('administrator') ? "WHERE `owner` IN ( '--- public ---', '" . wppa_get_user() . "' ) " : "") . wppa_get_album_order($args['root']), ARRAY_A);
    }
    /* Can not add to cache because only "SELECT * " can be added
    	// Add to secondary cache
    	if ( $albums ) {
    		wppa_cache_album( 'add', $albums );
    	}
    	*/
    if ($albums) {
        // Filter for root
        if ($args['root']) {
            $root = $args['root'];
            switch ($root) {
                // case '0': all, will be skipped as it returns false in 'if ( $args['root'] )'
                case '-2':
                    // Generic only
                    foreach (array_keys($albums) as $albidx) {
                        if (wppa_is_separate($albums[$albidx]['id'])) {
                            unset($albums[$albidx]);
                        }
                    }
                    break;
                case '-1':
                    // Separate only
                    foreach (array_keys($albums) as $albidx) {
                        if (!wppa_is_separate($albums[$albidx]['id'])) {
                            unset($albums[$albidx]);
                        }
                    }
                    break;
                default:
                    foreach (array_keys($albums) as $albidx) {
                        if (!wppa_is_ancestor($root, $albums[$albidx]['id'])) {
                            unset($albums[$albidx]);
                        }
                    }
                    break;
            }
        }
        // Filter for must have content
        if ($args['content']) {
            foreach (array_keys($albums) as $albidx) {
                if (wppa_get_photo_count($albums[$albidx]['id']) <= wppa_get_mincount()) {
                    unset($albums[$albidx]);
                }
            }
        }
        // Add paths
        if ($args['path']) {
            $albums = wppa_add_paths($albums);
        } else {
            foreach (array_keys($albums) as $index) {
                $albums[$index]['name'] = __(stripslashes($albums[$index]['name']));
            }
        }
        // Sort
        if ($args['sort']) {
            $albums = wppa_array_sort($albums, 'name');
        }
    }
    // Output
    $result = '';
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addpleaseselect']) {
        $result .= '<option value="0" disabled="disabled" ' . $selected . ' >' . __('- select an album -', 'wp-photo-album-plus') . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addnone']) {
        $result .= '<option value="0"' . $selected . ' >' . __('--- none ---', 'wp-photo-album-plus') . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addall']) {
        $result .= '<option value="0"' . $selected . ' >' . __('--- all ---', 'wp-photo-album-plus') . '</option>';
    }
    $selected = $args['selected'] == '-2' ? ' selected="selected"' : '';
    if ($args['addall']) {
        $result .= '<option value="-2"' . $selected . ' >' . __('--- generic ---', 'wp-photo-album-plus') . '</option>';
    }
    $selected = $args['selected'] == '-3' ? ' selected="selected"' : '';
    if ($args['addowner']) {
        $result .= '<option value="-3"' . $selected . ' >' . __('--- owner/public ---', 'wp-photo-album-plus') . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addblank']) {
        $result .= '<option value="0"' . $selected . ' >' . '</option>';
    }
    $selected = $args['selected'] == '-99' ? ' selected="selected"' : '';
    if ($args['addmultiple']) {
        $result .= '<option value="-99"' . $selected . ' >' . __('--- multiple see below ---', 'wp-photo-album-plus') . '</option>';
    }
    $selected = $args['selected'] == '0' ? ' selected="selected"' : '';
    if ($args['addselbox']) {
        $result .= '<option value="0"' . $selected . ' >' . __('--- a selection box ---', 'wp-photo-album-plus') . '</option>';
    }
    // In case multiple
    if (strpos($args['selected'], ',') !== false) {
        $selarr = explode(',', $args['selected']);
    } else {
        $selarr = array($args['selected']);
    }
    if ($albums) {
        foreach ($albums as $album) {
            if ($args['disabled'] == $album['id'] || $args['exclude'] == $album['id'] || $args['checkupload'] && !wppa_allow_uploads($album['id']) || $args['disableancestors'] && wppa_is_ancestor($args['exclude'], $album['id'])) {
                $disabled = ' disabled="disabled"';
            } else {
                $disabled = '';
            }
            if (in_array($album['id'], $selarr, true) && !$disabled) {
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $ok = true;
            // Assume this will be in the list
            if ($args['checkaccess'] && !wppa_have_access($album['id'])) {
                $ok = false;
            }
            /* This is in the query now
            		if ( $args['checkowner'] && wppa_switch( 'upload_owner_only' ) ) { 							// Need to check
            			if ( $album['owner'] != wppa_get_user() && $album['owner']  != '--- public ---' ) { 	// Not 'mine'
            				if ( ! wppa_user_is( 'administrator' ) ) {											// No admin
            					$ok = false;
            				}
            			}
            		}
            		*/
            /* This is in the query now
            		if ( $args['checkarray'] ) {
            			if ( ! in_array( $album['id'], $args['array'] ) ) {
            				$ok = false;
            			}
            		}
            		*/
            if ($selected && $args['addselected']) {
                $ok = true;
            }
            if ($ok) {
                if ($args['addnumbers']) {
                    $number = ' ( ' . $album['id'] . ' )';
                } else {
                    $number = '';
                }
                $result .= '<option class="' . $args['optionclass'] . '" value="' . $album['id'] . '" ' . $selected . $disabled . '>' . $album['name'] . $number . '</option>';
            }
        }
    }
    $selected = $args['selected'] == '-1' ? ' selected="selected"' : '';
    if ($args['addseparate']) {
        $result .= '<option value="-1"' . $selected . '>' . __('--- separate ---', 'wp-photo-album-plus') . '</option>';
    }
    return $result;
}
예제 #6
0
    /** @see WP_Widget::form */
    function form($instance)
    {
        global $wpdb;
        //Defaults
        $instance = wp_parse_args((array) $instance, array('title' => __('User Photos', 'wp-photo-album-plus'), 'sortby' => 'name', 'ignore' => 'admin', 'parent' => ''));
        $widget_title = apply_filters('widget_title', $instance['title']);
        ?>
		<p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:', 'wp-photo-album-plus');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $widget_title;
        ?>
" />
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('sortby');
        ?>
"><?php 
        _e('Sort by:', 'wp-photo-album-plus');
        ?>
</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('sortby');
        ?>
" name="<?php 
        echo $this->get_field_name('sortby');
        ?>
" >
				<option value="name" <?php 
        if ($instance['sortby'] == 'name') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        _e('Display name', 'wp-photo-album-plus');
        ?>
</option>
				<option value="count" <?php 
        if ($instance['sortby'] == 'count') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        _e('Number of photos', 'wp-photo-album-plus');
        ?>
</option>
				<option value="date" <?php 
        if ($instance['sortby'] == 'date') {
            echo 'selected="selected"';
        }
        ?>
><?php 
        _e('Most recent photo', 'wp-photo-album-plus');
        ?>
</option>
			</select>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('ignore');
        ?>
"><?php 
        _e('Ignore:', 'wp-photo-album-plus');
        ?>
</label>
			<input class="widefat" id=<?php 
        echo $this->get_field_id('ignore');
        ?>
" name="<?php 
        echo $this->get_field_name('ignore');
        ?>
" value="<?php 
        echo $instance['ignore'];
        ?>
" />
			<small><?php 
        _e('Enter loginnames seperated by commas', 'wp-photo-album-plus');
        ?>
</small>
		</p>

		<p><label for="<?php 
        echo $this->get_field_id('parent');
        ?>
"><?php 
        _e('Look only in albums (including sub-albums):', 'wp-photo-album-plus');
        ?>
</label>
			<input type="hidden" id="<?php 
        echo $this->get_field_id('parent');
        ?>
" name="<?php 
        echo $this->get_field_name('parent');
        ?>
" value="<?php 
        echo $instance['parent'];
        ?>
" />
			<?php 
        if ($instance['parent']) {
            echo '<br/><small>( ' . $instance['parent'] . ' )</small>';
        }
        ?>
			<select class="widefat" multiple="multiple" onchange="wppaGetSelEnumToId( 'parentalbums-<?php 
        echo $this->get_widget_id();
        ?>
', '<?php 
        echo $this->get_field_id('parent');
        ?>
' )" id="<?php 
        echo $this->get_field_id('parent-list');
        ?>
" name="<?php 
        echo $this->get_field_name('parent-list');
        ?>
" >
			<?php 
        // Prepare albuminfo
        $albums = $wpdb->get_results("SELECT `id`, `name` FROM `" . WPPA_ALBUMS . "`", ARRAY_A);
        if (wppa_switch('hier_albsel')) {
            $albums = wppa_add_paths($albums);
        } else {
            foreach (array_keys($albums) as $index) {
                $albums[$index]['name'] = __(stripslashes($albums[$index]['name']), 'wp-photo-album-plus');
            }
        }
        $albums = wppa_array_sort($albums, 'name');
        // Please select
        $sel = $instance['parent'] ? '' : 'selected="selected" ';
        echo '<option class="parentalbums-' . $this->get_widget_id() . '" value="" ' . $sel . '>-- ' . __('All albums', 'wp-photo-album-plus') . ' --</option>';
        // Find the albums currently selected
        $selalbs = explode('.', wppa_expand_enum($instance['parent']));
        // All standard albums
        foreach ($albums as $album) {
            $s = in_array($album['id'], $selalbs);
            $sel = $s ? 'selected="selected" ' : '';
            echo '<option class="parentalbums-' . $this->get_widget_id() . '" value="' . $album['id'] . '" ' . $sel . '>' . stripslashes(__($album['name'], 'wp-photo-album-plus')) . ' (' . $album['id'] . ')</option>';
        }
        ?>
			</select>
		</p>

<?php 
    }