Exemplo n.º 1
0
 /**
  * get the thumbnail url to the image
  */
 static function get_thumbnail_url($imageID, $picturepath = '', $fileName = '')
 {
     // get the complete url to the thumbnail
     global $wpdb;
     // safety first
     $imageID = (int) $imageID;
     // get gallery values
     if (empty($fileName)) {
         list($fileName, $picturepath) = $wpdb->get_row("SELECT p.filename, g.path FROM {$wpdb->nggpictures} AS p INNER JOIN {$wpdb->nggallery} AS g ON (p.galleryid = g.gid) WHERE p.pid = '{$imageID}' ", ARRAY_N);
     }
     if (empty($picturepath)) {
         $picturepath = $wpdb->get_var("SELECT g.path FROM {$wpdb->nggpictures} AS p INNER JOIN {$wpdb->nggallery} AS g ON (p.galleryid = g.gid) WHERE p.pid = '{$imageID}' ");
     }
     // set gallery url
     $folder_url = site_url() . '/' . $picturepath . nggGallery::get_thumbnail_folder($picturepath, FALSE);
     $thumbnailURL = $folder_url . 'thumbs_' . $fileName;
     return $thumbnailURL;
 }
Exemplo n.º 2
0
 /**
  * nggAdmin::import_gallery()
  * TODO: Check permission of existing thumb folder & images
  * 
  * @class nggAdmin
  * @param string $galleryfolder contains relative path to the gallery itself
  * @return void
  */
 function import_gallery($galleryfolder)
 {
     global $wpdb, $user_ID;
     // get the current user ID
     get_currentuserinfo();
     $created_msg = '';
     // remove trailing slash at the end, if somebody use it
     if (substr($galleryfolder, -1) == '/') {
         $galleryfolder = substr($galleryfolder, 0, -1);
     }
     $gallerypath = WINABSPATH . $galleryfolder;
     if (!is_dir($gallerypath)) {
         nggGallery::show_error(__('Directory', 'nggallery') . ' <strong>' . $gallerypath . '</strong> ' . __('doesn&#96;t exist!', 'nggallery'));
         return;
     }
     // read list of images
     $new_imageslist = nggAdmin::scandir($gallerypath);
     if (empty($new_imageslist)) {
         nggGallery::show_message(__('Directory', 'nggallery') . ' <strong>' . $gallerypath . '</strong> ' . __('contains no pictures', 'nggallery'));
         return;
     }
     // check & create thumbnail folder
     if (!nggGallery::get_thumbnail_folder($gallerypath)) {
         return;
     }
     // take folder name as gallery name
     $galleryname = basename($galleryfolder);
     $galleryname = apply_filters('ngg_gallery_name', $galleryname);
     // check for existing gallery folder
     $gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' ");
     if (!$gallery_id) {
         $result = $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->nggallery} (name, path, title, author) VALUES (%s, %s, %s, %s)", $galleryname, $galleryfolder, $galleryname, $user_ID));
         if (!$result) {
             nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery'));
             return;
         }
         $created_msg = _n('Gallery', 'Galleries', 1, 'nggallery') . ' <strong>' . $galleryname . '</strong> ' . __('successfully created!', 'nggallery') . '<br />';
         $gallery_id = $wpdb->insert_id;
         // get index_id
     }
     // Look for existing image list
     $old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' ");
     // if no images are there, create empty array
     if ($old_imageslist == NULL) {
         $old_imageslist = array();
     }
     // check difference
     $new_images = array_diff($new_imageslist, $old_imageslist);
     // all images must be valid files
     foreach ($new_images as $key => $picture) {
         if (!@getimagesize($gallerypath . '/' . $picture)) {
             unset($new_images[$key]);
             @unlink($gallerypath . '/' . $picture);
         }
     }
     // add images to database
     $image_ids = nggAdmin::add_Images($gallery_id, $new_images);
     //add the preview image if needed
     nggAdmin::set_gallery_preview($gallery_id);
     // now create thumbnails
     nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
     //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
     nggGallery::show_message($created_msg . count($image_ids) . __(' picture(s) successfully added', 'nggallery'));
     return;
 }
Exemplo n.º 3
0
 /**
  * nggAdmin::import_gallery()
  * TODO: Check permission of existing thumb folder & images
  *
  * @class nggAdmin
  * @param string $galleryfolder contains relative path to the gallery itself
  * @return void
  */
 function import_gallery($galleryfolder)
 {
     global $wpdb, $user_ID;
     // get the current user ID
     get_currentuserinfo();
     $created_msg = '';
     // remove trailing slash at the end, if somebody use it
     $galleryfolder = untrailingslashit($galleryfolder);
     $gallerypath = WINABSPATH . $galleryfolder;
     if (!is_dir($gallerypath)) {
         nggGallery::show_error(__('Directory', 'nggallery') . ' <strong>' . esc_html($gallerypath) . '</strong> ' . __('doesn&#96;t exist!', 'nggallery'));
         return;
     }
     // read list of images
     $new_imageslist = nggAdmin::scandir($gallerypath);
     if (empty($new_imageslist)) {
         nggGallery::show_message(__('Directory', 'nggallery') . ' <strong>' . esc_html($gallerypath) . '</strong> ' . __('contains no pictures', 'nggallery'));
         return;
     }
     // check & create thumbnail folder
     if (!nggGallery::get_thumbnail_folder($gallerypath)) {
         return;
     }
     // take folder name as gallery name
     $galleryname = basename($galleryfolder);
     $galleryname = apply_filters('ngg_gallery_name', $galleryname);
     // check for existing gallery folder
     $gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' ");
     if (!$gallery_id) {
         // now add the gallery to the database
         $gallery_id = nggdb::add_gallery($galleryname, $galleryfolder, '', 0, 0, $user_ID);
         if (!$gallery_id) {
             nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery'));
             return;
         } else {
             do_action('ngg_created_new_gallery', $gallery_id);
         }
         $created_msg = _n('Gallery', 'Galleries', 1, 'nggallery') . ' <strong>' . esc_html($galleryname) . '</strong> ' . __('successfully created!', 'nggallery') . '<br />';
     }
     // Look for existing image list
     $old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' ");
     // if no images are there, create empty array
     if ($old_imageslist == NULL) {
         $old_imageslist = array();
     }
     // check difference
     $new_images = array_diff($new_imageslist, $old_imageslist);
     // all images must be valid files
     foreach ($new_images as $key => $picture) {
         // filter function to rename/change/modify image before
         $picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id);
         $new_images[$key] = $picture;
         if (!@getimagesize($gallerypath . '/' . $picture)) {
             unset($new_images[$key]);
             @unlink($gallerypath . '/' . $picture);
         }
     }
     // add images to database
     $image_ids = nggAdmin::add_Images($gallery_id, $new_images);
     do_action('ngg_after_new_images_added', $gallery_id, $image_ids);
     //add the preview image if needed
     nggAdmin::set_gallery_preview($gallery_id);
     // now create thumbnails
     nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery'));
     //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
     $message = $created_msg . count($image_ids) . __(' picture(s) successfully added', 'nggallery');
     $message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >';
     $message .= __('Edit gallery', 'nggallery');
     $message .= '</a>]';
     nggGallery::show_message($message);
     return;
 }
Exemplo n.º 4
0
function getgallerycontainer($galleryid = 0, $used = false)
{
    global $wpdb;
    $gallery = $wpdb->get_row("SELECT * FROM {$wpdb->nggallery} WHERE gid = '{$galleryid}'");
    if ($gallery) {
        // set image url
        $act_thumbnail_url = get_option('siteurl') . '/' . $gallery->path . nggGallery::get_thumbnail_folder($gallery->path, FALSE);
        $post = get_post($gallery->pageid);
        $pagename = $post->post_title;
        $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$gallery->previewpic}'");
        $img = $filename ? '<img src="' . $act_thumbnail_url . 'thumbs_' . $filename . '" />' : '';
        // add class if it's in use in other albums
        $used = $used ? ' inUse' : '';
        echo '<div id="gid-' . $gallery->gid . '" class="groupItem' . $used . '">
				<div class="innerhandle">
					<div class="item_top">
						<a href="#" class="min" title="close">[-]</a>
						ID: ' . $gallery->gid . ' || Title: ' . $gallery->title . '
					</div>
					<div class="itemContent">
						<div class="inlinepicture">' . $img . '</div>
							<p><strong>' . __('ID', 'nggallery') . ' : </strong>' . $gallery->gid . '</p>
							<p><strong>' . __('Name', 'nggallery') . ' : </strong>' . $gallery->name . '</p>
							<p><strong>' . __('Title', 'nggallery') . ' : </strong>' . $gallery->title . '</p>
							<p><strong>' . __('Page', 'nggallery') . ' : </strong>' . $pagename . '</p>
						</div>
				</div>
			   </div>';
    }
}
Exemplo n.º 5
0
/**
 * @author Alex Rabe
 * @copyright 2008
 */
function nggallery_sortorder($galleryID = 0)
{
    global $wpdb, $ngg;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('ngg_updatesortorder');
        // get variable new sortorder
        parse_str($_POST['sortorder']);
        if (is_array($sortArray)) {
            $neworder = array();
            foreach ($sortArray as $pid) {
                $pid = substr($pid, 4);
                // get id from "pid-x"
                $neworder[] = (int) $pid;
            }
            $sortindex = 1;
            foreach ($neworder as $pic_id) {
                $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
                $sortindex++;
            }
            nggGallery::show_message(__('Sort order changed', 'nggallery'));
        }
    }
    //TODO:A unique gallery call must provide me with this information, like $gallery  = new nggGallery($id);
    // get gallery values
    $act_gallery = $wpdb->get_row("SELECT * FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' ");
    // set gallery url
    $act_gallery_url = get_option('siteurl') . "/" . $act_gallery->path . "/";
    $act_thumbnail_url = get_option('siteurl') . "/" . $act_gallery->path . nggGallery::get_thumbnail_folder($act_gallery->path, FALSE);
    // look for presort args
    $presort = $_GET['presort'];
    $dir = $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
    $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
    // ensure that nobody added some evil sorting :-)
    if (in_array($presort, $sortitems)) {
        $picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' ORDER BY {$presort} {$dir}");
    } else {
        $picturelist = $wpdb->get_results("SELECT * FROM {$wpdb->nggpictures} WHERE galleryid = '{$galleryID}' ORDER BY sortorder {$dir}");
    }
    //this is the url without any presort variable
    $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
    // In the case somebody presort, then we take this url
    if (isset($_GET['dir']) || isset($_GET['presort'])) {
        $base_url = $_SERVER['REQUEST_URI'];
    } else {
        $base_url = $clean_url;
    }
    ?>
	<script type='text/javascript' src='<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/js/sorter.js'></script>
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php 
    echo $clean_url;
    ?>
" onsubmit="saveImageOrder()" accept-charset="utf-8">
			<h2><?php 
    _e('Sort Gallery', 'nggallery');
    ?>
</h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php 
    wp_nonce_field('ngg_updatesortorder');
    ?>
					<input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php 
    _e('Update Sort Order', 'nggallery');
    ?>
" />
				</div>
				<div class="alignright actions">
					<input class="button-secondary action" type="submit" name="backToGallery" value="<?php 
    _e('Back to gallery', 'nggallery');
    ?>
" />
				</div>
			</div>	
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php 
    _e('Presort', 'nggallery');
    ?>
 :</li>
				<li><a href="<?php 
    echo attribute_escape(remove_query_arg('presort', $base_url));
    ?>
" <?php 
    if ($presort == '') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Unsorted', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'pid', $base_url));
    ?>
" <?php 
    if ($presort == 'pid') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Image ID', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'filename', $base_url));
    ?>
" <?php 
    if ($presort == 'filename') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Filename', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'alttext', $base_url));
    ?>
" <?php 
    if ($presort == 'alttext') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Alt/Title text', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('presort', 'imagedate', $base_url));
    ?>
" <?php 
    if ($presort == 'imagedate') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Date/Time', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('dir', 'ASC', $base_url));
    ?>
" <?php 
    if ($dir == 'ASC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Ascending', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo attribute_escape(add_query_arg('dir', 'DESC', $base_url));
    ?>
" <?php 
    if ($dir == 'DESC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Descending', 'nggallery');
    ?>
</a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<?php 
    if ($picturelist) {
        foreach ($picturelist as $picture) {
            ?>
				<div class="imageBox" id="pid-<?php 
            echo $picture->pid;
            ?>
">
					<div class="imageBox_theImage" style="background-image:url('<?php 
            echo $act_thumbnail_url . "thumbs_" . $picture->filename;
            ?>
')"></div>	
					<div class="imageBox_label"><span><?php 
            echo stripslashes($picture->alttext);
            ?>
</span></div>
				</div>
				<?php 
        }
    }
    ?>
		<div id="insertionMarker">
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_top.gif"/>
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_middle.gif" id="insertionMarkerLine"/>
			<img src="<?php 
    echo NGGALLERY_URLPATH;
    ?>
admin/images/marker_bottom.gif"/>
		</div>
		<div id="dragDropContent"></div>
	</div>
	
<?php 
}
Exemplo n.º 6
0
 function processor()
 {
     global $wpdb, $ngg;
     if ($this->mode == 'delete') {
         // Delete a gallery
         check_admin_referer('ngg_editgallery');
         // get the path to the gallery
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         if ($gallerypath) {
             // delete pictures
             //TODO:Remove also Tag reference
             $imagelist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$this->gid}' ");
             if ($ngg->options['deleteImg']) {
                 if (is_array($imagelist)) {
                     foreach ($imagelist as $filename) {
                         @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                         @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                     }
                 }
                 // delete folder
                 @rmdir(WINABSPATH . $gallerypath . '/thumbs');
                 @rmdir(WINABSPATH . $gallerypath);
             }
         }
         $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE galleryid = {$this->gid}");
         $delete_galllery = $wpdb->query("DELETE FROM {$wpdb->nggallery} WHERE gid = {$this->gid}");
         if ($delete_galllery) {
             nggGallery::show_message(__ngettext('Gallery', 'Galleries', 1, 'nggallery') . ' \'' . $this->gid . '\' ' . __('deleted successfully', 'nggallery'));
         }
         $this->mode = 'main';
         // show mainpage
     }
     if ($this->mode == 'delpic') {
         // Delete a picture
         //TODO:Remove also Tag reference
         check_admin_referer('ngg_delpicture');
         $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$this->pid}' ");
         if ($filename) {
             $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
             if ($gallerypath) {
                 $thumb_folder = nggGallery::get_thumbnail_folder($gallerypath, FALSE);
                 if ($ngg->options['deleteImg']) {
                     @unlink(WINABSPATH . $gallerypath . '/thumbs/thumbs_' . $filename);
                     @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                 }
             }
             $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$this->pid}");
         }
         if ($delete_pic) {
             nggGallery::show_message(__('Picture', 'nggallery') . ' \'' . $this->pid . '\' ' . __('deleted successfully', 'nggallery'));
         }
         $this->mode = 'edit';
         // show pictures
     }
     if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
         // do bulk update
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         $imageslist = array();
         if (is_array($_POST['doaction'])) {
             foreach ($_POST['doaction'] as $imageID) {
                 $imageslist[] = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}' ");
             }
         }
         switch ($_POST['bulkaction']) {
             case 'no_action':
                 // No action
                 break;
             case 'set_watermark':
                 // Set watermark
                 nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
                 break;
             case 'new_thumbnail':
                 // Create new thumbnails
                 nggAdmin::do_ajax_operation('create_thumbnail', $_POST['doaction'], __('Create new thumbnails', 'nggallery'));
                 break;
             case 'resize_images':
                 // Resample images
                 nggAdmin::do_ajax_operation('resize_image', $_POST['doaction'], __('Resize images', 'nggallery'));
                 break;
             case 'delete_images':
                 // Delete images
                 if (is_array($_POST['doaction'])) {
                     if ($gallerypath) {
                         $thumb_folder = nggGallery::get_thumbnail_folder($gallerypath, FALSE);
                         foreach ($_POST['doaction'] as $imageID) {
                             $filename = $wpdb->get_var("SELECT filename FROM {$wpdb->nggpictures} WHERE pid = '{$imageID}' ");
                             if ($ngg->options['deleteImg']) {
                                 @unlink(WINABSPATH . $gallerypath . '/' . $thumb_folder . '/' . "thumbs_" . $filename);
                                 @unlink(WINABSPATH . $gallerypath . '/' . $filename);
                             }
                             $delete_pic = $wpdb->query("DELETE FROM {$wpdb->nggpictures} WHERE pid = {$imageID}");
                         }
                     }
                     if ($delete_pic) {
                         nggGallery::show_message(__('Pictures deleted successfully ', "nggallery"));
                     }
                 }
                 break;
             case 'import_meta':
                 // Import Metadata
                 nggAdmin::import_MetaData($_POST['doaction']);
                 nggGallery::show_message(__('Import metadata finished', "nggallery"));
                 break;
         }
     }
     // will be called after a ajax operation
     if (isset($_POST['ajax_callback'])) {
         if ($_POST['ajax_callback'] == 1) {
             nggGallery::show_message(__('Operation successfull. Please clear your browser cache.', "nggallery"));
         }
         $this->mode = 'edit';
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
         check_admin_referer('ngg_thickbox_form');
         $pic_ids = explode(",", $_POST['TB_imagelist']);
         $dest_gid = (int) $_POST['dest_gid'];
         switch ($_POST['TB_bulkaction']) {
             case 'copy_to':
                 // Copy images
                 nggAdmin::copy_images($pic_ids, $dest_gid);
                 break;
             case 'move_to':
                 // Move images
                 nggAdmin::move_images($pic_ids, $dest_gid);
                 break;
         }
     }
     if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) {
         // do tags update
         check_admin_referer('ngg_thickbox_form');
         // get the images list
         $pic_ids = explode(",", $_POST['TB_imagelist']);
         $taglist = explode(",", $_POST['taglist']);
         $taglist = array_map('trim', $taglist);
         if (is_array($pic_ids)) {
             foreach ($pic_ids as $pic_id) {
                 // which action should be performed ?
                 switch ($_POST['TB_bulkaction']) {
                     case 'no_action':
                         // No action
                         break;
                     case 'overwrite_tags':
                         // Overwrite tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
                         break;
                     case 'add_tags':
                         // Add / append tags
                         wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
                         break;
                     case 'delte_tags':
                         // Delete tags
                         $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
                         // get the slugs, to vaoid  case sensitive problems
                         $slugarray = array_map('sanitize_title', $taglist);
                         $oldtags = array_map('sanitize_title', $oldtags);
                         // compare them and return the diff
                         $newtags = array_diff($oldtags, $slugarray);
                         wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
                         break;
                 }
             }
             nggGallery::show_message(__('Tags changed', "nggallery"));
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('ngg_updategallery');
         $gallery_title = attribute_escape($_POST['title']);
         $gallery_path = attribute_escape($_POST['path']);
         $gallery_desc = attribute_escape($_POST['gallerydesc']);
         $gallery_pageid = (int) $_POST['pageid'];
         $gallery_preview = (int) $_POST['previewpic'];
         $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', path= '{$gallery_path}', galdesc = '{$gallery_desc}', pageid = '{$gallery_pageid}', previewpic = '{$gallery_preview}' WHERE gid = '{$this->gid}'");
         if (isset($_POST['author'])) {
             $gallery_author = (int) $_POST['author'];
             $wpdb->query("UPDATE {$wpdb->nggallery} SET author = '{$gallery_author}' WHERE gid = '{$this->gid}'");
         }
         if ($this->showTags) {
             $this->update_tags();
         } else {
             $this->update_pictures();
         }
         //hook for other plugin to update the fields
         do_action('ngg_update_gallery', $this->gid, $_POST);
         nggGallery::show_message(__('Update successful', "nggallery"));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::import_gallery($gallerypath);
     }
     if (isset($_POST['addnewpage'])) {
         // Add a new page
         check_admin_referer('ngg_updategallery');
         $parent_id = attribute_escape($_POST['parent_id']);
         $gallery_title = attribute_escape($_POST['title']);
         $gallery_name = $wpdb->get_var("SELECT name FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         // Create a WP page
         global $user_ID;
         $page['post_type'] = 'page';
         $page['post_content'] = '[nggallery id=' . $this->gid . ']';
         $page['post_parent'] = $parent_id;
         $page['post_author'] = $user_ID;
         $page['post_status'] = 'publish';
         $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
         $gallery_pageid = wp_insert_post($page);
         if ($gallery_pageid != 0) {
             $result = $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', pageid = '{$gallery_pageid}' WHERE gid = '{$this->gid}'");
             nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery'));
         }
     }
     if (isset($_POST['backToGallery'])) {
         $this->mode = 'edit';
     }
     // show sort order
     if (isset($_POST['sortGallery'])) {
         $this->mode = 'sort';
     }
 }