NGG_Gallery_Manager

Class NGG_Gallery_Manager.

Defined (1)

The class is defined in the following location(s).

/admin/manage/class-ngg-gallery-manager.php  
  1. class NGG_Gallery_Manager extends NGG_Manager { 
  2.  
  3. /** 
  4. * Display the page. 
  5. */ 
  6. public function display() { 
  7.  
  8. parent::display(); 
  9.  
  10. /** 
  11. * Add a gallery. 
  12. */ 
  13. if ( isset( $_POST['gallery_name'] ) ) { 
  14. $this->handle_add_gallery(); 
  15.  
  16. /** 
  17. * Display the actual table. 
  18. */ 
  19. $table = new NGG_Gallery_List_Table( self::BASE ); 
  20. $table->prepare_items(); 
  21. ?> 
  22. <div class="wrap"> 
  23. <h2><?php _e( 'Galleries', 'nggallery' ); ?> 
  24. <?php if ( current_user_can( 'NextGEN Upload images' ) && nggGallery::current_user_can( 'NextGEN Add new gallery' ) ) { ?> 
  25. <a class="add-new-h2" id="new-gallery" href="#"><?php _e( 'Add new gallery', 'nggallery' ) ?></a> 
  26. <?php }; ?> 
  27. </h2> 
  28.  
  29. <form method="get"> 
  30. <input type="hidden" name="page" value="nggallery-manage"> 
  31. <input type="hidden" name="mode" value="search"> 
  32. <?php $table->search_box( 'Search images', 'nggallery' ); ?> 
  33. </form> 
  34.  
  35. <form method="post"> 
  36. <input type="hidden" id="page_type" name="page_type" value="gallery"/> 
  37. <?php $table->display(); ?> 
  38. </form> 
  39. </div> 
  40. <?php 
  41. $this->print_dialogs(); 
  42. $this->print_scripts(); 
  43.  
  44. protected function print_scripts() { 
  45. parent::print_scripts(); 
  46. ?> 
  47. <script type="text/javascript"> 
  48. jQuery(function() { 
  49. jQuery("#new-gallery").click(function() { 
  50. addGalleryDialog(); 
  51. return false; 
  52. }); 
  53. }); 
  54.  
  55. function addGalleryDialog() { 
  56. showDialog("#add_gallery_dialog", '<?php echo esc_js(__('Add a new gallery', 'nggallery')); ?>'); 
  57. </script> 
  58. <?php 
  59.  
  60. protected function print_dialogs() { 
  61. parent::print_dialogs(); 
  62.  
  63. $options = get_option( 'ngg_options' ); 
  64. ?> 
  65. <div class="ngg-dialog-container"> 
  66. <!-- Add Gallery --> 
  67. <form id="add_gallery_dialog" method="POST" accept-charset="utf-8"> 
  68. <?php wp_nonce_field( 'ngg_add_gallery' ); ?> 
  69. <label> 
  70. <strong><?php _e( 'Name', 'nggallery' ); ?>: </strong> 
  71. <input id="gallery_name" type="text" class="regular-text" name="gallery_name"> 
  72. </label> 
  73. <br> 
  74. <?php if ( ! is_multisite() ) { ?> 
  75. <?php _e( 'Create a new , empty gallery below the folder', 'nggallery' ); ?> 
  76. <strong><?php echo $options['gallerypath']; ?></strong><br> 
  77. <?php } ?> 
  78. <p class="description"> 
  79. <?php printf( __( 'Allowed characters for file and folder names are %s', 'nggallery' ), 'a-z, A-Z, 0-9, -, _' ) ?> 
  80. </p> 
  81. <?php do_action( 'ngg_add_new_gallery_form' ); ?> 
  82. </form> 
  83. </div> 
  84. <?php 
  85.  
  86. /** 
  87. * Add a new gallery. 
  88. */ 
  89. private function handle_add_gallery() { 
  90.  
  91. if ( wp_verify_nonce( $_POST['_wpnonce'],  
  92. 'ngg_add_gallery' ) === false || ! nggGallery::current_user_can( 'NextGEN Add new gallery' ) 
  93. ) { 
  94. nggGallery::show_error( __( 'You waited too long, or you cheated.', 'nggallery' ) ); 
  95.  
  96. return; 
  97.  
  98. $options = get_option( 'ngg_options' ); 
  99.  
  100. // get the default path for a new gallery 
  101. $default_path = $options['gallerypath']; 
  102. $new_gallery = esc_attr( $_POST['gallery_name'] ); 
  103. if ( ! empty( $new_gallery ) ) { 
  104. nggAdmin::create_gallery( $new_gallery, $default_path ); 
  105.  
  106. do_action( 'ngg_update_addgallery_page' );