Example #1
0
    function tab_uploadimage()
    {
        global $ngg;
        // check the cookie for the current setting
        $checked = get_user_setting('ngg_upload_resize') ? ' checked="true"' : '';
        ?>
    	<!-- upload images -->
    	<h2><?php 
        _e('Upload Images', 'nggallery');
        ?>
</h2>
		<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $this->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>
                <?php 
        if ($ngg->options['swfUpload'] && defined('IS_WP_3_3')) {
            ?>
				<td>
                <div id="plupload-upload-ui">
                	<div>
                    	<?php 
            _e('Choose files to upload');
            ?>
                    	<input id="plupload-browse-button" type="button" value="<?php 
            esc_attr_e('Select Files');
            ?>
" class="button" />
                	</div>
                	<p class="ngg-dragdrop-info howto" style="display:none;" ><?php 
            _e('Or you can drop the files into this window.');
            ?>
</p>
                    <div id='uploadQueue'></div>
                    <p><label><input name="image_resize" type="checkbox" id="image_resize" value="true"<?php 
            echo $checked;
            ?>
 />
                        <?php 
            printf(__('Scale images to max width %1$dpx or max height %2$dpx', 'nggallery'), (int) $ngg->options['imgWidth'], (int) $ngg->options['imgHeight']);
            ?>
                        <div id='image_resize_pointer'>&nbsp;</div>
                        </label>
                    </p>
                    
                 </div>
                </td>
                <?php 
        } else {
            ?>
				<td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></td>
                <?php 
        }
        ?>
            </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 ($this->gallerylist as $gallery) {
            //special case : we check if a user has this cap, then we override the second cap check
            if (!current_user_can('NextGEN Upload in all galleries')) {
                if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                    continue;
                }
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr($name) . '</option>' . "\n";
        }
        ?>
				</select>
				<br /><?php 
        echo $this->maxsize;
        ?>
				<br /><?php 
        if (is_multisite() && 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>
    <?php 
    }
Example #2
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('&#038;', '&', $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 
}
Example #3
0
    function tab_uploadimage()
    {
        global $ngg;
        ?>
    	<!-- upload images -->
    	<h2><?php 
        _e('Upload Images', 'nggallery');
        ?>
</h2>
		<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $this->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 ($this->gallerylist as $gallery) {
            //special case : we check if a user has this cap, then we override the second cap check
            if (!current_user_can('NextGEN Upload in all galleries')) {
                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 $this->maxsize;
        ?>
				<br /><?php 
        if (is_multisite() && 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>
    <?php 
    }
Example #4
0
function flag_admin_add_gallery()
{
    global $wpdb, $flagdb, $flag;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . urlencode($_GET['page']);
    // check for the max image size
    $maxsize = flagGallery::check_memory_limit();
    $defaultpath = $flag->options['galleryPath'];
    if ($_POST['addgallery']) {
        check_admin_referer('flag_addgallery');
        $newgallery = trim($_POST['galleryname']);
        if (!empty($newgallery)) {
            flagAdmin::create_gallery($newgallery, $defaultpath);
        }
    }
    if ($_POST['uploadimage']) {
        check_admin_referer('flag_upload');
        $flag->options['thumbWidth'] = intval($_POST['thumbWidth']) ? intval($_POST['thumbWidth']) : 100;
        $flag->options['thumbHeight'] = intval($_POST['thumbHeight']) ? intval($_POST['thumbHeight']) : 100;
        $flag->options['thumbFix'] = isset($_POST['thumbFix']) ? 1 : 0;
        update_option('flag_options', $flag->options);
        if ($_FILES['MF__F_0_0']['error'] == 0) {
            flagAdmin::upload_images();
        } else {
            flagGallery::show_error(__('Upload failed!', 'flag'));
        }
    }
    if ($_POST['importfolder']) {
        check_admin_referer('flag_addgallery');
        $galleryfolder = $_POST['galleryfolder'];
        if (!empty($galleryfolder) and $defaultpath != $galleryfolder and false === strpos($galleryfolder, '..')) {
            flagAdmin::import_gallery($galleryfolder);
        }
    }
    if (isset($_POST['disable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = false;
        update_option('flag_options', $flag->options);
    }
    if (isset($_POST['enable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = true;
        update_option('flag_options', $flag->options);
    }
    //get all galleries (after we added new ones)
    $gallerylist = $flagdb->find_all_galleries($flag->options['albSort'], $flag->options['albSortDir'], false, 0, 0, 0, true);
    ?>

	<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>
		<link rel="stylesheet" type="text/css" href="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.css"/>
		<script type="text/javascript" src="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.js"></script>
		<script type="text/javascript">
			/* <![CDATA[ */
			jQuery(function(){
				jQuery("span.browsefiles").show().click(function(){
					jQuery("#file_browser").fileTree({
						script: "admin-ajax.php?action=flag_file_browser&nonce=<?php 
        echo wp_create_nonce('flag-ajax');
        ?>
",
						root: jQuery("#galleryfolder").val()
					}, function(file){
						//var path = file.replace("<?php 
        echo WINABSPATH;
        ?>
", "");
						jQuery("#galleryfolder").val(file);
					});

					jQuery("#file_browser").show("slide");
				});
			});
			/* ]]> */
		</script>
	<?php 
    }
    ?>
	<div id="slider" class="flag-wrap">

		<ul id="tabs" class="tabs">
			<li class="selected"><a href="#" rel="addgallery"><?php 
    _e('Add new gallery', 'flag');
    ?>
</a></li>
			<li><a href="#" rel="uploadimage"><?php 
    _e('Upload Images', 'flag');
    ?>
</a></li>
			<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>
				<li><a href="#" rel="importfolder"><?php 
        _e('Import image folder', 'flag');
        ?>
</a></li>
			<?php 
    }
    ?>
		</ul>

		<!-- create gallery -->
		<div id="addgallery" class="cptab">
			<h2><?php 
    _e('Create a new gallery', 'flag');
    ?>
</h2>

			<form name="addgallery" id="addgallery_form" method="POST" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8">
				<?php 
    wp_nonce_field('flag_addgallery');
    ?>
				<table class="form-table" style="width: auto;">
					<tr>
						<th scope="col" colspan="2" style="padding-bottom: 0;">
							<strong><?php 
    _e('New Gallery', 'flag');
    ?>
</strong></th>
					</tr>
					<tr valign="top">
						<td><input type="text" size="65" name="galleryname" value=""/><br/>
							<?php 
    if (!IS_WPMU) {
        ?>
								<?php 
        _e('Create a new , empty gallery below the folder', 'flag');
        ?>
								<strong><?php 
        echo $defaultpath;
        ?>
</strong><br/>
							<?php 
    }
    ?>
							<i>( <?php 
    _e('Allowed characters for file and folder names are', 'flag');
    ?>
: a-z, A-Z, 0-9, -, _ )</i>
						</td>
						<?php 
    do_action('flag_add_new_gallery_form');
    ?>
						<td>
							<div class="submit" style="margin: 0; padding: 0;">
								<input class="button-primary" type="submit" name="addgallery" value="<?php 
    _e('Add gallery', 'flag');
    ?>
"/>
							</div>
						</td>
					</tr>
				</table>
				<p>&nbsp;</p>
			</form>
		</div>
		<!-- upload images -->
		<div id="uploadimage" class="cptab">
			<h2><?php 
    _e('Upload images', 'flag');
    ?>
</h2>

			<form name="uploadimage" id="gmUpload" method="POST" enctype="multipart/form-data" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8">
				<?php 
    wp_nonce_field('flag_upload');
    ?>
				<table class="flag-form-table">
					<tr valign="top">
						<td style="width: 216px;">
							<label for="galleryselect"><?php 
    _e('Upload images in', 'flag');
    ?>
 *</label>
							<select name="galleryselect" id="galleryselect" style="width: 200px">
								<option value="0"><?php 
    _e('Choose gallery', 'flag');
    ?>
</option>
								<?php 
    $ingallery = isset($_GET['gid']) ? (int) $_GET['gid'] : '';
    foreach ($gallerylist as $gallery) {
        if (!flagAdmin::can_manage_this_gallery($gallery->author)) {
            continue;
        }
        $name = empty($gallery->title) ? $gallery->name : esc_html(stripslashes($gallery->title));
        if ($flag->options['albSort'] == 'gid') {
            $name = '#' . $gallery->gid . ' - ' . $name;
        }
        if ($flag->options['albSort'] == 'title') {
            $name = $name . ' (#' . $gallery->gid . ')';
        }
        $sel = $ingallery == $gallery->gid ? 'selected="selected" ' : '';
        echo '<option ' . $sel . 'value="' . $gallery->gid . '" >' . $name . '</option>' . "\n";
    }
    ?>
							</select>
							<?php 
    echo $maxsize;
    ?>
							<br/><?php 
    if (IS_WPMU && flagGallery::flag_wpmu_enable_function('wpmuQuotaCheck')) {
        display_space_usage();
    }
    ?>
							<br/>

							<p><?php 
    _e('Thumbnail WIDTH x HEIGHT (in pixel)', 'flag');
    ?>
 *
								<br/><input type="text" size="5" maxlength="5" name="thumbWidth" id="thumbWidth" value="<?php 
    echo $flag->options['thumbWidth'];
    ?>
"/> x
								<input type="text" size="5" maxlength="5" name="thumbHeight" id="thumbHeight" value="<?php 
    echo $flag->options['thumbHeight'];
    ?>
"/>
								<br/>
								<small><?php 
    _e('These values are maximum values ', 'flag');
    ?>
</small>
							</p>
							<p>
								<label><input type="checkbox" name="thumbFix" id="thumbFix" value="1" <?php 
    checked('1', $flag->options['thumbFix']);
    ?>
 /> <?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'flag');
    ?>
								</label></p>

							<div class="submit">
					<span class="useflashupload">
					<?php 
    if ($flag->options['swfUpload']) {
        ?>
						<input type="submit" class="button-secondary" name="disable_flash" id="disable_flash" title="<?php 
        _e('The batch upload via Plupload, disable it if you have problems', 'flag');
        ?>
" value="<?php 
        _e('Switch to Browser Upload', 'flag');
        ?>
"/>
					<?php 
    } else {
        ?>
						<input type="submit" class="button-secondary" name="enable_flash" id="enable_flash" title="<?php 
        _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'flag');
        ?>
" value="<?php 
        _e('Switch to Plupload based Upload', 'flag');
        ?>
"/>
					<?php 
    }
    ?>
					</span>

								<div class="clear"></div>
							</div>

						</td>

						<td>
							<div id="pluploadUploader">
								<?php 
    if (!$flag->options['swfUpload']) {
        ?>
								<strong><?php 
        _e('Upload image(s):', 'flag');
        ?>
</strong><br>
								<input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/>
							</div>
						<span id="choosegalfirst">
							<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'flag');
        ?>
"/>
							<span class="disabledbut" style="display: none;"></span>
						</span>
							<?php 
    }
    ?>
						</td>
					</tr>
				</table>
				<div id="pl-message"></div>
			</form>
			<?php 
    if ($flag->options['swfUpload']) {
        $nonce = wp_create_nonce('flag_upload');
        ?>
				<script type="text/javascript">
					// Convert divs to queue widgets when the DOM is ready
					jQuery(function($){
						var files_remaining = 0;
						$("#pluploadUploader").plupload({
							runtimes: 'html5,flash,html4',
							url: '<?php 
        echo str_replace('&#038;', '&', wp_nonce_url(admin_url('admin-ajax.php?action=plupload_uploader'), 'flag_upload'));
        ?>
',
							multipart: true,
							multipart_params: {postData: '', pluploadimage: 1},
							max_file_size: '<?php 
        echo floor(wp_max_upload_size() * 0.99 / 1024 / 1024) - 1;
        ?>
Mb',
							unique_names: false,
							rename: true,
							chunk_size: '<?php 
        echo min(floor(wp_max_upload_size() * 0.99 / 1024 / 1024) - 1, 6);
        ?>
Mb',
							max_retries: 2,
							sortable: true,
							dragdrop: true,
							views: {
								list: true,
								thumbs: true,
								active: 'thumbs'
							},
							filters: [{title: "Images", extensions: "jpg,gif,png"}],
							flash_swf_url: '<?php 
        echo plugins_url(FLAGFOLDER . '/admin/js/plupload/plupload.flash.swf');
        ?>
'

						});

						var uploader = $("#pluploadUploader").plupload('getUploader');
						uploader.bind('QueueChanged StateChanged', function(up){
							if(up.state == plupload.QUEUED){
								files_remaining = up.files.length;
							}
							if(up.state == plupload.STARTED){
								up.settings.multipart_params = {
									galleryselect: jQuery('#galleryselect').val(),
									thumbw: jQuery('#thumbWidth').val(),
									thumbh: jQuery('#thumbHeight').val(),
									thumbf: jQuery('#thumbFix').prop("checked"),
									last: files_remaining,
									action: 'flag_plupload_uploader',
									_wpnonce: '<?php 
        echo $nonce;
        ?>
'
								};
							}
							if($("#galleryselect").val() == 0){
								$("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
							}
							console.log('[StateChanged]', up.state, up.settings.multipart_params);
						});
						uploader.bind('ChunkUploaded', function(up, file, info){
							console.log('[ChunkUploaded] File:', file, "Info:", info);
							var response = jQuery.parseJSON(info.response);
							if(response && response.error){
								up.stop();
								file.status = plupload.FAILED;
								console.log(response.error);
								up.trigger('QueueChanged StateChanged');
								up.trigger('UploadProgress', file);
								up.start();
							}
						});
						uploader.bind('FileUploaded', function(up, file, info){
							console.log('[FileUploaded] File:', file, "Info:", info);
							files_remaining--;
							if(info.response){
								file.status = plupload.FAILED;
								jQuery('<div/>').addClass('error').html('<span><u><em>' + file.name + ':</em></u> ' + info.response + '</span>').appendTo('#pl-message');
							}
						});
						uploader.bind('UploadProgress', function(up, file){
							var percent = uploader.total.percent;
							$('#total-progress-info .progress-bar').css('width', percent + "%").attr('aria-valuenow', percent);
						});
						uploader.bind('Error', function(up, args){
							jQuery('<div/>').addClass('error').html('<span><u><em>' + args.file.name + ':</em></u> ' + args.message + ' ' + args.status + '</span>').appendTo('#pl-message');
							console.log('[error] ', args);
						});
						uploader.bind('UploadComplete', function(up, files){
							console.log('[UploadComplete]', files);
							jQuery('<div/>').addClass('success').html('<?php 
        _e('Done!', 'flag');
        ?>
 <a href="<?php 
        echo wp_nonce_url($flag->manage_page->base_page . "&mode=edit", 'flag_editgallery');
        ?>
&gid=' + jQuery("#galleryselect").val() + '">Open Gallery</a>').appendTo('#pl-message');
						});

						jQuery("#gmUpload").on('click', '.ui-button-disabled', function(){
							if(files_remaining){
								alert("Choose gallery, please.")
							}
						});
						jQuery("#galleryselect").change(function(){
							if(jQuery(this).val() == 0){
								jQuery("#pluploadUploader_start").addClass('ui-button-disabled ui-state-disabled');
							} else{
								if(files_remaining){
									jQuery("#pluploadUploader_start").removeClass('ui-button-disabled ui-state-disabled');
								}
							}
						});

					});
				</script>
			<?php 
    } else {
        ?>
				<!-- MultiFile script -->
				<script type="text/javascript">
					/* <![CDATA[ */
					jQuery(document).ready(function(){
						jQuery('#imagefiles').MultiFile({
							STRING: {
								remove: '<?php 
        _e('remove', 'flag');
        ?>
'
							}
						});

						if(jQuery("#galleryselect").val() == 0){
							jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
							jQuery("#choosegalfirst .disabledbut").show();
						}
						jQuery("#choosegalfirst .disabledbut").click(function(){
							alert("Choose gallery, please.")
						});
						jQuery("#galleryselect").change(function(){
							if(jQuery(this).val() == 0){
								jQuery("#choosegalfirst .disabledbut").show();
								jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
							} else{
								jQuery("#choosegalfirst .disabledbut").hide();
								jQuery("#choosegalfirst").animate({opacity: "1"}, 600);
							}
						});
					});
					/* ]]> */
				</script>

			<?php 
    }
    ?>
		</div>
		<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>
			<!-- import folder -->
			<div id="importfolder" class="cptab">
				<h2><?php 
        _e('Import image folder', 'flag');
        ?>
</h2>

				<form name="importfolder" id="importfolder_form" method="POST" action="<?php 
        echo $filepath;
        ?>
" accept-charset="utf-8">
					<?php 
        wp_nonce_field('flag_addgallery');
        ?>
					<table class="form-table">
						<tr valign="top">
							<th scope="row"><?php 
        _e('Import from Server path:', 'flag');
        ?>
</th>
							<td>
								<input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php 
        echo $defaultpath;
        ?>
"/><span class="browsefiles button" style="display:none"><?php 
        _e('Browse...', "flag");
        ?>
</span>

								<div id="file_browser"></div>
								<div><?php 
        echo $maxsize;
        ?>
									<?php 
        if (SAFE_MODE) {
            ?>
										<br/><?php 
            _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'flag');
        }
        ?>
								</div>
							</td>
						</tr>
					</table>
					<div class="submit">
						<input class="button-primary" type="submit" name="importfolder" value="<?php 
        _e('Import folder', 'flag');
        ?>
"/>
					</div>
				</form>
			</div>
		<?php 
    }
    ?>

		<script type="text/javascript">
			var cptabs = new ddtabcontent("tabs");
			cptabs.setpersist(true);
			cptabs.setselectedClassTarget("linkparent");
			cptabs.init();
		</script>
	</div>
<?php 
}
Example #5
0
    function tab_uploadimage()
    {
        global $ngg;
        // check the cookie for the current setting
        //$checked = get_user_setting('ngg_upload_resize') ? ' checked="true"' : '';
        ?>
    	<!-- upload images -->
    	<h3><?php 
        _e('Upload images', 'nggallery');
        ?>
</h3>
		<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $this->filepath . '#uploadimage';
        ?>
" accept-charset="utf-8" >
		<?php 
        wp_nonce_field('ngg_addgallery');
        ?>
			<table class="form-table">
			<tr valign="top">
				<td scope="row" style="padding: 0;" colspan="2"><?php 
        _e('in to', 'nggallery');
        ?>
<select style="margin-left:10px;" name="galleryselect" id="galleryselect">
				<option value="0" ><?php 
        _e('Choose gallery', 'nggallery');
        ?>
</option>
				<?php 
        foreach ($this->gallerylist as $gallery) {
            //special case : we check if a user has this cap, then we override the second cap check
            if (!current_user_can('NextGEN Upload in all galleries')) {
                if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                    continue;
                }
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr($name) . '</option>' . "\n";
        }
        ?>
				</select>
				<br /><?php 
        echo $this->maxsize;
        ?>
				<br /><?php 
        if (is_multisite() && wpmu_enable_function('wpmuQuotaCheck')) {
            display_space_usage();
        }
        ?>
</td>
			</tr>
			<tr valign="top">
                <?php 
        if ($ngg->options['swfUpload']) {
            ?>
				<td colspan="2" style="padding: 0;">
                <div id="plupload-upload-ui">
				<div id="drag-drop-area" style="border: 4px dashed #bbb;height: 150px; padding:20px;">
				<div class="drag-drop-inside" style="margin:auto; text-align:center; width: 250px;">
					<p class="ngg-dragdrop-info drag-drop-info" style="font-size:20px;" >
					<?php 
            _e('Drop your files in this window', 'nggallery');
            ?>
<br/><span style="font-size:14px;"><?php 
            _e('Or', 'nggallery');
            ?>
</p>
                    <input style="margin:auto; text-align:center;" id="plupload-browse-button" type="button" value="<?php 
            esc_attr_e('Select Files', 'nggallery');
            ?>
" class="button" />
					</div>
					</div>
					</div>
                </td>
                <?php 
        } else {
            ?>
				<td><span id='spanButtonPlaceholder'></span>
				<input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles" multiple/></td>
                <?php 
        }
        ?>
				</tr>
				<tr><td><div id='uploadQueue' style="margin-top: 10px;"><td></div>
            </tr>
			</table>
			<div class="submit">
				<?php 
        if ($ngg->options['swfUpload']) {
            ?>
				<input class="button action" type="submit" name="disable_flash" id="disable_flash" title="<?php 
            _e('Click here to use the browser upload instead', 'nggallery');
            ?>
" value="<?php 
            _e('Use basic uploader', 'nggallery');
            ?>
" />
				<?php 
        } else {
            ?>
				<input class="button action" type="submit" name="enable_flash" id="enable_flash" title="<?php 
            _e('Advanced uploading', 'nggallery');
            ?>
" value="<?php 
            _e('Use advanced uploader', 'nggallery');
            ?>
" />
				<?php 
        }
        ?>
				<input <?php 
        if (!$ngg->options['swfUpload']) {
            ?>
 onclick="checkForm('galleryselect'); checkImgFile()" <?php 
        }
        ?>
 class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'nggallery');
        ?>
" />
				<?php 
        if ($ngg->options['imgAutoResize'] == 1) {
            ?>
				<span class="description" style="margin-left: 10px;"><?php 
            printf(__('Your images will be rescaled to max width %1$dpx or max height %2$dpx.', 'nggallery'), (int) $ngg->options['imgWidth'], (int) $ngg->options['imgHeight']);
            ?>
</span>
				<?php 
        }
        ?>
			</div>
		</form>
    <?php 
    }
Example #6
0
function flag_admin_add_gallery()
{
    global $wpdb, $flagdb, $flag;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . urlencode($_GET['page']);
    // check for the max image size
    $maxsize = flagGallery::check_memory_limit();
    $defaultpath = $flag->options['galleryPath'];
    if ($_POST['addgallery']) {
        check_admin_referer('flag_addgallery');
        $newgallery = trim($_POST['galleryname']);
        if (!empty($newgallery)) {
            flagAdmin::create_gallery($newgallery, $defaultpath);
        }
    }
    if ($_POST['uploadimage']) {
        check_admin_referer('flag_upload');
        if ($_FILES['MF__F_0_0']['error'] == 0) {
            flagAdmin::upload_images();
        } else {
            flagGallery::show_error(__('Upload failed!', 'flag'));
        }
    }
    if ($_POST['importfolder']) {
        check_admin_referer('flag_addgallery');
        $galleryfolder = $_POST['galleryfolder'];
        if (!empty($galleryfolder) and $defaultpath != $galleryfolder and false === strpos($galleryfolder, '..')) {
            flagAdmin::import_gallery($galleryfolder);
        }
    }
    if (isset($_POST['disable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = false;
        update_option('flag_options', $flag->options);
    }
    if (isset($_POST['enable_flash'])) {
        check_admin_referer('flag_upload');
        $flag->options['swfUpload'] = true;
        update_option('flag_options', $flag->options);
    }
    //get all galleries (after we added new ones)
    $gallerylist = $flagdb->find_all_galleries($flag->options['albSort'], $flag->options['albSortDir']);
    ?>

	
<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>

	<link rel="stylesheet" type="text/css" href="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.css" />
	<script type="text/javascript" src="<?php 
        echo FLAG_URLPATH;
        ?>
admin/js/jqueryFileTree/jqueryFileTree.js"></script>
	<script type="text/javascript">
	/* <![CDATA[ */
		  jQuery(function() {
		    jQuery("span.browsefiles").show().click(function(){
			    jQuery("#file_browser").fileTree({
			      script: "admin-ajax.php?action=flag_file_browser&nonce=<?php 
        echo wp_create_nonce('flag-ajax');
        ?>
",
			      root: jQuery("#galleryfolder").val()
			    }, function(file) {
			        //var path = file.replace("<?php 
        echo WINABSPATH;
        ?>
", "");
			        jQuery("#galleryfolder").val(file);
			    });

		    	jQuery("#file_browser").show("slide");
		    });
		  });
	/* ]]> */
	</script>
<?php 
    }
    ?>

	<div id="slider" class="wrap">
	
		<ul id="tabs" class="tabs">
			<li class="selected"><a href="#" rel="addgallery"><?php 
    _e('Add new gallery', 'flag');
    ?>
</a></li>
			<li><a href="#" rel="uploadimage"><?php 
    _e('Upload Images', 'flag');
    ?>
</a></li>
<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>

			<li><a href="#" rel="importfolder"><?php 
        _e('Import image folder', 'flag');
        ?>
</a></li>
<?php 
    }
    ?>

		</ul>

		<!-- create gallery -->
		<div id="addgallery" class="cptab">
			<h2><?php 
    _e('Create a new gallery', 'flag');
    ?>
</h2>
			<form name="addgallery" id="addgallery_form" method="POST" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8" >
			<?php 
    wp_nonce_field('flag_addgallery');
    ?>

				<table class="form-table" style="width: auto;"> 
				<tr>
					<th scope="col" colspan="2" style="padding-bottom: 0;"><strong><?php 
    _e('New Gallery', 'flag');
    ?>
</strong></th> 
				</tr>
				<tr valign="top"> 
					<td><input type="text" size="65" name="galleryname" value="" /><br />
					<?php 
    if (!IS_WPMU) {
        ?>

						<?php 
        _e('Create a new , empty gallery below the folder', 'flag');
        ?>
  <strong><?php 
        echo $defaultpath;
        ?>
</strong><br />
					<?php 
    }
    ?>

						<i>( <?php 
    _e('Allowed characters for file and folder names are', 'flag');
    ?>
: a-z, A-Z, 0-9, -, _ )</i></td>
					<?php 
    do_action('flag_add_new_gallery_form');
    ?>

					<td><div class="submit" style="margin: 0; padding: 0;"><input class="button-primary" type="submit" name= "addgallery" value="<?php 
    _e('Add gallery', 'flag');
    ?>
"/></div></td>
				</tr>
				</table>
				<p>&nbsp;</p>
			</form>
		</div>
		<!-- upload images -->
		<div id="uploadimage" class="cptab">
			<h2><?php 
    _e('Upload images', 'flag');
    ?>
</h2>
			<form name="uploadimage" id="gmUpload" method="POST" enctype="multipart/form-data" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8" >
				<?php 
    wp_nonce_field('flag_upload');
    ?>

				<table class="form-table">
				<tr valign="top">
					<td style="width: 216px;"><label for="galleryselect"><?php 
    _e('in to', 'flag');
    ?>
</label>
						<select name="galleryselect" id="galleryselect" style="width: 200px">
							<option value="0" ><?php 
    _e('Choose gallery', 'flag');
    ?>
</option>
							<?php 
    $ingallery = isset($_GET['gid']) ? (int) $_GET['gid'] : '';
    foreach ($gallerylist as $gallery) {
        if (!flagAdmin::can_manage_this_gallery($gallery->author)) {
            continue;
        }
        $name = empty($gallery->title) ? $gallery->name : esc_html(stripslashes($gallery->title));
        if ($flag->options['albSort'] == 'gid') {
            $name = $gallery->gid . ' - ' . $name;
        }
        if ($flag->options['albSort'] == 'title') {
            $name = $name . ' (' . $gallery->gid . ')';
        }
        $sel = $ingallery == $gallery->gid ? 'selected="selected" ' : '';
        echo '<option ' . $sel . 'value="' . $gallery->gid . '" >' . $name . '</option>' . "\n";
    }
    ?>

						</select>
						<?php 
    echo $maxsize;
    ?>

						<br /><?php 
    if (IS_WPMU && flagGallery::flag_wpmu_enable_function('wpmuQuotaCheck')) {
        display_space_usage();
    }
    ?>


						<div class="submit">
					<span class="useflashupload">
					<?php 
    if ($flag->options['swfUpload']) {
        ?>

						<input type="submit" name="disable_flash" id="disable_flash" title="<?php 
        _e('The batch upload via Plupload, disable it if you have problems', 'flag');
        ?>
" value="<?php 
        _e('Switch to Browser Upload', 'flag');
        ?>
" />
					<?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', 'flag');
        ?>
" value="<?php 
        _e('Switch to Plupload based Upload', 'flag');
        ?>
" />
					<?php 
    }
    ?>

					</span>
							<div class="clear"></div>
						</div>

					</td>

					<td><div id="pluploadUploader">
					<?php 
    if (!$flag->options['swfUpload']) {
        ?>

						<strong><?php 
        _e('Upload image(s):', 'flag');
        ?>
</strong><br>
						<input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></div>
						<span id="choosegalfirst">
							<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'flag');
        ?>
" />
							<span class="disabledbut" style="display: none;"></span>
						</span>
					<?php 
    }
    ?>

					</td>
				</tr>
				</table>
				<div id="pl-message"></div>
			</form>
<?php 
    if ($flag->options['swfUpload']) {
        ?>

	<script type="text/javascript">
		// Convert divs to queue widgets when the DOM is ready
		jQuery(function () {
			var files_remaining = 0;
			jQuery("#pluploadUploader").pluploadQueue({
				// General settings
				runtimes        		: 'flash,html5,html4',
				url             		: '<?php 
        echo str_replace('&#038;', '&', wp_nonce_url(plugins_url(FLAGFOLDER . '/admin/upload.php'), 'flag_upload'));
        ?>
',
				multipart       		: true,
				multipart_params		: { postData: ''},
				max_file_size					: '<?php 
        echo min(floor(wp_max_upload_size() * 0.99 / 1024 / 1024) - 1, 8);
        ?>
Mb',
				unique_names    		: false,
				rename          		: true,
				urlstream_upload	: true,

				// Resize images on clientside if we can
				//resize 						: {width : 150, height : 150, quality : 90},

				// Specify what files to browse for
				filters         		: [{title: "Images", extensions: "jpg,gif,png"}],

				// Flash settings
				flash_swf_url   		: '<?php 
        echo plugins_url(FLAGFOLDER . '/admin/js/plupload/plupload.flash.swf');
        ?>
',

				// PreInit events, bound before any internal events
				preinit : {
					Init: function(up, info) {
						console.log('[Init]', 'Info:', info, 'Features:', up.features);
					},

					UploadFile: function(up, file) {
						console.log('[UploadFile]', file);
						up.settings.multipart_params = { galleryselect: jQuery('#galleryselect').val(), last: files_remaining };
						files_remaining--;
						// You can override settings before the file is uploaded
						// up.settings.url = 'upload.php?id=' + file.id;
						// up.settings.multipart_params = {param1 : 'value1', param2 : 'value2'};
					}
				},

				// Post init events, bound after the internal events
				init : {
					Refresh: function(up) {
						// Called when upload shim is moved
						console.log('[Refresh]');
						files_remaining = up.files.length;
						if(jQuery("#galleryselect").val() == 0) {
							jQuery(".plupload_start").addClass("plupload_disabled");
						}
					},

					StateChanged: function(up) {
						// Called when the state of the queue is changed
						console.log('[StateChanged]', up.state == plupload.STARTED ? "STARTED" : "STOPPED");
					},

					QueueChanged: function(up) {
						// Called when the files in queue are changed by adding/removing files
						console.log('[QueueChanged]');
					},

					UploadProgress: function(up, file) {
						// Called while a file is being uploaded
						console.log('[UploadProgress]', 'File:', file, "Total:", up.total);
					},

					FileUploaded: function(up, file, info) {
						// Called when a file has finished uploading
						console.log('[FileUploaded] File:', file, "Info:", info);
						if (info.response){
							file.status = plupload.FAILED;
							jQuery('<div/>').addClass('error').html('<span><u><em>'+file.name+':</em></u> '+info.response+'</span>').appendTo('#pl-message');
						}
					},

					Error: function(up, args) {
						// Called when a error has occured
						jQuery('<div/>').addClass('error').html('<span><u><em>'+args.file.name+':</em></u> '+args.message+' '+args.status+'</span>').appendTo('#pl-message');
						console.log('[error] ', args);
					},

					UploadComplete: function(up, file) {
						console.log('[UploadComplete]');
						jQuery(".plupload_buttons").css("display", "inline");
						jQuery(".plupload_upload_status").css("display", "inline");
						jQuery(".plupload_start").addClass("plupload_disabled");
						jQuery("#gmUpload").one("mousedown", ".plupload_add", function () {
							up.splice();
							up.trigger('Refresh');
							//up.refresh();
						});
						jQuery('<div/>').addClass('success').html('<?php 
        _e('Done!', 'flag');
        ?>
 <a href="<?php 
        echo wp_nonce_url($flag->manage_page->base_page . "&mode=edit", 'flag_editgallery');
        ?>
&gid=' + jQuery("#galleryselect").val() + '">Open Gallery</a>').appendTo('#pl-message');
					}
				}
			});
			jQuery("#gmUpload").on('click','.plupload_disabled',function(){
				if(files_remaining){
					alert("Choose gallery, please.")
				}
			});
			jQuery("#galleryselect").change(function () {
				if(jQuery(this).val() == 0) {
					jQuery(".plupload_start").addClass('plupload_disabled');
				} else {
					if(files_remaining){
						jQuery(".plupload_start").removeClass('plupload_disabled');
					}
				}
			});

		});
	</script>
<?php 
    } else {
        ?>

	<!-- MultiFile script -->
	<script type="text/javascript">
		/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#imagefiles').MultiFile({
				STRING: {
					remove:'<?php 
        _e('remove', 'flag');
        ?>
'
				}
			});

			if(jQuery("#galleryselect").val() == 0) {
				jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
				jQuery("#choosegalfirst .disabledbut").show();
			}
			jQuery("#choosegalfirst .disabledbut").click(function () {
				alert("Choose gallery, please.")
			});
			jQuery("#galleryselect").change(function () {
				if(jQuery(this).val() == 0) {
					jQuery("#choosegalfirst .disabledbut").show();
					jQuery("#choosegalfirst").animate({opacity: "0.5"}, 600);
				} else {
					jQuery("#choosegalfirst .disabledbut").hide();
					jQuery("#choosegalfirst").animate({opacity: "1"}, 600);
				}
			});
		});
		/* ]]> */
	</script>

<?php 
    }
    ?>

		</div>
<?php 
    if (!IS_WPMU || current_user_can('FlAG Import folder')) {
        ?>

		<!-- import folder -->
		<div id="importfolder" class="cptab">
		<h2><?php 
        _e('Import image folder', 'flag');
        ?>
</h2>
			<form name="importfolder" id="importfolder_form" method="POST" action="<?php 
        echo $filepath;
        ?>
" accept-charset="utf-8" >
			<?php 
        wp_nonce_field('flag_addgallery');
        ?>

				<table class="form-table">
				<tr valign="top"> 
					<th scope="row"><?php 
        _e('Import from Server path:', 'flag');
        ?>
</th> 
					<td><input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php 
        echo $defaultpath;
        ?>
" /><span class="browsefiles button" style="display:none"><?php 
        _e('Browse...', "flag");
        ?>
</span>
					<div id="file_browser"></div>
					<div><?php 
        echo $maxsize;
        ?>

					<?php 
        if (SAFE_MODE) {
            ?>
<br /><?php 
            _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'flag');
        }
        ?>
</div></td> 
				</tr>
				</table>
				<div class="submit"><input class="button-primary" type="submit" name="importfolder" value="<?php 
        _e('Import folder', 'flag');
        ?>
"/></div>
			</form>
		</div>
<?php 
    }
    ?>


<script type="text/javascript">
	var cptabs=new ddtabcontent("tabs");
	cptabs.setpersist(true);
	cptabs.setselectedClassTarget("linkparent");
	cptabs.init();
</script>
</div>
<?php 
}