Exemple #1
0
    function tab_uploadimage()
    {
        global $ngg;
        // check the cookie for the current setting
        $checked = get_user_setting('ngg_upload_resize') ? ' checked="true"' : '';
        ?>
    	<!-- upload images -->
    	<h2><?php 
        _e('Upload Images', 'nggallery');
        ?>
</h2>
		<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $this->filepath . '#uploadimage';
        ?>
" accept-charset="utf-8" >
		<?php 
        wp_nonce_field('ngg_addgallery');
        ?>
			<table class="form-table">
            
			<tr valign="top">
				<th scope="row"><?php 
        _e('Upload image', 'nggallery');
        ?>
</th>
                <?php 
        if ($ngg->options['swfUpload'] && defined('IS_WP_3_3')) {
            ?>
				<td>
                <div id="plupload-upload-ui">
                	<div>
                    	<?php 
            _e('Choose files to upload');
            ?>
                    	<input id="plupload-browse-button" type="button" value="<?php 
            esc_attr_e('Select Files');
            ?>
" class="button" />
                	</div>
                	<p class="ngg-dragdrop-info howto" style="display:none;" ><?php 
            _e('Or you can drop the files into this window.');
            ?>
</p>
                    <div id='uploadQueue'></div>
                    <p><label><input name="image_resize" type="checkbox" id="image_resize" value="true"<?php 
            echo $checked;
            ?>
 />
                        <?php 
            printf(__('Scale images to max width %1$dpx or max height %2$dpx', 'nggallery'), (int) $ngg->options['imgWidth'], (int) $ngg->options['imgHeight']);
            ?>
                        <div id='image_resize_pointer'>&nbsp;</div>
                        </label>
                    </p>
                    
                 </div>
                </td>
                <?php 
        } else {
            ?>
				<td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></td>
                <?php 
        }
        ?>
            </tr> 
			<tr valign="top"> 
				<th scope="row"><?php 
        _e('in to', 'nggallery');
        ?>
</th> 
				<td><select name="galleryselect" id="galleryselect">
				<option value="0" ><?php 
        _e('Choose gallery', 'nggallery');
        ?>
</option>
				<?php 
        foreach ($this->gallerylist as $gallery) {
            //special case : we check if a user has this cap, then we override the second cap check
            if (!current_user_can('NextGEN Upload in all galleries')) {
                if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                    continue;
                }
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr($name) . '</option>' . "\n";
        }
        ?>
				</select>
				<br /><?php 
        echo $this->maxsize;
        ?>
				<br /><?php 
        if (is_multisite() && wpmu_enable_function('wpmuQuotaCheck')) {
            display_space_usage();
        }
        ?>
</td> 
			</tr> 
			</table>
			<div class="submit">
				<?php 
        if ($ngg->options['swfUpload']) {
            ?>
				<input type="submit" name="disable_flash" id="disable_flash" title="<?php 
            _e('The batch upload requires Adobe Flash 10, disable it if you have problems', 'nggallery');
            ?>
" value="<?php 
            _e('Disable flash upload', 'nggallery');
            ?>
" />
				<?php 
        } else {
            ?>
				<input type="submit" name="enable_flash" id="enable_flash" title="<?php 
            _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'nggallery');
            ?>
" value="<?php 
            _e('Enable flash based upload', 'nggallery');
            ?>
" />
				<?php 
        }
        ?>
				<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'nggallery');
        ?>
" />
			</div>
		</form>
    <?php 
    }
function nggallery_manage_gallery_main()
{
    global $ngg, $nggdb, $wp_query;
    //Build the pagination for more than 25 galleries
    if (!isset($_GET['paged']) || $_GET['paged'] < 1) {
        $_GET['paged'] = 1;
    }
    $start = ($_GET['paged'] - 1) * 25;
    $gallerylist = $nggdb->find_all_galleries('gid', 'asc', TRUE, 25, $start, false);
    $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $nggdb->paged['max_objects_per_page'], 'current' => $_GET['paged']));
    ?>
	<script type="text/javascript"> 
	<!--
	function checkAll(form)
	{
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]") {
					if(form.elements[i].checked == true)
						form.elements[i].checked = false;
					else
						form.elements[i].checked = true;
				}
			}
		}
	}
	
	function getNumChecked(form)
	{
		var num = 0;
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]")
					if(form.elements[i].checked == true)
						num++;
			}
		}
		return num;
	}

	// this function check for a the number of selected images, sumbmit false when no one selected
	function checkSelected() {
	
		var numchecked = getNumChecked(document.getElementById('editgalleries'));
		 
		if(numchecked < 1) { 
			alert('<?php 
    echo esc_js(__('No images selected', 'nggallery'));
    ?>
');
			return false; 
		} 
		
		actionId = jQuery('#bulkaction').val();
		
		switch (actionId) {
			case "resize_images":
                showDialog('resize_images', '<?php 
    echo esc_js(__('Resize images', 'nggallery'));
    ?>
');
				return false;
				break;
			case "new_thumbnail":
				showDialog('new_thumbnail', '<?php 
    echo esc_js(__('Create new thumbnails', 'nggallery'));
    ?>
');
				return false;
				break;
		}
		
		return confirm('<?php 
    echo sprintf(esc_js(__("You are about to start the bulk edit for %s galleries \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
	}

	function showDialog( windowId, title ) {
		var form = document.getElementById('editgalleries');
		var elementlist = "";
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]")
					if(form.elements[i].checked == true)
						if (elementlist == "")
							elementlist = form.elements[i].value
						else
							elementlist += "," + form.elements[i].value ;
			}
		}
		jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
		jQuery("#" + windowId + "_imagelist").val(elementlist);
        // now show the dialog
    	jQuery( "#" + windowId ).dialog({
    		width: 640,
            resizable : false,
    		modal: true,
            title: title      
    	});
        jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
	}
	
	function showAddGallery() {
    	jQuery( "#addGallery").dialog({
    		width: 640,
            resizable : false,
    		modal: true,
            title: '<?php 
    echo esc_js(__('Add new gallery', 'nggallery'));
    ?>
'          
    	});	   
        jQuery("#addGallery .dialog-cancel").click(function() { jQuery( "#addGallery" ).dialog("close"); });
	}
	//-->
	</script>
	<div class="wrap">
        <?php 
    screen_icon('nextgen-gallery');
    ?>
		<h2><?php 
    echo _n('Gallery', 'Galleries', 2, 'nggallery');
    ?>
</h2>
		<form class="search-form" action="" method="get">
		<p class="search-box">
			<label class="hidden" for="media-search-input"><?php 
    _e('Search Images', 'nggallery');
    ?>
:</label>
			<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
			<input type="text" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
			<input type="submit" value="<?php 
    _e('Search Images', 'nggallery');
    ?>
" class="button" />
		</p>
		</form>
		<form id="editgalleries" class="nggform" method="POST" action="<?php 
    echo $ngg->manage_page->base_page . '&amp;paged=' . $_GET['paged'];
    ?>
" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_bulkgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />
		
		<div class="tablenav">
			
			<div class="alignleft actions">
				<?php 
    if (function_exists('json_encode')) {
        ?>
				<select name="bulkaction" id="bulkaction">
					<option value="no_action" ><?php 
        _e("Bulk actions", 'nggallery');
        ?>
</option>
					<option value="delete_gallery" ><?php 
        _e("Delete", 'nggallery');
        ?>
</option>
                    <option value="set_watermark" ><?php 
        _e("Set watermark", 'nggallery');
        ?>
</option>
					<option value="new_thumbnail" ><?php 
        _e("Create new thumbnails", 'nggallery');
        ?>
</option>
					<option value="resize_images" ><?php 
        _e("Resize images", 'nggallery');
        ?>
</option>
					<option value="import_meta" ><?php 
        _e("Import metadata", 'nggallery');
        ?>
</option>
					<option value="recover_images" ><?php 
        _e("Recover from backup", 'nggallery');
        ?>
</option>
				</select>
				<input name="showThickbox" class="button-secondary" type="submit" value="<?php 
        _e('Apply', 'nggallery');
        ?>
" onclick="if ( !checkSelected() ) return false;" />
				<?php 
    }
    ?>
				<?php 
    if (current_user_can('NextGEN Upload images') && nggGallery::current_user_can('NextGEN Add new gallery')) {
        ?>
					<input name="doaction" class="button-secondary action" type="submit" onclick="showAddGallery(); return false;" value="<?php 
        _e('Add new gallery', 'nggallery');
        ?>
"/>
				<?php 
    }
    ?>
			</div>
			
		<?php 
    if ($page_links) {
        ?>
			<div class="tablenav-pages"><?php 
        $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links);
        echo $page_links_text;
        ?>
</div>
		<?php 
    }
    ?>
		
		</div>
		<table class="widefat" cellspacing="0">
			<thead>
			<tr>
<?php 
    print_column_headers('nggallery-manage-galleries');
    ?>
			</tr>
			</thead>
			<tfoot>
			<tr>
<?php 
    print_column_headers('nggallery-manage-galleries', false);
    ?>
			</tr>
			</tfoot>            
			<tbody>
<?php 
    if ($gallerylist) {
        //get the columns
        $gallery_columns = ngg_manage_gallery_columns();
        $hidden_columns = get_hidden_columns('nggallery-manage-images');
        $num_columns = count($gallery_columns) - count($hidden_columns);
        foreach ($gallerylist as $gallery) {
            $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
            $gid = $gallery->gid;
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            $author_user = get_userdata((int) $gallery->author);
            ?>
		<tr id="gallery-<?php 
            echo $gid;
            ?>
" <?php 
            echo $alternate;
            ?>
 >
		<?php 
            foreach ($gallery_columns as $gallery_column_key => $column_display_name) {
                $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\"";
                $style = '';
                if (in_array($gallery_column_key, $hidden_columns)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($gallery_column_key) {
                    case 'cb':
                        ?>
        			<th scope="row" class="cb column-cb">
        				<?php 
                        if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                            ?>
        					<input name="doaction[]" type="checkbox" value="<?php 
                            echo $gid;
                            ?>
" />
        				<?php 
                        }
                        ?>
        			</th>
        			<?php 
                        break;
                    case 'id':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
 scope="row"><?php 
                        echo $gid;
                        ?>
</td>
					<?php 
                        break;
                    case 'title':
                        ?>
        			<td>
        				<?php 
                        if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                            ?>
        					<a href="<?php 
                            echo wp_nonce_url($ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $gid, 'ngg_editgallery');
                            ?>
" class='edit' title="<?php 
                            _e('Edit');
                            ?>
" >
        						<?php 
                            echo nggGallery::i18n($name);
                            ?>
        					</a>
        				<?php 
                        } else {
                            ?>
        					<?php 
                            echo nggGallery::i18n($gallery->title);
                            ?>
        				<?php 
                        }
                        ?>
        			</td>
        			<?php 
                        break;
                    case 'description':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo nggGallery::i18n($gallery->galdesc);
                        ?>
&nbsp;</td>
					<?php 
                        break;
                    case 'author':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $author_user->display_name;
                        ?>
</td>
					<?php 
                        break;
                    case 'page_id':
                        ?>
        			<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gallery->pageid;
                        ?>
</td>
        			<?php 
                        break;
                    case 'quantity':
                        ?>
        			<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gallery->counter;
                        ?>
</td>
        			<?php 
                        break;
                    default:
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid);
                        ?>
</td>
					<?php 
                        break;
                }
            }
            ?>
		</tr>
		<?php 
        }
    } else {
        echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>
			
			</tbody>
		</table>
        <div class="tablenav">
		<?php 
    if ($page_links) {
        ?>
			<div class="tablenav-pages"><?php 
        $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links);
        echo $page_links_text;
        ?>
</div>
		<?php 
    }
    ?>
        </div>
		</form>
	</div>
	<!-- #addGallery -->
	<div id="addGallery" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_addgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<td>
					<strong><?php 
    _e('New Gallery', 'nggallery');
    ?>
:</strong> <input type="text" size="35" name="galleryname" value="" /><br />
					<?php 
    if (!is_multisite()) {
        ?>
					<?php 
        _e('Create a new , empty gallery below the folder', 'nggallery');
        ?>
  <strong><?php 
        echo $ngg->options['gallerypath'];
        ?>
</strong><br />
					<?php 
    }
    ?>
					<i>( <?php 
    _e('Allowed characters for file and folder names are', 'nggallery');
    ?>
: a-z, A-Z, 0-9, -, _ )</i>
				</td>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="addgallery" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#addGallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong> 
				</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'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php 
    echo $ngg->options['thumbwidth'];
    ?>
" /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php 
    echo $ngg->options['thumbheight'];
    ?>
" />
				<br /><small><?php 
    _e('These values are maximum values ', 'nggallery');
    ?>
</small></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']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->	

<?php 
}
Exemple #3
0
function nggallery_picturelist($controller)
{
    // *** show picture list
    global $wpdb, $nggdb, $user_ID, $ngg;
    // Look if its a search result
    $is_search = isset($_GET['s']) ? true : false;
    $counter = 0;
    $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
    if ($is_search) {
        // fetch the imagelist
        $picturelist = $ngg->manage_page->search_result;
        // we didn't set a gallery or a pagination
        $act_gid = 0;
        $_GET['paged'] = 1;
        $page_links = false;
    } else {
        // GET variables
        $act_gid = $ngg->manage_page->gid;
        // Load the gallery metadata
        $mapper = C_Gallery_Mapper::get_instance();
        $gallery = $mapper->find($act_gid);
        if (!$gallery) {
            nggGallery::show_error(__('Gallery not found.', 'nggallery'));
            return;
        }
        // Check if you have the correct capability
        if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
            nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
            return;
        }
        // look for pagination
        $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
        $items_per_page = 50;
        $start = ($_GET['paged'] - 1) * $items_per_page;
        // get picture values
        $image_mapper = C_Image_Mapper::get_instance();
        $total_number_of_images = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $act_gid))->run_query(FALSE, TRUE));
        $picturelist = $image_mapper->select()->where(array("galleryid = %d", $act_gid))->order_by($ngg->options['galSort'], $ngg->options['galSortDir'])->limit($items_per_page, $start)->run_query();
        // get the current author
        $act_author_user = get_userdata((int) $gallery->author);
    }
    // list all galleries
    $gallerylist = $nggdb->find_all_galleries();
    //get the columns
    $image_columns = $wp_list_table->get_columns();
    $hidden_columns = get_hidden_columns('nggallery-manage-images');
    $num_columns = count($image_columns) - count($hidden_columns);
    $attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"';
    ?>
<script type="text/javascript">
<!--
function showDialog( windowId, title ) {
	var form = document.getElementById('updategallery');
	var elementlist = "";
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					if (elementlist == "")
						elementlist = form.elements[i].value;
					else
						elementlist += "," + form.elements[i].value ;
		}
	}
	jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
	jQuery("#" + windowId + "_imagelist").val(elementlist);
    // now show the dialog
	jQuery( "#" + windowId ).dialog({
		width: 640,
        resizable : false,
		modal: true,
        title: title,
		position: {
			my:		'center',
			at:		'center',
			of:		window.parent
		}
	});
    jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
}

jQuery(function (){

    jQuery('span.tooltip, label.tooltip').tooltip();

    // load a content via ajax
    jQuery('a.ngg-dialog').click(function() {
    	var dialogs = jQuery('.ngg-overlay-dialog:visible');
    	if (dialogs.size() > 0) {
    		return false;
    	}

      if ( jQuery( "#spinner" ).length == 0) {
      	jQuery("body").append('<div id="spinner"></div>');
      }

    	var $this = jQuery(this);
      var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
    	var width  = ( results ) ? results[1] : 600;
      var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
	    var height = ( results ) ? results[1] : 440;
      var container = window;

      if (window.parent) {
      	container = window.parent;
      }

      jQuery('#spinner').fadeIn();
      jQuery('#spinner').position({ my: "center", at: "center", of: container });

      var dialog = jQuery('<div class="ngg-overlay-dialog" style="display:hidden"></div>').appendTo('body');
      // load the remote content
      dialog.load(
          this.href,
          {},
          function () {
              jQuery('#spinner').hide();

              dialog.dialog({
                  title: ($this.attr('title')) ? $this.attr('title') : '',
                  position: { my: "center", at: "center", of: container },
                  width: width,
                  height: height,
                  modal: true,
                  resizable: false,
                  close: function() { dialog.remove(); }
              }).width(width - 30).height(height - 30);
          }
      );

      //prevent the browser to follow the link
      return false;
    });
});

function checkAll(form)
{
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]") {
				if(form.elements[i].checked == true)
					form.elements[i].checked = false;
				else
					form.elements[i].checked = true;
			}
		}
	}
}

function getNumChecked(form)
{
	var num = 0;
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					num++;
		}
	}
	return num;
}

// this function check for a the number of selected images, sumbmit false when no one selected
function checkSelected() {

	var numchecked = getNumChecked(document.getElementById('updategallery'));

    if (typeof document.activeElement == "undefined" && document.addEventListener) {
    	document.addEventListener("focus", function (e) {
    		document.activeElement = e.target;
    	}, true);
    }

    if ( document.activeElement.name == 'post_paged' )
        return true;

	if(numchecked < 1) {
		alert('<?php 
    echo esc_js(__('No images selected', 'nggallery'));
    ?>
');
		return false;
	}

	actionId = jQuery('#bulkaction').val();

	switch (actionId) {
		case "copy_to":
			showDialog('selectgallery', '<?php 
    echo esc_js(__('Copy image to...', 'nggallery'));
    ?>
');
			return false;
			break;
		case "move_to":
			showDialog('selectgallery', '<?php 
    echo esc_js(__('Move image to...', 'nggallery'));
    ?>
');
			return false;
			break;
		case "add_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Add new tags', 'nggallery'));
    ?>
');
			return false;
			break;
		case "delete_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Delete tags', 'nggallery'));
    ?>
');
			return false;
			break;
		case "overwrite_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Overwrite', 'nggallery'));
    ?>
');
			return false;
			break;
		case "resize_images":
			showDialog('resize_images', '<?php 
    echo esc_js(__('Resize images', 'nggallery'));
    ?>
');
			return false;
			break;
		case "new_thumbnail":
			showDialog('new_thumbnail', '<?php 
    echo esc_js(__('Create new thumbnails', 'nggallery'));
    ?>
');
			return false;
			break;
	}

	return confirm('<?php 
    echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
}

jQuery(document).ready( function($) {
	if ($(this).data('ready')) return;

	// close postboxes that should be closed
	jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
	postboxes.add_postbox_toggles('ngg-manage-gallery');

	jQuery('.iedit').mouseover(
		function(e){
			jQuery(this).parent().find('.row-actions').css('visibility', 'hidden');
			jQuery(this).next('.row_actions:first').find('.row-actions:first').css('visibility', 'visible');
		}
	);

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

//-->
</script>
<div class="wrap">
<?php 
    //include('templates/social_media_buttons.php');
    screen_icon('nextgen-gallery');
    if ($is_search) {
        ?>
<h2><?php 
        printf(__('Search results for &#8220;%s&#8221;', 'nggallery'), esc_html(get_search_query()));
        ?>
</h2>
<form class="search-form" action="" method="get">
<p class="search-box">
	<label class="hidden" for="media-search-input"><?php 
        _e('Search Images', 'nggallery');
        ?>
:</label>
	<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
	<input type="text" id="media-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
	<input type="submit" value="<?php 
        _e('Search Images', 'nggallery');
        ?>
" class="button" />
</p>
</form>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . get_search_query();
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
    } else {
        ?>
<h2><?php 
        echo _n('Gallery', 'Galleries', 1, 'nggallery');
        ?>
 : <?php 
        echo esc_html(nggGallery::i18n($gallery->title));
        ?>
</h2>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . esc_attr($_GET['paged']);
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
        if (nggGallery::current_user_can('NextGEN Edit gallery options')) {
            ?>
<div id="poststuff">
	<?php 
            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
            ?>
	<div id="gallerydiv" class="postbox <?php 
            echo postbox_classes('gallerydiv', 'ngg-manage-gallery');
            ?>
" >
		<h3><?php 
            _e('Gallery settings', 'nggallery');
            ?>
<small> (<?php 
            _e('Click here for more settings', 'nggallery');
            ?>
)</small></h3>
		<div class="inside">
			<?php 
            $controller->render_gallery_fields();
            ?>

			<div class="submit">
				<?php 
            if (wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can('NextGEN Import image folder')) {
                ?>
				<input type="submit" class="button-secondary" name="scanfolder" value="<?php 
                _e("Scan Folder for new images", 'nggallery');
                ?>
 " />
				<?php 
            }
            ?>
				<input type="submit" class="button-primary action" name="updatepictures" value="<?php 
            _e("Save Changes", 'nggallery');
            ?>
" />
			</div>

		</div>
	</div>
</div> <!-- poststuff -->
<?php 
        }
        ?>

<?php 
    }
    ?>

<div class="tablenav top ngg-tablenav">
    <?php 
    $ngg->manage_page->pagination('top', $_GET['paged'], $total_number_of_images, $items_per_page);
    ?>
	<div class="alignleft actions">
	<select id="bulkaction" name="bulkaction">
		<option value="no_action" ><?php 
    _e("Bulk actions", 'nggallery');
    ?>
</option>
		<option value="set_watermark" ><?php 
    _e("Set watermark", 'nggallery');
    ?>
</option>
		<option value="new_thumbnail" ><?php 
    _e("Create new thumbnails", 'nggallery');
    ?>
</option>
		<option value="resize_images" ><?php 
    _e("Resize images", 'nggallery');
    ?>
</option>
		<option value="recover_images" ><?php 
    _e("Recover from backup", 'nggallery');
    ?>
</option>
		<option value="delete_images" ><?php 
    _e("Delete images", 'nggallery');
    ?>
</option>
		<option value="import_meta" ><?php 
    _e("Import metadata", 'nggallery');
    ?>
</option>
		<option value="rotate_cw" ><?php 
    _e("Rotate images clockwise", 'nggallery');
    ?>
</option>
		<option value="rotate_ccw" ><?php 
    _e("Rotate images counter-clockwise", 'nggallery');
    ?>
</option>
		<option value="copy_to" ><?php 
    _e("Copy to...", 'nggallery');
    ?>
</option>
		<option value="move_to"><?php 
    _e("Move to...", 'nggallery');
    ?>
</option>
		<option value="add_tags" ><?php 
    _e("Add tags", 'nggallery');
    ?>
</option>
		<option value="delete_tags" ><?php 
    _e("Delete tags", 'nggallery');
    ?>
</option>
		<option value="overwrite_tags" ><?php 
    _e("Overwrite tags", 'nggallery');
    ?>
</option>
	</select>
	<input class="button-secondary" type="submit" name="showThickbox" value="<?php 
    _e('Apply', 'nggallery');
    ?>
" onclick="if ( !checkSelected() ) return false;" />

	<?php 
    if ($ngg->options['galSort'] == "sortorder" && !$is_search) {
        ?>
		<input class="button-secondary" type="submit" name="sortGallery" value="<?php 
        _e('Sort gallery', 'nggallery');
        ?>
" />
	<?php 
    }
    ?>

	<input type="submit" name="updatepictures" class="button-primary action"  value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
	</div>
</div>
<table id="ngg-listimages" class="widefat fixed" cellspacing="0" >

	<thead>
		<?php 
    $controller->render_image_row_header();
    ?>
	</thead>
	<tfoot>
		<?php 
    $controller->render_image_row_header();
    ?>
	</tfoot>
	<tbody id="the-list">
<?php 
    if ($picturelist) {
        $thumbsize = '';
        $storage = C_Gallery_Storage::get_instance();
        if ($ngg->options['thumbfix']) {
            $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
        }
        foreach ($picturelist as $picture) {
            //for search result we need to check the capatibiliy
            if (!nggAdmin::can_manage_this_gallery($gallery->author) && $is_search) {
                continue;
            }
            $counter++;
            $picture->imageURL = $storage->get_image_url($picture);
            $picture->thumbURL = $storage->get_thumb_url($picture);
            $picture->imagePath = $storage->get_image_abspath($picture);
            $picture->thumbPath = $storage->get_thumb_abspath($picture);
            echo apply_filters('ngg_manage_images_row', $picture, $counter);
        }
    }
    // In the case you have no capaptibility to see the search result
    if ($counter == 0) {
        echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>

		</tbody>
	</table>
    <div class="tablenav bottom">
    <input type="submit" class="button-primary action" name="updatepictures" value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
    <?php 
    $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_images, $items_per_page);
    ?>
    </div>
	</form>
	<br class="clear"/>
	</div><!-- /#wrap -->

	<!-- #entertags -->
	<div id="entertags" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th><?php 
    _e("Enter the tags", 'nggallery');
    ?>
 : <input name="taglist" type="text" style="width:90%" value="" /></th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="TB_EditTags" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e("Cancel", 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#entertags -->

	<!-- #selectgallery -->
	<div id="selectgallery" style="display: none;" >
		<form id="form-select-gallery" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th>
		    		<?php 
    _e('Select the destination gallery:', 'nggallery');
    ?>
&nbsp;
		    		<select name="dest_gid" style="width:90%" >
		    			<?php 
    foreach ($gallerylist as $gallery) {
        if ($gallery->gid != $act_gid) {
            ?>
						<option value="<?php 
            echo $gallery->gid;
            ?>
" ><?php 
            echo $gallery->gid;
            ?>
 - <?php 
            echo esc_attr(stripslashes($gallery->title));
            ?>
</option>
						<?php 
        }
    }
    ?>
		    		</select>
		    	</th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="<?php 
    _e("Cancel", 'nggallery');
    ?>
" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#selectgallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong>
				</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'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
    <table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td>
				<?php 
    include dirname(__FILE__) . '/thumbnails-template.php';
    ?>
				</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']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->

	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){columns.init('nggallery-manage-images');});
	/* ]]> */
	</script>
	<?php 
}
Exemple #4
0
function nggallery_picturelist()
{
    // *** show picture list
    global $wpdb, $nggdb, $user_ID, $ngg;
    // Look if its a search result
    $is_search = isset($_GET['s']) ? true : false;
    $counter = 0;
    $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
    if ($is_search) {
        // fetch the imagelist
        $picturelist = $ngg->manage_page->search_result;
        // we didn't set a gallery or a pagination
        $act_gid = 0;
        $_GET['paged'] = 1;
        $page_links = false;
    } else {
        // GET variables
        $act_gid = $ngg->manage_page->gid;
        // Load the gallery metadata
        $gallery = $nggdb->find_gallery($act_gid);
        if (!$gallery) {
            nggGallery::show_error(__('Gallery not found.', 'nggallery'));
            return;
        }
        // Check if you have the correct capability
        if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
            nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
            return;
        }
        // look for pagination
        $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
        $start = ($_GET['paged'] - 1) * 50;
        // get picture values
        $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start);
        // get the current author
        $act_author_user = get_userdata((int) $gallery->author);
    }
    // list all galleries
    $gallerylist = $nggdb->find_all_galleries();
    //get the columns
    $image_columns = $wp_list_table->get_columns();
    $hidden_columns = get_hidden_columns('nggallery-manage-images');
    $num_columns = count($image_columns) - count($hidden_columns);
    $attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"';
    ?>
<script type="text/javascript">
<!--
function showDialog( windowId, title ) {
	var form = document.getElementById('updategallery');
	var elementlist = "";
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					if (elementlist == "")
						elementlist = form.elements[i].value;
					else
						elementlist += "," + form.elements[i].value ;
		}
	}
	jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
	jQuery("#" + windowId + "_imagelist").val(elementlist);
    // now show the dialog
	jQuery( "#" + windowId ).dialog({
		width: 640,
        resizable : false,
		modal: true,
        title: title,
		position: {
			my:		'center',
			at:		'center',
			of:		window.parent
		}
	});
    jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
}

jQuery(function (){

    jQuery('span.tooltip, label.tooltip').tooltip();

    // load a content via ajax
    jQuery('a.ngg-dialog').click(function() {
    	var dialogs = jQuery('.ngg-overlay-dialog:visible');
    	if (dialogs.size() > 0) {
    		return false;
    	}

      if ( jQuery( "#spinner" ).length == 0) {
      	jQuery("body").append('<div id="spinner"></div>');
      }

    	var $this = jQuery(this);
      var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
    	var width  = ( results ) ? results[1] : 600;
      var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
	    var height = ( results ) ? results[1] : 440;
      var container = window;

      if (window.parent) {
      	container = window.parent;
      }

      jQuery('#spinner').fadeIn();
      jQuery('#spinner').position({ my: "center", at: "center", of: container });

      var dialog = jQuery('<div class="ngg-overlay-dialog" style="display:hidden"></div>').appendTo('body');
      // load the remote content
      dialog.load(
          this.href,
          {},
          function () {
              jQuery('#spinner').hide();

              dialog.dialog({
                  title: ($this.attr('title')) ? $this.attr('title') : '',
                  position: { my: "center", at: "center", of: container },
                  width: width,
                  height: height,
                  modal: true,
                  resizable: false,
                  close: function() { dialog.remove(); }
              }).width(width - 30).height(height - 30);
          }
      );

      //prevent the browser to follow the link
      return false;
    });
});

function checkAll(form)
{
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]") {
				if(form.elements[i].checked == true)
					form.elements[i].checked = false;
				else
					form.elements[i].checked = true;
			}
		}
	}
}

function getNumChecked(form)
{
	var num = 0;
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					num++;
		}
	}
	return num;
}

// this function check for a the number of selected images, sumbmit false when no one selected
function checkSelected() {

	var numchecked = getNumChecked(document.getElementById('updategallery'));

    if (typeof document.activeElement == "undefined" && document.addEventListener) {
    	document.addEventListener("focus", function (e) {
    		document.activeElement = e.target;
    	}, true);
    }

    if ( document.activeElement.name == 'post_paged' )
        return true;

	if(numchecked < 1) {
		alert('<?php 
    echo esc_js(__('No images selected', 'nggallery'));
    ?>
');
		return false;
	}

	actionId = jQuery('#bulkaction').val();

	switch (actionId) {
		case "copy_to":
			showDialog('selectgallery', '<?php 
    echo esc_js(__('Copy image to...', 'nggallery'));
    ?>
');
			return false;
			break;
		case "move_to":
			showDialog('selectgallery', '<?php 
    echo esc_js(__('Move image to...', 'nggallery'));
    ?>
');
			return false;
			break;
		case "add_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Add new tags', 'nggallery'));
    ?>
');
			return false;
			break;
		case "delete_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Delete tags', 'nggallery'));
    ?>
');
			return false;
			break;
		case "overwrite_tags":
			showDialog('entertags', '<?php 
    echo esc_js(__('Overwrite', 'nggallery'));
    ?>
');
			return false;
			break;
		case "resize_images":
			showDialog('resize_images', '<?php 
    echo esc_js(__('Resize images', 'nggallery'));
    ?>
');
			return false;
			break;
		case "new_thumbnail":
			showDialog('new_thumbnail', '<?php 
    echo esc_js(__('Create new thumbnails', 'nggallery'));
    ?>
');
			return false;
			break;
	}

	return confirm('<?php 
    echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
}

jQuery(document).ready( function($) {
	if ($(this).data('ready')) return;

	// close postboxes that should be closed
	jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
	postboxes.add_postbox_toggles('ngg-manage-gallery');

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

//-->
</script>
<div class="wrap">
<?php 
    //include('templates/social_media_buttons.php');
    screen_icon('nextgen-gallery');
    if ($is_search) {
        ?>
<h2><?php 
        printf(__('Search results for &#8220;%s&#8221;', 'nggallery'), esc_html(get_search_query()));
        ?>
</h2>
<form class="search-form" action="" method="get">
<p class="search-box">
	<label class="hidden" for="media-search-input"><?php 
        _e('Search Images', 'nggallery');
        ?>
:</label>
	<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
	<input type="text" id="media-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
	<input type="submit" value="<?php 
        _e('Search Images', 'nggallery');
        ?>
" class="button" />
</p>
</form>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . get_search_query();
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
    } else {
        ?>
<h2><?php 
        echo _n('Gallery', 'Galleries', 1, 'nggallery');
        ?>
 : <?php 
        echo esc_html(nggGallery::i18n($gallery->title));
        ?>
</h2>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . $_GET['paged'];
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
        if (nggGallery::current_user_can('NextGEN Edit gallery options')) {
            ?>
<div id="poststuff">
	<?php 
            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
            ?>
	<div id="gallerydiv" class="postbox <?php 
            echo postbox_classes('gallerydiv', 'ngg-manage-gallery');
            ?>
" >
		<h3><?php 
            _e('Gallery settings', 'nggallery');
            ?>
<small> (<?php 
            _e('Click here for more settings', 'nggallery');
            ?>
)</small></h3>
		<div class="inside">
			<table class="form-table" >
				<tr>
					<th align="left"><?php 
            _e('Title');
            ?>
:</th>
					<th align="left"><input <?php 
            nggGallery::current_user_can_form('NextGEN Edit gallery title');
            ?>
 type="text" size="50" name="title" value="<?php 
            echo esc_attr(stripslashes($gallery->title));
            ?>
"  /></th>
					<th align="right"><?php 
            _e('Page Link to', 'nggallery');
            ?>
:</th>
					<th align="left">
					<select <?php 
            nggGallery::current_user_can_form('NextGEN Edit gallery page id');
            ?>
  name="pageid" style="width:95%">
						<option value="0" ><?php 
            _e('Not linked', 'nggallery');
            ?>
</option>
                        <?php 
            foreach (get_pages() as $page) {
                ?>
                            <option <?php 
                selected($gallery->pageid, $page->ID);
                ?>
 value="<?php 
                echo esc_attr($page->ID);
                ?>
"><?php 
                echo esc_html($page->post_title);
                ?>
</option>
                        <?php 
            }
            ?>
					</select>
					</th>
				</tr>
				<tr>
					<th align="left"><?php 
            _e('Description');
            ?>
:</th>
					<th align="left"><textarea  <?php 
            nggGallery::current_user_can_form('NextGEN Edit gallery description');
            ?>
 name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php 
            echo esc_attr(stripslashes($gallery->galdesc));
            ?>
</textarea></th>
					<th align="right"><?php 
            _e('Preview image', 'nggallery');
            ?>
:</th>
					<th align="left">
						<select <?php 
            nggGallery::current_user_can_form('NextGEN Edit gallery preview pic');
            ?>
 name="previewpic" style="width:95%" >
							<option value="0" ><?php 
            _e('No Picture', 'nggallery');
            ?>
</option>
							<?php 
            // ensure that a preview pic from a other page is still shown here
            if (intval($gallery->previewpic) != 0) {
                if (!array_key_exists($gallery->previewpic, $picturelist)) {
                    $previewpic = $nggdb->find_image($gallery->previewpic);
                    if ($previewpic) {
                        echo '<option value="' . $previewpic->pid . '" selected="selected" >' . $previewpic->pid . ' - ' . esc_attr($previewpic->filename) . '</option>' . "\n";
                    }
                }
            }
            if (is_array($picturelist)) {
                foreach ($picturelist as $picture) {
                    if ($picture->exclude) {
                        continue;
                    }
                    $selected = $picture->pid == $gallery->previewpic ? 'selected="selected" ' : '';
                    echo '<option value="' . $picture->pid . '" ' . $selected . '>' . $picture->pid . ' - ' . esc_attr($picture->filename) . '</option>' . "\n";
                }
            }
            ?>
						</select>
					</th>
				</tr>
				<tr>
					<th align="left"><?php 
            _e('Path', 'nggallery');
            ?>
:</th>
					<th align="left"><input readonly="readonly" type="text" size="50" name="path" value="<?php 
            echo $gallery->path;
            ?>
"  /></th>
					<th align="right"><?php 
            _e('Author', 'nggallery');
            ?>
:</th>
					<th align="left">
					<?php 
            $editable_ids = $ngg->manage_page->get_editable_user_ids($user_ID);
            if ($editable_ids && count($editable_ids) > 1 && nggGallery::current_user_can('NextGEN Edit gallery author')) {
                wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author));
            } else {
                echo $act_author_user->display_name;
            }
            ?>
					</th>
				</tr>
				<?php 
            if (current_user_can('publish_pages')) {
                ?>
				<tr>
					<th align="left">&nbsp;</th>
					<th align="left">&nbsp;</th>
					<th align="right">
                        <label for='ngg_settings_parent_id'
                               class='tooltip'
                               title="Clicking <?php 
                _e('Add Page');
                ?>
 will create a new page with the same name as this gallery and will display the gallery on that new page. You can create a sub-page by selecting the parent page from the drop down.">
                            <?php 
                _e('Create new page', 'nggallery');
                ?>
:
                        </label>
                    </th>
					<th align="left">
					<select name="parent_id" style="width:95%" id='ngg_settings_parent_id'>
						<option value="0"><?php 
                _e('Main page (No parent)', 'nggallery');
                ?>
</option>
						<?php 
                foreach (get_pages() as $page) {
                    ?>
                        <option value="<?php 
                    echo esc_attr($page->ID);
                    ?>
"><?php 
                    echo esc_html($page->post_title);
                    ?>
</option>
                        <?php 
                }
                ?>
					</select>
					<input class="button-secondary action" type="submit" name="addnewpage" value="<?php 
                _e('Add page', 'nggallery');
                ?>
" id="group"/>
					</th>
				</tr>
				<?php 
            }
            ?>
                <?php 
            do_action('ngg_manage_gallery_settings', $act_gid);
            ?>

			</table>

			<div class="submit">
				<?php 
            if (wpmu_enable_function('wpmuScanFolder') && nggGallery::current_user_can('NextGEN Scan folder')) {
                ?>
				<input type="submit" class="button-secondary" name="scanfolder" value="<?php 
                _e("Scan Folder for new images", 'nggallery');
                ?>
 " />
				<?php 
            }
            ?>
				<input type="submit" class="button-primary action" name="updatepictures" value="<?php 
            _e("Save Changes", 'nggallery');
            ?>
" />
			</div>

		</div>
	</div>
</div> <!-- poststuff -->
<?php 
        }
        ?>

<?php 
    }
    ?>

<div class="tablenav top ngg-tablenav">
    <?php 
    $ngg->manage_page->pagination('top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page']);
    ?>
	<div class="alignleft actions">
	<select id="bulkaction" name="bulkaction">
		<option value="no_action" ><?php 
    _e("Bulk actions", 'nggallery');
    ?>
</option>
		<option value="set_watermark" ><?php 
    _e("Set watermark", 'nggallery');
    ?>
</option>
		<option value="new_thumbnail" ><?php 
    _e("Create new thumbnails", 'nggallery');
    ?>
</option>
		<option value="resize_images" ><?php 
    _e("Resize images", 'nggallery');
    ?>
</option>
		<option value="recover_images" ><?php 
    _e("Recover from backup", 'nggallery');
    ?>
</option>
		<option value="delete_images" ><?php 
    _e("Delete images", 'nggallery');
    ?>
</option>
		<option value="import_meta" ><?php 
    _e("Import metadata", 'nggallery');
    ?>
</option>
		<option value="rotate_cw" ><?php 
    _e("Rotate images clockwise", 'nggallery');
    ?>
</option>
		<option value="rotate_ccw" ><?php 
    _e("Rotate images counter-clockwise", 'nggallery');
    ?>
</option>
		<option value="copy_to" ><?php 
    _e("Copy to...", 'nggallery');
    ?>
</option>
		<option value="move_to"><?php 
    _e("Move to...", 'nggallery');
    ?>
</option>
		<option value="add_tags" ><?php 
    _e("Add tags", 'nggallery');
    ?>
</option>
		<option value="delete_tags" ><?php 
    _e("Delete tags", 'nggallery');
    ?>
</option>
		<option value="overwrite_tags" ><?php 
    _e("Overwrite tags", 'nggallery');
    ?>
</option>
	</select>
	<input class="button-secondary" type="submit" name="showThickbox" value="<?php 
    _e('Apply', 'nggallery');
    ?>
" onclick="if ( !checkSelected() ) return false;" />

	<?php 
    if ($ngg->options['galSort'] == "sortorder" && !$is_search) {
        ?>
		<input class="button-secondary" type="submit" name="sortGallery" value="<?php 
        _e('Sort gallery', 'nggallery');
        ?>
" />
	<?php 
    }
    ?>

	<input type="submit" name="updatepictures" class="button-primary action"  value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
	</div>
</div>

<table id="ngg-listimages" class="widefat fixed" cellspacing="0" >

	<thead>
	<tr>
<?php 
    $wp_list_table->print_column_headers(true);
    ?>
	</tr>
	</thead>
	<tfoot>
	<tr>
<?php 
    $wp_list_table->print_column_headers(false);
    ?>
	</tr>
	</tfoot>
	<tbody id="the-list">
<?php 
    if ($picturelist) {
        $thumbsize = '';
        if ($ngg->options['thumbfix']) {
            $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
        }
        foreach ($picturelist as $picture) {
            //for search result we need to check the capatibiliy
            if (!nggAdmin::can_manage_this_gallery($picture->author) && $is_search) {
                continue;
            }
            $counter++;
            $pid = (int) $picture->pid;
            $alternate = !isset($alternate) || $alternate == 'alternate' ? '' : 'alternate';
            $exclude = $picture->exclude ? 'checked="checked"' : '';
            $date = mysql2date(get_option('date_format'), $picture->imagedate);
            $time = mysql2date(get_option('time_format'), $picture->imagedate);
            ?>
		<tr id="picture-<?php 
            echo $pid;
            ?>
" class="<?php 
            echo $alternate;
            ?>
 iedit"  valign="top">
			<?php 
            foreach ($image_columns as $image_column_key => $column_display_name) {
                $class = "class='{$image_column_key} column-{$image_column_key}'";
                $style = '';
                if (in_array($image_column_key, $hidden_columns)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                switch ($image_column_key) {
                    case 'cb':
                        $attributes = 'class="column-cb check-column"' . $style;
                        ?>
						<th <?php 
                        echo $attributes;
                        ?>
 scope="row"><input name="doaction[]" type="checkbox" value="<?php 
                        echo $pid;
                        ?>
" /></th>
						<?php 
                        break;
                    case 'id':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
 style=""><?php 
                        echo $pid;
                        ?>
							<input type="hidden" name="pid[]" value="<?php 
                        echo $pid;
                        ?>
" />
						</td>
						<?php 
                        break;
                    case 'filename':
                        $attributes = 'class="title column-filename column-title"' . $style;
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<strong><a href="<?php 
                        echo nextgen_esc_url($picture->imageURL);
                        ?>
" class="thickbox" title="<?php 
                        echo esc_attr($picture->filename);
                        ?>
">
								<?php 
                        echo empty($picture->alttext) ? esc_html($picture->filename) : esc_html(stripslashes(nggGallery::i18n($picture->alttext)));
                        ?>
							</a></strong>
							<br /><?php 
                        echo $date;
                        ?>
							<?php 
                        if (!empty($picture->meta_data)) {
                            ?>
							<br /><?php 
                            echo $picture->meta_data['width'];
                            ?>
 x <?php 
                            echo $picture->meta_data['height'];
                            ?>
 <?php 
                            _e('pixel', 'nggallery');
                            ?>

							<?php 
                        }
                        ?>
							<p>
							<?php 
                        $actions = array();
                        $actions['view'] = '<a class="shutter" href="' . nextgen_esc_url($picture->imageURL) . '" title="' . esc_attr(sprintf(__('View "%s"'), sanitize_title($picture->filename))) . '">' . __('View', 'nggallery') . '</a>';
                        $actions['meta'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data', 'nggallery') . '">' . __('Meta', 'nggallery') . '</a>';
                        $actions['custom_thumb'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail', 'nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>';
                        $actions['rotate'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate', 'nggallery') . '">' . __('Rotate', 'nggallery') . '</a>';
                        if (current_user_can('publish_posts')) {
                            $actions['publish'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/publish.php?id=' . $pid . '&h=230" title="' . __('Publish this image', 'nggallery') . '">' . __('Publish', 'nggallery') . '</a>';
                        }
                        if (file_exists($picture->imagePath . '_backup')) {
                            $actions['recover'] = '<a class="confirmrecover" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=recoverpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_recoverpicture') . '" title="' . __('Recover', 'nggallery') . '" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Recover "%s" ?', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Recover', 'nggallery') . '</a>';
                        }
                        $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=delpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_delpicture') . '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s" ?', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Delete') . '</a>';
                        $action_count = count($actions);
                        $i = 0;
                        echo '<div class="row-actions">';
                        foreach ($actions as $action => $link) {
                            ++$i;
                            $i == $action_count ? $sep = '' : ($sep = ' | ');
                            echo "<span class='{$action}'>{$link}{$sep}</span>";
                        }
                        echo '</div>';
                        ?>
</p>
						</td>
						<?php 
                        break;
                    case 'thumbnail':
                        $attributes = 'class="id column-thumbnail media-icon"' . $style;
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><a href="<?php 
                        echo nextgen_esc_url(add_query_arg('i', mt_rand(), $picture->imageURL));
                        ?>
" class="shutter" title="<?php 
                        echo $picture->filename;
                        ?>
">
								<img class="thumb" src="<?php 
                        echo nextgen_esc_url(add_query_arg('i', mt_rand(), $picture->thumbURL));
                        ?>
" id="thumb<?php 
                        echo $pid;
                        ?>
" />
							</a>
						</td>
						<?php 
                        break;
                    case 'alt_title_desc':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<input name="alttext[<?php 
                        echo $pid;
                        ?>
]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php 
                        echo esc_attr(stripslashes($picture->alttext));
                        ?>
" /><br/>
							<textarea name="description[<?php 
                        echo $pid;
                        ?>
]" style="width:95%; margin-top: 2px;" rows="2" ><?php 
                        echo esc_attr(stripslashes($picture->description));
                        ?>
</textarea>
						</td>
						<?php 
                        break;
                    case 'exclude':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><input name="exclude[<?php 
                        echo $pid;
                        ?>
]" type="checkbox" value="1" <?php 
                        echo $exclude;
                        ?>
 /></td>
						<?php 
                        break;
                    case 'tags':
                        $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names');
                        if (is_array($picture->tags)) {
                            $picture->tags = implode(', ', $picture->tags);
                        }
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><textarea name="tags[<?php 
                        echo $pid;
                        ?>
]" style="width:95%;" rows="2"><?php 
                        echo $picture->tags;
                        ?>
</textarea></td>
						<?php 
                        break;
                    default:
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('ngg_manage_image_custom_column', $image_column_key, $pid);
                        ?>
</td>
						<?php 
                        break;
                }
                ?>
			<?php 
            }
            ?>
		</tr>
		<?php 
        }
    }
    // In the case you have no capaptibility to see the search result
    if ($counter == 0) {
        echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>

		</tbody>
	</table>
    <div class="tablenav bottom">
    <input type="submit" class="button-primary action" name="updatepictures" value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
    <?php 
    $ngg->manage_page->pagination('bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page']);
    ?>
    </div>
	</form>
	<br class="clear"/>
	</div><!-- /#wrap -->

	<!-- #entertags -->
	<div id="entertags" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th><?php 
    _e("Enter the tags", 'nggallery');
    ?>
 : <input name="taglist" type="text" style="width:90%" value="" /></th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="TB_EditTags" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e("Cancel", 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#entertags -->

	<!-- #selectgallery -->
	<div id="selectgallery" style="display: none;" >
		<form id="form-select-gallery" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th>
		    		<?php 
    _e('Select the destination gallery:', 'nggallery');
    ?>
&nbsp;
		    		<select name="dest_gid" style="width:90%" >
		    			<?php 
    foreach ($gallerylist as $gallery) {
        if ($gallery->gid != $act_gid) {
            ?>
						<option value="<?php 
            echo $gallery->gid;
            ?>
" ><?php 
            echo $gallery->gid;
            ?>
 - <?php 
            echo esc_attr(stripslashes($gallery->title));
            ?>
</option>
						<?php 
        }
    }
    ?>
		    		</select>
		    	</th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="<?php 
    _e("Cancel", 'nggallery');
    ?>
" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#selectgallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong>
				</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'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
    <table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td>
				<?php 
    include dirname(__FILE__) . '/thumbnails-template.php';
    ?>
				</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']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->

	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){columns.init('nggallery-manage-images');});
	/* ]]> */
	</script>
	<?php 
}
Exemple #5
0
 /**
  * Method "ngg.getImages"
  * Return the list of all images inside a gallery
  * 
  * @since 1.4
  * 
  * @param array $args Method parameters.
  * 			- int blog_id
  *	    	- string username
  *	    	- string password
  *	    	- int gallery_id 
  * @return array with all images
  */
 function getImages($args)
 {
     global $nggdb;
     require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
     // admin functions
     $this->escape($args);
     $blog_ID = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $gid = (int) $args[3];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     // Look for the gallery , could we find it ?
     if (!($gallery = nggdb::find_gallery($gid))) {
         return new IXR_Error(404, __('Could not find gallery ' . $gid));
     }
     // Now check if you have the correct capability for this gallery
     if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
         logIO('O', '(NGG) User does not have upload_files capability');
         $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
         return $this->error;
     }
     // get picture values
     $picture_list = $nggdb->get_gallery($gid, 'pid', 'ASC', false);
     return $picture_list;
 }
function nggallery_manage_gallery_main()
{
    global $ngg, $nggdb, $wp_query;
    //Build the pagination for more than 25 galleries
    $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
    $items_per_page = apply_filters('ngg_manage_galleries_items_per_page', 25);
    $start = ($_GET['paged'] - 1) * $items_per_page;
    if (!empty($_GET['order']) && in_array($_GET['order'], array('DESC', 'ASC'))) {
        $order = $_GET['order'];
    } else {
        $order = apply_filters('ngg_manage_galleries_items_order', 'ASC');
    }
    if (!empty($_GET['orderby']) && in_array($_GET['orderby'], array('gid', 'title', 'author'))) {
        $orderby = $_GET['orderby'];
    } else {
        $orderby = apply_filters('ngg_manage_galleries_items_orderby', 'gid');
    }
    $mapper = C_Gallery_Mapper::get_instance();
    $total_number_of_galleries = $mapper->count();
    $gallerylist = $mapper->select()->order_by($orderby, $order)->limit($items_per_page, $start)->run_query();
    // Need for upgrading from 2.0.40 to 2.0.52 or later.
    // For some reason, the installer doesn't always run.
    // TODO: Remove in 2.1
    if (!$gallerylist) {
        global $wpdb;
        if ($wpdb->get_results("SELECT gid FROM {$wpdb->nggallery} LIMIT 1")) {
            $installer = new C_NggLegacy_Installer();
            $installer->install();
            $gallerylist = $mapper->select()->order_by($orderby, $order)->limit($items_per_page, $start)->run_query();
        }
    }
    $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
    ?>
	<script type="text/javascript">
	<!--

	// Listen for frame events
	jQuery(function($){
		if ($(this).data('ready')) return;

		if (window.Frame_Event_Publisher) {

			// If a new gallery is added, refresh the page
			Frame_Event_Publisher.listen_for('attach_to_post:new_gallery attach_to_post:manage_images attach_to_post:images_added',function(){
				window.location.href = window.location.href;
			});
		}

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


	function checkAll(form)
	{
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]") {
					if(form.elements[i].checked == true)
						form.elements[i].checked = false;
					else
						form.elements[i].checked = true;
				}
			}
		}
	}

	function getNumChecked(form)
	{
		var num = 0;
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]")
					if(form.elements[i].checked == true)
						num++;
			}
		}
		return num;
	}

	// this function check for a the number of selected images, sumbmit false when no one selected
	function checkSelected() {

        if (typeof document.activeElement == "undefined" && document.addEventListener) {
        	document.addEventListener("focus", function (e) {
        		document.activeElement = e.target;
        	}, true);
        }

        if ( document.activeElement.name == 'post_paged' )
            return true;

		var numchecked = getNumChecked(document.getElementById('editgalleries'));

		if(numchecked < 1) {
			alert('<?php 
    echo esc_js(__('No images selected', 'nggallery'));
    ?>
');
			return false;
		}

		actionId = jQuery('#bulkaction').val();

		switch (actionId) {
			case "resize_images":
                showDialog('resize_images', '<?php 
    echo esc_js(__('Resize images', 'nggallery'));
    ?>
');
				return false;
				break;
			case "new_thumbnail":
				showDialog('new_thumbnail', '<?php 
    echo esc_js(__('Create new thumbnails', 'nggallery'));
    ?>
');
				return false;
				break;
		}

		return confirm('<?php 
    echo sprintf(esc_js(__("You are about to start the bulk edit for %s galleries \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
	}

	function showDialog( windowId, title ) {
		var form = document.getElementById('editgalleries');
		var elementlist = "";
		for (i = 0, n = form.elements.length; i < n; i++) {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].name == "doaction[]")
					if(form.elements[i].checked == true)
						if (elementlist == "")
							elementlist = form.elements[i].value;
						else
							elementlist += "," + form.elements[i].value ;
			}
		}
		jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
		jQuery("#" + windowId + "_imagelist").val(elementlist);
        // now show the dialog
    	jQuery( "#" + windowId ).dialog({
    		width: 640,
            resizable : false,
    		modal: true,
            title: title,
			position: {
				my:		'center',
				at:		'center',
				of:		window.parent
			}
    	});
        jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
	}

	function showAddGallery() {
    	jQuery( "#addGallery").dialog({
    		width: 640,
            resizable : false,
    		modal: true,
            title: '<?php 
    echo esc_js(__('Add new gallery', 'nggallery'));
    ?>
',
			position: {
				my:		'center',
				at:		'center',
				of:		window.parent
			}
    	});
        jQuery("#addGallery .dialog-cancel").click(function() { jQuery( "#addGallery" ).dialog("close"); });
	}
	//-->
	</script>
	<div class="wrap">
		<?php 
    screen_icon('nextgen-gallery');
    ?>
		<h2><?php 
    echo _n('Manage Galleries', 'Manage Galleries', 2, 'nggallery');
    ?>
</h2>
		<form class="search-form" action="" method="get">
		<p class="search-box">
			<label class="hidden" for="media-search-input"><?php 
    _e('Search Images', 'nggallery');
    ?>
:</label>
			<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
			<input type="text" id="media-search-input" name="s" value="<?php 
    the_search_query();
    ?>
" />
			<input type="submit" value="<?php 
    _e('Search Images', 'nggallery');
    ?>
" class="button" />
		</p>
		</form>
		<form id="editgalleries" class="nggform" method="POST" action="<?php 
    echo $ngg->manage_page->base_page . '&amp;paged=' . esc_attr($_GET['paged']);
    ?>
" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_bulkgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />

		<div class="tablenav top">

			<div class="alignleft actions">
				<?php 
    if (function_exists('json_encode')) {
        ?>
				<select name="bulkaction" id="bulkaction">
					<option value="no_action" ><?php 
        _e("Bulk actions", 'nggallery');
        ?>
</option>
					<option value="delete_gallery" ><?php 
        _e("Delete", 'nggallery');
        ?>
</option>
                    <option value="set_watermark" ><?php 
        _e("Set watermark", 'nggallery');
        ?>
</option>
					<option value="new_thumbnail" ><?php 
        _e("Create new thumbnails", 'nggallery');
        ?>
</option>
					<option value="resize_images" ><?php 
        _e("Resize images", 'nggallery');
        ?>
</option>
					<option value="import_meta" ><?php 
        _e("Import metadata", 'nggallery');
        ?>
</option>
					<option value="recover_images" ><?php 
        _e("Recover from backup", 'nggallery');
        ?>
</option>
				</select>
				<input name="showThickbox" class="button-secondary" type="submit" value="<?php 
        _e('Apply', 'nggallery');
        ?>
" onclick="if ( !checkSelected() ) return false;" />
				<?php 
    }
    ?>
				<?php 
    if (current_user_can('NextGEN Upload images') && nggGallery::current_user_can('NextGEN Add new gallery')) {
        ?>
					<input name="doaction" class="button-secondary action" type="submit" onclick="showAddGallery(); return false;" value="<?php 
        _e('Add new gallery', 'nggallery');
        ?>
"/>
				<?php 
    }
    ?>
			</div>


        <?php 
    $ngg->manage_page->pagination('top', $_GET['paged'], $total_number_of_galleries, $items_per_page);
    ?>

		</div>
		<table class="wp-list-table widefat" cellspacing="0">
			<thead>
			<tr>
<?php 
    $wp_list_table->print_column_headers(true);
    ?>
			</tr>
			</thead>
			<tfoot>
			<tr>
<?php 
    $wp_list_table->print_column_headers(false);
    ?>
			</tr>
			</tfoot>
			<tbody id="the-list">
<?php 
    if ($gallerylist) {
        //get the columns
        $gallery_columns = $wp_list_table->get_columns();
        $hidden_columns = get_hidden_columns('nggallery-manage-gallery');
        $num_columns = count($gallery_columns) - count($hidden_columns);
        $image_mapper = C_Image_Mapper::get_instance();
        foreach ($gallerylist as $gallery) {
            $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"';
            $gid = $gallery->gid;
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            $author_user = get_userdata((int) $gallery->author);
            ?>
		<tr id="gallery-<?php 
            echo $gid;
            ?>
" <?php 
            echo $alternate;
            ?>
 >
		<?php 
            foreach ($gallery_columns as $gallery_column_key => $column_display_name) {
                $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\"";
                $style = '';
                if (in_array($gallery_column_key, $hidden_columns)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($gallery_column_key) {
                    case 'cb':
                        ?>
        			<th scope="row" class="column-cb check-column">
        				<?php 
                        if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                            ?>
        					<input name="doaction[]" type="checkbox" value="<?php 
                            echo $gid;
                            ?>
" />
        				<?php 
                        }
                        ?>
        			</th>
        			<?php 
                        break;
                    case 'id':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gid;
                        ?>
</td>
					<?php 
                        break;
                    case 'title':
                        ?>
        			<td class="title column-title">
        				<?php 
                        if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                            ?>
        					<a href="<?php 
                            echo wp_nonce_url($ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $gid, 'ngg_editgallery');
                            ?>
" class='edit' title="<?php 
                            _e('Edit');
                            ?>
" >
        						<?php 
                            echo esc_html(M_I18N::translate($name));
                            ?>
        					</a>
        				<?php 
                        } else {
                            ?>
        					<?php 
                            echo esc_html(M_I18N::translate($gallery->title));
                            ?>
        				<?php 
                        }
                        ?>
                        <div class="row-actions"></div>
        			</td>
        			<?php 
                        break;
                    case 'description':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo esc_html(M_I18N::translate($gallery->galdesc));
                        ?>
&nbsp;</td>
					<?php 
                        break;
                    case 'author':
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo esc_html($author_user->display_name);
                        ?>
</td>
					<?php 
                        break;
                    case 'page_id':
                        ?>
        			<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gallery->pageid;
                        ?>
</td>
        			<?php 
                        break;
                    case 'quantity':
                        $gallery->counter = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $gallery->{$gallery->id_field}))->run_query(FALSE, FALSE, TRUE));
                        ?>
        			<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        echo $gallery->counter;
                        ?>
</td>
        			<?php 
                        break;
                    default:
                        ?>
					<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid);
                        ?>
</td>
					<?php 
                        break;
                }
            }
            ?>
		</tr>
		<?php 
        }
    } else {
        echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>
			</tbody>
		</table>
        <div class="tablenav bottom">
		<?php 
    $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_galleries, $items_per_page);
    ?>
        </div>
		</form>
	</div>
	<!-- #addGallery -->
	<div id="addGallery" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_addgallery');
    ?>
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<td>
					<strong><?php 
    _e('New Gallery', 'nggallery');
    ?>
:</strong> <input type="text" size="35" name="galleryname" value="" /><br />
					<?php 
    if (!is_multisite()) {
        ?>
					<?php 
        _e('Create a new , empty gallery below the folder', 'nggallery');
        ?>
  <strong><?php 
        echo $ngg->options['gallerypath'];
        ?>
</strong><br />
					<?php 
    }
    ?>
					<i>( <?php 
    _e('Allowed characters for file and folder names are', 'nggallery');
    ?>
: a-z, A-Z, 0-9, -, _ )</i>
				</td>
		  	</tr>
            <?php 
    do_action('ngg_add_new_gallery_form');
    ?>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="addgallery" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#addGallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong>
				</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'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-galleries" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td>
				<?php 
    include dirname(__FILE__) . '/thumbnails-template.php';
    ?>
				</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']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" />
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->

<?php 
}
Exemple #7
0
    function tab_uploadimage()
    {
        global $ngg;
        ?>
    	<!-- upload images -->
    	<h2><?php 
        _e('Upload Images', 'nggallery');
        ?>
</h2>
		<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $this->filepath . '#uploadimage';
        ?>
" accept-charset="utf-8" >
		<?php 
        wp_nonce_field('ngg_addgallery');
        ?>
			<table class="form-table"> 
			<tr valign="top"> 
				<th scope="row"><?php 
        _e('Upload image', 'nggallery');
        ?>
</th>
				<td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></td>
			</tr> 
			<tr valign="top"> 
				<th scope="row"><?php 
        _e('in to', 'nggallery');
        ?>
</th> 
				<td><select name="galleryselect" id="galleryselect">
				<option value="0" ><?php 
        _e('Choose gallery', 'nggallery');
        ?>
</option>
				<?php 
        foreach ($this->gallerylist as $gallery) {
            //special case : we check if a user has this cap, then we override the second cap check
            if (!current_user_can('NextGEN Upload in all galleries')) {
                if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                    continue;
                }
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
        }
        ?>
				</select>
				<br /><?php 
        echo $this->maxsize;
        ?>
				<br /><?php 
        if (is_multisite() && wpmu_enable_function('wpmuQuotaCheck')) {
            display_space_usage();
        }
        ?>
</td> 
			</tr> 
			</table>
			<div class="submit">
				<?php 
        if ($ngg->options['swfUpload']) {
            ?>
				<input type="submit" name="disable_flash" id="disable_flash" title="<?php 
            _e('The batch upload requires Adobe Flash 10, disable it if you have problems', 'nggallery');
            ?>
" value="<?php 
            _e('Disable flash upload', 'nggallery');
            ?>
" />
				<?php 
        } else {
            ?>
				<input type="submit" name="enable_flash" id="enable_flash" title="<?php 
            _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'nggallery');
            ?>
" value="<?php 
            _e('Enable flash based upload', 'nggallery');
            ?>
" />
				<?php 
        }
        ?>
				<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'nggallery');
        ?>
" />
			</div>
		</form>
    <?php 
    }
Exemple #8
0
function nggallery_picturelist()
{
    // *** show picture list
    global $wpdb, $nggdb, $user_ID, $ngg;
    // Look if its a search result
    $is_search = isset($_GET['s']) ? true : false;
    if ($is_search) {
        // fetch the imagelist
        $picturelist = $ngg->manage_page->search_result;
        // we didn't set a gallery or a pagination
        $act_gid = 0;
        $_GET['paged'] = 1;
        $page_links = false;
    } else {
        // GET variables
        $act_gid = $ngg->manage_page->gid;
        // Load the gallery metadata
        $gallery = $nggdb->find_gallery($act_gid);
        if (!$gallery) {
            nggGallery::show_error(__('Gallery not found.', 'nggallery'));
            return;
        }
        // Check if you have the correct capability
        if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
            nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
            return;
        }
        // look for pagination
        if (!isset($_GET['paged']) || $_GET['paged'] < 1) {
            $_GET['paged'] = 1;
        }
        $start = ($_GET['paged'] - 1) * 50;
        // get picture values
        $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start);
        // build pagination
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $nggdb->paged['max_objects_per_page'], 'current' => $_GET['paged']));
        // get the current author
        $act_author_user = get_userdata((int) $gallery->author);
    }
    // list all galleries
    $gallerylist = $nggdb->find_all_galleries();
    //get the columns
    $gallery_columns = ngg_manage_gallery_columns();
    $hidden_columns = get_hidden_columns('nggallery-manage-images');
    $num_columns = count($gallery_columns) - count($hidden_columns);
    ?>
<!--[if IE]>
	<style type="text/css">
		.custom_thumb {
			display : none;
		}
	</style>
<![endif]-->

<script type="text/javascript"> 
<!--

function showDialog( windowId, height ) {
	var form = document.getElementById('updategallery');
	var elementlist = "";
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					if (elementlist == "")
						elementlist = form.elements[i].value
					else
						elementlist += "," + form.elements[i].value ;
		}
	}
	jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
	jQuery("#" + windowId + "_imagelist").val(elementlist);
	// console.log (jQuery("#TB_imagelist").val());
	tb_show("", "#TB_inline?width=640&height=" + height + "&inlineId=" + windowId + "&modal=true", false);
}

function checkAll(form)
{
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]") {
				if(form.elements[i].checked == true)
					form.elements[i].checked = false;
				else
					form.elements[i].checked = true;
			}
		}
	}
}

function getNumChecked(form)
{
	var num = 0;
	for (i = 0, n = form.elements.length; i < n; i++) {
		if(form.elements[i].type == "checkbox") {
			if(form.elements[i].name == "doaction[]")
				if(form.elements[i].checked == true)
					num++;
		}
	}
	return num;
}

// this function check for a the number of selected images, sumbmit false when no one selected
function checkSelected() {

	var numchecked = getNumChecked(document.getElementById('updategallery'));
	 
	if(numchecked < 1) { 
		alert('<?php 
    echo js_escape(__('No images selected', 'nggallery'));
    ?>
');
		return false; 
	} 
	
	actionId = jQuery('#bulkaction').val();
	
	switch (actionId) {
		case "copy_to":
		case "move_to":
			showDialog('selectgallery', 120);
			return false;
			break;
		case "add_tags":
		case "delete_tags":
		case "overwrite_tags":
			showDialog('entertags', 120);
			return false;
			break;
		case "resize_images":
			showDialog('resize_images', 120);
			return false;
			break;
		case "new_thumbnail":
			showDialog('new_thumbnail', 160);
			return false;
			break;			
	}
	
	return confirm('<?php 
    echo sprintf(js_escape(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '");
    ?>
');
}

jQuery(document).ready( function() {
	// close postboxes that should be closed
	jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
	postboxes.add_postbox_toggles('ngg-manage-gallery');

});

//-->
</script>

<div class="wrap">

<?php 
    if ($is_search) {
        ?>
<h2><?php 
        printf(__('Search results for &#8220;%s&#8221;', 'nggallery'), wp_specialchars(get_search_query()));
        ?>
</h2>
<form class="search-form" action="" method="get">
<p class="search-box">
	<label class="hidden" for="media-search-input"><?php 
        _e('Search Images', 'nggallery');
        ?>
:</label>
	<input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
	<input type="text" id="media-search-input" name="s" value="<?php 
        the_search_query();
        ?>
" />
	<input type="submit" value="<?php 
        _e('Search Images', 'nggallery');
        ?>
" class="button" />
</p>
</form>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . $_GET['s'];
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<?php 
    } else {
        ?>
<h2><?php 
        echo _n('Gallery', 'Galleries', 1, 'nggallery');
        ?>
 : <?php 
        echo nggGallery::i18n($gallery->title);
        ?>
</h2>

<br style="clear: both;" />

<form id="updategallery" class="nggform" method="POST" action="<?php 
        echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . $_GET['paged'];
        ?>
" accept-charset="utf-8">
<?php 
        wp_nonce_field('ngg_updategallery');
        ?>
<input type="hidden" name="page" value="manage-images" />

<div id="poststuff">
	<?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
	<div id="gallerydiv" class="postbox <?php 
        echo postbox_classes('gallerydiv', 'ngg-manage-gallery');
        ?>
" >
		<h3><?php 
        _e('Gallery settings', 'nggallery');
        ?>
<small> (<?php 
        _e('Click here for more settings', 'nggallery');
        ?>
)</small></h3>
		<div class="inside">
			<table class="form-table" >
				<tr>
					<th align="left"><?php 
        _e('Title');
        ?>
:</th>
					<th align="left"><input type="text" size="50" name="title" value="<?php 
        echo $gallery->title;
        ?>
"  /></th>
					<th align="right"><?php 
        _e('Page Link to', 'nggallery');
        ?>
:</th>
					<th align="left">
					<select name="pageid" style="width:95%">
						<option value="0" ><?php 
        _e('Not linked', 'nggallery');
        ?>
</option>
						<?php 
        parent_dropdown($gallery->pageid);
        ?>
					</select>
					</th>
				</tr>
				<tr>
					<th align="left"><?php 
        _e('Description');
        ?>
:</th> 
					<th align="left"><textarea name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php 
        echo $gallery->galdesc;
        ?>
</textarea></th>
					<th align="right"><?php 
        _e('Preview image', 'nggallery');
        ?>
:</th>
					<th align="left">
						<select name="previewpic" style="width:95%" >
							<option value="0" ><?php 
        _e('No Picture', 'nggallery');
        ?>
</option>
							<?php 
        if (is_array($picturelist)) {
            foreach ($picturelist as $picture) {
                $selected = $picture->pid == $gallery->previewpic ? 'selected="selected" ' : '';
                echo '<option value="' . $picture->pid . '" ' . $selected . '>' . $picture->pid . ' - ' . $picture->filename . '</option>' . "\n";
            }
        }
        ?>
						</select>
					</th>
				</tr>
				<tr>
					<th align="left"><?php 
        _e('Path', 'nggallery');
        ?>
:</th> 
					<th align="left"><input <?php 
        if (IS_WPMU) {
            echo 'readonly = "readonly"';
        }
        ?>
 type="text" size="50" name="path" value="<?php 
        echo $gallery->path;
        ?>
"  /></th>
					<th align="right"><?php 
        _e('Author', 'nggallery');
        ?>
:</th>
					<th align="left"> 
					<?php 
        $editable_ids = $ngg->manage_page->get_editable_user_ids($user_ID);
        if ($editable_ids && count($editable_ids) > 1) {
            wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author));
        } else {
            echo $act_author_user->display_name;
        }
        ?>
					</th>
				</tr>
				<?php 
        if (current_user_can("publish_pages")) {
            ?>
				<tr>
					<th align="left">&nbsp;</th>
					<th align="left">&nbsp;</th>				
					<th align="right"><?php 
            _e('Create new page', 'nggallery');
            ?>
:</th>
					<th align="left"> 
					<select name="parent_id" style="width:95%">
						<option value="0"><?php 
            _e('Main page (No parent)', 'nggallery');
            ?>
</option>
						<?php 
            parent_dropdown();
            ?>
					</select>
					<input class="button-secondary action" type="submit" name="addnewpage" value="<?php 
            _e('Add page', 'nggallery');
            ?>
" id="group"/>
					</th>
				</tr>
				<?php 
        }
        ?>
			</table>
			
			<div class="submit">
				<input type="submit" class="button-secondary" name="scanfolder" value="<?php 
        _e("Scan Folder for new images", 'nggallery');
        ?>
 " />
				<input type="submit" class="button-primary action" name="updatepictures" value="<?php 
        _e("Save Changes", 'nggallery');
        ?>
" />
			</div>

		</div>
	</div>
</div> <!-- poststuff -->
<?php 
    }
    ?>

<div class="tablenav ngg-tablenav">
	<?php 
    if ($page_links) {
        ?>
	<div class="tablenav-pages"><?php 
        $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links);
        echo $page_links_text;
        ?>
</div>
	<?php 
    }
    ?>
	<div class="alignleft actions">
	<select id="bulkaction" name="bulkaction">
		<option value="no_action" ><?php 
    _e("No action", 'nggallery');
    ?>
</option>
		<option value="set_watermark" ><?php 
    _e("Set watermark", 'nggallery');
    ?>
</option>
		<option value="new_thumbnail" ><?php 
    _e("Create new thumbnails", 'nggallery');
    ?>
</option>
		<option value="resize_images" ><?php 
    _e("Resize images", 'nggallery');
    ?>
</option>
		<option value="delete_images" ><?php 
    _e("Delete images", 'nggallery');
    ?>
</option>
		<option value="import_meta" ><?php 
    _e("Import metadata", 'nggallery');
    ?>
</option>
		<option value="rotate_cw" ><?php 
    _e("Rotate images clockwise", 'nggallery');
    ?>
</option>
		<option value="rotate_ccw" ><?php 
    _e("Rotate images counter-clockwise", 'nggallery');
    ?>
</option>
		<option value="copy_to" ><?php 
    _e("Copy to...", 'nggallery');
    ?>
</option>
		<option value="move_to"><?php 
    _e("Move to...", 'nggallery');
    ?>
</option>
		<option value="add_tags" ><?php 
    _e("Add tags", 'nggallery');
    ?>
</option>
		<option value="delete_tags" ><?php 
    _e("Delete tags", 'nggallery');
    ?>
</option>
		<option value="overwrite_tags" ><?php 
    _e("Overwrite tags", 'nggallery');
    ?>
</option>
	</select>
	<input class="button-secondary" type="submit" name="showThickbox" value="<?php 
    _e('Apply', 'nggallery');
    ?>
" onclick="if ( !checkSelected() ) return false;" />
	
	<?php 
    if ($ngg->options['galSort'] == "sortorder" && !$is_search) {
        ?>
		<input class="button-secondary" type="submit" name="sortGallery" value="<?php 
        _e('Sort gallery', 'nggallery');
        ?>
" />
	<?php 
    }
    ?>
	
	<input type="submit" name="updatepictures" class="button-primary action"  value="<?php 
    _e('Save Changes', 'nggallery');
    ?>
" />
	</div>
</div>

<table id="ngg-listimages" class="widefat fixed" cellspacing="0" >

	<thead>
	<tr>
<?php 
    print_column_headers('nggallery-manage-images');
    ?>
	</tr>
	</thead>
	<tfoot>
	<tr>
<?php 
    print_column_headers('nggallery-manage-images', false);
    ?>
	</tr>
	</tfoot>
	<tbody>
<?php 
    if ($picturelist) {
        $thumbsize = '';
        $counter = 0;
        if ($ngg->options['thumbfix']) {
            $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
        }
        foreach ($picturelist as $picture) {
            //for search result we need to check the capatibiliy
            if (!nggAdmin::can_manage_this_gallery($picture->author) && $is_search) {
                continue;
            }
            $counter++;
            $pid = (int) $picture->pid;
            $alternate = !isset($alternate) || $alternate == 'alternate' ? '' : 'alternate';
            $exclude = $picture->exclude ? 'checked="checked"' : '';
            $date = mysql2date(get_option('date_format'), $picture->imagedate);
            $time = mysql2date(get_option('time_format'), $picture->imagedate);
            ?>
		<tr id="picture-<?php 
            echo $pid;
            ?>
" class="<?php 
            echo $alternate;
            ?>
 iedit"  valign="top">
			<?php 
            foreach ($gallery_columns as $gallery_column_key => $column_display_name) {
                $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\"";
                $style = '';
                if (in_array($gallery_column_key, $hidden_columns)) {
                    $style = ' style="display:none;"';
                }
                $attributes = "{$class}{$style}";
                switch ($gallery_column_key) {
                    case 'cb':
                        ?>
 
						<th <?php 
                        echo $attributes;
                        ?>
 scope="row"><input name="doaction[]" type="checkbox" value="<?php 
                        echo $pid;
                        ?>
" /></th>
						<?php 
                        break;
                    case 'id':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
 scope="row" style=""><?php 
                        echo $pid;
                        ?>
							<input type="hidden" name="pid[]" value="<?php 
                        echo $pid;
                        ?>
" />
						</td>
						<?php 
                        break;
                    case 'filename':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<strong><a href="<?php 
                        echo $picture->imageURL;
                        ?>
" class="thickbox" title="<?php 
                        echo $picture->filename;
                        ?>
">
								<?php 
                        echo empty($picture->alttext) ? $picture->filename : stripslashes(nggGallery::i18n($picture->alttext));
                        ?>
							</a></strong>
							<br /><?php 
                        echo $date;
                        ?>
							<?php 
                        if (!empty($picture->meta_data)) {
                            ?>
							<br /><?php 
                            echo $picture->meta_data['width'];
                            ?>
 x <?php 
                            echo $picture->meta_data['height'];
                            ?>
 <?php 
                            _e('pixel', 'nggallery');
                            ?>
							<?php 
                        }
                        ?>
							<p>
							<?php 
                        $actions = array();
                        //TODO:Add a JS edit option
                        //$actions['edit']   = '<a class="editinline" href="#">' . __('Edit') . '</a>';
                        $actions['view'] = '<a class="thickbox" href="' . $picture->imageURL . '" title="' . esc_attr(sprintf(__('View "%s"'), $picture->filename)) . '">' . __('View', 'nggallery') . '</a>';
                        $actions['meta'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data', 'nggallery') . '">' . __('Meta', 'nggallery') . '</a>';
                        $actions['custom_thumb'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail', 'nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>';
                        $actions['rotate'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate', 'nggallery') . '">' . __('Rotate', 'nggallery') . '</a>';
                        $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=delpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_delpicture') . '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s"', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Delete') . '</a>';
                        $action_count = count($actions);
                        $i = 0;
                        echo '<div class="row-actions">';
                        foreach ($actions as $action => $link) {
                            ++$i;
                            $i == $action_count ? $sep = '' : ($sep = ' | ');
                            echo "<span class='{$action}'>{$link}{$sep}</span>";
                        }
                        echo '</div>';
                        ?>
</p>
						</td>
						<?php 
                        break;
                    case 'thumbnail':
                        // generate the thumbnail size if the meta data available
                        if (is_array($size = $picture->meta_data['thumbnail'])) {
                            $thumbsize = 'width="' . $size['width'] . '" height="' . $size['height'] . '"';
                        }
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><a href="<?php 
                        echo $picture->imageURL . '?' . mt_rand();
                        ?>
" class="thickbox" title="<?php 
                        echo $picture->filename;
                        ?>
">
								<img class="thumb" src="<?php 
                        echo $picture->thumbURL . '?' . mt_rand();
                        ?>
" <?php 
                        echo $thumbsize;
                        ?>
 id="thumb<?php 
                        echo $pid;
                        ?>
" />
							</a>
						</td>
						<?php 
                        break;
                    case 'alt_title_desc':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
>
							<input name="alttext[<?php 
                        echo $pid;
                        ?>
]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php 
                        echo stripslashes($picture->alttext);
                        ?>
" /><br/>
							<textarea name="description[<?php 
                        echo $pid;
                        ?>
]" style="width:95%; margin-top: 2px;" rows="2" ><?php 
                        echo stripslashes($picture->description);
                        ?>
</textarea>
						</td>
						<?php 
                        break;
                    case 'exclude':
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><input name="exclude[<?php 
                        echo $pid;
                        ?>
]" type="checkbox" value="1" <?php 
                        echo $exclude;
                        ?>
 /></td>
						<?php 
                        break;
                    case 'tags':
                        $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names');
                        if (is_array($picture->tags)) {
                            $picture->tags = implode(', ', $picture->tags);
                        }
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><textarea name="tags[<?php 
                        echo $pid;
                        ?>
]" style="width:95%;" rows="2"><?php 
                        echo $picture->tags;
                        ?>
</textarea></td>
						<?php 
                        break;
                    default:
                        ?>
						<td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $pid);
                        ?>
</td>
						<?php 
                        break;
                }
                ?>
			<?php 
            }
            ?>
		</tr>
		<?php 
        }
    }
    // In the case you have no capaptibility to see the search result
    if ($counter == 0) {
        echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>
	
		</tbody>
	</table>
	<p class="submit"><input type="submit" class="button-primary action" name="updatepictures" value="<?php 
    _e("Save Changes", 'nggallery');
    ?>
" /></p>
	</form>	
	<br class="clear"/>
	</div><!-- /#wrap -->

	<!-- #entertags -->
	<div id="entertags" style="display: none;" >
		<form id="form-tags" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th><?php 
    _e("Enter the tags", 'nggallery');
    ?>
 : <input name="taglist" type="text" style="width:90%" value="" /></th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input class="button-primary" type="submit" name="TB_EditTags" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e("Cancel", 'nggallery');
    ?>
&nbsp;" onclick="tb_remove()"/>
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#entertags -->

	<!-- #selectgallery -->
	<div id="selectgallery" style="display: none;" >
		<form id="form-select-gallery" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
		  	<tr>
		    	<th>
		    		<?php 
    _e('Select the destination gallery:', 'nggallery');
    ?>
&nbsp;
		    		<select name="dest_gid" style="width:90%" >
		    			<?php 
    foreach ($gallerylist as $gallery) {
        if ($gallery->gid != $act_gid) {
            ?>
						<option value="<?php 
            echo $gallery->gid;
            ?>
" ><?php 
            echo $gallery->gid;
            ?>
 - <?php 
            echo stripslashes($gallery->title);
            ?>
</option>
						<?php 
        }
    }
    ?>
		    		</select>
		    	</th>
		  	</tr>
		  	<tr align="right">
		    	<td class="submit">
		    		<input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php 
    _e("OK", 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="<?php 
    _e("Cancel", 'nggallery');
    ?>
" onclick="tb_remove()"/>
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#selectgallery -->

	<!-- #resize_images -->
	<div id="resize_images" style="display: none;" >
		<form id="form-resize-images" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<td>
					<strong><?php 
    _e('Resize Images to', 'nggallery');
    ?>
:</strong> 
				</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'];
    ?>
" />
					<br /><small><?php 
    _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery');
    ?>
</small>
				</td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" onclick="tb_remove()"/>
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#resize_images -->

	<!-- #new_thumbnail -->
	<div id="new_thumbnail" style="display: none;" >
		<form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
		<?php 
    wp_nonce_field('ngg_thickbox_form');
    ?>
		<input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
		<input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
		<input type="hidden" name="page" value="manage-images" />
		<table width="100%" border="0" cellspacing="3" cellpadding="3" >
			<tr valign="top">
				<th align="left"><?php 
    _e('Width x height (in pixel)', 'nggallery');
    ?>
</th>
				<td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php 
    echo $ngg->options['thumbwidth'];
    ?>
" /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php 
    echo $ngg->options['thumbheight'];
    ?>
" />
				<br /><small><?php 
    _e('These values are maximum values ', 'nggallery');
    ?>
</small></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']);
    ?>
 />
				<br /><small><?php 
    _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery');
    ?>
</small></td>
			</tr>
		  	<tr align="right">
		    	<td colspan="2" class="submit">
		    		<input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php 
    _e('OK', 'nggallery');
    ?>
" />
		    		&nbsp;
		    		<input class="button-secondary" type="reset" value="&nbsp;<?php 
    _e('Cancel', 'nggallery');
    ?>
&nbsp;" onclick="tb_remove()"/>
		    	</td>
			</tr>
		</table>
		</form>
	</div>
	<!-- /#new_thumbnail -->	

	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready(function(){columns.init('nggallery-manage-images');});	
	/* ]]> */
	</script>
	<?php 
}
function nggallery_manage_gallery_main()
{
    global $wpdb, $ngg;
    ?>
	<div class="wrap">
		<h2><?php 
    _e('Gallery Overview', 'nggallery');
    ?>
</h2>
		<br style="clear: both;"/>
		<table class="widefat">
			<thead>
			<tr>
				<th scope="col" ><?php 
    _e('ID');
    ?>
</th>
				<th scope="col" ><?php 
    _e('Title', 'nggallery');
    ?>
</th>
				<th scope="col" ><?php 
    _e('Description', 'nggallery');
    ?>
</th>
				<th scope="col" ><?php 
    _e('Author', 'nggallery');
    ?>
</th>
				<th scope="col" ><?php 
    _e('Page ID', 'nggallery');
    ?>
</th>
				<th scope="col" ><?php 
    _e('Quantity', 'nggallery');
    ?>
</th>
				<th scope="col" ><?php 
    _e('Action');
    ?>
</th>
			</tr>
			</thead>
			<tbody>
<?php 
    $gallerylist = nggdb::find_all_galleries('gid', 'asc', TRUE);
    if ($gallerylist) {
        foreach ($gallerylist as $gallery) {
            $class = $class == 'class="alternate"' ? '' : 'class="alternate"';
            $gid = $gallery->gid;
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            $author_user = get_userdata((int) $gallery->author);
            ?>
		<tr id="gallery-<?php 
            echo $gid;
            ?>
" <?php 
            echo $class;
            ?>
 >
			<th scope="row"><?php 
            echo $gid;
            ?>
</th>
			<td>
				<?php 
            if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                ?>
					<a href="<?php 
                echo wp_nonce_url($ngg->manage_page->base_page . "&amp;mode=edit&amp;gid=" . $gid, 'ngg_editgallery');
                ?>
" class='edit' title="<?php 
                _e('Edit');
                ?>
" >
						<?php 
                echo $name;
                ?>
					</a>
				<?php 
            } else {
                ?>
					<?php 
                echo $gallery->title;
                ?>
				<?php 
            }
            ?>
			</td>
			<td><?php 
            echo $gallery->galdesc;
            ?>
&nbsp;</td>
			<td><?php 
            echo $author_user->display_name;
            ?>
</td>
			<td><?php 
            echo $gallery->pageid;
            ?>
</td>
			<td><?php 
            echo $gallery->counter;
            ?>
</td>
			<td>
				<?php 
            if (nggAdmin::can_manage_this_gallery($gallery->author)) {
                ?>
					<a href="<?php 
                echo wp_nonce_url($ngg->manage_page->base_page . "&amp;mode=delete&amp;gid=" . $gid, 'ngg_editgallery');
                ?>
" class="delete" onclick="javascript:check=confirm( '<?php 
                _e("Delete this gallery ?", 'nggallery');
                ?>
');if(check==false) return false;"><?php 
                _e('Delete');
                ?>
</a>
				<?php 
            }
            ?>
			</td>
		</tr>
		<?php 
        }
    } else {
        echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
    }
    ?>
			
			</tbody>
		</table>
	</div>
<?php 
}
Exemple #10
0
    function tab_uploadimage()
    {
        global $ngg;
        // check the cookie for the current setting
        //$checked = get_user_setting('ngg_upload_resize') ? ' checked="true"' : '';
        ?>
    	<!-- upload images -->
    	<h3><?php 
        _e('Upload images', 'nggallery');
        ?>
</h3>
		<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $this->filepath . '#uploadimage';
        ?>
" accept-charset="utf-8" >
		<?php 
        wp_nonce_field('ngg_addgallery');
        ?>
			<table class="form-table">
			<tr valign="top">
				<td scope="row" style="padding: 0;" colspan="2"><?php 
        _e('in to', 'nggallery');
        ?>
<select style="margin-left:10px;" name="galleryselect" id="galleryselect">
				<option value="0" ><?php 
        _e('Choose gallery', 'nggallery');
        ?>
</option>
				<?php 
        foreach ($this->gallerylist as $gallery) {
            //special case : we check if a user has this cap, then we override the second cap check
            if (!current_user_can('NextGEN Upload in all galleries')) {
                if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                    continue;
                }
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr($name) . '</option>' . "\n";
        }
        ?>
				</select>
				<br /><?php 
        echo $this->maxsize;
        ?>
				<br /><?php 
        if (is_multisite() && wpmu_enable_function('wpmuQuotaCheck')) {
            display_space_usage();
        }
        ?>
</td>
			</tr>
			<tr valign="top">
                <?php 
        if ($ngg->options['swfUpload']) {
            ?>
				<td colspan="2" style="padding: 0;">
                <div id="plupload-upload-ui">
				<div id="drag-drop-area" style="border: 4px dashed #bbb;height: 150px; padding:20px;">
				<div class="drag-drop-inside" style="margin:auto; text-align:center; width: 250px;">
					<p class="ngg-dragdrop-info drag-drop-info" style="font-size:20px;" >
					<?php 
            _e('Drop your files in this window', 'nggallery');
            ?>
<br/><span style="font-size:14px;"><?php 
            _e('Or', 'nggallery');
            ?>
</p>
                    <input style="margin:auto; text-align:center;" id="plupload-browse-button" type="button" value="<?php 
            esc_attr_e('Select Files', 'nggallery');
            ?>
" class="button" />
					</div>
					</div>
					</div>
                </td>
                <?php 
        } else {
            ?>
				<td><span id='spanButtonPlaceholder'></span>
				<input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles" multiple/></td>
                <?php 
        }
        ?>
				</tr>
				<tr><td><div id='uploadQueue' style="margin-top: 10px;"><td></div>
            </tr>
			</table>
			<div class="submit">
				<?php 
        if ($ngg->options['swfUpload']) {
            ?>
				<input class="button action" type="submit" name="disable_flash" id="disable_flash" title="<?php 
            _e('Click here to use the browser upload instead', 'nggallery');
            ?>
" value="<?php 
            _e('Use basic uploader', 'nggallery');
            ?>
" />
				<?php 
        } else {
            ?>
				<input class="button action" type="submit" name="enable_flash" id="enable_flash" title="<?php 
            _e('Advanced uploading', 'nggallery');
            ?>
" value="<?php 
            _e('Use advanced uploader', 'nggallery');
            ?>
" />
				<?php 
        }
        ?>
				<input <?php 
        if (!$ngg->options['swfUpload']) {
            ?>
 onclick="checkForm('galleryselect'); checkImgFile()" <?php 
        }
        ?>
 class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
        _e('Upload images', 'nggallery');
        ?>
" />
				<?php 
        if ($ngg->options['imgAutoResize'] == 1) {
            ?>
				<span class="description" style="margin-left: 10px;"><?php 
            printf(__('Your images will be rescaled to max width %1$dpx or max height %2$dpx.', 'nggallery'), (int) $ngg->options['imgWidth'], (int) $ngg->options['imgHeight']);
            ?>
</span>
				<?php 
        }
        ?>
			</div>
		</form>
    <?php 
    }
Exemple #11
0
function nggallery_admin_add_gallery()
{
    global $wpdb, $nggdb, $ngg;
    // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
    $filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
    // check for the max image size
    $maxsize = nggGallery::check_memory_limit();
    // link for the flash file
    $swf_upload_link = NGGALLERY_URLPATH . 'admin/upload.php';
    $swf_upload_link = wp_nonce_url($swf_upload_link, 'ngg_swfupload');
    //flash doesn't seem to like encoded ampersands, so convert them back here
    $swf_upload_link = str_replace('&#038;', '&', $swf_upload_link);
    $defaultpath = $ngg->options['gallerypath'];
    if ($_POST['addgallery']) {
        check_admin_referer('ngg_addgallery');
        $newgallery = esc_attr($_POST['galleryname']);
        if (!empty($newgallery)) {
            nggAdmin::create_gallery($newgallery, $defaultpath);
        }
    }
    if ($_POST['zipupload']) {
        check_admin_referer('ngg_addgallery');
        if ($_FILES['zipfile']['error'] == 0 || !empty($_POST['zipurl'])) {
            nggAdmin::import_zipfile(intval($_POST['zipgalselect']));
        } else {
            nggGallery::show_error(__('Upload failed!', 'nggallery'));
        }
    }
    if ($_POST['importfolder']) {
        check_admin_referer('ngg_addgallery');
        $galleryfolder = $_POST['galleryfolder'];
        if (!empty($galleryfolder) and $defaultpath != $galleryfolder) {
            nggAdmin::import_gallery($galleryfolder);
        }
    }
    if ($_POST['uploadimage']) {
        check_admin_referer('ngg_addgallery');
        if ($_FILES['imagefiles']['error'][0] == 0) {
            $messagetext = nggAdmin::upload_images();
        } else {
            nggGallery::show_error(__('Upload failed!', 'nggallery'));
        }
    }
    if (isset($_POST['swf_callback'])) {
        if ($_POST['galleryselect'] == '0') {
            nggGallery::show_error(__('No gallery selected !', 'nggallery'));
        } else {
            // get the path to the gallery
            $galleryID = (int) $_POST['galleryselect'];
            $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' ");
            nggAdmin::import_gallery($gallerypath);
        }
    }
    if (isset($_POST['disable_flash'])) {
        check_admin_referer('ngg_addgallery');
        $ngg->options['swfUpload'] = false;
        update_option('ngg_options', $ngg->options);
    }
    if (isset($_POST['enable_flash'])) {
        check_admin_referer('ngg_addgallery');
        $ngg->options['swfUpload'] = true;
        update_option('ngg_options', $ngg->options);
    }
    //get all galleries (after we added new ones)
    $gallerylist = $nggdb->find_all_galleries('gid', 'DESC');
    ?>
	
	<?php 
    if ($ngg->options['swfUpload']) {
        ?>
	<!-- SWFUpload script -->
	<script type="text/javascript">
		var ngg_swf_upload;
			
		window.onload = function () {
			ngg_swf_upload = new SWFUpload({
				// Backend settings
				upload_url : "<?php 
        echo $swf_upload_link;
        ?>
",
				flash_url : "<?php 
        echo NGGALLERY_URLPATH;
        ?>
admin/js/swfupload.swf",
				
				// Button Settings
				button_placeholder_id : "spanButtonPlaceholder",
				button_width: 300,
				button_height: 27,
				button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
				button_cursor: SWFUpload.CURSOR.HAND,
								
				// File Upload Settings
				file_size_limit : "<?php 
        echo wp_max_upload_size();
        ?>
b",
				file_types : "*.jpg;*.jpeg;*.gif;*.png",
				file_types_description : "<?php 
        _e('Image Files', 'nggallery');
        ?>
",
				
				// Queue handler
				file_queued_handler : fileQueued,
				
				// Upload handler
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				
				post_params : {
					"auth_cookie" : "<?php 
        echo $_COOKIE[AUTH_COOKIE];
        ?>
",
					"galleryselect" : "0"
				},
				
				// i18names
				custom_settings : {
					"remove" : "<?php 
        _e('remove', 'nggallery');
        ?>
",
					"browse" : "<?php 
        _e('Browse...', 'nggallery');
        ?>
",
					"upload" : "<?php 
        _e('Upload images', 'nggallery');
        ?>
"
				},

				// Debug settings
				debug: false
				
			});
			
			// on load change the upload to swfupload
			initSWFUpload();
			
		};
	</script>
	
	<div class="wrap" id="progressbar-wrap">
		<div class="progressborder">
			<div class="progressbar" id="progressbar">
				<span>0%</span>
			</div>
		</div>
	</div>
	
	<?php 
    } else {
        ?>
	<!-- MultiFile script -->
	<script type="text/javascript">	
	/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#imagefiles').MultiFile({
				STRING: {
			    	remove:'[<?php 
        _e('remove', 'nggallery');
        ?>
]'
  				}
		 	});
		});
	/* ]]> */
	</script>
	<?php 
    }
    ?>
	<!-- jQuery Tabs script -->
	<script type="text/javascript">
	/* <![CDATA[ */
		jQuery(document).ready(function(){
			jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' });	
		});
	/* ]]> */
	</script>
		
	<div id="slider" class="wrap">
	
		<ul id="tabs">
			<li><a href="#addgallery"><?php 
    _e('Add new gallery', 'nggallery');
    ?>
</a></li>
			<?php 
    if (wpmu_enable_function('wpmuZipUpload')) {
        ?>
			<li><a href="#zipupload"><?php 
        _e('Upload a Zip-File', 'nggallery');
        ?>
</a></li>
			<?php 
    }
    if (!IS_WPMU) {
        ?>
			<li><a href="#importfolder"><?php 
        _e('Import image folder', 'nggallery');
        ?>
</a></li>
			<?php 
    }
    ?>
			<li><a href="#uploadimage"><?php 
    _e('Upload Images', 'nggallery');
    ?>
</a></li>
		</ul>

		<!-- create gallery -->
		<div id="addgallery">
		<h2><?php 
    _e('Add new gallery', 'nggallery');
    ?>
</h2>
			<form name="addgallery" id="addgallery_form" method="POST" action="<?php 
    echo $filepath;
    ?>
" accept-charset="utf-8" >
			<?php 
    wp_nonce_field('ngg_addgallery');
    ?>
				<table class="form-table"> 
				<tr valign="top"> 
					<th scope="row"><?php 
    _e('New Gallery', 'nggallery');
    ?>
:</th> 
					<td><input type="text" size="35" name="galleryname" value="" /><br />
					<?php 
    if (!IS_WPMU) {
        ?>
					<?php 
        _e('Create a new , empty gallery below the folder', 'nggallery');
        ?>
  <strong><?php 
        echo $defaultpath;
        ?>
</strong><br />
					<?php 
    }
    ?>
					<i>( <?php 
    _e('Allowed characters for file and folder names are', 'nggallery');
    ?>
: a-z, A-Z, 0-9, -, _ )</i></td>
				</tr>
				<?php 
    do_action('ngg_add_new_gallery_form');
    ?>
				</table>
				<div class="submit"><input class="button-primary" type="submit" name= "addgallery" value="<?php 
    _e('Add gallery', 'nggallery');
    ?>
"/></div>
			</form>
		</div>
		<?php 
    if (wpmu_enable_function('wpmuZipUpload')) {
        ?>
		<!-- zip-file operation -->
		<div id="zipupload">
		<h2><?php 
        _e('Upload a Zip-File', 'nggallery');
        ?>
</h2>
			<form name="zipupload" id="zipupload_form" method="POST" enctype="multipart/form-data" action="<?php 
        echo $filepath . '#zipupload';
        ?>
" accept-charset="utf-8" >
			<?php 
        wp_nonce_field('ngg_addgallery');
        ?>
				<table class="form-table"> 
				<tr valign="top"> 
					<th scope="row"><?php 
        _e('Select Zip-File', 'nggallery');
        ?>
:</th> 
					<td><input type="file" name="zipfile" id="zipfile" size="35" class="uploadform"/><br />
					<?php 
        _e('Upload a zip file with images', 'nggallery');
        ?>
</td> 
				</tr>
				<?php 
        if (function_exists('curl_init')) {
            ?>
				<tr valign="top"> 
					<th scope="row"><?php 
            _e('or enter a Zip-File URL', 'nggallery');
            ?>
:</th> 
					<td><input type="text" name="zipurl" id="zipurl" size="35" class="uploadform"/><br />
					<?php 
            _e('Import a zip file with images from a url', 'nggallery');
            ?>
</td> 
				</tr>
				<?php 
        }
        ?>
				<tr valign="top"> 
					<th scope="row"><?php 
        _e('in to', 'nggallery');
        ?>
</th> 
					<td><select name="zipgalselect">
					<option value="0" ><?php 
        _e('a new gallery', 'nggallery');
        ?>
</option>
					<?php 
        foreach ($gallerylist as $gallery) {
            if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
                continue;
            }
            $name = empty($gallery->title) ? $gallery->name : $gallery->title;
            echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
        }
        ?>
					</select>
					<br /><?php 
        echo $maxsize;
        ?>
					<br /><?php 
        echo _e('Note : The upload limit on your server is ', 'nggallery') . "<strong>" . ini_get('upload_max_filesize') . "Byte</strong>\n";
        ?>
					<br /><?php 
        if (IS_WPMU && wpmu_enable_function('wpmuQuotaCheck')) {
            display_space_usage();
        }
        ?>
</td> 
				</tr> 
				</table>
				<div class="submit"><input class="button-primary" type="submit" name= "zipupload" value="<?php 
        _e('Start upload', 'nggallery');
        ?>
"/></div>
			</form>
		</div>
		<?php 
    }
    if (!IS_WPMU) {
        ?>
		<!-- import folder -->
		<div id="importfolder">
		<h2><?php 
        _e('Import image folder', 'nggallery');
        ?>
</h2>
			<form name="importfolder" id="importfolder_form" method="POST" action="<?php 
        echo $filepath . '#importfolder';
        ?>
" accept-charset="utf-8" >
			<?php 
        wp_nonce_field('ngg_addgallery');
        ?>
				<table class="form-table"> 
				<tr valign="top"> 
					<th scope="row"><?php 
        _e('Import from Server path:', 'nggallery');
        ?>
</th> 
					<td><input type="text" size="35" name="galleryfolder" value="<?php 
        echo $defaultpath;
        ?>
" /><br />
					<br /><?php 
        echo $maxsize;
        ?>
					<?php 
        if (SAFE_MODE) {
            ?>
<br /><?php 
            _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'nggallery');
        }
        ?>
</td> 
				</tr>
				</table>
				<div class="submit"><input class="button-primary" type="submit" name= "importfolder" value="<?php 
        _e('Import folder', 'nggallery');
        ?>
"/></div>
			</form>
		</div>
		<?php 
    }
    ?>
 
		<!-- upload images -->
		<div id="uploadimage">
		<h2><?php 
    _e('Upload Images', 'nggallery');
    ?>
</h2>
			<form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php 
    echo $filepath . '#uploadimage';
    ?>
" accept-charset="utf-8" >
			<?php 
    wp_nonce_field('ngg_addgallery');
    ?>
				<table class="form-table"> 
				<tr valign="top"> 
					<th scope="row"><?php 
    _e('Upload image', 'nggallery');
    ?>
</th>
					<td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></td>
				</tr> 
				<tr valign="top"> 
					<th scope="row"><?php 
    _e('in to', 'nggallery');
    ?>
</th> 
					<td><select name="galleryselect" id="galleryselect">
					<option value="0" ><?php 
    _e('Choose gallery', 'nggallery');
    ?>
</option>
					<?php 
    foreach ($gallerylist as $gallery) {
        if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
            continue;
        }
        $name = empty($gallery->title) ? $gallery->name : $gallery->title;
        echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . $name . '</option>' . "\n";
    }
    ?>
					</select>
					<br /><?php 
    echo $maxsize;
    ?>
					<br /><?php 
    if (IS_WPMU && wpmu_enable_function('wpmuQuotaCheck')) {
        display_space_usage();
    }
    ?>
</td> 
				</tr> 
				</table>
				<div class="submit">
					<?php 
    if ($ngg->options['swfUpload']) {
        ?>
					<input type="submit" name="disable_flash" id="disable_flash" title="<?php 
        _e('The batch upload requires Adobe Flash 10, disable it if you have problems', 'nggallery');
        ?>
" value="<?php 
        _e('Disable flash upload', 'nggallery');
        ?>
" />
					<?php 
    } else {
        ?>
					<input type="submit" name="enable_flash" id="enable_flash" title="<?php 
        _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'nggallery');
        ?>
" value="<?php 
        _e('Enable flash based upload', 'nggallery');
        ?>
" />
					<?php 
    }
    ?>
					<input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php 
    _e('Upload images', 'nggallery');
    ?>
" />
				</div>
			</form>
		</div>
	</div>
	<?php 
}