예제 #1
0
 /**
  * Save/Load options and add a new hook for plugins
  * 
  * @return void
  */
 function processor()
 {
     global $ngg, $nggRewrite;
     $old_state = $ngg->options['usePermalinks'];
     if (isset($_POST['irDetect'])) {
         check_admin_referer('ngg_settings');
         $ngg->options['irURL'] = ngg_search_imagerotator();
         update_option('ngg_options', $ngg->options);
     }
     if (isset($_POST['updateoption'])) {
         check_admin_referer('ngg_settings');
         // get the hidden option fields, taken from WP core
         if ($_POST['page_options']) {
             $options = explode(',', stripslashes($_POST['page_options']));
         }
         if ($options) {
             foreach ($options as $option) {
                 $option = trim($option);
                 $value = isset($_POST[$option]) ? trim($_POST[$option]) : false;
                 //		$value = sanitize_option($option, $value); // This does stripslashes on those that need it
                 $ngg->options[$option] = $value;
             }
             // the path should always end with a slash
             $ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
             $ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
             // the custom sortorder must be ascending
             $ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
         }
         // Save options
         update_option('ngg_options', $ngg->options);
         // Flush Rewrite rules
         if ($old_state != $ngg->options['usePermalinks']) {
             $nggRewrite->flush();
         }
         nggGallery::show_message(__('Update Successfully', 'nggallery'));
     }
     if (isset($_POST['clearcache'])) {
         check_admin_referer('ngg_settings');
         $path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
         if (is_dir($path)) {
             if ($handle = opendir($path)) {
                 while (false !== ($file = readdir($handle))) {
                     if ($file != '.' && $file != '..') {
                         @unlink($path . '/' . $file);
                     }
                 }
                 closedir($handle);
             }
         }
         nggGallery::show_message(__('Cache cleared', 'nggallery'));
     }
     if (isset($_POST['createslugs'])) {
         check_admin_referer('ngg_settings');
         include_once dirname(__FILE__) . '/upgrade.php';
         ngg_rebuild_unique_slugs::start_rebuild();
     }
     do_action('ngg_update_options_page');
 }
예제 #2
0
function nggallery_admin_options()
{
    global $wpdb, $ngg, $nggRewrite;
    $old_state = $ngg->options['usePermalinks'];
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
    if (isset($_POST['updateoption'])) {
        check_admin_referer('ngg_settings');
        // get the hidden option fields, taken from WP core
        if ($_POST['page_options']) {
            $options = explode(',', stripslashes($_POST['page_options']));
        }
        if ($options) {
            foreach ($options as $option) {
                $option = trim($option);
                $value = trim($_POST[$option]);
                //		$value = sanitize_option($option, $value); // This does stripslashes on those that need it
                $ngg->options[$option] = $value;
            }
            // the path should always end with a slash
            $ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
            $ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
            // the custom sortorder must be ascending
            $ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
        }
        // Save options
        update_option('ngg_options', $ngg->options);
        // Flush ReWrite rules
        if ($old_state != $ngg->options['usePermalinks']) {
            $nggRewrite->flush();
        }
        nggGallery::show_message(__('Update Successfully', 'nggallery'));
    }
    if (isset($_POST['clearcache'])) {
        $path = WINABSPATH . $ngg->options['gallerypath'] . "cache/";
        if (is_dir($path)) {
            if ($handle = opendir($path)) {
                while (false !== ($file = readdir($handle))) {
                    if ($file != '.' && $file != '..') {
                        @unlink($path . '/' . $file);
                    }
                }
                closedir($handle);
            }
        }
        nggGallery::show_message(__('Cache cleared', 'nggallery'));
    }
    // message windows
    if (!empty($messagetext)) {
        echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . $messagetext . '</p></div>';
    }
    ?>
	<script type="text/javascript">
		jQuery(function() {
			jQuery('#slider > ul').tabs({ fxFade: true, fxSpeed: 'fast' });	
		});
	
		function insertcode(value) {
			var effectcode;
			switch (value) {
			  case "none":
			    effectcode = "";
			    jQuery('#tbImage').hide("slow");
			    break;
			  case "thickbox":
			    effectcode = 'class="thickbox" rel="%GALLERY_NAME%"';
			    jQuery('#tbImage').show("slow");
			    break;
			  case "lightbox":
			    effectcode = 'rel="lightbox[%GALLERY_NAME%]"';
			    jQuery('#tbImage').hide("slow");
			    break;
			  case "highslide":
			    effectcode = 'class="highslide" onclick="return hs.expand(this, { slideshowGroup: %GALLERY_NAME% })"';
			    jQuery('#tbImage').hide("slow");
			    break;
			  case "shutter":
			    effectcode = 'class="shutterset_%GALLERY_NAME%"';
			    jQuery('#tbImage').hide("slow");
			    break;
			  default:
			    break;
			}
			jQuery("#thumbCode").val(effectcode);
		};
		
		function setcolor(fileid,color) {
			jQuery(fileid).css("background", color );
		};
	</script>
	
	<div id="slider" class="wrap">
	
		<ul id="tabs">
			<li><a href="#generaloptions"><?php 
    _e('General Options', 'nggallery');
    ?>
</a></li>
			<li><a href="#thumbnails"><?php 
    _e('Thumbnails', 'nggallery');
    ?>
</a></li>
			<li><a href="#images"><?php 
    _e('Images', 'nggallery');
    ?>
</a></li>
			<li><a href="#gallery"><?php 
    echo __ngettext('Gallery', 'Galleries', 1, 'nggallery');
    ?>
</a></li>
			<li><a href="#effects"><?php 
    _e('Effects', 'nggallery');
    ?>
</a></li>
			<li><a href="#watermark"><?php 
    _e('Watermark', 'nggallery');
    ?>
</a></li>
			<li><a href="#slideshow"><?php 
    _e('Slideshow', 'nggallery');
    ?>
</a></li>
		</ul>

		<!-- General Options -->

		<div id="generaloptions">
			<h2><?php 
    _e('General Options', 'nggallery');
    ?>
</h2>
			<form name="generaloptions" method="post">
			<?php 
    wp_nonce_field('ngg_settings');
    ?>
			<input type="hidden" name="page_options" value="gallerypath,deleteImg,useMediaRSS,usePicLens,usePermalinks,graphicLibrary,imageMagickDir,activateTags,appendType,maxImages" />
				<table class="form-table ngg-options">
					<tr valign="top">
						<th align="left"><?php 
    _e('Gallery path', 'nggallery');
    ?>
</th>
						<td><input <?php 
    if (IS_WPMU) {
        echo 'readonly = "readonly"';
    }
    ?>
 type="text" size="35" name="gallerypath" value="<?php 
    echo $ngg->options['gallerypath'];
    ?>
" />
						<span class="setting-description"><?php 
    _e('This is the default path for all galleries', 'nggallery');
    ?>
</span></td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Delete image files', 'nggallery');
    ?>
</th>
						<td><input <?php 
    if (IS_WPMU) {
        echo 'readonly = "readonly"';
    }
    ?>
 type="checkbox" name="deleteImg" value="1" <?php 
    checked('1', $ngg->options['deleteImg']);
    ?>
 />
						<?php 
    _e('Delete files, when removing a gallery in the database', 'nggallery');
    ?>
</td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Activate permalinks', 'nggallery');
    ?>
</th>
						<td><input type="checkbox" name="usePermalinks" value="1" <?php 
    checked('1', $ngg->options['usePermalinks']);
    ?>
 />
						<?php 
    _e('When you activate this option, you need to update your permalink structure one time.', 'nggallery');
    ?>
</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Select graphic library', 'nggallery');
    ?>
:</th>
						<td><label><input name="graphicLibrary" type="radio" value="gd" <?php 
    checked('gd', $ngg->options['graphicLibrary']);
    ?>
 /> <?php 
    _e('GD Library', 'nggallery');
    ?>
</label><br />
						<label><input name="graphicLibrary" type="radio" value="im" <?php 
    checked('im', $ngg->options['graphicLibrary']);
    ?>
 /> <?php 
    _e('ImageMagick (Experimental). Path to the library :', 'nggallery');
    ?>
&nbsp;
						<input <?php 
    if (IS_WPMU) {
        echo 'readonly = "readonly"';
    }
    ?>
 type="text" size="35" name="imageMagickDir" value="<?php 
    echo $ngg->options['imageMagickDir'];
    ?>
" /></label>
						</td>
					</tr>
					<tr>
						<th align="left"><?php 
    _e('Activate Media RSS feed', 'nggallery');
    ?>
</th>
						<td><input type="checkbox" name="useMediaRSS" value="1" <?php 
    checked('1', $ngg->options['useMediaRSS']);
    ?>
 />
						<span class="setting-description"><?php 
    _e('A RSS feed will be added to you blog header. Usefull for CoolIris/PicLens', 'nggallery');
    ?>
</span></td>
					</tr>
					<tr>
						<th align="left"><?php 
    _e('Activate PicLens/CoolIris support', 'nggallery');
    ?>
 (<a href="http://www.cooliris.com">CoolIris</a>)</th>
						<td><input type="checkbox" name="usePicLens" value="1" <?php 
    checked('1', $ngg->options['usePicLens']);
    ?>
 />
						<span class="setting-description"><?php 
    _e('When you activate this option, some javascript is added to your site footer. Make sure that wp_footer is called in your theme.', 'nggallery');
    ?>
</span></td>
					</tr>
				</table>
			<h3><?php 
    _e('Tags / Categories', 'nggallery');
    ?>
</h3>
				<table class="form-table ngg-options">
					<tr>
						<th valign="top"><?php 
    _e('Activate related images', 'nggallery');
    ?>
:</th>
						<td><input name="activateTags" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['activateTags']);
    ?>
 />
						<?php 
    _e('This option will append related images to every post', 'nggallery');
    ?>
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Match with', 'nggallery');
    ?>
:</th>
						<td><label><input name="appendType" type="radio" value="category" <?php 
    checked('category', $ngg->options['appendType']);
    ?>
 /> <?php 
    _e('Categories', 'nggallery');
    ?>
</label><br />
						<label><input name="appendType" type="radio" value="tags" <?php 
    checked('tags', $ngg->options['appendType']);
    ?>
 /> <?php 
    _e('Tags', 'nggallery');
    ?>
</label>
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Max. number of images', 'nggallery');
    ?>
:</th>
						<td><input type="text" name="maxImages" value="<?php 
    echo $ngg->options['maxImages'];
    ?>
" size="3" maxlength="3" />
						<span class="setting-description"><?php 
    _e('0 will show all images', 'nggallery');
    ?>
</span>
						</td>
					</tr>
				</table> 				
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
			</form>	
		</div>	
		
		<!-- Thumbnail settings -->
		
		<div id="thumbnails">
			<h2><?php 
    _e('Thumbnail settings', 'nggallery');
    ?>
</h2>
			<form name="thumbnailsettings" method="POST" action="<?php 
    echo $filepath . '#thumbnails';
    ?>
" >
			<?php 
    wp_nonce_field('ngg_settings');
    ?>
			<input type="hidden" name="page_options" value="thumbwidth,thumbheight,thumbfix,thumbcrop,thumbquality" />
				<p><?php 
    _e('Please note : If you change the settings, you need to recreate the thumbnails under -> Manage Gallery .', 'nggallery');
    ?>
</p>
				<table class="form-table ngg-options">
					<tr valign="top">
						<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
						<td><input type="text" size="4" maxlength="4" name="thumbwidth" value="<?php 
    echo $ngg->options['thumbwidth'];
    ?>
" /> x <input type="text" size="4" maxlength="4" name="thumbheight" value="<?php 
    echo $ngg->options['thumbheight'];
    ?>
" />
						<span class="setting-description"><?php 
    _e('These values are maximum values ', 'nggallery');
    ?>
</span></td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Set fix dimension', 'nggallery');
    ?>
</th>
						<td><input type="checkbox" name="thumbfix" value="1" <?php 
    checked('1', $ngg->options['thumbfix']);
    ?>
 />
						<?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Crop square thumbnail from image', 'nggallery');
    ?>
</th>
						<td><input type="checkbox" name="thumbcrop" value="1" <?php 
    checked('1', $ngg->options['thumbcrop']);
    ?>
 />
						<?php 
    _e('Create square thumbnails, use only the width setting :', 'nggallery');
    ?>
 <?php 
    echo $ngg->options['thumbwidth'];
    ?>
 x <?php 
    echo $ngg->options['thumbwidth'];
    ?>
</td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Thumbnail quality', 'nggallery');
    ?>
</th>
						<td><input type="text" size="3" maxlength="3" name="thumbquality" value="<?php 
    echo $ngg->options['thumbquality'];
    ?>
" /> %</td>
					</tr>
				</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
			</form>	
		</div>
		
		<!-- Image settings -->
		
		<div id="images">
			<h2><?php 
    _e('Image settings', 'nggallery');
    ?>
</h2>
			<form name="imagesettings" method="POST" action="<?php 
    echo $filepath . '#images';
    ?>
" >
			<?php 
    wp_nonce_field('ngg_settings');
    ?>
			<input type="hidden" name="page_options" value="imgResize,imgWidth,imgHeight,imgQuality,imgCacheSinglePic" />
				<table class="form-table ngg-options">
					<tr valign="top">
						<th scope="row"><label for="fixratio"><?php 
    _e('Resize Images', 'nggallery');
    ?>
</label></th>
						<!--TODO: checkbox fixratio can be used later -->
						<td><input type="hidden" name="imgResize" value="1" <?php 
    checked('1', $ngg->options['imgResize']);
    ?>
 /> </td>
						<td><input type="text" size="5" name="imgWidth" value="<?php 
    echo $ngg->options['imgWidth'];
    ?>
" /> x <input type="text" size="5" name="imgHeight" value="<?php 
    echo $ngg->options['imgHeight'];
    ?>
" />
						<span class="setting-description"><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</span></td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Image quality', 'nggallery');
    ?>
</th>
						<td></td>
						<td><input type="text" size="3" maxlength="3" name="imgQuality" value="<?php 
    echo $ngg->options['imgQuality'];
    ?>
" /> %</td>
					</tr>
				</table>
				<h3><?php 
    _e('Single picture', 'nggallery');
    ?>
</h3>
				<table class="form-table ngg-options">
					<tr valign="top">
						<th align="left"><?php 
    _e('Cache single pictures', 'nggallery');
    ?>
</th>
						<td></td>
						<td><input <?php 
    if (IS_WPMU) {
        echo 'readonly = "readonly"';
    }
    ?>
 type="checkbox" name="imgCacheSinglePic" value="1" <?php 
    checked('1', $ngg->options['imgCacheSinglePic']);
    ?>
 />
						<span class="setting-description"><?php 
    _e('Creates a file for each singlepic settings. Reduce the CPU load', 'nggallery');
    ?>
</span></td>
					</tr>
					<tr valign="top">
						<th align="left"><?php 
    _e('Clear cache folder', 'nggallery');
    ?>
</th>
						<td></td>
						<td><input type="submit" name="clearcache" class="button-secondary"  value="<?php 
    _e('Proceed now', 'nggallery');
    ?>
 &raquo;"/></td>
					</tr>
				</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
			</form>	
		</div>
		
		<!-- Gallery settings -->
		
		<div id="gallery">
			<h2><?php 
    _e('Gallery settings', 'nggallery');
    ?>
</h2>
			<form name="galleryform" method="POST" action="<?php 
    echo $filepath . '#gallery';
    ?>
" >
			<?php 
    wp_nonce_field('ngg_settings');
    ?>
			<input type="hidden" name="page_options" value="galNoPages,galImages,galShowSlide,galTextSlide,galTextGallery,galShowOrder,galImgBrowser,galSort,galSortDir" />
				<table class="form-table ngg-options">
					<tr>
						<th valign="top"><?php 
    _e('Deactivate gallery page link', 'nggallery');
    ?>
:</th>
						<td><input name="galNoPages" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['galNoPages']);
    ?>
 />
						<?php 
    _e('The album will not link to a gallery subpage. The gallery is shown on the same page.', 'nggallery');
    ?>
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Number of images per page', 'nggallery');
    ?>
:</th>
						<td><input type="text" name="galImages" value="<?php 
    echo $ngg->options['galImages'];
    ?>
" size="3" maxlength="3" />
						<span class="setting-description"><?php 
    _e('0 will disable pagination, all images on one page', 'nggallery');
    ?>
</span>
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Integrate slideshow', 'nggallery');
    ?>
:</th>
						<td><input name="galShowSlide" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['galShowSlide']);
    ?>
 />
							<input type="text" name="galTextSlide" value="<?php 
    echo $ngg->options['galTextSlide'];
    ?>
" size="20" />
							<input type="text" name="galTextGallery" value="<?php 
    echo $ngg->options['galTextGallery'];
    ?>
" size="20" />
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Show first', 'nggallery');
    ?>
:</th>
						<td><label><input name="galShowOrder" type="radio" value="gallery" <?php 
    checked('gallery', $ngg->options['galShowOrder']);
    ?>
 /> <?php 
    _e('Thumbnails', 'nggallery');
    ?>
</label><br />
						<label><input name="galShowOrder" type="radio" value="slide" <?php 
    checked('slide', $ngg->options['galShowOrder']);
    ?>
 /> <?php 
    _e('Slideshow', 'nggallery');
    ?>
</label>
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Show ImageBrowser', 'nggallery');
    ?>
:</th>
						<td><input name="galImgBrowser" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['galImgBrowser']);
    ?>
 />
						<?php 
    _e('The gallery will open the ImageBrowser instead the effect.', 'nggallery');
    ?>
						</td>
					</tr>
				</table>
			<h3><?php 
    _e('Sort options', 'nggallery');
    ?>
</h3>
				<table class="form-table ngg-options">
					<tr>
						<th valign="top"><?php 
    _e('Sort thumbnails', 'nggallery');
    ?>
:</th>
						<td>
						<label><input name="galSort" type="radio" value="sortorder" <?php 
    checked('sortorder', $ngg->options['galSort']);
    ?>
 /> <?php 
    _e('Custom order', 'nggallery');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="pid" <?php 
    checked('pid', $ngg->options['galSort']);
    ?>
 /> <?php 
    _e('Image ID', 'nggallery');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="filename" <?php 
    checked('filename', $ngg->options['galSort']);
    ?>
 /> <?php 
    _e('File name', 'nggallery');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="alttext" <?php 
    checked('alttext', $ngg->options['galSort']);
    ?>
 /> <?php 
    _e('Alt / Title text', 'nggallery');
    ?>
</label><br />
						<label><input name="galSort" type="radio" value="imagedate" <?php 
    checked('imagedate', $ngg->options['galSort']);
    ?>
 /> <?php 
    _e('Date / Time', 'nggallery');
    ?>
</label>
						</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Sort direction', 'nggallery');
    ?>
:</th>
						<td><label><input name="galSortDir" type="radio" value="ASC" <?php 
    checked('ASC', $ngg->options['galSortDir']);
    ?>
 /> <?php 
    _e('Ascending', 'nggallery');
    ?>
</label><br />
						<label><input name="galSortDir" type="radio" value="DESC" <?php 
    checked('DESC', $ngg->options['galSortDir']);
    ?>
 /> <?php 
    _e('Descending', 'nggallery');
    ?>
</label>
						</td>
					</tr>
				</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
			</form>	
		</div>
		
		<!-- Effects settings -->
		
		<div id="effects">
			<h2><?php 
    _e('Effects', 'nggallery');
    ?>
</h2>
			<form name="effectsform" method="POST" action="<?php 
    echo $filepath . '#effects';
    ?>
" >
			<?php 
    wp_nonce_field('ngg_settings');
    ?>
			<input type="hidden" name="page_options" value="thumbEffect,thumbCode" />
			<p><?php 
    _e('Here you can select the thumbnail effect, NextGEN Gallery will integrate the required HTML code in the images. Please note that only the Thickbox effect will automatic added to your theme.', 'nggallery');
    ?>
			<?php 
    _e('With the placeholder', 'nggallery');
    ?>
<strong> %GALLERY_NAME% </strong> <?php 
    _e('you can activate a navigation through the images (depend on the effect). Change the code line only , when you use a different thumbnail effect or you know what you do.', 'nggallery');
    ?>
</p>
				<table class="form-table ngg-options">
					<tr valign="top">
						<th><?php 
    _e('JavaScript Thumbnail effect', 'nggallery');
    ?>
:</th>
						<td>
						<select size="1" id="thumbEffect" name="thumbEffect" onchange="insertcode(this.value)">
							<option value="none" <?php 
    selected('none', $ngg->options['thumbEffect']);
    ?>
 ><?php 
    _e('None', 'nggallery');
    ?>
</option>
							<option value="thickbox" <?php 
    selected('thickbox', $ngg->options['thumbEffect']);
    ?>
 ><?php 
    _e('Thickbox', 'nggallery');
    ?>
</option>
							<option value="lightbox" <?php 
    selected('lightbox', $ngg->options['thumbEffect']);
    ?>
 ><?php 
    _e('Lightbox', 'nggallery');
    ?>
</option>
							<option value="highslide" <?php 
    selected('highslide', $ngg->options['thumbEffect']);
    ?>
 ><?php 
    _e('Highslide', 'nggallery');
    ?>
</option>
							<option value="shutter" <?php 
    selected('shutter', $ngg->options['thumbEffect']);
    ?>
 ><?php 
    _e('Shutter', 'nggallery');
    ?>
</option>
							<option value="custom" <?php 
    selected('custom', $ngg->options['thumbEffect']);
    ?>
 ><?php 
    _e('Custom', 'nggallery');
    ?>
</option>
						</select>
						</td>
					</tr>
					<tr valign="top">
						<th><?php 
    _e('Link Code line', 'nggallery');
    ?>
 :</th>
						<td><textarea id="thumbCode" name="thumbCode" cols="50" rows="5"><?php 
    echo htmlspecialchars(stripslashes($ngg->options['thumbCode']));
    ?>
</textarea></td>
					</tr>
				</table>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
			</form>	
		</div>
		
		<!-- Watermark settings -->
		
		<?php 
    $imageID = $wpdb->get_var("SELECT MIN(pid) FROM {$wpdb->nggpictures}");
    $imageID = $wpdb->get_row("SELECT * FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}'");
    if ($imageID) {
        $imageURL = '<img width="75%" src="' . NGGALLERY_URLPATH . 'nggshow.php?pid=' . $imageID->pid . '&amp;mode=watermark&amp;width=320&amp;height=240" alt="' . $imageID->alttext . '" title="' . $imageID->alttext . '" />';
    }
    ?>
		<div id="watermark">
			<h2><?php 
    _e('Watermark', 'nggallery');
    ?>
</h2>
			<p><?php 
    _e('Please note : You can only activate the watermark under -> Manage Gallery . This action cannot be undone.', 'nggallery');
    ?>
</p>
			<form name="watermarkform" method="POST" action="<?php 
    echo $filepath . '#watermark';
    ?>
" >
			<?php 
    wp_nonce_field('ngg_settings');
    ?>
			<input type="hidden" name="page_options" value="wmPos,wmXpos,wmYpos,wmType,wmPath,wmFont,wmSize,wmColor,wmText,wmOpaque" />
			<div id="wm-preview">
				<h3><?php 
    _e('Preview', 'nggallery');
    ?>
</h3>
				<p style="text-align:center;"><?php 
    echo $imageURL;
    ?>
</p>
				<h3><?php 
    _e('Position', 'nggallery');
    ?>
</h3>
				<div>
				    <table id="wm-position">
					<tr>
						<td valign="top">
							<strong><?php 
    _e('Position', 'nggallery');
    ?>
</strong>
							<table border="1">
								<tr>
									<td><input type="radio" name="wmPos" value="topLeft" <?php 
    checked('topLeft', $ngg->options['wmPos']);
    ?>
 /></td>
									<td><input type="radio" name="wmPos" value="topCenter" <?php 
    checked('topCenter', $ngg->options['wmPos']);
    ?>
 /></td>
									<td><input type="radio" name="wmPos" value="topRight" <?php 
    checked('topRight', $ngg->options['wmPos']);
    ?>
 /></td>
								</tr>
								<tr>
									<td><input type="radio" name="wmPos" value="midLeft" <?php 
    checked('midLeft', $ngg->options['wmPos']);
    ?>
 /></td>
									<td><input type="radio" name="wmPos" value="midCenter" <?php 
    checked('midCenter', $ngg->options['wmPos']);
    ?>
 /></td>
									<td><input type="radio" name="wmPos" value="midRight" <?php 
    checked('midRight', $ngg->options['wmPos']);
    ?>
 /></td>
								</tr>
								<tr>
									<td><input type="radio" name="wmPos" value="botLeft" <?php 
    checked('botLeft', $ngg->options['wmPos']);
    ?>
 /></td>
									<td><input type="radio" name="wmPos" value="botCenter" <?php 
    checked('botCenter', $ngg->options['wmPos']);
    ?>
 /></td>
									<td><input type="radio" name="wmPos" value="botRight" <?php 
    checked('botRight', $ngg->options['wmPos']);
    ?>
 /></td>
								</tr>
							</table>
						</td>
						<td valign="top">
							<strong><?php 
    _e('Offset', 'nggallery');
    ?>
</strong>
							<table border="0">
								<tr>
									<td>x</td>
									<td><input type="text" name="wmXpos" value="<?php 
    echo $ngg->options['wmXpos'];
    ?>
" size="4" /> px</td>
								</tr>
								<tr>
									<td>y</td>
									<td><input type="text" name="wmYpos" value="<?php 
    echo $ngg->options['wmYpos'];
    ?>
" size="4" /> px</td>
								</tr>
							</table>
						</td>
					</tr>
					</table>
				</div>
			</div> 
				<h3><label><input type="radio" name="wmType" value="image" <?php 
    checked('image', $ngg->options['wmType']);
    ?>
 /> <?php 
    _e('Use image as watermark', 'nggallery');
    ?>
</label></h3>
				<table class="wm-table form-table">
					<tr>
						<th><?php 
    _e('URL to file', 'nggallery');
    ?>
 :</th>
						<td><input type="text" size="40" name="wmPath" value="<?php 
    echo $ngg->options['wmPath'];
    ?>
" /><br />
						<?php 
    if (!ini_get('allow_url_fopen')) {
        _e('The accessing of URL files is disabled at your server (allow_url_fopen)', 'nggallery');
    }
    ?>
 </td>
					</tr>
				</table>	
				<h3><label><input type="radio" name="wmType" value="text" <?php 
    checked('text', $ngg->options['wmType']);
    ?>
 /> <?php 
    _e('Use text as watermark', 'nggallery');
    ?>
</label></h3>
				<table class="wm-table form-table">	
					<tr>
						<th><?php 
    _e('Font', 'nggallery');
    ?>
:</th>
						<td><select name="wmFont" size="1">	<?php 
    $fontlist = ngg_get_TTFfont();
    foreach ($fontlist as $fontfile) {
        echo "\n" . '<option value="' . $fontfile . '" ' . ngg_input_selected($fontfile, $ngg->options['wmFont']) . ' >' . $fontfile . '</option>';
    }
    ?>
							</select><br /><span class="setting-description">
							<?php 
    if (!function_exists(ImageTTFBBox)) {
        _e('This function will not work, cause you need the FreeType library', 'nggallery');
    } else {
        _e('You can upload more fonts in the folder <strong>nggallery/fonts</strong>', 'nggallery');
    }
    ?>
                            </span>
						</td>
					</tr>
					<tr>
						<th><?php 
    _e('Size', 'nggallery');
    ?>
:</th>
						<td><input type="text" name="wmSize" value="<?php 
    echo $ngg->options['wmSize'];
    ?>
" size="4" maxlength="2" /> px</td>
					</tr>
					<tr>
						<th><?php 
    _e('Color', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="6" maxlength="6" id="wmColor" name="wmColor" onchange="setcolor('#previewText', this.value)" value="<?php 
    echo $ngg->options['wmColor'];
    ?>
" />
						<input type="text" size="1" readonly="readonly" id="previewText" style="background-color: #<?php 
    echo $ngg->options['wmColor'];
    ?>
" /> <?php 
    _e('(hex w/o #)', 'nggallery');
    ?>
</td>
					</tr>
					<tr>
						<th valign="top"><?php 
    _e('Text', 'nggallery');
    ?>
:</th>
						<td><textarea name="wmText" cols="40" rows="4"><?php 
    echo $ngg->options['wmText'];
    ?>
</textarea></td>
					</tr>
					<tr>
						<th><?php 
    _e('Opaque', 'nggallery');
    ?>
:</th>
						<td><input type="text" name="wmOpaque" value="<?php 
    echo $ngg->options['wmOpaque'];
    ?>
" size="3" maxlength="3" /> % </td>
					</tr>
				</table>
			<div class="clear"> &nbsp; </div>
			<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
			</form>	
		</div>
		
		<!-- Slideshow settings -->
		
		<div id="slideshow">
		<form name="player_options" method="POST" action="<?php 
    echo $filepath . '#slideshow';
    ?>
" >
		<?php 
    wp_nonce_field('ngg_settings');
    ?>
		<input type="hidden" name="page_options" value="irWidth,irHeight,irShuffle,irLinkfromdisplay,irShownavigation,irShowicons,irWatermark,irOverstretch,irRotatetime,irTransition,irKenburns,irBackcolor,irFrontcolor,irLightcolor,irScreencolor,irAudio,irXHTMLvalid" />
		<h2><?php 
    _e('Slideshow', 'nggallery');
    ?>
</h2>
		<?php 
    if (!NGGALLERY_IREXIST) {
        ?>
<p><div id="message" class="error fade"><p><?php 
        _e('The imagerotator.swf is not in the nggallery folder, the slideshow will not work.', 'nggallery');
        ?>
</p></div></p><?php 
    }
    ?>
		<p><?php 
    _e('The settings are used in the JW Image Rotator Version', 'nggallery');
    ?>
 3.17 .
		   <?php 
    _e('See more information for the Flash Player on the web page', 'nggallery');
    ?>
 <a href="http://www.longtailvideo.com/players/jw-image-rotator/" target="_blank" >JW Image Rotator from Jeroen Wijering</a>.
		</p>
				<table class="form-table ngg-options">
					<tr>
						<th><?php 
    _e('Default size (W x H)', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="3" maxlength="4" name="irWidth" value="<?php 
    echo $ngg->options['irWidth'];
    ?>
" /> x
						<input type="text" size="3" maxlength="4" name="irHeight" value="<?php 
    echo $ngg->options['irHeight'];
    ?>
" /></td>
					</tr>					
					<tr>
						<th><?php 
    _e('Shuffle mode', 'nggallery');
    ?>
:</th>
						<td><input name="irShuffle" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irShuffle']);
    ?>
 /></td>
					</tr>
					<tr>
						<th><?php 
    _e('Show next image on click', 'nggallery');
    ?>
:</th>
						<td><input name="irLinkfromdisplay" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irLinkfromdisplay']);
    ?>
 /></td>
					</tr>					
					<tr>
						<th><?php 
    _e('Show navigation bar', 'nggallery');
    ?>
:</th>
						<td><input name="irShownavigation" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irShownavigation']);
    ?>
 /></td>
					</tr>
					<tr>
						<th><?php 
    _e('Show loading icon', 'nggallery');
    ?>
:</th>
						<td><input name="irShowicons" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irShowicons']);
    ?>
 /></td>
					</tr>
					<tr>
						<th><?php 
    _e('Use watermark logo', 'nggallery');
    ?>
:</th>
						<td><input name="irWatermark" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irWatermark']);
    ?>
 />
						<span class="setting-description"><?php 
    _e('You can change the logo at the watermark settings', 'nggallery');
    ?>
</span></td>
					</tr>
					<tr>
						<th><?php 
    _e('Stretch image', 'nggallery');
    ?>
:</th>
						<td>
						<select size="1" name="irOverstretch">
							<option value="true" <?php 
    selected('true', $ngg->options['irOverstretch']);
    ?>
 ><?php 
    _e('true', 'nggallery');
    ?>
</option>
							<option value="false" <?php 
    selected('false', $ngg->options['irOverstretch']);
    ?>
 ><?php 
    _e('false', 'nggallery');
    ?>
</option>
							<option value="fit" <?php 
    selected('fit', $ngg->options['irOverstretch']);
    ?>
 ><?php 
    _e('fit', 'nggallery');
    ?>
</option>
							<option value="none" <?php 
    selected('none', $ngg->options['irOverstretch']);
    ?>
 ><?php 
    _e('none', 'nggallery');
    ?>
</option>
						</select>
						</td>
					</tr>
					<tr>					
						<th><?php 
    _e('Duration time', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="3" maxlength="3" name="irRotatetime" value="<?php 
    echo $ngg->options['irRotatetime'];
    ?>
" /> <?php 
    _e('sec.', 'nggallery');
    ?>
</td>
					</tr>					
					<tr>					
						<th><?php 
    _e('Transition / Fade effect', 'nggallery');
    ?>
:</th>
						<td>
						<select size="1" name="irTransition">
							<option value="fade" <?php 
    selected('fade', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('fade', 'nggallery');
    ?>
</option>
							<option value="bgfade" <?php 
    selected('bgfade', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('bgfade', 'nggallery');
    ?>
</option>
							<option value="slowfade" <?php 
    selected('slowfade', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('slowfade', 'nggallery');
    ?>
</option>
							<option value="circles" <?php 
    selected('circles', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('circles', 'nggallery');
    ?>
</option>
							<option value="bubbles" <?php 
    selected('bubbles', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('bubbles', 'nggallery');
    ?>
</option>
							<option value="blocks" <?php 
    selected('blocks', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('blocks', 'nggallery');
    ?>
</option>
							<option value="fluids" <?php 
    selected('fluids', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('fluids', 'nggallery');
    ?>
</option>
							<option value="flash" <?php 
    selected('flash', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('flash', 'nggallery');
    ?>
</option>
							<option value="lines" <?php 
    selected('lines', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('lines', 'nggallery');
    ?>
</option>
							<option value="random" <?php 
    selected('random', $ngg->options['irTransition']);
    ?>
 ><?php 
    _e('random', 'nggallery');
    ?>
</option>
						</select>
					</tr>
					<tr>
						<th><?php 
    _e('Use slow zooming effect', 'nggallery');
    ?>
:</th>
						<td><input name="irKenburns" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irKenburns']);
    ?>
 /></td>
					</tr>
					<tr>
						<th><?php 
    _e('Background Color', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="6" maxlength="6" id="irBackcolor" name="irBackcolor" onchange="setcolor('#previewBack', this.value)" value="<?php 
    echo $ngg->options['irBackcolor'];
    ?>
" />
						<input type="text" size="1" readonly="readonly" id="previewBack" style="background-color: #<?php 
    echo $ngg->options['irBackcolor'];
    ?>
" /></td>
					</tr>
					<tr>					
						<th><?php 
    _e('Texts / Buttons Color', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="6" maxlength="6" id="irFrontcolor" name="irFrontcolor" onchange="setcolor('#previewFront', this.value)" value="<?php 
    echo $ngg->options['irFrontcolor'];
    ?>
" />
						<input type="text" size="1" readonly="readonly" id="previewFront" style="background-color: #<?php 
    echo $ngg->options['irFrontcolor'];
    ?>
" /></td>
					</tr>
					<tr>					
						<th><?php 
    _e('Rollover / Active Color', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="6" maxlength="6" id="irLightcolor" name="irLightcolor" onchange="setcolor('#previewLight', this.value)" value="<?php 
    echo $ngg->options['irLightcolor'];
    ?>
" />
						<input type="text" size="1" readonly="readonly" id="previewLight" style="background-color: #<?php 
    echo $ngg->options['irLightcolor'];
    ?>
" /></td>
					</tr>
					<tr>					
						<th><?php 
    _e('Screen Color', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="6" maxlength="6" id="irScreencolor" name="irScreencolor" onchange="setcolor('#previewScreen', this.value)" value="<?php 
    echo $ngg->options['irScreencolor'];
    ?>
" />
						<input type="text" size="1" readonly="readonly" id="previewScreen" style="background-color: #<?php 
    echo $ngg->options['irScreencolor'];
    ?>
" /></td>
					</tr>
					<tr>					
						<th><?php 
    _e('Background music (URL)', 'nggallery');
    ?>
:</th>
						<td><input type="text" size="50" id="irAudio" name="irAudio" value="<?php 
    echo $ngg->options['irAudio'];
    ?>
" /></td>
					</tr>
					<tr>
						<th><?php 
    _e('Try XHTML validation (with CDATA)', 'nggallery');
    ?>
:</th>
						<td><input name="irXHTMLvalid" type="checkbox" value="1" <?php 
    checked('1', $ngg->options['irXHTMLvalid']);
    ?>
 />
						<span class="setting-description"><?php 
    _e('Important : Could causes problem at some browser. Please recheck your page.', 'nggallery');
    ?>
</span></td>
					</tr>
					</table>
				<div class="clear"> &nbsp; </div>
				<div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php 
    _e('Save Changes');
    ?>
"/></div>
		</form>
		</div>
	</div>

	<?php 
}
예제 #3
0
/**
 * @author Alex Rabe
 * 
 */

function nggallery_sortorder($galleryID = 0){
	global $wpdb, $ngg, $nggdb;
	
	if ($galleryID == 0) return;

	$galleryID = (int) $galleryID;
	
	if (isset ($_POST['updateSortorder']))  {
		check_admin_referer('ngg_updatesortorder');
		// get variable new sortorder 
		parse_str($_POST['sortorder']);
		if (is_array($sortArray)){ 
			$neworder = array();
			foreach($sortArray as $pid) {		
				$pid = substr($pid, 4); // get id from "pid-x"
				$neworder[] = (int) $pid;
			}
			$sortindex = 1;
			foreach($neworder as $pic_id) {
				$wpdb->query("UPDATE $wpdb->nggpictures SET sortorder = '$sortindex' WHERE pid = $pic_id");
				$sortindex++;
			}

			do_action('ngg_gallery_sort', $galleryID);

			nggGallery::show_message(__('Sort order changed','nggallery'));
		} 
	}
	
	// look for presort args	
	$presort = isset($_GET['presort']) ? $_GET['presort'] : false;
	$dir = ( isset($_GET['dir']) && $_GET['dir'] == 'DESC' ) ? 'DESC' : 'ASC';
	$sortitems = array('pid', 'filename', 'alttext', 'imagedate');
	// ensure that nobody added some evil sorting :-)
	if (in_array( $presort, $sortitems) )
		$picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
	else	
		$picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
		
	//this is the url without any presort variable
	$clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
	//if we go back , then the mode should be edit
	$back_url  = 'admin.php?page=nggallery-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
	
	// In the case somebody presort, then we take this url
	if ( isset($_GET['dir']) || isset($_GET['presort']) )
		$base_url = $_SERVER['REQUEST_URI'];
	else		
		$base_url = $clean_url;
	
?>
	<script type="text/javascript">
		// seralize the ImageOrder
		function saveImageOrder()
		{
			var serial = "";
			var objects = document.getElementsByTagName('div');
			for(var no=0;no<objects.length;no++){
				if(objects[no].className=='imageBox' || objects[no].className=='imageBoxHighlighted'){
					if (serial.length > 0)	serial = serial + '&'
					serial = serial + "sortArray[]=" + objects[no].id;
				}			
			}
			jQuery('input[name=sortorder]').val(serial);
			// debug( 'This is the new order of the images(IDs) : <br>' + orderString );
			
		}
		jQuery(document).ready(function($) {
			$(".jqui-sortable").sortable({items: 'div.imageBox'});
		});
	</script>	
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php echo $clean_url ?>" onsubmit="saveImageOrder()" accept-charset="utf-8">
			<h2><?php _e('Sort Gallery', 'nggallery') ?></h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php wp_nonce_field('ngg_updatesortorder') ?>
					<input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php _e('Update Sort Order', 'nggallery') ?>" />
				</div>
				<div class="alignright actions">
					<a href="<?php echo esc_url( $back_url ); ?>" class="button"><?php _e('Back to gallery', 'nggallery'); ?></a>
				</div>
			</div>	
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php _e('Presort', 'nggallery') ?> :</li>
				<li><a href="<?php echo esc_attr(remove_query_arg('presort', $base_url)); ?>" <?php if ($presort == '') echo 'class="current"'; ?>><?php _e('Unsorted', 'nggallery') ?></a> |</li>
				<li><a href="<?php echo esc_attr(add_query_arg('presort', 'pid', $base_url)); ?>" <?php if ($presort == 'pid') echo 'class="current"'; ?>><?php _e('Image ID', 'nggallery') ?></a> |</li>
				<li><a href="<?php echo esc_attr(add_query_arg('presort', 'filename', $base_url)); ?>" <?php if ($presort == 'filename') echo 'class="current"'; ?>><?php _e('Filename', 'nggallery') ?></a> |</li>
				<li><a href="<?php echo esc_attr(add_query_arg('presort', 'alttext', $base_url)); ?>" <?php if ($presort == 'alttext') echo 'class="current"'; ?>><?php _e('Alt/Title text', 'nggallery') ?></a> |</li>
				<li><a href="<?php echo esc_attr(add_query_arg('presort', 'imagedate', $base_url)); ?>" <?php if ($presort == 'imagedate') echo 'class="current"'; ?>><?php _e('Date/Time', 'nggallery') ?></a> |</li>
				<li><a href="<?php echo esc_attr(add_query_arg('dir', 'ASC', $base_url)); ?>" <?php if ($dir == 'ASC') echo 'class="current"'; ?>><?php _e('Ascending', 'nggallery') ?></a> |</li>
				<li><a href="<?php echo esc_attr(add_query_arg('dir', 'DESC', $base_url)); ?>" <?php if ($dir == 'DESC') echo 'class="current"'; ?>><?php _e('Descending', 'nggallery') ?></a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<div class='jqui-sortable'>
			<?php 
			if($picturelist) {
				foreach($picturelist as $picture) {
					?>
					<div class="imageBox" id="pid-<?php echo $picture->pid ?>">
						<div class="imageBox_theImage" style="background-image:url('<?php echo esc_url( $picture->thumbURL ); ?>')"></div>	
						<div class="imageBox_label"><span><?php echo esc_html( stripslashes($picture->alttext) ); ?></span></div>
					</div>
					<?php
				}
			}
			?>
		</div>
	</div>
	
<?php
}
예제 #4
0
파일: setup.php 프로젝트: valerol/korpus
function nggallery_admin_setup()
{
    global $wpdb, $ngg;
    if (isset($_POST['resetdefault'])) {
        check_admin_referer('ngg_uninstall');
        include_once dirname(__FILE__) . '/install.php';
        ngg_default_options();
        $ngg->load_options();
        nggGallery::show_message(__('Reset all settings to default parameter', 'nggallery'));
    }
    if (isset($_POST['uninstall'])) {
        check_admin_referer('ngg_uninstall');
        include_once dirname(__FILE__) . '/install.php';
        nggallery_uninstall();
        nggGallery::show_message(__('Uninstall sucessful ! Now delete the plugin and enjoy your life ! Good luck !', 'nggallery'));
    }
    ?>
	<div class="wrap">
	<h2><?php 
    _e('Reset options', 'nggallery');
    ?>
</h2>
		<form name="resetsettings" method="post">
			<?php 
    wp_nonce_field('ngg_uninstall');
    ?>
			<p><?php 
    _e('Reset all options/settings to the default installation.', 'nggallery');
    ?>
</p>
			<div align="center"><input type="submit" class="button" name="resetdefault" value="<?php 
    _e('Reset settings', 'nggallery');
    ?>
" onclick="javascript:check=confirm('<?php 
    _e('Reset all options to default settings ?\\n\\nChoose [Cancel] to Stop, [OK] to proceed.\\n', 'nggallery');
    ?>
');if(check==false) return false;" /></div>
		</form>
	</div>
	<?php 
    if (!is_multisite() || is_super_admin()) {
        ?>
	<div class="wrap">
	<h2><?php 
        _e('Uninstall plugin tables', 'nggallery');
        ?>
</h2>
		
		<form name="resetsettings" method="post">
		<div>
			<?php 
        wp_nonce_field('ngg_uninstall');
        ?>
			<p><?php 
        _e('You don\'t like NextCellent Gallery ?', 'nggallery');
        ?>
</p>
			<p><?php 
        _e('No problem, before you deactivate this plugin press the Uninstall Button, because deactivating NextCellent Gallery does not remove any data that may have been created. ', 'nggallery');
        ?>
		</div>
		<p><font color="red"><strong><?php 
        _e('WARNING:', 'nggallery');
        ?>
</strong><br />
		<?php 
        _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to backup all the tables first. NextCellent gallery is stored in the tables', 'nggallery');
        ?>
 <strong><?php 
        echo $wpdb->nggpictures;
        ?>
</strong>, <strong><?php 
        echo $wpdb->nggalbum;
        ?>
</strong> <?php 
        _e('and', 'nggallery');
        ?>
 <strong><?php 
        echo $wpdb->nggalbum;
        ?>
</strong>.</font></p>
		<div align="center">
			<input type="submit" name="uninstall" class="button delete" value="<?php 
        _e('Uninstall plugin', 'nggallery');
        ?>
" onclick="javascript:check=confirm('<?php 
        _e('You are about to Uninstall this plugin from WordPress.\\nThis action is not reversible.\\n\\nChoose [Cancel] to Stop, [OK] to Uninstall.\\n', 'nggallery');
        ?>
');if(check==false) return false;"/>
		</div>
		</form>
	</div>
	<?php 
    }
    ?>

	<?php 
}
예제 #5
0
/**
 * @author Alex Rabe
 * @copyright 2008-2011
 */
function nggallery_sortorder($galleryID = 0)
{
    global $wpdb, $ngg, $nggdb;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('ngg_updatesortorder');
        // get variable new sortorder
        parse_str($_POST['sortorder']);
        if (is_array($sortArray)) {
            $neworder = array();
            foreach ($sortArray as $pid) {
                $pid = substr($pid, 4);
                // get id from "pid-x"
                $neworder[] = (int) $pid;
            }
            $sortindex = 1;
            foreach ($neworder as $pic_id) {
                $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
                $sortindex++;
            }
            do_action('ngg_gallery_sort', $galleryID);
            nggGallery::show_message(__('Sort order changed', 'nggallery'));
        }
    }
    // look for presort args
    $presort = isset($_GET['presort']) ? $_GET['presort'] : false;
    $dir = isset($_GET['dir']) && $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
    $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
    // ensure that nobody added some evil sorting :-)
    if (in_array($presort, $sortitems)) {
        $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
    } else {
        $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
    }
    //this is the url without any presort variable
    $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
    //if we go back , then the mode should be edit
    $back_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
    // In the case somebody presort, then we take this url
    if (isset($_GET['dir']) || isset($_GET['presort'])) {
        $base_url = $_SERVER['REQUEST_URI'];
    } else {
        $base_url = $clean_url;
    }
    ?>
	<script type='text/javascript' src='<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/js/sorter.js'></script>
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php 
    echo $clean_url;
    ?>
" onsubmit="saveImageOrder()" accept-charset="utf-8">
			<h2><?php 
    _e('Sort Gallery', 'nggallery');
    ?>
</h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php 
    wp_nonce_field('ngg_updatesortorder');
    ?>
					<input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php 
    _e('Update Sort Order', 'nggallery');
    ?>
" />
				</div>
				<div class="alignright actions">
					<a href="<?php 
    echo esc_url($back_url);
    ?>
" class="button"><?php 
    _e('Back to gallery', 'nggallery');
    ?>
</a>
				</div>
			</div>	
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php 
    _e('Presort', 'nggallery');
    ?>
 :</li>
				<li><a href="<?php 
    echo esc_attr(remove_query_arg('presort', $base_url));
    ?>
" <?php 
    if ($presort == '') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Unsorted', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'pid', $base_url));
    ?>
" <?php 
    if ($presort == 'pid') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Image ID', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'filename', $base_url));
    ?>
" <?php 
    if ($presort == 'filename') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Filename', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'alttext', $base_url));
    ?>
" <?php 
    if ($presort == 'alttext') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Alt/Title text', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'imagedate', $base_url));
    ?>
" <?php 
    if ($presort == 'imagedate') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Date/Time', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'ASC', $base_url));
    ?>
" <?php 
    if ($dir == 'ASC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Ascending', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'DESC', $base_url));
    ?>
" <?php 
    if ($dir == 'DESC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Descending', 'nggallery');
    ?>
</a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<?php 
    if ($picturelist) {
        foreach ($picturelist as $picture) {
            ?>
				<div class="imageBox" id="pid-<?php 
            echo $picture->pid;
            ?>
">
					<div class="imageBox_theImage" style="background-image:url('<?php 
            echo esc_url($picture->thumbURL);
            ?>
')"></div>	
					<div class="imageBox_label"><span><?php 
            echo esc_html(stripslashes($picture->alttext));
            ?>
</span></div>
				</div>
				<?php 
        }
    }
    ?>
		<div id="insertionMarker">
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_top.gif"/>
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_middle.gif" id="insertionMarkerLine"/>
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_bottom.gif"/>
		</div>
		<div id="dragDropContent"></div>
	</div>
	
<?php 
}
예제 #6
0
파일: settings.php 프로젝트: valerol/korpus
 /**
  * Save/Load options and add a new hook for plugins
  */
 public function processor()
 {
     global $ngg, $nggRewrite;
     $old_state = $ngg->options['usePermalinks'];
     $old_slug = $ngg->options['permalinkSlug'];
     if (isset($_POST['updateoption'])) {
         check_admin_referer('ngg_settings');
         // get the hidden option fields, taken from WP core
         if ($_POST['page_options']) {
             $options = explode(',', stripslashes($_POST['page_options']));
         }
         if ($options) {
             foreach ($options as $option) {
                 $option = trim($option);
                 $value = false;
                 if (isset($_POST[$option])) {
                     $value = trim($_POST[$option]);
                     if ($value === "true") {
                         $value = true;
                     }
                     if (is_numeric($value)) {
                         $value = (int) $value;
                     }
                 }
                 $ngg->options[$option] = $value;
             }
             // do not allow a empty string
             if (empty($ngg->options['permalinkSlug'])) {
                 $ngg->options['permalinkSlug'] = 'nggallery';
             }
             // the path should always end with a slash
             $ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
             $ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
             // the custom sortorder must be ascending
             $ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir'];
         }
         // Save options
         update_option('ngg_options', $ngg->options);
         // Flush Rewrite rules
         if ($old_state != $ngg->options['usePermalinks'] || $old_slug != $ngg->options['permalinkSlug']) {
             $nggRewrite->flush();
         }
         nggGallery::show_message(__('Settings updated successfully', 'nggallery'));
     }
     if (isset($_POST['clearcache'])) {
         check_admin_referer('ngg_settings');
         $path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
         if (is_dir($path)) {
             if ($handle = opendir($path)) {
                 while (false !== ($file = readdir($handle))) {
                     if ($file != '.' && $file != '..') {
                         @unlink($path . '/' . $file);
                     }
                 }
                 closedir($handle);
             }
         }
         nggGallery::show_message(__('Cache cleared', 'nggallery'));
     }
     if (isset($_POST['createslugs'])) {
         check_admin_referer('ngg_settings');
         ngg_rebuild_unique_slugs::start_rebuild();
     }
     do_action('ngg_update_options_page');
 }
예제 #7
0
 function update_album()
 {
     check_admin_referer('ngg_thickbox_form');
     if (!nggGallery::current_user_can('NextGEN Edit album settings')) {
         wp_die(__('Cheatin&#8217; uh?'));
     }
     $this->currentID = $_REQUEST['act_album'];
     $album = $this->_get_album($this->currentID);
     $album->name = stripslashes($_POST['album_name']);
     $album->albumdesc = stripslashes($_POST['album_desc']);
     $album->previewpic = (int) $_POST['previewpic'];
     $album->pageid = (int) $_POST['pageid'];
     $result = C_Album_Mapper::get_instance()->save($album);
     //hook for other plugin to update the fields
     do_action('ngg_update_album', $this->currentID, $_POST);
     if ($result) {
         nggGallery::show_message(__('Update Successfully', 'nggallery'));
     }
 }
예제 #8
0
파일: roles.php 프로젝트: valerol/korpus
function nggallery_admin_roles()
{
    if (isset($_POST['update_cap'])) {
        check_admin_referer('ngg_addroles');
        // now set or remove the capability
        ngg_set_capability($_POST['general'], "NextGEN Gallery overview");
        ngg_set_capability($_POST['tinymce'], "NextGEN Use TinyMCE");
        ngg_set_capability($_POST['add_gallery'], "NextGEN Upload images");
        ngg_set_capability($_POST['manage_gallery'], "NextGEN Manage gallery");
        ngg_set_capability($_POST['manage_others'], "NextGEN Manage others gallery");
        ngg_set_capability($_POST['manage_tags'], "NextGEN Manage tags");
        ngg_set_capability($_POST['edit_album'], "NextGEN Edit album");
        ngg_set_capability($_POST['change_style'], "NextGEN Change style");
        ngg_set_capability($_POST['change_options'], "NextGEN Change options");
        nggGallery::show_message(__('Updated capabilities', "nggallery"));
    }
    ?>
	<div class="wrap">
    <?php 
    screen_icon('nextgen-gallery');
    ?>
	<h2><?php 
    _e('Roles / capabilities', 'nggallery');
    ?>
</h2>
	<p><?php 
    _e('Select the lowest role which should be able to access the following capabilities. NextCellent Gallery supports the standard roles from WordPress.', 'nggallery');
    ?>
 <br />
	   <?php 
    _e('For a more flexible user management you can use the', 'nggallery');
    ?>
 <a href="http://wordpress.org/extend/plugins/capsman/" target="_blank">Capability Manager</a>.</p>
	<form name="addroles" id="addroles" method="POST" accept-charset="utf-8" >
		<?php 
    wp_nonce_field('ngg_addroles');
    ?>
			<table class="form-table">
			<tr valign="top">
				<th scope="row"><label for="general"><?php 
    _e('NextCellent Gallery overview', 'nggallery');
    ?>
</label></th>
				<td><select name="general" id="general"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Gallery overview'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="tinymce"><?php 
    _e('Use TinyMCE Button / Add Media', 'nggallery');
    ?>
</label></th>
				<td><select name="tinymce" id="tinymce"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Use TinyMCE'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="add_gallery"><?php 
    _e('Add gallery / Upload images', 'nggallery');
    ?>
</label></th>
				<td><select name="add_gallery" id="add_gallery"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Upload images'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="manage_gallery"><?php 
    _e('Manage gallery', 'nggallery');
    ?>
</label></th>
				<td><select name="manage_gallery" id="manage_gallery"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Manage gallery'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="manage_others"><?php 
    _e('Manage others gallery', 'nggallery');
    ?>
</label></th>
				<td><select name="manage_others" id="manage_others"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Manage others gallery'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="manage_tags"><?php 
    _e('Manage tags', 'nggallery');
    ?>
</label></th>
				<td><select name="manage_tags" id="manage_tags"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Manage tags'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="edit_album"><?php 
    _e('Edit Album', 'nggallery');
    ?>
</label></th>
				<td><select name="edit_album" id="edit_album"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Edit album'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="change_style"><?php 
    _e('Change style', 'nggallery');
    ?>
</label></th>
				<td><select name="change_style" id="change_style"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Change style'));
    ?>
</select></td>
			</tr>
			<tr valign="top">
				<th scope="row"><label for="change_options"><?php 
    _e('Change options', 'nggallery');
    ?>
</label></th>
				<td><select name="change_options" id="change_options"><?php 
    wp_dropdown_roles(ngg_get_role('NextGEN Change options'));
    ?>
</select></td>
			</tr>
			</table>
			<div class="submit"><input type="submit" class="button-primary" name= "update_cap" value="<?php 
    _e('Update capabilities', 'nggallery');
    ?>
"/></div>
	</form>
	</div>
<?php 
}
예제 #9
0
파일: album.php 프로젝트: alx/SimplePress
 function update_album()
 {
     global $wpdb;
     check_admin_referer('ngg_thickbox_form');
     $name = esc_attr($_POST['album_name']);
     $desc = esc_attr($_POST['album_desc']);
     $prev = (int) $_POST['previewpic'];
     $link = (int) $_POST['pageid'];
     $result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggalbum} SET name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '{$this->currentID}'", $name, $desc, $prev, $link));
     if ($result) {
         nggGallery::show_message(__('Update Successfully', 'nggallery'));
     }
 }
예제 #10
0
파일: style.php 프로젝트: valerol/korpus
 /**
  * Save, change and move the css files and options.
  *
  * @since 1.9.22
  *
  */
 function processor()
 {
     global $ngg;
     $i = 0;
     if (isset($_POST['activate'])) {
         check_admin_referer('ngg_style');
         $file = $_POST['css'];
         $activate = $_POST['activateCSS'];
         // save option now
         $ngg->options['activateCSS'] = $activate;
         $ngg->options['CSSfile'] = $file;
         update_option('ngg_options', $ngg->options);
         if (isset($activate)) {
             nggGallery::show_message(__('Successfully selected CSS file.', 'nggallery'));
         } else {
             nggGallery::show_message(__('No CSS file will be used.', 'nggallery'));
         }
     }
     if (isset($_POST['updatecss'])) {
         check_admin_referer('ngg_style');
         if (!current_user_can('edit_themes')) {
             wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
         }
         $newcontent = stripslashes($_POST['newcontent']);
         $old_path = $_POST['file'];
         $folder = $_POST['folder'];
         //if the file is in the css folder, copy it.
         if ($folder === 'css') {
             $filename = basename($old_path, '.css');
             $new_path = NGG_CONTENT_DIR . "/ngg_styles/" . $filename . ".css";
             //check for duplicate files
             while (file_exists($new_path)) {
                 $i++;
                 $new_path = NGG_CONTENT_DIR . "/ngg_styles/" . $filename . "-" . $i . ".css";
             }
             //check if ngg_styles exist or not
             if (!file_exists(NGG_CONTENT_DIR . "/ngg_styles")) {
                 wp_mkdir_p(NGG_CONTENT_DIR . "/ngg_styles");
             }
             //copy the file
             if (copy($old_path, $new_path)) {
                 //set option to new file
                 $ngg->options['CSSfile'] = $new_path;
                 update_option('ngg_options', $ngg->options);
             } else {
                 nggGallery::show_error(__('Could not move file.', 'nggallery'));
                 return;
             }
         }
         if (file_put_contents($old_path, $newcontent)) {
             nggGallery::show_message(__('CSS file successfully updated.', 'nggallery'));
         } else {
             nggGallery::show_error(__('Could not save file.', 'nggallery'));
         }
     }
     if (isset($_POST['movecss'])) {
         if (!current_user_can('edit_themes')) {
             wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
         }
         $old_path = $_POST['oldpath'];
         $new_path = NGG_CONTENT_DIR . "/ngg_styles/nggallery.css";
         //check for duplicate files
         while (file_exists($new_path)) {
             $i++;
             $new_path = NGG_CONTENT_DIR . "/ngg_styles/nggallery-" . $i . ".css";
         }
         //move file
         if (rename($old_path, $new_path)) {
             nggGallery::show_message(__('CSS file successfully moved.', 'nggallery'));
             //set option to new file
             $ngg->options['CSSfile'] = $new_path;
             update_option('ngg_options', $ngg->options);
         } else {
             nggGallery::show_error(__('Could not move the CSS file.', 'nggallery'));
         }
     }
 }
예제 #11
0
/**
 * @author Alex Rabe
 * @copyright 2008
 */
function nggallery_sortorder($galleryID = 0)
{
    global $wpdb, $ngg;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('ngg_updatesortorder');
        // get variable new sortorder
        parse_str($_POST['sortorder']);
        if (is_array($sortArray)) {
            $neworder = array();
            foreach ($sortArray as $pid) {
                $pid = substr($pid, 4);
                // get id from "pid-x"
                $neworder[] = (int) $pid;
            }
            $sortindex = 1;
            foreach ($neworder as $pic_id) {
                $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
                $sortindex++;
            }
            nggGallery::show_message(__('Sort order changed', 'nggallery'));
        }
    }
    //TODO:A unique gallery call must provide me with this information, like $gallery  = new nggGallery($id);
    // get gallery values
    $act_gallery = $wpdb->get_row("SELECT * FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' ");
    // set gallery url
    $act_gallery_url = get_option('siteurl') . "/" . $act_gallery->path . "/";
    $act_thumbnail_url = get_option('siteurl') . "/" . $act_gallery->path . nggGallery::get_thumbnail_folder($act_gallery->path, FALSE);
    // look for presort args
    $presort = $_GET['presort'];
    $dir = $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
    $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
    // ensure that nobody added some evil sorting :-)
    if (in_array($presort, $sortitems)) {
        $picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' ORDER BY {$presort} {$dir}");
    } else {
        $picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' ORDER BY sortorder {$dir}");
    }
    //this is the url without any presort variable
    $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
    // In the case somebody presort, then we take this url
    if (isset($_GET['dir']) || isset($_GET['presort'])) {
        $base_url = $_SERVER['REQUEST_URI'];
    } else {
        $base_url = $clean_url;
    }
    ?>
	<script type='text/javascript' src='<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/js/sorter.js'></script>
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php 
    echo $clean_url;
    ?>
" onsubmit="saveImageOrder()" accept-charset="utf-8">
			<h2><?php 
    _e('Sort Gallery', 'nggallery');
    ?>
</h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php 
    wp_nonce_field('ngg_updatesortorder');
    ?>
					<input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php 
    _e('Update Sort Order', 'nggallery');
    ?>
" />
				</div>
				<div class="alignright actions">
					<input class="button-secondary action" type="submit" name="backToGallery" value="<?php 
    _e('Back to gallery', 'nggallery');
    ?>
" />
				</div>
			</div>	
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php 
    _e('Presort', 'nggallery');
    ?>
 :</li>
				<li><a href="<?php 
    echo attribute_escape(remove_query_arg('presort', $base_url));
    ?>
" <?php 
    if ($presort == '') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Unsorted', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'pid', $base_url));
    ?>
" <?php 
    if ($presort == 'pid') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Image ID', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'filename', $base_url));
    ?>
" <?php 
    if ($presort == 'filename') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Filename', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'alttext', $base_url));
    ?>
" <?php 
    if ($presort == 'alttext') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Alt/Title text', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'imagedate', $base_url));
    ?>
" <?php 
    if ($presort == 'imagedate') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Date/Time', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('dir', 'ASC', $base_url));
    ?>
" <?php 
    if ($dir == 'ASC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Ascending', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('dir', 'DESC', $base_url));
    ?>
" <?php 
    if ($dir == 'DESC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Descending', 'nggallery');
    ?>
</a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<?php 
    if ($picturelist) {
        foreach ($picturelist as $picture) {
            ?>
				<div class="imageBox" id="pid-<?php 
            echo $picture->pid;
            ?>
">
					<div class="imageBox_theImage" style="background-image:url('<?php 
            echo $act_thumbnail_url . "thumbs_" . $picture->filename;
            ?>
')"></div>	
					<div class="imageBox_label"><span><?php 
            echo stripslashes($picture->alttext);
            ?>
</span></div>
				</div>
				<?php 
        }
    }
    ?>
		<div id="insertionMarker">
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_top.gif"/>
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_middle.gif" id="insertionMarkerLine"/>
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_bottom.gif"/>
		</div>
		<div id="dragDropContent"></div>
	</div>
	
<?php 
}
예제 #12
0
function nggallery_admin_style()
{
    global $ngg;
    if ($theme_css_exists = file_exists(TEMPLATEPATH . "/nggallery.css")) {
        $real_file = TEMPLATEPATH . "/nggallery.css";
        $file_show = 'nggallery.css ' . __('(From the theme folder)', 'nggallery');
    } else {
        if (isset($_POST['css'])) {
            check_admin_referer('ngg_style');
            $act_cssfile = $_POST['css'];
            if (isset($_POST['activate'])) {
                // save option now
                $ngg->options['activateCSS'] = $_POST['activateCSS'];
                $ngg->options['CSSfile'] = $act_cssfile;
                update_option('ngg_options', $ngg->options);
                nggGallery::show_message(__('Update Successfully', 'nggallery'));
            }
        } else {
            // get the options
            if (isset($_POST['file'])) {
                $act_cssfile = $_POST['file'];
            } else {
                $act_cssfile = $ngg->options['CSSfile'];
            }
        }
        // set the path
        $real_file = NGGALLERY_ABSPATH . "css/" . $act_cssfile;
    }
    if (isset($_POST['updatecss'])) {
        check_admin_referer('ngg_style');
        if (!current_user_can('edit_themes')) {
            wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this blog.') . '</p>');
        }
        $newcontent = stripslashes($_POST['newcontent']);
        if (is_writeable($real_file)) {
            $f = fopen($real_file, 'w+');
            fwrite($f, $newcontent);
            fclose($f);
            nggGallery::show_message(__('CSS file successfully updated', 'nggallery'));
        }
    }
    // get the content of the file
    //TODO: BUG : Read failed after write a file, maybe a Cache problem
    $error = !is_file($real_file);
    if (!$error && filesize($real_file) > 0) {
        $f = fopen($real_file, 'r');
        $content = fread($f, filesize($real_file));
        $content = htmlspecialchars($content);
    }
    ?>
<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery('#colorSelector').ColorPicker({
			color: '#0000ff',
			onShow: function (colpkr) {
				jQuery(colpkr).fadeIn(500);
				return false;
			},
			onHide: function (colpkr) {
				jQuery(colpkr).fadeOut(500);
				return false;
			},
			onChange: function (hsb, hex, rgb) {
				jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
			}
		});
	});
</script>
<div class="wrap">

	<div class="bordertitle">
        <?php 
    screen_icon('nextgen-gallery');
    ?>
		<h2><?php 
    _e('Style Editor', 'nggallery');
    ?>
</h2>
		<?php 
    if (!$theme_css_exists) {
        ?>
		<form id="themeselector" name="cssfiles" method="post">
		<?php 
        wp_nonce_field('ngg_style');
        ?>
		<strong><?php 
        _e('Activate and use style sheet:', 'nggallery');
        ?>
</strong>
		<input type="checkbox" name="activateCSS" value="1" <?php 
        checked('1', $ngg->options['activateCSS']);
        ?>
 /> 
			<select name="css" id="theme" style="margin: 0pt; padding: 0pt;" onchange="this.form.submit();">
			<?php 
        $csslist = ngg_get_cssfiles();
        foreach ($csslist as $key => $a_cssfile) {
            $css_name = $a_cssfile['Name'];
            if ($key == $act_cssfile) {
                $file_show = $key;
                $selected = " selected='selected'";
                $act_css_description = $a_cssfile['Description'];
                $act_css_author = $a_cssfile['Author'];
                $act_css_version = $a_cssfile['Version'];
            } else {
                $selected = '';
            }
            $css_name = esc_attr($css_name);
            echo "\n\t<option value=\"{$key}\" {$selected}>{$css_name}</option>";
        }
        ?>
			</select>
			<input class="button" type="submit" name="activate" value="<?php 
        _e('Activate', 'nggallery');
        ?>
 &raquo;" class="button" />
		</form>
		<?php 
    }
    ?>
	</div>
	<br style="clear: both;"/>
	
<?php 
    if (!is_multisite() || wpmu_site_admin()) {
        ?>
	<div class="tablenav"> 
	  <?php 
        if (is_writeable($real_file)) {
            echo '<big>' . sprintf(__('Editing <strong>%s</strong>', 'nggallery'), $file_show) . '</big>';
        } else {
            echo '<big>' . sprintf(__('Browsing <strong>%s</strong>', 'nggallery'), $file_show) . '</big>';
        }
        ?>
	</div>
	<br style="clear: both;"/>
	
	<div id="templateside">
	<?php 
        if (!$theme_css_exists) {
            ?>
		<ul>
			<li><strong><?php 
            _e('Author', 'nggallery');
            ?>
 :</strong> <?php 
            echo $act_css_author;
            ?>
</li>
			<li><strong><?php 
            _e('Version', 'nggallery');
            ?>
 :</strong> <?php 
            echo $act_css_version;
            ?>
</li>
			<li><strong><?php 
            _e('Description', 'nggallery');
            ?>
 :<br /></strong> <?php 
            echo $act_css_description;
            ?>
</li>
		</ul>
		<p><?php 
            _e('Tip : Copy your stylesheet (nggallery.css) to your theme folder, so it will be not lost during a upgrade', 'nggallery');
            ?>
</p>
	<?php 
        } else {
            ?>
		<p><?php 
            _e('Your theme contain a NextGEN Gallery stylesheet (nggallery.css), this file will be used', 'nggallery');
            ?>
</p>
	<?php 
        }
        ?>
    	<p><?php 
        _e('Tip No. 2: Use the color picker below to help you find the right color scheme for your gallery!', 'nggallery');
        ?>
</p>
    	<div id="colorSelector">
        	<div></div>
        </div>
	</div>
		<?php 
        if (!$error) {
            ?>
		<form name="template" id="template" method="post">
			 <?php 
            wp_nonce_field('ngg_style');
            ?>
			 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"  class="codepress css"><?php 
            echo $content;
            ?>
</textarea>
			 <input type="hidden" name="updatecss" value="updatecss" />
			 <input type="hidden" name="file" value="<?php 
            echo $file_show;
            ?>
" />
			 </div>
	<?php 
            if (is_writeable($real_file)) {
                ?>
		<p class="submit">
			<input class="button-primary action" type="submit" name="submit" value="<?php 
                _e('Update File', 'nggallery');
                ?>
" tabindex="2" />
		</p>
	<?php 
            } else {
                ?>
	<p><em><?php 
                _e('If this file were writable you could edit it.', 'nggallery');
                ?>
</em></p>
	<?php 
            }
            ?>
		</form>
		<?php 
        } else {
            echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.', 'nggallery') . '</p></div>';
        }
        ?>
	<div class="clear"> &nbsp; </div>
</div> <!-- wrap-->
	
<?php 
    }
}
예제 #13
0
 function processor()
 {
     global $wpdb, $ngg;
     if ($this->mode == 'delete') {
         // Delete a gallery
         check_admin_referer('ngg_editgallery');
         // get the path to the gallery
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         if ($gallerypath) {
             // delete pictures
             //TODO:Remove also Tag reference
             $imagelist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$this->gid}' ");
             if ($ngg->options['deleteImg']) {
                 if (is_array($imagelist)) {
                     foreach ($imagelist as $filename) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                 }
                 // delete folder
                 @rmdir(WINABSPATH . $gallerypath . '/thumbs');
                 @rmdir(WINABSPATH . $gallerypath);
             }
         }
         $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE galleryid = {$this->gid}");
         $delete_galllery = $wpdb->query("DELETE FROM {$wpdb->nggallery} WHERE gid = {$this->gid}");
         if ($delete_galllery) {
             nggGallery::show_message(__ngettext('Gallery', 'Galleries', 1, 'nggallery') . ' \'' . $this->gid . '\' ' . __('deleted successfully', 'nggallery'));
         }
         $this->mode = 'main';
         // show mainpage
     }
     if ($this->mode == 'delpic') {
         // Delete a picture
         //TODO:Remove also Tag reference
         check_admin_referer('ngg_delpicture');
         $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$this->pid}' ");
         if ($filename) {
             $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
             if ($gallerypath) {
                 $thumb_folder = nggGallery::get_thumbnail_folder($gallerypath, FALSE);
                 if ($ngg->options['deleteImg']) {
                     @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                     @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                 }
             }
             $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$this->pid}");
         }
         if ($delete_pic) {
             nggGallery::show_message(__('Picture', 'nggallery') . ' \'' . $this->pid . '\' ' . __('deleted successfully', 'nggallery'));
         }
         $this->mode = 'edit';
         // show pictures
     }
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         // do bulk update
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         $imageslist = array();
         if (is_array($_POST['doaction'])) {
             foreach ($_POST['doaction'] as $imageID) {
                 $imageslist[] = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}' ");
             }
         }
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 // No action
                 break;
             case 'set_watermark':
                 // Set watermark
                 nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'new_thumbnail':
                 // Create new thumbnails
                 nggAdmin::do_ajax_operation('create_thumbnail', $_POST['doaction'], __('Create new thumbnails', 'nggallery'));
                 break;
             case 'resize_images':
                 // Resample images
                 nggAdmin::do_ajax_operation('resize_image', $_POST['doaction'], __('Resize images', 'nggallery'));
                 break;
             case 'delete_images':
                 // Delete images
                 if (is_array($_POST['doaction'])) {
                     if ($gallerypath) {
                         $thumb_folder = nggGallery::get_thumbnail_folder($gallerypath, FALSE);
                         foreach ($_POST['doaction'] as $imageID) {
                             $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}' ");
                             if ($ngg->options['deleteImg']) {
                                 @unlink(WINABSPATH . $gallerypath . '/' . $thumb_folder . '/' . "thumbs_" . $filename);
                                 @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                             }
                             $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$imageID}");
                         }
                     }
                     if ($delete_pic) {
                         nggGallery::show_message(__('Pictures deleted successfully ', "nggallery"));
                     }
                 }
                 break;
             case 'import_meta':
                 // Import Metadata
                 nggAdmin::import_MetaData($_POST['doaction']);
                 nggGallery::show_message(__('Import metadata finished', "nggallery"));
                 break;
         }
     }
     // will be called after a ajax operation
     if (isset($_POST['ajax_callback'])) {
         if ($_POST['ajax_callback'] == 1) {
             nggGallery::show_message(__('Operation successfull. Please clear your browser cache.', "nggallery"));
         }
         $this->mode = 'edit';
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
         check_admin_referer('ngg_thickbox_form');
         $pic_ids = explode(",", $_POST['TB_imagelist']);
         $dest_gid = (int) $_POST['dest_gid'];
         switch ($_POST['TB_bulkaction']) {
             case 'copy_to':
                 // Copy images
                 nggAdmin::copy_images($pic_ids, $dest_gid);
                 break;
             case 'move_to':
                 // Move images
                 nggAdmin::move_images($pic_ids, $dest_gid);
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) {
         // do tags update
         check_admin_referer('ngg_thickbox_form');
         // get the images list
         $pic_ids = explode(",", $_POST['TB_imagelist']);
         $taglist = explode(",", $_POST['taglist']);
         $taglist = array_map('trim', $taglist);
         if (is_array($pic_ids)) {
             foreach ($pic_ids as $pic_id) {
                 // which action should be performed ?
                 switch ($_POST['TB_bulkaction']) {
                     case 'no_action':
                         // No action
                         break;
                     case 'overwrite_tags':
                         // Overwrite tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
                         break;
                     case 'add_tags':
                         // Add / append tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
                         break;
                     case 'delte_tags':
                         // Delete tags
                         $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
                         // get the slugs, to vaoid  case sensitive problems
                         $slugarray = array_map('sanitize_title', $taglist);
                         $oldtags = array_map('sanitize_title', $oldtags);
                         // compare them and return the diff
                         $newtags = array_diff($oldtags, $slugarray);
                         wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
                         break;
                 }
             }
             nggGallery::show_message(__('Tags changed', "nggallery"));
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('ngg_updategallery');
         $gallery_title = attribute_escape($_POST['title']);
         $gallery_path = attribute_escape($_POST['path']);
         $gallery_desc = attribute_escape($_POST['gallerydesc']);
         $gallery_pageid = (int) $_POST['pageid'];
         $gallery_preview = (int) $_POST['previewpic'];
         $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', path= '{$gallery_path}', galdesc = '{$gallery_desc}', pageid = '{$gallery_pageid}', previewpic = '{$gallery_preview}' WHERE gid = '{$this->gid}'");
         if (isset($_POST['author'])) {
             $gallery_author = (int) $_POST['author'];
             $wpdb->query("UPDATE {$wpdb->nggallery} SET author = '{$gallery_author}' WHERE gid = '{$this->gid}'");
         }
         if ($this->showTags) {
             $this->update_tags();
         } else {
             $this->update_pictures();
         }
         //hook for other plugin to update the fields
         do_action('ngg_update_gallery', $this->gid, $_POST);
         nggGallery::show_message(__('Update successful', "nggallery"));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::import_gallery($gallerypath);
     }
     if (isset($_POST['addnewpage'])) {
         // Add a new page
         check_admin_referer('ngg_updategallery');
         $parent_id = attribute_escape($_POST['parent_id']);
         $gallery_title = attribute_escape($_POST['title']);
         $gallery_name = $wpdb->get_var("SELECT name FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         // Create a WP page
         global $user_ID;
         $page['post_type'] = 'page';
         $page['post_content'] = '[nggallery id=' . $this->gid . ']';
         $page['post_parent'] = $parent_id;
         $page['post_author'] = $user_ID;
         $page['post_status'] = 'publish';
         $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
         $gallery_pageid = wp_insert_post($page);
         if ($gallery_pageid != 0) {
             $result = $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', pageid = '{$gallery_pageid}' WHERE gid = '{$this->gid}'");
             nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery'));
         }
     }
     if (isset($_POST['backToGallery'])) {
         $this->mode = 'edit';
     }
     // show sort order
     if (isset($_POST['sortGallery'])) {
         $this->mode = 'sort';
     }
 }
예제 #14
0
 function update_album()
 {
     global $wpdb, $nggdb;
     check_admin_referer('ngg_thickbox_form');
     if (!nggGallery::current_user_can('NextGEN Edit album settings')) {
         wp_die(__('Cheatin&#8217; uh?'));
     }
     $name = $_POST['album_name'];
     $desc = $_POST['album_desc'];
     $prev = (int) $_POST['previewpic'];
     $link = (int) $_POST['pageid'];
     // slug must be unique, we use the title for that
     $slug = nggdb::get_unique_slug(sanitize_title($name), 'album', $this->currentID);
     $result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggalbum} SET slug= '%s', name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '%d'", $slug, $name, $desc, $prev, $link, $this->currentID));
     //hook for other plugin to update the fields
     do_action('ngg_update_album', $this->currentID, $_POST);
     if ($result) {
         nggGallery::show_message(__('Update Successfully', 'nggallery'));
     }
 }
예제 #15
0
 /**
  * Function for uploading of images via the upload form
  *
  * @class nggAdmin
  * @return void
  */
 function upload_images()
 {
     global $nggdb;
     // WPMU action
     if (nggWPMU::check_quota()) {
         return;
     }
     // Images must be an array
     $imageslist = array();
     // get selected gallery
     $galleryID = (int) $_POST['galleryselect'];
     if ($galleryID == 0) {
         nggGallery::show_error(__('No gallery selected !', 'nggallery'));
         return;
     }
     // get the path to the gallery
     $gallery = $nggdb->find_gallery($galleryID);
     if (empty($gallery->path)) {
         nggGallery::show_error(__('Failure in database, no gallery path set !', 'nggallery'));
         return;
     }
     // read list of images
     $dirlist = nggAdmin::scandir($gallery->abspath);
     $imagefiles = $_FILES['imagefiles'];
     if (is_array($imagefiles)) {
         foreach ($imagefiles['name'] as $key => $value) {
             // look only for uploded files
             if ($imagefiles['error'][$key] == 0) {
                 $temp_file = $imagefiles['tmp_name'][$key];
                 //clean filename and extract extension
                 $filepart = nggGallery::fileinfo($imagefiles['name'][$key]);
                 $filename = $filepart['basename'];
                 // check for allowed extension and if it's an image file
                 $ext = array('jpg', 'png', 'gif');
                 if (!in_array($filepart['extension'], $ext) || !@getimagesize($temp_file)) {
                     nggGallery::show_error('<strong>' . esc_html($imagefiles['name'][$key]) . ' </strong>' . __('is no valid image file!', 'nggallery'));
                     continue;
                 }
                 // check if this filename already exist in the folder
                 $i = 0;
                 while (in_array($filename, $dirlist)) {
                     $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension'];
                 }
                 $dest_file = $gallery->abspath . '/' . $filename;
                 //check for folder permission
                 if (!is_writeable($gallery->abspath)) {
                     $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html($gallery->abspath));
                     nggGallery::show_error($message);
                     return;
                 }
                 // save temp file to gallery
                 if (!@move_uploaded_file($temp_file, $dest_file)) {
                     nggGallery::show_error(__('Error, the file could not be moved to : ', 'nggallery') . esc_html($dest_file));
                     nggAdmin::check_safemode($gallery->abspath);
                     continue;
                 }
                 if (!nggAdmin::chmod($dest_file)) {
                     nggGallery::show_error(__('Error, the file permissions could not be set', 'nggallery'));
                     continue;
                 }
                 // add to imagelist & dirlist
                 $imageslist[] = $filename;
                 $dirlist[] = $filename;
             }
         }
     }
     if (count($imageslist) > 0) {
         // add images to database
         $image_ids = nggAdmin::add_Images($galleryID, $imageslist);
         //create thumbnails
         nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
         //add the preview image if needed
         nggAdmin::set_gallery_preview($galleryID);
         nggGallery::show_message(count($image_ids) . __(' Image(s) successfully added', 'nggallery'));
     }
     return;
 }
예제 #16
0
 /**
  * nggAdmin::import_gallery()
  * TODO: Check permission of existing thumb folder & images
  *
  * @class nggAdmin
  * @param string $galleryfolder contains relative path to the gallery itself
  * @return void
  */
 static function import_gallery($galleryfolder, $gallery_id = NULL)
 {
     global $wpdb, $user_ID;
     // get the current user ID
     wp_get_current_user();
     $created_msg = '';
     // remove trailing slash at the end, if somebody use it
     $galleryfolder = untrailingslashit($galleryfolder);
     $fs = C_Fs::get_instance();
     if (is_null($gallery_id)) {
         $gallerypath = $fs->join_paths($fs->get_document_root('content'), $galleryfolder);
     } else {
         $storage = C_Gallery_Storage::get_instance();
         $gallerypath = $storage->get_gallery_abspath($gallery_id);
     }
     if (!is_dir($gallerypath)) {
         nggGallery::show_error(sprintf(__("Directory <strong>%s</strong> doesn&#96;t exist!", 'nggallery'), esc_html($gallerypath)));
         return;
     }
     // read list of images
     $new_imageslist = nggAdmin::scandir($gallerypath);
     if (empty($new_imageslist)) {
         nggGallery::show_message(sprintf(__("Directory <strong>%s</strong> contains no pictures", 'nggallery'), esc_html($gallerypath)));
         return;
     }
     // take folder name as gallery name
     $galleryname = basename($galleryfolder);
     $galleryname = apply_filters('ngg_gallery_name', $galleryname);
     // check for existing gallery folder
     if (is_null($gallery_id)) {
         $gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' ");
     }
     if (!$gallery_id) {
         // now add the gallery to the database
         $gallery_id = nggdb::add_gallery($galleryname, $galleryfolder, '', 0, 0, $user_ID);
         if (!$gallery_id) {
             nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery'));
             return;
         } else {
             do_action('ngg_created_new_gallery', $gallery_id);
         }
         $created_msg = sprintf(_n("Gallery <strong>%s</strong> successfully created!", 'Galleries <strong>%s</strong> successfully created!', 1, 'nggallery'), esc_html($galleryname));
     }
     // Look for existing image list
     $old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' ");
     // if no images are there, create empty array
     if ($old_imageslist == NULL) {
         $old_imageslist = array();
     }
     // check difference
     $new_images = array_diff($new_imageslist, $old_imageslist);
     // all images must be valid files
     foreach ($new_images as $key => $picture) {
         // filter function to rename/change/modify image before
         $picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id);
         $new_images[$key] = $picture;
         if (!@getimagesize($gallerypath . '/' . $picture)) {
             unset($new_images[$key]);
             @unlink($gallerypath . '/' . $picture);
         }
     }
     // add images to database
     $image_ids = nggAdmin::add_Images($gallery_id, $new_images);
     do_action('ngg_after_new_images_added', $gallery_id, $image_ids);
     //add the preview image if needed
     nggAdmin::set_gallery_preview($gallery_id);
     // now create thumbnails
     nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
     //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
     $message = $created_msg . sprintf(_n('%s picture successfully added', '%s pictures successfully added', count($image_ids), 'nggallery'), count($image_ids));
     $message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >';
     $message .= __('Edit gallery', 'nggallery');
     $message .= '</a>]';
     nggGallery::show_message($message);
     return;
 }
예제 #17
0
function nggallery_admin_manage_album()
{
    global $wpdb;
    $albumID = (int) $_POST['act_album'];
    if ($_POST['update']) {
        check_admin_referer('ngg_album');
        if ($_POST['newalbum']) {
            $newalbum = attribute_escape($_POST['newalbum']);
            $result = $wpdb->query("INSERT INTO {$wpdb->nggalbum} (name, sortorder) VALUES ('{$newalbum}','0')");
            if ($result) {
                nggGallery::show_message(__('Update Successfully', 'nggallery'));
            }
        }
        if ($albumID > 0) {
            // get variable galleryContainer
            parse_str($_POST['sortorder']);
            if (is_array($gid)) {
                $serial_sort = serialize($gid);
                $wpdb->query("UPDATE {$wpdb->nggalbum} SET sortorder = '{$serial_sort}' WHERE id = {$albumID} ");
            } else {
                $wpdb->query("UPDATE {$wpdb->nggalbum} SET sortorder = '0' WHERE id = {$albumID} ");
            }
            nggGallery::show_message(__('Update Successfully', 'nggallery'));
        }
    }
    if ($_POST['delete']) {
        check_admin_referer('ngg_album');
        $result = nggdb::delete_album($albumID);
        if ($result) {
            nggGallery::show_message(__('Album deleted', 'nggallery'));
        }
    }
    ?>

<script type="text/javascript">

jQuery(document).ready(
	function()
	{

		jQuery('#selectContainer').sortable( {
			items: '.groupItem',
			placeholder: 'sort_placeholder',
			opacity: 0.7,
			tolerance: 'intersect',
			distance: 2,
			connectWith: ["#galleryContainer"] 
		} );

		jQuery('#galleryContainer').sortable( {
			items: '.groupItem',
			placeholder: 'sort_placeholder',
			opacity: 0.7,
			tolerance: 'intersect',
			distance: 2,
			connectWith: ["#selectContainer"] 
		} );
		
		jQuery('a.min').bind('click', toggleContent);

		// Hide used galleries
		jQuery('a#toggle_used').click(function()
			{
				jQuery('#selectContainer div.inUse').toggle();
				return false;
			}
		);	
			
		// Maximize All Portlets (whole site, no differentiation)
		jQuery('a#all_max').click(function()
			{
				jQuery('div.itemContent:hidden').show();
				return false;
			}
		);

		// Minimize All Portlets (whole site, no differentiation)
		jQuery('a#all_min').click(function()
			{
				jQuery('div.itemContent:visible').hide();
				return false;
			}
		);
	   // Auto Minimize if more than 4 (whole site, no differentiation)
	   if(jQuery('a.min').length > 4)
	   {
	   		jQuery('a.min').html('[+]');
	   		jQuery('div.itemContent:visible').hide();
	   		jQuery('#selectContainer div.inUse').toggle();
	   };
	}
);

var toggleContent = function(e)
{
	var targetContent = jQuery('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		jQuery(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		jQuery(this).html('[+]');
	}
	return false;
}

function ngg_serialize(s)
{
	//serial = jQuery.SortSerialize(s);
	serial = jQuery('#galleryContainer').sortable('serialize');
	jQuery('input[@name=sortorder]').val(serial);
}
</script>
<div class="wrap album" id="wrap" >
	<h2><?php 
    _e('Manage Albums', 'nggallery');
    ?>
</h2>
	<form id="selectalbum" method="POST" onsubmit="ngg_serialize()" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_album');
    ?>
		<input name="sortorder" type="hidden" />
		<div class="tablenav">
			<div class="alignleft actions">
				<?php 
    _e('Select album', 'nggallery');
    ?>
				<select id="act_album" name="act_album" onchange="this.form.submit();">
					<option value="0" ><?php 
    _e('No album selected', 'nggallery');
    ?>
</option>
					<?php 
    $albumlist = $wpdb->get_results("SELECT * FROM {$wpdb->nggalbum} ORDER BY id ASC");
    if (is_array($albumlist)) {
        foreach ($albumlist as $album) {
            if ($_POST['act_album'] == $album->id) {
                $selected = 'selected="selected" ';
            } else {
                $selected = '';
            }
            echo '<option value="' . $album->id . '" ' . $selected . '>' . $album->name . '</option>' . "\n";
        }
    }
    ?>
				</select>
				<?php 
    if ($_POST['act_album'] > 0) {
        ?>
					<input class="button-primary action" type="submit" name="update" value="<?php 
        _e('Update', 'nggallery');
        ?>
"/>
					<input type="submit" name="delete" class="button-secondary action" value="<?php 
        _e('Delete', 'nggallery');
        ?>
" onclick="javascript:check=confirm('<?php 
        _e('Delete album ?', 'nggallery');
        ?>
');if(check==false) return false;"/>
				<?php 
    } else {
        ?>
					<span><?php 
        _e('Add new album', 'nggallery');
        ?>
&nbsp;</span><input class="search-input" id="newalbum" name="newalbum" type="text" value="" />			
					<input class="button-secondary action" type="submit" name="update" value="<?php 
        _e('Add', 'nggallery');
        ?>
"/>
				<?php 
    }
    ?>
	
			</div>
		</div>
	</form>
	<br style="clear: both;"/>
	<p>
	<div style="float:right;">
	  <a href="#" id="toggle_used"><?php 
    _e('[Show all]', 'nggallery');
    ?>
</a>
	| <a href="#" id="all_max"><?php 
    _e('[Maximize]', 'nggallery');
    ?>
</a>
	| <a href="#" id="all_min"><?php 
    _e('[Minimize]', 'nggallery');
    ?>
</a>
	</div>
	<?php 
    _e('After you create and select a album, you can drag and drop a gallery into your album below', 'nggallery');
    ?>
	</p>

	<br class="clear"/>
	
	<div class="container">
		<div id="selectContainer" class="groupWrapper">
		<h3><?php 
    _e('Select Gallery', 'nggallery');
    ?>
</h3>
		<?php 
    $gallerylist = $wpdb->get_results("SELECT gid FROM {$wpdb->nggallery}");
    //TODO:Code MUST be optimized, how to flag a used gallery better ?
    $used_list = getallusedgalleries();
    if (is_array($gallerylist)) {
        if ($_POST['act_album'] == 0 or !isset($_POST['act_album'])) {
            foreach ($gallerylist as $gallery) {
                if (in_array($gallery->gid, $used_list)) {
                    getgallerycontainer($gallery->gid, true);
                } else {
                    getgallerycontainer($gallery->gid, false);
                }
            }
        } else {
            $act_album = $_POST['act_album'];
            $sortorder = $wpdb->get_var("SELECT sortorder FROM {$wpdb->nggalbum} WHERE id = '{$act_album}'");
            $sort_array = unserialize($sortorder);
            // if something went wrong, initialize to empty array
            if (!is_array($sort_array)) {
                $sort_array = array();
            }
            foreach ($gallerylist as $gallery) {
                if (!in_array($gallery->gid, $sort_array)) {
                    if (in_array($gallery->gid, $used_list)) {
                        getgallerycontainer($gallery->gid, true);
                    } else {
                        getgallerycontainer($gallery->gid, false);
                    }
                }
            }
        }
    }
    ?>
		</div><!-- /#select container -->

		<div id="galleryContainer" class="groupWrapper">
		<?php 
    if ($_POST['act_album'] > 0) {
        $act_album = $_POST['act_album'];
        $album = $wpdb->get_row("SELECT * FROM {$wpdb->nggalbum} WHERE id = '{$act_album}'");
        echo '<h3>' . __('Album Page ID', 'nggallery') . ' ' . $album->id . ' : ' . $album->name . '</h3>' . "\n";
        if (!empty($album->sortorder)) {
            $sort_array = unserialize($album->sortorder);
            if (is_array($sort_array)) {
                foreach ($sort_array as $galleryid) {
                    getgallerycontainer($galleryid, false);
                }
            }
        }
    } else {
        echo '<h3>' . __('No album selected!', 'nggallery') . '</h3>';
    }
    ?>
 
		</div><!-- /#gallery container -->

	</div><!-- /#container -->
</div><!-- /#wrap -->

<?php 
}
예제 #18
0
 /**
  * Publish a new post with the shortcode from the selected image
  * 
  * @since 1.7.0
  * @return void
  */
 function publish_post()
 {
     check_admin_referer('publish-post');
     // Create a WP page
     global $user_ID, $ngg;
     $ngg->options['publish_width'] = (int) $_POST['width'];
     $ngg->options['publish_height'] = (int) $_POST['height'];
     $ngg->options['publish_align'] = $_POST['align'];
     $align = $ngg->options['publish_align'] == 'none' ? '' : 'float=' . $ngg->options['publish_align'];
     //save the new values for the next operation
     update_option('ngg_options', $ngg->options);
     $post['post_type'] = 'post';
     $post['post_content'] = '[singlepic id=' . intval($_POST['pid']) . ' w=' . $ngg->options['publish_width'] . ' h=' . $ngg->options['publish_height'] . ' ' . $align . ']';
     $post['post_author'] = $user_ID;
     $post['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
     $post['post_title'] = $_POST['post_title'];
     $post = apply_filters('ngg_add_new_post', $post, $_POST['pid']);
     $post_id = wp_insert_post($post);
     if ($post_id != 0) {
         nggGallery::show_message(__('Published a new post', 'nggallery'));
     }
 }
예제 #19
0
/**
 * @author Alex Rabe
 *
 */
function nggallery_sortorder($galleryID = 0)
{
    global $wpdb, $ngg, $nggdb;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('ngg_updatesortorder');
        // get variable new sortorder
        parse_str($_POST['sortorder']);
        if (is_array($sortArray)) {
            $neworder = array();
            foreach ($sortArray as $pid) {
                $neworder[] = (int) $pid;
            }
            $sortindex = 1;
            foreach ($neworder as $pic_id) {
                $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
                $sortindex++;
            }
            C_Photocrati_Cache::flush('displayed_gallery_rendering');
            do_action('ngg_gallery_sort', $galleryID);
            nggGallery::show_message(__('Sort order changed', 'nggallery'));
        }
    }
    // look for presort args
    $presort = isset($_GET['presort']) ? $_GET['presort'] : false;
    $dir = isset($_GET['dir']) && $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
    $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
    // ensure that nobody added some evil sorting :-)
    if (in_array($presort, $sortitems)) {
        $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
    } else {
        $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
    }
    //this is the url without any presort variable
    $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
    //if we go back , then the mode should be edit
    $back_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
    // In the case somebody presort, then we take this url
    if (isset($_GET['dir']) || isset($_GET['presort'])) {
        $base_url = $_SERVER['REQUEST_URI'];
    } else {
        $base_url = $clean_url;
    }
    ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			if ($(this).data('ready')) return;

			// Enable sorting
			$(".jqui-sortable").sortable({items: 'div.imageBox'});

			$('#sortGallery').submit(function(e){
				var serial = "";
				var $images = $('div.imageBox');
				for (var i=0; i<$images.length; i++) {
					var image_id = $images[i].id.split('-').pop();
					if (serial.length > 0) serial = serial + '&';
					serial = serial + "sortArray[]=" + image_id;
				}
				$('input[name=sortorder]').val(serial);
			});

			// Listen for events in other frames
			if (window.Frame_Event_Publisher) {
				Frame_Event_Publisher.listen_for('attach_to_post:manage_galleries attach_to_post:manage_images', function(){
					window.location.href = window.location.href;
				});
			}

			$(this).data('ready', true);
		});


	</script>
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php 
    echo $clean_url;
    ?>
" accept-charset="utf-8">
			<h2><?php 
    _e('Sort Gallery', 'nggallery');
    ?>
</h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php 
    wp_nonce_field('ngg_updatesortorder');
    ?>
					<input class="button-primary action" type="submit" name="updateSortorder" value="<?php 
    _e('Update Sort Order', 'nggallery');
    ?>
" />
				</div>
				<div class="alignright actions">
					<a href="<?php 
    echo nextgen_esc_url($back_url);
    ?>
" class="button"><?php 
    _e('Back to gallery', 'nggallery');
    ?>
</a>
				</div>
			</div>
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php 
    _e('Presort', 'nggallery');
    ?>
 :</li>
				<li><a href="<?php 
    echo esc_attr(remove_query_arg('presort', $base_url));
    ?>
" <?php 
    if ($presort == '') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Unsorted', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'pid', $base_url));
    ?>
" <?php 
    if ($presort == 'pid') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Image ID', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'filename', $base_url));
    ?>
" <?php 
    if ($presort == 'filename') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Filename', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'alttext', $base_url));
    ?>
" <?php 
    if ($presort == 'alttext') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Alt/Title text', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'imagedate', $base_url));
    ?>
" <?php 
    if ($presort == 'imagedate') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Date/Time', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'ASC', $base_url));
    ?>
" <?php 
    if ($dir == 'ASC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Ascending', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'DESC', $base_url));
    ?>
" <?php 
    if ($dir == 'DESC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Descending', 'nggallery');
    ?>
</a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<div class='jqui-sortable'>
			<?php 
    if ($picturelist) {
        foreach ($picturelist as $picture) {
            ?>
					<div class="imageBox" id="pid-<?php 
            echo $picture->pid;
            ?>
">
						<div class="imageBox_theImage" style="background-image:url('<?php 
            echo nextgen_esc_url($picture->thumbURL);
            ?>
')"></div>
						<div class="imageBox_label"><span><?php 
            echo esc_html(stripslashes($picture->alttext));
            ?>
</span></div>
					</div>
					<?php 
        }
    }
    ?>
		</div>
	</div>

<?php 
}
예제 #20
0
 /**
  * Copy images to another gallery
  * 
  * @class nggAdmin
  * @param array|int $pic_ids ID's of the images
  * @param int $dest_gid destination gallery
  * @return void
  */
 function copy_images($pic_ids, $dest_gid)
 {
     require_once NGGALLERY_ABSPATH . '/lib/meta.php';
     $errors = $messages = '';
     if (!is_array($pic_ids)) {
         $pic_ids = array($pic_ids);
     }
     // Get destination gallery
     $destination = nggdb::find_gallery($dest_gid);
     if ($destination == null) {
         nggGallery::show_error(__('The destination gallery does not exist', 'nggallery'));
         return;
     }
     // Check for folder permission
     if (!is_writeable(WINABSPATH . $destination->path)) {
         $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path);
         nggGallery::show_error($message);
         return;
     }
     // Get pictures
     $images = nggdb::find_images_in_list($pic_ids);
     $destination_path = WINABSPATH . $destination->path;
     foreach ($images as $image) {
         // WPMU action
         if (nggWPMU::check_quota()) {
             return;
         }
         $i = 0;
         $tmp_prefix = '';
         $destination_file_name = $image->filename;
         while (file_exists($destination_path . '/' . $destination_file_name)) {
             $tmp_prefix = 'copy_' . $i++ . '_';
             $destination_file_name = $tmp_prefix . $image->filename;
         }
         $destination_file_path = $destination_path . '/' . $destination_file_name;
         $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
         // Copy files
         if (!@copy($image->imagePath, $destination_file_path)) {
             $errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />';
             continue;
         }
         // Copy backup file, if possible
         @copy($image->imagePath . '_backup', $destination_file_path . '_backup');
         // Copy the thumbnail if possible
         @copy($image->thumbPath, $destination_thumb_file_path);
         // Create new database entry for the image
         $new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
         if (!isset($new_pid)) {
             $errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />';
             continue;
         }
         // Copy tags
         nggTags::copy_tags($image->pid, $new_pid);
         // Copy meta information
         $meta = new nggMeta($image->pid);
         nggdb::update_image_meta($new_pid, $meta->image->meta_data);
         if ($tmp_prefix != '') {
             $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) &raquo; The file already existed in the destination gallery.', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
         } else {
             $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />';
         }
     }
     // Finish by showing errors or success
     if ($errors == '') {
         $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>';
         $messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'nggallery'), count($images), $link);
     }
     if ($messages != '') {
         nggGallery::show_message($messages);
     }
     if ($errors != '') {
         nggGallery::show_error($errors);
     }
     return;
 }
예제 #21
0
파일: manage.php 프로젝트: alx/SimplePress
 function post_processor_images()
 {
     global $wpdb, $ngg, $nggdb;
     // bulk update in a single gallery
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         check_admin_referer('ngg_updategallery');
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 break;
             case 'rotate_cw':
                 nggAdmin::do_ajax_operation('rotate_cw', $_POST['doaction'], __('Rotate images', 'nggallery'));
                 break;
             case 'rotate_ccw':
                 nggAdmin::do_ajax_operation('rotate_ccw', $_POST['doaction'], __('Rotate images', 'nggallery'));
                 break;
             case 'set_watermark':
                 nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'delete_images':
                 if (is_array($_POST['doaction'])) {
                     foreach ($_POST['doaction'] as $imageID) {
                         $image = $nggdb->find_image($imageID);
                         if ($image) {
                             if ($ngg->options['deleteImg']) {
                                 @unlink($image->imagePath);
                                 @unlink($image->thumbPath);
                             }
                             $delete_pic = nggdb::delete_image($image->pid);
                         }
                     }
                     if ($delete_pic) {
                         nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery'));
                     }
                 }
                 break;
             case 'import_meta':
                 nggAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
         $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
         update_option('ngg_options', $ngg->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         nggAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
         check_admin_referer('ngg_thickbox_form');
         //save the new values for the next operation
         $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
         $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
         $ngg->options['thumbfix'] = (bool) $_POST['thumbfix'];
         update_option('ngg_options', $ngg->options);
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         nggAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'nggallery'));
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
         check_admin_referer('ngg_thickbox_form');
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $dest_gid = (int) $_POST['dest_gid'];
         switch ($_POST['TB_bulkaction']) {
             case 'copy_to':
                 // Copy images
                 nggAdmin::copy_images($pic_ids, $dest_gid);
                 break;
             case 'move_to':
                 // Move images
                 nggAdmin::move_images($pic_ids, $dest_gid);
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) {
         // do tags update
         check_admin_referer('ngg_thickbox_form');
         // get the images list
         $pic_ids = explode(',', $_POST['TB_imagelist']);
         $taglist = explode(',', $_POST['taglist']);
         $taglist = array_map('trim', $taglist);
         if (is_array($pic_ids)) {
             foreach ($pic_ids as $pic_id) {
                 // which action should be performed ?
                 switch ($_POST['TB_bulkaction']) {
                     case 'no_action':
                         // No action
                         break;
                     case 'overwrite_tags':
                         // Overwrite tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
                         break;
                     case 'add_tags':
                         // Add / append tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
                         break;
                     case 'delete_tags':
                         // Delete tags
                         $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
                         // get the slugs, to vaoid  case sensitive problems
                         $slugarray = array_map('sanitize_title', $taglist);
                         $oldtags = array_map('sanitize_title', $oldtags);
                         // compare them and return the diff
                         $newtags = array_diff($oldtags, $slugarray);
                         wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
                         break;
                 }
             }
             nggGallery::show_message(__('Tags changed', 'nggallery'));
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('ngg_updategallery');
         $gallery_title = esc_attr($_POST['title']);
         $gallery_path = esc_attr($_POST['path']);
         $gallery_desc = esc_attr($_POST['gallerydesc']);
         $gallery_pageid = (int) $_POST['pageid'];
         $gallery_preview = (int) $_POST['previewpic'];
         $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', path= '{$gallery_path}', galdesc = '{$gallery_desc}', pageid = '{$gallery_pageid}', previewpic = '{$gallery_preview}' WHERE gid = '{$this->gid}'");
         if (isset($_POST['author'])) {
             $gallery_author = (int) $_POST['author'];
             $wpdb->query("UPDATE {$wpdb->nggallery} SET author = '{$gallery_author}' WHERE gid = '{$this->gid}'");
         }
         $this->update_pictures();
         //hook for other plugin to update the fields
         do_action('ngg_update_gallery', $this->gid, $_POST);
         nggGallery::show_message(__('Update successful', "nggallery"));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::import_gallery($gallerypath);
     }
     if (isset($_POST['addnewpage'])) {
         // Add a new page
         check_admin_referer('ngg_updategallery');
         $parent_id = esc_attr($_POST['parent_id']);
         $gallery_title = esc_attr($_POST['title']);
         $gallery_name = $wpdb->get_var("SELECT name FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         // Create a WP page
         global $user_ID;
         $page['post_type'] = 'page';
         $page['post_content'] = '[nggallery id=' . $this->gid . ']';
         $page['post_parent'] = $parent_id;
         $page['post_author'] = $user_ID;
         $page['post_status'] = 'publish';
         $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
         $page = apply_filters('ngg_add_new_page', $page, $this->gid);
         $gallery_pageid = wp_insert_post($page);
         if ($gallery_pageid != 0) {
             $result = $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', pageid = '{$gallery_pageid}' WHERE gid = '{$this->gid}'");
             nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery'));
         }
     }
 }