/** * Check the Quota under WPMU. Only needed for this case * * @class nggWPMU * @return bool $result */ function check_quota() { if (get_site_option('upload_space_check_disabled')) { return false; } if (is_multisite() && nggWPMU::wpmu_enable_function('wpmuQuotaCheck')) { if ($error = upload_is_user_over_quota(false)) { nggGallery::show_error(__('Sorry, you have used your space allocation. Please delete some files to upload more files.', 'nggallery')); return true; } } return false; }
/** * Copy images to another gallery * * @class nggAdmin * @param array|int $pic_ids ID's of the images * @param int $dest_gid destination gallery * @return void */ function copy_images($pic_ids, $dest_gid) { require_once NGGALLERY_ABSPATH . '/lib/meta.php'; $errors = $messages = ''; if (!is_array($pic_ids)) { $pic_ids = array($pic_ids); } // Get destination gallery $destination = nggdb::find_gallery($dest_gid); if ($destination == null) { nggGallery::show_error(__('The destination gallery does not exist', 'nggallery')); return; } // Check for folder permission if (!is_writeable(WINABSPATH . $destination->path)) { $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path); nggGallery::show_error($message); return; } // Get pictures $images = nggdb::find_images_in_list($pic_ids); $destination_path = WINABSPATH . $destination->path; foreach ($images as $image) { // WPMU action if (nggWPMU::check_quota()) { return; } $i = 0; $tmp_prefix = ''; $destination_file_name = $image->filename; while (file_exists($destination_path . '/' . $destination_file_name)) { $tmp_prefix = 'copy_' . $i++ . '_'; $destination_file_name = $tmp_prefix . $image->filename; } $destination_file_path = $destination_path . '/' . $destination_file_name; $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name; // Copy files if (!@copy($image->imagePath, $destination_file_path)) { $errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />'; continue; } // Copy backup file, if possible @copy($image->imagePath . '_backup', $destination_file_path . '_backup'); // Copy the thumbnail if possible @copy($image->thumbPath, $destination_thumb_file_path); // Create new database entry for the image $new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude); if (!isset($new_pid)) { $errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />'; continue; } // Copy tags nggTags::copy_tags($image->pid, $new_pid); // Copy meta information $meta = new nggMeta($image->pid); nggdb::update_image_meta($new_pid, $meta->image->meta_data); if ($tmp_prefix != '') { $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) » The file already existed in the destination gallery.', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />'; } else { $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />'; } } // Finish by showing errors or success if ($errors == '') { $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>'; $messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'nggallery'), count($images), $link); } if ($messages != '') { nggGallery::show_message($messages); } if ($errors != '') { nggGallery::show_error($errors); } return; }
function nggallery_picturelist() { // *** show picture list global $wpdb, $nggdb, $user_ID, $ngg; // Look if its a search result $is_search = isset($_GET['s']) ? true : false; $counter = 0; $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images'); if ($is_search) { // fetch the imagelist $picturelist = $ngg->manage_page->search_result; // we didn't set a gallery or a pagination $act_gid = 0; $_GET['paged'] = 1; $page_links = false; } else { // GET variables $act_gid = $ngg->manage_page->gid; // Load the gallery metadata $gallery = $nggdb->find_gallery($act_gid); if (!$gallery) { nggGallery::show_error(__('Gallery not found.', 'nggallery')); return; } // Check if you have the correct capability if (!nggAdmin::can_manage_this_gallery($gallery->author)) { nggGallery::show_error(__('Sorry, you have no access here', 'nggallery')); return; } // look for pagination $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1; $start = ($_GET['paged'] - 1) * 50; // get picture values $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start); // get the current author $act_author_user = get_userdata((int) $gallery->author); } // list all galleries $gallerylist = $nggdb->find_all_galleries(); //get the columns $image_columns = $wp_list_table->get_columns(); $hidden_columns = get_hidden_columns('nggallery-manage-images'); $num_columns = count($image_columns) - count($hidden_columns); $attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"'; ?> <script type="text/javascript"> <!-- function showDialog( windowId, title ) { var form = document.getElementById('updategallery'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value; else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // now show the dialog jQuery( "#" + windowId ).dialog({ width: 640, resizable : false, modal: true, title: title, position: { my: 'center', at: 'center', of: window.parent } }); jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); }); } jQuery(function (){ jQuery('span.tooltip, label.tooltip').tooltip(); // load a content via ajax jQuery('a.ngg-dialog').click(function() { var dialogs = jQuery('.ngg-overlay-dialog:visible'); if (dialogs.size() > 0) { return false; } if ( jQuery( "#spinner" ).length == 0) { jQuery("body").append('<div id="spinner"></div>'); } var $this = jQuery(this); var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href); var width = ( results ) ? results[1] : 600; var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href); var height = ( results ) ? results[1] : 440; var container = window; if (window.parent) { container = window.parent; } jQuery('#spinner').fadeIn(); jQuery('#spinner').position({ my: "center", at: "center", of: container }); var dialog = jQuery('<div class="ngg-overlay-dialog" style="display:hidden"></div>').appendTo('body'); // load the remote content dialog.load( this.href, {}, function () { jQuery('#spinner').hide(); dialog.dialog({ title: ($this.attr('title')) ? $this.attr('title') : '', position: { my: "center", at: "center", of: container }, width: width, height: height, modal: true, resizable: false, close: function() { dialog.remove(); } }).width(width - 30).height(height - 30); } ); //prevent the browser to follow the link return false; }); }); function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('updategallery')); if (typeof document.activeElement == "undefined" && document.addEventListener) { document.addEventListener("focus", function (e) { document.activeElement = e.target; }, true); } if ( document.activeElement.name == 'post_paged' ) return true; if(numchecked < 1) { alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?> '); return false; } actionId = jQuery('#bulkaction').val(); switch (actionId) { case "copy_to": showDialog('selectgallery', '<?php echo esc_js(__('Copy image to...', 'nggallery')); ?> '); return false; break; case "move_to": showDialog('selectgallery', '<?php echo esc_js(__('Move image to...', 'nggallery')); ?> '); return false; break; case "add_tags": showDialog('entertags', '<?php echo esc_js(__('Add new tags', 'nggallery')); ?> '); return false; break; case "delete_tags": showDialog('entertags', '<?php echo esc_js(__('Delete tags', 'nggallery')); ?> '); return false; break; case "overwrite_tags": showDialog('entertags', '<?php echo esc_js(__('Overwrite', 'nggallery')); ?> '); return false; break; case "resize_images": showDialog('resize_images', '<?php echo esc_js(__('Resize images', 'nggallery')); ?> '); return false; break; case "new_thumbnail": showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails', 'nggallery')); ?> '); return false; break; } return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } jQuery(document).ready( function($) { if ($(this).data('ready')) return; // close postboxes that should be closed jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); postboxes.add_postbox_toggles('ngg-manage-gallery'); $(this).data('ready', true); }); //--> </script> <div class="wrap"> <?php //include('templates/social_media_buttons.php'); screen_icon('nextgen-gallery'); if ($is_search) { ?> <h2><?php printf(__('Search results for “%s”', 'nggallery'), esc_html(get_search_query())); ?> </h2> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="media-search-input"><?php _e('Search Images', 'nggallery'); ?> :</label> <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" /> <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search Images', 'nggallery'); ?> " class="button" /> </p> </form> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&s=' . get_search_query(); ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php } else { ?> <h2><?php echo _n('Gallery', 'Galleries', 1, 'nggallery'); ?> : <?php echo esc_html(nggGallery::i18n($gallery->title)); ?> </h2> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&gid=' . $act_gid . '&paged=' . $_GET['paged']; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php if (nggGallery::current_user_can('NextGEN Edit gallery options')) { ?> <div id="poststuff"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <h3><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></h3> <div class="inside"> <table class="form-table" > <tr> <th align="left"><?php _e('Title'); ?> :</th> <th align="left"><input <?php nggGallery::current_user_can_form('NextGEN Edit gallery title'); ?> type="text" size="50" name="title" value="<?php echo esc_attr(stripslashes($gallery->title)); ?> " /></th> <th align="right"><?php _e('Page Link to', 'nggallery'); ?> :</th> <th align="left"> <select <?php nggGallery::current_user_can_form('NextGEN Edit gallery page id'); ?> name="pageid" style="width:95%"> <option value="0" ><?php _e('Not linked', 'nggallery'); ?> </option> <?php foreach (get_pages() as $page) { ?> <option <?php selected($gallery->pageid, $page->ID); ?> value="<?php echo esc_attr($page->ID); ?> "><?php echo esc_html($page->post_title); ?> </option> <?php } ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Description'); ?> :</th> <th align="left"><textarea <?php nggGallery::current_user_can_form('NextGEN Edit gallery description'); ?> name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php echo esc_attr(stripslashes($gallery->galdesc)); ?> </textarea></th> <th align="right"><?php _e('Preview image', 'nggallery'); ?> :</th> <th align="left"> <select <?php nggGallery::current_user_can_form('NextGEN Edit gallery preview pic'); ?> name="previewpic" style="width:95%" > <option value="0" ><?php _e('No Picture', 'nggallery'); ?> </option> <?php // ensure that a preview pic from a other page is still shown here if (intval($gallery->previewpic) != 0) { if (!array_key_exists($gallery->previewpic, $picturelist)) { $previewpic = $nggdb->find_image($gallery->previewpic); if ($previewpic) { echo '<option value="' . $previewpic->pid . '" selected="selected" >' . $previewpic->pid . ' - ' . esc_attr($previewpic->filename) . '</option>' . "\n"; } } } if (is_array($picturelist)) { foreach ($picturelist as $picture) { if ($picture->exclude) { continue; } $selected = $picture->pid == $gallery->previewpic ? 'selected="selected" ' : ''; echo '<option value="' . $picture->pid . '" ' . $selected . '>' . $picture->pid . ' - ' . esc_attr($picture->filename) . '</option>' . "\n"; } } ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Path', 'nggallery'); ?> :</th> <th align="left"><input readonly="readonly" type="text" size="50" name="path" value="<?php echo $gallery->path; ?> " /></th> <th align="right"><?php _e('Author', 'nggallery'); ?> :</th> <th align="left"> <?php $editable_ids = $ngg->manage_page->get_editable_user_ids($user_ID); if ($editable_ids && count($editable_ids) > 1 && nggGallery::current_user_can('NextGEN Edit gallery author')) { wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author)); } else { echo $act_author_user->display_name; } ?> </th> </tr> <?php if (current_user_can('publish_pages')) { ?> <tr> <th align="left"> </th> <th align="left"> </th> <th align="right"> <label for='ngg_settings_parent_id' class='tooltip' title="Clicking <?php _e('Add Page'); ?> will create a new page with the same name as this gallery and will display the gallery on that new page. You can create a sub-page by selecting the parent page from the drop down."> <?php _e('Create new page', 'nggallery'); ?> : </label> </th> <th align="left"> <select name="parent_id" style="width:95%" id='ngg_settings_parent_id'> <option value="0"><?php _e('Main page (No parent)', 'nggallery'); ?> </option> <?php foreach (get_pages() as $page) { ?> <option value="<?php echo esc_attr($page->ID); ?> "><?php echo esc_html($page->post_title); ?> </option> <?php } ?> </select> <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e('Add page', 'nggallery'); ?> " id="group"/> </th> </tr> <?php } ?> <?php do_action('ngg_manage_gallery_settings', $act_gid); ?> </table> <div class="submit"> <?php if (wpmu_enable_function('wpmuScanFolder') && nggGallery::current_user_can('NextGEN Scan folder')) { ?> <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images", 'nggallery'); ?> " /> <?php } ?> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /> </div> </div> </div> </div> <!-- poststuff --> <?php } ?> <?php } ?> <div class="tablenav top ngg-tablenav"> <?php $ngg->manage_page->pagination('top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page']); ?> <div class="alignleft actions"> <select id="bulkaction" name="bulkaction"> <option value="no_action" ><?php _e("Bulk actions", 'nggallery'); ?> </option> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="recover_images" ><?php _e("Recover from backup", 'nggallery'); ?> </option> <option value="delete_images" ><?php _e("Delete images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="rotate_cw" ><?php _e("Rotate images clockwise", 'nggallery'); ?> </option> <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise", 'nggallery'); ?> </option> <option value="copy_to" ><?php _e("Copy to...", 'nggallery'); ?> </option> <option value="move_to"><?php _e("Move to...", 'nggallery'); ?> </option> <option value="add_tags" ><?php _e("Add tags", 'nggallery'); ?> </option> <option value="delete_tags" ><?php _e("Delete tags", 'nggallery'); ?> </option> <option value="overwrite_tags" ><?php _e("Overwrite tags", 'nggallery'); ?> </option> </select> <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php if ($ngg->options['galSort'] == "sortorder" && !$is_search) { ?> <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery'); ?> " /> <?php } ?> <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery'); ?> " /> </div> </div> <table id="ngg-listimages" class="widefat fixed" cellspacing="0" > <thead> <tr> <?php $wp_list_table->print_column_headers(true); ?> </tr> </thead> <tfoot> <tr> <?php $wp_list_table->print_column_headers(false); ?> </tr> </tfoot> <tbody id="the-list"> <?php if ($picturelist) { $thumbsize = ''; if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } foreach ($picturelist as $picture) { //for search result we need to check the capatibiliy if (!nggAdmin::can_manage_this_gallery($picture->author) && $is_search) { continue; } $counter++; $pid = (int) $picture->pid; $alternate = !isset($alternate) || $alternate == 'alternate' ? '' : 'alternate'; $exclude = $picture->exclude ? 'checked="checked"' : ''; $date = mysql2date(get_option('date_format'), $picture->imagedate); $time = mysql2date(get_option('time_format'), $picture->imagedate); ?> <tr id="picture-<?php echo $pid; ?> " class="<?php echo $alternate; ?> iedit" valign="top"> <?php foreach ($image_columns as $image_column_key => $column_display_name) { $class = "class='{$image_column_key} column-{$image_column_key}'"; $style = ''; if (in_array($image_column_key, $hidden_columns)) { $style = ' style="display:none;"'; } $attributes = $class . $style; switch ($image_column_key) { case 'cb': $attributes = 'class="column-cb check-column"' . $style; ?> <th <?php echo $attributes; ?> scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid; ?> " /></th> <?php break; case 'id': ?> <td <?php echo $attributes; ?> style=""><?php echo $pid; ?> <input type="hidden" name="pid[]" value="<?php echo $pid; ?> " /> </td> <?php break; case 'filename': $attributes = 'class="title column-filename column-title"' . $style; ?> <td <?php echo $attributes; ?> > <strong><a href="<?php echo nextgen_esc_url($picture->imageURL); ?> " class="thickbox" title="<?php echo esc_attr($picture->filename); ?> "> <?php echo empty($picture->alttext) ? esc_html($picture->filename) : esc_html(stripslashes(nggGallery::i18n($picture->alttext))); ?> </a></strong> <br /><?php echo $date; ?> <?php if (!empty($picture->meta_data)) { ?> <br /><?php echo $picture->meta_data['width']; ?> x <?php echo $picture->meta_data['height']; ?> <?php _e('pixel', 'nggallery'); ?> <?php } ?> <p> <?php $actions = array(); $actions['view'] = '<a class="shutter" href="' . nextgen_esc_url($picture->imageURL) . '" title="' . esc_attr(sprintf(__('View "%s"'), sanitize_title($picture->filename))) . '">' . __('View', 'nggallery') . '</a>'; $actions['meta'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data', 'nggallery') . '">' . __('Meta', 'nggallery') . '</a>'; $actions['custom_thumb'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail', 'nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>'; $actions['rotate'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate', 'nggallery') . '">' . __('Rotate', 'nggallery') . '</a>'; if (current_user_can('publish_posts')) { $actions['publish'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/publish.php?id=' . $pid . '&h=230" title="' . __('Publish this image', 'nggallery') . '">' . __('Publish', 'nggallery') . '</a>'; } if (file_exists($picture->imagePath . '_backup')) { $actions['recover'] = '<a class="confirmrecover" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&mode=recoverpic&gid=" . $act_gid . "&pid=" . $pid, 'ngg_recoverpicture') . '" title="' . __('Recover', 'nggallery') . '" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Recover "%s" ?', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Recover', 'nggallery') . '</a>'; } $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&mode=delpic&gid=" . $act_gid . "&pid=" . $pid, 'ngg_delpicture') . '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s" ?', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Delete') . '</a>'; $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; ?> </p> </td> <?php break; case 'thumbnail': $attributes = 'class="id column-thumbnail media-icon"' . $style; ?> <td <?php echo $attributes; ?> ><a href="<?php echo nextgen_esc_url(add_query_arg('i', mt_rand(), $picture->imageURL)); ?> " class="shutter" title="<?php echo $picture->filename; ?> "> <img class="thumb" src="<?php echo nextgen_esc_url(add_query_arg('i', mt_rand(), $picture->thumbURL)); ?> " id="thumb<?php echo $pid; ?> " /> </a> </td> <?php break; case 'alt_title_desc': ?> <td <?php echo $attributes; ?> > <input name="alttext[<?php echo $pid; ?> ]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo esc_attr(stripslashes($picture->alttext)); ?> " /><br/> <textarea name="description[<?php echo $pid; ?> ]" style="width:95%; margin-top: 2px;" rows="2" ><?php echo esc_attr(stripslashes($picture->description)); ?> </textarea> </td> <?php break; case 'exclude': ?> <td <?php echo $attributes; ?> ><input name="exclude[<?php echo $pid; ?> ]" type="checkbox" value="1" <?php echo $exclude; ?> /></td> <?php break; case 'tags': $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names'); if (is_array($picture->tags)) { $picture->tags = implode(', ', $picture->tags); } ?> <td <?php echo $attributes; ?> ><textarea name="tags[<?php echo $pid; ?> ]" style="width:95%;" rows="2"><?php echo $picture->tags; ?> </textarea></td> <?php break; default: ?> <td <?php echo $attributes; ?> ><?php do_action('ngg_manage_image_custom_column', $image_column_key, $pid); ?> </td> <?php break; } ?> <?php } ?> </tr> <?php } } // In the case you have no capaptibility to see the search result if ($counter == 0) { echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?> " /> <?php $ngg->manage_page->pagination('bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page']); ?> </div> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="entertags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e('Select the destination gallery:', 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo esc_attr(stripslashes($gallery->title)); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td> <?php include dirname(__FILE__) . '/thumbnails-template.php'; ?> </td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
function nggallery_picturelist($controller) { // *** show picture list global $wpdb, $nggdb, $user_ID, $ngg; // Look if its a search result $is_search = isset($_GET['s']) ? true : false; $counter = 0; $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images'); if ($is_search) { // fetch the imagelist $picturelist = $ngg->manage_page->search_result; // we didn't set a gallery or a pagination $act_gid = 0; $_GET['paged'] = 1; $page_links = false; } else { // GET variables $act_gid = $ngg->manage_page->gid; // Load the gallery metadata $mapper = C_Gallery_Mapper::get_instance(); $gallery = $mapper->find($act_gid); if (!$gallery) { nggGallery::show_error(__('Gallery not found.', 'nggallery')); return; } // Check if you have the correct capability if (!nggAdmin::can_manage_this_gallery($gallery->author)) { nggGallery::show_error(__('Sorry, you have no access here', 'nggallery')); return; } // look for pagination $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1; $items_per_page = 50; $start = ($_GET['paged'] - 1) * $items_per_page; // get picture values $image_mapper = C_Image_Mapper::get_instance(); $total_number_of_images = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $act_gid))->run_query(FALSE, TRUE)); $picturelist = $image_mapper->select()->where(array("galleryid = %d", $act_gid))->order_by($ngg->options['galSort'], $ngg->options['galSortDir'])->limit($items_per_page, $start)->run_query(); // get the current author $act_author_user = get_userdata((int) $gallery->author); } // list all galleries $gallerylist = $nggdb->find_all_galleries(); //get the columns $image_columns = $wp_list_table->get_columns(); $hidden_columns = get_hidden_columns('nggallery-manage-images'); $num_columns = count($image_columns) - count($hidden_columns); $attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"'; ?> <script type="text/javascript"> <!-- function showDialog( windowId, title ) { var form = document.getElementById('updategallery'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value; else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // now show the dialog jQuery( "#" + windowId ).dialog({ width: 640, resizable : false, modal: true, title: title, position: { my: 'center', at: 'center', of: window.parent } }); jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); }); } jQuery(function (){ jQuery('span.tooltip, label.tooltip').tooltip(); // load a content via ajax jQuery('a.ngg-dialog').click(function() { var dialogs = jQuery('.ngg-overlay-dialog:visible'); if (dialogs.size() > 0) { return false; } if ( jQuery( "#spinner" ).length == 0) { jQuery("body").append('<div id="spinner"></div>'); } var $this = jQuery(this); var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href); var width = ( results ) ? results[1] : 600; var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href); var height = ( results ) ? results[1] : 440; var container = window; if (window.parent) { container = window.parent; } jQuery('#spinner').fadeIn(); jQuery('#spinner').position({ my: "center", at: "center", of: container }); var dialog = jQuery('<div class="ngg-overlay-dialog" style="display:hidden"></div>').appendTo('body'); // load the remote content dialog.load( this.href, {}, function () { jQuery('#spinner').hide(); dialog.dialog({ title: ($this.attr('title')) ? $this.attr('title') : '', position: { my: "center", at: "center", of: container }, width: width, height: height, modal: true, resizable: false, close: function() { dialog.remove(); } }).width(width - 30).height(height - 30); } ); //prevent the browser to follow the link return false; }); }); function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('updategallery')); if (typeof document.activeElement == "undefined" && document.addEventListener) { document.addEventListener("focus", function (e) { document.activeElement = e.target; }, true); } if ( document.activeElement.name == 'post_paged' ) return true; if(numchecked < 1) { alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?> '); return false; } actionId = jQuery('#bulkaction').val(); switch (actionId) { case "copy_to": showDialog('selectgallery', '<?php echo esc_js(__('Copy image to...', 'nggallery')); ?> '); return false; break; case "move_to": showDialog('selectgallery', '<?php echo esc_js(__('Move image to...', 'nggallery')); ?> '); return false; break; case "add_tags": showDialog('entertags', '<?php echo esc_js(__('Add new tags', 'nggallery')); ?> '); return false; break; case "delete_tags": showDialog('entertags', '<?php echo esc_js(__('Delete tags', 'nggallery')); ?> '); return false; break; case "overwrite_tags": showDialog('entertags', '<?php echo esc_js(__('Overwrite', 'nggallery')); ?> '); return false; break; case "resize_images": showDialog('resize_images', '<?php echo esc_js(__('Resize images', 'nggallery')); ?> '); return false; break; case "new_thumbnail": showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails', 'nggallery')); ?> '); return false; break; } return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } jQuery(document).ready( function($) { if ($(this).data('ready')) return; // close postboxes that should be closed jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); postboxes.add_postbox_toggles('ngg-manage-gallery'); jQuery('.iedit').mouseover( function(e){ jQuery(this).parent().find('.row-actions').css('visibility', 'hidden'); jQuery(this).next('.row_actions:first').find('.row-actions:first').css('visibility', 'visible'); } ); $(this).data('ready', true); }); //--> </script> <div class="wrap"> <?php //include('templates/social_media_buttons.php'); screen_icon('nextgen-gallery'); if ($is_search) { ?> <h2><?php printf(__('Search results for “%s”', 'nggallery'), esc_html(get_search_query())); ?> </h2> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="media-search-input"><?php _e('Search Images', 'nggallery'); ?> :</label> <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" /> <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search Images', 'nggallery'); ?> " class="button" /> </p> </form> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&s=' . get_search_query(); ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php } else { ?> <h2><?php echo _n('Gallery', 'Galleries', 1, 'nggallery'); ?> : <?php echo esc_html(nggGallery::i18n($gallery->title)); ?> </h2> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&gid=' . $act_gid . '&paged=' . esc_attr($_GET['paged']); ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php if (nggGallery::current_user_can('NextGEN Edit gallery options')) { ?> <div id="poststuff"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <h3><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></h3> <div class="inside"> <?php $controller->render_gallery_fields(); ?> <div class="submit"> <?php if (wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can('NextGEN Import image folder')) { ?> <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images", 'nggallery'); ?> " /> <?php } ?> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /> </div> </div> </div> </div> <!-- poststuff --> <?php } ?> <?php } ?> <div class="tablenav top ngg-tablenav"> <?php $ngg->manage_page->pagination('top', $_GET['paged'], $total_number_of_images, $items_per_page); ?> <div class="alignleft actions"> <select id="bulkaction" name="bulkaction"> <option value="no_action" ><?php _e("Bulk actions", 'nggallery'); ?> </option> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="recover_images" ><?php _e("Recover from backup", 'nggallery'); ?> </option> <option value="delete_images" ><?php _e("Delete images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="rotate_cw" ><?php _e("Rotate images clockwise", 'nggallery'); ?> </option> <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise", 'nggallery'); ?> </option> <option value="copy_to" ><?php _e("Copy to...", 'nggallery'); ?> </option> <option value="move_to"><?php _e("Move to...", 'nggallery'); ?> </option> <option value="add_tags" ><?php _e("Add tags", 'nggallery'); ?> </option> <option value="delete_tags" ><?php _e("Delete tags", 'nggallery'); ?> </option> <option value="overwrite_tags" ><?php _e("Overwrite tags", 'nggallery'); ?> </option> </select> <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php if ($ngg->options['galSort'] == "sortorder" && !$is_search) { ?> <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery'); ?> " /> <?php } ?> <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery'); ?> " /> </div> </div> <table id="ngg-listimages" class="widefat fixed" cellspacing="0" > <thead> <?php $controller->render_image_row_header(); ?> </thead> <tfoot> <?php $controller->render_image_row_header(); ?> </tfoot> <tbody id="the-list"> <?php if ($picturelist) { $thumbsize = ''; $storage = C_Gallery_Storage::get_instance(); if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } foreach ($picturelist as $picture) { //for search result we need to check the capatibiliy if (!nggAdmin::can_manage_this_gallery($gallery->author) && $is_search) { continue; } $counter++; $picture->imageURL = $storage->get_image_url($picture); $picture->thumbURL = $storage->get_thumb_url($picture); $picture->imagePath = $storage->get_image_abspath($picture); $picture->thumbPath = $storage->get_thumb_abspath($picture); echo apply_filters('ngg_manage_images_row', $picture, $counter); } } // In the case you have no capaptibility to see the search result if ($counter == 0) { echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?> " /> <?php $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_images, $items_per_page); ?> </div> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="entertags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e('Select the destination gallery:', 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo esc_attr(stripslashes($gallery->title)); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td> <?php include dirname(__FILE__) . '/thumbnails-template.php'; ?> </td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
/** * nggAdmin::import_gallery() * TODO: Check permission of existing thumb folder & images * * @class nggAdmin * @param string $galleryfolder contains relative path to the gallery itself * @return void */ static function import_gallery($galleryfolder, $gallery_id = NULL) { global $wpdb, $user_ID; // get the current user ID wp_get_current_user(); $created_msg = ''; // remove trailing slash at the end, if somebody use it $galleryfolder = untrailingslashit($galleryfolder); $fs = C_Fs::get_instance(); if (is_null($gallery_id)) { $gallerypath = $fs->join_paths($fs->get_document_root('content'), $galleryfolder); } else { $storage = C_Gallery_Storage::get_instance(); $gallerypath = $storage->get_gallery_abspath($gallery_id); } if (!is_dir($gallerypath)) { nggGallery::show_error(sprintf(__("Directory <strong>%s</strong> doesn`t exist!", 'nggallery'), esc_html($gallerypath))); return; } // read list of images $new_imageslist = nggAdmin::scandir($gallerypath); if (empty($new_imageslist)) { nggGallery::show_message(sprintf(__("Directory <strong>%s</strong> contains no pictures", 'nggallery'), esc_html($gallerypath))); return; } // take folder name as gallery name $galleryname = basename($galleryfolder); $galleryname = apply_filters('ngg_gallery_name', $galleryname); // check for existing gallery folder if (is_null($gallery_id)) { $gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' "); } if (!$gallery_id) { // now add the gallery to the database $gallery_id = nggdb::add_gallery($galleryname, $galleryfolder, '', 0, 0, $user_ID); if (!$gallery_id) { nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery')); return; } else { do_action('ngg_created_new_gallery', $gallery_id); } $created_msg = sprintf(_n("Gallery <strong>%s</strong> successfully created!", 'Galleries <strong>%s</strong> successfully created!', 1, 'nggallery'), esc_html($galleryname)); } // Look for existing image list $old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' "); // if no images are there, create empty array if ($old_imageslist == NULL) { $old_imageslist = array(); } // check difference $new_images = array_diff($new_imageslist, $old_imageslist); // all images must be valid files foreach ($new_images as $key => $picture) { // filter function to rename/change/modify image before $picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id); $new_images[$key] = $picture; if (!@getimagesize($gallerypath . '/' . $picture)) { unset($new_images[$key]); @unlink($gallerypath . '/' . $picture); } } // add images to database $image_ids = nggAdmin::add_Images($gallery_id, $new_images); do_action('ngg_after_new_images_added', $gallery_id, $image_ids); //add the preview image if needed nggAdmin::set_gallery_preview($gallery_id); // now create thumbnails nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery')); //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX $message = $created_msg . sprintf(_n('%s picture successfully added', '%s pictures successfully added', count($image_ids), 'nggallery'), count($image_ids)); $message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >'; $message .= __('Edit gallery', 'nggallery'); $message .= '</a>]'; nggGallery::show_message($message); return; }
/** * Check UID in folder and Script * Read http://www.php.net/manual/en/features.safe-mode.php to understand safe_mode * * @class nggAdmin * @param string $foldername * @return bool $result */ function check_safemode($foldername) { if (SAFE_MODE) { $script_uid = ini_get('safe_mode_gid') ? getmygid() : getmyuid(); $folder_uid = fileowner($foldername); if ($script_uid != $folder_uid) { $message = sprintf(__('SAFE MODE Restriction in effect! You need to create the folder <strong>%s</strong> manually', 'nggallery'), esc_html($foldername)); $message .= '<br />' . sprintf(__('When safe_mode is on, PHP checks to see if the owner (%s) of the current script matches the owner (%s) of the file to be operated on by a file function or its directory', 'nggallery'), $script_uid, $folder_uid); nggGallery::show_error($message); return false; } } return true; }
/** * Render the page content. * * @since 1.9.22 * */ function controller() { global $ngg; //the directions containing the css files if (file_exists(NGG_CONTENT_DIR . "/ngg_styles")) { $dir = array(NGGALLERY_ABSPATH . "css", NGG_CONTENT_DIR . "/ngg_styles"); } else { $dir = array(NGGALLERY_ABSPATH . "css"); } //support for legacy location (in theme folder) if ($theme_css_exists = file_exists(get_stylesheet_directory() . "/nggallery.css")) { $act_cssfile = get_stylesheet_directory() . "/nggallery.css"; } //if someone uses the filter, don't display this page. if (!$theme_css_exists && ($set_css_file = nggGallery::get_theme_css_file())) { nggGallery::show_error(__('Your CSS file is set by a theme or another plugin.', 'nggallery') . "<br><br>" . __('This CSS file will be applied:', 'nggallery') . "<br>" . $set_css_file); return; } //load all files if (!isset($act_cssfile)) { $csslist = NGG_Style::ngg_get_cssfiles($dir); $act_cssfile = $ngg->options['CSSfile']; } //get the data from the file $act_css_data = NGG_Style::ngg_get_cssfiles_data($act_cssfile); $act_css_name = $act_css_data['Name']; $act_css_description = $act_css_data['Description']; $act_css_author = $act_css_data['Author']; $act_css_version = $act_css_data['Version']; $act_css_folder = $act_css_data['Folder']; // get the content of the file $error = !is_file($act_cssfile); if (!$error && filesize($act_cssfile) > 0) { $f = fopen($act_cssfile, 'r'); $content = fread($f, filesize($act_cssfile)); $content = htmlspecialchars($content); } ?> <div class="wrap"> <div class="bordertitle"> <?php screen_icon('nextgen-gallery'); ?> <h2><?php _e('Style Editor', 'nggallery'); ?> </h2> <div class="fileedit-sub"> <?php if (!$theme_css_exists) { //no need if there is a theme css ?> <div class="alignright"> <form id="themeselector" name="cssfiles" method="post"> <?php wp_nonce_field('ngg_style'); ?> <strong><?php _e('Activate and use style sheet:', 'nggallery'); ?> </strong> <input type="checkbox" name="activateCSS" value="1" <?php checked('1', $ngg->options['activateCSS']); ?> /> <select name="css" id="theme" style="margin: 0pt; padding: 0pt;"> <?php self::output_css_files_dropdown($csslist, $act_cssfile); ?> </select> <input class="button" type="submit" name="activate" value="<?php _e('Activate', 'nggallery'); ?> »" class="button" /> </form> </div> <?php } ?> <?php if (!is_multisite() || is_super_admin()) { ?> <div class="alignleft"> <?php $title = '<h3>'; if (is_writeable($act_cssfile)) { $title .= sprintf(__('Editing %s', 'nggallery'), $act_css_name); } else { $title .= sprintf(__('Browsing %s', 'nggallery'), $act_css_name); } if ($theme_css_exists) { $title .= ' ' . __('(from the theme folder)', 'nggallery'); } $title .= '</h3>'; echo $title; ?> </div> <br class="clear" /> </div> <!-- fileedit-sub --> <div id="templateside"> <?php if ($theme_css_exists) { ?> <form id="filemover" name="filemover" method="post" style="background:white; padding: 1px 10px 10px;"> <p><?php _e('To ensure your css file stays safe during upgrades, please move it to the right folder.', 'nggallery'); ?> </p> <input type="hidden" name="movecss" value="movecss" /> <input type="hidden" name="oldpath" value="<?php echo $act_cssfile; ?> " /> <input class="button-primary action" type="submit" name="submit" value="<?php _e('Move file', 'nggallery'); ?> " /> </form> <br class="clear" /> <?php } ?> <ul> <li><strong><?php _e('Author', 'nggallery'); ?> :</strong> <?php echo $act_css_author; ?> </li> <li><strong><?php _e('Version', 'nggallery'); ?> :</strong> <?php echo $act_css_version; ?> </li> </ul> <p><strong><?php _e('Description', 'nggallery'); ?> :</strong></p> <p class="description"><?php echo $act_css_description; ?> </p> <p><strong><?php _e('File location', 'nggallery'); ?> :</strong></p> <p class="description"><?php echo $act_cssfile; ?> </p> </div> <?php if (!$error) { ?> <form name="template" id="template" method="post"> <?php wp_nonce_field('ngg_style'); ?> <div> <textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress css"><?php echo $content; ?> </textarea> <input type="hidden" name="updatecss" value="updatecss" /> <input type="hidden" name="folder" value="<?php echo $act_css_folder; ?> " /> <input type="hidden" name="file" value="<?php echo $act_cssfile; ?> " /> </div> <?php if (is_writeable($act_cssfile)) { ?> <p class="submit"><input class="button-primary action" type="submit" name="submit" value="<?php _e('Update File', 'nggallery'); ?> " tabindex="2" /></p> <?php } else { ?> <p><em><?php _e('If this file were writable you could edit it.', 'nggallery'); ?> </em></p> <?php } ?> </form> <?php } else { echo '<div class="error"><p>' . __('This file does not exist. Double check the name and try again.', 'nggallery') . '</p></div>'; } ?> <div class="clear"> </div> </div> <!-- wrap--> <?php } //end if ( !is_multisite() || is_super_admin() ) }
function nggallery_picturelist() { // *** show picture list global $wpdb, $user_ID, $ngg; // GET variables $act_gid = $ngg->manage_page->gid; $showTags = $ngg->manage_page->showTags; $hideThumbs = $ngg->manage_page->hideThumbs; // Load the gallery metadata $gallery = nggdb::find_gallery($act_gid); if (!$gallery) { nggGallery::show_error(__('Gallery not found.', 'nggallery')); return; } // get picture values $picturelist = nggdb::get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false); // get the current author $act_author_user = get_userdata((int) $gallery->author); // list all galleries $gallerylist = nggdb::find_all_galleries(); ?> <script type="text/javascript"> function showDialog( windowId ) { var form = document.getElementById('updategallery'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // console.log (jQuery("#TB_imagelist").val()); tb_show("", "#TB_inline?width=640&height=120&inlineId=" + windowId + "&modal=true", false); } </script> <script type="text/javascript"> <!-- function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('updategallery')); if(numchecked < 1) { alert('<?php echo js_escape(__("No images selected", 'nggallery')); ?> '); return false; } //TODO: For copy to and move to we need some better way around if (jQuery('#bulkaction').val() == 'copy_to') { showDialog('selectgallery'); return false; } if (jQuery('#bulkaction').val() == 'move_to') { showDialog('selectgallery'); return false; } return confirm('<?php echo sprintf(js_escape(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } jQuery(document).ready( function() { // close postboxes that should be closed jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); if (typeof postboxes != "undefined") postboxes.add_postbox_toggles('ngg-manage-gallery'); // WP 2.7 else add_postbox_toggles('ngg-manage-gallery'); // WP 2.6 }); //--> </script> <div class="wrap"> <h2><?php echo __ngettext('Gallery', 'Galleries', 1, 'nggallery'); ?> : <?php echo $gallery->title; ?> </h2> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&gid=' . $act_gid; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <?php if ($showTags) { ?> <input type="hidden" name="showTags" value="true" /><?php } if ($hideThumbs) { ?> <input type="hidden" name="hideThumbs" value="true" /><?php } ?> <div id="poststuff"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <h3><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></h3> <div class="inside"> <table class="form-table" > <tr> <th align="left"><?php _e('Title'); ?> :</th> <th align="left"><input type="text" size="50" name="title" value="<?php echo $gallery->title; ?> " /></th> <th align="right"><?php _e('Page Link to', 'nggallery'); ?> :</th> <th align="left"> <select name="pageid" style="width:95%"> <option value="0" ><?php _e('Not linked', 'nggallery'); ?> </option> <?php parent_dropdown($gallery->pageid); ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Description'); ?> :</th> <th align="left"><textarea name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php echo $gallery->galdesc; ?> </textarea></th> <th align="right"><?php _e('Preview image', 'nggallery'); ?> :</th> <th align="left"> <select name="previewpic" style="width:95%" > <option value="0" ><?php _e('No Picture', 'nggallery'); ?> </option> <?php if (is_array($picturelist)) { foreach ($picturelist as $picture) { $selected = $picture->pid == $gallery->previewpic ? 'selected="selected" ' : ''; echo '<option value="' . $picture->pid . '" ' . $selected . '>' . $picture->pid . ' - ' . $picture->filename . '</option>' . "\n"; } } ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Path', 'nggallery'); ?> :</th> <th align="left"><input <?php if (IS_WPMU) { echo 'readonly = "readonly"'; } ?> type="text" size="50" name="path" value="<?php echo $gallery->path; ?> " /></th> <th align="right"><?php _e('Author', 'nggallery'); ?> :</th> <th align="left"> <?php $editable_ids = $ngg->manage_page->get_editable_user_ids($user_ID); if ($editable_ids && count($editable_ids) > 1) { wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author)); } else { echo $act_author_user->display_name; } ?> </th> </tr> <tr> <th align="left"> </th> <th align="left"> </th> <th align="right"><?php _e('Create new page', 'nggallery'); ?> :</th> <th align="left"> <select name="parent_id" style="width:95%"> <option value="0"><?php _e('Main page (No parent)', 'nggallery'); ?> </option> <?php parent_dropdown(); ?> </select> <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e('Add page', 'nggallery'); ?> " id="group"/> </th> </tr> </table> <div class="submit"> <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images", 'nggallery'); ?> " /> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /> </div> </div> </div> </div> <!-- poststuff --> <div class="tablenav ngg-tablenav"> <div class="alignleft actions" style="float: left;"> <select id="bulkaction" name="bulkaction"> <option value="no_action" ><?php _e("No action", 'nggallery'); ?> </option> <?php if (!$showTags) { ?> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="delete_images" ><?php _e("Delete images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="copy_to" ><?php _e("Copy to...", 'nggallery'); ?> </option> <option value="move_to"><?php _e("Move to...", 'nggallery'); ?> </option> <?php } else { ?> <option value="add_tags" ><?php _e("Add tags", 'nggallery'); ?> </option> <option value="delete_tags" ><?php _e("Delete tags", 'nggallery'); ?> </option> <option value="overwrite_tags" ><?php _e("Overwrite tags", 'nggallery'); ?> </option> <?php } ?> </select> <?php if (!$showTags) { ?> <input class="button-secondary" type="submit" name="doaction" value="<?php _e("OK", 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php } else { ?> <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e("OK", 'nggallery'); ?> " onclick="showDialog('tags'); return false;" /> <?php } ?> <?php if (!$hideThumbs) { ?> <input class="button-secondary" type="submit" name="togglethumbs" value="<?php _e("Hide thumbnails ", 'nggallery'); ?> " /> <?php } else { ?> <input class="button-secondary" type="submit" name="togglethumbs" value="<?php _e("Show thumbnails ", 'nggallery'); ?> " /> <?php } ?> <?php if (!$showTags) { ?> <input class="button-secondary" type="submit" name="toggletags" value="<?php _e("Show tags", 'nggallery'); ?> " /> <?php } else { ?> <input class="button-secondary" type="submit" name="toggletags" value="<?php _e("Hide tags", 'nggallery'); ?> " /> <?php } ?> <?php if ($ngg->options['galSort'] == "sortorder") { ?> <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e("Sort gallery", 'nggallery'); ?> " /> <?php } ?> </div> <span style="float:right; padding:2px 8px 0 0;"><input type="submit" name="updatepictures" class="button-primary action" value="<?php _e("Save Changes", 'nggallery'); ?> " /></span> </div> <table id="ngg-listimages" class="widefat" > <thead> <tr> <?php $gallery_columns = ngg_manage_gallery_columns(); ?> <?php foreach ($gallery_columns as $gallery_column_key => $column_display_name) { switch ($gallery_column_key) { case 'cb': $class = ' class="check-column;"'; break; case 'tags': $class = ' style="width:70%;"'; break; case 'action': $class = ' colspan="3" style="text-align: center;"'; break; default: $class = ' style="text-align: center;"'; } ?> <th scope="col"<?php echo $class; ?> ><?php echo $column_display_name; ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <?php foreach ($gallery_columns as $gallery_column_key => $column_display_name) { switch ($gallery_column_key) { case 'cb': $class = ' class="check-column;"'; break; case 'tags': $class = ' style="width:70%;"'; break; case 'action': $class = ' colspan="3" style="text-align: center;"'; break; default: $class = ' style="text-align: center;"'; } ?> <th scope="col"<?php echo $class; ?> ><?php echo $column_display_name; ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php if ($picturelist) { $thumbsize = ""; if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } if ($ngg->options['thumbcrop']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbwidth'] . '"'; } foreach ($picturelist as $picture) { $pid = (int) $picture->pid; $class = $class == 'class="alternate"' ? '' : 'class="alternate"'; $exclude = $picture->exclude ? 'checked="checked"' : ''; $date = mysql2date(get_option('date_format'), $picture->imagedate); $time = mysql2date(get_option('time_format'), $picture->imagedate); ?> <tr id="picture-<?php echo $pid; ?> " <?php echo $class; ?> style="text-align:center"> <?php foreach ($gallery_columns as $gallery_column_key => $column_display_name) { switch ($gallery_column_key) { case 'cb': ?> <td class="check-column" scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid; ?> " /></td> <?php break; case 'id': ?> <td class="id column-id" scope="row" style="text-align: center"><?php echo $pid; ?> </td> <?php break; case 'filename': ?> <td class="media-icon" style="text-align: left;"> <a href="<?php echo $picture->imageURL; ?> " class="thickbox" title="<?php echo $picture->filename; ?> "> <?php echo $picture->filename; ?> </a> <br /><?php echo $date; ?> </td> <?php break; case 'thumbnail': ?> <td class="thumbnail column-thumbnail"><a href="<?php echo $picture->imageURL; ?> " class="thickbox" title="<?php echo $picture->filename; ?> "> <img class="thumb" src="<?php echo $picture->thumbURL; ?> " <?php echo $thumbsize; ?> /> </a> <br /><?php echo $date; ?> </td> <?php break; case 'alt_title_desc': ?> <td class="altdesc column-altdesc" style="width:500px"> <input name="alttext[<?php echo $pid; ?> ]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo stripslashes($picture->alttext); ?> " /><br/> <textarea name="description[<?php echo $pid; ?> ]" style="width:95%; margin-top: 2px;" rows="2" ><?php echo stripslashes($picture->description); ?> </textarea> </td> <?php break; case 'description': ?> <td class="description column-description"><textarea name="description[<?php echo $pid; ?> ]" class="textarea1" cols="42" rows="2" ><?php echo stripslashes($picture->description); ?> </textarea></td> <?php break; case 'alt_title_text': ?> <td class="alttext column-alttext"><input name="alttext[<?php echo $pid; ?> ]" type="text" size="30" value="<?php echo stripslashes($picture->alttext); ?> " /></td> <?php break; case 'exclude': ?> <td class="exclude column-exclude"><input name="exclude[<?php echo $pid; ?> ]" type="checkbox" value="1" <?php echo $exclude; ?> /></td> <?php break; case 'tags': $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names'); if (is_array($picture->tags)) { $picture->tags = implode(', ', $picture->tags); } ?> <td class="tags column-tags" style="width:500px;"><textarea name="tags[<?php echo $pid; ?> ]" style="width:95%;" rows="2"><?php echo $picture->tags; ?> </textarea></td> <?php break; case 'action': ?> <td><a href="<?php echo NGGALLERY_URLPATH . "admin/showmeta.php?id=" . $pid; ?> " class="thickbox" title="<?php _e("Show Meta data", 'nggallery'); ?> " ><?php _e('Meta'); ?> </a></td> <td><a href="<?php echo wp_nonce_url("admin.php?page=nggallery-manage-gallery&mode=delpic&gid=" . $act_gid . "&pid=" . $pid, 'ngg_delpicture'); ?> " class="delete" onclick="javascript:check=confirm( '<?php _e("Delete this file ?", 'nggallery'); ?> ');if(check==false) return false;" ><?php _e('Delete'); ?> </a></td> <?php break; default: ?> <td><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $pid); ?> </td> <?php break; } ?> <?php } ?> </tr> <?php } } else { echo '<tr><td colspan="8" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <p class="submit"><input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /></p> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="tags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <?php if ($showTags) { ?> <input type="hidden" name="showTags" value="true" /><?php } ?> <?php if ($hideThumbs) { ?> <input type="hidden" name="hideThumbs" value="true" /><?php } ?> <input type="hidden" id="tags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="tags_bulkaction" name="TB_bulkaction" value="" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " onclick="var numchecked = getNumChecked(document.getElementById('updategallery')); if(numchecked < 1) { alert('<?php echo js_escape(__("No images selected", 'nggallery')); ?> '); tb_remove(); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> ')" /> <input class="button-secondary" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <?php if ($showTags) { ?> <input type="hidden" name="showTags" value="true" /><?php } ?> <?php if ($hideThumbs) { ?> <input type="hidden" name="hideThumbs" value="true" /><?php } ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e("Select the destination gallery:", 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo stripslashes($gallery->title); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " onclick="var numchecked = getNumChecked(document.getElementById('updategallery')); if(numchecked < 1) { alert('<?php echo js_escape(__("No images selected", 'nggallery')); ?> '); tb_remove(); return false } return confirm('<?php echo sprintf(js_escape(__("You are about to copy or move %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> ')" /> <input class="button-secondary" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <?php }
$filepart['filename'] = substr($filepart["basename"], 0, strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1)); $filename = time() . sanitize_title($filepart['filename']) . '.' . $filepart['extension']; // check for allowed extension $ext = array('jpeg', 'jpg', 'png', 'gif'); if (!in_array($filepart['extension'], $ext)) { $display = 'block'; $errormsg = 'sorry,the file is no valid image file!'; } else { $dest_file = WINABSPATH . $gallerypath . '/' . $filename; // save temp file to gallery if (!@move_uploaded_file($_FILES['image']['tmp_name'], $dest_file)) { nggGallery::show_error(__('Error, the file could not moved to : ', 'nggallery') . $dest_file); continue; } if (!foto_chmod($dest_file)) { nggGallery::show_error(__('Error, the file permissions could not set', 'nggallery')); continue; } $pid = nggdb::insert_image($gid, $filename, $title, $description, 1); $tags = explode(",", $tags); wp_set_object_terms($pid, $tags, 'ngg_tag'); $wpdb->query("UPDATE {$wpdb->nggpictures} SET imagedate = now() WHERE pid = {$pid}"); $display = 'block'; $errormsg = 'your upload is successful,it will be reviewed.you can continue'; } } } } //输出页头keywords $keywords = $cfg['keywords']; //输出页面description
public static function show_error($msg) { if (is_user_logged_in() && apply_filters('uploader_ngg_admin_show_error', true)) { nggGallery::show_error($msg); } }
function nggallery_picturelist() { // *** show picture list global $wpdb, $nggdb, $user_ID, $ngg; // Look if its a search result $is_search = isset($_GET['s']) ? true : false; if ($is_search) { // fetch the imagelist $picturelist = $ngg->manage_page->search_result; // we didn't set a gallery or a pagination $act_gid = 0; $_GET['paged'] = 1; $page_links = false; } else { // GET variables $act_gid = $ngg->manage_page->gid; // Load the gallery metadata $gallery = $nggdb->find_gallery($act_gid); if (!$gallery) { nggGallery::show_error(__('Gallery not found.', 'nggallery')); return; } // Check if you have the correct capability if (!nggAdmin::can_manage_this_gallery($gallery->author)) { nggGallery::show_error(__('Sorry, you have no access here', 'nggallery')); return; } // look for pagination if (!isset($_GET['paged']) || $_GET['paged'] < 1) { $_GET['paged'] = 1; } $start = ($_GET['paged'] - 1) * 50; // get picture values $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start); // build pagination $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $nggdb->paged['max_objects_per_page'], 'current' => $_GET['paged'])); // get the current author $act_author_user = get_userdata((int) $gallery->author); } // list all galleries $gallerylist = $nggdb->find_all_galleries(); //get the columns $gallery_columns = ngg_manage_gallery_columns(); $hidden_columns = get_hidden_columns('nggallery-manage-images'); $num_columns = count($gallery_columns) - count($hidden_columns); ?> <!--[if IE]> <style type="text/css"> .custom_thumb { display : none; } </style> <![endif]--> <script type="text/javascript"> <!-- function showDialog( windowId, height ) { var form = document.getElementById('updategallery'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // console.log (jQuery("#TB_imagelist").val()); tb_show("", "#TB_inline?width=640&height=" + height + "&inlineId=" + windowId + "&modal=true", false); } function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('updategallery')); if(numchecked < 1) { alert('<?php echo js_escape(__('No images selected', 'nggallery')); ?> '); return false; } actionId = jQuery('#bulkaction').val(); switch (actionId) { case "copy_to": case "move_to": showDialog('selectgallery', 120); return false; break; case "add_tags": case "delete_tags": case "overwrite_tags": showDialog('entertags', 120); return false; break; case "resize_images": showDialog('resize_images', 120); return false; break; case "new_thumbnail": showDialog('new_thumbnail', 160); return false; break; } return confirm('<?php echo sprintf(js_escape(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } jQuery(document).ready( function() { // close postboxes that should be closed jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); postboxes.add_postbox_toggles('ngg-manage-gallery'); }); //--> </script> <div class="wrap"> <?php if ($is_search) { ?> <h2><?php printf(__('Search results for “%s”', 'nggallery'), wp_specialchars(get_search_query())); ?> </h2> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="media-search-input"><?php _e('Search Images', 'nggallery'); ?> :</label> <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" /> <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search Images', 'nggallery'); ?> " class="button" /> </p> </form> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&s=' . $_GET['s']; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php } else { ?> <h2><?php echo _n('Gallery', 'Galleries', 1, 'nggallery'); ?> : <?php echo nggGallery::i18n($gallery->title); ?> </h2> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&gid=' . $act_gid . '&paged=' . $_GET['paged']; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <div id="poststuff"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <h3><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></h3> <div class="inside"> <table class="form-table" > <tr> <th align="left"><?php _e('Title'); ?> :</th> <th align="left"><input type="text" size="50" name="title" value="<?php echo $gallery->title; ?> " /></th> <th align="right"><?php _e('Page Link to', 'nggallery'); ?> :</th> <th align="left"> <select name="pageid" style="width:95%"> <option value="0" ><?php _e('Not linked', 'nggallery'); ?> </option> <?php parent_dropdown($gallery->pageid); ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Description'); ?> :</th> <th align="left"><textarea name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php echo $gallery->galdesc; ?> </textarea></th> <th align="right"><?php _e('Preview image', 'nggallery'); ?> :</th> <th align="left"> <select name="previewpic" style="width:95%" > <option value="0" ><?php _e('No Picture', 'nggallery'); ?> </option> <?php if (is_array($picturelist)) { foreach ($picturelist as $picture) { $selected = $picture->pid == $gallery->previewpic ? 'selected="selected" ' : ''; echo '<option value="' . $picture->pid . '" ' . $selected . '>' . $picture->pid . ' - ' . $picture->filename . '</option>' . "\n"; } } ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Path', 'nggallery'); ?> :</th> <th align="left"><input <?php if (IS_WPMU) { echo 'readonly = "readonly"'; } ?> type="text" size="50" name="path" value="<?php echo $gallery->path; ?> " /></th> <th align="right"><?php _e('Author', 'nggallery'); ?> :</th> <th align="left"> <?php $editable_ids = $ngg->manage_page->get_editable_user_ids($user_ID); if ($editable_ids && count($editable_ids) > 1) { wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author)); } else { echo $act_author_user->display_name; } ?> </th> </tr> <?php if (current_user_can("publish_pages")) { ?> <tr> <th align="left"> </th> <th align="left"> </th> <th align="right"><?php _e('Create new page', 'nggallery'); ?> :</th> <th align="left"> <select name="parent_id" style="width:95%"> <option value="0"><?php _e('Main page (No parent)', 'nggallery'); ?> </option> <?php parent_dropdown(); ?> </select> <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e('Add page', 'nggallery'); ?> " id="group"/> </th> </tr> <?php } ?> </table> <div class="submit"> <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images", 'nggallery'); ?> " /> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /> </div> </div> </div> </div> <!-- poststuff --> <?php } ?> <div class="tablenav ngg-tablenav"> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links); echo $page_links_text; ?> </div> <?php } ?> <div class="alignleft actions"> <select id="bulkaction" name="bulkaction"> <option value="no_action" ><?php _e("No action", 'nggallery'); ?> </option> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="delete_images" ><?php _e("Delete images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="rotate_cw" ><?php _e("Rotate images clockwise", 'nggallery'); ?> </option> <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise", 'nggallery'); ?> </option> <option value="copy_to" ><?php _e("Copy to...", 'nggallery'); ?> </option> <option value="move_to"><?php _e("Move to...", 'nggallery'); ?> </option> <option value="add_tags" ><?php _e("Add tags", 'nggallery'); ?> </option> <option value="delete_tags" ><?php _e("Delete tags", 'nggallery'); ?> </option> <option value="overwrite_tags" ><?php _e("Overwrite tags", 'nggallery'); ?> </option> </select> <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php if ($ngg->options['galSort'] == "sortorder" && !$is_search) { ?> <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery'); ?> " /> <?php } ?> <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery'); ?> " /> </div> </div> <table id="ngg-listimages" class="widefat fixed" cellspacing="0" > <thead> <tr> <?php print_column_headers('nggallery-manage-images'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('nggallery-manage-images', false); ?> </tr> </tfoot> <tbody> <?php if ($picturelist) { $thumbsize = ''; $counter = 0; if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } foreach ($picturelist as $picture) { //for search result we need to check the capatibiliy if (!nggAdmin::can_manage_this_gallery($picture->author) && $is_search) { continue; } $counter++; $pid = (int) $picture->pid; $alternate = !isset($alternate) || $alternate == 'alternate' ? '' : 'alternate'; $exclude = $picture->exclude ? 'checked="checked"' : ''; $date = mysql2date(get_option('date_format'), $picture->imagedate); $time = mysql2date(get_option('time_format'), $picture->imagedate); ?> <tr id="picture-<?php echo $pid; ?> " class="<?php echo $alternate; ?> iedit" valign="top"> <?php foreach ($gallery_columns as $gallery_column_key => $column_display_name) { $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\""; $style = ''; if (in_array($gallery_column_key, $hidden_columns)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($gallery_column_key) { case 'cb': ?> <th <?php echo $attributes; ?> scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid; ?> " /></th> <?php break; case 'id': ?> <td <?php echo $attributes; ?> scope="row" style=""><?php echo $pid; ?> <input type="hidden" name="pid[]" value="<?php echo $pid; ?> " /> </td> <?php break; case 'filename': ?> <td <?php echo $attributes; ?> > <strong><a href="<?php echo $picture->imageURL; ?> " class="thickbox" title="<?php echo $picture->filename; ?> "> <?php echo empty($picture->alttext) ? $picture->filename : stripslashes(nggGallery::i18n($picture->alttext)); ?> </a></strong> <br /><?php echo $date; ?> <?php if (!empty($picture->meta_data)) { ?> <br /><?php echo $picture->meta_data['width']; ?> x <?php echo $picture->meta_data['height']; ?> <?php _e('pixel', 'nggallery'); ?> <?php } ?> <p> <?php $actions = array(); //TODO:Add a JS edit option //$actions['edit'] = '<a class="editinline" href="#">' . __('Edit') . '</a>'; $actions['view'] = '<a class="thickbox" href="' . $picture->imageURL . '" title="' . esc_attr(sprintf(__('View "%s"'), $picture->filename)) . '">' . __('View', 'nggallery') . '</a>'; $actions['meta'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data', 'nggallery') . '">' . __('Meta', 'nggallery') . '</a>'; $actions['custom_thumb'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail', 'nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>'; $actions['rotate'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate', 'nggallery') . '">' . __('Rotate', 'nggallery') . '</a>'; $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&mode=delpic&gid=" . $act_gid . "&pid=" . $pid, 'ngg_delpicture') . '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s"', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Delete') . '</a>'; $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; ?> </p> </td> <?php break; case 'thumbnail': // generate the thumbnail size if the meta data available if (is_array($size = $picture->meta_data['thumbnail'])) { $thumbsize = 'width="' . $size['width'] . '" height="' . $size['height'] . '"'; } ?> <td <?php echo $attributes; ?> ><a href="<?php echo $picture->imageURL . '?' . mt_rand(); ?> " class="thickbox" title="<?php echo $picture->filename; ?> "> <img class="thumb" src="<?php echo $picture->thumbURL . '?' . mt_rand(); ?> " <?php echo $thumbsize; ?> id="thumb<?php echo $pid; ?> " /> </a> </td> <?php break; case 'alt_title_desc': ?> <td <?php echo $attributes; ?> > <input name="alttext[<?php echo $pid; ?> ]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo stripslashes($picture->alttext); ?> " /><br/> <textarea name="description[<?php echo $pid; ?> ]" style="width:95%; margin-top: 2px;" rows="2" ><?php echo stripslashes($picture->description); ?> </textarea> </td> <?php break; case 'exclude': ?> <td <?php echo $attributes; ?> ><input name="exclude[<?php echo $pid; ?> ]" type="checkbox" value="1" <?php echo $exclude; ?> /></td> <?php break; case 'tags': $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names'); if (is_array($picture->tags)) { $picture->tags = implode(', ', $picture->tags); } ?> <td <?php echo $attributes; ?> ><textarea name="tags[<?php echo $pid; ?> ]" style="width:95%;" rows="2"><?php echo $picture->tags; ?> </textarea></td> <?php break; default: ?> <td <?php echo $attributes; ?> ><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $pid); ?> </td> <?php break; } ?> <?php } ?> </tr> <?php } } // In the case you have no capaptibility to see the search result if ($counter == 0) { echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <p class="submit"><input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /></p> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="entertags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e('Select the destination gallery:', 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo stripslashes($gallery->title); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?> " /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?> " /> <br /><small><?php _e('These values are maximum values ', 'nggallery'); ?> </small></td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
function nggallery_wpmu_setup() { //to be sure if (!is_super_admin()) { die('You are not allowed to call this page.'); } $messagetext = ''; // get the options $ngg_options = get_site_option('ngg_options'); if (isset($_POST['updateoption'])) { check_admin_referer('ngg_wpmu_settings'); // get the hidden option fields, taken from WP core if ($_POST['page_options']) { $options = explode(',', stripslashes($_POST['page_options'])); } if ($options) { foreach ($options as $option) { $option = trim($option); $value = false; if (isset($_POST[$option])) { $value = trim($_POST[$option]); if ($value === "true") { $value = true; } if (is_numeric($value)) { $value = (int) $value; } } // $value = sanitize_option($option, $value); // This does stripslashes on those that need it $ngg_options[$option] = $value; } } // the path should always end with a slash $ngg_options['gallerypath'] = trailingslashit($ngg_options['gallerypath']); update_site_option('ngg_options', $ngg_options); var_dump($ngg_options); $messagetext = __('Update successfully', 'nggallery'); } global $ngg; //the directions containing the css files if (file_exists(NGG_CONTENT_DIR . "/ngg_styles")) { $dir = array(NGGALLERY_ABSPATH . "css", NGG_CONTENT_DIR . "/ngg_styles"); } else { $dir = array(NGGALLERY_ABSPATH . "css"); } //support for legacy location (in theme folder) if ($theme_css_exists = file_exists(get_stylesheet_directory() . "/nggallery.css")) { $act_cssfile = get_stylesheet_directory() . "/nggallery.css"; } //if someone uses the filter, don't display this page. if (!$theme_css_exists && ($set_css_file = nggGallery::get_theme_css_file())) { nggGallery::show_error(__('Your CSS file is set by a theme or another plugin.', 'nggallery') . "<br><br>" . __('This CSS file will be applied:', 'nggallery') . "<br>" . $set_css_file); return; } //load all files if (!isset($act_cssfile)) { $csslist = NGG_Style::ngg_get_cssfiles($dir); $act_cssfile = $ngg->options['CSSfile']; } // message windows if (!empty($messagetext)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . $messagetext . '</p></div>'; } ?> <div class="wrap"> <h2><?php _e('Network Options', 'nggallery'); ?> </h2> <form name="generaloptions" method="post"> <?php wp_nonce_field('ngg_wpmu_settings'); ?> <input type="hidden" name="page_options" value="silentUpgrade,gallerypath,wpmuQuotaCheck,wpmuZipUpload,wpmuImportFolder,wpmuStyle,wpmuRoles,wpmuCSSfile" /> <table class="form-table"> <tr> <th><label for="gallerypath"><?php _e('Gallery path', 'nggallery'); ?> </label></th> <td> <input type="text" size="50" name="gallerypath" id="gallerypath" value="<?php echo $ngg_options['gallerypath']; ?> "> <p class="description"> <?php _e('This is the default path for all blogs. With the placeholder %BLOG_ID% you can organize the folder structure better.', 'nggallery'); ?> <?php echo sprintf(__('The default setting should be %s.', 'nggallery'), '<code>wp-content/blogs.dir/%BLOG_ID%/files/</code>'); ?> </p> </td> </tr> <tr> <th><?php _e('Silent database upgrade', 'nggallery'); ?> </th> <td> <input type="checkbox" name="silentUpgrade" id="silentUpgrade" value="true" <?php checked($ngg_options['silentUpgrade']); ?> > <label for="silentUpgrade"><?php _e('Update the database without notice.', 'nggallery'); ?> </label> </td> </tr> <tr> <th><?php _e('Enable upload quota check', 'nggallery'); ?> </th> <td> <input name="wpmuQuotaCheck" id="wpmuQuotaCheck" type="checkbox" value="true" <?php checked($ngg_options['wpmuQuotaCheck']); ?> > <label for="wpmuQuotaCheck"><?php _e('Should work if the gallery is bellow the blog.dir', 'nggallery'); ?> </label> </td> </tr> <tr> <th><?php _e('Enable zip upload option', 'nggallery'); ?> </th> <td> <input name="wpmuZipUpload" id="wpmuZipUpload" type="checkbox" value="true" <?php checked($ngg_options['wpmuZipUpload']); ?> > <label for="wpmuZipUpload"><?php _e('Allow users to upload zip folders.', 'nggallery'); ?> </label> </td> </tr> <tr> <th><?php _e('Enable import function', 'nggallery'); ?> </th> <td> <input name="wpmuImportFolder" id="wpmuImportFolder" type="checkbox" value="true" <?php checked($ngg_options['wpmuImportFolder']); ?> > <label for="wpmuImportFolder"><?php _e('Allow users to import images folders from the server.', 'nggallery'); ?> </label> </td> </tr> <tr> <th><?php _e('Enable style selection', 'nggallery'); ?> </th> <td> <input name="wpmuStyle" id="wpmuStyle" type="checkbox" value="true" <?php checked($ngg_options['wpmuStyle']); ?> > <label for="wpmuStyle"><?php _e('Allow users to choose a style for the gallery.', 'nggallery'); ?> </label> </td> </tr> <tr> <th><?php _e('Enable roles/capabilities', 'nggallery'); ?> </th> <td> <input name="wpmuRoles" id="wpmuRoles" type="checkbox" value="true" <?php checked($ngg_options['wpmuRoles']); ?> > <label for="wpmuRoles"><?php _e('Allow users to change the roles for other blog authors.', 'nggallery'); ?> </label> </td> </tr> <tr> <th><label for="wpmuCSSfile"><?php _e('Default style', 'nggallery'); ?> </label></th> <td> <select name="wpmuCSSfile" id="wpmuCSSfile"> <?php NGG_Style::output_css_files_dropdown($csslist, $act_cssfile); ?> </select> <p class="description"> <?php _e('Choose the default style for the galleries.', 'nggallery'); ?> <?php _e('Note: between brackets is the folder in which the file is.', 'nggallery'); ?> </p> </td> </tr> </table> <?php submit_button(__('Save Changes'), 'primary', 'updateoption'); ?> </form> </div> <?php }
/** * Function for uploading of images via the upload form * * @class nggAdmin * @return void */ function upload_images($galleryID, $image, $desc, $title) { global $wpdb; $gallery = $wpdb->prefix . "spf_gallery"; $pictures = $wpdb->prefix . "spf_pictures"; if ($galleryID == 0) { show_error(__('No gallery selected !', 'nggallery')); return; } $gid = $galleryID; $query = "SELECT * FROM " . $gallery . " WHERE gid='" . $gid . "'"; $results = mysql_query($query); $count = mysql_num_rows($results); while ($data = mysql_fetch_array($results)) { //$id = $data['gid']; $fullpath = ABSPATH . stripslashes($data['path']); ///$quote = stripslashes($data['description']); } $fullpath = str_replace("\\", "/", $fullpath); if (empty($fullpath)) { nggGallery::show_error(__('Failure in database, no gallery path set !', 'nggallery')); return; } // read list of images //$dirlist = scandir($fullpath); $imagefiles = $image; // look only for uploded files if ($imagefiles['error'] == 0) { $temp_file = $imagefiles['tmp_name']; //clean filename and extract extension $filepart = fileinfo($imagefiles['name']); print_r($filepart); echo $filename = $filepart['basename']; // check for allowed extension and if it's an image file $ext = array('jpg', 'png', 'gif', 'bmp', 'jpeg'); if (!in_array($filepart['extension'], $ext)) { show_error('<strong>' . $imagefiles['name'] . ' </strong>' . __('is no valid image file!', 'nggallery')); //continue; } // check if this filename already exist in the folder if (file_exists($fullpath . $filename)) { $txt = "File ({$filename}) already exists."; show_error($txt); return false; } else { echo $filename = $filepart['filename'] . '.' . $filepart['extension']; } echo $dest_file = $fullpath . $filename; //check for folder permission if (!is_writeable($fullpath)) { echo "<br>" . $fullpath; chmod($fullpath, 0777); //$message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?'), $fullpath); // show_error($message); // return; } // save temp file to gallery if (!@move_uploaded_file($temp_file, $dest_file)) { show_error(__('Error, the file could not moved to : ') . $dest_file); //continue; } else { $insert = "INSERT INTO " . $pictures . " (pid, gid, filename, description, title) \t \t\t\t\t\t\t\t\t\t\t\t \t\t\t\t\t\t\t\t" . "VALUES ('', '" . $gid . "', " . $file_name . "', '" . $desc . "', '" . $title . "')"; $results = $wpdb->query($insert); if ($results) { ?> <div class="updated" id="message" style="background-color: rgb(255, 251, 204);"><p> <?php echo 'New Gallery added successfully!'; ?> </p></div> <?php } } //if ( !chmod($dest_file) ) // { // show_error(__('Error, the file permissions could not set')); // continue; // } } return; }
/** * nggGallery::get_thumbnail_folder() * * @param mixed $gallerypath * @param bool $include_Abspath * @return string $foldername */ static function create_thumbnail_folder($gallerypath, $include_Abspath = TRUE) { if (!$include_Abspath) { $gallerypath = ABSPATH . $gallerypath; } if (!file_exists($gallerypath)) { return FALSE; } if (is_dir($gallerypath . '/thumbs/')) { return '/thumbs/'; } if (is_admin()) { if (!is_dir($gallerypath . '/thumbs/')) { if (!wp_mkdir_p($gallerypath . '/thumbs/')) { if (SAFE_MODE) { nggAdmin::check_safemode($gallerypath . '/thumbs/'); } else { nggGallery::show_error(__('Unable to create directory ', 'nggallery') . $gallerypath . '/thumbs !'); } return FALSE; } return '/thumbs/'; } } return FALSE; }
function nggallery_admin_add_gallery() { global $wpdb, $ngg; // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0 $filepath = admin_url() . 'admin.php?page=' . $_GET['page']; // link for the flash file $swf_upload_link = NGGALLERY_URLPATH . 'admin/upload.php'; $swf_upload_link = wp_nonce_url($swf_upload_link, 'ngg_swfupload'); //flash doesn't seem to like encoded ampersands, so convert them back here $swf_upload_link = str_replace('&', '&', $swf_upload_link); $defaultpath = $ngg->options['gallerypath']; if ($_POST['addgallery']) { check_admin_referer('ngg_addgallery'); $newgallery = attribute_escape($_POST['galleryname']); if (!empty($newgallery)) { nggAdmin::create_gallery($newgallery, $defaultpath); } } if ($_POST['zipupload']) { check_admin_referer('ngg_addgallery'); if ($_FILES['zipfile']['error'] == 0) { $messagetext = nggAdmin::import_zipfile(intval($_POST['zipgalselect'])); } else { nggGallery::show_error(__('Upload failed!', 'nggallery')); } } if ($_POST['importfolder']) { check_admin_referer('ngg_addgallery'); $galleryfolder = $_POST['galleryfolder']; if (!empty($galleryfolder) and $defaultpath != $galleryfolder) { nggAdmin::import_gallery($galleryfolder); } } if ($_POST['uploadimage']) { check_admin_referer('ngg_addgallery'); if ($_FILES['MF__F_0_0']['error'] == 0) { $messagetext = nggAdmin::upload_images(); } else { nggGallery::show_error(__('Upload failed!', 'nggallery')); } } if (isset($_POST['swf_callback'])) { if ($_POST['galleryselect'] == "0") { nggGallery::show_error(__('No gallery selected !', 'nggallery')); } else { // get the path to the gallery $galleryID = (int) $_POST['galleryselect']; $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' "); nggAdmin::import_gallery($gallerypath); } } if (isset($_POST['disable_flash'])) { check_admin_referer('ngg_addgallery'); $ngg->options['swfUpload'] = false; update_option('ngg_options', $ngg->options); } if (isset($_POST['enable_flash'])) { check_admin_referer('ngg_addgallery'); $ngg->options['swfUpload'] = true; update_option('ngg_options', $ngg->options); } //get all galleries (after we added new ones) $gallerylist = nggdb::find_all_galleries(); ?> <?php if ($ngg->options['swfUpload']) { ?> <!-- SWFUpload script --> <script type="text/javascript"> var ngg_swf_upload; window.onload = function () { ngg_swf_upload = new SWFUpload({ // Backend settings upload_url : "<?php echo $swf_upload_link; ?> ", flash_url : "<?php echo NGGALLERY_URLPATH; ?> admin/js/swfupload.swf", // Button Settings button_placeholder_id : "spanButtonPlaceholder", button_width: 300, button_height: 27, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND, // File Upload Settings file_size_limit : "<?php echo wp_max_upload_size(); ?> b", file_types : "*.jpg;*.gif;*.png", file_types_description : "<?php _e('Image Files', 'nggallery'); ?> ", // Queue handler file_queued_handler : fileQueued, // Upload handler upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, post_params : { "auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?> ", "galleryselect" : "0" }, // i18names custom_settings : { "remove" : "<?php _e('remove', 'nggallery'); ?> ", "browse" : "<?php _e('Browse...', 'nggallery'); ?> ", "upload" : "<?php _e('Upload images', 'nggallery'); ?> " }, // Debug settings debug: false }); // on load change the upload to swfupload initSWFUpload(); }; </script> <div class="wrap" id="progressbar-wrap"> <div class="progressborder"> <div class="progressbar" id="progressbar"> <span>0%</span> </div> </div> </div> <?php } else { ?> <!-- MultiFile script --> <script type="text/javascript"> jQuery(function(){ jQuery('#imagefiles').MultiFile({ STRING: { remove:'<?php _e('remove', 'nggallery'); ?> ' } }); }); </script> <?php } ?> <!-- jQuery Tabs script --> <script type="text/javascript"> jQuery(function() { jQuery('#slider > ul').tabs({ fxFade: true, fxSpeed: 'fast' }); }); </script> <div id="slider" class="wrap"> <ul id="tabs"> <li><a href="#addgallery"><?php _e('Add new gallery', 'nggallery'); ?> </a></li> <?php if (wpmu_enable_function('wpmuZipUpload')) { ?> <li><a href="#zipupload"><?php _e('Upload a Zip-File', 'nggallery'); ?> </a></li> <?php } if (!IS_WPMU) { ?> <li><a href="#importfolder"><?php _e('Import image folder', 'nggallery'); ?> </a></li> <?php } ?> <li><a href="#uploadimage"><?php _e('Upload Images', 'nggallery'); ?> </a></li> </ul> <!-- create gallery --> <div id="addgallery"> <h2><?php _e('Add new gallery', 'nggallery'); ?> </h2> <form name="addgallery" id="addgallery_form" method="POST" action="<?php echo $filepath; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('New Gallery', 'nggallery'); ?> :</th> <td><input type="text" size="35" name="galleryname" value="" /><br /> <?php if (!IS_WPMU) { ?> <?php _e('Create a new , empty gallery below the folder', 'nggallery'); ?> <strong><?php echo $defaultpath; ?> </strong><br /> <?php } ?> <i>( <?php _e('Allowed characters for file and folder names are', 'nggallery'); ?> : a-z, A-Z, 0-9, -, _ )</i></td> </tr> </table> <div class="submit"><input class="button-primary" type="submit" name= "addgallery" value="<?php _e('Add gallery', 'nggallery'); ?> "/></div> </form> </div> <?php if (wpmu_enable_function('wpmuZipUpload')) { ?> <!-- zip-file operation --> <div id="zipupload"> <h2><?php _e('Upload a Zip-File', 'nggallery'); ?> </h2> <form name="zipupload" id="zipupload_form" method="POST" enctype="multipart/form-data" action="<?php echo $filepath . '#zipupload'; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Select Zip-File', 'nggallery'); ?> :</th> <td><input type="file" name="zipfile" id="zipfile" size="35" class="uploadform"/><br /> <?php _e('Upload a zip file with images', 'nggallery'); ?> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('in to', 'nggallery'); ?> </th> <td><select name="zipgalselect"> <option value="0" ><?php _e('a new gallery', 'nggallery'); ?> </option> <?php foreach ($gallerylist as $gallery) { $name = empty($gallery->title) ? $gallery->name : $gallery->title; echo '<option value="' . $gallery->gid . '" >' . $name . '</option>' . "\n"; } ?> </select> <br /><?php echo _e('Note : The upload limit on your server is ', 'nggallery') . "<strong>" . ini_get('upload_max_filesize') . "Byte</strong>\n"; ?> <br /><?php if (IS_WPMU && wpmu_enable_function('wpmuQuotaCheck')) { display_space_usage(); } ?> </td> </tr> </table> <div class="submit"><input class="button-primary" type="submit" name= "zipupload" value="<?php _e('Start upload', 'nggallery'); ?> "/></div> </form> </div> <?php } if (!IS_WPMU) { ?> <!-- import folder --> <div id="importfolder"> <h2><?php _e('Import image folder', 'nggallery'); ?> </h2> <form name="importfolder" id="importfolder_form" method="POST" action="<?php echo $filepath . '#importfolder'; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Import from Server path:', 'nggallery'); ?> </th> <td><input type="text" size="35" name="galleryfolder" value="<?php echo $defaultpath; ?> " /><br /> <?php _e('Import a folder with all images.', 'nggallery'); ?> <?php if (SAFE_MODE) { ?> <br /><?php _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'nggallery'); } ?> </td> </tr> </table> <div class="submit"><input class="button-primary" type="submit" name= "importfolder" value="<?php _e('Import folder', 'nggallery'); ?> "/></div> </form> </div> <?php } ?> <!-- upload images --> <div id="uploadimage"> <h2><?php _e('Upload Images', 'nggallery'); ?> </h2> <form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php echo $filepath . '#uploadimage'; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Upload image', 'nggallery'); ?> </th> <td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles" id="imagefiles" size="35" class="imagefiles"/></td> </tr> <tr valign="top"> <th scope="row"><?php _e('in to', 'nggallery'); ?> </th> <td><select name="galleryselect" id="galleryselect"> <option value="0" ><?php _e('Choose gallery', 'nggallery'); ?> </option> <?php foreach ($gallerylist as $gallery) { $name = empty($gallery->title) ? $gallery->name : $gallery->title; echo '<option value="' . $gallery->gid . '" >' . $name . '</option>' . "\n"; } ?> </select> <br /><?php echo _e('Note : The upload limit on your server is ', 'nggallery') . "<strong>" . ini_get('upload_max_filesize') . "Byte</strong>\n"; ?> <br /><?php if (IS_WPMU && wpmu_enable_function('wpmuQuotaCheck')) { display_space_usage(); } ?> </td> </tr> </table> <div class="submit"> <?php if ($ngg->options['swfUpload']) { ?> <input type="submit" name="disable_flash" id="disable_flash" title="<?php _e('The batch upload requires Adobe Flash 9, disable it if you have problems', 'nggallery'); ?> " value="<?php _e('Disable flash upload', 'nggallery'); ?> " /> <?php } else { ?> <input type="submit" name="enable_flash" id="enable_flash" title="<?php _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'nggallery'); ?> " value="<?php _e('Enable flash based upload', 'nggallery'); ?> " /> <?php } ?> <input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php _e('Upload images', 'nggallery'); ?> " /> </div> </form> </div> </div> <?php }
/** * Perform the upload and add a new hook for plugins * * @return void */ function processor() { global $wpdb, $ngg, $nggdb; $defaultpath = $ngg->options['gallerypath']; if (isset($_POST['addgallery'])) { check_admin_referer('ngg_addgallery'); if (!nggGallery::current_user_can('NextGEN Add new gallery')) { wp_die(__('Cheatin’ uh?')); } $newgallery = esc_attr($_POST['galleryname']); if (!empty($newgallery)) { nggAdmin::create_gallery($newgallery, $defaultpath); } } if (isset($_POST['zipupload'])) { check_admin_referer('ngg_addgallery'); if (!nggGallery::current_user_can('NextGEN Upload a zip')) { wp_die(__('Cheatin’ uh?')); } if ($_FILES['zipfile']['error'] == 0 || !empty($_POST['zipurl'])) { nggAdmin::import_zipfile(intval($_POST['zipgalselect'])); } else { nggGallery::show_error(__('Upload failed!', 'nggallery')); } } if (isset($_POST['importfolder'])) { check_admin_referer('ngg_addgallery'); if (!nggGallery::current_user_can('NextGEN Import image folder')) { wp_die(__('Cheatin’ uh?')); } $galleryfolder = $_POST['galleryfolder']; if (!empty($galleryfolder) and $defaultpath != $galleryfolder) { nggAdmin::import_gallery($galleryfolder); } } if (isset($_POST['uploadimage'])) { check_admin_referer('ngg_addgallery'); if (!nggGallery::current_user_can('NextGEN Upload in all galleries')) { wp_die(__('Cheatin’ uh?')); } if ($_FILES['imagefiles']['error'][0] == 0) { $messagetext = nggAdmin::upload_images(); } else { nggGallery::show_error(__('Upload failed! ' . nggAdmin::decode_upload_error($_FILES['imagefiles']['error'][0]), 'nggallery')); } } if (isset($_POST['swf_callback'])) { if ($_POST['galleryselect'] == '0') { nggGallery::show_error(__('No gallery selected !', 'nggallery')); } else { if ($_POST['swf_callback'] == '-1') { nggGallery::show_error(__('Upload failed! ', 'nggallery')); } else { $gallery = $nggdb->find_gallery((int) $_POST['galleryselect']); nggAdmin::import_gallery($gallery->path); } } } if (isset($_POST['disable_flash'])) { check_admin_referer('ngg_addgallery'); $ngg->options['swfUpload'] = false; update_option('ngg_options', $ngg->options); } if (isset($_POST['enable_flash'])) { check_admin_referer('ngg_addgallery'); $ngg->options['swfUpload'] = true; update_option('ngg_options', $ngg->options); } do_action('ngg_update_addgallery_page'); }
function upload_images_widget() { global $wpdb; // Image Array $imageslist = array(); // Get Gallery ID $galleryID = (int) $_POST['galleryselect']; if ($galleryID == 0) { if (get_option('npu_default_gallery')) { $galleryID = get_option('npu_default_gallery'); } else { nggGallery::show_error(__('No gallery selected.', 'nggallery')); return; } } // Get Gallery Path $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' "); if (!$gallerypath) { nggGallery::show_error(__('Failure in database, no gallery path set.', 'nggallery')); return; } // Read Image List $dirlist = $this->scandir(WINABSPATH . $gallerypath); foreach ($_FILES as $key => $value) { if ($_FILES[$key]['error'] == 0) { $temp_file = $_FILES[$key]['tmp_name']; $filepart = pathinfo(strtolower($_FILES[$key]['name'])); // Required Until PHP 5.2.0 $filepart['filename'] = substr($filepart["basename"], 0, strlen($filepart["basename"]) - (strlen($filepart["extension"]) + 1)); $filename = sanitize_title($filepart['filename']) . '.' . $filepart['extension']; // Allowed Extensions $ext = array('jpeg', 'jpg', 'png', 'gif'); if (!in_array($filepart['extension'], $ext) || !@getimagesize($temp_file)) { nggGallery::show_error('<strong>' . $_FILES[$key]['name'] . ' </strong>' . __('is not a valid file.', 'nggallery')); continue; } // Check If File Exists $i = 0; while (in_array($filename, $dirlist)) { $filename = sanitize_title($filepart['filename']) . '_' . $i++ . '.' . $filepart['extension']; } $dest_file = WINABSPATH . $gallerypath . '/' . $filename; // Check Folder Permissions if (!is_writeable(WINABSPATH . $gallerypath)) { $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $gallerypath); nggGallery::show_error($message); return; } // Save Temporary File if (!@move_uploaded_file($_FILES[$key]['tmp_name'], $dest_file)) { nggGallery::show_error(__('Error, the file could not moved to : ', 'nggallery') . $dest_file); $this->check_safemode(WINABSPATH . $gallerypath); continue; } if (!$this->chmod($dest_file)) { nggGallery::show_error(__('Error, the file permissions could not set.', 'nggallery')); continue; } // Add to Image and Dir List $imageslist[] = $filename; $dirlist[] = $filename; } } if (count($imageslist) > 0) { if (get_option('npu_exclude_select') == "Disabled") { $npu_exclude_id = 0; } else { $npu_exclude_id = 1; } // Add Images to Database $image_ids = $this->add_Images($galleryID, $imageslist); $this->arrThumbReturn = array(); foreach ($image_ids as $pid) { $wpdb->query("UPDATE {$wpdb->nggpictures} SET exclude = '{$npu_exclude_id}' WHERE pid = '{$pid}'"); $this->arrThumbReturn[] = $this->create_thumbnail($pid); } $this->arrImageIds = array(); $this->arrImageIds = $image_ids; $this->arrImageNames = array(); $this->arrImageNames = $imageslist; $this->strGalleryPath = $gallerypath; } return; }