PageRenderTime 49ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/wp-content/plugins/nextgen-gallery/admin/manage-images.php

https://bitbucket.org/dkrzos/phc
PHP | 715 lines | 599 code | 83 blank | 33 comment | 77 complexity | c9b6ffa13da2421c17f0d9038674c9f9 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.');}
  3. function nggallery_picturelist() {
  4. // *** show picture list
  5. global $wpdb, $nggdb, $user_ID, $ngg;
  6. // Look if its a search result
  7. $is_search = isset ($_GET['s']) ? true : false;
  8. $counter = 0;
  9. $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
  10. if ($is_search) {
  11. // fetch the imagelist
  12. $picturelist = $ngg->manage_page->search_result;
  13. // we didn't set a gallery or a pagination
  14. $act_gid = 0;
  15. $_GET['paged'] = 1;
  16. $page_links = false;
  17. } else {
  18. // GET variables
  19. $act_gid = $ngg->manage_page->gid;
  20. // Load the gallery metadata
  21. $gallery = $nggdb->find_gallery($act_gid);
  22. if (!$gallery) {
  23. nggGallery::show_error(__('Gallery not found.', 'nggallery'));
  24. return;
  25. }
  26. // Check if you have the correct capability
  27. if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
  28. nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
  29. return;
  30. }
  31. // look for pagination
  32. $_GET['paged'] = isset($_GET['paged']) && ($_GET['paged'] > 0) ? absint($_GET['paged']) : 1;
  33. $start = ( $_GET['paged'] - 1 ) * 50;
  34. // get picture values
  35. $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start );
  36. // get the current author
  37. $act_author_user = get_userdata( (int) $gallery->author );
  38. }
  39. // list all galleries
  40. $gallerylist = $nggdb->find_all_galleries();
  41. //get the columns
  42. $image_columns = $wp_list_table->get_columns();
  43. $hidden_columns = get_hidden_columns('nggallery-manage-images');
  44. $num_columns = count($image_columns) - count($hidden_columns);
  45. $attr = (nggGallery::current_user_can( 'NextGEN Edit gallery options' )) ? '' : 'disabled="disabled"';
  46. ?>
  47. <script type="text/javascript">
  48. <!--
  49. function showDialog( windowId, title ) {
  50. var form = document.getElementById('updategallery');
  51. var elementlist = "";
  52. for (i = 0, n = form.elements.length; i < n; i++) {
  53. if(form.elements[i].type == "checkbox") {
  54. if(form.elements[i].name == "doaction[]")
  55. if(form.elements[i].checked == true)
  56. if (elementlist == "")
  57. elementlist = form.elements[i].value
  58. else
  59. elementlist += "," + form.elements[i].value ;
  60. }
  61. }
  62. jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
  63. jQuery("#" + windowId + "_imagelist").val(elementlist);
  64. // now show the dialog
  65. jQuery( "#" + windowId ).dialog({
  66. width: 640,
  67. resizable : false,
  68. modal: true,
  69. title: title
  70. });
  71. jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
  72. }
  73. jQuery(function (){
  74. // load a content via ajax
  75. jQuery('a.ngg-dialog').click(function() {
  76. if ( jQuery( "#spinner" ).length == 0)
  77. jQuery("body").append('<div id="spinner"></div>');
  78. var $this = jQuery(this);
  79. var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
  80. var width = ( results ) ? results[1] : 600;
  81. var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
  82. var height = ( results ) ? results[1] : 440;
  83. jQuery('#spinner').fadeIn();
  84. var dialog = jQuery('<div style="display:hidden"></div>').appendTo('body');
  85. // load the remote content
  86. dialog.load(
  87. this.href,
  88. {},
  89. function () {
  90. jQuery('#spinner').hide();
  91. dialog.dialog({
  92. title: ($this.attr('title')) ? $this.attr('title') : '',
  93. width: width,
  94. height: height,
  95. modal: true,
  96. resizable: false,
  97. close: function() { dialog.remove(); }
  98. }).width(width - 30).height(height - 30);
  99. }
  100. );
  101. //prevent the browser to follow the link
  102. return false;
  103. });
  104. });
  105. function checkAll(form)
  106. {
  107. for (i = 0, n = form.elements.length; i < n; i++) {
  108. if(form.elements[i].type == "checkbox") {
  109. if(form.elements[i].name == "doaction[]") {
  110. if(form.elements[i].checked == true)
  111. form.elements[i].checked = false;
  112. else
  113. form.elements[i].checked = true;
  114. }
  115. }
  116. }
  117. }
  118. function getNumChecked(form)
  119. {
  120. var num = 0;
  121. for (i = 0, n = form.elements.length; i < n; i++) {
  122. if(form.elements[i].type == "checkbox") {
  123. if(form.elements[i].name == "doaction[]")
  124. if(form.elements[i].checked == true)
  125. num++;
  126. }
  127. }
  128. return num;
  129. }
  130. // this function check for a the number of selected images, sumbmit false when no one selected
  131. function checkSelected() {
  132. var numchecked = getNumChecked(document.getElementById('updategallery'));
  133. if (typeof document.activeElement == "undefined" && document.addEventListener) {
  134. document.addEventListener("focus", function (e) {
  135. document.activeElement = e.target;
  136. }, true);
  137. }
  138. if ( document.activeElement.name == 'post_paged' )
  139. return true;
  140. if(numchecked < 1) {
  141. alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?>');
  142. return false;
  143. }
  144. actionId = jQuery('#bulkaction').val();
  145. switch (actionId) {
  146. case "copy_to":
  147. showDialog('selectgallery', '<?php echo esc_js(__('Copy image to...','nggallery')); ?>');
  148. return false;
  149. break;
  150. case "move_to":
  151. showDialog('selectgallery', '<?php echo esc_js(__('Move image to...','nggallery')); ?>');
  152. return false;
  153. break;
  154. case "add_tags":
  155. showDialog('entertags', '<?php echo esc_js(__('Add new tags','nggallery')); ?>');
  156. return false;
  157. break;
  158. case "delete_tags":
  159. showDialog('entertags', '<?php echo esc_js(__('Delete tags','nggallery')); ?>');
  160. return false;
  161. break;
  162. case "overwrite_tags":
  163. showDialog('entertags', '<?php echo esc_js(__('Overwrite','nggallery')); ?>');
  164. return false;
  165. break;
  166. case "resize_images":
  167. showDialog('resize_images', '<?php echo esc_js(__('Resize images','nggallery')); ?>');
  168. return false;
  169. break;
  170. case "new_thumbnail":
  171. showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails','nggallery')); ?>');
  172. return false;
  173. break;
  174. }
  175. 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 + '") ; ?>');
  176. }
  177. jQuery(document).ready( function() {
  178. // close postboxes that should be closed
  179. jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
  180. postboxes.add_postbox_toggles('ngg-manage-gallery');
  181. });
  182. //-->
  183. </script>
  184. <div class="wrap">
  185. <?php include('templates/social_media_buttons.php'); ?>
  186. <?php screen_icon( 'nextgen-gallery' ); ?>
  187. <?php if ($is_search) :?>
  188. <h2><?php printf( __('Search results for &#8220;%s&#8221;', 'nggallery'), esc_html( get_search_query() ) ); ?></h2>
  189. <form class="search-form" action="" method="get">
  190. <p class="search-box">
  191. <label class="hidden" for="media-search-input"><?php _e( 'Search Images', 'nggallery' ); ?>:</label>
  192. <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
  193. <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
  194. <input type="submit" value="<?php _e( 'Search Images', 'nggallery' ); ?>" class="button" />
  195. </p>
  196. </form>
  197. <br style="clear: both;" />
  198. <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . get_search_query(); ?>" accept-charset="utf-8">
  199. <?php wp_nonce_field('ngg_updategallery') ?>
  200. <input type="hidden" name="page" value="manage-images" />
  201. <?php else :?>
  202. <h2><?php echo _n( 'Gallery', 'Galleries', 1, 'nggallery' ); ?> : <?php echo esc_html ( nggGallery::i18n($gallery->title) ); ?></h2>
  203. <br style="clear: both;" />
  204. <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . $_GET['paged']; ?>" accept-charset="utf-8">
  205. <?php wp_nonce_field('ngg_updategallery') ?>
  206. <input type="hidden" name="page" value="manage-images" />
  207. <?php if ( nggGallery::current_user_can( 'NextGEN Edit gallery options' )) : ?>
  208. <div id="poststuff">
  209. <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
  210. <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?>" >
  211. <h3><?php _e('Gallery settings', 'nggallery') ?><small> (<?php _e('Click here for more settings', 'nggallery') ?>)</small></h3>
  212. <div class="inside">
  213. <table class="form-table" >
  214. <tr>
  215. <th align="left"><?php _e('Title') ?>:</th>
  216. <th align="left"><input <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery title' ); ?> type="text" size="50" name="title" value="<?php echo $gallery->title; ?>" /></th>
  217. <th align="right"><?php _e('Page Link to', 'nggallery') ?>:</th>
  218. <th align="left">
  219. <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery page id' ); ?> name="pageid" style="width:95%">
  220. <option value="0" ><?php _e('Not linked', 'nggallery') ?></option>
  221. <?php $err = error_reporting(0); ?>
  222. <?php parent_dropdown(intval($gallery->pageid)); ?>
  223. <?php error_reporting($err); ?>
  224. </select>
  225. </th>
  226. </tr>
  227. <tr>
  228. <th align="left"><?php _e('Description') ?>:</th>
  229. <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 $gallery->galdesc; ?></textarea></th>
  230. <th align="right"><?php _e('Preview image', 'nggallery') ?>:</th>
  231. <th align="left">
  232. <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery preview pic' ); ?> name="previewpic" style="width:95%" >
  233. <option value="0" ><?php _e('No Picture', 'nggallery') ?></option>
  234. <?php
  235. // ensure that a preview pic from a other page is still shown here
  236. if ( intval($gallery->previewpic) != 0) {
  237. if ( !array_key_exists ($gallery->previewpic, $picturelist )){
  238. $previewpic = $nggdb->find_image($gallery->previewpic);
  239. if ($previewpic)
  240. echo '<option value="'.$previewpic->pid.'" selected="selected" >'.$previewpic->pid.' - ' . esc_attr( $previewpic->filename ) . '</option>'."\n";
  241. }
  242. }
  243. if(is_array($picturelist)) {
  244. foreach($picturelist as $picture) {
  245. if ($picture->exclude) continue;
  246. $selected = ($picture->pid == $gallery->previewpic) ? 'selected="selected" ' : '';
  247. echo '<option value="'.$picture->pid.'" '.$selected.'>'.$picture->pid.' - ' . esc_attr( $picture->filename ) . '</option>'."\n";
  248. }
  249. }
  250. ?>
  251. </select>
  252. </th>
  253. </tr>
  254. <tr>
  255. <th align="left"><?php _e('Path', 'nggallery') ?>:</th>
  256. <th align="left"><input <?php if ( is_multisite() ) echo 'readonly = "readonly"'; ?> <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery path' ); ?> type="text" size="50" name="path" value="<?php echo $gallery->path; ?>" /></th>
  257. <th align="right"><?php _e('Author', 'nggallery'); ?>:</th>
  258. <th align="left">
  259. <?php
  260. $editable_ids = $ngg->manage_page->get_editable_user_ids( $user_ID );
  261. if ( $editable_ids && count( $editable_ids ) > 1 && nggGallery::current_user_can( 'NextGEN Edit gallery author') )
  262. wp_dropdown_users( array('include' => $editable_ids, 'name' => 'author', 'selected' => empty( $gallery->author ) ? 0 : $gallery->author ) );
  263. else
  264. echo $act_author_user->display_name;
  265. ?>
  266. </th>
  267. </tr>
  268. <?php if(current_user_can( 'publish_pages' )) : ?>
  269. <tr>
  270. <th align="left">&nbsp;</th>
  271. <th align="left">&nbsp;</th>
  272. <th align="right"><?php _e('Create new page', 'nggallery') ?>:</th>
  273. <th align="left">
  274. <select name="parent_id" style="width:95%">
  275. <option value="0"><?php _e ('Main page (No parent)', 'nggallery'); ?></option>
  276. <?php if (get_post()): ?>
  277. <?php parent_dropdown (); ?>
  278. <?php endif ?>
  279. </select>
  280. <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e ('Add page', 'nggallery'); ?>" id="group"/>
  281. </th>
  282. </tr>
  283. <?php endif; ?>
  284. <?php do_action('ngg_manage_gallery_settings', $act_gid); ?>
  285. </table>
  286. <div class="submit">
  287. <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images",'nggallery'); ?> " />
  288. <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes",'nggallery'); ?>" />
  289. </div>
  290. </div>
  291. </div>
  292. </div> <!-- poststuff -->
  293. <?php endif; ?>
  294. <?php endif; ?>
  295. <div class="tablenav top ngg-tablenav">
  296. <?php $ngg->manage_page->pagination( 'top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
  297. <div class="alignleft actions">
  298. <select id="bulkaction" name="bulkaction">
  299. <option value="no_action" ><?php _e("Bulk actions",'nggallery'); ?></option>
  300. <option value="set_watermark" ><?php _e("Set watermark",'nggallery'); ?></option>
  301. <option value="new_thumbnail" ><?php _e("Create new thumbnails",'nggallery'); ?></option>
  302. <option value="resize_images" ><?php _e("Resize images",'nggallery'); ?></option>
  303. <option value="recover_images" ><?php _e("Recover from backup",'nggallery'); ?></option>
  304. <option value="delete_images" ><?php _e("Delete images",'nggallery'); ?></option>
  305. <option value="import_meta" ><?php _e("Import metadata",'nggallery'); ?></option>
  306. <option value="rotate_cw" ><?php _e("Rotate images clockwise",'nggallery'); ?></option>
  307. <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise",'nggallery'); ?></option>
  308. <option value="copy_to" ><?php _e("Copy to...",'nggallery'); ?></option>
  309. <option value="move_to"><?php _e("Move to...",'nggallery'); ?></option>
  310. <option value="add_tags" ><?php _e("Add tags",'nggallery'); ?></option>
  311. <option value="delete_tags" ><?php _e("Delete tags",'nggallery'); ?></option>
  312. <option value="overwrite_tags" ><?php _e("Overwrite tags",'nggallery'); ?></option>
  313. </select>
  314. <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?>" onclick="if ( !checkSelected() ) return false;" />
  315. <?php if (($ngg->options['galSort'] == "sortorder") && (!$is_search) ) { ?>
  316. <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery');?>" />
  317. <?php } ?>
  318. <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery');?>" />
  319. </div>
  320. </div>
  321. <table id="ngg-listimages" class="widefat fixed" cellspacing="0" >
  322. <thead>
  323. <tr>
  324. <?php $wp_list_table->print_column_headers(true); ?>
  325. </tr>
  326. </thead>
  327. <tfoot>
  328. <tr>
  329. <?php $wp_list_table->print_column_headers(false); ?>
  330. </tr>
  331. </tfoot>
  332. <tbody id="the-list">
  333. <?php
  334. if($picturelist) {
  335. $thumbsize = '';
  336. if ($ngg->options['thumbfix'])
  337. $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
  338. foreach($picturelist as $picture) {
  339. //for search result we need to check the capatibiliy
  340. if ( !nggAdmin::can_manage_this_gallery($picture->author) && $is_search )
  341. continue;
  342. $counter++;
  343. $pid = (int) $picture->pid;
  344. $alternate = ( !isset($alternate) || $alternate == 'alternate' ) ? '' : 'alternate';
  345. $exclude = ( $picture->exclude ) ? 'checked="checked"' : '';
  346. $date = mysql2date(get_option('date_format'), $picture->imagedate);
  347. $time = mysql2date(get_option('time_format'), $picture->imagedate);
  348. ?>
  349. <tr id="picture-<?php echo $pid ?>" class="<?php echo $alternate ?> iedit" valign="top">
  350. <?php
  351. foreach($image_columns as $image_column_key => $column_display_name) {
  352. $class = "class='$image_column_key column-$image_column_key'";
  353. $style = '';
  354. if ( in_array($image_column_key, $hidden_columns) )
  355. $style = ' style="display:none;"';
  356. $attributes = $class . $style;
  357. switch ($image_column_key) {
  358. case 'cb' :
  359. $attributes = 'class="column-cb check-column"' . $style;
  360. ?>
  361. <th <?php echo $attributes ?> scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid ?>" /></th>
  362. <?php
  363. break;
  364. case 'id' :
  365. ?>
  366. <td <?php echo $attributes ?> style=""><?php echo $pid; ?>
  367. <input type="hidden" name="pid[]" value="<?php echo $pid ?>" />
  368. </td>
  369. <?php
  370. break;
  371. case 'filename' :
  372. $attributes = 'class="title column-filename column-title"' . $style;
  373. ?>
  374. <td <?php echo $attributes ?>>
  375. <strong><a href="<?php echo esc_url( $picture->imageURL ); ?>" class="thickbox" title="<?php echo esc_attr ($picture->filename); ?>">
  376. <?php echo ( empty($picture->alttext) ) ? esc_html( $picture->filename ) : esc_html( stripslashes(nggGallery::i18n($picture->alttext)) ); ?>
  377. </a></strong>
  378. <br /><?php echo $date; ?>
  379. <?php if ( !empty($picture->meta_data) ): ?>
  380. <br /><?php echo $picture->meta_data['width']; ?> x <?php echo $picture->meta_data['height']; ?> <?php _e('pixel', 'nggallery'); ?>
  381. <?php endif; ?>
  382. <p>
  383. <?php
  384. $actions = array();
  385. $actions['view'] = '<a class="shutter" href="' . esc_url( $picture->imageURL ) . '" title="' . esc_attr( sprintf(__('View "%s"'), sanitize_title ($picture->filename) )) . '">' . __('View', 'nggallery') . '</a>';
  386. $actions['meta'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data','nggallery') . '">' . __('Meta', 'nggallery') . '</a>';
  387. $actions['custom_thumb'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail','nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>';
  388. $actions['rotate'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate','nggallery') . '">' . __('Rotate', 'nggallery') . '</a>';
  389. if ( current_user_can( 'publish_posts' ) )
  390. $actions['publish'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/publish.php?id=' . $pid . '&h=230" title="' . __('Publish this image','nggallery') . '">' . __('Publish', 'nggallery') . '</a>';
  391. if ( file_exists( $picture->imagePath . '_backup' ) )
  392. $actions['recover'] = '<a class="confirmrecover" href="' .wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=recoverpic&amp;gid=" . $act_gid . "&amp;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>';
  393. $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=delpic&amp;gid=" . $act_gid . "&amp;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>';
  394. $action_count = count($actions);
  395. $i = 0;
  396. echo '<div class="row-actions">';
  397. foreach ( $actions as $action => $link ) {
  398. ++$i;
  399. ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
  400. echo "<span class='$action'>$link$sep</span>";
  401. }
  402. echo '</div>';
  403. ?></p>
  404. </td>
  405. <?php
  406. break;
  407. case 'thumbnail' :
  408. $attributes = 'class="id column-thumbnail media-icon"' . $style;
  409. ?>
  410. <td <?php echo $attributes ?>><a href="<?php echo esc_url ( add_query_arg('i', mt_rand(), $picture->imageURL) ); ?>" class="shutter" title="<?php echo $picture->filename ?>">
  411. <img class="thumb" src="<?php echo esc_url ( add_query_arg('i', mt_rand(), $picture->thumbURL) ); ?>" id="thumb<?php echo $pid ?>" />
  412. </a>
  413. </td>
  414. <?php
  415. break;
  416. case 'alt_title_desc' :
  417. ?>
  418. <td <?php echo $attributes ?>>
  419. <input name="alttext[<?php echo $pid ?>]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo stripslashes($picture->alttext) ?>" /><br/>
  420. <textarea name="description[<?php echo $pid ?>]" style="width:95%; margin-top: 2px;" rows="2" ><?php echo stripslashes($picture->description) ?></textarea>
  421. </td>
  422. <?php
  423. break;
  424. case 'exclude' :
  425. ?>
  426. <td <?php echo $attributes ?>><input name="exclude[<?php echo $pid ?>]" type="checkbox" value="1" <?php echo $exclude ?> /></td>
  427. <?php
  428. break;
  429. case 'tags' :
  430. $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names');
  431. if (is_array ($picture->tags) ) $picture->tags = implode(', ', $picture->tags);
  432. ?>
  433. <td <?php echo $attributes ?>><textarea name="tags[<?php echo $pid ?>]" style="width:95%;" rows="2"><?php echo $picture->tags ?></textarea></td>
  434. <?php
  435. break;
  436. default :
  437. ?>
  438. <td <?php echo $attributes ?>><?php do_action('ngg_manage_image_custom_column', $image_column_key, $pid); ?></td>
  439. <?php
  440. break;
  441. }
  442. ?>
  443. <?php } ?>
  444. </tr>
  445. <?php
  446. }
  447. }
  448. // In the case you have no capaptibility to see the search result
  449. if ( $counter == 0 )
  450. echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>'.__('No entries found','nggallery').'</strong></td></tr>';
  451. ?>
  452. </tbody>
  453. </table>
  454. <div class="tablenav bottom">
  455. <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?>" />
  456. <?php $ngg->manage_page->pagination( 'bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
  457. </div>
  458. </form>
  459. <br class="clear"/>
  460. </div><!-- /#wrap -->
  461. <!-- #entertags -->
  462. <div id="entertags" style="display: none;" >
  463. <form id="form-tags" method="POST" accept-charset="utf-8">
  464. <?php wp_nonce_field('ngg_thickbox_form') ?>
  465. <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
  466. <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
  467. <input type="hidden" name="page" value="manage-images" />
  468. <table width="100%" border="0" cellspacing="3" cellpadding="3" >
  469. <tr>
  470. <th><?php _e("Enter the tags",'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th>
  471. </tr>
  472. <tr align="right">
  473. <td class="submit">
  474. <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK",'nggallery'); ?>" />
  475. &nbsp;
  476. <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e("Cancel",'nggallery'); ?>&nbsp;" />
  477. </td>
  478. </tr>
  479. </table>
  480. </form>
  481. </div>
  482. <!-- /#entertags -->
  483. <!-- #selectgallery -->
  484. <div id="selectgallery" style="display: none;" >
  485. <form id="form-select-gallery" method="POST" accept-charset="utf-8">
  486. <?php wp_nonce_field('ngg_thickbox_form') ?>
  487. <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
  488. <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
  489. <input type="hidden" name="page" value="manage-images" />
  490. <table width="100%" border="0" cellspacing="3" cellpadding="3" >
  491. <tr>
  492. <th>
  493. <?php _e('Select the destination gallery:', 'nggallery'); ?>&nbsp;
  494. <select name="dest_gid" style="width:90%" >
  495. <?php
  496. foreach ($gallerylist as $gallery) {
  497. if ($gallery->gid != $act_gid) {
  498. ?>
  499. <option value="<?php echo $gallery->gid; ?>" ><?php echo $gallery->gid; ?> - <?php echo esc_attr( stripslashes($gallery->title) ); ?></option>
  500. <?php
  501. }
  502. }
  503. ?>
  504. </select>
  505. </th>
  506. </tr>
  507. <tr align="right">
  508. <td class="submit">
  509. <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK",'nggallery'); ?>" />
  510. &nbsp;
  511. <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel",'nggallery'); ?>" />
  512. </td>
  513. </tr>
  514. </table>
  515. </form>
  516. </div>
  517. <!-- /#selectgallery -->
  518. <!-- #resize_images -->
  519. <div id="resize_images" style="display: none;" >
  520. <form id="form-resize-images" method="POST" accept-charset="utf-8">
  521. <?php wp_nonce_field('ngg_thickbox_form') ?>
  522. <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
  523. <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
  524. <input type="hidden" name="page" value="manage-images" />
  525. <table width="100%" border="0" cellspacing="3" cellpadding="3" >
  526. <tr valign="top">
  527. <td>
  528. <strong><?php _e('Resize Images to', 'nggallery'); ?>:</strong>
  529. </td>
  530. <td>
  531. <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']; ?>" />
  532. <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size','nggallery') ?></small>
  533. </td>
  534. </tr>
  535. <tr align="right">
  536. <td colspan="2" class="submit">
  537. <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?>" />
  538. &nbsp;
  539. <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
  540. </td>
  541. </tr>
  542. </table>
  543. </form>
  544. </div>
  545. <!-- /#resize_images -->
  546. <!-- #new_thumbnail -->
  547. <div id="new_thumbnail" style="display: none;" >
  548. <form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
  549. <?php wp_nonce_field('ngg_thickbox_form') ?>
  550. <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
  551. <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
  552. <input type="hidden" name="page" value="manage-images" />
  553. <table width="100%" border="0" cellspacing="3" cellpadding="3" >
  554. <tr valign="top">
  555. <th align="left"><?php _e('Width x height (in pixel)','nggallery') ?></th>
  556. <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']; ?>" />
  557. <br /><small><?php _e('These values are maximum values ','nggallery') ?></small></td>
  558. </tr>
  559. <tr valign="top">
  560. <th align="left"><?php _e('Set fix dimension','nggallery') ?></th>
  561. <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
  562. <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails','nggallery') ?></small></td>
  563. </tr>
  564. <tr align="right">
  565. <td colspan="2" class="submit">
  566. <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery');?>" />
  567. &nbsp;
  568. <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
  569. </td>
  570. </tr>
  571. </table>
  572. </form>
  573. </div>
  574. <!-- /#new_thumbnail -->
  575. <script type="text/javascript">
  576. /* <![CDATA[ */
  577. jQuery(document).ready(function(){columns.init('nggallery-manage-images');});
  578. /* ]]> */
  579. </script>
  580. <?php
  581. }
  582. /**
  583. * Construtor class to create the table layout
  584. *
  585. * @package WordPress
  586. * @subpackage List_Table
  587. * @since 1.8.0
  588. * @access private
  589. */
  590. class _NGG_Images_List_Table extends WP_List_Table {
  591. var $_screen;
  592. var $_columns;
  593. function _NGG_Images_List_Table( $screen ) {
  594. if ( is_string( $screen ) )
  595. $screen = convert_to_screen( $screen );
  596. $this->_screen = $screen;
  597. $this->_columns = array() ;
  598. add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
  599. }
  600. function get_column_info() {
  601. $columns = get_column_headers( $this->_screen );
  602. $hidden = get_hidden_columns( $this->_screen );
  603. $_sortable = $this->get_sortable_columns();
  604. $sortable = array();
  605. foreach ( $_sortable as $id => $data ) {
  606. if ( empty( $data ) )
  607. continue;
  608. $data = (array) $data;
  609. if ( !isset( $data[1] ) )
  610. $data[1] = false;
  611. $sortable[$id] = $data;
  612. }
  613. return array( $columns, $hidden, $sortable );
  614. }
  615. // define the columns to display, the syntax is 'internal name' => 'display name'
  616. function get_columns() {
  617. $columns = array();
  618. $columns['cb'] = '<input name="checkall" type="checkbox" onclick="checkAll(document.getElementById(\'updategallery\'));" />';
  619. $columns['id'] = __('ID');
  620. $columns['thumbnail'] = __('Thumbnail', 'nggallery');
  621. $columns['filename'] = __('Filename', 'nggallery');
  622. $columns['alt_title_desc'] = __('Alt &amp; Title Text', 'nggallery') . ' / ' . __('Description', 'nggallery');
  623. $columns['tags'] = __('Tags (comma separated list)', 'nggallery');
  624. $columns['exclude'] = __('exclude', 'nggallery');
  625. $columns = apply_filters('ngg_manage_images_columns', $columns);
  626. return $columns;
  627. }
  628. function get_sortable_columns() {
  629. return array();
  630. }
  631. }
  632. ?>