Exemple #1
0
 function post_processor_galleries()
 {
     global $wpdb, $ngg, $nggdb;
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('ngg_bulkgallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 // No action
                 break;
             case 'recover_images':
                 // Recover images from backup
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
                 break;
             case 'set_watermark':
                 // Set watermark
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'import_meta':
                 // Import Metadata
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
                 break;
             case 'delete_gallery':
                 // Delete gallery
                 if (is_array($_POST['doaction'])) {
                     $deleted = false;
                     foreach ($_POST['doaction'] as $id) {
                         // get the path to the gallery
                         $gallery = nggdb::find_gallery($id);
                         if ($gallery) {
                             //TODO:Remove also Tag reference, look here for ids instead filename
                             $imagelist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery->gid}' ");
                             if ($ngg->options['deleteImg']) {
                                 if (is_array($imagelist)) {
                                     foreach ($imagelist as $filename) {
                                         @unlink(WINABSPATH . $gallery->path . '/thumbs/thumbs_' . $filename);
                                         @unlink(WINABSPATH . $gallery->path . '/' . $filename);
                                         @unlink(WINABSPATH . $gallery->path . '/' . $filename . '_backup');
                                     }
                                 }
                                 // delete folder
                                 @rmdir(WINABSPATH . $gallery->path . '/thumbs');
                                 @rmdir(WINABSPATH . $gallery->path);
                             }
                         }
                         do_action('ngg_delete_gallery', $id);
                         $deleted = nggdb::delete_gallery($id);
                     }
                     if ($deleted) {
                         nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
                     }
                 }
                 break;
         }
     }
     if (isset($_POST['addgallery']) && isset($_POST['galleryname'])) {
         check_admin_referer('ngg_addgallery');
         if (!nggGallery::current_user_can('NextGEN Add new gallery')) {
             wp_die(__('Cheatin’ uh?'));
         }
         // get the default path for a new gallery
         $defaultpath = $ngg->options['gallerypath'];
         $newgallery = esc_attr($_POST['galleryname']);
         if (!empty($newgallery)) {
             nggAdmin::create_gallery($newgallery, $defaultpath);
         }
         do_action('ngg_update_addgallery_page');
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
         $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         update_option('ngg_options', $ngg->options);
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_resize_image', $gallery_ids, __('Resize images', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
         $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
         $ngg->options['thumbfix'] = isset($_POST['thumbfix']) ? true : false;
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         update_option('ngg_options', $ngg->options);
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_create_thumbnail', $gallery_ids, __('Create new thumbnails', 'nggallery'));
     }
 }
Exemple #2
0
 /**
  * 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');
 }
Exemple #3
0
 function post_processor_galleries()
 {
     global $wpdb, $ngg, $nggdb;
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('ngg_bulkgallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 // No action
                 break;
             case 'recover_images':
                 // Recover images from backup
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
                 break;
             case 'set_watermark':
                 // Set watermark
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'import_meta':
                 // Import Metadata
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
                 break;
             case 'delete_gallery':
                 // Delete gallery
                 if (is_array($_POST['doaction'])) {
                     $deleted = FALSE;
                     $mapper = C_Gallery_Mapper::get_instance();
                     foreach ($_POST['doaction'] as $id) {
                         if ($mapper->destroy($id, TRUE)) {
                             $deleted = TRUE;
                         }
                     }
                     if ($deleted) {
                         nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
                     }
                 }
                 break;
         }
     }
     if (isset($_POST['addgallery']) && isset($_POST['galleryname'])) {
         check_admin_referer('ngg_addgallery');
         if (!nggGallery::current_user_can('NextGEN Add new gallery')) {
             wp_die(__('Cheatin’ uh?', 'nggallery'));
         }
         // get the default path for a new gallery
         $defaultpath = $ngg->options['gallerypath'];
         $newgallery = $_POST['galleryname'];
         if (!empty($newgallery)) {
             nggAdmin::create_gallery($newgallery, $defaultpath);
         }
         do_action('ngg_update_addgallery_page');
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
         $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         update_option('ngg_options', $ngg->options);
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_resize_image', $gallery_ids, __('Resize images', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('ngg_thickbox_form');
         // save the new values for the next operation
         $settings = C_NextGen_Settings::get_instance();
         $settings->thumbwidth = (int) $_POST['thumbwidth'];
         $settings->thumbheight = (int) $_POST['thumbheight'];
         $settings->thumbfix = isset($_POST['thumbfix']) ? TRUE : FALSE;
         $settings->save();
         ngg_refreshSavedSettings();
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_create_thumbnail', $gallery_ids, __('Create new thumbnails', 'nggallery'));
     }
 }
Exemple #4
0
 /**
  * Method "ngg.newGallery"
  * Create a new gallery
  * 
  * @since 1.4
  * 
  * @param array $args Method parameters.
  * 			- int blog_id
  *	    	- string username
  *	    	- string password
  *	    	- string new gallery name
  * @return int with new gallery ID
  */
 function newGallery($args)
 {
     global $ngg;
     require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
     // admin functions
     $this->escape($args);
     $blog_ID = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $name = $args[3];
     $id = false;
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     if (!current_user_can('NextGEN Manage gallery')) {
         return new IXR_Error(401, __('Sorry, you must be able to manage galleries'));
     }
     if (!empty($name)) {
         $id = nggAdmin::create_gallery($name, $ngg->options['gallerypath'], false);
     }
     if (!$id) {
         return new IXR_Error(500, __('Sorry, could not create the gallery'));
     }
     return $id;
 }
Exemple #5
0
 function post_processor_galleries()
 {
     global $wpdb, $ngg, $nggdb;
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('ngg_bulkgallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 // No action
                 break;
             case 'recover_images':
                 // Recover images from backup
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
                 break;
             case 'set_watermark':
                 // Set watermark
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'import_meta':
                 // Import Metadata
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
                 break;
             case 'delete_gallery':
                 // Delete gallery
                 if (is_array($_POST['doaction'])) {
                     $deleted = false;
                     foreach ($_POST['doaction'] as $id) {
                         // get the path to the gallery
                         $gallery = nggdb::find_gallery($id);
                         if ($gallery) {
                             //TODO:Remove also Tag reference, look here for ids instead filename
                             $imagelist = $wpdb->get_col("SELECT pid FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery->gid}' ");
                             if ($ngg->options['deleteImg']) {
                                 $storage = C_Component_Registry::get_instance()->get_utility('I_Gallery_Storage');
                                 if (is_array($imagelist)) {
                                     foreach ($imagelist as $pid) {
                                         $storage->delete_image($pid);
                                     }
                                 }
                                 // delete folder. abspath provided by nggdb::find_gallery()
                                 $fs = C_Fs::get_instance();
                                 @rmdir($fs->join_paths($gallery->abspath, 'thumbs'));
                                 @rmdir($fs->join_paths($gallery->abspath, 'dynamic'));
                                 @rmdir($gallery->abspath);
                             }
                         }
                         do_action('ngg_delete_gallery', $id);
                         $deleted = nggdb::delete_gallery($id);
                     }
                     if ($deleted) {
                         nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
                     }
                 }
                 break;
         }
     }
     if (isset($_POST['addgallery']) && isset($_POST['galleryname'])) {
         check_admin_referer('ngg_addgallery');
         if (!nggGallery::current_user_can('NextGEN Add new gallery')) {
             wp_die(__('Cheatin’ uh?', 'nggallery'));
         }
         // get the default path for a new gallery
         $defaultpath = $ngg->options['gallerypath'];
         $newgallery = $_POST['galleryname'];
         if (!empty($newgallery)) {
             nggAdmin::create_gallery($newgallery, $defaultpath);
         }
         do_action('ngg_update_addgallery_page');
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
         $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         update_option('ngg_options', $ngg->options);
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_resize_image', $gallery_ids, __('Resize images', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('ngg_thickbox_form');
         // save the new values for the next operation
         $settings = C_NextGen_Settings::get_instance();
         $settings->thumbwidth = (int) $_POST['thumbwidth'];
         $settings->thumbheight = (int) $_POST['thumbheight'];
         $settings->thumbfix = isset($_POST['thumbfix']) ? TRUE : FALSE;
         $settings->save();
         ngg_refreshSavedSettings();
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_create_thumbnail', $gallery_ids, __('Create new thumbnails', 'nggallery'));
     }
 }
Exemple #6
0
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 
}
Exemple #7
0
 function post_processor_galleries()
 {
     global $wpdb, $ngg, $nggdb;
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('ngg_bulkgallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 // No action
                 break;
             case 'set_watermark':
                 // Set watermark
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'import_meta':
                 // Import Metadata
                 // A prefix 'gallery_' will first fetch all ids from the selected galleries
                 nggAdmin::do_ajax_operation('gallery_import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
                 break;
         }
     }
     if (isset($_POST['addgallery']) && isset($_POST['galleryname'])) {
         check_admin_referer('ngg_addgallery');
         // get the default path for a new gallery
         $defaultpath = $ngg->options['gallerypath'];
         $newgallery = esc_attr($_POST['galleryname']);
         if (!empty($newgallery)) {
             nggAdmin::create_gallery($newgallery, $defaultpath);
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
         $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         update_option('ngg_options', $ngg->options);
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_resize_image', $gallery_ids, __('Resize images', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
         $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
         $ngg->options['thumbfix'] = (bool) $_POST['thumbfix'];
         // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
         update_option('ngg_options', $ngg->options);
         $gallery_ids = explode(',', $_POST['TB_imagelist']);
         // A prefix 'gallery_' will first fetch all ids from the selected galleries
         nggAdmin::do_ajax_operation('gallery_create_thumbnail', $gallery_ids, __('Create new thumbnails', 'nggallery'));
     }
 }