/** * ngg_convert_filestructure() - converter for old thumnail folder structure * * @return void */ function ngg_convert_filestructure() { global $wpdb; $gallerylist = $wpdb->get_results("SELECT * FROM {$wpdb->nggallery} ORDER BY gid ASC", OBJECT_K); if (is_array($gallerylist)) { $errors = array(); foreach ($gallerylist as $gallery) { $gallerypath = ABSPATH . $gallery->path; // old mygallery check, convert the wrong folder/ file name now if (@is_dir($gallerypath . '/tumbs')) { if (!@rename($gallerypath . '/tumbs', $gallerypath . '/thumbs')) { $errors[] = $gallery->path . '/thumbs'; } // read list of images $imageslist = nggAdmin::scandir($gallerypath . '/thumbs'); if (!empty($imageslist)) { foreach ($imageslist as $image) { $purename = substr($image, 4); if (!@rename($gallerypath . '/thumbs/' . $image, $gallerypath . '/thumbs/thumbs_' . $purename)) { $errors[] = $gallery->path . '/thumbs/thumbs_' . $purename; } } } } } if (!empty($errors)) { echo "<div class='error_inline'><p>" . __('Some folders/files could not renamed, please recheck the permission and rescan the folder in the manage gallery section.', 'nggallery') . "</p>"; foreach ($errors as $value) { echo __('Rename failed', 'nggallery') . ' : <strong>' . $value . "</strong><br />\n"; } echo '</div>'; } } }
function _save_entity($entity) { // If successfully saved, then import metadata and $retval = $this->call_parent('_save_entity', $entity); if ($retval) { include_once NGGALLERY_ABSPATH . '/admin/functions.php'; $image_id = $this->get_id($entity); nggAdmin::import_MetaData($image_id); C_Photocrati_Cache::flush(); } return $retval; }
function _save_entity($entity) { // If successfully saved, then import metadata and $retval = $this->call_parent('_save_entity', $entity); if ($retval) { include_once NGGALLERY_ABSPATH . '/admin/functions.php'; $image_id = $this->get_id($entity); if (!isset($entity->meta_data['saved'])) { nggAdmin::import_MetaData($image_id); } C_Photocrati_Cache::flush('displayed_gallery_rendering'); } return $retval; }
function ngg_ajax_operation() { global $wpdb; // if nonce is not correct it returns -1 check_ajax_referer("ngg-ajax"); // check for correct capability if (!is_user_logged_in()) { die('-1'); } // check for correct NextGEN capability if (!current_user_can('NextGEN Upload images') || !current_user_can('NextGEN Manage gallery')) { die('-1'); } // include the ngg function include_once dirname(__FILE__) . '/functions.php'; // Get the image id if (isset($_POST['image'])) { $id = (int) $_POST['image']; // let's get the image data $picture = nggdb::find_image($id); // what do you want to do ? switch ($_POST['operation']) { case 'create_thumbnail': $result = nggAdmin::create_thumbnail($picture); break; case 'resize_image': $result = nggAdmin::resize_image($picture); break; case 'set_watermark': $result = nggAdmin::set_watermark($picture); break; default: die('-1'); break; } // A success should retun a '1' die($result); } // The script should never stop here die('0'); }
/** * Upload function will be called via the Flash uploader * * @class nggAdmin * @param integer $galleryID * @return string $result */ static function swfupload_image($galleryID = 0) { global $nggdb; if ($galleryID == 0) { return __('No gallery selected !', 'nggallery'); } // WPMU action if (nggWPMU::check_quota()) { return '0'; } // Check the upload if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) { return __('Invalid upload. Error Code : ', 'nggallery') . $_FILES['Filedata']['error']; } // get the filename and extension $temp_file = $_FILES['Filedata']['tmp_name']; $filepart = nggGallery::fileinfo($_FILES['Filedata']['name']); $filename = $filepart['basename']; // check for allowed extension $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif')); if (!in_array(strtolower($filepart['extension']), $ext)) { return esc_html($_FILES[$key]['name']) . __('is no valid image file!', 'nggallery'); } // get the path to the gallery $gallery = $nggdb->find_gallery((int) $galleryID); if (empty($gallery->path)) { @unlink($temp_file); return __('Failure in database, no gallery path set !', 'nggallery'); } // read list of images $imageslist = nggAdmin::scandir(WINABSPATH . $gallery->path); // check if this filename already exist $i = 0; while (in_array($filename, $imageslist)) { $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension']; } $dest_file = WINABSPATH . $gallery->path . '/' . $filename; // save temp file to gallery if (!@move_uploaded_file($_FILES["Filedata"]['tmp_name'], $dest_file)) { nggAdmin::check_safemode(WINABSPATH . $gallery->path); return __('Error, the file could not be moved to : ', 'nggallery') . esc_html($dest_file); } if (!nggAdmin::chmod($dest_file)) { return __('Error, the file permissions could not be set', 'nggallery'); } return '0'; }
function post_processor_images() { global $wpdb, $ngg, $nggdb; // bulk update in a single gallery if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) { check_admin_referer('ngg_updategallery'); switch ($_POST['bulkaction']) { case 'no_action': break; case 'rotate_cw': nggAdmin::do_ajax_operation('rotate_cw', $_POST['doaction'], __('Rotate images', 'nggallery')); break; case 'rotate_ccw': nggAdmin::do_ajax_operation('rotate_ccw', $_POST['doaction'], __('Rotate images', 'nggallery')); break; case 'recover_images': nggAdmin::do_ajax_operation('recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery')); break; case 'set_watermark': nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery')); break; case 'delete_images': if (is_array($_POST['doaction'])) { foreach ($_POST['doaction'] as $imageID) { $image = $nggdb->find_image($imageID); if ($image) { if ($ngg->options['deleteImg']) { $storage = C_Gallery_Storage::get_instance(); $storage->delete_image($image->pid); } do_action('ngg_delete_picture', $image->pid); $delete_pic = C_Image_Mapper::get_instance()->destroy($image->pid); } } if ($delete_pic) { nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery')); } } break; case 'import_meta': nggAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery')); break; } } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) { check_admin_referer('ngg_thickbox_form'); //save the new values for the next operation $ngg->options['imgWidth'] = (int) $_POST['imgWidth']; $ngg->options['imgHeight'] = (int) $_POST['imgHeight']; update_option('ngg_options', $ngg->options); $pic_ids = explode(',', $_POST['TB_imagelist']); nggAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'nggallery')); } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) { check_admin_referer('ngg_thickbox_form'); // save the new values for the next operation $settings = C_NextGen_Settings::get_instance(); $settings->thumbwidth = (int) $_POST['thumbwidth']; $settings->thumbheight = (int) $_POST['thumbheight']; $settings->thumbfix = isset($_POST['thumbfix']) ? TRUE : FALSE; $settings->save(); ngg_refreshSavedSettings(); $pic_ids = explode(',', $_POST['TB_imagelist']); nggAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'nggallery')); } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) { check_admin_referer('ngg_thickbox_form'); $pic_ids = explode(',', $_POST['TB_imagelist']); $dest_gid = (int) $_POST['dest_gid']; switch ($_POST['TB_bulkaction']) { case 'copy_to': C_Gallery_Storage::get_instance()->copy_images($pic_ids, $dest_gid); break; case 'move_to': C_Gallery_Storage::get_instance()->move_images($pic_ids, $dest_gid); break; } } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) { // do tags update check_admin_referer('ngg_thickbox_form'); // get the images list $pic_ids = explode(',', $_POST['TB_imagelist']); $taglist = explode(',', $_POST['taglist']); $taglist = array_map('trim', $taglist); if (is_array($pic_ids)) { foreach ($pic_ids as $pic_id) { // which action should be performed ? switch ($_POST['TB_bulkaction']) { case 'no_action': // No action break; case 'overwrite_tags': // Overwrite tags wp_set_object_terms($pic_id, $taglist, 'ngg_tag'); break; case 'add_tags': // Add / append tags wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE); break; case 'delete_tags': // Delete tags $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names'); // get the slugs, to vaoid case sensitive problems $slugarray = array_map('sanitize_title', $taglist); $oldtags = array_map('sanitize_title', $oldtags); // compare them and return the diff $newtags = array_diff($oldtags, $slugarray); wp_set_object_terms($pic_id, $newtags, 'ngg_tag'); break; } } nggGallery::show_message(__('Tags changed', 'nggallery')); } } if (isset($_POST['updatepictures'])) { // Update pictures check_admin_referer('ngg_updategallery'); if (nggGallery::current_user_can('NextGEN Edit gallery options') && !isset($_GET['s'])) { $tags = array('<a>', '<abbr>', '<acronym>', '<address>', '<b>', '<base>', '<basefont>', '<big>', '<blockquote>', '<br>', '<br/>', '<caption>', '<center>', '<cite>', '<code>', '<col>', '<colgroup>', '<dd>', '<del>', '<dfn>', '<dir>', '<div>', '<dl>', '<dt>', '<em>', '<fieldset>', '<font>', '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>', '<hr>', '<i>', '<ins>', '<label>', '<legend>', '<li>', '<menu>', '<noframes>', '<noscript>', '<ol>', '<optgroup>', '<option>', '<p>', '<pre>', '<q>', '<s>', '<samp>', '<select>', '<small>', '<span>', '<strike>', '<strong>', '<sub>', '<sup>', '<table>', '<tbody>', '<td>', '<tfoot>', '<th>', '<thead>', '<tr>', '<tt>', '<u>', '<ul>'); $fields = array('title', 'galdesc'); // Sanitize fields foreach ($fields as $field) { $html = $_POST[$field]; $html = preg_replace('/\\s+on\\w+=(["\']).*?\\1/i', '', $html); $html = preg_replace('/(<\\/[^>]+?>)(<[^>\\/][^>]*?>)/', '$1 $2', $html); $html = strip_tags($html, implode('', $tags)); $_POST[$field] = $html; } // Update the gallery $mapper = C_Gallery_Mapper::get_instance(); if ($entity = $mapper->find($this->gid)) { foreach ($_POST as $key => $value) { $entity->{$key} = $value; } $mapper->save($entity); } wp_cache_delete($this->gid, 'ngg_gallery'); } $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, $this->gid); } // Add a new page if (isset($_POST['addnewpage'])) { check_admin_referer('ngg_updategallery'); $parent_id = esc_attr($_POST['parent_id']); $gallery_title = esc_attr($_POST['title']); $mapper = C_Gallery_Mapper::get_instance(); $gallery = $mapper->find($this->gid); $gallery_name = $gallery->name; // Create a WP page global $user_ID; $page['post_type'] = 'page'; $page['post_content'] = apply_filters('ngg_add_page_shortcode', '[nggallery id="' . $this->gid . '"]'); $page['post_parent'] = $parent_id; $page['post_author'] = $user_ID; $page['post_status'] = 'publish'; $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title; $page = apply_filters('ngg_add_new_page', $page, $this->gid); $gallery_pageid = wp_insert_post($page); if ($gallery_pageid != 0) { $gallery->pageid = $gallery_pageid; $mapper->save($gallery); nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery')); } do_action('ngg_gallery_addnewpage', $this->gid); } }
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie']; } elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) { $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; } if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) { $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie']; } // don't ask me why, sometimes needed, taken from wp core unset($current_user); // admin.php require a proper login cookie require_once ABSPATH . '/wp-admin/admin.php'; header('Content-Type: text/plain; charset=' . get_option('blog_charset')); //check for correct capability if (!is_user_logged_in()) { die('Login failure. -1'); } //check for correct capability if (!current_user_can('NextGEN Upload images')) { die('You do not have permission to upload files. -2'); } //check for correct nonce check_admin_referer('ngg_swfupload'); //check for nggallery if (!defined('NGGALLERY_ABSPATH')) { die('NextGEN Gallery not available. -3'); } include_once NGGALLERY_ABSPATH . 'admin/functions.php'; // get the gallery $galleryID = (int) $_POST['galleryselect']; echo nggAdmin::swfupload_image($galleryID);
function show_add_Product() { global $wpdb, $ngg, $nggdb; if (!empty($_POST['submit'])) { $_POST['galleryselect'] = 1; nggAdmin::upload_images(); //$imagefiles = $_FILES['imagefiles']; /* $title=$_POST['productName']; $content=$_POST['description']."<br/>[displayPrice]"; $linkToWebSite=$_POST['linkWebSite']; $currency=$_POST['currency']; $price=$_POST['price']; $Image1=$_FILES['image1']; $Image2=$_FILES['image2']; $Image3=$_FILES['image3']; $Image4=$_FILES['image4']; $postType='post'; $post = array('post_title' =>$title,'post_content' =>$content,'post_type' => $postType,'post_status' =>'publish' ); $newPostId=wp_insert_post( $post, $wp_error ); if (!empty($linkToWebSite)) add_post_meta($newPostId, 'LinkToWebsite', $linkToWebSite); add_post_meta($newPostId, 'Price', $price, false); add_post_meta($newPostId, 'Currency', $currency, false); */ //creating gallery /* $defaultpath = $ngg->options['gallerypath']; $newgallery = esc_attr("Test"); nggAdmin::create_gallery($newgallery, $defaultpath); nggAdmin::upload_images(); */ } else { ?> <form enctype="multipart/form-data" action="" method="POST"> Product Name: <br/><input type="text" name="productName" size="60"/><br/> <br/>Description:<br/> <textarea name="description" rows="10" cols="70"></textarea><br/> <br/> Link to Website: <br/><input type="text" name="linkWebSite" size="60"/><br/> <br/> Price: <br/> <select name="currency"> <option value="Rs.">Rs</option> </select> <input type="text" name="price" size="10"/> <br/> <br/>Upload Featured Image: <input name="imagefiles[]" type="file" /><br/> <br/>Upload Gallery Image 1: <input name="imagefiles[]" type="file" /><br/> <br/>Upload Gallery Image 2: <input name="imagefiles1" type="file" /><br/> <br/>Upload Gallery Image 3: <input name="imagefiles1" type="file" /><br/> <br/> <br/> <select name="category0"> <option></option> </select> <?php wp_list_categories(); ?> <br/><input type="submit" name="submit" value="Add Product" /> </form> <?php } return ""; }
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'> </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 }
/** * Copy images to another gallery */ function copy_images($pic_ids, $dest_gid) { $errors = $messages = ''; if (!is_array($pic_ids)) { $pic_ids = array($pic_ids); } // Get destination gallery $destination = nggdb::find_gallery($dest_gid); if ($destination == null) { nggGallery::show_error(__('The destination gallery does not exist', 'nggallery')); return; } // Check for folder permission if (!is_writeable(WINABSPATH . $destination->path)) { $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path); nggGallery::show_error($message); return; } // Get pictures $images = nggdb::find_images_in_list($pic_ids); $destination_path = WINABSPATH . $destination->path; foreach ($images as $image) { // WPMU action if (nggAdmin::check_quota()) { return; } $i = 0; $tmp_prefix = ''; $destination_file_name = $image->filename; while (file_exists($destination_path . '/' . $destination_file_name)) { $tmp_prefix = 'copy_' . $i++ . '_'; $destination_file_name = $tmp_prefix . $image->filename; } $destination_file_path = $destination_path . '/' . $destination_file_name; $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name; // Copy files if (!@copy($image->imagePath, $destination_file_path)) { $errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />'; continue; } // Copy the thumbnail if possible !@copy($image->thumbPath, $destination_thumb_file_path); // Create new database entry for the image $new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude); if (!isset($new_pid)) { $errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />'; continue; } // Copy tags nggTags::copy_tags($image->pid, $new_pid); if ($tmp_prefix != '') { $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) » The file already existed in the destination gallery.', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />'; } else { $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)', 'nggallery'), $image->pid, $image->filename, $new_pid, $destination_file_name) . '<br />'; } } // Finish by showing errors or success if ($errors == '') { $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . $destination->title . '</a>'; $messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .', 'nggallery'), count($images), $link); } if ($messages != '') { nggGallery::show_message($messages); } if ($errors != '') { nggGallery::show_error($errors); } return; }
/** * nggAdmin::import_gallery() * TODO: Check permission of existing thumb folder & images * * @class nggAdmin * @param string $galleryfolder contains relative path to the gallery itself * @return void */ static function import_gallery($galleryfolder, $gallery_id = NULL) { global $wpdb, $user_ID; // get the current user ID wp_get_current_user(); $created_msg = ''; // remove trailing slash at the end, if somebody use it $galleryfolder = untrailingslashit($galleryfolder); $fs = C_Fs::get_instance(); if (is_null($gallery_id)) { $gallerypath = $fs->join_paths($fs->get_document_root('content'), $galleryfolder); } else { $storage = C_Gallery_Storage::get_instance(); $gallerypath = $storage->get_gallery_abspath($gallery_id); } if (!is_dir($gallerypath)) { nggGallery::show_error(sprintf(__("Directory <strong>%s</strong> doesn`t exist!", 'nggallery'), esc_html($gallerypath))); return; } // read list of images $new_imageslist = nggAdmin::scandir($gallerypath); if (empty($new_imageslist)) { nggGallery::show_message(sprintf(__("Directory <strong>%s</strong> contains no pictures", 'nggallery'), esc_html($gallerypath))); return; } // take folder name as gallery name $galleryname = basename($galleryfolder); $galleryname = apply_filters('ngg_gallery_name', $galleryname); // check for existing gallery folder if (is_null($gallery_id)) { $gallery_id = $wpdb->get_var("SELECT gid FROM {$wpdb->nggallery} WHERE path = '{$galleryfolder}' "); } if (!$gallery_id) { // now add the gallery to the database $gallery_id = nggdb::add_gallery($galleryname, $galleryfolder, '', 0, 0, $user_ID); if (!$gallery_id) { nggGallery::show_error(__('Database error. Could not add gallery!', 'nggallery')); return; } else { do_action('ngg_created_new_gallery', $gallery_id); } $created_msg = sprintf(_n("Gallery <strong>%s</strong> successfully created!", 'Galleries <strong>%s</strong> successfully created!', 1, 'nggallery'), esc_html($galleryname)); } // Look for existing image list $old_imageslist = $wpdb->get_col("SELECT filename FROM {$wpdb->nggpictures} WHERE galleryid = '{$gallery_id}' "); // if no images are there, create empty array if ($old_imageslist == NULL) { $old_imageslist = array(); } // check difference $new_images = array_diff($new_imageslist, $old_imageslist); // all images must be valid files foreach ($new_images as $key => $picture) { // filter function to rename/change/modify image before $picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id); $new_images[$key] = $picture; if (!@getimagesize($gallerypath . '/' . $picture)) { unset($new_images[$key]); @unlink($gallerypath . '/' . $picture); } } // add images to database $image_ids = nggAdmin::add_Images($gallery_id, $new_images); do_action('ngg_after_new_images_added', $gallery_id, $image_ids); //add the preview image if needed nggAdmin::set_gallery_preview($gallery_id); // now create thumbnails nggAdmin::do_ajax_operation('create_thumbnail', $image_ids, __('Create new thumbnails', 'nggallery')); //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX $message = $created_msg . sprintf(_n('%s picture successfully added', '%s pictures successfully added', count($image_ids), 'nggallery'), count($image_ids)); $message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >'; $message .= __('Edit gallery', 'nggallery'); $message .= '</a>]'; nggGallery::show_message($message); return; }
function nggallery_admin_add_gallery() { global $wpdb, $ngg; // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0 $filepath = admin_url() . 'admin.php?page=' . $_GET['page']; // link for the flash file $swf_upload_link = NGGALLERY_URLPATH . 'admin/upload.php'; $swf_upload_link = wp_nonce_url($swf_upload_link, 'ngg_swfupload'); //flash doesn't seem to like encoded ampersands, so convert them back here $swf_upload_link = str_replace('&', '&', $swf_upload_link); $defaultpath = $ngg->options['gallerypath']; if ($_POST['addgallery']) { check_admin_referer('ngg_addgallery'); $newgallery = attribute_escape($_POST['galleryname']); if (!empty($newgallery)) { nggAdmin::create_gallery($newgallery, $defaultpath); } } if ($_POST['zipupload']) { check_admin_referer('ngg_addgallery'); if ($_FILES['zipfile']['error'] == 0) { $messagetext = nggAdmin::import_zipfile(intval($_POST['zipgalselect'])); } else { nggGallery::show_error(__('Upload failed!', 'nggallery')); } } if ($_POST['importfolder']) { check_admin_referer('ngg_addgallery'); $galleryfolder = $_POST['galleryfolder']; if (!empty($galleryfolder) and $defaultpath != $galleryfolder) { nggAdmin::import_gallery($galleryfolder); } } if ($_POST['uploadimage']) { check_admin_referer('ngg_addgallery'); if ($_FILES['MF__F_0_0']['error'] == 0) { $messagetext = nggAdmin::upload_images(); } else { nggGallery::show_error(__('Upload failed!', 'nggallery')); } } if (isset($_POST['swf_callback'])) { if ($_POST['galleryselect'] == "0") { nggGallery::show_error(__('No gallery selected !', 'nggallery')); } else { // get the path to the gallery $galleryID = (int) $_POST['galleryselect']; $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' "); nggAdmin::import_gallery($gallerypath); } } if (isset($_POST['disable_flash'])) { check_admin_referer('ngg_addgallery'); $ngg->options['swfUpload'] = false; update_option('ngg_options', $ngg->options); } if (isset($_POST['enable_flash'])) { check_admin_referer('ngg_addgallery'); $ngg->options['swfUpload'] = true; update_option('ngg_options', $ngg->options); } //get all galleries (after we added new ones) $gallerylist = nggdb::find_all_galleries(); ?> <?php if ($ngg->options['swfUpload']) { ?> <!-- SWFUpload script --> <script type="text/javascript"> var ngg_swf_upload; window.onload = function () { ngg_swf_upload = new SWFUpload({ // Backend settings upload_url : "<?php echo $swf_upload_link; ?> ", flash_url : "<?php echo NGGALLERY_URLPATH; ?> admin/js/swfupload.swf", // Button Settings button_placeholder_id : "spanButtonPlaceholder", button_width: 300, button_height: 27, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND, // File Upload Settings file_size_limit : "<?php echo wp_max_upload_size(); ?> b", file_types : "*.jpg;*.gif;*.png", file_types_description : "<?php _e('Image Files', 'nggallery'); ?> ", // Queue handler file_queued_handler : fileQueued, // Upload handler upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, post_params : { "auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?> ", "galleryselect" : "0" }, // i18names custom_settings : { "remove" : "<?php _e('remove', 'nggallery'); ?> ", "browse" : "<?php _e('Browse...', 'nggallery'); ?> ", "upload" : "<?php _e('Upload images', 'nggallery'); ?> " }, // Debug settings debug: false }); // on load change the upload to swfupload initSWFUpload(); }; </script> <div class="wrap" id="progressbar-wrap"> <div class="progressborder"> <div class="progressbar" id="progressbar"> <span>0%</span> </div> </div> </div> <?php } else { ?> <!-- MultiFile script --> <script type="text/javascript"> jQuery(function(){ jQuery('#imagefiles').MultiFile({ STRING: { remove:'<?php _e('remove', 'nggallery'); ?> ' } }); }); </script> <?php } ?> <!-- jQuery Tabs script --> <script type="text/javascript"> jQuery(function() { jQuery('#slider > ul').tabs({ fxFade: true, fxSpeed: 'fast' }); }); </script> <div id="slider" class="wrap"> <ul id="tabs"> <li><a href="#addgallery"><?php _e('Add new gallery', 'nggallery'); ?> </a></li> <?php if (wpmu_enable_function('wpmuZipUpload')) { ?> <li><a href="#zipupload"><?php _e('Upload a Zip-File', 'nggallery'); ?> </a></li> <?php } if (!IS_WPMU) { ?> <li><a href="#importfolder"><?php _e('Import image folder', 'nggallery'); ?> </a></li> <?php } ?> <li><a href="#uploadimage"><?php _e('Upload Images', 'nggallery'); ?> </a></li> </ul> <!-- create gallery --> <div id="addgallery"> <h2><?php _e('Add new gallery', 'nggallery'); ?> </h2> <form name="addgallery" id="addgallery_form" method="POST" action="<?php echo $filepath; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('New Gallery', 'nggallery'); ?> :</th> <td><input type="text" size="35" name="galleryname" value="" /><br /> <?php if (!IS_WPMU) { ?> <?php _e('Create a new , empty gallery below the folder', 'nggallery'); ?> <strong><?php echo $defaultpath; ?> </strong><br /> <?php } ?> <i>( <?php _e('Allowed characters for file and folder names are', 'nggallery'); ?> : a-z, A-Z, 0-9, -, _ )</i></td> </tr> </table> <div class="submit"><input class="button-primary" type="submit" name= "addgallery" value="<?php _e('Add gallery', 'nggallery'); ?> "/></div> </form> </div> <?php if (wpmu_enable_function('wpmuZipUpload')) { ?> <!-- zip-file operation --> <div id="zipupload"> <h2><?php _e('Upload a Zip-File', 'nggallery'); ?> </h2> <form name="zipupload" id="zipupload_form" method="POST" enctype="multipart/form-data" action="<?php echo $filepath . '#zipupload'; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Select Zip-File', 'nggallery'); ?> :</th> <td><input type="file" name="zipfile" id="zipfile" size="35" class="uploadform"/><br /> <?php _e('Upload a zip file with images', 'nggallery'); ?> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('in to', 'nggallery'); ?> </th> <td><select name="zipgalselect"> <option value="0" ><?php _e('a new gallery', 'nggallery'); ?> </option> <?php foreach ($gallerylist as $gallery) { $name = empty($gallery->title) ? $gallery->name : $gallery->title; echo '<option value="' . $gallery->gid . '" >' . $name . '</option>' . "\n"; } ?> </select> <br /><?php echo _e('Note : The upload limit on your server is ', 'nggallery') . "<strong>" . ini_get('upload_max_filesize') . "Byte</strong>\n"; ?> <br /><?php if (IS_WPMU && wpmu_enable_function('wpmuQuotaCheck')) { display_space_usage(); } ?> </td> </tr> </table> <div class="submit"><input class="button-primary" type="submit" name= "zipupload" value="<?php _e('Start upload', 'nggallery'); ?> "/></div> </form> </div> <?php } if (!IS_WPMU) { ?> <!-- import folder --> <div id="importfolder"> <h2><?php _e('Import image folder', 'nggallery'); ?> </h2> <form name="importfolder" id="importfolder_form" method="POST" action="<?php echo $filepath . '#importfolder'; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Import from Server path:', 'nggallery'); ?> </th> <td><input type="text" size="35" name="galleryfolder" value="<?php echo $defaultpath; ?> " /><br /> <?php _e('Import a folder with all images.', 'nggallery'); ?> <?php if (SAFE_MODE) { ?> <br /><?php _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'nggallery'); } ?> </td> </tr> </table> <div class="submit"><input class="button-primary" type="submit" name= "importfolder" value="<?php _e('Import folder', 'nggallery'); ?> "/></div> </form> </div> <?php } ?> <!-- upload images --> <div id="uploadimage"> <h2><?php _e('Upload Images', 'nggallery'); ?> </h2> <form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php echo $filepath . '#uploadimage'; ?> " accept-charset="utf-8" > <?php wp_nonce_field('ngg_addgallery'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Upload image', 'nggallery'); ?> </th> <td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles" id="imagefiles" size="35" class="imagefiles"/></td> </tr> <tr valign="top"> <th scope="row"><?php _e('in to', 'nggallery'); ?> </th> <td><select name="galleryselect" id="galleryselect"> <option value="0" ><?php _e('Choose gallery', 'nggallery'); ?> </option> <?php foreach ($gallerylist as $gallery) { $name = empty($gallery->title) ? $gallery->name : $gallery->title; echo '<option value="' . $gallery->gid . '" >' . $name . '</option>' . "\n"; } ?> </select> <br /><?php echo _e('Note : The upload limit on your server is ', 'nggallery') . "<strong>" . ini_get('upload_max_filesize') . "Byte</strong>\n"; ?> <br /><?php if (IS_WPMU && wpmu_enable_function('wpmuQuotaCheck')) { display_space_usage(); } ?> </td> </tr> </table> <div class="submit"> <?php if ($ngg->options['swfUpload']) { ?> <input type="submit" name="disable_flash" id="disable_flash" title="<?php _e('The batch upload requires Adobe Flash 9, disable it if you have problems', 'nggallery'); ?> " value="<?php _e('Disable flash upload', 'nggallery'); ?> " /> <?php } else { ?> <input type="submit" name="enable_flash" id="enable_flash" title="<?php _e('Upload multiple files at once by ctrl/shift-selecting in dialog', 'nggallery'); ?> " value="<?php _e('Enable flash based upload', 'nggallery'); ?> " /> <?php } ?> <input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php _e('Upload images', 'nggallery'); ?> " /> </div> </form> </div> </div> <?php }
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 }
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' => __('«'), 'next_text' => __('»'), '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 “%s”', '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 . '&mode=edit&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 . '&mode=edit&gid=' . $act_gid . '&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"> </th> <th align="left"> </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–%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&mode=delpic&gid=" . $act_gid . "&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'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " 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'); ?> <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'); ?> " /> <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'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " 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'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " 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 . "&mode=edit&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; ?> </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 . "&mode=delete&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 }
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 . '&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 . '&mode=edit&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)); ?> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <?php }
function post_processor_images() { global $wpdb, $ngg, $nggdb; // bulk update in a single gallery if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) { check_admin_referer('ngg_updategallery'); switch ($_POST['bulkaction']) { case 'no_action': break; case 'rotate_cw': nggAdmin::do_ajax_operation('rotate_cw', $_POST['doaction'], __('Rotate images', 'nggallery')); break; case 'rotate_ccw': nggAdmin::do_ajax_operation('rotate_ccw', $_POST['doaction'], __('Rotate images', 'nggallery')); break; case 'recover_images': nggAdmin::do_ajax_operation('recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery')); break; case 'set_watermark': nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery')); break; case 'delete_images': if (is_array($_POST['doaction'])) { foreach ($_POST['doaction'] as $imageID) { $image = $nggdb->find_image($imageID); if ($image) { if ($ngg->options['deleteImg']) { @unlink($image->imagePath); @unlink($image->thumbPath); @unlink($image->imagePath . "_backup"); } do_action('ngg_delete_picture', $image->pid); $delete_pic = nggdb::delete_image($image->pid); } } if ($delete_pic) { nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery')); } } break; case 'import_meta': nggAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery')); break; } } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) { check_admin_referer('ngg_thickbox_form'); //save the new values for the next operation $ngg->options['imgWidth'] = (int) $_POST['imgWidth']; $ngg->options['imgHeight'] = (int) $_POST['imgHeight']; update_option('ngg_options', $ngg->options); $pic_ids = explode(',', $_POST['TB_imagelist']); nggAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'nggallery')); } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) { check_admin_referer('ngg_thickbox_form'); //save the new values for the next operation $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth']; $ngg->options['thumbheight'] = (int) $_POST['thumbheight']; $ngg->options['thumbfix'] = isset($_POST['thumbfix']) ? true : false; update_option('ngg_options', $ngg->options); $pic_ids = explode(',', $_POST['TB_imagelist']); nggAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'nggallery')); } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) { check_admin_referer('ngg_thickbox_form'); $pic_ids = explode(',', $_POST['TB_imagelist']); $dest_gid = (int) $_POST['dest_gid']; switch ($_POST['TB_bulkaction']) { case 'copy_to': // Copy images nggAdmin::copy_images($pic_ids, $dest_gid); break; case 'move_to': // Move images nggAdmin::move_images($pic_ids, $dest_gid); break; } } if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) { // do tags update check_admin_referer('ngg_thickbox_form'); // get the images list $pic_ids = explode(',', $_POST['TB_imagelist']); $taglist = explode(',', $_POST['taglist']); $taglist = array_map('trim', $taglist); if (is_array($pic_ids)) { foreach ($pic_ids as $pic_id) { // which action should be performed ? switch ($_POST['TB_bulkaction']) { case 'no_action': // No action break; case 'overwrite_tags': // Overwrite tags wp_set_object_terms($pic_id, $taglist, 'ngg_tag'); break; case 'add_tags': // Add / append tags wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE); break; case 'delete_tags': // Delete tags $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names'); // get the slugs, to vaoid case sensitive problems $slugarray = array_map('sanitize_title', $taglist); $oldtags = array_map('sanitize_title', $oldtags); // compare them and return the diff $newtags = array_diff($oldtags, $slugarray); wp_set_object_terms($pic_id, $newtags, 'ngg_tag'); break; } } nggGallery::show_message(__('Tags changed', 'nggallery')); } } if (isset($_POST['updatepictures'])) { // Update pictures check_admin_referer('ngg_updategallery'); if (nggGallery::current_user_can('NextGEN Edit gallery options') && !isset($_GET['s'])) { if (nggGallery::current_user_can('NextGEN Edit gallery title')) { // don't forget to update the slug $slug = nggdb::get_unique_slug(sanitize_title($_POST['title']), 'gallery', $this->gid); $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET title= '%s', slug= '%s' WHERE gid = %d", esc_attr($_POST['title']), $slug, $this->gid)); } if (nggGallery::current_user_can('NextGEN Edit gallery path')) { $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET path= '%s' WHERE gid = %d", untrailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['path'])))), $this->gid)); } if (nggGallery::current_user_can('NextGEN Edit gallery description')) { $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET galdesc= '%s' WHERE gid = %d", esc_attr($_POST['gallerydesc']), $this->gid)); } if (nggGallery::current_user_can('NextGEN Edit gallery page id')) { $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET pageid= '%d' WHERE gid = %d", (int) $_POST['pageid'], $this->gid)); } if (nggGallery::current_user_can('NextGEN Edit gallery preview pic')) { $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET previewpic= '%d' WHERE gid = %d", (int) $_POST['previewpic'], $this->gid)); } if (isset($_POST['author']) && nggGallery::current_user_can('NextGEN Edit gallery author')) { $wpdb->query($wpdb->prepare("UPDATE {$wpdb->nggallery} SET author= '%d' WHERE gid = %d", (int) $_POST['author'], $this->gid)); } wp_cache_delete($this->gid, 'ngg_gallery'); } $this->update_pictures(); //hook for other plugin to update the fields do_action('ngg_update_gallery', $this->gid, $_POST); nggGallery::show_message(__('Update successful', "nggallery")); } if (isset($_POST['scanfolder'])) { // Rescan folder check_admin_referer('ngg_updategallery'); $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' "); nggAdmin::import_gallery($gallerypath); } if (isset($_POST['addnewpage'])) { // Add a new page check_admin_referer('ngg_updategallery'); $parent_id = esc_attr($_POST['parent_id']); $gallery_title = esc_attr($_POST['title']); $gallery_name = $wpdb->get_var("SELECT name FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' "); // Create a WP page global $user_ID; $page['post_type'] = 'page'; $page['post_content'] = '[nggallery id=' . $this->gid . ']'; $page['post_parent'] = $parent_id; $page['post_author'] = $user_ID; $page['post_status'] = 'publish'; $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title; $page = apply_filters('ngg_add_new_page', $page, $this->gid); $gallery_pageid = wp_insert_post($page); if ($gallery_pageid != 0) { $result = $wpdb->query("UPDATE {$wpdb->nggallery} SET title= '{$gallery_title}', pageid = '{$gallery_pageid}' WHERE gid = '{$this->gid}'"); wp_cache_delete($this->gid, 'ngg_gallery'); nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery')); } do_action('ngg_gallery_addnewpage', $this->gid); } }
function ngg_rotateImage() { // check for correct capability if (!is_user_logged_in()) { die('-1'); } // check for correct NextGEN capability if (!current_user_can('NextGEN Manage gallery')) { die('-1'); } require_once dirname(dirname(__FILE__)) . '/ngg-config.php'; // include the ngg function include_once dirname(__FILE__) . '/functions.php'; $ngg_options = get_option('ngg_options'); $id = (int) $_POST['id']; $result = '-1'; switch ($_POST['ra']) { case 'cw': $result = nggAdmin::rotate_image($id, 'CW'); break; case 'ccw': $result = nggAdmin::rotate_image($id, 'CCW'); break; case 'fv': $result = nggAdmin::rotate_image($id, 0, 'V'); break; case 'fh': $result = nggAdmin::rotate_image($id, 0, 'H'); break; } // recreate the thumbnail nggAdmin::create_thumbnail($id); if ($result == 1) { die('1'); } header('HTTP/1.1 500 Internal Server Error'); die($result); }
/** * Upload function will be called via the Flash uploader * * @class nggAdmin * @param integer $galleryID * @return string $result */ function swfupload_image($galleryID = 0) { global $wpdb; if ($galleryID == 0) { return __('No gallery selected !', 'nggallery'); } // WPMU action if (nggWPMU::check_quota()) { return '0'; } // Check the upload if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0) { return __('Invalid upload. Error Code : ', 'nggallery') . $_FILES['Filedata']['error']; } // get the filename and extension $temp_file = $_FILES['Filedata']['tmp_name']; $filepart = nggGallery::fileinfo($_FILES['Filedata']['name']); $filename = $filepart['basename']; // check for allowed extension $ext = array('jpg', 'png', 'gif'); if (!in_array($filepart['extension'], $ext)) { return $_FILES[$key]['name'] . __('is no valid image file!', 'nggallery'); } // get the path to the gallery $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$galleryID}' "); if (!$gallerypath) { @unlink($temp_file); return __('Failure in database, no gallery path set !', 'nggallery'); } // read list of images $imageslist = nggAdmin::scandir(WINABSPATH . $gallerypath); // check if this filename already exist $i = 0; while (in_array($filename, $imageslist)) { $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension']; } $dest_file = WINABSPATH . $gallerypath . '/' . $filename; // save temp file to gallery if (!@move_uploaded_file($_FILES["Filedata"]['tmp_name'], $dest_file)) { nggAdmin::check_safemode(WINABSPATH . $gallerypath); return __('Error, the file could not be moved to : ', 'nggallery') . $dest_file; } if (!nggAdmin::chmod($dest_file)) { return __('Error, the file permissions could not be set', 'nggallery'); } return '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 “%s”', '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 . '&mode=edit&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 . '&mode=edit&gid=' . $act_gid . '&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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " /> </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'); ?> <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'); ?> " /> <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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
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'; } }
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 “%s”', '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 . '&mode=edit&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 . '&mode=edit&gid=' . $act_gid . '&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"> </th> <th align="left"> </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&mode=recoverpic&gid=" . $act_gid . "&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&mode=delpic&gid=" . $act_gid . "&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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " /> </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'); ?> <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'); ?> " /> <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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
/** * 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; }
/** * nggGallery::get_thumbnail_folder() * * @param mixed $gallerypath * @param bool $include_Abspath * @return string $foldername */ static function create_thumbnail_folder($gallerypath, $include_Abspath = TRUE) { if (!$include_Abspath) { $gallerypath = ABSPATH . $gallerypath; } if (!file_exists($gallerypath)) { return FALSE; } if (is_dir($gallerypath . '/thumbs/')) { return '/thumbs/'; } if (is_admin()) { if (!is_dir($gallerypath . '/thumbs/')) { if (!wp_mkdir_p($gallerypath . '/thumbs/')) { if (SAFE_MODE) { nggAdmin::check_safemode($gallerypath . '/thumbs/'); } else { nggGallery::show_error(__('Unable to create directory ', 'nggallery') . $gallerypath . '/thumbs !'); } return FALSE; } return '/thumbs/'; } } return FALSE; }
public function reimport_metadata($image_or_id) { // Get the image $image = NULL; if (is_int($image_or_id)) { $image = $this->object->find($image_or_id); } else { $image = $image_or_id; } // Reset all image details that would have normally been imported $image->alttext = ''; $image->description = ''; if (is_array($image->meta_data)) { unset($image->meta_data['saved']); } wp_delete_object_term_relationships($image->{$image->id_field}, 'ngg_tag'); nggAdmin::import_MetaData($image); return $this->object->save($image); }
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' => __('«'), 'next_text' => __('»'), '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 . '&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–%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 . '&mode=edit&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); ?> </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–%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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </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'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <?php }
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 }