Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • I worked something out, that saved me a lot of time.

    I copied the tabs Create new gallery and import Image folders, replaced the text input with a textarea, so you can place a comma separated list. While processing i exploded the textarea input and surrounded the worker call with a foreach.

    Create multiple galleries works like a charm with my 78 galleries, though there will be a limit by php_execution time. Import Multiple folder has got the same limitation and i tried it with stacks of 25 galleries. For some of them there were no thumbs created, but that is a task you can do from the gallery overview.

    So creating the galleries, copying files and importing them took me just an hour. Creating thumbs took an other hour, but that was a low brainer.

    My mods are quick and dirty, need some style clean up, but they work.

    Here is a diff of the modification to the original file

    --- D:/Download/nextgen-gallery/admin/addgallery.php	Wed Feb 17 10:23:22 2010
    +++ X:/subdomains/test/httpdocs/wp-content/plugins/nextgen-gallery/admin/addgallery.php	Thu Feb 25 10:12:16 2010
    @@ -29,6 +29,15 @@
     			nggAdmin::create_gallery($newgallery, $defaultpath);
     	}
    
    +	if ($_POST['addmultigallery']){
    +		check_admin_referer('ngg_addgallery');
    +		$newgalleries = explode(',', esc_attr( $_POST['gallerynames']));
    +		foreach ($newgalleries as $newgallery) {
    +			if ( !empty($newgallery) )
    +				nggAdmin::create_gallery($newgallery, $defaultpath);
    +		}
    +	}
    +
     	if ($_POST['zipupload']){
     		check_admin_referer('ngg_addgallery');
     		if ($_FILES['zipfile']['error'] == 0 || (!empty($_POST['zipurl'])))
    @@ -44,6 +53,15 @@
     			nggAdmin::import_gallery($galleryfolder);
     	}
    
    +	if ($_POST['importmultifolder']){
    +		check_admin_referer('ngg_addgallery');
    +		$galleryfolders = explode(',', $_POST['galleryfolders']);
    +		foreach ( $galleryfolders as $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 )
    @@ -178,6 +196,8 @@
     			<li><a href="#importfolder"><?php _e('Import image folder', 'nggallery') ;?></a></li>
     			<?php } ?>
     			<li><a href="#uploadimage"><?php _e('Upload Images', 'nggallery') ;?></a></li>
    +			<li><a href="#addmultigallery"><?php _e('Add multiple new galleries', 'nggallery') ;?></a></li>
    +			<li><a href="#importmultifolder"><?php _e('Import multiple image folders', 'nggallery') ;?></a></li>
     		</ul>
    
     		<!-- create gallery -->
    @@ -294,6 +314,44 @@
     				</div>
     			</form>
     		</div>
    +		<!-- create multiple gallery -->
    +		<div id="addmultigallery">
    +		<h2><?php _e('Add multiple new galleries', '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><textarea name="gallerynames" value=""></textarea><br />
    +					<?php if(!IS_WPMU) { ?>
    +					<?php _e('Create multiple new, empty galleries 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= "addmultigallery" value="<?php _e('Add multiple galleries', 'nggallery') ;?>"/></div>
    +			</form>
    +		</div>
    +		<?php
    +		if (!IS_WPMU) {?>
    +		<!-- import multiple folder -->
    +		<div id="importmultifolder">
    +		<h2><?php _e('Import multiple image folders', '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><textarea size="35" name="galleryfolders"><?php echo $defaultpath; ?></textarea><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') ;?><?php }; ?></td>
    +				</tr>
    +				</table>
    +				<div class="submit"><input class="button-primary" type="submit" name= "importmultifolder" value="<?php _e('Import multiple folders', 'nggallery') ;?>"/></div>
    +			</form>
    +		</div>
    +		<?php } ?>
     	</div>
     	<?php
     	}

    Well, if have php knowledge and i wouldn’t care about user friendliness. A manual import will take me days. So i have to script something. If i do it myself it will be quick and very dirty.

    I would really like to take a look at your script.

    Hi there and thx to Alex for this great plugin.

    I also have to import about 100 galleries with over 2000 pictures.

    @chuckrock, alexrabe

    Did you work something out you could share?

Viewing 3 replies - 1 through 3 (of 3 total)