Exemplo n.º 1
0
    /**
     * Render the page content
     * 
     * @return void
     */
    function controller()
    {
        global $ngg, $nggdb;
        // check for the max image size
        $this->maxsize = nggGallery::check_memory_limit();
        //get all galleries (after we added new ones)
        $this->gallerylist = $nggdb->find_all_galleries('gid', 'DESC');
        $this->defaultpath = $ngg->options['gallerypath'];
        // link for the flash file
        $swf_upload_link = NGGALLERY_URLPATH . 'admin/upload.php';
        // get list of tabs
        $tabs = $this->tabs_order();
        // with this filter you can add custom file types
        $file_types = apply_filters('ngg_swf_file_types', '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG');
        // Set the post params, which plupload will post back with the file, and pass them through a filter.
        $post_params = array("auth_cookie" => is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE], "logged_in_cookie" => $_COOKIE[LOGGED_IN_COOKIE], "_wpnonce" => wp_create_nonce('ngg_swfupload'), "galleryselect" => "0");
        $p = array();
        foreach ($post_params as $param => $val) {
            $val = esc_js($val);
            $p[] = "'{$param}' : '{$val}'";
        }
        $post_params_str = implode(',', $p) . "\n";
        ?>
	
	<?php 
        if ($ngg->options['swfUpload'] && !empty($this->gallerylist)) {
            ?>
    <?php 
            if (defined('IS_WP_3_3')) {
                ?>
    <!-- plupload script -->
    <script type="text/javascript">
    //<![CDATA[
    var resize_height = <?php 
                echo (int) $ngg->options['imgHeight'];
                ?>
, 
    	resize_width = <?php 
                echo (int) $ngg->options['imgWidth'];
                ?>
;
    
    jQuery(document).ready(function($) {
    	window.uploader = new plupload.Uploader({
    		runtimes: '<?php 
                echo apply_filters('plupload_runtimes', 'html5,flash,silverlight,html4,');
                ?>
',
    		browse_button: 'plupload-browse-button',
    		container: 'plupload-upload-ui',
    		drop_element: 'uploadimage',
    		file_data_name: 'Filedata',
    		max_file_size: '<?php 
                echo round((int) wp_max_upload_size() / 1024);
                ?>
kb',
    		url: '<?php 
                echo esc_js($swf_upload_link);
                ?>
',
    		flash_swf_url: '<?php 
                echo esc_js(includes_url('js/plupload/plupload.flash.swf'));
                ?>
',
    		silverlight_xap_url: '<?php 
                echo esc_js(includes_url('js/plupload/plupload.silverlight.xap'));
                ?>
',
    		filters: [
    			{title: '<?php 
                echo esc_js(__('Image Files', 'nggallery'));
                ?>
', extensions: '<?php 
                echo esc_js(str_replace(array('*.', ';'), array('', ','), $file_types));
                ?>
'}
    		],
    		multipart: true,
    		urlstream_upload: true,
    		multipart_params : {
    			<?php 
                echo $post_params_str;
                ?>
    		},
            debug: false,
            preinit : {
    			Init: function(up, info) {
    				debug('[Init]', 'Info :', info,  'Features :', up.features);
                    initUploader();
    			}
            },
			i18n : {
				'remove' : '<?php 
                _e('remove', 'nggallery');
                ?>
',
				'browse' : '<?php 
                _e('Browse...', 'nggallery');
                ?>
',
				'upload' : '<?php 
                _e('Upload images', 'nggallery');
                ?>
'
			}                                   
    	});
    
    	uploader.bind('FilesAdded', function(up, files) {
    		$.each(files, function(i, file) {
    			fileQueued(file);
    		});
    
    		up.refresh();
    	});
    
    	uploader.bind('BeforeUpload', function(up, file) {
            uploadStart(file);
    	});
    	
    	uploader.bind('UploadProgress', function(up, file) {
    		uploadProgress(file, file.loaded, file.size);
    	});
    	
    	uploader.bind('Error', function(up, err) {
    		uploadError(err.file, err.code, err.message);
    	
    		up.refresh();
    	});

    	uploader.bind('FileUploaded', function(up, file, response) {
    		uploadSuccess(file, response);
    	});
            
    	uploader.bind('UploadComplete', function(up, file) {
    		uploadComplete(file);
    	});

		// on load change the upload to plupload
		uploader.init();

		nggAjaxOptions = {
		  	header: "<?php 
                _e('Upload images', 'nggallery');
                ?>
",
		  	maxStep: 100
		};

    });
    //]]>
    </script>
    <?php 
            } else {
                ?>
	<!-- SWFUpload script -->
	<script type="text/javascript">
		var ngg_swf_upload;
			
		window.onload = function () {
			ngg_swf_upload = new SWFUpload({
				// Backend settings
				upload_url : "<?php 
                echo esc_js($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 : "<?php 
                echo $file_types;
                ?>
",
				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 is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE];
                ?>
",
                    "logged_in_cookie": "<?php 
                echo $_COOKIE[LOGGED_IN_COOKIE];
                ?>
",
                    "_wpnonce" : "<?php 
                echo wp_create_nonce('ngg_swfupload');
                ?>
",                    
					"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();

			nggAjaxOptions = {
			  	header: "<?php 
                _e('Upload images', 'nggallery');
                ?>
",
			  	maxStep: 100
			};
			
		};
	</script>
    <?php 
            }
            ?>
	
	<?php 
        } else {
            ?>
	<!-- MultiFile script -->
	<script type="text/javascript">	
	/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#imagefiles').MultiFile({
				STRING: {
			    	remove:'[<?php 
            _e('remove', 'nggallery');
            ?>
]'
  				}
		 	});
		});
	/* ]]> */
	</script>
	<?php 
        }
        ?>
	<!-- jQuery Tabs script -->
	<script type="text/javascript">
	/* <![CDATA[ */
		jQuery(document).ready(function(){
            jQuery('html,body').scrollTop(0);
			jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' });
            jQuery('#slider').css('display', 'block');  	
		});
		
		// File Tree implementation
		jQuery(function() {								 
		    jQuery("span.browsefiles").show().click(function(){
    		    jQuery("#file_browser").fileTree({
    		      script: "admin-ajax.php?action=ngg_file_browser&nonce=<?php 
        echo wp_create_nonce('ngg-ajax');
        ?>
",
                  root: jQuery("#galleryfolder").val()
    		    }, function(folder) {
    		        jQuery("#galleryfolder").val( folder );
    		    });
		    	jQuery("#file_browser").show('slide');
		    });	
		});
	/* ]]> */
	</script>
	<div id="slider" class="wrap" style="display: none;">
        <ul id="tabs">
            <?php 
        foreach ($tabs as $tab_key => $tab_name) {
            echo "\n\t\t<li><a href='#{$tab_key}'>{$tab_name}</a></li>";
        }
        ?>
		</ul>
        <?php 
        foreach ($tabs as $tab_key => $tab_name) {
            echo "\n\t<div id='{$tab_key}'>\n";
            // Looks for the internal class function, otherwise enable a hook for plugins
            if (method_exists($this, "tab_{$tab_key}")) {
                call_user_func(array(&$this, "tab_{$tab_key}"));
            } else {
                do_action('ngg_tab_content_' . $tab_key);
            }
            echo "\n\t</div>";
        }
        ?>
    </div>
    <?php 
    }
Exemplo n.º 2
0
    /**
     * Render the page content
     *
     * @return void
     */
    function controller()
    {
        global $ngg, $nggdb;
        // check for the max image size
        $this->maxsize = nggGallery::check_memory_limit();
        //get all galleries (after we added new ones)
        $this->gallerylist = $nggdb->find_all_galleries('gid', 'DESC');
        $this->defaultpath = $ngg->options['gallerypath'];
        // link for the flash file
        $swf_upload_link = admin_url('/?nggupload');
        // get list of tabs
        $tabs = $this->tabs_order();
        // with this filter you can add custom file types
        $file_types = apply_filters('ngg_swf_file_types', '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG');
        // Set the post params, which plupload will post back with the file, and pass them through a filter.
        $post_params = array("auth_cookie" => is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE], "logged_in_cookie" => $_COOKIE[LOGGED_IN_COOKIE], "_wpnonce" => wp_create_nonce('ngg_swfupload'), "galleryselect" => "0");
        $p = array();
        foreach ($post_params as $param => $val) {
            $val = esc_js($val);
            $p[] = "'{$param}' : '{$val}'";
        }
        $post_params_str = implode(',', $p) . "\n";
        ?>
	<div class="wrap ngg-wrap">
	<?php 
        screen_icon('nextgen-gallery');
        ?>
	<h2><?php 
        _e('Add Gallery / Images', 'nggallery');
        ?>
</h2>
	</div>
	<?php 
        if (!empty($this->gallerylist)) {
            ?>
	<?php 
            if ($ngg->options['swfUpload']) {
                ?>
    <!-- plupload script -->
    <script type="text/javascript">
    //<![CDATA[

    jQuery(document).ready(function($) {
    	window.uploader = new plupload.Uploader({
    		runtimes: '<?php 
                echo apply_filters('plupload_runtimes', 'html5,flash,silverlight,html4,');
                ?>
',
    		browse_button: 'plupload-browse-button',
    		container: 'plupload-upload-ui',
    		drop_element: 'uploadimage',
    		file_data_name: 'Filedata',
    		url: '<?php 
                echo esc_js($swf_upload_link);
                ?>
',
    		flash_swf_url: '<?php 
                echo esc_js(includes_url('js/plupload/plupload.flash.swf'));
                ?>
',
    		silverlight_xap_url: '<?php 
                echo esc_js(includes_url('js/plupload/plupload.silverlight.xap'));
                ?>
',
    		filters: {
				mime_types : [
					{title: '<?php 
                echo esc_js(__('Image Files', 'nggallery'));
                ?>
', extensions: '<?php 
                echo esc_js(str_replace(array('*.', ';'), array('', ','), $file_types));
                ?>
'}
				],
				max_file_size: '<?php 
                echo round((int) wp_max_upload_size() / 1024);
                ?>
kb'
			},
    		multipart: true,
    		urlstream_upload: true,
    		multipart_params : {
    			<?php 
                echo $post_params_str;
                ?>
    		},
			<?php 
                if ($ngg->options['imgAutoResize'] == 1) {
                    ?>
			resize: {
				width: <?php 
                    echo esc_js($ngg->options['imgWidth']);
                    ?>
,
				height: <?php 
                    echo esc_js($ngg->options['imgHeight']);
                    ?>
,
				quality: <?php 
                    echo esc_js($ngg->options['imgQuality']);
                    ?>
			},
			<?php 
                }
                ?>
            debug: false,
            preinit : {
    			Init: function(up, info) {
    				debug('[Init]', 'Info :', info,  'Features :', up.features);
                    if (navigator.appVersion.indexOf("MSIE 10") > -1) {
                        up.features.triggerDialog = true;
                    }
                    initUploader();
    			}
            },
			i18n : {
				'remove' : '<?php 
                _e('remove', 'nggallery');
                ?>
',
				'browse' : '<?php 
                _e('Browse...', 'nggallery');
                ?>
',
				'upload' : '<?php 
                _e('Upload images', 'nggallery');
                ?>
'
			}
    	});

    	uploader.bind('FilesAdded', function(up, files) {
    		$.each(files, function(i, file) {
    			fileQueued(file);
    		});

    		up.refresh();
    	});

    	uploader.bind('BeforeUpload', function(up, file) {
            uploadStart(file);
    	});

    	uploader.bind('UploadProgress', function(up, file) {
    		uploadProgress(file, file.loaded, file.size);
    	});

    	uploader.bind('Error', function(up, err) {
    		uploadError(err.file, err.code, err.message);

    		up.refresh();
    	});

    	uploader.bind('FileUploaded', function(up, file, response) {
    		uploadSuccess(file, response);
    	});

    	uploader.bind('UploadComplete', function(up, file) {
    		uploadComplete(file);
    	});

		// on load change the upload to plupload
		uploader.init();

		nggAjaxOptions = {
		  	header: "<?php 
                _e('Upload images', 'nggallery');
                ?>
",
		  	maxStep: 100
		};

    });
    //]]>
    </script>
	<?php 
            } else {
                ?>
	<!-- Browser upload script -->
	<script type="text/javascript">
	/* <![CDATA[ */
	var selDiv = "";

	document.addEventListener("DOMContentLoaded", init, false);

	function init() {
		document.querySelector('#imagefiles').addEventListener('change', handleFileSelect, false);
		selDiv = document.querySelector("#uploadQueue");
	}
		
	function handleFileSelect(e) {
		if(!e.target.files) return;
		selDiv.innerHTML = "";
		var files = e.target.files;
		for(var i=0; i<files.length; i++) {
			var f = files[i];	
			selDiv.innerHTML += f.name + "<br/>";
		}	
	}
	/* ]]> */
	</script>
	<?php 
            }
        }
        ?>
	<!-- jQuery Tabs script -->
	<script type="text/javascript">
	/* <![CDATA[ */
		jQuery(document).ready(function(){
            jQuery('html,body').scrollTop(0);
			jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' }).css({ 'display': 'block' });
		});

		// File Tree implementation
		jQuery(function() {
		    jQuery("span.browsefiles").show().click(function(){
    		    jQuery("#file_browser").fileTree({
    		      script: "admin-ajax.php?action=ngg_file_browser&nonce=<?php 
        echo wp_create_nonce('ngg-ajax');
        ?>
",
                  root: jQuery("#galleryfolder").val()
    		    }, function(folder) {
    		        jQuery("#galleryfolder").val( folder );
    		    });
		    	jQuery("#file_browser").show('slide');
		    });
		});
	
	//Check for a selected gallery on basic uploader and zip upload
	function checkForm(buttonID) {
		var e = document.getElementById(buttonID);
		var strUser = e.options[e.selectedIndex].value;
		if (strUser == "0") {
			alert("<?php 
        _e('You didn\'t select a gallery!', 'nggallery');
        ?>
");
			event.preventDefault();
		}
	}
	
	//Check if the user has selected a zip file
	function checkZipFile() {
		 if( !(document.getElementById('zipfile').value || document.getElementById("zipurl").value) ) { 
			alert("<?php 
        _e('You didn\'t select a file!', 'nggallery');
        ?>
");
			event.preventDefault();
		}
	}
	
	//Check if the user has selected an image file
	function checkImgFile() {
		 if( !document.getElementById('imagefiles').value ) { 
			alert("<?php 
        _e('You didn\'t select a file!', 'nggallery');
        ?>
");
			event.preventDefault();
		}
	}
	/* ]]> */
	</script>
	<div id="slider" class="wrap" style="display: none;">
        <ul id="tabs">
            <?php 
        foreach ($tabs as $tab_key => $tab_name) {
            echo "\n\t\t<li><a class='nav-tab' href='#{$tab_key}'>{$tab_name}</a></li>";
        }
        ?>
		</ul>
        <?php 
        foreach ($tabs as $tab_key => $tab_name) {
            echo "\n\t<div id='{$tab_key}'>\n";
            // Looks for the internal class function, otherwise enable a hook for plugins
            if (method_exists($this, "tab_{$tab_key}")) {
                call_user_func(array(&$this, "tab_{$tab_key}"));
            } else {
                do_action('ngg_tab_content_' . $tab_key);
            }
            echo "\n\t</div>";
        }
        ?>
    </div>
    <?php 
    }
Exemplo n.º 3
0
    /**
     * Render the page content
     * 
     * @return void
     */
    function controller()
    {
        global $ngg, $nggdb;
        // check for the max image size
        $this->maxsize = nggGallery::check_memory_limit();
        //get all galleries (after we added new ones)
        $this->gallerylist = $nggdb->find_all_galleries('gid', 'DESC');
        $this->defaultpath = $ngg->options['gallerypath'];
        // link for the flash file
        $swf_upload_link = NGGALLERY_URLPATH . 'admin/upload.php';
        // get list of tabs
        $tabs = $this->tabs_order();
        // with this filter you can add custom file types
        $file_types = apply_filters('ngg_swf_file_types', '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG');
        ?>
	
	<?php 
        if ($ngg->options['swfUpload'] && !empty($this->gallerylist)) {
            ?>
	<!-- SWFUpload script -->
	<script type="text/javascript">
		var ngg_swf_upload;
			
		window.onload = function () {
			ngg_swf_upload = new SWFUpload({
				// Backend settings
				upload_url : "<?php 
            echo esc_attr($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 : "<?php 
            echo $file_types;
            ?>
",
				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 is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE];
            ?>
",
                    "logged_in_cookie": "<?php 
            echo $_COOKIE[LOGGED_IN_COOKIE];
            ?>
",
                    "_wpnonce" : "<?php 
            echo wp_create_nonce('ngg_swfupload');
            ?>
",                    
					"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();

			nggAjaxOptions = {
			  	header: "<?php 
            _e('Upload images', 'nggallery');
            ?>
",
			  	maxStep: 100
			};
			
		};
	</script>
	
	<?php 
        } else {
            ?>
	<!-- MultiFile script -->
	<script type="text/javascript">	
	/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#imagefiles').MultiFile({
				STRING: {
			    	remove:'[<?php 
            _e('remove', 'nggallery');
            ?>
]'
  				}
		 	});
		});
	/* ]]> */
	</script>
	<?php 
        }
        ?>
	<!-- jQuery Tabs script -->
	<script type="text/javascript">
	/* <![CDATA[ */
		jQuery(document).ready(function(){
            jQuery('html,body').scrollTop(0);
			jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' });	
		});
		
		// File Tree implementation
		jQuery(function() {								 
		    jQuery("span.browsefiles").show().click(function(){
    		    jQuery("#file_browser").fileTree({
    		      script: "admin-ajax.php?action=ngg_file_browser&nonce=<?php 
        echo wp_create_nonce('ngg-ajax');
        ?>
",
                  root: jQuery("#galleryfolder").val(),
    		    }, function(folder) {
    		        jQuery("#galleryfolder").val( folder );
    		    });
		    	jQuery("#file_browser").show('slide');
		    });	
		});
	/* ]]> */
	</script>
	<div id="slider" class="wrap">
        <ul id="tabs">
            <?php 
        foreach ($tabs as $tab_key => $tab_name) {
            echo "\n\t\t<li><a href='#{$tab_key}'>{$tab_name}</a></li>";
        }
        ?>
		</ul>
        <?php 
        foreach ($tabs as $tab_key => $tab_name) {
            echo "\n\t<div id='{$tab_key}'>\n";
            // Looks for the internal class function, otherwise enable a hook for plugins
            if (method_exists($this, "tab_{$tab_key}")) {
                call_user_func(array(&$this, "tab_{$tab_key}"));
            } else {
                do_action('ngg_tab_content_' . $tab_key);
            }
            echo "\n\t</div>";
        }
        ?>
    </div>
    <?php 
    }
Exemplo n.º 4
0
function nggallery_admin_add_gallery()
{
    global $wpdb, $nggdb, $ngg;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
    // check for the max image size
    $maxsize = nggGallery::check_memory_limit();
    // 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('&#038;', '&', $swf_upload_link);
    $defaultpath = $ngg->options['gallerypath'];
    if ($_POST['addgallery']) {
        check_admin_referer('ngg_addgallery');
        $newgallery = esc_attr($_POST['galleryname']);
        if (!empty($newgallery)) {
            nggAdmin::create_gallery($newgallery, $defaultpath);
        }
    }
    if ($_POST['zipupload']) {
        check_admin_referer('ngg_addgallery');
        if ($_FILES['zipfile']['error'] == 0 || !empty($_POST['zipurl'])) {
            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['imagefiles']['error'][0] == 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('gid', 'DESC');
    ?>
	
	<?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;*.jpeg;*.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">	
	/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#imagefiles').MultiFile({
				STRING: {
			    	remove:'[<?php 
        _e('remove', 'nggallery');
        ?>
]'
  				}
		 	});
		});
	/* ]]> */
	</script>
	<?php 
    }
    ?>
	<!-- jQuery Tabs script -->
	<script type="text/javascript">
	/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#slider').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>
				<?php 
    do_action('ngg_add_new_gallery_form');
    ?>
				</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>
				<?php 
        if (function_exists('curl_init')) {
            ?>
				<tr valign="top"> 
					<th scope="row"><?php 
            _e('or enter a Zip-File URL', 'nggallery');
            ?>
:</th> 
					<td><input type="text" name="zipurl" id="zipurl" size="35" class="uploadform"/><br />
					<?php 
            _e('Import a zip file with images from a url', 'nggallery');
            ?>
</td> 
				</tr>
				<?php 
        }
        ?>
				<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) {
            if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                continue;
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
        }
        ?>
					</select>
					<br /><?php 
        echo $maxsize;
        ?>
					<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 />
					<br /><?php 
        echo $maxsize;
        ?>
					<?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) {
        if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
            continue;
        }
        $name = empty($gallery->title) ? $gallery->name : $gallery->title;
        echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
    }
    ?>
					</select>
					<br /><?php 
    echo $maxsize;
    ?>
					<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 10, 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 
}