function getData($number) { global $wpdb; $data = array(); $pictures = $wpdb->get_results("SELECT a.*, b.path FROM " . $wpdb->base_prefix . "ngg_pictures AS a LEFT JOIN " . $wpdb->base_prefix . "ngg_gallery AS b ON a.galleryid = b.gid WHERE a.galleryid = '" . intval($this->_data->get('nggsourcegallery', 0)) . "'"); $i = 0; if (class_exists('nggGallery') && !class_exists('C_Component_Registry')) { // legacy foreach ($pictures as $p) { $data[$i]['alt_text'] = $p->alttext; $data[$i]['image'] = nggGallery::get_image_url($p->pid, $p->path, $p->filename); $data[$i]['thumbnail'] = nggGallery::get_thumbnail_url($p->pid, $p->path, $p->filename); $i++; } } else { $storage = C_Component_Registry::get_instance()->get_utility('I_Gallery_Storage'); foreach ($pictures as $p) { $data[$i]['alt_text'] = $p->alttext; $data[$i]['image'] = $storage->get_image_url($p); $data[$i]['thumbnail'] = $storage->get_thumbnail_url($p); $i++; } } return $data; }
function nextgengallery_showfirstpic($galleryid, $class = '') { global $wpdb; global $ngg_options; if (!$galleryid) { return; } if (!$wpdb->nggallery) { return; } if (!$ngg_options) { $ngg_options = get_option('ngg_options'); } $picturelist = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE t.gid = '{$galleryid}' AND tt.exclude != 1 ORDER BY tt.{$ngg_options['galSort']} {$ngg_options['galSortDir']} LIMIT 1"); if ($class) { $myclass = ' class="' . $class . '" '; } if ($picturelist) { $pid = $picturelist[0]->pid; if (is_callable(array('nggGallery', 'get_thumbnail_url'))) { // new NextGen 1.0+ $out = '<img alt="' . __('property photo') . '" src="' . nggGallery::get_thumbnail_url($pid) . '" ' . $myclass . ' />'; } else { // backwards compatibility - NextGen below 1.0 $out = '<img alt="' . __('property photo') . '" src="' . nggallery::get_thumbnail_url($pid) . '" ' . $myclass . ' />'; } return $out; } }
/** * Save/Load options and add a new hook for plugins * * @return void */ function processor() { global $ngg, $nggRewrite; $old_state = $ngg->options['usePermalinks']; if (isset($_POST['irDetect'])) { check_admin_referer('ngg_settings'); $ngg->options['irURL'] = ngg_search_imagerotator(); update_option('ngg_options', $ngg->options); } if (isset($_POST['updateoption'])) { check_admin_referer('ngg_settings'); // get the hidden option fields, taken from WP core if ($_POST['page_options']) { $options = explode(',', stripslashes($_POST['page_options'])); } if ($options) { foreach ($options as $option) { $option = trim($option); $value = isset($_POST[$option]) ? trim($_POST[$option]) : false; // $value = sanitize_option($option, $value); // This does stripslashes on those that need it $ngg->options[$option] = $value; } // the path should always end with a slash $ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']); $ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']); // the custom sortorder must be ascending $ngg->options['galSortDir'] = $ngg->options['galSort'] == 'sortorder' ? 'ASC' : $ngg->options['galSortDir']; } // Save options update_option('ngg_options', $ngg->options); // Flush Rewrite rules if ($old_state != $ngg->options['usePermalinks']) { $nggRewrite->flush(); } nggGallery::show_message(__('Update Successfully', 'nggallery')); } if (isset($_POST['clearcache'])) { check_admin_referer('ngg_settings'); $path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/'; if (is_dir($path)) { if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { @unlink($path . '/' . $file); } } closedir($handle); } } nggGallery::show_message(__('Cache cleared', 'nggallery')); } if (isset($_POST['createslugs'])) { check_admin_referer('ngg_settings'); include_once dirname(__FILE__) . '/upgrade.php'; ngg_rebuild_unique_slugs::start_rebuild(); } do_action('ngg_update_options_page'); }
function createNewThumb() { global $ngg; // 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'); } include_once nggGallery::graphic_library(); $id = (int) $_POST['id']; $picture = nggdb::find_image($id); $x = round($_POST['x'] * $_POST['rr'], 0); $y = round($_POST['y'] * $_POST['rr'], 0); $w = round($_POST['w'] * $_POST['rr'], 0); $h = round($_POST['h'] * $_POST['rr'], 0); $thumb = new ngg_Thumbnail($picture->imagePath, TRUE); $thumb->crop($x, $y, $w, $h); // Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way if ($ngg->options['thumbfix']) { // check for portrait format if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) { // first resize to the wanted height, here changed to create_thumbnail() $thumb->resize(0, $ngg->options['thumbheight']); // get optimal y startpos $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2; $thumb->crop(0, $ypos, $ngg->options['thumbwidth'], $ngg->options['thumbheight']); } else { // first resize to the wanted width, here changed to create_thumbnail() $thumb->resize($ngg->options['thumbwidth'], 0); // // get optimal x startpos $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2; $thumb->crop($xpos, 0, $ngg->options['thumbwidth'], $ngg->options['thumbheight']); } //this create a thumbnail but keep ratio settings } else { $thumb->resize($ngg->options['thumbwidth'], $ngg->options['thumbheight']); } if ($thumb->save($picture->thumbPath, 100)) { //read the new sizes $new_size = @getimagesize($picture->thumbPath); $size['width'] = $new_size[0]; $size['height'] = $new_size[1]; // add them to the database nggdb::update_image_meta($picture->pid, array('thumbnail' => $size)); echo "OK"; } else { header('HTTP/1.1 500 Internal Server Error'); echo "KO"; } exit; }
public function instantiate() { $this->options = nggGallery::get_option('ngg_options'); $this->overwriteNggConf(); add_filter('ngg_show_gallery_content', array(&$this, "ngg_show_gallery_content")); add_filter('ngg_show_imagebrowser_content', array(&$this, "ngg_show_imagebrowser_content")); add_filter('ngg_show_album_content', array(&$this, "ngg_show_album_content")); add_filter('ngg_show_slideshow_content', array(&$this, "ngg_show_slideshow_content"), 10, 4); add_filter('ngg_show_slideshow_widget_content', array(&$this, "ngg_show_slideshow_widget_content"), 10, 4); add_filter('ngg_slideshow_size', array(&$this, "ngg_slideshow_size")); add_filter('wptouch_user_agents', array(&$this, "wptouch_user_agents")); }
/** * Check the Quota under WPMU. Only needed for this case * * @class nggWPMU * @return bool $result */ function check_quota() { if (get_site_option('upload_space_check_disabled')) { return false; } if (is_multisite() && nggWPMU::wpmu_enable_function('wpmuQuotaCheck')) { if ($error = upload_is_user_over_quota(false)) { nggGallery::show_error(__('Sorry, you have used your space allocation. Please delete some files to upload more files.', 'nggallery')); return true; } } return false; }
/** * Get the XML <rss> node corresponding to a gallery * * @param $gallery (object) The gallery to include in RSS * @param $prev_gallery (object) The previous gallery to link in RSS (null if none) * @param $next_gallery (object) The next gallery to link in RSS (null if none) */ function get_gallery_mrss($gallery, $prev_gallery = null, $next_gallery = null) { $ngg_options = nggGallery::get_option('ngg_options'); //Set sort order value, if not used (upgrade issue) $ngg_options['galSort'] = $ngg_options['galSort'] ? $ngg_options['galSort'] : 'pid'; $ngg_options['galSortDir'] = $ngg_options['galSortDir'] == 'DESC' ? 'DESC' : 'ASC'; $title = stripslashes(M_I18N::translate($gallery->title)); $description = stripslashes(M_I18N::translate($gallery->galdesc)); $link = nggMediaRss::get_permalink($gallery->pageid); $prev_link = $prev_gallery != null ? nggMediaRss::get_gallery_mrss_url($prev_gallery->gid, true) : ''; $next_link = $next_gallery != null ? nggMediaRss::get_gallery_mrss_url($next_gallery->gid, true) : ''; $images = nggdb::get_gallery($gallery->gid, $ngg_options['galSort'], $ngg_options['galSortDir']); return nggMediaRss::get_mrss_root_node($title, $description, $link, $prev_link, $next_link, $images); }
function createNewThumb() { // 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_once nggGallery::graphic_library(); $ngg_options = get_option('ngg_options'); $id = (int) $_POST['id']; $picture = nggdb::find_image($id); $x = round($_POST['x'] * $_POST['rr'], 0); $y = round($_POST['y'] * $_POST['rr'], 0); $w = round($_POST['w'] * $_POST['rr'], 0); $h = round($_POST['h'] * $_POST['rr'], 0); $thumb = new ngg_Thumbnail($picture->imagePath, TRUE); $thumb->crop($x, $y, $w, $h); if ($ngg_options['thumbfix']) { if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) { $thumb->resize($ngg_options['thumbwidth'], 0); } else { $thumb->resize(0, $ngg_options['thumbheight']); } } else { $thumb->resize($ngg_options['thumbwidth'], $ngg_options['thumbheight'], $ngg_options['thumbResampleMode']); } if ($thumb->save($picture->thumbPath, 100)) { //read the new sizes $new_size = @getimagesize($picture->thumbPath); $size['width'] = $new_size[0]; $size['height'] = $new_size[1]; // add them to the database nggdb::update_image_meta($picture->pid, array('thumbnail' => $size)); echo "OK"; } else { header('HTTP/1.1 500 Internal Server Error'); echo "KO"; } exit; }
function widget($args, $instance) { extract($args); $ngg_options = nggGallery::get_option('ngg_options'); $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base); $show_global_mrss = $instance['show_global_mrss']; $show_icon = $instance['show_icon']; $mrss_text = stripslashes($instance['mrss_text']); $mrss_title = strip_tags(stripslashes($instance['mrss_title'])); echo $before_widget; echo $before_title . $title . $after_title; echo "<ul class='ngg-media-rss-widget'>\n"; if ($show_global_mrss) { echo " <li>"; echo $this->get_mrss_link(nggMediaRss::get_mrss_url(), $show_icon, stripslashes($mrss_title), stripslashes($mrss_text), $ngg_options['usePicLens']); echo "</li>\n"; } echo "</ul>\n"; echo $after_widget; }
/** * @author Alex Rabe * @copyright 2008-2011 */ function nggallery_sortorder($galleryID = 0) { global $wpdb, $ngg, $nggdb; if ($galleryID == 0) { return; } $galleryID = (int) $galleryID; if (isset($_POST['updateSortorder'])) { check_admin_referer('ngg_updatesortorder'); // get variable new sortorder parse_str($_POST['sortorder']); if (is_array($sortArray)) { $neworder = array(); foreach ($sortArray as $pid) { $pid = substr($pid, 4); // get id from "pid-x" $neworder[] = (int) $pid; } $sortindex = 1; foreach ($neworder as $pic_id) { $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}"); $sortindex++; } do_action('ngg_gallery_sort', $galleryID); nggGallery::show_message(__('Sort order changed', 'nggallery')); } } // look for presort args $presort = isset($_GET['presort']) ? $_GET['presort'] : false; $dir = isset($_GET['dir']) && $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC'; $sortitems = array('pid', 'filename', 'alttext', 'imagedate'); // ensure that nobody added some evil sorting :-) if (in_array($presort, $sortitems)) { $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false); } else { $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false); } //this is the url without any presort variable $clean_url = 'admin.php?page=nggallery-manage-gallery&mode=sort&gid=' . $galleryID; //if we go back , then the mode should be edit $back_url = 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $galleryID; // In the case somebody presort, then we take this url if (isset($_GET['dir']) || isset($_GET['presort'])) { $base_url = $_SERVER['REQUEST_URI']; } else { $base_url = $clean_url; } ?> <script type='text/javascript' src='<?php echo NGGALLERY_URLPATH; ?> admin/js/sorter.js'></script> <div class="wrap"> <form id="sortGallery" method="POST" action="<?php echo $clean_url; ?> " onsubmit="saveImageOrder()" accept-charset="utf-8"> <h2><?php _e('Sort Gallery', 'nggallery'); ?> </h2> <div class="tablenav"> <div class="alignleft actions"> <?php wp_nonce_field('ngg_updatesortorder'); ?> <input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php _e('Update Sort Order', 'nggallery'); ?> " /> </div> <div class="alignright actions"> <a href="<?php echo esc_url($back_url); ?> " class="button"><?php _e('Back to gallery', 'nggallery'); ?> </a> </div> </div> <input name="sortorder" type="hidden" /> <ul class="subsubsub"> <li><?php _e('Presort', 'nggallery'); ?> :</li> <li><a href="<?php echo esc_attr(remove_query_arg('presort', $base_url)); ?> " <?php if ($presort == '') { echo 'class="current"'; } ?> ><?php _e('Unsorted', 'nggallery'); ?> </a> |</li> <li><a href="<?php echo esc_attr(add_query_arg('presort', 'pid', $base_url)); ?> " <?php if ($presort == 'pid') { echo 'class="current"'; } ?> ><?php _e('Image ID', 'nggallery'); ?> </a> |</li> <li><a href="<?php echo esc_attr(add_query_arg('presort', 'filename', $base_url)); ?> " <?php if ($presort == 'filename') { echo 'class="current"'; } ?> ><?php _e('Filename', 'nggallery'); ?> </a> |</li> <li><a href="<?php echo esc_attr(add_query_arg('presort', 'alttext', $base_url)); ?> " <?php if ($presort == 'alttext') { echo 'class="current"'; } ?> ><?php _e('Alt/Title text', 'nggallery'); ?> </a> |</li> <li><a href="<?php echo esc_attr(add_query_arg('presort', 'imagedate', $base_url)); ?> " <?php if ($presort == 'imagedate') { echo 'class="current"'; } ?> ><?php _e('Date/Time', 'nggallery'); ?> </a> |</li> <li><a href="<?php echo esc_attr(add_query_arg('dir', 'ASC', $base_url)); ?> " <?php if ($dir == 'ASC') { echo 'class="current"'; } ?> ><?php _e('Ascending', 'nggallery'); ?> </a> |</li> <li><a href="<?php echo esc_attr(add_query_arg('dir', 'DESC', $base_url)); ?> " <?php if ($dir == 'DESC') { echo 'class="current"'; } ?> ><?php _e('Descending', 'nggallery'); ?> </a></li> </ul> </form> <div id="debug" style="clear:both"></div> <?php if ($picturelist) { foreach ($picturelist as $picture) { ?> <div class="imageBox" id="pid-<?php echo $picture->pid; ?> "> <div class="imageBox_theImage" style="background-image:url('<?php echo esc_url($picture->thumbURL); ?> ')"></div> <div class="imageBox_label"><span><?php echo esc_html(stripslashes($picture->alttext)); ?> </span></div> </div> <?php } } ?> <div id="insertionMarker"> <img src="<?php echo NGGALLERY_URLPATH; ?> admin/images/marker_top.gif"/> <img src="<?php echo NGGALLERY_URLPATH; ?> admin/images/marker_middle.gif" id="insertionMarkerLine"/> <img src="<?php echo NGGALLERY_URLPATH; ?> admin/images/marker_bottom.gif"/> </div> <div id="dragDropContent"></div> </div> <?php }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base); global $wpdb; $items = $instance['items']; $exclude = $instance['exclude']; $list = $instance['list']; $webslice = $instance['webslice']; $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->nggpictures} WHERE exclude != 1 "); if ($count < $instance['items']) { $instance['items'] = $count; } $exclude_list = ''; // THX to Kay Germer for the idea & addon code if (!empty($list) && $exclude != 'all') { $list = explode(',', $list); // Prepare for SQL $list = "'" . implode("', '", $list) . "'"; if ($exclude == 'denied') { $exclude_list = "AND NOT (t.gid IN ({$list}))"; } if ($exclude == 'allow') { $exclude_list = "AND t.gid IN ({$list})"; } // Limit the output to the current author, can be used on author template pages if ($exclude == 'user_id') { $exclude_list = "AND t.author IN ({$list})"; } } if ($instance['type'] == 'random') { $imageList = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 {$exclude_list} ORDER by rand() limit {$items}"); } else { $imageList = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 {$exclude_list} ORDER by pid DESC limit 0,{$items}"); } // IE8 webslice support if needed if ($webslice) { $before_widget .= "\n" . '<div class="hslice" id="ngg-webslice" >' . "\n"; //the headline needs to have the class enty-title $before_title = str_replace('class="', 'class="entry-title ', $before_title); $after_widget = '</div>' . "\n" . $after_widget; } echo $before_widget . $before_title . $title . $after_title; echo "\n" . '<div class="ngg-widget entry-content">' . "\n"; if (is_array($imageList)) { foreach ($imageList as $image) { // get the URL constructor $image = new nggImage($image); // get the effect code $thumbcode = $image->get_thumbcode($widget_id); // enable i18n support for alttext and description $alttext = htmlspecialchars(stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext'))); $description = htmlspecialchars(stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description'))); //TODO:For mixed portrait/landscape it's better to use only the height setting, if widht is 0 or vice versa $out = '<a href="' . $image->imageURL . '" title="' . $description . '" ' . $thumbcode . '>'; // Typo fix for the next updates (happend until 1.0.2) $instance['show'] = $instance['show'] == 'orginal' ? 'original' : $instance['show']; if ($instance['show'] == 'original') { $out .= '<img src="' . trailingslashit(home_url()) . 'index.php?callback=image&pid=' . $image->pid . '&width=' . $instance['width'] . '&height=' . $instance['height'] . '" title="' . $alttext . '" alt="' . $alttext . '" />'; } else { $out .= '<img src="' . $image->thumbURL . '" width="' . $instance['width'] . '" height="' . $instance['height'] . '" title="' . $alttext . '" alt="' . $alttext . '" />'; } echo $out . '</a>' . "\n"; } } echo '</div>' . "\n"; echo $after_widget; }
function load_styles() { // check first the theme folder for a nggallery.css if (nggGallery::get_theme_css_file()) { wp_enqueue_style('NextGEN', nggGallery::get_theme_css_file(), false, '1.0.0', 'screen'); } else { if ($this->options['activateCSS']) { wp_enqueue_style('NextGEN', NGGALLERY_URLPATH . 'css/' . $this->options['CSSfile'], false, '1.0.0', 'screen'); } } // activate Thickbox if ($this->options['thumbEffect'] == 'thickbox') { wp_enqueue_style('thickbox'); } // activate modified Shutter reloaded if not use the Shutter plugin if ($this->options['thumbEffect'] == 'shutter' && !function_exists('srel_makeshutter')) { wp_enqueue_style('shutter', NGGALLERY_URLPATH . 'shutter/shutter-reloaded.css', false, '1.3.0', 'screen'); } }
/** * Publish a new post with the shortcode from the selected image * * @since 1.7.0 * @return void */ function publish_post() { check_admin_referer('publish-post'); // Create a WP page global $user_ID, $ngg; $ngg->options['publish_width'] = (int) $_POST['width']; $ngg->options['publish_height'] = (int) $_POST['height']; $ngg->options['publish_align'] = $_POST['align']; $align = $ngg->options['publish_align'] == 'none' ? '' : 'float=' . $ngg->options['publish_align']; //save the new values for the next operation update_option('ngg_options', $ngg->options); $post['post_type'] = 'post'; $post['post_content'] = '[singlepic id=' . intval($_POST['pid']) . ' w=' . $ngg->options['publish_width'] . ' h=' . $ngg->options['publish_height'] . ' ' . $align . ']'; $post['post_author'] = $user_ID; $post['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft'; $post['post_title'] = $_POST['post_title']; $post = apply_filters('ngg_add_new_post', $post, $_POST['pid']); $post_id = wp_insert_post($post); if ($post_id != 0) { nggGallery::show_message(__('Published a new post', 'nggallery')); } }
/** * Output HTML for the post thumbnail meta-box. * * @see wp-admin\includes\post.php * @param int $thumbnail_id ID of the image used for thumbnail * @return string html output */ function _wp_post_thumbnail_html($thumbnail_id = NULL) { global $_wp_additional_image_sizes, $post_ID; $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__('Set featured image') . '" href="' . esc_url(get_upload_iframe_src('image')) . '" id="set-post-thumbnail" class="thickbox">%s</a></p>'; $content = sprintf($set_thumbnail_link, esc_html__('Set featured image')); $image = nggdb::find_image($thumbnail_id); $img_src = false; // get the options $ngg_options = nggGallery::get_option('ngg_options'); if ($image) { if (is_array($_wp_additional_image_sizes) && isset($_wp_additional_image_sizes['post-thumbnail'])) { // Use post thumbnail settings if defined $width = absint($_wp_additional_image_sizes['post-thumbnail']['width']); $height = absint($_wp_additional_image_sizes['post-thumbnail']['height']); $mode = $_wp_additional_image_sizes['post-thumbnail']['crop'] ? 'crop' : ''; // check fo cached picture $img_src = $image->cached_singlepic_file($width, $height, $mode); } // if we didn't use a cached image then we take the on-the-fly mode if ($img_src == false) { $img_src = trailingslashit(home_url()) . 'index.php?callback=image&pid=' . $image->pid . '&width=' . $width . '&height=' . $height . '&mode=crop'; } $thumbnail_html = '<img width="266" src="' . $img_src . '" alt="' . $image->alttext . '" title="' . $image->alttext . '" />'; if (!empty($thumbnail_html)) { $ajax_nonce = wp_create_nonce("set_post_thumbnail-{$post_ID}"); $content = sprintf($set_thumbnail_link, $thumbnail_html); $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__('Remove featured image') . '</a></p>'; } } return $content; }
/** * NextGEN_shortcodes::convert_shortcode() * convert old shortcodes to the new WordPress core style * [gallery=1] ->> [nggallery id=1] * * @param string $content Content to search for shortcodes * @return string Content with new shortcodes. */ function convert_shortcode($content) { $ngg_options = nggGallery::get_option('ngg_options'); if (stristr($content, '[singlepic')) { $search = "@\\[singlepic=(\\d+)(|,\\d+|,)(|,\\d+|,)(|,watermark|,web20|,)(|,right|,center|,left|,)\\]@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // remove the comma $match[2] = ltrim($match[2], ','); $match[3] = ltrim($match[3], ','); $match[4] = ltrim($match[4], ','); $match[5] = ltrim($match[5], ','); $replace = "[singlepic id=\"{$match[1]}\" w=\"{$match[2]}\" h=\"{$match[3]}\" mode=\"{$match[4]}\" float=\"{$match[5]}\" ]"; $content = str_replace($match[0], $replace, $content); } } } if (stristr($content, '[album')) { $search = "@(?:<p>)*\\s*\\[album\\s*=\\s*(\\w+|^\\+)(|,extend|,compact)\\]\\s*(?:</p>)*@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // remove the comma $match[2] = ltrim($match[2], ','); $replace = "[album id=\"{$match[1]}\" template=\"{$match[2]}\"]"; $content = str_replace($match[0], $replace, $content); } } } if (stristr($content, '[gallery')) { $search = "@(?:<p>)*\\s*\\[gallery\\s*=\\s*(\\w+|^\\+)\\]\\s*(?:</p>)*@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $replace = "[nggallery id=\"{$match[1]}\"]"; $content = str_replace($match[0], $replace, $content); } } } if (stristr($content, '[imagebrowser')) { $search = "@(?:<p>)*\\s*\\[imagebrowser\\s*=\\s*(\\w+|^\\+)\\]\\s*(?:</p>)*@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $replace = "[imagebrowser id=\"{$match[1]}\"]"; $content = str_replace($match[0], $replace, $content); } } } if (stristr($content, '[slideshow')) { $search = "@(?:<p>)*\\s*\\[slideshow\\s*=\\s*(\\w+|^\\+)(|,(\\d+)|,)(|,(\\d+))\\]\\s*(?:</p>)*@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // remove the comma $match[3] = ltrim($match[3], ','); $match[5] = ltrim($match[5], ','); $replace = "[slideshow id=\"{$match[1]}\" w=\"{$match[3]}\" h=\"{$match[5]}\"]"; $content = str_replace($match[0], $replace, $content); } } } if (stristr($content, '[tags')) { $search = "@(?:<p>)*\\s*\\[tags\\s*=\\s*(.*?)\\s*\\]\\s*(?:</p>)*@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $replace = "[nggtags gallery=\"{$match[1]}\"]"; $content = str_replace($match[0], $replace, $content); } } } if (stristr($content, '[albumtags')) { $search = "@(?:<p>)*\\s*\\[albumtags\\s*=\\s*(.*?)\\s*\\]\\s*(?:</p>)*@i"; if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $replace = "[nggtags album=\"{$match[1]}\"]"; $content = str_replace($match[0], $replace, $content); } } } return $content; }
function jig_ng_find_subalbums($parent_album_id, $cover_picture, $count = false) { global $wpdb; $parent_album = wp_cache_get(substr($parent_album_id, 1), 'jig_ng_albums'); if ($cover_picture === 'needed') { if ($parent_album->previewpic > 0) { // The album had previewpic set already $cover_picture = $this->jig_ng_find_images($parent_album->previewpic, true); if (empty($cover_picture)) { // The preview picture is obsolete $cover_picture = 'needed'; } } } if ($parent_album->sortorder) { // If the album is not empty $parent_album_contents = $this->jig_ng_unserialize($parent_album->sortorder); $galleries = $sub_albums = array(); foreach ($parent_album_contents as $parent_album_element_ID) { if (is_numeric($parent_album_element_ID)) { //$galleries[] = wp_cache_get($parent_album_element_ID, 'jig_ng_galleries'); $galleries[] = $parent_album_element_ID; } else { $sub_albums[] = $parent_album_element_ID; } } if ($cover_picture === 'needed') { // If cover picture is not found yet, try to get one from the galleries if (!empty($galleries)) { foreach ($galleries as $gallery) { $cover_picture = $this->ng_find_cover_image_for_gallery($gallery); if (!empty($cover_picture)) { // Gallery had (?) a previewpic set break; } else { // Gallery has no pics $cover_picture = 'needed'; } } } } if ($cover_picture === 'needed') { // If cover picture is still not found yet if (!empty($sub_albums)) { foreach ($sub_albums as $sub_album) { if ($sub_album !== $parent_album_id) { // Protection against infinite recursion $cover_picture = $this->jig_ng_find_subalbums($sub_album, 'needed'); // Recursive call of this function } else { // It would have been the same album in the same album .. (infinitely) $cover_picture = NULL; } if ($cover_picture !== NULL) { // The recursive function call found a preview picture break; } else { // The recursive function call could not find a picture, this album won't be shown $cover_picture = 'needed'; } } } } if ($cover_picture !== 'needed' && !empty($cover_picture)) { // If there is a cover picture (should be) if ($count === true) { // And this is not a recursively called function but the main one, include extra data for the album $cover_picture->jig['galleryCount'] = count($galleries); $cover_picture->jig['albumCount'] = count($sub_albums); $cover_picture->jig['slug'] = $parent_album->slug; $cover_picture->jig['id'] = $parent_album->id; $cover_picture->jig['pageid'] = $parent_album->pageid; $cover_picture->jig['name'] = nggGallery::i18n($parent_album->name, 'album_' . $parent_album->id . '_name'); $cover_picture->jig['albumdesc'] = nggGallery::i18n($parent_album->albumdesc, 'album_' . $parent_album->id . '_albumdesc'); } return $cover_picture; } else { // This album won't be shown! return NULL; } } else { //$notice_after .= sprintf(__('There is no content in the NextGEN album: "%1$s"!', 'jig_td'),stripcslashes($parent_album->name)); return NULL; } }
function nggallery_admin_roles() { if (isset($_POST['update_cap'])) { check_admin_referer('ngg_addroles'); // now set or remove the capability ngg_set_capability($_POST['general'], "NextGEN Gallery overview"); ngg_set_capability($_POST['tinymce'], "NextGEN Use TinyMCE"); ngg_set_capability($_POST['add_gallery'], "NextGEN Upload images"); ngg_set_capability($_POST['manage_gallery'], "NextGEN Manage gallery"); ngg_set_capability($_POST['manage_others'], "NextGEN Manage others gallery"); ngg_set_capability($_POST['manage_tags'], "NextGEN Manage tags"); ngg_set_capability($_POST['edit_album'], "NextGEN Edit album"); ngg_set_capability($_POST['change_style'], "NextGEN Change style"); ngg_set_capability($_POST['change_options'], "NextGEN Change options"); nggGallery::show_message(__('Updated capabilities', "nggallery")); } ?> <div class="wrap"> <?php screen_icon('nextgen-gallery'); ?> <h2><?php _e('Roles / capabilities', 'nggallery'); ?> </h2> <p><?php _e('Select the lowest role which should be able to access the following capabilities. NextCellent Gallery supports the standard roles from WordPress.', 'nggallery'); ?> <br /> <?php _e('For a more flexible user management you can use the', 'nggallery'); ?> <a href="http://wordpress.org/extend/plugins/capsman/" target="_blank">Capability Manager</a>.</p> <form name="addroles" id="addroles" method="POST" accept-charset="utf-8" > <?php wp_nonce_field('ngg_addroles'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="general"><?php _e('NextCellent Gallery overview', 'nggallery'); ?> </label></th> <td><select name="general" id="general"><?php wp_dropdown_roles(ngg_get_role('NextGEN Gallery overview')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="tinymce"><?php _e('Use TinyMCE Button / Add Media', 'nggallery'); ?> </label></th> <td><select name="tinymce" id="tinymce"><?php wp_dropdown_roles(ngg_get_role('NextGEN Use TinyMCE')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="add_gallery"><?php _e('Add gallery / Upload images', 'nggallery'); ?> </label></th> <td><select name="add_gallery" id="add_gallery"><?php wp_dropdown_roles(ngg_get_role('NextGEN Upload images')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="manage_gallery"><?php _e('Manage gallery', 'nggallery'); ?> </label></th> <td><select name="manage_gallery" id="manage_gallery"><?php wp_dropdown_roles(ngg_get_role('NextGEN Manage gallery')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="manage_others"><?php _e('Manage others gallery', 'nggallery'); ?> </label></th> <td><select name="manage_others" id="manage_others"><?php wp_dropdown_roles(ngg_get_role('NextGEN Manage others gallery')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="manage_tags"><?php _e('Manage tags', 'nggallery'); ?> </label></th> <td><select name="manage_tags" id="manage_tags"><?php wp_dropdown_roles(ngg_get_role('NextGEN Manage tags')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="edit_album"><?php _e('Edit Album', 'nggallery'); ?> </label></th> <td><select name="edit_album" id="edit_album"><?php wp_dropdown_roles(ngg_get_role('NextGEN Edit album')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="change_style"><?php _e('Change style', 'nggallery'); ?> </label></th> <td><select name="change_style" id="change_style"><?php wp_dropdown_roles(ngg_get_role('NextGEN Change style')); ?> </select></td> </tr> <tr valign="top"> <th scope="row"><label for="change_options"><?php _e('Change options', 'nggallery'); ?> </label></th> <td><select name="change_options" id="change_options"><?php wp_dropdown_roles(ngg_get_role('NextGEN Change options')); ?> </select></td> </tr> </table> <div class="submit"><input type="submit" class="button-primary" name= "update_cap" value="<?php _e('Update capabilities', 'nggallery'); ?> "/></div> </form> </div> <?php }
/** * Create array for tabs and add a filter for other plugins to inject more tabs * * @return array $tabs */ function tabs_order() { $tabs = array(); if (!empty($this->gallerylist)) { $tabs['uploadimage'] = __('Upload Images', 'nggallery'); } if (nggGallery::current_user_can('NextGEN Add new gallery')) { $tabs['addgallery'] = __('Add new gallery', 'nggallery'); } if (wpmu_enable_function('wpmuZipUpload') && nggGallery::current_user_can('NextGEN Upload a zip')) { $tabs['zipupload'] = __('Upload a Zip-File', 'nggallery'); } if (wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can('NextGEN Import image folder')) { $tabs['importfolder'] = __('Import image folder', 'nggallery'); } $tabs = apply_filters('ngg_addgallery_tabs', $tabs); return $tabs; }
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 }
/** * nggShowRelatedImages() - return related images based on category or tags * * @access public * @param string $type could be 'tags' or 'category' * @param integer $maxImages of images * @return the content */ function nggShowRelatedImages($type = '', $maxImages = 0) { $ngg_options = nggGallery::get_option('ngg_options'); if ($type == '') { $type = $ngg_options['appendType']; $maxImages = $ngg_options['maxImages']; } $sluglist = array(); switch ($type) { case 'tags': if (function_exists('get_the_tags')) { $taglist = get_the_tags(); if (is_array($taglist)) { foreach ($taglist as $tag) { $sluglist[] = $tag->slug; } } } break; case 'category': $catlist = get_the_category(); if (is_array($catlist)) { foreach ($catlist as $cat) { $sluglist[] = $cat->category_nicename; } } break; } $sluglist = implode(',', $sluglist); $out = nggShowRelatedGallery($sluglist, $maxImages); return $out; }
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 }
/** * Get the XML <item> node corresponding to one single image * * @param $image The image object */ function get_image_mrss_node($image, $indent = "\t\t") { $ngg_options = nggGallery::get_option('ngg_options'); $tags = $image->get_tags(); $tag_names = ''; foreach ($tags as $tag) { $tag_names .= $tag_names == '' ? $tag->name : ', ' . $tag->name; } $title = html_entity_decode(stripslashes($image->alttext)); $desc = html_entity_decode(stripslashes($image->description)); $thumbwidth = $ngg_options['thumbwidth']; $thumbheight = $ngg_options['thumbfix'] ? $ngg_options['thumbheight'] : $thumbwidth; $out = $indent . "<item>\n"; $out .= $indent . "\t<title><![CDATA[" . nggGallery::i18n($title, 'pic_' . $image->pid . '_alttext') . "]]></title>\n"; $out .= $indent . "\t<description><![CDATA[" . nggGallery::i18n($desc, 'pic_' . $image->pid . '_description') . "]]></description>\n"; $out .= $indent . "\t<link><![CDATA[" . $image->get_permalink() . "]]></link>\n"; $out .= $indent . "\t<guid>image-id:" . $image->pid . "</guid>\n"; $out .= $indent . "\t<media:content url='" . nextgen_esc_url($image->imageURL) . "' medium='image' />\n"; $out .= $indent . "\t<media:title><![CDATA[" . nggGallery::i18n($title, 'pic_' . $image->pid . '_alttext') . "]]></media:title>\n"; $out .= $indent . "\t<media:description><![CDATA[" . nggGallery::i18n($desc, 'pic_' . $image->pid . '_description') . "]]></media:description>\n"; $out .= $indent . "\t<media:thumbnail url='" . nextgen_esc_url($image->thumbURL) . "' width='" . $thumbwidth . "' height='" . $thumbheight . "' />\n"; $out .= $indent . "\t<media:keywords><![CDATA[" . nggGallery::i18n($tag_names) . "]]></media:keywords>\n"; $out .= $indent . "\t<media:copyright><![CDATA[Copyright (c) " . get_option("blogname") . " (" . site_url() . ")]]></media:copyright>\n"; $out .= $indent . "</item>\n"; return $out; }
/** * Create the album or gallery container * * @param integer $id (the prefix 'a' indidcates that you look for a album * @param bool $used (object will be hidden) * @return $output */ function get_container($id = 0, $used = false) { global $wpdb, $nggdb; $obj = array(); $preview_image = ''; $class = ''; // if the id started with a 'a', then it's a sub album if (substr($id, 0, 1) == 'a') { if (!($album = $this->albums[substr($id, 1)])) { return; } $obj['id'] = $album->id; $obj['name'] = $obj['title'] = $album->name; $obj['type'] = 'album'; $class = 'album_obj'; // get the post name $post = get_post($album->pageid); $obj['pagenname'] = $post == null ? '---' : $post->post_title; // for speed reason we limit it to 50 if ($this->num_albums < 50) { if ($album->previewpic != 0) { $image = $nggdb->find_image($album->previewpic); $preview_image = !is_null($image->thumbURL) ? '<div class="inlinepicture"><img src="' . esc_url($image->thumbURL) . '" /></div>' : ''; } } // this indicates that we have a album container $prefix = 'a'; } else { if (!($gallery = $nggdb->find_gallery($id))) { return; } $obj['id'] = $gallery->gid; $obj['name'] = $gallery->name; $obj['title'] = $gallery->title; $obj['type'] = 'gallery'; // get the post name $post = get_post($gallery->pageid); $obj['pagenname'] = $post == null ? '---' : $post->post_title; // for spped reason we limit it to 50 if ($this->num_galleries < 50) { // set image url $image = $nggdb->find_image($gallery->previewpic); $preview_image = isset($image->thumbURL) ? '<div class="inlinepicture"><img src="' . esc_url($image->thumbURL) . '" /></div>' : ''; } $prefix = ''; } // add class if it's in use in other albums $used = $used ? ' inUse' : ''; echo '<div id="gid-' . $prefix . $obj['id'] . '" class="groupItem' . $used . '"> <div class="innerhandle"> <div class="item_top ' . $class . '"> <a href="#" class="min" title="close">[-]</a> ID: ' . $obj['id'] . ' | ' . wp_html_excerpt(esc_html(nggGallery::i18n($obj['title'])), 25) . ' </div> <div class="itemContent"> ' . $preview_image . ' <p><strong>' . __('Name', 'nggallery') . ' : </strong>' . esc_html(nggGallery::i18n($obj['name'])) . '</p> <p><strong>' . __('Title', 'nggallery') . ' : </strong>' . esc_html(nggGallery::i18n($obj['title'])) . '</p> <p><strong>' . __('Page', 'nggallery') . ' : </strong>' . esc_html(nggGallery::i18n($obj['pagenname'])) . '</p> ' . apply_filters('ngg_display_album_item_content', '', $obj) . ' </div> </div> </div>'; }
/** * Load styles based on options defined * 20150106: added style for Qunit */ function load_styles() { //Notice stylesheet selection has this priority: //1-sytlesheet loaded from filter ngg_load_stylesheet //2-nggalery.css on folder's current theme //3-active stylesheet defined on styles. if ($css_file = nggGallery::get_theme_css_file()) { wp_enqueue_style('NextGEN', $css_file, false, '1.0.0', 'screen'); //load the framework wp_enqueue_style('NextCellent-Framework', NGGALLERY_URLPATH . 'css/framework-min.css', false, '1.0.1', 'screen'); } elseif ($this->options['activateCSS']) { //convert the path to an URL $replace = content_url(); $path = str_replace(NGG_CONTENT_DIR, $replace, $this->options['CSSfile']); wp_enqueue_style('NextGEN', $path, false, '1.0.0', 'screen'); //load the framework wp_enqueue_style('NextCellent-Framework', NGGALLERY_URLPATH . 'css/framework-min.css', false, '1.0.1', 'screen'); } // activate Thickbox if ($this->options['thumbEffect'] == 'thickbox') { wp_enqueue_style('thickbox'); } // activate modified Shutter reloaded if not use the Shutter plugin if ($this->options['thumbEffect'] == 'shutter' && !function_exists('srel_makeshutter')) { wp_enqueue_style('shutter', NGGALLERY_URLPATH . 'shutter/shutter-reloaded.css', false, '1.3.4', 'screen'); } // add qunit style if activated. I put 1.0.0 as formula, but it would mean nothing. $nxc = isset($_GET['nextcellent']) ? $_GET['nextcellent'] : ""; if ($nxc) { wp_enqueue_style("qunit", NGGALLERY_URLPATH . "css/qunit-1.16.0.css", false, '1.0.0', 'screen'); } }
/** * Copy images to another gallery * * @class nggAdmin * @param array|int $pic_ids ID's of the images * @param int $dest_gid destination gallery * @return void */ function copy_images($pic_ids, $dest_gid) { require_once NGGALLERY_ABSPATH . '/lib/meta.php'; $errors = $messages = ''; if (!is_array($pic_ids)) { $pic_ids = array($pic_ids); } // Get destination gallery $destination = nggdb::find_gallery($dest_gid); if ($destination == null) { nggGallery::show_error(__('The destination gallery does not exist', 'nggallery')); return; } // Check for folder permission if (!is_writeable(WINABSPATH . $destination->path)) { $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), WINABSPATH . $destination->path); nggGallery::show_error($message); return; } // Get pictures $images = nggdb::find_images_in_list($pic_ids); $destination_path = WINABSPATH . $destination->path; foreach ($images as $image) { // WPMU action if (nggWPMU::check_quota()) { return; } $i = 0; $tmp_prefix = ''; $destination_file_name = $image->filename; while (file_exists($destination_path . '/' . $destination_file_name)) { $tmp_prefix = 'copy_' . $i++ . '_'; $destination_file_name = $tmp_prefix . $image->filename; } $destination_file_path = $destination_path . '/' . $destination_file_name; $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name; // Copy files if (!@copy($image->imagePath, $destination_file_path)) { $errors .= sprintf(__('Failed to copy image %1$s to %2$s', 'nggallery'), $image->filename, $destination_file_path) . '<br />'; continue; } // Copy backup file, if possible @copy($image->imagePath . '_backup', $destination_file_path . '_backup'); // Copy the thumbnail if possible @copy($image->thumbPath, $destination_thumb_file_path); // Create new database entry for the image $new_pid = nggdb::insert_image($destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude); if (!isset($new_pid)) { $errors .= sprintf(__('Failed to copy database row for picture %s', 'nggallery'), $image->pid) . '<br />'; continue; } // Copy tags nggTags::copy_tags($image->pid, $new_pid); // Copy meta information $meta = new nggMeta($image->pid); nggdb::update_image_meta($new_pid, $meta->image->meta_data); if ($tmp_prefix != '') { $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) » 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; }
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 }
/** * Check for extended capabilites and echo disabled="disabled" for input form * * @since 1.5.0 * @param string $capability * @return void */ static function current_user_can_form($capability) { if (!nggGallery::current_user_can($capability)) { echo 'disabled="disabled"'; } }
// get the gallery id $galleryID = (int) $_GET['gid']; // get the pictures if ($galleryID == 0) { $thepictures = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 ORDER BY tt.{$ngg_options['galSort']} {$ngg_options['galSortDir']} "); } else { $thepictures = $wpdb->get_results("SELECT t.*, tt.* FROM {$wpdb->nggallery} AS t INNER JOIN {$wpdb->nggpictures} AS tt ON t.gid = tt.galleryid WHERE t.gid = '{$galleryID}' AND tt.exclude != 1 ORDER BY tt.{$ngg_options['galSort']} {$ngg_options['galSortDir']} "); } // Create XML output header("content-type:text/xml;charset=utf-8"); echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n"; echo "\t<title>" . stripslashes(nggGallery::i18n($thepictures[0]->name)) . "</title>\n"; echo "\t<trackList>\n"; if (is_array($thepictures)) { foreach ($thepictures as $picture) { echo "\t\t<track>\n"; if (!empty($picture->description)) { echo "\t\t\t<title>" . strip_tags(stripslashes(html_entity_decode(nggGallery::i18n($picture->description)))) . "</title>\n"; } else { if (!empty($picture->alttext)) { echo "\t\t\t<title>" . stripslashes(nggGallery::i18n($picture->alttext)) . "</title>\n"; } else { echo "\t\t\t<title>" . $picture->filename . "</title>\n"; } } echo "\t\t\t<location>" . $siteurl . "/" . $picture->path . "/" . $picture->filename . "</location>\n"; echo "\t\t</track>\n"; } } echo "\t</trackList>\n"; echo "</playlist>\n";
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 }
/** * 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; }