function wppa_admin_albums_collapsable() { global $wpdb; // Read the albums $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY `id`", ARRAY_A); // Find the ordering method $reverse = false; if (isset($_REQUEST['order_by'])) { $order = $_REQUEST['order_by']; } else { $order = ''; } if (!$order) { $order = get_option('wppa_album_order_' . wppa_get_user(), 'id'); $reverse = get_option('wppa_album_order_' . wppa_get_user() . '_reverse') == 'yes'; } else { $old_order = get_option('wppa_album_order_' . wppa_get_user(), 'id'); $reverse = get_option('wppa_album_order_' . wppa_get_user() . '_reverse') == 'yes'; if ($old_order == $order) { $reverse = !$reverse; } else { $reverse = false; } update_option('wppa_album_order_' . wppa_get_user(), $order); if ($reverse) { update_option('wppa_album_order_' . wppa_get_user() . '_reverse', 'yes'); } else { update_option('wppa_album_order_' . wppa_get_user() . '_reverse', 'no'); } } if (!empty($albums)) { // Setup the sequence array $seq = false; $num = false; foreach ($albums as $album) { switch ($order) { case 'name': $seq[] = strtolower(__(stripslashes($album['name']))); break; case 'description': $seq[] = strtolower(__(stripslashes($album['description']))); break; case 'owner': $seq[] = strtolower($album['owner']); break; case 'a_order': $seq[] = $album['a_order']; $num = true; break; case 'a_parent': $seq[] = strtolower(wppa_get_album_name($album['a_parent']), 'extended'); break; default: $seq[] = $album['id']; $num = true; break; } } // Sort the seq array if ($num) { asort($seq, SORT_NUMERIC); } else { asort($seq, SORT_REGULAR); } // Reverse ? if ($reverse) { $t = $seq; $c = count($t); $tmp = array_keys($t); $seq = false; for ($i = $c - 1; $i >= 0; $i--) { $seq[$tmp[$i]] = '0'; } } $downimg = '<img src="' . wppa_get_imgdir() . 'down.png" alt="down" style=" height:12px; position:relative; top:2px; " />'; $upimg = '<img src="' . wppa_get_imgdir() . 'up.png" alt="up" style=" height:12px; position:relative; top:2px; " />'; ?> <!-- <div class="table_wrapper"> --> <table class="widefat wppa-table wppa-setting-table" style="margin-top:12px;" > <thead> <tr> <td style="min-width:20px;" > <img src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " style="height:16px;" title="<?php _e('Collapse subalbums', 'wp-photo-album-plus'); ?> " /> <img src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " style="height:16px;" title="<?php _e('Expand subalbums', 'wp-photo-album-plus'); ?> " /> </td> <?php $url = get_admin_url() . 'admin.php?page=wppa_admin_menu&order_by='; ?> <td colspan="6" style="min-width: 50px;" > <a href="<?php echo wppa_dbg_url($url . 'id'); ?> "> <?php _e('ID', 'wp-photo-album-plus'); if ($order == 'id') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="min-width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'name'); ?> "> <?php _e('Name', 'wp-photo-album-plus'); if ($order == 'name') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td > <a href="<?php echo wppa_dbg_url($url . 'description'); ?> "> <?php _e('Description', 'wp-photo-album-plus'); if ($order == 'description') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php if (current_user_can('administrator')) { ?> <td style="min-width: 100px;"> <a href="<?php echo wppa_dbg_url($url . 'owner'); ?> "> <?php _e('Owner', 'wp-photo-album-plus'); if ($order == 'owner') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php } ?> <td style="min-width: 100px;" > <a href="<?php echo wppa_dbg_url($url . 'a_order'); ?> "> <?php _e('Order', 'wp-photo-album-plus'); if ($order == 'a_order') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'a_parent'); ?> "> <?php _e('Parent', 'wp-photo-album-plus'); if ($order == 'a_parent') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td title="<?php _e('Albums/Photos/Moderation required/Scheduled', 'wp-photo-album-plus'); ?> " > <?php _e('A/P/PM/S', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Edit', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Quick', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Bulk', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Seq', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Delete', 'wp-photo-album-plus'); ?> </td> <?php if (wppa_can_create_album()) { echo '<td >' . __('Create', 'wp-photo-album-plus') . '</td>'; } ?> </tr> </thead> <tbody> <?php wppa_do_albumlist('0', '0', $albums, $seq); ?> <?php if ($wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = '-1'") > 0) { ?> <tr> <td colspan="19" ><em><?php _e('The following albums are ---separate--- and do not show up in the generic album display', 'wp-photo-album-plus'); ?> </em></td> </tr> <?php wppa_do_albumlist('-1', '0', $albums, $seq); ?> <?php } wppa_search_edit(true); ?> </tbody> <tfoot> <tr> <td> <img src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " style="height:16px;" /> <img src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " style="height:16px;" /> </td> <?php $url = get_admin_url() . 'admin.php?page=wppa_admin_menu&order_by='; ?> <td colspan="6" > <a href="<?php echo wppa_dbg_url($url . 'id'); ?> "> <?php _e('ID', 'wp-photo-album-plus'); if ($order == 'id') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'name'); ?> "> <?php _e('Name', 'wp-photo-album-plus'); if ($order == 'name') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td > <a href="<?php echo wppa_dbg_url($url . 'description'); ?> "> <?php _e('Description', 'wp-photo-album-plus'); if ($order == 'description') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php if (current_user_can('administrator')) { ?> <td style="width: 100px;"> <a href="<?php echo wppa_dbg_url($url . 'owner'); ?> "> <?php _e('Owner', 'wp-photo-album-plus'); if ($order == 'owner') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php } ?> <td > <a href="<?php echo wppa_dbg_url($url . 'a_order'); ?> "> <?php _e('Order', 'wp-photo-album-plus'); if ($order == 'a_order') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'a_parent'); ?> "> <?php _e('Parent', 'wp-photo-album-plus'); if ($order == 'a_parent') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td title="<?php _e('Albums/Photos/Moderation required/Scheduled', 'wp-photo-album-plus'); ?> " > <?php _e('A/P/PM/S', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Edit', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Quick', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Bulk', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Seq', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Delete', 'wp-photo-album-plus'); ?> </td> <?php if (wppa_can_create_album()) { echo '<td >' . __('Create', 'wp-photo-album-plus') . '</td>'; } ?> </tr> </tfoot> </table> <script type="text/javascript" > function checkArrows() { elms = jQuery('.alb-arrow-off'); for(i=0;i<elms.length;i++) { elm = elms[i]; if ( elm.parentNode.parentNode.style.display == 'none' ) elm.style.display = 'none'; } elms = jQuery('.alb-arrow-on'); for(i=0;i<elms.length;i++) { elm = elms[i]; if ( elm.parentNode.parentNode.style.display == 'none' ) elm.style.display = ''; } } </script> <!-- </div> --> <?php wppa_album_admin_footer(); } else { ?> <p><?php _e('No albums yet.', 'wp-photo-album-plus'); ?> </p> <?php } }
function _wppa_page_import() { global $wppa_revno; global $wpdb; global $wppa_supported_photo_extensions; global $wppa_supported_video_extensions; global $wppa_supported_audio_extensions; global $wppa_session; if (wppa('ajax')) { ob_start(); } // Suppress output if ajax operation // Init $ngg_opts = get_option('ngg_options', false); $user = wppa_get_user(); // Check database wppa_check_database(true); // Update watermark settings for the user if new values supplied if (wppa_switch('watermark_on') && (wppa_switch('watermark_user') || current_user_can('wppa_settings'))) { // File if (isset($_POST['wppa-watermark-file'])) { // Sanitize input $watermark_file = $_POST['wppa-watermark-file']; if (stripos($watermark_file, '.png') !== false) { $watermark_file = sanitize_file_name($watermark_file); } else { if (!in_array($watermark_file, array('--- none ---', '---name---', '---filename---', '---description---', '---predef---'))) { $watermark_file = 'nil'; } } // Update setting update_option('wppa_watermark_file_' . $user, $watermark_file); } // Position if (isset($_POST['wppa-watermark-pos'])) { // Sanitize input $watermark_pos = $_POST['wppa-watermark-pos']; if (!in_array($watermark_pos, array('toplft', 'topcen', 'toprht', 'cenlft', 'cencen', 'cenrht', 'botlft', 'botcen', 'botrht'))) { $watermark_pos = 'nil'; } // Update setting update_option('wppa_watermark_pos_' . $user, $watermark_pos); } } // Update last used albums if (isset($_POST['wppa-photo-album'])) { update_option('wppa-photo-album-import-' . wppa_get_user(), strval(intval($_POST['wppa-photo-album']))); } if (isset($_POST['wppa-video-album'])) { update_option('wppa-video-album-import-' . wppa_get_user(), strval(intval($_POST['wppa-video-album']))); } if (isset($_POST['wppa-audio-album'])) { update_option('wppa-audio-album-import-' . wppa_get_user(), strval(intval($_POST['wppa-audio-album']))); } // Verify last albums still exist $alb = get_option('wppa-photo-album-import-' . wppa_get_user(), '0'); if ($alb) { $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb)); if (!$exists) { update_option('wppa-photo-album-import-' . wppa_get_user(), '0'); } } $alb = get_option('wppa-video-album-import-' . wppa_get_user(), '0'); if ($alb) { $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb)); if (!$exists) { update_option('wppa-video-album-import-' . wppa_get_user(), '0'); } } $alb = get_option('wppa-audio-album-import-' . wppa_get_user(), '0'); if ($alb) { $exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $alb)); if (!$exists) { update_option('wppa-audio-album-import-' . wppa_get_user(), '0'); } } // Extract zip if (isset($_GET['zip'])) { wppa_extract($_GET['zip'], true); } // Set local / remote if (isset($_POST['wppa-local-remote']) && in_array($_POST['wppa-local-remote'], array('local', 'remote'))) { check_admin_referer('$wppa_nonce', WPPA_NONCE); update_option('wppa_import_source_type_' . $user, $_POST['wppa-local-remote']); } // Set import source dir ( when local ) if (isset($_POST['wppa-import-set-source-dir']) && is_dir($_POST['wppa-source'])) { check_admin_referer('$wppa_nonce', WPPA_NONCE); if (isset($_POST['wppa-source'])) { update_option('wppa_import_source_' . $user, $_POST['wppa-source']); } } // Set import source url ( when remote ) if (isset($_POST['wppa-import-set-source-url'])) { check_admin_referer('$wppa_nonce', WPPA_NONCE); if (isset($_POST['wppa-source-remote'])) { update_option('wppa_import_source_url_' . $user, esc_url($_POST['wppa-source-remote'])); update_option('wppa_import_source_url_found_' . $user, false); update_option('wppa_import_remote_max_' . $user, strval(intval($_POST['wppa-import-remote-max']))); } } // Hit the submit button if (isset($_POST['wppa-import-submit'])) { if (wppa('ajax')) { if (!wp_verify_nonce($_POST['wppa-update-check'], '$wppa_nonce')) { echo $_POST['wppa-update-check'] . ' Security check failure'; wppa_exit(); } } else { check_admin_referer('$wppa_nonce', WPPA_NONCE); } $delp = isset($_POST['del-after-p']); $delf = isset($_POST['del-after-f']); $dela = isset($_POST['del-after-a']); $delz = isset($_POST['del-after-z']); $delv = isset($_POST['del-after-v']); $delu = isset($_POST['del-after-u']); $delc = isset($_POST['del-after-c']); wppa_import_photos($delp, $dela, $delz, $delv, $delu, $delc, $delf); } elseif (isset($_GET['continue'])) { if (wp_verify_nonce($_GET['nonce'], 'dirimport')) { wppa_import_photos(); } } // If we did this by ajax, setup reporting results for it if (wppa('ajax')) { ob_end_clean(); if (wppa('ajax_import_files_done')) { echo '<span style="color:green" >' . wppa('ajax_import_files') . ' ' . __('Done!', 'wp-photo-album-plus') . '</span>'; } elseif (wppa('ajax_import_files_error')) { echo '<span style="color:red" >' . wppa('ajax_import_files') . ' ' . wppa('ajax_import_files_error') . '</span>'; } else { echo '<span style="color:red" >' . wppa('ajax_import_files') . ' ' . __('Failed!', 'wp-photo-album-plus') . '</span>'; } wppa_exit(); } // Open the Form echo '<div class="wrap">' . '<h2>' . __('Import Photos', 'wp-photo-album-plus') . '</h2>'; // See if remote is possible $can_remote = ini_get('allow_url_fopen') && function_exists('curl_init'); if (!$can_remote) { update_option('wppa_import_source_type_' . $user, 'local'); } // Get this users current source type setting ( local/remote ) $source_type = get_option('wppa_import_source_type_' . $user, 'local'); // Local. Find data we will going to need if ($source_type == 'local') { // Get curren local dir setting $source = get_option('wppa_import_source_' . $user, WPPA_DEPOT_PATH); if (!$source || !is_dir($source)) { $source = WPPA_DEPOT_PATH; update_option('wppa_import_source_' . $user, WPPA_DEPOT_PATH); } // See if the current source is the 'home' directory $is_depot = $source == WPPA_DEPOT_PATH; // See if the current source is a subdir of my depot $is_sub_depot = substr($source, 0, strlen(WPPA_DEPOT_PATH)) == WPPA_DEPOT_PATH; // Sanitize system, removes illegal files if ($is_sub_depot) { wppa_sanitize_files(); } // See what's in there $files = wppa_get_import_files(); $zipcount = wppa_get_zipcount($files); $albumcount = wppa_get_albumcount($files); $photocount = wppa_get_photocount($files); $videocount = wppa_get_video_count($files); $audiocount = wppa_get_audio_count($files); $dircount = $is_depot ? wppa_get_dircount($files) : '0'; $csvcount = $is_depot ? wppa_get_csvcount($files) : '0'; if ($ngg_opts) { $is_ngg = strpos($source, $ngg_opts['gallerypath']) !== false; // this is false for the ngg root !! } else { $is_ngg = false; } } // Remote. Find data we will going to need if ($source_type == 'remote') { wppa('is_remote', true); $source = get_option('wppa_import_source_url_' . $user, 'http://'); $source_path = $source; $source_url = $source; $is_depot = false; $is_sub_depot = false; $files = wppa_get_import_files(); $zipcount = '0'; $albumcount = '0'; $photocount = $files ? count($files) : '0'; $videocount = '0'; $audiocount = '0'; $dircount = '0'; $csvcount = '0'; $is_ngg = false; $remote_max = get_option('wppa_import_remote_max_' . $user, '10'); } // The form echo '<form' . ' action="' . wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_import_photos') . '"' . ' method="post"' . ' >'; // Admin and superuser can change import source, other users only if change source not is restricted if (wppa_user_is('administrator') || !wppa_switch('chgsrc_is_restricted')) { // Local / Remote echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' . wp_nonce_field('$wppa_nonce', WPPA_NONCE, true, false) . __('Select Local or Remote', 'wp-photo-album-plus') . ($disabled = $can_remote ? '' : 'disabled="disabled"') . '<select name="wppa-local-remote" >' . '<option value="local" ' . ($source_type == 'local' ? 'selected="selected"' : '') . '>' . __('Local', 'wp-photo-album-plus') . '</option>' . '<option value="remote" ' . $disabled . ($source_type == 'remote' ? 'selected="selected"' : '') . '>' . __('Remote', 'wp-photo-album-plus') . '</option>' . '</select>'; if ($can_remote) { echo '<input' . ' type="submit"' . ' class="button-secundary"' . ' name="wppa-import-set-source"' . ' value="' . __('Set Local/Remote', 'wp-photo-album-plus') . '"' . '/>'; } else { if (!ini_get('allow_url_fopen')) { _e('The server does not allow you to import from remote locations. ( The php directive allow_url_fopen is not set to 1 )', 'wp-photo-album-plus'); } if (!function_exists('curl_init')) { _e('The server does not allow you to import from remote locations. ( The curl functions are not set up )', 'wp-photo-album-plus'); } } echo '</div>'; // Source dir / url echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' . wp_nonce_field('$wppa_nonce', WPPA_NONCE, true, false) . __('Import photos from:', 'wp-photo-album-plus'); // Local: dir if ($source_type == 'local') { echo '<select name="wppa-source" >' . wppa_abs_walktree(wppa_opt('import_root'), $source) . '</select>' . '<input' . ' type="submit"' . ' class="button-secundary"' . ' name="wppa-import-set-source-dir"' . ' value="' . __('Set source directory', 'wp-photo-album-plus') . '"' . ' />'; } else { echo '<input' . ' type="text"' . ' style="width:50%"' . ' name="wppa-source-remote"' . ' value="' . $source . '"' . ' />' . __('Max:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' style="width:50px;"' . ' name="wppa-import-remote-max"' . ' value="' . $remote_max . '"' . ' />' . '<input' . ' type="submit"' . ' onclick="jQuery( \'#rem-rem\' ).css( \'display\',\'inline\' ); return true;"' . ' class="button-secundary"' . ' name="wppa-import-set-source-url"' . ' value="' . __('Find remote photos', 'wp-photo-album-plus') . '"' . ' />' . '<span id="rem-rem" style="display:none;" >' . __('Working, please wait...', 'wp-photo-album-plus') . '</span>' . '<br />' . __('You can enter either a web page address like <i>http://mysite.com/mypage/</i> or a full url to an image file like <i>http://mysite.com/wp-content/uploads/wppa/4711.jpg</i>', 'wp-photo-album-plus'); } echo '</div>'; } echo '</form>'; // check if albums exist or will be made before allowing upload if (!wppa_has_albums() && !$albumcount && !$dircount && !$csvcount) { $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu'); echo '<p>' . __('No albums exist. You must', 'wp-photo-album-plus') . ' ' . '<a href="' . $url . '" >' . __('create one', 'wp-photo-album-plus') . ' ' . '</a> ' . __('beofre you can upload your photos.', 'wp-photo-album-plus') . '</p>'; return; } // Something to import? if ($photocount || $albumcount || $zipcount || $dircount || $videocount || $audiocount || $csvcount) { // Open the form echo '<form' . ' action="' . wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_import_photos') . '"' . ' method="post"' . ' >' . wp_nonce_field('$wppa_nonce', WPPA_NONCE, true, false); // Display the zips if (PHP_VERSION_ID >= 50207 && $zipcount > '0') { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' . '<p><b>' . sprintf(_n('There is %d zipfile in the depot', 'There are %d zipfiles in the depot', $zipcount, 'wp-photo-album-plus'), $zipcount) . '</b></p>' . '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-zip"' . ' checked="checked"' . ' onchange="checkAll( \'all-zip\', \'.wppa-zip\' )"' . ' />' . '<b> ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>'; if ($is_sub_depot) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-z"' . ' name="del-after-z"' . ' checked="checked"' . ' />' . '<b> ' . __('Delete after successful extraction.', 'wp-photo-album-plus') . '</b>' . '</td>'; } echo '</tr>' . '</thead>' . '</table>' . '<table' . ' class="form-table wppa-table widefat"' . ' style="margin-top:0;"' . ' >' . '<tr>'; $ct = 0; $idx = '0'; foreach ($files as $file) { $ext = wppa_get_ext($file); if ($ext == 'zip') { echo '<td>' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' class="wppa-zip"' . ' checked="checked"' . ' /> ' . wppa_sanitize_file_name(basename($file)) . '</td>'; if ($ct == 3) { echo '</tr><tr>'; $ct = 0; } else { $ct++; } } $idx++; } echo '</tr>' . '</table>' . '</div>'; } // Dispay the albums ( .amf files ) if ($albumcount) { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >' . '<p><b>' . sprintf(_n('There is %d albumdefinition in the depot', 'There are %d albumdefinitions in the depot', $albumcount, 'wp-photo-album-plus'), $albumcount) . '</b></p>' . '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-amf"' . ' checked="checked"' . ' onchange="checkAll( \'all-amf\', \'.wppa-amf\' )"' . ' />' . '<b> ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>'; if ($is_sub_depot) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-a"' . ' name="del-after-a"' . ' checked="checked"' . ' />' . '<b> ' . __('Remove from depot after successful import, or if the album already exists.', 'wp-photo-album-plus') . '</b>' . '</td>'; } echo '</tr>' . '</thead>' . '</table>' . '<table' . ' class="form-table wppa-table widefat"' . ' style="margin-top:0;"' . ' >' . '<tr>'; $ct = 0; $idx = '0'; foreach ($files as $file) { $ext = wppa_get_ext($file); if ($ext == 'amf') { echo '<td>' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' class="wppa-amf"' . ' checked="checked"' . ' />' . ' ' . basename($file) . ' ' . stripslashes(wppa_get_meta_name($file, '( ')) . '</td>'; if ($ct == 3) { echo '</tr><tr>'; $ct = 0; } else { $ct++; } } $idx++; } echo '</tr>' . '</table>' . '</div>'; } // Display the single photos if ($photocount) { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >'; // Display the number of photos '<p><b>'; // Local if ($source_type == 'local') { if ($is_ngg) { printf(_n('There is %d photo in the ngg gallery', 'There are %d photos in the ngg gallery', $photocount, 'wp-photo-album-plus'), $photocount); } else { printf(_n('There is %d photo in the depot', 'There are %d photos in the depot', $photocount, 'wp-photo-album-plus'), $photocount); } } else { printf(_n('There is %d possible photo found remote', 'There are %d possible photos found remote', $photocount, 'wp-photo-album-plus'), $photocount); } // Tell if downsize on if (wppa_switch('resize_on_upload')) { echo ' ' . __('Photos will be downsized during import.', 'wp-photo-album-plus'); } echo '</b></p>'; // The album selection echo '<p class="hideifupdate" >' . __('Default album for import:', 'wp-photo-album-plus') . '<select name="wppa-photo-album" id="wppa-photo-album" >' . wppa_album_select_a(array('path' => wppa_switch('hier_albsel'), 'selected' => get_option('wppa-photo-album-import-' . wppa_get_user(), '0'), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true)) . '</select>' . __('Photos that have (<em>name</em>)[<em>album</em>] will be imported by that <em>name</em> in that <em>album</em>.', 'wp-photo-album-plus') . '</p>'; // Watermark if (wppa_switch('watermark_on') && (wppa_switch('watermark_user') || current_user_can('wppa_settings'))) { echo '<p>' . __('Apply watermark file:', 'wp-photo-album-plus') . '<select name="wppa-watermark-file" id="wppa-watermark-file" >' . wppa_watermark_file_select() . '</select>' . __('Position:', 'wp-photo-album-plus') . '<select name="wppa-watermark-pos" id="wppa-watermark-pos" >' . wppa_watermark_pos_select() . '</select>' . '</p>'; } // Header of photo list echo '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-pho"' . ($is_sub_depot ? 'checked="checked"' : '') . ' onchange="checkAll( \'all-pho\', \'.wppa-pho\' )"' . ' />' . '<b>' . ' ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>'; // Depot specific switches if ($is_sub_depot) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-p"' . ' name="del-after-p"' . ' checked="checked"' . ' />' . '<b>' . ' ' . __('Remove from depot after successful import.', 'wp-photo-album-plus') . '</b>' . '</td>' . '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-f"' . ' name="del-after-f"' . ' />' . '<b>' . ' ' . __('Remove from depot after failed import.', 'wp-photo-album-plus') . '</b>' . '</td>'; } // Nextgen import specific switches if ($is_ngg) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="cre-album"' . ' name="cre-album"' . ' checked="checked"' . ' value="' . esc_attr(basename($source)) . '"' . ' />' . '<b>' . ' ' . __('Import into album', 'wp-photo-album-plus') . ' ' . basename($source) . '</b>' . '<small>' . __('The album will be created if it does not exist', 'wp-photo-album-plus') . '</small>' . '</td>' . '<td>' . '<input' . ' type="checkbox"' . ' id="use-backup"' . ' name="use-backup"' . ' checked="checked"' . ' />' . '<b>' . ' ' . __('Use backup if available', 'wp-photo-album-plus') . '</b>' . '</td>'; } // Update existing switch echo '<td>' . '<input' . ' type="checkbox"' . ' id="wppa-update"' . ' onchange="impUpd( this, \'#submit\' )"' . ' name="wppa-update"' . ' />' . '<b>' . ' ' . __('Update existing photos', 'wp-photo-album-plus') . '</b>' . '</td>'; // Void dups switch echo '<td>'; if (wppa_switch('void_dups')) { echo '<input' . ' type="hidden"' . ' id="wppa-nodups"' . ' name="wppa-nodups"' . ' value="true"' . ' />'; } else { echo '<input' . ' type="checkbox"' . ' id="wppa-nodups"' . ' name="wppa-nodups"' . ' checked="checked"' . ' />' . '<b>' . ' ' . __('Do not create duplicates', 'wp-photo-album-plus') . '</b>'; } echo '</td>'; // Import preview zoomable switch if (wppa_switch('import_preview')) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="wppa-zoom"' . ' onclick="wppa_setCookie(\'zoompreview\', this.checked, \'365\')"' . ' />' . '<b>' . ' ' . __('Zoom previews', 'wp-photo-album-plus') . '</b>' . '<script type="text/javascript">if ( wppa_getCookie(\'zoompreview\') == true ) { jQuery(\'#wppa-zoom\').attr(\'checked\', \'checked\') }</script>' . '</td>'; } echo '</tr>' . '</thead>' . '</table>'; // Photo list echo '<table class="form-table wppa-table widefat" style="margin-top:0;" >' . '<tr>'; $ct = 0; $idx = '0'; if (is_array($files)) { foreach ($files as $file) { $ext = wppa_get_ext($file); $meta = wppa_strip_ext($file) . '.PMF'; if (!is_file($meta)) { $meta = wppa_strip_ext($file) . '.pmf'; } if (!is_file($meta)) { $meta = false; } if (in_array(strtolower($ext), $wppa_supported_photo_extensions)) { echo '<td id="td-file-' . $idx . '" >' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' title="' . esc_attr($file) . '"' . ' class="wppa-pho"' . ($is_sub_depot ? 'checked="checked"' : '') . '/ >' . '<span' . ' id="name-file-' . $idx . '"' . ' >' . ' '; if (wppa('is_wppa_tree')) { $t = explode('uploads/wppa/', $file); echo $t[1]; } else { echo wppa_sanitize_file_name(basename($file)); } if ($meta) { echo ' ' . stripslashes(wppa_get_meta_name($meta, '( ')) . stripslashes(wppa_get_meta_album($meta, '[')); } echo '</span>'; if (wppa_switch('import_preview')) { if (wppa('is_remote')) { if (strpos($file, '//res.cloudinary.com/') !== false) { $img_url = dirname($file) . '/h_144/' . basename($file); } else { $img_url = $file; } } else { $img_url = str_replace(ABSPATH, home_url() . '/', $file); } echo '<img src="' . $img_url . '"' . ' alt="N.A."' . ' style="max-height:48px;"' . ' onmouseover="if (jQuery(\'#wppa-zoom\').attr(\'checked\')) jQuery(this).css(\'max-height\', \'144px\')"' . ' onmouseout="if (jQuery(\'#wppa-zoom\').attr(\'checked\')) jQuery(this).css(\'max-height\', \'48px\')"' . ' />'; } echo '</td>'; if ($ct == 3) { echo '</tr><tr>'; $ct = 0; } else { $ct++; } } $idx++; } } echo '</tr>' . '</table>' . '</div>'; } // Display the videos if ($videocount && wppa_switch('enable_video')) { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >'; // Display available files echo '<p><b>' . sprintf(_n('There is %d video in the depot', 'There are %d videos in the depot', $videocount, 'wp-photo-album-plus'), $videocount) . '</b></p>'; // Album to import to echo '<p class="hideifupdate" >' . __('Album to import to:', 'wp-photo-album-plus') . '<select name="wppa-video-album" id="wppa-video-album">' . wppa_album_select_a(array('path' => wppa_switch('hier_albsel'), 'selected' => get_option('wppa-video-album-import-' . wppa_get_user(), '0'), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true)) . '</select>' . '</p>'; // Header of video list echo '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-video"' . ' checked="checked"' . ' onchange="checkAll( \'all-video\', \'.wppa-video\' )"' . ' />' . '<b>' . ' ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>'; if ($is_sub_depot) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-v"' . ' name="del-after-v"' . ' checked="checked"' . ' />' . '<b>' . ' ' . __('Remove from depot after successful import.', 'wp-photo-album-plus') . ' <small>' . __('Files larger than 64MB will always be removed after successful import.', 'wp-photo-album-plus') . '</small>' . '</b>' . '</td>'; } echo '</tr>' . '</thead>' . '</table>'; // Video list echo '<table class="form-table wppa-table widefat" style="margin-top:0;" >' . '<tr>'; $ct = 0; $idx = '0'; if (is_array($files)) { foreach ($files as $file) { $ext = strtolower(substr(strrchr($file, "."), 1)); if (in_array(strtolower($ext), $wppa_supported_video_extensions)) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' title="' . $file . '"' . ' class="wppa-video"' . ' checked="checked"' . ' />' . '<span' . ' id="name-file-' . $idx . '"' . ' >' . ' ' . wppa_sanitize_file_name(basename($file)) . '</span>' . '</td>'; if ($ct == 3) { echo '</tr><tr>'; $ct = 0; } else { $ct++; } } $idx++; } } echo '</tr>' . '</table>' . '</div>'; } // Display the audios if ($audiocount && wppa_switch('enable_audio')) { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >'; // Display available files echo '<p><b>' . sprintf(_n('There is %d audio in the depot', 'There are %d audios in the depot', $audiocount, 'wp-photo-album-plus'), $audiocount) . '</b></p>'; // Album to import to echo '<p class="hideifupdate" >' . __('Album to import to:', 'wp-photo-album-plus') . '<select name="wppa-audio-album" id="wppa-audio-album" >' . wppa_album_select_a(array('path' => wppa_switch('hier_albsel'), 'selected' => get_option('wppa-audio-album-import-' . wppa_get_user(), '0'), 'addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true)) . '</select>' . '</p>'; // Header of audio list echo '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-audio"' . ' checked="checked"' . ' onchange="checkAll( \'all-audio\', \'.wppa-audio\' )"' . ' />' . '<b>' . ' ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>'; // The remove box if ($is_sub_depot) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-u"' . ' name="del-after-u"' . ' checked="checked"' . ' />' . '<b>' . ' ' . __('Remove from depot after successful import.', 'wp-photo-album-plus') . '</b>' . '</td>'; } echo '</tr>' . '</thead>' . '</table>'; // Audio list echo '<table class="form-table wppa-table widefat" style="margin-top:0;" >' . '<tr>'; $ct = 0; $idx = '0'; if (is_array($files)) { foreach ($files as $file) { $ext = strtolower(substr(strrchr($file, "."), 1)); if (in_array(strtolower($ext), $wppa_supported_audio_extensions)) { echo '<td>' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' title="' . $file . '"' . ' class="wppa-audio"' . ' checked="checked"' . ' />' . '<span' . ' id="name-file-' . $idx . '"' . ' >' . ' ' . wppa_sanitize_file_name(basename($file)) . '</span>' . '</td>'; if ($ct == 3) { echo '</tr><tr>'; $ct = 0; } else { $ct++; } } $idx++; } } echo '</tr>' . '</table>' . '</div>'; } // Display the directories to be imported as albums. Do this in the depot only!! if ($is_depot && $dircount) { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >'; // Display number of dirs echo '<p><b>' . sprintf(_n('There is %d albumdirectory in the depot', 'There are %d albumdirectories in the depot', $dircount, 'wp-photo-album-plus'), $dircount) . '</b></p>'; // Header of dirlist echo '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-dir"' . ' checked="checked"' . ' onchange="checkAll( \'all-dir\', \'.wppa-dir\' )"' . ' />' . '<b>' . ' ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>' . '</tr>' . '</thead>' . '</table>'; // Dirlist echo '<table class="form-table wppa-table widefat" style="margin-top:0;" >'; $ct = 0; $idx = '0'; foreach ($files as $dir) { if (basename($dir) == '.') { } elseif (basename($dir) == '..') { } elseif (is_dir($dir)) { echo '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' class= "wppa-dir"' . ' checked="checked"' . ' />' . ' ' . '<b>' . wppa_sanitize_file_name(basename($dir)) . '</b>'; $subfiles = glob($dir . '/*'); $subdircount = '0'; if ($subfiles) { foreach ($subfiles as $subfile) { if (is_dir($subfile) && basename($subfile) != '.' && basename($subfile) != '..') { $subdircount++; } } } $sfcount = empty($subfiles) ? '0' : wppa_get_photocount($subfiles); echo ' ' . sprintf(_n('Contains %d file', 'Contains %d files', $sfcount, 'wp-photo-album-plus'), $sfcount); if ($subdircount) { echo ' ' . sprintf(_n('and %d subdirectory', 'and %d subdirectories', $subdircount, 'wp-photo-album-plus'), $subdircount); } '</td>' . '</tr>'; } $idx++; } echo '</table>' . '</div>'; } // Display the csv files if ($is_depot && $csvcount) { echo '<div style="border:1px solid gray; padding:4px; margin: 3px 0;" >'; // Display number of files echo '<p><b>' . sprintf(_n('There is %d .csv file in the depot', 'There are %d .csv files in the depot', $csvcount, 'wp-photo-album-plus'), $csvcount) . '</b></p>'; // Header of .csv file list echo '<table class="form-table wppa-table widefat" style="margin-bottom:0;" >' . '<thead>' . '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="all-csv"' . ' checked="checked"' . ' onchange="checkAll( \'all-csv\', \'.wppa-csv\' )"' . ' />' . '<b>' . ' ' . __('Check/uncheck all', 'wp-photo-album-plus') . '</b>' . '</td>' . '<td>' . '<input' . ' type="checkbox"' . ' id="del-after-c"' . ' name="del-after-c"' . ' checked="checked"' . ' disabled="disabled"' . ' />' . '<b>' . ' ' . __('Remove from depot after successful import.', 'wp-photo-album-plus') . '</b>' . '</td>' . '</tr>' . '</thead>' . '</table>'; // CSV file list echo '<table class="form-table wppa-table widefat" style="margin-top:0;" >'; $ct = 0; $idx = '0'; foreach ($files as $csv) { if (is_file($csv) && strtolower(wppa_get_ext($csv)) == 'csv') { echo '<tr>' . '<td>' . '<input' . ' type="checkbox"' . ' id="file-' . $idx . '"' . ' name="file-' . $idx . '"' . ' class="wppa-csv"' . ' checked="checked"' . ' />' . ' ' . '<b>' . wppa_sanitize_file_name(basename($csv)) . ' (' . sprintf('%5.1f', filesize($csv) / 1024) . ' kb)' . '</b>' . '</td>' . '</tr>'; } $idx++; } echo '</table>' . '</div>'; } // The submit button ?> <p> <script type="text/javascript"> function wppaVfyAlbum() { var csvs = jQuery( '.wppa-csv' ); if ( jQuery( '#wppa-update' ).attr( 'checked' ) != 'checked' ) { if ( ! parseInt( jQuery( '#wppa-photo-album' ).attr( 'value' ) ) && ! parseInt( jQuery( '#wppa-video-album' ).attr( 'value' ) ) && ! parseInt( jQuery( '#wppa-audio-album' ).attr( 'value' ) ) && csvs.length == 0 ) { alert( 'Please select an album first' ); return false; } } return true; } function wppaCheckInputVars() { var checks = jQuery( ':checked' ); var nChecks = checks.length; var nMax = <?php echo ini_get('max_input_vars'); ?> ; if ( nMax == 0 ) nMax = 100; if ( nChecks > nMax ) { alert ( 'There are '+nChecks+' boxes checked or selected, that is more than the maximum allowed number of '+nMax ); return false; } var dirs = jQuery( '.wppa-dir' ); var nDirsChecked = 0; if ( dirs.length > 0 ) { var i = 0; while ( i < dirs.length ) { if ( jQuery( dirs[i] ).attr( 'checked' ) == 'checked' ) { nDirsChecked++; } i++; } } var zips = jQuery( '.wppa-zip' ); var nZipsChecked = 0; if ( zips.length > 0 ) { var i = 0; while ( i < zips.length ) { if ( jQuery( zips[i] ).attr( 'checked' ) == 'checked' ) { nZipsChecked++; } i++; } } // If no dirs to import checked, there must be an album selected if ( 0 == nDirsChecked && 0 == nZipsChecked && ! wppaVfyAlbum() ) return false; return true; } </script> <input type="submit" onclick="return wppaCheckInputVars()" class="button-primary" id="submit" name="wppa-import-submit" value="<?php _e('Import', 'wp-photo-album-plus'); ?> " /> <script type="text/javascript" > var wppaImportRuns = false; function wppaDoAjaxImport() { wppaImportRuns = true; var data = ''; data += 'wppa-update-check='+jQuery( '#wppa-update-check' ).attr( 'value' ); data += '&wppa-photo-album='+jQuery( '#wppa-photo-album' ).attr( 'value' ); data += '&wppa-video-album='+jQuery( '#wppa-video-album' ).attr( 'value' ); data += '&wppa-audio-album='+jQuery( '#wppa-audio-album' ).attr( 'value' ); data += '&wppa-watermark-file='+jQuery( '#wppa-watermark-file' ).attr( 'value' ); data += '&wppa-watermark-pos='+jQuery( '#wppa-watermark-pos' ).attr( 'value' ); if ( jQuery( '#cre-album' ).attr( 'checked' ) ) data += '&cre-album='+jQuery( '#cre-album' ).attr( 'value' ); if ( jQuery( '#use-backup' ).attr( 'checked' ) ) data += '&use-backup=on'; //+jQuery( '#use-backup' ).attr( 'value' ); if ( jQuery( '#wppa-update' ).attr( 'checked' ) ) data += '&wppa-update=on'; //+jQuery( '#wppa-update' ).attr( 'value' ); if ( jQuery( '#wppa-nodups' ).attr( 'checked' ) ) data += '&wppa-nodups=on'; //+jQuery( '#wppa-nudups' ).attr( 'value' ); if ( jQuery( '#del-after-p' ).attr( 'checked' ) ) data += '&del-after-p=on'; if ( jQuery( '#del-after-f' ).attr( 'checked' ) ) data += '&del-after-f=on'; if ( jQuery( '#del-after-v' ).attr( 'checked' ) ) data += '&del-after-v=on'; if ( jQuery( '#del-after-u' ).attr( 'checked' ) ) data += '&del-after-u=on'; data += '&wppa-import-submit=ajax'; var files = jQuery( ':checked' ); var found = false; var i=0; var elm; var fulldata; for ( i=0; i<files.length; i++ ) { found = false; // assume done elm = files[i]; // Is it a file checkbox? var temp = elm.id.split( '-' ); if ( temp[0] != 'file' ) continue; // no fulldata = data+'&import-ajax-file='+elm.title; found = true; break; } // alert( data ); if ( ! found ) { wppaStopAjaxImport(); return; // nothing left } // found one, do it var oldhtml=jQuery( '#name-'+elm.id ).html(); var xmlhttp = wppaGetXmlHttp(); xmlhttp.onreadystatechange = function() { if ( xmlhttp.readyState == 4 ) { if ( xmlhttp.status!=404 ) { var resp = xmlhttp.responseText; // if ( resp.length == 0 ) { jQuery( '#name-'+elm.id ).html('<span style="color:red" >Timeout</span>' ); wppaStopAjaxImport(); return; } // if ( resp.indexOf( 'Server' ) != -1 && resp.indexOf( 'Error' ) != -1 ) { resp = '<span style="color:red" >Server error</span>'; } jQuery( '#name-'+elm.id ).html( ' <b>'+resp+'</b>' ); elm.checked = ''; if ( jQuery( '#del-after-p' ).attr( 'checked' ) || jQuery( '#del-after-f' ).attr( 'checked' ) ) { elm.disabled = 'disabled'; elm.title = ''; } if ( wppaImportRuns ) { setTimeout( 'wppaDoAjaxImport()', 100 ); } } else { jQuery( '#name-'+elm.id ).html( ' <b>Not found</b>' ); } } } var url = wppaAjaxUrl+'?action=wppa&wppa-action=import'; xmlhttp.open( 'POST',url,true ); xmlhttp.setRequestHeader( "Content-type","application/x-www-form-urlencoded" ); xmlhttp.send( fulldata ); jQuery( '#name-'+elm.id ).html( ' <b style="color:blue" >' + '<?php _e('Working...', 'wp-photo-album-plus'); ?> ' + '</b>' ); jQuery( '#wppa-start-ajax' ).css( 'display', 'none' ); jQuery( '#wppa-stop-ajax' ).css( 'display', 'inline' ); } function wppaStopAjaxImport() { wppaImportRuns = false; jQuery( '#wppa-start-ajax' ).css( 'display', 'inline' ); jQuery( '#wppa-stop-ajax' ).css( 'display', 'none' ); } </script> <?php if (($photocount || $videocount || $audiocount) && !$albumcount && !$dircount && !$zipcount) { ?> <input id="wppa-start-ajax" type="button" onclick="if ( wppaVfyAlbum() ) { wppaDoAjaxImport() }" class="button-secundary" value="<?php esc_attr(_e('Start Ajax Import', 'wp-photo-album-plus')); ?> " /> <input id="wppa-stop-ajax" style="display:none;" type="button" onclick="wppaStopAjaxImport()" class="button-secundary" value="<?php esc_attr(_e('Stop Ajax Import', 'wp-photo-album-plus')); ?> " /> <?php } ?> </p> </form> <?php } else { if ($source_type == 'local') { wppa_ok_message(__('There are no importable files found in directory:', 'wp-photo-album-plus') . ' ' . $source); } else { wppa_ok_message(__('There are no photos found or left to process at url:', 'wp-photo-album-plus') . ' ' . $source_url); } } echo '<br /><b>'; _e('You can import the following file types:', 'wp-photo-album-plus'); echo '</b><br />'; if (PHP_VERSION_ID >= 50207) { echo '<br />'; _e('Compressed file types: .zip', 'wp-photo-album-plus'); } if (true) { echo '<br />'; _e('Photo file types:', 'wp-photo-album-plus'); foreach ($wppa_supported_photo_extensions as $ext) { echo ' .' . $ext; } } if (wppa_switch('enable_video')) { echo '<br />'; _e('Video file types:', 'wp-photo-album-plus'); foreach ($wppa_supported_video_extensions as $ext) { echo ' .' . $ext; } } if (wppa_switch('enable_audio')) { echo '<br />'; _e('Audio file types:', 'wp-photo-album-plus'); foreach ($wppa_supported_audio_extensions as $ext) { echo ' .' . $ext; } } echo '<br />'; _e('WPPA+ file types: .amf .pmf', 'wp-photo-album-plus'); echo '<br />'; _e('Directories with optional subdirs containig photos', 'wp-photo-album-plus'); echo '<br />'; _e('Custom data files of type .csv', 'wp-photo-album-plus'); echo '<br /><br />'; _e('Your depot directory is:', 'wp-photo-album-plus'); echo '<b> .../' . WPPA_DEPOT . '/</b>'; if (wppa('continue')) { wppa_warning_message(__('Trying to continue...', 'wp-photo-album-plus')); echo '<script type="text/javascript">document.location=\'' . get_admin_url() . 'admin.php?page=wppa_import_photos&continue&nonce=' . wp_create_nonce('dirimport') . '\';</script>'; } echo '<br /><br />'; wppa_album_admin_footer(); echo '</div><!-- .wrap -->'; }
function wppa_admin_albums_collapsable() { global $wpdb; // Init $pagesize = wppa_opt('album_admin_pagesize'); $page = '1'; $skips = '0'; $pages = '1'; // Find out what page to show if ($pagesize) { if (isset($_REQUEST['album-page-no'])) { $page = strval(intval($_REQUEST['album-page-no'])); $page = max($page, '1'); $skips = ($page - 1) * $pagesize; } } // Read all albums, pre-ordered $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` ORDER BY " . get_option('wppa_album_order_' . wppa_get_user(), 'id') . (get_option('wppa_album_order_' . wppa_get_user() . '_reverse') == 'yes' ? " DESC" : ""), ARRAY_A); // Remove non accessable albums $temp = $albums; $albums = array(); foreach (array_keys($temp) as $idx) { if (wppa_have_access($temp[$idx]['id'])) { $albums[] = $temp[$idx]; } } $count = count($albums); // If pagination: Make new array with selected albums only if ($pagesize) { $temp = $albums; $albums = array(); $i = 0; foreach ($temp as $item) { if ($i < $skips) { } elseif ($i >= $skips + $pagesize) { } else { $albums[] = $item; } $i++; } } // Make sure all (grand)parents are in $done = false; while (!$done) { $done = true; foreach ($albums as $a) { $parent = $a['a_parent']; if ($parent > '0') { $found = false; foreach ($albums as $p) { if ($p['id'] == $parent) { $found = true; } } if (!$found) { $done = false; // Add missing parent $albums[] = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `id` = %d", $parent), ARRAY_A); } } } } // Find the ordering method $reverse = false; if (isset($_REQUEST['order_by'])) { $order = $_REQUEST['order_by']; } else { $order = ''; } if (!$order) { $order = get_option('wppa_album_order_' . wppa_get_user(), 'id'); $reverse = get_option('wppa_album_order_' . wppa_get_user() . '_reverse') == 'yes'; } else { $old_order = get_option('wppa_album_order_' . wppa_get_user(), 'id'); $reverse = get_option('wppa_album_order_' . wppa_get_user() . '_reverse') == 'yes'; if ($old_order == $order) { $reverse = !$reverse; } else { $reverse = false; } update_option('wppa_album_order_' . wppa_get_user(), $order); if ($reverse) { update_option('wppa_album_order_' . wppa_get_user() . '_reverse', 'yes'); } else { update_option('wppa_album_order_' . wppa_get_user() . '_reverse', 'no'); } } if (!empty($albums)) { // Setup the sequence array $seq = false; $num = false; foreach ($albums as $album) { switch ($order) { case 'name': $seq[] = strtolower(__(stripslashes($album['name']))); break; case 'description': $seq[] = strtolower(__(stripslashes($album['description']))); break; case 'owner': $seq[] = strtolower($album['owner']); break; case 'a_order': $seq[] = $album['a_order']; $num = true; break; case 'a_parent': $seq[] = strtolower(wppa_get_album_name($album['a_parent']), 'extended'); break; default: $seq[] = $album['id']; $num = true; break; } } // Sort the seq array if ($num) { asort($seq, SORT_NUMERIC); } else { asort($seq, SORT_REGULAR); } // Reverse ? if ($reverse) { $t = $seq; $c = count($t); $tmp = array_keys($t); $seq = false; for ($i = $c - 1; $i >= 0; $i--) { $seq[$tmp[$i]] = '0'; } } $downimg = '<img src="' . wppa_get_imgdir() . 'down.png" alt="down" style=" height:12px; position:relative; top:2px; " />'; $upimg = '<img src="' . wppa_get_imgdir() . 'up.png" alt="up" style=" height:12px; position:relative; top:2px; " />'; wppa_album_table_pagination($page, $count); ?> <table class="widefat wppa-table wppa-setting-table" style="margin-top:12px;" > <thead> <tr> <td style="min-width:20px;" > <img src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " style="height:16px;" title="<?php _e('Collapse subalbums', 'wp-photo-album-plus'); ?> " /> <img src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " style="height:16px;" title="<?php _e('Expand subalbums', 'wp-photo-album-plus'); ?> " /> </td> <?php $url = get_admin_url() . 'admin.php?page=wppa_admin_menu&order_by='; ?> <td colspan="6" style="min-width: 50px;" > <a href="<?php echo wppa_dbg_url($url . 'id'); ?> "> <?php _e('ID', 'wp-photo-album-plus'); if ($order == 'id') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="min-width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'name'); ?> "> <?php _e('Name', 'wp-photo-album-plus'); if ($order == 'name') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td > <a href="<?php echo wppa_dbg_url($url . 'description'); ?> "> <?php _e('Description', 'wp-photo-album-plus'); if ($order == 'description') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php if (current_user_can('administrator')) { ?> <td style="min-width: 100px;"> <a href="<?php echo wppa_dbg_url($url . 'owner'); ?> "> <?php _e('Owner', 'wp-photo-album-plus'); if ($order == 'owner') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php } ?> <td style="min-width: 100px;" > <a href="<?php echo wppa_dbg_url($url . 'a_order'); ?> "> <?php _e('Order', 'wp-photo-album-plus'); if ($order == 'a_order') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'a_parent'); ?> "> <?php _e('Parent', 'wp-photo-album-plus'); if ($order == 'a_parent') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td title="<?php _e('Albums/Photos/Moderation required/Scheduled', 'wp-photo-album-plus'); ?> " > <?php _e('A/P/PM/S', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Edit', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Quick', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Bulk', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Seq', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Delete', 'wp-photo-album-plus'); ?> </td> <?php if (wppa_can_create_album()) { echo '<td >' . __('Create', 'wp-photo-album-plus') . '</td>'; } ?> </tr> </thead> <tbody> <?php wppa_do_albumlist('0', '0', $albums, $seq); ?> <?php if ($wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = '-1'") > 0) { ?> <tr> <td colspan="19" ><em><?php _e('The following albums are ---separate--- and do not show up in the generic album display', 'wp-photo-album-plus'); ?> </em></td> </tr> <?php wppa_do_albumlist('-1', '0', $albums, $seq); ?> <?php } wppa_search_edit(true); ?> </tbody> <tfoot> <tr> <td> <img src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " style="height:16px;" /> <img src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " style="height:16px;" /> </td> <?php $url = get_admin_url() . 'admin.php?page=wppa_admin_menu&order_by='; ?> <td colspan="6" > <a href="<?php echo wppa_dbg_url($url . 'id'); ?> "> <?php _e('ID', 'wp-photo-album-plus'); if ($order == 'id') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'name'); ?> "> <?php _e('Name', 'wp-photo-album-plus'); if ($order == 'name') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td > <a href="<?php echo wppa_dbg_url($url . 'description'); ?> "> <?php _e('Description', 'wp-photo-album-plus'); if ($order == 'description') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php if (current_user_can('administrator')) { ?> <td style="width: 100px;"> <a href="<?php echo wppa_dbg_url($url . 'owner'); ?> "> <?php _e('Owner', 'wp-photo-album-plus'); if ($order == 'owner') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <?php } ?> <td > <a href="<?php echo wppa_dbg_url($url . 'a_order'); ?> "> <?php _e('Order', 'wp-photo-album-plus'); if ($order == 'a_order') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td style="width: 120px;"> <a href="<?php echo wppa_dbg_url($url . 'a_parent'); ?> "> <?php _e('Parent', 'wp-photo-album-plus'); if ($order == 'a_parent') { if ($reverse) { echo $upimg; } else { echo $downimg; } } ?> </a> </td> <td title="<?php _e('Albums/Photos/Moderation required/Scheduled', 'wp-photo-album-plus'); ?> " > <?php _e('A/P/PM/S', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Edit', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Quick', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Bulk', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Seq', 'wp-photo-album-plus'); ?> </td> <td ><?php _e('Delete', 'wp-photo-album-plus'); ?> </td> <?php if (wppa_can_create_album()) { echo '<td >' . __('Create', 'wp-photo-album-plus') . '</td>'; } ?> </tr> </tfoot> </table> <script type="text/javascript" > function checkArrows() { elms = jQuery('.alb-arrow-off'); for(i=0;i<elms.length;i++) { elm = elms[i]; if ( elm.parentNode.parentNode.style.display == 'none' ) elm.style.display = 'none'; } elms = jQuery('.alb-arrow-on'); for(i=0;i<elms.length;i++) { elm = elms[i]; if ( elm.parentNode.parentNode.style.display == 'none' ) elm.style.display = ''; } } </script> <?php wppa_album_table_pagination($page, $count); wppa_album_admin_footer(); } else { ?> <p><?php _e('No albums yet.', 'wp-photo-album-plus'); ?> </p> <?php } }