function translate_image($entity) { if (!empty($entity->description)) { $entity->description = M_I18N::translate($entity->description, 'pic_' . $entity->{$entity->id_field} . '_description'); } if (!empty($entity->alttext)) { $entity->alttext = M_I18N::translate($entity->alttext, 'pic_' . $entity->{$entity->id_field} . '_alttext'); } }
function translate_gallery($entity) { if (!empty($entity->title)) { $entity->title = M_I18N::translate($entity->title, 'gallery_' . $entity->{$entity->id_field} . '_name'); } if (!empty($entity->galdesc)) { $entity->galdesc = M_I18N::translate($entity->galdesc, 'gallery_' . $entity->{$entity->id_field} . '_description'); } }
public function set_defaults($entity) { $this->call_parent('set_defaults', $entity); if (!is_admin()) { if (!empty($entity->description)) { $entity->description = M_I18N::translate($entity->description, 'pic_' . $entity->{$entity->id_field} . '_description'); } if (!empty($entity->alttext)) { $entity->alttext = M_I18N::translate($entity->alttext, 'pic_' . $entity->{$entity->id_field} . '_alttext'); } } }
function translate_album($entity) { if (!empty($entity->name)) { $entity->name = M_I18N::translate($entity->name, 'album_' . $entity->{$entity->id_field} . '_name'); } if (!empty($entity->albumdesc)) { $entity->albumdesc = M_I18N::translate($entity->albumdesc, 'album_' . $entity->{$entity->id_field} . '_description'); } // these fields are set when the album is a child to another album if (!empty($entity->title)) { $entity->title = M_I18N::translate($entity->title, 'album_' . $entity->{$entity->id_field} . '_name'); } if (!empty($entity->galdesc)) { $entity->galdesc = M_I18N::translate($entity->galdesc, 'album_' . $entity->{$entity->id_field} . '_description'); } }
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 = !empty($_GET['items']) ? $_GET['items'] : apply_filters('ngg_manage_images_items_per_page', 50); if ($items_per_page == 'all') { $items_per_page = PHP_INT_MAX; } else { $items_per_page = (int) $items_per_page; } $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, 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"); }); } function setURLParam(param, paramVal) { var url = window.location.href; var params = ""; var tmp = ""; var tmpArray = url.split("?"); var base = tmpArray[0]; var additional = tmpArray[1]; if (additional) { tmpArray = additional.split("&"); for (i = 0; i < tmpArray.length; i++) { if (tmpArray[i].split('=')[0] != param) { params += tmp + tmpArray[i]; tmp = "&"; } } } return base + "?" + params + tmp + "" + param + "=" + paramVal; } jQuery(function (){ jQuery('span.tooltip, label.tooltip').tooltip(); jQuery('#ngg-manage-images-items-per-page').on('change', function() { window.location.href = setURLParam('items', jQuery(this).val()); }); // 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', 'left': 0 // WP 4.4 compatibility; it assigns left:-9999em by default to row-actions }); } ); $(this).data('ready', true); }); //--> </script> <div class="wrap"> <?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(M_I18N::translate($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" class="meta-box-sortables"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <div class="handlediv" title="<?php esc_attr_e('Click to toggle'); ?> "><br/></div> <h3 class="hndl"><span><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></span></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); $items_per_page_array = apply_filters('ngg_manage_images_items_per_page_array', array('25' => __(' 25', 'nggallery'), '50' => __(' 50', 'nggallery'), '75' => __(' 75', 'nggallery'), '100' => __('100', 'nggallery'), '200' => __('200', 'nggallery'), 'all' => __('All', 'nggallery'))); ?> <select id="ngg-manage-images-items-per-page"> <?php foreach ($items_per_page_array as $val => $label) { ?> <?php $selected = ''; if (!empty($_GET['items']) && $val == $_GET['items']) { $selected = 'selected'; } elseif (empty($_GET['items']) && $val == $items_per_page) { $selected = 'selected'; } ?> <option value="<?php echo esc_attr($val); ?> " <?php echo $selected; ?> > <?php echo esc_html($label); ?> </option> <?php } ?> </select> <label id="ngg-manage-images-items-per-page-label" for="ngg-manage-images-items-per-page"><?php echo __('Images per page:', 'nggallery'); ?> </label> <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(); $gallery_mapper = C_Gallery_Mapper::get_instance(); if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } foreach ($picturelist as $picture) { if (empty($gallery) && $is_search) { $gallery = $gallery_mapper->find($picture->galleryid, FALSE); } //for search result we need to check the capatibiliy if (!nggAdmin::can_manage_this_gallery($gallery->author) && $is_search) { continue; } $counter++; $picture->imageURL = $storage->get_image_url($picture); $picture->thumbURL = $storage->get_thumb_url($picture); $picture->imagePath = $storage->get_image_abspath($picture); $picture->thumbPath = $storage->get_thumb_abspath($picture); echo apply_filters('ngg_manage_images_row', $picture, $counter); } } // In the case you have no capaptibility to see the search result if ($counter == 0) { echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?> " /> <?php $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_images, $items_per_page); ?> </div> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="entertags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e('Select the destination gallery:', 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo esc_attr(stripslashes($gallery->title)); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td> <?php include dirname(__FILE__) . '/thumbnails-template.php'; ?> </td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
function 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 }
/** * 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->_get_album(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) { $thumbURL = ""; if ($album->previewpic) { $image = $nggdb->find_image($album->previewpic); if ($image) { $thumbURL = @add_query_arg('timestamp', time(), $image->thumbURL); } } $preview_image = $thumbURL ? '<div class="inlinepicture"><img rel="' . $album->previewpic . '" src="' . nextgen_esc_url($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 $thumbURL = ""; if ($gallery->previewpic) { $image = $nggdb->find_image($gallery->previewpic); $thumbURL = @add_query_arg('timestamp', time(), $image->thumbURL); } $preview_image = !is_null($thumbURL) ? '<div class="inlinepicture"><img rel="' . $gallery->previewpic . '" src="' . nextgen_esc_url($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(M_I18N::translate($obj['title'])), 25) . ' </div> <div class="itemContent"> ' . $preview_image . ' <p><strong>' . __('Name', 'nggallery') . ' : </strong>' . esc_html(M_I18N::translate($obj['name'])) . '</p> <p><strong>' . __('Title', 'nggallery') . ' : </strong>' . esc_html(M_I18N::translate($obj['title'])) . '</p> <p><strong>' . __('Page', 'nggallery') . ' : </strong>' . esc_html(M_I18N::translate($obj['pagenname'])) . '</p> ' . apply_filters('ngg_display_album_item_content', '', $obj) . ' </div> </div> </div>'; }
?> " title="<?php echo stripslashes(M_I18N::translate($image->description, 'pic_' . $image->pid . '_description')); ?> " <?php echo $effect_code; ?> > <img title="<?php echo stripslashes(M_I18N::translate($image->alttext, 'pic_' . $image->pid . '_alttext')); ?> " alt="<?php echo stripslashes(M_I18N::translate($image->alttext, 'pic_' . $image->pid . '_alttext')); ?> " data-image-id="<?php echo esc_attr($image->{$image->id_field}); ?> " src="<?php echo $image->thumbURL; ?> "/> </a> <?php } ?> </div>
/** * Get the XML <item> node corresponding to one single image * * @param $image The image object */ function get_image_mrss_node($image, $indent = "\t\t") { $settings = C_NextGen_Settings::get_instance(); $storage = C_Gallery_Storage::get_instance(); $tags = wp_get_object_terms($image->pid, 'ngg_tag', 'fields=names'); if (is_array($tags)) { $tags = implode(', ', $tags); } $title = html_entity_decode(stripslashes($image->alttext)); $desc = html_entity_decode(stripslashes($image->description)); $image_url = $storage->get_image_url($image); $thumb_url = $storage->get_thumb_url($image); $thumbwidth = 80; $thumbheight = 80; if ($dimensions = $storage->get_thumb_dimensions($image)) { $thumbwidth = $dimensions['width']; $thumbheight = $dimensions['height']; } $out = $indent . "<item>\n"; $out .= $indent . "\t<title><![CDATA[" . M_I18N::translate($title, 'pic_' . $image->pid . '_alttext') . "]]></title>\n"; $out .= $indent . "\t<description><![CDATA[" . M_I18N::translate($desc, 'pic_' . $image->pid . '_description') . "]]></description>\n"; $out .= $indent . "\t<link><![CDATA[" . nextgen_esc_url($image_url) . "]]></link>\n"; $out .= $indent . "\t<guid>image-id:" . $image->pid . "</guid>\n"; $out .= $indent . "\t<media:content url='" . nextgen_esc_url($image_url) . "' medium='image' />\n"; $out .= $indent . "\t<media:title><![CDATA[" . M_I18N::translate($title, 'pic_' . $image->pid . '_alttext') . "]]></media:title>\n"; $out .= $indent . "\t<media:description><![CDATA[" . M_I18N::translate($desc, 'pic_' . $image->pid . '_description') . "]]></media:description>\n"; $out .= $indent . "\t<media:thumbnail url='" . nextgen_esc_url($thumb_url) . "' width='" . $thumbwidth . "' height='" . $thumbheight . "' />\n"; $out .= $indent . "\t<media:keywords><![CDATA[" . esc_html(M_I18N::translate($tags)) . "]]></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; }