NextGEN Gallery – WordPress Gallery Plugin - Version 1.8.3

Version Description

  • 07.08.2011 =
  • Changed : Support for simple custom permalink structures (i.e. /%category%/%postname%/)
  • Bugfix : Sub-Albums in Albums didn't create the correct link
  • Bugfix : AJAX Pagination didn't work anymore
  • Bugfix : Adding index.php to home_url()
  • Bugfix : Preview picture lost on backend gallery page 2 or higher
Download this release

Release Info

Developer alexrabe
Plugin Icon 128x128 NextGEN Gallery – WordPress Gallery Plugin
Version 1.8.3
Comparing to
See all releases

Code changes from version 1.8.2 to 1.8.3

admin/album.php CHANGED
@@ -173,7 +173,7 @@ jQuery(document).ready(
173
  function()
174
  {
175
  jQuery("#previewpic").nggAutocomplete( {
176
- type: 'image',domain: "<?php echo home_url(); ?>/"
177
  });
178
 
179
  jQuery('#selectContainer').sortable( {
@@ -299,7 +299,7 @@ function showDialog() {
299
  <input class="button-secondary" type="submit" name="showThickbox" value="<?php esc_attr_e( 'Edit album', 'nggallery'); ?>" onclick="showDialog(); return false;" />
300
  <?php } ?>
301
  <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
302
- <input class="button-secondary action "type="submit" name="delete" value="<?php esc_attr_e('Delete', 'nggallery'); ?>" onclick="javascript:check=confirm('<?php esc_js('Delete album ?','nggallery'); ?>');if(check==false) return false;"/>
303
  <?php } ?>
304
  <?php } else { ?>
305
  <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
173
  function()
174
  {
175
  jQuery("#previewpic").nggAutocomplete( {
176
+ type: 'image',domain: "<?php echo home_url('index.php'); ?>/"
177
  });
178
 
179
  jQuery('#selectContainer').sortable( {
299
  <input class="button-secondary" type="submit" name="showThickbox" value="<?php esc_attr_e( 'Edit album', 'nggallery'); ?>" onclick="showDialog(); return false;" />
300
  <?php } ?>
301
  <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
302
+ <input class="button-secondary action "type="submit" name="delete" value="<?php esc_attr_e('Delete', 'nggallery'); ?>" onclick="javascript:check=confirm('<?php echo esc_js('Delete album ?','nggallery'); ?>');if(check==false) return false;"/>
303
  <?php } ?>
304
  <?php } else { ?>
305
  <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
admin/manage-images.php CHANGED
@@ -270,6 +270,13 @@ jQuery(document).ready( function() {
270
  <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery preview pic' ); ?> name="previewpic" style="width:95%" >
271
  <option value="0" ><?php _e('No Picture', 'nggallery') ?></option>
272
  <?php
 
 
 
 
 
 
 
273
  if(is_array($picturelist)) {
274
  foreach($picturelist as $picture) {
275
  if ($picture->exclude) continue;
270
  <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery preview pic' ); ?> name="previewpic" style="width:95%" >
271
  <option value="0" ><?php _e('No Picture', 'nggallery') ?></option>
272
  <?php
273
+ // ensure that a preview pic from a other page is still shown here
274
+ if ( intval($gallery->previewpic) != 0) {
275
+ if ( !array_key_exists ($gallery->previewpic, $picturelist )){
276
+ $previewpic = $nggdb->find_image($gallery->previewpic);
277
+ echo '<option value="'.$previewpic->pid.'" selected="selected" >'.$previewpic->pid.' - '.$previewpic->filename.'</option>'."\n";
278
+ }
279
+ }
280
  if(is_array($picturelist)) {
281
  foreach($picturelist as $picture) {
282
  if ($picture->exclude) continue;
admin/overview.php CHANGED
@@ -137,7 +137,7 @@ function ngg_plugin_check() {
137
  img_ok: '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" class="icon" alt="ok"/>',
138
  img_fail: '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" class="icon" alt="failed" />',
139
  adminurl: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
140
- domain: '<?php echo esc_url( trailingslashit ( home_url() ) ); ?>'
141
  },
142
 
143
  run: function( index, state ) {
137
  img_ok: '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" class="icon" alt="ok"/>',
138
  img_fail: '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" class="icon" alt="failed" />',
139
  adminurl: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
140
+ domain: '<?php echo esc_url( home_url('index.php') ); ?>'
141
  },
142
 
143
  run: function( index, state ) {
admin/tinymce/window.php CHANGED
@@ -24,13 +24,13 @@ global $wpdb, $nggdb;
24
  <script type="text/javascript">
25
  jQuery(document).ready(function(){
26
  jQuery("#gallerytag").nggAutocomplete( {
27
- type: 'gallery',domain: "<?php echo home_url(); ?>/"
28
  });
29
  jQuery("#albumtag").nggAutocomplete( {
30
- type: 'album',domain: "<?php echo home_url(); ?>/"
31
  });
32
  jQuery("#singlepictag").nggAutocomplete( {
33
- type: 'image',domain: "<?php echo home_url(); ?>/"
34
  });
35
  });
36
  </script>
24
  <script type="text/javascript">
25
  jQuery(document).ready(function(){
26
  jQuery("#gallerytag").nggAutocomplete( {
27
+ type: 'gallery',domain: "<?php echo home_url('index.php'); ?>/"
28
  });
29
  jQuery("#albumtag").nggAutocomplete( {
30
+ type: 'album',domain: "<?php echo home_url('index.php'); ?>/"
31
  });
32
  jQuery("#singlepictag").nggAutocomplete( {
33
+ type: 'image',domain: "<?php echo home_url('index.php'); ?>/"
34
  });
35
  });
36
  </script>
changelog.txt CHANGED
@@ -3,9 +3,16 @@ by Alex Rabe & NextGEN DEV Team
3
 
4
  = V1.9.0 - sometimes =
5
  * TODO : Facebook connector
6
- * TODO : Switch to Plupload (http://www.plupload.com/)
7
  * TODO : Rework album page for large amount of galleries
8
 
 
 
 
 
 
 
 
9
  = V1.8.2 - 12.07.2011 =
10
  * Bugfix : Set pagination variables for search result, otherwise update failed
11
  * Bugfix : Update failed for paged galleries since WordPress 3.2
3
 
4
  = V1.9.0 - sometimes =
5
  * TODO : Facebook connector
6
+ * TODO : Switch to Plupload (http://www.plupload.com/) see also http://wordpress.org/extend/plugins/wplupload/
7
  * TODO : Rework album page for large amount of galleries
8
 
9
+ = V1.8.3 - 07.08.2011 =
10
+ * Changed : Support for simple custom permalink structures (i.e. /%category%/%postname%/)
11
+ * Bugfix : Sub-Albums in Albums didn't create the correct link
12
+ * Bugfix : AJAX Pagination didn't work anymore
13
+ * Bugfix : Adding index.php to home_url()
14
+ * Bugfix : Preview picture lost on backend gallery page 2 or higher
15
+
16
  = V1.8.2 - 12.07.2011 =
17
  * Bugfix : Set pagination variables for search result, otherwise update failed
18
  * Bugfix : Update failed for paged galleries since WordPress 3.2
js/ngg.js CHANGED
@@ -31,7 +31,7 @@ function ngg_ajax_navigation(e, obj) {
31
  }
32
 
33
  // try to find gallery number by checking the parents ID until we find a matching one
34
- var currentNode = obj;
35
  while (null != currentNode.parentNode && !jQuery.nodeName(currentNode.parentNode, "body") && "ngg-gallery-" != jQuery(currentNode.parentNode).attr("id").substring(0, 12)) {
36
  currentNode = currentNode.parentNode;
37
  }
31
  }
32
 
33
  // try to find gallery number by checking the parents ID until we find a matching one
34
+ var currentNode = obj.parentNode;
35
  while (null != currentNode.parentNode && !jQuery.nodeName(currentNode.parentNode, "body") && "ngg-gallery-" != jQuery(currentNode.parentNode).attr("id").substring(0, 12)) {
36
  currentNode = currentNode.parentNode;
37
  }
lib/core.php CHANGED
@@ -142,10 +142,15 @@ class nggGallery {
142
  * @return array $options
143
  */
144
  function get_option($key) {
 
 
145
  // get first the options from the database
146
  $options = get_option($key);
147
-
148
- // Get all key/value data for the current post.
 
 
 
149
  $meta_array = get_post_custom();
150
 
151
  // Ensure that this is a array
@@ -537,5 +542,34 @@ class nggGallery {
537
 
538
  return false;
539
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
540
  }
541
  ?>
142
  * @return array $options
143
  */
144
  function get_option($key) {
145
+ global $post;
146
+
147
  // get first the options from the database
148
  $options = get_option($key);
149
+
150
+ if ( $post == null )
151
+ return $options;
152
+
153
+ // Get all key/value data for the current post.
154
  $meta_array = get_post_custom();
155
 
156
  // Ensure that this is a array
542
 
543
  return false;
544
  }
545
+
546
+ /**
547
+ * get_memory_usage
548
+ *
549
+ * @access only for debug purpose
550
+ * @since 1.8.3
551
+ * @param string $text
552
+ * @return void
553
+ */
554
+ function get_memory( $text = '' ) {
555
+ global $memory;
556
+
557
+ $memory_peak = memory_get_usage();
558
+ $diff = 0;
559
+
560
+ if ( isset($memory) )
561
+ $diff = $memory_peak - $memory;
562
+
563
+ $exp = ($diff < 0) ? '-' : '';
564
+ $diff = ($exp == '-') ? 0 - $diff : $diff;
565
+
566
+ $memory = $memory_peak;
567
+
568
+ $unit = array('b','kb','mb','gb','tb','pb');
569
+ $rounded = @round($diff/pow(1024,($i=floor(log($diff,1024)))),2).' '.$unit[$i];
570
+
571
+ echo $text . ': ' . $exp . $rounded .'<br />';
572
+
573
+ }
574
  }
575
  ?>
lib/image.php CHANGED
@@ -68,13 +68,14 @@ class nggImage{
68
  $this->thumbURL = site_url() . '/' . $this->path . '/thumbs/thumbs_' . $this->filename;
69
  $this->imagePath = WINABSPATH.$this->path . '/' . $this->filename;
70
  $this->thumbPath = WINABSPATH.$this->path . '/thumbs/thumbs_' . $this->filename;
71
- $this->meta_data = unserialize($this->meta_data);
72
  $this->imageHTML = $this->get_href_link();
73
  $this->thumbHTML = $this->get_href_thumb_link();
74
 
75
  do_action_ref_array('ngg_get_image', array(&$this));
76
- wp_cache_add($this->pid, $this, 'ngg_image');
77
-
 
78
  // Get tags only if necessary
79
  unset($this->tags);
80
  }
@@ -85,6 +86,10 @@ class nggImage{
85
  * Applies the filter 'ngg_get_thumbcode'
86
  */
87
  function get_thumbcode($galleryname = '') {
 
 
 
 
88
  // read the option setting
89
  $ngg_options = get_option('ngg_options');
90
 
@@ -209,6 +214,10 @@ class nggImage{
209
 
210
  return $this->permalink;
211
  }
 
 
 
 
212
  }
213
  endif;
214
  ?>
68
  $this->thumbURL = site_url() . '/' . $this->path . '/thumbs/thumbs_' . $this->filename;
69
  $this->imagePath = WINABSPATH.$this->path . '/' . $this->filename;
70
  $this->thumbPath = WINABSPATH.$this->path . '/thumbs/thumbs_' . $this->filename;
71
+ $this->meta_data = unserialize($this->meta_data);
72
  $this->imageHTML = $this->get_href_link();
73
  $this->thumbHTML = $this->get_href_thumb_link();
74
 
75
  do_action_ref_array('ngg_get_image', array(&$this));
76
+
77
+ // Note wp_cache_add will increase memory needs (4-8 kb)
78
+ //wp_cache_add($this->pid, $this, 'ngg_image');
79
  // Get tags only if necessary
80
  unset($this->tags);
81
  }
86
  * Applies the filter 'ngg_get_thumbcode'
87
  */
88
  function get_thumbcode($galleryname = '') {
89
+
90
+ // clean up the name
91
+ $galleryname = sanitize_title( $galleryname );
92
+
93
  // read the option setting
94
  $ngg_options = get_option('ngg_options');
95
 
214
 
215
  return $this->permalink;
216
  }
217
+
218
+ function __destruct() {
219
+
220
+ }
221
  }
222
  endif;
223
  ?>
lib/ngg-db.php CHANGED
@@ -252,7 +252,8 @@ class nggdb {
252
  // due to a browser bug we need to remove the key for associative array for json request
253
  // (see http://code.google.com/p/chromium/issues/detail?id=883)
254
  if ($json) $key = $i++;
255
- $gallery[$key] = new nggImage( $value );
 
256
  }
257
  }
258
 
252
  // due to a browser bug we need to remove the key for associative array for json request
253
  // (see http://code.google.com/p/chromium/issues/detail?id=883)
254
  if ($json) $key = $i++;
255
+ $gallery[$key] = new nggImage( $value ); // keep in my each request requery 8 - 16 kb memory usage
256
+
257
  }
258
  }
259
 
lib/rewrite.php CHANGED
@@ -12,9 +12,22 @@
12
  */
13
  class nggRewrite {
14
 
15
- // default value
16
- var $slug = 'nggallery';
17
-
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Constructor
20
  */
@@ -37,6 +50,26 @@ class nggRewrite {
37
 
38
  if ($this->options['usePermalinks'])
39
  add_action('generate_rewrite_rules', array(&$this, 'RewriteRules'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
 
42
  } // end of initialization
@@ -47,12 +80,17 @@ class nggRewrite {
47
  function get_permalink( $args ) {
48
  global $wp_rewrite, $wp_query;
49
 
 
 
 
 
50
  //TODO: Watch out for ticket http://trac.wordpress.org/ticket/6627
51
  if ($wp_rewrite->using_permalinks() && $this->options['usePermalinks'] ) {
52
  $post = &get_post(get_the_ID());
53
 
54
- // $_GET from wp_query
55
- $album = get_query_var('album');
 
56
  if ( !empty( $album ) )
57
  $args ['album'] = $album;
58
 
@@ -75,6 +113,9 @@ class nggRewrite {
75
 
76
  // 1. Post / Page url + main slug
77
  $url = trailingslashit ( get_permalink ($post->ID) ) . $this->slug;
 
 
 
78
 
79
  // 2. Album, pid or tags
80
  if (isset ($args['album']) && ($args['gallery'] == false) )
@@ -105,10 +146,6 @@ class nggRewrite {
105
  if (is_home())
106
  $args['pageid'] = get_the_ID();
107
 
108
- // taken from is_frontpage plugin, required for static homepage
109
- $show_on_front = get_option('show_on_front');
110
- $page_on_front = get_option('page_on_front');
111
-
112
  if (($show_on_front == 'page') && ($page_on_front == get_the_ID()))
113
  $args['page_id'] = get_the_ID();
114
 
@@ -225,31 +262,11 @@ class nggRewrite {
225
  global $ngg;
226
 
227
  $rewrite_rules = array (
228
-
229
- // new page rewrites
230
- '(.+?)/' . $this->slug . '/page-([0-9]+)/?$' => 'index.php?pagename=$matches[1]&nggpage=$matches[2]',
231
- '(.+?)/' . $this->slug . '/image/([^/]+)/?$' => 'index.php?pagename=$matches[1]&pid=$matches[2]',
232
- '(.+?)/' . $this->slug . '/image/([^/]+)/page-([0-9]+)/?$' => 'index.php?pagename=$matches[1]&pid=$matches[2]&nggpage=$matches[3]',
233
- '(.+?)/' . $this->slug . '/slideshow/?$' => 'index.php?pagename=$matches[1]&show=slide',
234
- '(.+?)/' . $this->slug . '/images/?$' => 'index.php?pagename=$matches[1]&show=gallery',
235
- '(.+?)/' . $this->slug . '/tags/([^/]+)/?$' => 'index.php?pagename=$matches[1]&gallerytag=$matches[2]',
236
- '(.+?)/' . $this->slug . '/tags/([^/]+)/page-([0-9]+)/?$' => 'index.php?pagename=$matches[1]&gallerytag=$matches[2]&nggpage=$matches[3]',
237
-
238
- '(.+?)/' . $this->slug . '/([^/]+)/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]',
239
- '(.+?)/' . $this->slug . '/([^/]+)/page-([0-9]+)/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&nggpage=$matches[3]',
240
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]',
241
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/slideshow/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]&show=slide',
242
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/images/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]&show=gallery',
243
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/page-([0-9]+)/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]&nggpage=$matches[4]',
244
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/page-([0-9]+)/slideshow/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]&nggpage=$matches[4]&show=slide',
245
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/page-([0-9]+)/images/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]&nggpage=$matches[4]&show=gallery',
246
- '(.+?)/' . $this->slug . '/([^/]+)/([^/]+)/image/([^/]+)/?$' => 'index.php?pagename=$matches[1]&album=$matches[2]&gallery=$matches[3]&pid=$matches[4]',
247
-
248
  // XML request
249
- $this->slug . '/slideshow/([0-9]+)/?$' => 'index.php?imagerotator=true&gid=$matches[1]',
250
- );
251
 
252
- $rewrite_rules = array_merge($this->generate_rewrite_rules(), $rewrite_rules);
253
  $wp_rewrite->rules = array_merge($rewrite_rules, $wp_rewrite->rules);
254
  }
255
 
@@ -262,25 +279,7 @@ class nggRewrite {
262
  function generate_rewrite_rules() {
263
  global $wp_rewrite;
264
 
265
- $new_rules = array(
266
- '/page-([0-9]+)/' => '&nggpage=[matches]',
267
- '/image/([^/]+)/' => '&pid=[matches]',
268
- '/image/([^/]+)/page-([0-9]+)/' => '&pid=[matches]&nggpage=[matches]',
269
- '/slideshow/' => '&show=slide',
270
- '/images/' => '&show=gallery',
271
- '/tags/([^/]+)/' => '&gallerytag=[matches]',
272
- '/tags/([^/]+)/page-([0-9]+)/' => '&gallerytag=[matches]&nggpage=[matches]',
273
- '/([^/]+)/' => '&album=[matches]',
274
- '/([^/]+)/page-([0-9]+)/' => '&album=[matches]&nggpage=[matches]',
275
- '/([^/]+)/([^/]+)/' => '&album=[matches]&gallery=[matches]',
276
- '/([^/]+)/([^/]+)/slideshow/' => '&album=[matches]&gallery=[matches]&show=slide',
277
- '/([^/]+)/([^/]+)/images/' => '&album=[matches]&gallery=[matches]&show=gallery',
278
- '/([^/]+)/([^/]+)/page-([0-9]+)/' => '&album=[matches]&gallery=[matches]&nggpage=[matches]',
279
- '/([^/]+)/([^/]+)/page-([0-9]+)/slideshow/' => '&album=[matches]&gallery=[matches]&nggpage=[matches]&show=slide',
280
- '/([^/]+)/([^/]+)/page-([0-9]+)/images/' => '&album=[matches]&gallery=[matches]&nggpage=[matches]&show=gallery',
281
- '/([^/]+)/([^/]+)/image/([^/]+)/' => '&album=[matches]&gallery=[matches]&pid=[matches]'
282
- );
283
-
284
  $permalink_structure = $wp_rewrite->permalink_structure;
285
 
286
  //get everything up to the first rewrite tag
@@ -290,7 +289,7 @@ class nggRewrite {
290
 
291
  $num_tokens = count($tokens[0]);
292
 
293
- $index = $wp_rewrite->index; //probably 'index.php'
294
 
295
  //build a list from the rewritecode and queryreplace arrays, that will look something like
296
  //tagname=$matches[i] where i is the current $i
@@ -329,10 +328,71 @@ class nggRewrite {
329
 
330
  //get the 'tagname=$matches[i]'
331
  $query = ( isset($queries) && is_array($queries) ) ? $queries[$num_toks - 1] : '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
 
333
- $post_rewrite = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
- foreach ( $new_rules as $regex => $new_query) {
 
 
336
 
337
  // first add your nextgen slug
338
  $final_match = $match . $this->slug;
@@ -348,16 +408,17 @@ class nggRewrite {
348
  $new_query = preg_replace('/\[matches\]/', '$matches[' . ++$offset . ']', $new_query, 1);
349
  }
350
  $final_query = $query . $new_query;
351
-
352
  //close the match and finalise the query
353
  $final_match .= '?$';
354
- $final_query = $index . '?' . $final_query;
355
-
356
- $post_rewrite = array_merge($post_rewrite, array($final_match => $final_query));
 
357
  }
358
 
359
- return $post_rewrite; //the finished rules. phew!
360
- }
361
 
362
  } // of nggRewrite CLASS
363
 
12
  */
13
  class nggRewrite {
14
 
15
+ /**
16
+ * Default slug name
17
+ *
18
+ * @since 1.8.0
19
+ * @var string
20
+ */
21
+ var $slug = 'nggallery';
22
+
23
+ /**
24
+ * Contain the main rewrite structure
25
+ *
26
+ * @since 1.8.3
27
+ * @var array
28
+ */
29
+ var $ngg_rules = '';
30
+
31
  /**
32
  * Constructor
33
  */
50
 
51
  if ($this->options['usePermalinks'])
52
  add_action('generate_rewrite_rules', array(&$this, 'RewriteRules'));
53
+
54
+ // setup the main rewrite structure for the plugin
55
+ $this->ngg_rules = array(
56
+ '/page-([0-9]+)/' => '&nggpage=[matches]',
57
+ '/image/([^/]+)/' => '&pid=[matches]',
58
+ '/image/([^/]+)/page-([0-9]+)/' => '&pid=[matches]&nggpage=[matches]',
59
+ '/slideshow/' => '&show=slide',
60
+ '/images/' => '&show=gallery',
61
+ '/tags/([^/]+)/' => '&gallerytag=[matches]',
62
+ '/tags/([^/]+)/page-([0-9]+)/' => '&gallerytag=[matches]&nggpage=[matches]',
63
+ '/([^/]+)/' => '&album=[matches]',
64
+ '/([^/]+)/page-([0-9]+)/' => '&album=[matches]&nggpage=[matches]',
65
+ '/([^/]+)/([^/]+)/' => '&album=[matches]&gallery=[matches]',
66
+ '/([^/]+)/([^/]+)/slideshow/' => '&album=[matches]&gallery=[matches]&show=slide',
67
+ '/([^/]+)/([^/]+)/images/' => '&album=[matches]&gallery=[matches]&show=gallery',
68
+ '/([^/]+)/([^/]+)/page-([0-9]+)/' => '&album=[matches]&gallery=[matches]&nggpage=[matches]',
69
+ '/([^/]+)/([^/]+)/page-([0-9]+)/slideshow/' => '&album=[matches]&gallery=[matches]&nggpage=[matches]&show=slide',
70
+ '/([^/]+)/([^/]+)/page-([0-9]+)/images/' => '&album=[matches]&gallery=[matches]&nggpage=[matches]&show=gallery',
71
+ '/([^/]+)/([^/]+)/image/([^/]+)/' => '&album=[matches]&gallery=[matches]&pid=[matches]'
72
+ );
73
 
74
 
75
  } // end of initialization
80
  function get_permalink( $args ) {
81
  global $wp_rewrite, $wp_query;
82
 
83
+ // taken from is_frontpage plugin, required for static homepage
84
+ $show_on_front = get_option('show_on_front');
85
+ $page_on_front = get_option('page_on_front');
86
+
87
  //TODO: Watch out for ticket http://trac.wordpress.org/ticket/6627
88
  if ($wp_rewrite->using_permalinks() && $this->options['usePermalinks'] ) {
89
  $post = &get_post(get_the_ID());
90
 
91
+ // If the album is not set before get it from the wp_query ($_GET)
92
+ if ( !isset ($args['album'] ) )
93
+ $album = get_query_var('album');
94
  if ( !empty( $album ) )
95
  $args ['album'] = $album;
96
 
113
 
114
  // 1. Post / Page url + main slug
115
  $url = trailingslashit ( get_permalink ($post->ID) ) . $this->slug;
116
+ //TODO: For static home pages generate the link to the selected page, still doesn't work
117
+ if (($show_on_front == 'page') && ($page_on_front == get_the_ID()))
118
+ $url = trailingslashit ( $post->guid ) . $this->slug;
119
 
120
  // 2. Album, pid or tags
121
  if (isset ($args['album']) && ($args['gallery'] == false) )
146
  if (is_home())
147
  $args['pageid'] = get_the_ID();
148
 
 
 
 
 
149
  if (($show_on_front == 'page') && ($page_on_front == get_the_ID()))
150
  $args['page_id'] = get_the_ID();
151
 
262
  global $ngg;
263
 
264
  $rewrite_rules = array (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  // XML request
266
+ $this->slug . '/slideshow/([0-9]+)/?$' => 'index.php?imagerotator=true&gid=$matches[1]'
267
+ );
268
 
269
+ $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules() );
270
  $wp_rewrite->rules = array_merge($rewrite_rules, $wp_rewrite->rules);
271
  }
272
 
279
  function generate_rewrite_rules() {
280
  global $wp_rewrite;
281
 
282
+ $rewrite_rules = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  $permalink_structure = $wp_rewrite->permalink_structure;
284
 
285
  //get everything up to the first rewrite tag
289
 
290
  $num_tokens = count($tokens[0]);
291
 
292
+ $this->index = $wp_rewrite->index; //probably 'index.php'
293
 
294
  //build a list from the rewritecode and queryreplace arrays, that will look something like
295
  //tagname=$matches[i] where i is the current $i
328
 
329
  //get the 'tagname=$matches[i]'
330
  $query = ( isset($queries) && is_array($queries) ) ? $queries[$num_toks - 1] : '';
331
+
332
+ if ( $num_toks ) {
333
+ // In the case we build for each and every page ( based on a simple %pagename% rule ) the rewrite rules,
334
+ // we need to add them first, then the post rules
335
+ if ( $wp_rewrite->use_verbose_page_rules )
336
+ $rewrite_rules = array_merge ( $this->page_rewrite_rules(), $this->add_rewrite_rules( $match, $query, $num_toks ) );
337
+ else
338
+ $rewrite_rules = array_merge ( $this->add_rewrite_rules( $match, $query, $num_toks ), $this->page_rewrite_rules() );
339
+ }
340
+
341
+ return $rewrite_rules;
342
+ }
343
+
344
+ /**
345
+ * Retrieve all of the rewrite rules for pages.
346
+ *
347
+ * If the 'use_verbose_page_rules' property is false, then there will only
348
+ * be a single rewrite rule for pages for those matching '%pagename%'. With
349
+ * the property set to true, the attachments and the pages will be added for
350
+ * each individual attachment URI and page URI, respectively.
351
+ *
352
+ * @since 1.8.3
353
+ * @access public
354
+ * @return array
355
+ */
356
+ function page_rewrite_rules() {
357
+ global $wp_rewrite;
358
+
359
+ $rewrite_rules = array();
360
 
361
+ if ( ! $wp_rewrite->use_verbose_page_rules ) {
362
+
363
+ $rewrite_rules = $this->add_rewrite_rules( "(.+?)/", 'pagename=$matches[1]', 1 );
364
+ return $rewrite_rules;
365
+ }
366
+
367
+ $page_uris = $wp_rewrite->page_uri_index();
368
+ $uris = $page_uris[0];
369
+
370
+ if ( is_array( $uris ) ) {
371
+
372
+ foreach ( $uris as $uri => $pagename ) {
373
+ $rewrite_rules = array_merge($rewrite_rules, $this->add_rewrite_rules( "($uri)/", 'pagename=$matches[1]', 1 ) );
374
+ }
375
+
376
+ }
377
+
378
+ return $rewrite_rules;
379
+ }
380
+
381
+ /**
382
+ * Build the final structure of the rewrite rules based on match/query
383
+ *
384
+ * @since 1.8.3
385
+ * @param string $match
386
+ * @param string $query
387
+ * @param int $num_toks
388
+ * @return array
389
+ */
390
+ function add_rewrite_rules( $match, $query, $num_toks ) {
391
+ global $wp_rewrite;
392
 
393
+ $rewrite_rules = array();
394
+
395
+ foreach ( $this->ngg_rules as $regex => $new_query) {
396
 
397
  // first add your nextgen slug
398
  $final_match = $match . $this->slug;
408
  $new_query = preg_replace('/\[matches\]/', '$matches[' . ++$offset . ']', $new_query, 1);
409
  }
410
  $final_query = $query . $new_query;
411
+
412
  //close the match and finalise the query
413
  $final_match .= '?$';
414
+ $final_query = $this->index . '?' . $final_query;
415
+
416
+ $rewrite_rules = array_merge($rewrite_rules, array($final_match => $final_query));
417
+
418
  }
419
 
420
+ return $rewrite_rules;
421
+ }
422
 
423
  } // of nggRewrite CLASS
424
 
nggallery.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: NextGEN Gallery
4
  Plugin URI: http://alexrabe.de/?page_id=80
5
  Description: A NextGENeration Photo Gallery for WordPress
6
  Author: Alex Rabe
7
- Version: 1.8.2
8
 
9
  Author URI: http://alexrabe.de/
10
 
@@ -34,7 +34,7 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
34
  if (!class_exists('nggLoader')) {
35
  class nggLoader {
36
 
37
- var $version = '1.8.2';
38
  var $dbversion = '1.8.0';
39
  var $minium_WP = '3.1';
40
  var $donators = 'http://nextgen.boelinger.com/donators.php';
@@ -363,7 +363,7 @@ class nggLoader {
363
  // Load AJAX navigation script, works only with shutter script as we need to add the listener
364
  if ( $this->options['galAjaxNav'] ) {
365
  if ( ($this->options['thumbEffect'] == "shutter") || function_exists('srel_makeshutter') ) {
366
- wp_enqueue_script ( 'ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery'), '2.0');
367
  wp_localize_script( 'ngg_script', 'ngg_ajax', array('path' => NGGALLERY_URLPATH,
368
  'callback' => home_url() . '/' . 'index.php?callback=ngg-ajax',
369
  'loading' => __('loading', 'nggallery'),
4
  Plugin URI: http://alexrabe.de/?page_id=80
5
  Description: A NextGENeration Photo Gallery for WordPress
6
  Author: Alex Rabe
7
+ Version: 1.8.3
8
 
9
  Author URI: http://alexrabe.de/
10
 
34
  if (!class_exists('nggLoader')) {
35
  class nggLoader {
36
 
37
+ var $version = '1.8.3';
38
  var $dbversion = '1.8.0';
39
  var $minium_WP = '3.1';
40
  var $donators = 'http://nextgen.boelinger.com/donators.php';
363
  // Load AJAX navigation script, works only with shutter script as we need to add the listener
364
  if ( $this->options['galAjaxNav'] ) {
365
  if ( ($this->options['thumbEffect'] == "shutter") || function_exists('srel_makeshutter') ) {
366
+ wp_enqueue_script ( 'ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery'), '2.1');
367
  wp_localize_script( 'ngg_script', 'ngg_ajax', array('path' => NGGALLERY_URLPATH,
368
  'callback' => home_url() . '/' . 'index.php?callback=ngg-ajax',
369
  'loading' => __('loading', 'nggallery'),
nggfunctions.php CHANGED
@@ -157,6 +157,7 @@ function nggShowGallery( $galleryID, $template = '', $images = false ) {
157
  $ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
158
 
159
  // get gallery values
 
160
  $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
161
 
162
  if ( !$picturelist )
157
  $ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
158
 
159
  // get gallery values
160
+ //TODO: Use pagination limits here to reduce memory needs
161
  $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
162
 
163
  if ( !$picturelist )
readme.txt CHANGED
@@ -130,6 +130,13 @@ To show the most recent added mages : **[recent max=x ]**
130
 
131
  == Changelog ==
132
 
 
 
 
 
 
 
 
133
  = V1.8.2 - 12.07.2011 =
134
  * Bugfix : Set pagination variables for search result, otherwise update failed
135
  * Bugfix : Update failed for paged galleries since WordPress 3.2
130
 
131
  == Changelog ==
132
 
133
+ = V1.8.3 - 07.08.2011 =
134
+ * Changed : Support for simple custom permalink structures (i.e. /%category%/%postname%/)
135
+ * Bugfix : Sub-Albums in Albums didn't create the correct link
136
+ * Bugfix : AJAX Pagination didn't work anymore
137
+ * Bugfix : Adding index.php to home_url()
138
+ * Bugfix : Preview picture lost on backend gallery page 2 or higher
139
+
140
  = V1.8.2 - 12.07.2011 =
141
  * Bugfix : Set pagination variables for search result, otherwise update failed
142
  * Bugfix : Update failed for paged galleries since WordPress 3.2