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 }
function nggallery_picturelist($controller) { // *** show picture list global $wpdb, $nggdb, $user_ID, $ngg; // Look if its a search result $is_search = isset($_GET['s']) ? true : false; $counter = 0; $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images'); if ($is_search) { // fetch the imagelist $picturelist = $ngg->manage_page->search_result; // we didn't set a gallery or a pagination $act_gid = 0; $_GET['paged'] = 1; $page_links = false; } else { // GET variables $act_gid = $ngg->manage_page->gid; // Load the gallery metadata $mapper = C_Gallery_Mapper::get_instance(); $gallery = $mapper->find($act_gid); if (!$gallery) { nggGallery::show_error(__('Gallery not found.', 'nggallery')); return; } // Check if you have the correct capability if (!nggAdmin::can_manage_this_gallery($gallery->author)) { nggGallery::show_error(__('Sorry, you have no access here', 'nggallery')); return; } // look for pagination $_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1; $items_per_page = 50; $start = ($_GET['paged'] - 1) * $items_per_page; // get picture values $image_mapper = C_Image_Mapper::get_instance(); $total_number_of_images = count($image_mapper->select($image_mapper->get_primary_key_column())->where(array("galleryid = %d", $act_gid))->run_query(FALSE, TRUE)); $picturelist = $image_mapper->select()->where(array("galleryid = %d", $act_gid))->order_by($ngg->options['galSort'], $ngg->options['galSortDir'])->limit($items_per_page, $start)->run_query(); // get the current author $act_author_user = get_userdata((int) $gallery->author); } // list all galleries $gallerylist = $nggdb->find_all_galleries(); //get the columns $image_columns = $wp_list_table->get_columns(); $hidden_columns = get_hidden_columns('nggallery-manage-images'); $num_columns = count($image_columns) - count($hidden_columns); $attr = nggGallery::current_user_can('NextGEN Edit gallery options') ? '' : 'disabled="disabled"'; ?> <script type="text/javascript"> <!-- function showDialog( windowId, title ) { var form = document.getElementById('updategallery'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value; else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // now show the dialog jQuery( "#" + windowId ).dialog({ width: 640, resizable : false, modal: true, title: title, position: { my: 'center', at: 'center', of: window.parent } }); jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); }); } jQuery(function (){ jQuery('span.tooltip, label.tooltip').tooltip(); // load a content via ajax jQuery('a.ngg-dialog').click(function() { var dialogs = jQuery('.ngg-overlay-dialog:visible'); if (dialogs.size() > 0) { return false; } if ( jQuery( "#spinner" ).length == 0) { jQuery("body").append('<div id="spinner"></div>'); } var $this = jQuery(this); var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href); var width = ( results ) ? results[1] : 600; var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href); var height = ( results ) ? results[1] : 440; var container = window; if (window.parent) { container = window.parent; } jQuery('#spinner').fadeIn(); jQuery('#spinner').position({ my: "center", at: "center", of: container }); var dialog = jQuery('<div class="ngg-overlay-dialog" style="display:hidden"></div>').appendTo('body'); // load the remote content dialog.load( this.href, {}, function () { jQuery('#spinner').hide(); dialog.dialog({ title: ($this.attr('title')) ? $this.attr('title') : '', position: { my: "center", at: "center", of: container }, width: width, height: height, modal: true, resizable: false, close: function() { dialog.remove(); } }).width(width - 30).height(height - 30); } ); //prevent the browser to follow the link return false; }); }); function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('updategallery')); if (typeof document.activeElement == "undefined" && document.addEventListener) { document.addEventListener("focus", function (e) { document.activeElement = e.target; }, true); } if ( document.activeElement.name == 'post_paged' ) return true; if(numchecked < 1) { alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?> '); return false; } actionId = jQuery('#bulkaction').val(); switch (actionId) { case "copy_to": showDialog('selectgallery', '<?php echo esc_js(__('Copy image to...', 'nggallery')); ?> '); return false; break; case "move_to": showDialog('selectgallery', '<?php echo esc_js(__('Move image to...', 'nggallery')); ?> '); return false; break; case "add_tags": showDialog('entertags', '<?php echo esc_js(__('Add new tags', 'nggallery')); ?> '); return false; break; case "delete_tags": showDialog('entertags', '<?php echo esc_js(__('Delete tags', 'nggallery')); ?> '); return false; break; case "overwrite_tags": showDialog('entertags', '<?php echo esc_js(__('Overwrite', 'nggallery')); ?> '); return false; break; case "resize_images": showDialog('resize_images', '<?php echo esc_js(__('Resize images', 'nggallery')); ?> '); return false; break; case "new_thumbnail": showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails', 'nggallery')); ?> '); return false; break; } return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } jQuery(document).ready( function($) { if ($(this).data('ready')) return; // close postboxes that should be closed jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); postboxes.add_postbox_toggles('ngg-manage-gallery'); jQuery('.iedit').mouseover( function(e){ jQuery(this).parent().find('.row-actions').css('visibility', 'hidden'); jQuery(this).next('.row_actions:first').find('.row-actions:first').css('visibility', 'visible'); } ); $(this).data('ready', true); }); //--> </script> <div class="wrap"> <?php //include('templates/social_media_buttons.php'); screen_icon('nextgen-gallery'); if ($is_search) { ?> <h2><?php printf(__('Search results for “%s”', 'nggallery'), esc_html(get_search_query())); ?> </h2> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="media-search-input"><?php _e('Search Images', 'nggallery'); ?> :</label> <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" /> <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search Images', 'nggallery'); ?> " class="button" /> </p> </form> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&s=' . get_search_query(); ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php } else { ?> <h2><?php echo _n('Gallery', 'Galleries', 1, 'nggallery'); ?> : <?php echo esc_html(nggGallery::i18n($gallery->title)); ?> </h2> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&gid=' . $act_gid . '&paged=' . esc_attr($_GET['paged']); ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php if (nggGallery::current_user_can('NextGEN Edit gallery options')) { ?> <div id="poststuff"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <h3><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></h3> <div class="inside"> <?php $controller->render_gallery_fields(); ?> <div class="submit"> <?php if (wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can('NextGEN Import image folder')) { ?> <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images", 'nggallery'); ?> " /> <?php } ?> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /> </div> </div> </div> </div> <!-- poststuff --> <?php } ?> <?php } ?> <div class="tablenav top ngg-tablenav"> <?php $ngg->manage_page->pagination('top', $_GET['paged'], $total_number_of_images, $items_per_page); ?> <div class="alignleft actions"> <select id="bulkaction" name="bulkaction"> <option value="no_action" ><?php _e("Bulk actions", 'nggallery'); ?> </option> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="recover_images" ><?php _e("Recover from backup", 'nggallery'); ?> </option> <option value="delete_images" ><?php _e("Delete images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="rotate_cw" ><?php _e("Rotate images clockwise", 'nggallery'); ?> </option> <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise", 'nggallery'); ?> </option> <option value="copy_to" ><?php _e("Copy to...", 'nggallery'); ?> </option> <option value="move_to"><?php _e("Move to...", 'nggallery'); ?> </option> <option value="add_tags" ><?php _e("Add tags", 'nggallery'); ?> </option> <option value="delete_tags" ><?php _e("Delete tags", 'nggallery'); ?> </option> <option value="overwrite_tags" ><?php _e("Overwrite tags", 'nggallery'); ?> </option> </select> <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php if ($ngg->options['galSort'] == "sortorder" && !$is_search) { ?> <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery'); ?> " /> <?php } ?> <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery'); ?> " /> </div> </div> <table id="ngg-listimages" class="widefat fixed" cellspacing="0" > <thead> <?php $controller->render_image_row_header(); ?> </thead> <tfoot> <?php $controller->render_image_row_header(); ?> </tfoot> <tbody id="the-list"> <?php if ($picturelist) { $thumbsize = ''; $storage = C_Gallery_Storage::get_instance(); if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } foreach ($picturelist as $picture) { //for search result we need to check the capatibiliy if (!nggAdmin::can_manage_this_gallery($gallery->author) && $is_search) { continue; } $counter++; $picture->imageURL = $storage->get_image_url($picture); $picture->thumbURL = $storage->get_thumb_url($picture); $picture->imagePath = $storage->get_image_abspath($picture); $picture->thumbPath = $storage->get_thumb_abspath($picture); echo apply_filters('ngg_manage_images_row', $picture, $counter); } } // In the case you have no capaptibility to see the search result if ($counter == 0) { echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?> " /> <?php $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_images, $items_per_page); ?> </div> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="entertags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e('Select the destination gallery:', 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo esc_attr(stripslashes($gallery->title)); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td> <?php include dirname(__FILE__) . '/thumbnails-template.php'; ?> </td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
function 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; }
/** * 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; }
// 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";
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @todo Needs to be better, without the mess to call to the database, but this requires a better database API. * * @param array $args Widget arguments. * @param array $instance Saved values from the database. */ public function widget($args, $instance) { $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base); global $wpdb; $items = min($instance['items'], $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->nggpictures} WHERE exclude != 1 ")); $exclude = $instance['exclude']; $list = $instance['list']; $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})"; } } 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}"); } echo $args['before_widget'] . $args['before_title'] . $title . $args['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($args['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 . '>'; 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 $args['after_widget']; }
/** * 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>'; }
// 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, 'pic_' . $picture->pid . '_description')))) . "</title>\n"; } else { if (!empty($picture->alttext)) { echo "\t\t\t<title>" . stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_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 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; } }
/** * Lazy-loader for image variables. * * @param string $name Parameter name * @return mixed */ public function __get($name) { if (isset($this->_cache_overrides[$name])) { return $this->_cache_overrides[$name]; } // at the bottom we default to returning $this->_cache[$name]. switch ($name) { case 'alttext': $this->_cache['alttext'] = empty($this->_cache['alttext']) ? ' ' : html_entity_decode(stripslashes(nggGallery::i18n($this->_cache['alttext'], 'pic_' . $this->__get('id') . '_alttext'))); return $this->_cache['alttext']; case 'author': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['author'] = $gallery->name; return $this->_cache['author']; case 'caption': $caption = html_entity_decode(stripslashes(nggGallery::i18n($this->__get('description'), 'pic_' . $this->__get('id') . '_description'))); if (empty($caption)) { $caption = ' '; } $this->_cache['caption'] = $caption; return $this->_cache['caption']; case 'description': $this->_cache['description'] = empty($this->_cache['description']) ? ' ' : html_entity_decode(stripslashes(nggGallery::i18n($this->_cache['description'], 'pic_' . $this->__get('id') . '_description'))); return $this->_cache['description']; case 'galdesc': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['galdesc'] = $gallery->name; return $this->_cache['galdesc']; case 'gid': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['gid'] = $gallery->name; return $this->_cache['gid']; case 'href': return $this->__get('imageHTML'); case 'id': return $this->_orig_image_id; case 'imageHTML': $tmp = '<a href="' . $this->__get('imageURL') . '" title="' . htmlspecialchars(stripslashes(nggGallery::i18n($this->__get('description'), 'pic_' . $this->__get('id') . '_description'))) . '" ' . $this->get_thumbcode($this->__get('name')) . '>' . '<img alt="' . $this->__get('alttext') . '" src="' . $this->__get('imageURL') . '"/>' . '</a>'; $this->_cache['href'] = $tmp; $this->_cache['imageHTML'] = $tmp; return $this->_cache['imageHTML']; case 'imagePath': $storage = $this->get_storage(); $this->_cache['imagePath'] = $storage->get_image_abspath($this->_orig_image, 'full'); return $this->_cache['imagePath']; case 'imageURL': $storage = $this->get_storage(); $this->_cache['imageURL'] = $storage->get_image_url($this->_orig_image, 'full'); return $this->_cache['imageURL']; case 'linktitle': $this->_cache['linktitle'] = htmlspecialchars(stripslashes(nggGallery::i18n($this->__get('description'), 'pic_' . $this->__get('id') . '_description'))); return $this->_cache['linktitle']; case 'name': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['name'] = $gallery->name; return $this->_cache['name']; case 'pageid': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['pageid'] = $gallery->name; return $this->_cache['pageid']; case 'path': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['path'] = $gallery->name; return $this->_cache['path']; case 'permalink': $this->_cache['permalink'] = $this->__get('imageURL'); return $this->_cache['permalink']; case 'pid': return $this->_orig_image_id; case 'pidlink': $application = C_Component_Registry::get_instance()->get_utility('I_Router')->get_routed_app(); $controller = C_Component_Registry::get_instance()->get_utility('I_Display_Type_Controller'); $this->_cache['pidlink'] = $controller->set_param_for($application->get_routed_url(TRUE), 'pid', $this->__get('image_slug')); return $this->_cache['pidlink']; case 'previewpic': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['previewpic'] = $gallery->name; return $this->_cache['previewpic']; case 'size': if (is_string($this->_orig_image->meta_data)) { $this->_orig_image = C_Image_Mapper::get_instance()->unserialize($this->_orig_image->meta_data); } $w = $this->_orig_image->meta_data['thumbnail']['width']; $h = $this->_orig_image->meta_data['thumbnail']['height']; return "width='{$w}' height='{$h}'"; case 'slug': if ($this->_legacy) { $gallery = $this->get_legacy_gallery($this->__get('galleryid')); } else { $gallery_map = $this->get_gallery($this->__get('galleryid')); $gallery = $gallery_map->find($this->__get('galleryid')); } $this->_cache['slug'] = $gallery->name; return $this->_cache['slug']; case 'tags': $this->_cache['tags'] = wp_get_object_terms($this->__get('id'), 'ngg_tag', 'fields=all'); return $this->_cache['tags']; case 'thumbHTML': $tmp = '<a href="' . $this->__get('imageURL') . '" title="' . htmlspecialchars(stripslashes(nggGallery::i18n($this->__get('description'), 'pic_' . $this->__get('id') . '_description'))) . '" ' . $this->get_thumbcode($this->__get('name')) . '>' . '<img alt="' . $this->__get('alttext') . '" src="' . $this->thumbURL . '"/>' . '</a>'; $this->_cache['href'] = $tmp; $this->_cache['thumbHTML'] = $tmp; return $this->_cache['thumbHTML']; case 'thumbPath': $storage = $this->get_storage(); $this->_cache['thumbPath'] = $storage->get_image_abspath($this->_orig_image, 'thumbnail'); return $this->_cache['thumbPath']; case 'thumbnailURL': $storage = $this->get_storage(); $this->_cache['thumbnailURL'] = $storage->get_thumb_url($this->_orig_image); return $this->_cache['thumbnailURL']; case 'thumbcode': $this->_cache['thumbcode'] = $this->get_thumbcode($this->__get('name')); return $this->_cache['thumbcode']; case 'thumbURL': return $this->__get('thumbnailURL'); case 'title': $this->_cache['title'] = stripslashes($this->__get('name')); return $this->_cache['title']; case 'url': $storage = $this->get_storage(); $this->_cache['url'] = $storage->get_image_url($this->_orig_image, 'full'); return $this->_cache['url']; default: return $this->_cache[$name]; } }
?> " title="<?php echo stripslashes(nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description')); ?> " <?php echo $effect_code; ?> > <img title="<?php echo stripslashes(nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext')); ?> " alt="<?php echo stripslashes(nggGallery::i18n($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>
function get_href_thumb_link() { // create the a href link with the thumbanil $this->href = "\n" . '<a href="' . $this->imageURL . '" title="' . htmlspecialchars(stripslashes(nggGallery::i18n($this->description, 'pic_' . $this->pid . '_description'))) . '" ' . $this->get_thumbcode($this->name) . '>' . "\n\t"; $this->href .= '<img alt="' . $this->alttext . '" src="' . $this->thumbURL . '"/>' . "\n" . '</a>' . "\n"; return $this->href; }
} global $wpdb, $ngg, $nggdb, $wp_query; //$albumlist= $nggdb->find_all_albums('aid', 'asc', TRUE, 25, $start, false); //$piclist = $nggdb->find_all_galleries('gid', 'asc', TRUE, 25, $start, false); $ngg_options = get_option('ngg_options'); $siteurl = site_url(); // get the gallery id $picID = (int) $_GET['gid']; // get the pictures if ($picID == 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 = '{$picID}' 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 "<gallery>\n"; if ($thepictures) { foreach ($thepictures as $pic) { $class = !isset($class) || $class == 'class="alternate"' ? '' : 'class="alternate"'; $gid = $pic->gid; $name = empty($pic->title) ? $pic->name : $pic->title; echo "\t<picture>\n"; echo "\t\t\t<title>" . $pic->alttext . "</title>\n"; echo "\t\t\t<description>" . $pic->description . "</description>\n"; echo "\t\t\t<url>" . $siteurl . "/" . $pic->path . "/" . $pic->filename . "</url>\n"; echo "\t\t\t<thumbnail>" . esc_url(nggGallery::i18n($pic->thumbURL)) . "</thumbnail>\n"; echo "\t</picture>\n"; } } echo "</gallery>\n";
function nggallery_picturelist() { // *** show picture list global $wpdb, $nggdb, $user_ID, $ngg; // Look if its a search result $is_search = isset($_GET['s']) ? true : false; if ($is_search) { // fetch the imagelist $picturelist = $ngg->manage_page->search_result; // we didn't set a gallery or a pagination $act_gid = 0; $_GET['paged'] = 1; $page_links = false; } else { // GET variables $act_gid = $ngg->manage_page->gid; // Load the gallery metadata $gallery = $nggdb->find_gallery($act_gid); if (!$gallery) { nggGallery::show_error(__('Gallery not found.', 'nggallery')); return; } // Check if you have the correct capability if (!nggAdmin::can_manage_this_gallery($gallery->author)) { nggGallery::show_error(__('Sorry, you have no access here', 'nggallery')); return; } // look for pagination if (!isset($_GET['paged']) || $_GET['paged'] < 1) { $_GET['paged'] = 1; } $start = ($_GET['paged'] - 1) * 50; // get picture values $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start); // build pagination $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $nggdb->paged['max_objects_per_page'], 'current' => $_GET['paged'])); // get the current author $act_author_user = get_userdata((int) $gallery->author); } // list all galleries $gallerylist = $nggdb->find_all_galleries(); //get the columns $gallery_columns = ngg_manage_gallery_columns(); $hidden_columns = get_hidden_columns('nggallery-manage-images'); $num_columns = count($gallery_columns) - count($hidden_columns); ?> <!--[if IE]> <style type="text/css"> .custom_thumb { display : none; } </style> <![endif]--> <script type="text/javascript"> <!-- function showDialog( windowId, height ) { var form = document.getElementById('updategallery'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // console.log (jQuery("#TB_imagelist").val()); tb_show("", "#TB_inline?width=640&height=" + height + "&inlineId=" + windowId + "&modal=true", false); } function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('updategallery')); if(numchecked < 1) { alert('<?php echo js_escape(__('No images selected', 'nggallery')); ?> '); return false; } actionId = jQuery('#bulkaction').val(); switch (actionId) { case "copy_to": case "move_to": showDialog('selectgallery', 120); return false; break; case "add_tags": case "delete_tags": case "overwrite_tags": showDialog('entertags', 120); return false; break; case "resize_images": showDialog('resize_images', 120); return false; break; case "new_thumbnail": showDialog('new_thumbnail', 160); return false; break; } return confirm('<?php echo sprintf(js_escape(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } jQuery(document).ready( function() { // close postboxes that should be closed jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); postboxes.add_postbox_toggles('ngg-manage-gallery'); }); //--> </script> <div class="wrap"> <?php if ($is_search) { ?> <h2><?php printf(__('Search results for “%s”', 'nggallery'), wp_specialchars(get_search_query())); ?> </h2> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="media-search-input"><?php _e('Search Images', 'nggallery'); ?> :</label> <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" /> <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search Images', 'nggallery'); ?> " class="button" /> </p> </form> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&s=' . $_GET['s']; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <?php } else { ?> <h2><?php echo _n('Gallery', 'Galleries', 1, 'nggallery'); ?> : <?php echo nggGallery::i18n($gallery->title); ?> </h2> <br style="clear: both;" /> <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&mode=edit&gid=' . $act_gid . '&paged=' . $_GET['paged']; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_updategallery'); ?> <input type="hidden" name="page" value="manage-images" /> <div id="poststuff"> <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?> " > <h3><?php _e('Gallery settings', 'nggallery'); ?> <small> (<?php _e('Click here for more settings', 'nggallery'); ?> )</small></h3> <div class="inside"> <table class="form-table" > <tr> <th align="left"><?php _e('Title'); ?> :</th> <th align="left"><input type="text" size="50" name="title" value="<?php echo $gallery->title; ?> " /></th> <th align="right"><?php _e('Page Link to', 'nggallery'); ?> :</th> <th align="left"> <select name="pageid" style="width:95%"> <option value="0" ><?php _e('Not linked', 'nggallery'); ?> </option> <?php parent_dropdown($gallery->pageid); ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Description'); ?> :</th> <th align="left"><textarea name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php echo $gallery->galdesc; ?> </textarea></th> <th align="right"><?php _e('Preview image', 'nggallery'); ?> :</th> <th align="left"> <select name="previewpic" style="width:95%" > <option value="0" ><?php _e('No Picture', 'nggallery'); ?> </option> <?php if (is_array($picturelist)) { foreach ($picturelist as $picture) { $selected = $picture->pid == $gallery->previewpic ? 'selected="selected" ' : ''; echo '<option value="' . $picture->pid . '" ' . $selected . '>' . $picture->pid . ' - ' . $picture->filename . '</option>' . "\n"; } } ?> </select> </th> </tr> <tr> <th align="left"><?php _e('Path', 'nggallery'); ?> :</th> <th align="left"><input <?php if (IS_WPMU) { echo 'readonly = "readonly"'; } ?> type="text" size="50" name="path" value="<?php echo $gallery->path; ?> " /></th> <th align="right"><?php _e('Author', 'nggallery'); ?> :</th> <th align="left"> <?php $editable_ids = $ngg->manage_page->get_editable_user_ids($user_ID); if ($editable_ids && count($editable_ids) > 1) { wp_dropdown_users(array('include' => $editable_ids, 'name' => 'author', 'selected' => empty($gallery->author) ? 0 : $gallery->author)); } else { echo $act_author_user->display_name; } ?> </th> </tr> <?php if (current_user_can("publish_pages")) { ?> <tr> <th align="left"> </th> <th align="left"> </th> <th align="right"><?php _e('Create new page', 'nggallery'); ?> :</th> <th align="left"> <select name="parent_id" style="width:95%"> <option value="0"><?php _e('Main page (No parent)', 'nggallery'); ?> </option> <?php parent_dropdown(); ?> </select> <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e('Add page', 'nggallery'); ?> " id="group"/> </th> </tr> <?php } ?> </table> <div class="submit"> <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images", 'nggallery'); ?> " /> <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /> </div> </div> </div> </div> <!-- poststuff --> <?php } ?> <div class="tablenav ngg-tablenav"> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links); echo $page_links_text; ?> </div> <?php } ?> <div class="alignleft actions"> <select id="bulkaction" name="bulkaction"> <option value="no_action" ><?php _e("No action", 'nggallery'); ?> </option> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="delete_images" ><?php _e("Delete images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="rotate_cw" ><?php _e("Rotate images clockwise", 'nggallery'); ?> </option> <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise", 'nggallery'); ?> </option> <option value="copy_to" ><?php _e("Copy to...", 'nggallery'); ?> </option> <option value="move_to"><?php _e("Move to...", 'nggallery'); ?> </option> <option value="add_tags" ><?php _e("Add tags", 'nggallery'); ?> </option> <option value="delete_tags" ><?php _e("Delete tags", 'nggallery'); ?> </option> <option value="overwrite_tags" ><?php _e("Overwrite tags", 'nggallery'); ?> </option> </select> <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php if ($ngg->options['galSort'] == "sortorder" && !$is_search) { ?> <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery'); ?> " /> <?php } ?> <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery'); ?> " /> </div> </div> <table id="ngg-listimages" class="widefat fixed" cellspacing="0" > <thead> <tr> <?php print_column_headers('nggallery-manage-images'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('nggallery-manage-images', false); ?> </tr> </tfoot> <tbody> <?php if ($picturelist) { $thumbsize = ''; $counter = 0; if ($ngg->options['thumbfix']) { $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"'; } foreach ($picturelist as $picture) { //for search result we need to check the capatibiliy if (!nggAdmin::can_manage_this_gallery($picture->author) && $is_search) { continue; } $counter++; $pid = (int) $picture->pid; $alternate = !isset($alternate) || $alternate == 'alternate' ? '' : 'alternate'; $exclude = $picture->exclude ? 'checked="checked"' : ''; $date = mysql2date(get_option('date_format'), $picture->imagedate); $time = mysql2date(get_option('time_format'), $picture->imagedate); ?> <tr id="picture-<?php echo $pid; ?> " class="<?php echo $alternate; ?> iedit" valign="top"> <?php foreach ($gallery_columns as $gallery_column_key => $column_display_name) { $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\""; $style = ''; if (in_array($gallery_column_key, $hidden_columns)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($gallery_column_key) { case 'cb': ?> <th <?php echo $attributes; ?> scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid; ?> " /></th> <?php break; case 'id': ?> <td <?php echo $attributes; ?> scope="row" style=""><?php echo $pid; ?> <input type="hidden" name="pid[]" value="<?php echo $pid; ?> " /> </td> <?php break; case 'filename': ?> <td <?php echo $attributes; ?> > <strong><a href="<?php echo $picture->imageURL; ?> " class="thickbox" title="<?php echo $picture->filename; ?> "> <?php echo empty($picture->alttext) ? $picture->filename : stripslashes(nggGallery::i18n($picture->alttext)); ?> </a></strong> <br /><?php echo $date; ?> <?php if (!empty($picture->meta_data)) { ?> <br /><?php echo $picture->meta_data['width']; ?> x <?php echo $picture->meta_data['height']; ?> <?php _e('pixel', 'nggallery'); ?> <?php } ?> <p> <?php $actions = array(); //TODO:Add a JS edit option //$actions['edit'] = '<a class="editinline" href="#">' . __('Edit') . '</a>'; $actions['view'] = '<a class="thickbox" href="' . $picture->imageURL . '" title="' . esc_attr(sprintf(__('View "%s"'), $picture->filename)) . '">' . __('View', 'nggallery') . '</a>'; $actions['meta'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data', 'nggallery') . '">' . __('Meta', 'nggallery') . '</a>'; $actions['custom_thumb'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail', 'nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>'; $actions['rotate'] = '<a class="thickbox" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate', 'nggallery') . '">' . __('Rotate', 'nggallery') . '</a>'; $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&mode=delpic&gid=" . $act_gid . "&pid=" . $pid, 'ngg_delpicture') . '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s"', 'nggallery'), $picture->filename)) . '\');if(check==false) return false;">' . __('Delete') . '</a>'; $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; ?> </p> </td> <?php break; case 'thumbnail': // generate the thumbnail size if the meta data available if (is_array($size = $picture->meta_data['thumbnail'])) { $thumbsize = 'width="' . $size['width'] . '" height="' . $size['height'] . '"'; } ?> <td <?php echo $attributes; ?> ><a href="<?php echo $picture->imageURL . '?' . mt_rand(); ?> " class="thickbox" title="<?php echo $picture->filename; ?> "> <img class="thumb" src="<?php echo $picture->thumbURL . '?' . mt_rand(); ?> " <?php echo $thumbsize; ?> id="thumb<?php echo $pid; ?> " /> </a> </td> <?php break; case 'alt_title_desc': ?> <td <?php echo $attributes; ?> > <input name="alttext[<?php echo $pid; ?> ]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo stripslashes($picture->alttext); ?> " /><br/> <textarea name="description[<?php echo $pid; ?> ]" style="width:95%; margin-top: 2px;" rows="2" ><?php echo stripslashes($picture->description); ?> </textarea> </td> <?php break; case 'exclude': ?> <td <?php echo $attributes; ?> ><input name="exclude[<?php echo $pid; ?> ]" type="checkbox" value="1" <?php echo $exclude; ?> /></td> <?php break; case 'tags': $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names'); if (is_array($picture->tags)) { $picture->tags = implode(', ', $picture->tags); } ?> <td <?php echo $attributes; ?> ><textarea name="tags[<?php echo $pid; ?> ]" style="width:95%;" rows="2"><?php echo $picture->tags; ?> </textarea></td> <?php break; default: ?> <td <?php echo $attributes; ?> ><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $pid); ?> </td> <?php break; } ?> <?php } ?> </tr> <?php } } // In the case you have no capaptibility to see the search result if ($counter == 0) { echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <p class="submit"><input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes", 'nggallery'); ?> " /></p> </form> <br class="clear"/> </div><!-- /#wrap --> <!-- #entertags --> <div id="entertags" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th><?php _e("Enter the tags", 'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e("Cancel", 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#entertags --> <!-- #selectgallery --> <div id="selectgallery" style="display: none;" > <form id="form-select-gallery" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <th> <?php _e('Select the destination gallery:', 'nggallery'); ?> <select name="dest_gid" style="width:90%" > <?php foreach ($gallerylist as $gallery) { if ($gallery->gid != $act_gid) { ?> <option value="<?php echo $gallery->gid; ?> " ><?php echo $gallery->gid; ?> - <?php echo stripslashes($gallery->title); ?> </option> <?php } } ?> </select> </th> </tr> <tr align="right"> <td class="submit"> <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK", 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value="<?php _e("Cancel", 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#selectgallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-images" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?> " /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?> " /> <br /><small><?php _e('These values are maximum values ', 'nggallery'); ?> </small></td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " onclick="tb_remove()"/> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <script type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function(){columns.init('nggallery-manage-images');}); /* ]]> */ </script> <?php }
/** * nggShowRelatedGallery() - create a gallery based on the tags * * @access public * @param string $taglist list of tags as csv * @param integer $maxImages (optional) limit the number of images to show * @return the content */ function nggShowRelatedGallery($taglist, $maxImages = 0) { $ngg_options = nggGallery::get_option('ngg_options'); // get now the related images $picturelist = nggTags::find_images_for_tags($taglist, 'RAND'); // go on if not empty if (empty($picturelist)) { return; } // cut the list to maxImages if ($maxImages > 0) { array_splice($picturelist, $maxImages); } // *** build the gallery output $out = '<div class="ngg-related-gallery">'; foreach ($picturelist as $picture) { // get the effect code $thumbcode = $picture->get_thumbcode(__('Related images for', 'nggallery') . ' ' . get_the_title()); $out .= '<a href="' . $picture->imageURL . '" title="' . stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) . '" ' . $thumbcode . ' >'; $out .= '<img title="' . stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) . '" alt="' . stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) . '" src="' . $picture->thumbURL . '" />'; $out .= '</a>' . "\n"; } $out .= '</div>' . "\n"; $out = apply_filters('ngg_show_related_gallery_content', $out, $taglist); 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 = 25; $start = ($_GET['paged'] - 1) * $items_per_page; $order = isset($_GET['order']) && $_GET['order'] == 'desc' ? 'DESC' : 'ASC'; $orderby = isset($_GET['orderby']) && in_array($_GET['orderby'], array('gid', 'title', 'author')) ? $_GET['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 //include('templates/social_media_buttons.php'); ?> <?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 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 ($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(nggGallery::i18n($name)); ?> </a> <?php } else { ?> <?php echo esc_html(nggGallery::i18n($gallery->title)); ?> <?php } ?> <div class="row-actions"></div> </td> <?php break; case 'description': ?> <td <?php echo $attributes; ?> ><?php echo esc_html(nggGallery::i18n($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, TRUE)); ?> <td <?php echo $attributes; ?> ><?php echo $gallery->counter; ?> </td> <?php break; default: ?> <td <?php echo $attributes; ?> ><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid); ?> </td> <?php break; } } ?> </tr> <?php } } else { echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <div class="tablenav bottom"> <?php $ngg->manage_page->pagination('bottom', $_GET['paged'], $total_number_of_galleries, $items_per_page); ?> </div> </form> </div> <!-- #addGallery --> <div id="addGallery" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_addgallery'); ?> <input type="hidden" name="page" value="manage-galleries" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <td> <strong><?php _e('New Gallery', 'nggallery'); ?> :</strong> <input type="text" size="35" name="galleryname" value="" /><br /> <?php if (!is_multisite()) { ?> <?php _e('Create a new , empty gallery below the folder', 'nggallery'); ?> <strong><?php echo $ngg->options['gallerypath']; ?> </strong><br /> <?php } ?> <i>( <?php _e('Allowed characters for file and folder names are', 'nggallery'); ?> : a-z, A-Z, 0-9, -, _ )</i> </td> </tr> <?php do_action('ngg_add_new_gallery_form'); ?> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="addgallery" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#addGallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-galleries" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-galleries" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td> <?php include dirname(__FILE__) . '/thumbnails-template.php'; ?> </td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <?php }
function nggallery_manage_gallery_main() { global $ngg, $nggdb, $wp_query; //Build the pagination for more than 25 galleries if (!isset($_GET['paged']) || $_GET['paged'] < 1) { $_GET['paged'] = 1; } $start = ($_GET['paged'] - 1) * 25; $gallerylist = $nggdb->find_all_galleries('gid', 'asc', TRUE, 25, $start, false); $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $nggdb->paged['max_objects_per_page'], 'current' => $_GET['paged'])); ?> <script type="text/javascript"> <!-- function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") { if(form.elements[i].checked == true) form.elements[i].checked = false; else form.elements[i].checked = true; } } } } function getNumChecked(form) { var num = 0; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) num++; } } return num; } // this function check for a the number of selected images, sumbmit false when no one selected function checkSelected() { var numchecked = getNumChecked(document.getElementById('editgalleries')); if(numchecked < 1) { alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?> '); return false; } actionId = jQuery('#bulkaction').val(); switch (actionId) { case "resize_images": showDialog('resize_images', '<?php echo esc_js(__('Resize images', 'nggallery')); ?> '); return false; break; case "new_thumbnail": showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails', 'nggallery')); ?> '); return false; break; } return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s galleries \n \n 'Cancel' to stop, 'OK' to proceed.", 'nggallery')), "' + numchecked + '"); ?> '); } function showDialog( windowId, title ) { var form = document.getElementById('editgalleries'); var elementlist = ""; for (i = 0, n = form.elements.length; i < n; i++) { if(form.elements[i].type == "checkbox") { if(form.elements[i].name == "doaction[]") if(form.elements[i].checked == true) if (elementlist == "") elementlist = form.elements[i].value else elementlist += "," + form.elements[i].value ; } } jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val()); jQuery("#" + windowId + "_imagelist").val(elementlist); // now show the dialog jQuery( "#" + windowId ).dialog({ width: 640, resizable : false, modal: true, title: title }); jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); }); } function showAddGallery() { jQuery( "#addGallery").dialog({ width: 640, resizable : false, modal: true, title: '<?php echo esc_js(__('Add new gallery', 'nggallery')); ?> ' }); jQuery("#addGallery .dialog-cancel").click(function() { jQuery( "#addGallery" ).dialog("close"); }); } //--> </script> <div class="wrap"> <?php screen_icon('nextgen-gallery'); ?> <h2><?php echo _n('Gallery', 'Galleries', 2, 'nggallery'); ?> </h2> <form class="search-form" action="" method="get"> <p class="search-box"> <label class="hidden" for="media-search-input"><?php _e('Search Images', 'nggallery'); ?> :</label> <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" /> <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search Images', 'nggallery'); ?> " class="button" /> </p> </form> <form id="editgalleries" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&paged=' . $_GET['paged']; ?> " accept-charset="utf-8"> <?php wp_nonce_field('ngg_bulkgallery'); ?> <input type="hidden" name="page" value="manage-galleries" /> <div class="tablenav"> <div class="alignleft actions"> <?php if (function_exists('json_encode')) { ?> <select name="bulkaction" id="bulkaction"> <option value="no_action" ><?php _e("Bulk actions", 'nggallery'); ?> </option> <option value="delete_gallery" ><?php _e("Delete", 'nggallery'); ?> </option> <option value="set_watermark" ><?php _e("Set watermark", 'nggallery'); ?> </option> <option value="new_thumbnail" ><?php _e("Create new thumbnails", 'nggallery'); ?> </option> <option value="resize_images" ><?php _e("Resize images", 'nggallery'); ?> </option> <option value="import_meta" ><?php _e("Import metadata", 'nggallery'); ?> </option> <option value="recover_images" ><?php _e("Recover from backup", 'nggallery'); ?> </option> </select> <input name="showThickbox" class="button-secondary" type="submit" value="<?php _e('Apply', 'nggallery'); ?> " onclick="if ( !checkSelected() ) return false;" /> <?php } ?> <?php if (current_user_can('NextGEN Upload images') && nggGallery::current_user_can('NextGEN Add new gallery')) { ?> <input name="doaction" class="button-secondary action" type="submit" onclick="showAddGallery(); return false;" value="<?php _e('Add new gallery', 'nggallery'); ?> "/> <?php } ?> </div> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links); echo $page_links_text; ?> </div> <?php } ?> </div> <table class="widefat" cellspacing="0"> <thead> <tr> <?php print_column_headers('nggallery-manage-galleries'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('nggallery-manage-galleries', false); ?> </tr> </tfoot> <tbody> <?php if ($gallerylist) { //get the columns $gallery_columns = ngg_manage_gallery_columns(); $hidden_columns = get_hidden_columns('nggallery-manage-images'); $num_columns = count($gallery_columns) - count($hidden_columns); foreach ($gallerylist as $gallery) { $alternate = !isset($alternate) || $alternate == 'class="alternate"' ? '' : 'class="alternate"'; $gid = $gallery->gid; $name = empty($gallery->title) ? $gallery->name : $gallery->title; $author_user = get_userdata((int) $gallery->author); ?> <tr id="gallery-<?php echo $gid; ?> " <?php echo $alternate; ?> > <?php foreach ($gallery_columns as $gallery_column_key => $column_display_name) { $class = "class=\"{$gallery_column_key} column-{$gallery_column_key}\""; $style = ''; if (in_array($gallery_column_key, $hidden_columns)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($gallery_column_key) { case 'cb': ?> <th scope="row" class="cb column-cb"> <?php if (nggAdmin::can_manage_this_gallery($gallery->author)) { ?> <input name="doaction[]" type="checkbox" value="<?php echo $gid; ?> " /> <?php } ?> </th> <?php break; case 'id': ?> <td <?php echo $attributes; ?> scope="row"><?php echo $gid; ?> </td> <?php break; case 'title': ?> <td> <?php if (nggAdmin::can_manage_this_gallery($gallery->author)) { ?> <a href="<?php echo wp_nonce_url($ngg->manage_page->base_page . '&mode=edit&gid=' . $gid, 'ngg_editgallery'); ?> " class='edit' title="<?php _e('Edit'); ?> " > <?php echo nggGallery::i18n($name); ?> </a> <?php } else { ?> <?php echo nggGallery::i18n($gallery->title); ?> <?php } ?> </td> <?php break; case 'description': ?> <td <?php echo $attributes; ?> ><?php echo nggGallery::i18n($gallery->galdesc); ?> </td> <?php break; case 'author': ?> <td <?php echo $attributes; ?> ><?php echo $author_user->display_name; ?> </td> <?php break; case 'page_id': ?> <td <?php echo $attributes; ?> ><?php echo $gallery->pageid; ?> </td> <?php break; case 'quantity': ?> <td <?php echo $attributes; ?> ><?php echo $gallery->counter; ?> </td> <?php break; default: ?> <td <?php echo $attributes; ?> ><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid); ?> </td> <?php break; } } ?> </tr> <?php } } else { echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>'; } ?> </tbody> </table> <div class="tablenav"> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s', number_format_i18n(($_GET['paged'] - 1) * $nggdb->paged['objects_per_page'] + 1), number_format_i18n(min($_GET['paged'] * $nggdb->paged['objects_per_page'], $nggdb->paged['total_objects'])), number_format_i18n($nggdb->paged['total_objects']), $page_links); echo $page_links_text; ?> </div> <?php } ?> </div> </form> </div> <!-- #addGallery --> <div id="addGallery" style="display: none;" > <form id="form-tags" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_addgallery'); ?> <input type="hidden" name="page" value="manage-galleries" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr> <td> <strong><?php _e('New Gallery', 'nggallery'); ?> :</strong> <input type="text" size="35" name="galleryname" value="" /><br /> <?php if (!is_multisite()) { ?> <?php _e('Create a new , empty gallery below the folder', 'nggallery'); ?> <strong><?php echo $ngg->options['gallerypath']; ?> </strong><br /> <?php } ?> <i>( <?php _e('Allowed characters for file and folder names are', 'nggallery'); ?> : a-z, A-Z, 0-9, -, _ )</i> </td> </tr> <tr align="right"> <td class="submit"> <input class="button-primary" type="submit" name="addgallery" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#addGallery --> <!-- #resize_images --> <div id="resize_images" style="display: none;" > <form id="form-resize-images" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-galleries" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <td> <strong><?php _e('Resize Images to', 'nggallery'); ?> :</strong> </td> <td> <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?> " /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?> " /> <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size', 'nggallery'); ?> </small> </td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#resize_images --> <!-- #new_thumbnail --> <div id="new_thumbnail" style="display: none;" > <form id="form-new-thumbnail" method="POST" accept-charset="utf-8"> <?php wp_nonce_field('ngg_thickbox_form'); ?> <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" /> <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" /> <input type="hidden" name="page" value="manage-galleries" /> <table width="100%" border="0" cellspacing="3" cellpadding="3" > <tr valign="top"> <th align="left"><?php _e('Width x height (in pixel)', 'nggallery'); ?> </th> <td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?> " /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?> " /> <br /><small><?php _e('These values are maximum values ', 'nggallery'); ?> </small></td> </tr> <tr valign="top"> <th align="left"><?php _e('Set fix dimension', 'nggallery'); ?> </th> <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> /> <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails', 'nggallery'); ?> </small></td> </tr> <tr align="right"> <td colspan="2" class="submit"> <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery'); ?> " /> <input class="button-secondary dialog-cancel" type="reset" value=" <?php _e('Cancel', 'nggallery'); ?> " /> </td> </tr> </table> </form> </div> <!-- /#new_thumbnail --> <?php }
function ngg_widget_output($args, $widget_args = 1, $options = false) { global $wpdb; extract($args, EXTR_SKIP); if (is_numeric($widget_args)) { $widget_args = array('number' => $widget_args); } $widget_args = wp_parse_args($widget_args, array('number' => -1)); extract($widget_args, EXTR_SKIP); // We could get this also as parameter if (!$options) { $options = get_option('ngg_widget'); } $title = $options[$number]['title']; $items = $options[$number]['items']; $exclude = $options[$number]['exclude']; $list = $options[$number]['list']; $webslice = $options[$number]['webslice']; $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->nggpictures} WHERE exclude != 1 "); if ($count < $options[$number]['items']) { $options[$number]['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})"; } } if ($options[$number]['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}"); } if ($webslice) { //TODO: If you change the title, it will not show up in widget admin panel $before_title = "\n" . '<div class="hslice" id="ngg-webslice" >' . "\n"; $before_title .= '<h2 class="widgettitle entry-title">'; $after_title = '</h2>'; $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("sidebar_" . $number); // enable i18n support for alttext and description $alttext = htmlspecialchars(stripslashes(nggGallery::i18n($image->alttext))); $description = htmlspecialchars(stripslashes(nggGallery::i18n($image->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) $options[$number]['show'] = $options[$number]['show'] == 'orginal' ? 'original' : $options[$number]['show']; if ($options[$number]['show'] == 'original') { $out .= '<img src="' . NGGALLERY_URLPATH . 'nggshow.php?pid=' . $image->pid . '&width=' . $options[$number]['width'] . '&height=' . $options[$number]['height'] . '" title="' . $alttext . '" alt="' . $alttext . '" />'; } else { $out .= '<img src="' . $image->thumbURL . '" width="' . $options[$number]['width'] . '" height="' . $options[$number]['height'] . '" title="' . $alttext . '" alt="' . $alttext . '" />'; } echo $out . '</a>' . "\n"; } } echo '</div>' . "\n"; echo $after_widget; }