NextGEN Gallery – WordPress Gallery Plugin - Version 0.94

Version Description

Download this release

Release Info

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

Code changes from version 0.93 to 0.94

admin/wp25/about.php CHANGED
@@ -101,7 +101,8 @@ function ngg_list_contributors() {
101
  "David Potter (Documentation and Help)" => "http://dpotter.net/",
102
  "Carlale Chen (Chinese Translation)" => "http://0-o-0.cc/",
103
  "Nica Luigi Cristian (Romanian Translation)" => "http://www.cristiannica.com/",
104
- "Igor Shevkoplyas (Russian Translation)" => "http://www.russian-translation-matters.com"
 
105
  );
106
 
107
  ksort($contributors);
101
  "David Potter (Documentation and Help)" => "http://dpotter.net/",
102
  "Carlale Chen (Chinese Translation)" => "http://0-o-0.cc/",
103
  "Nica Luigi Cristian (Romanian Translation)" => "http://www.cristiannica.com/",
104
+ "Igor Shevkoplyas (Russian Translation)" => "http://www.russian-translation-matters.com",
105
+ "Alexandr Kindras (Code contributor)" => "http://www.fixdev.com"
106
  );
107
 
108
  ksort($contributors);
changelog.txt CHANGED
@@ -1,6 +1,11 @@
1
  NextGEN Gallery
2
  by Alex Rabe & NextGEN DEV Team
3
 
 
 
 
 
 
4
  V0.93 - 12.04.2008
5
  - Added : Select Full-Size or Singlepic in Media Upload
6
  - Added : Check for minimum 8 MB Memory
1
  NextGEN Gallery
2
  by Alex Rabe & NextGEN DEV Team
3
 
4
+ V0.94 - 20.04.2008
5
+ - Added : New filter option ngg_create_gallery_link
6
+ - Changed : Reduce amount of DB queries in albums (Big THX to Alexandr Kindras)
7
+ - Changed : Revert wpautop priority change. Doesn't good for other plugins
8
+
9
  V0.93 - 12.04.2008
10
  - Added : Select Full-Size or Singlepic in Media Upload
11
  - Added : Check for minimum 8 MB Memory
css/nggallery.css CHANGED
@@ -32,7 +32,7 @@ html>body .ngg-album {
32
  overflow:hidden;
33
  padding: 5px;
34
  margin-bottom: 5px;
35
- border: 1px solid #fff;
36
  }
37
 
38
  .ngg-album {
32
  overflow:hidden;
33
  padding: 5px;
34
  margin-bottom: 5px;
35
+ border: 1px solid #cccccc;
36
  }
37
 
38
  .ngg-album {
lib/nggallery.lib.php CHANGED
@@ -238,14 +238,16 @@ class nggallery {
238
  // get the thumbnail url to the image
239
  //TODO:Combine in one class
240
  /**********************************************************/
241
- function get_thumbnail_url($imageID){
242
  // get the complete url to the thumbnail
243
  global $wpdb;
244
 
 
 
 
245
  // get gallery values
246
- $galleryID = $wpdb->get_var("SELECT galleryid FROM $wpdb->nggpictures WHERE pid = '$imageID' ");
247
- $fileName = $wpdb->get_var("SELECT filename FROM $wpdb->nggpictures WHERE pid = '$imageID' ");
248
- $picturepath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
249
 
250
  // set gallery url
251
  $folder_url = get_option ('siteurl')."/".$picturepath.nggallery::get_thumbnail_folder($picturepath, FALSE);
@@ -258,14 +260,16 @@ class nggallery {
258
  /**********************************************************/
259
  // get the complete url to the image
260
  /**********************************************************/
261
- function get_image_url($imageID){
262
 
263
  global $wpdb;
 
 
 
264
 
265
  // get gallery values
266
- $galleryID = $wpdb->get_var("SELECT galleryid FROM $wpdb->nggpictures WHERE pid = '$imageID' ");
267
- $fileName = $wpdb->get_var("SELECT filename FROM $wpdb->nggpictures WHERE pid = '$imageID' ");
268
- $picturepath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
269
 
270
  // set gallery url
271
  $imageURL = get_option ('siteurl')."/".$picturepath."/".$fileName;
238
  // get the thumbnail url to the image
239
  //TODO:Combine in one class
240
  /**********************************************************/
241
+ function get_thumbnail_url($imageID, $picturepath = '', $fileName = ''){
242
  // get the complete url to the thumbnail
243
  global $wpdb;
244
 
245
+ // safety first
246
+ $imageID = (int) $imageID;
247
+
248
  // get gallery values
249
+ if (empty($fileName)) list($galleryID, $fileName) = $wpdb->get_row("SELECT galleryid, filename FROM $wpdb->nggpictures WHERE pid = '$imageID' ", ARRAY_N);
250
+ if (empty($picturepath)) $picturepath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
 
251
 
252
  // set gallery url
253
  $folder_url = get_option ('siteurl')."/".$picturepath.nggallery::get_thumbnail_folder($picturepath, FALSE);
260
  /**********************************************************/
261
  // get the complete url to the image
262
  /**********************************************************/
263
+ function get_image_url($imageID, $picturepath = '', $fileName = ''){
264
 
265
  global $wpdb;
266
+
267
+ // safety first
268
+ $imageID = (int) $imageID;
269
 
270
  // get gallery values
271
+ if (empty($fileName)) list($galleryID, $fileName) = $wpdb->get_row("SELECT galleryid, filename FROM $wpdb->nggpictures WHERE pid = '$imageID' ", ARRAY_N);
272
+ if (empty($picturepath)) $picturepath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
 
273
 
274
  // set gallery url
275
  $imageURL = get_option ('siteurl')."/".$picturepath."/".$fileName;
nggallery.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: NextGEN Gallery
4
  Plugin URI: http://alexrabe.boelinger.com/?page_id=80
5
  Description: A NextGENeration Photo gallery for the WEB2.0(beta).
6
  Author: NextGEN DEV-Team
7
- Version: 0.93
8
 
9
  Author URI: http://alexrabe.boelinger.com/
10
 
@@ -62,7 +62,7 @@ if ( ($memory_limit != 0) && ($memory_limit < 12 ) ) {
62
  }
63
 
64
  // Version and path to check version
65
- define('NGGVERSION', "0.93");
66
  // Minimum required database version
67
  define('NGG_DBVERSION', "0.84");
68
  define('NGGURL', "http://nextgen.boelinger.com/version.php");
@@ -124,17 +124,16 @@ if (is_admin()) {
124
  // Load the gallery generator
125
  include_once (dirname (__FILE__)."/nggfunctions.php");
126
 
127
- // avoid wpautop() in gallery output
128
- remove_filter('the_content', 'wpautop');
129
- remove_filter('the_excerpt', 'wpautop');
130
- add_filter('the_content', 'wpautop',7);
131
- add_filter('the_excerpt', 'wpautop',7);
 
132
 
133
  // Action calls for all functions
134
- // required in WP 2.5, NextGEN should have higher priority than 9
135
- // see also http://trac.wordpress.org/ticket/6436
136
- add_filter('the_content', 'searchnggallerytags', 8);
137
- add_filter('the_excerpt', 'searchnggallerytags', 8);
138
  }
139
 
140
  // Load tinymce button
4
  Plugin URI: http://alexrabe.boelinger.com/?page_id=80
5
  Description: A NextGENeration Photo gallery for the WEB2.0(beta).
6
  Author: NextGEN DEV-Team
7
+ Version: 0.94
8
 
9
  Author URI: http://alexrabe.boelinger.com/
10
 
62
  }
63
 
64
  // Version and path to check version
65
+ define('NGGVERSION', "0.94");
66
  // Minimum required database version
67
  define('NGG_DBVERSION', "0.84");
68
  define('NGGURL', "http://nextgen.boelinger.com/version.php");
124
  // Load the gallery generator
125
  include_once (dirname (__FILE__)."/nggfunctions.php");
126
 
127
+ // required in WP 2.5, NextGEN should have higher priority than the shortcode
128
+ // see also http://trac.wordpress.org/ticket/6436
129
+ if (IS_WP25) {
130
+ remove_filter('the_content', 'do_shortcode', 9);
131
+ add_filter('the_content', 'do_shortcode', 11);
132
+ }
133
 
134
  // Action calls for all functions
135
+ add_filter('the_content', 'searchnggallerytags', 10);
136
+ add_filter('the_excerpt', 'searchnggallerytags', 10);
 
 
137
  }
138
 
139
  // Load tinymce button
nggfunctions.php CHANGED
@@ -37,11 +37,12 @@ function searchnggallerytags($content) {
37
  if (is_array($matches)) {
38
  foreach ($matches[1] as $key =>$v0) {
39
  // check for album id
40
- $albumID = $wpdb->get_var("SELECT id FROM $wpdb->nggalbum WHERE id = '$v0' ");
41
- if(!$albumID) $albumID = $wpdb->get_var("SELECT id FROM $wpdb->nggalbum WHERE name = '$v0' ");
 
42
  if($albumID) {
43
  $search = $matches[0][$key];
44
- $replace= nggShowAlbum($albumID,$matches[2][$key]);
45
  $content= str_replace ($search, $replace, $content);
46
  }
47
  }
@@ -332,9 +333,14 @@ function nggCreateGallery($picturelist,$galleryID = false) {
332
  $folder_url = get_option ('siteurl')."/".$picture->path."/";
333
  $thumbnailURL = get_option ('siteurl')."/".$picture->path.nggallery::get_thumbnail_folder($picture->path, FALSE);
334
  $thumb_prefix = nggallery::get_thumbnail_prefix($picture->path, FALSE);
 
335
  // choose link between imagebrowser or effect
 
336
 
337
- $link =($ngg_options['galImgBrowser']) ? $nggRewrite->get_permalink(array('pid'=>$picture->pid)) : $folder_url.$picture->filename;
 
 
 
338
  // create output
339
  $out .= '<div id="ngg-image-'. $picture->pid .'" class="ngg-gallery-thumbnail-box '. $class_desc .'">'."\n\t";
340
  $out .= '<div class="ngg-gallery-thumbnail" '.$setwidth.' >'."\n\t";
@@ -355,7 +361,7 @@ function nggCreateGallery($picturelist,$galleryID = false) {
355
  }
356
 
357
  /**********************************************************/
358
- function nggShowAlbum($albumID,$mode = "extend") {
359
 
360
  global $wpdb;
361
 
@@ -376,18 +382,15 @@ function nggShowAlbum($albumID,$mode = "extend") {
376
 
377
  $mode = ltrim($mode,',');
378
  $albumID = $wpdb->escape($albumID);
379
- $sortorder = $wpdb->get_var("SELECT sortorder FROM $wpdb->nggalbum WHERE id = '$albumID' ");
380
  if (!empty($sortorder)) {
381
  $gallery_array = unserialize($sortorder);
382
  }
383
 
384
  $out = '<div class="ngg-albumoverview">';
385
 
386
- if (is_array($gallery_array)) {
387
- foreach ($gallery_array as $galleryID) {
388
- $out .= nggCreateAlbum($galleryID,$mode,$albumID);
389
- }
390
- }
391
 
392
  $out .= '</div>'."\n";
393
  $out .= '<div class="ngg-clear"></div>'."\n";
@@ -397,57 +400,74 @@ function nggShowAlbum($albumID,$mode = "extend") {
397
  }
398
 
399
  /**********************************************************/
400
- function nggCreateAlbum($galleryID,$mode = "extend",$albumID = 0) {
401
  // create a gallery overview div
402
 
403
  global $wpdb, $nggRewrite;
404
 
405
  $ngg_options = nggallery::get_option('ngg_options');
406
 
407
- $galleryID = $wpdb->escape($galleryID);
408
- $gallerycontent = $wpdb->get_row("SELECT * FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
409
-
410
- // choose between variable and page link
411
- if ($ngg_options['galNoPages']) {
412
- $args['album'] = $albumID;
413
- $args['gallery'] = $galleryID;
414
- $link = $nggRewrite->get_permalink($args);
415
- } else {
416
- $link = get_permalink($gallerycontent->pageid);
417
- }
418
-
419
- if ($gallerycontent) {
420
- $counter = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = '$galleryID' AND exclude != 1");
421
- if ($mode == "compact") {
422
- if ($gallerycontent->previewpic != 0)
423
- $insertpic = '<img class="Thumb" alt="'.$gallerycontent->title.'" src="'.nggallery::get_thumbnail_url($gallerycontent->previewpic).'"/>';
424
- else
425
- $insertpic = __('Watch gallery', 'nggallery');
426
- $out = '
427
- <div class="ngg-album-compact">
428
- <div class="ngg-album-compactbox">
429
- <div class="ngg-album-link">
430
- <a class="Link" href="'.$link.'">'.$insertpic.'</a>
431
- </div>
432
- </div>
433
- <h4><a class="ngg-album-desc" title="'.$gallerycontent->title.'" href="'.$link.'">'.$gallerycontent->title.'</a></h4>
434
- <p><strong>'.$counter.'</strong> '.__('Photos', 'nggallery').'</p></div>';
435
  } else {
436
- // mode extend
437
- if ($gallerycontent->previewpic != 0)
438
- $insertpic = '<img src="'.nggallery::get_thumbnail_url($gallerycontent->previewpic).'" alt="'.$gallerycontent->title.'" title="'.$gallerycontent->title.'"/>';
439
- else
440
- $insertpic = __('Watch gallery', 'nggallery');
441
- $out = '
442
- <div class="ngg-album">
443
- <div class="ngg-albumtitle"><a href="'.$link.'">'.$gallerycontent->title.'</a></div>
444
- <div class="ngg-albumcontent">
445
- <div class="ngg-thumbnail"><a href="'.$link.'">'.$insertpic.'</a></div>
446
- <div class="ngg-description"><p>'.html_entity_decode(stripslashes($gallerycontent->galdesc)).'</p><p><strong>'.$counter.'</strong> '.__('Photos', 'nggallery').'</p></div>'."\n".'</div>'."\n".'</div>';
447
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
  }
449
  }
450
-
451
  return $out;
452
  }
453
 
@@ -779,5 +799,21 @@ function the_related_images($type = 'tags', $maxNumbers = 7) {
779
  // function for theme authors
780
  echo nggShowRelatedImages($type, $maxNumbers);
781
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
782
 
783
  ?>
37
  if (is_array($matches)) {
38
  foreach ($matches[1] as $key =>$v0) {
39
  // check for album id
40
+ list($albumID, $albumSortOrder) = $wpdb->get_row("SELECT id, sortorder FROM $wpdb->nggalbum WHERE id = '$v0' ", ARRAY_N);
41
+ if(!$albumID) list($albumID, $albumSortOrder) = $wpdb->get_var("SELECT id, sortorder FROM $wpdb->nggalbum WHERE name = '$v0' ", ARRAY_N);
42
+
43
  if($albumID) {
44
  $search = $matches[0][$key];
45
+ $replace= nggShowAlbum($albumID, $albumSortOrder, $matches[2][$key]);
46
  $content= str_replace ($search, $replace, $content);
47
  }
48
  }
333
  $folder_url = get_option ('siteurl')."/".$picture->path."/";
334
  $thumbnailURL = get_option ('siteurl')."/".$picture->path.nggallery::get_thumbnail_folder($picture->path, FALSE);
335
  $thumb_prefix = nggallery::get_thumbnail_prefix($picture->path, FALSE);
336
+
337
  // choose link between imagebrowser or effect
338
+ $link = ($ngg_options['galImgBrowser']) ? $nggRewrite->get_permalink(array('pid'=>$picture->pid)) : $folder_url.$picture->filename;
339
 
340
+ // add filter for the link
341
+ $link = apply_filters('ngg_create_gallery_link', $link, $picture);
342
+ $thumbcode = apply_filters('ngg_create_gallery_thumbcode', $thumbcode, $picture);
343
+
344
  // create output
345
  $out .= '<div id="ngg-image-'. $picture->pid .'" class="ngg-gallery-thumbnail-box '. $class_desc .'">'."\n\t";
346
  $out .= '<div class="ngg-gallery-thumbnail" '.$setwidth.' >'."\n\t";
361
  }
362
 
363
  /**********************************************************/
364
+ function nggShowAlbum($albumID, $sortorder, $mode = "extend") {
365
 
366
  global $wpdb;
367
 
382
 
383
  $mode = ltrim($mode,',');
384
  $albumID = $wpdb->escape($albumID);
385
+
386
  if (!empty($sortorder)) {
387
  $gallery_array = unserialize($sortorder);
388
  }
389
 
390
  $out = '<div class="ngg-albumoverview">';
391
 
392
+ if ( is_array($gallery_array) )
393
+ $out .= nggCreateAlbum( $gallery_array, $mode, $albumID );
 
 
 
394
 
395
  $out .= '</div>'."\n";
396
  $out .= '<div class="ngg-clear"></div>'."\n";
400
  }
401
 
402
  /**********************************************************/
403
+ function nggCreateAlbum( $galleriesID, $mode = "extend", $albumID = 0) {
404
  // create a gallery overview div
405
 
406
  global $wpdb, $nggRewrite;
407
 
408
  $ngg_options = nggallery::get_option('ngg_options');
409
 
410
+ foreach ($galleriesID as $i => $value) {
411
+ $galleriesID[$i] = addslashes($value);
412
+ }
413
+
414
+ $galleriesOfAlbum = $wpdb->get_results('SELECT * FROM '.$wpdb->nggallery.' WHERE gid IN (\''.implode('\',\'', $galleriesID).'\')');
415
+ $picturesCounter = $wpdb->get_results('SELECT galleryid, COUNT(*) as counter FROM '.$wpdb->nggpictures.' WHERE galleryid IN (\''.implode('\',\'', $galleriesID).'\') AND exclude != 1 GROUP BY galleryid', OBJECT);
416
+ $picturesCounter = ngg_emulate_objekt_k($picturesCounter);
417
+ $imagesID = array();
418
+
419
+ foreach ($galleriesOfAlbum as $gallery_row)
420
+ $imagesID[] = $gallery_row->previewpic;
421
+ $albumPreview = $wpdb->get_results('SELECT pid, filename FROM '.$wpdb->nggpictures.' WHERE pid IN (\''.implode('\',\'', $imagesID).'\')', OBJECT);
422
+ $albumPreview = ngg_emulate_objekt_k($albumPreview);
423
+
424
+ $out = '';
425
+
426
+ foreach ($galleriesOfAlbum as $gallery_row) {
427
+ $gallerycontent = $gallery_row;
428
+ $galleryID = $gallerycontent->gid;
429
+
430
+ // choose between variable and page link
431
+ if ($ngg_options['galNoPages']) {
432
+ $args['album'] = $albumID;
433
+ $args['gallery'] = $galleryID;
434
+ $link = $nggRewrite->get_permalink($args);
 
 
 
435
  } else {
436
+ $link = get_permalink($gallerycontent->pageid);
437
+ }
438
+
439
+ if ($gallerycontent) {
440
+ if ($mode == "compact") {
441
+ if ($gallerycontent->previewpic != 0)
442
+ $insertpic = '<img class="Thumb" alt="'.$gallerycontent->title.'" src="'.nggallery::get_thumbnail_url($gallerycontent->previewpic, $gallerycontent->path, $albumPreview[$gallerycontent->previewpic]->filename).'"/>';
443
+ else
444
+ $insertpic = __('Watch gallery', 'nggallery');
445
+ $out .= '
446
+ <div class="ngg-album-compact">
447
+ <div class="ngg-album-compactbox">
448
+ <div class="ngg-album-link">
449
+ <a class="Link" href="'.$link.'">'.$insertpic.'</a>
450
+ </div>
451
+ </div>
452
+ <h4><a class="ngg-album-desc" title="'.$gallerycontent->title.'" href="'.$link.'">'.$gallerycontent->title.'</a></h4>
453
+ <p><strong>'.$picturesCounter[$galleryID]->counter.'</strong> '.__('Photos', 'nggallery').'</p></div>';
454
+ } else {
455
+ // mode extend
456
+ if ($gallerycontent->previewpic != 0)
457
+ $insertpic = '<img src="'.nggallery::get_thumbnail_url($gallerycontent->previewpic, $gallerycontent->path, $albumPreview[$gallerycontent->previewpic]->filename).'" alt="'.$gallerycontent->title.'" title="'.$gallerycontent->title.'"/>';
458
+ else
459
+ $insertpic = __('Watch gallery', 'nggallery');
460
+ $out .= '
461
+ <div class="ngg-album">
462
+ <div class="ngg-albumtitle"><a href="'.$link.'">'.$gallerycontent->title.'</a></div>
463
+ <div class="ngg-albumcontent">
464
+ <div class="ngg-thumbnail"><a href="'.$link.'">'.$insertpic.'</a></div>
465
+ <div class="ngg-description"><p>'.html_entity_decode(stripslashes($gallerycontent->galdesc)).'</p><p><strong>'.$picturesCounter[$galleryID]->counter.'</strong> '.__('Photos', 'nggallery').'</p></div>'."\n".'</div>'."\n".'</div>';
466
+
467
+ }
468
  }
469
  }
470
+
471
  return $out;
472
  }
473
 
799
  // function for theme authors
800
  echo nggShowRelatedImages($type, $maxNumbers);
801
  }
802
+ /**********************************************************/
803
+ function ngg_emulate_objekt_k($old_array) {
804
+ // WP 2.5 introduce this function, intermediate solution for compatible reasons
805
+ // Return an array of row objects with keys from column 1
806
+ // (Duplicates are discarded)
807
+ $new_array = array();
808
+ if (is_array($old_array)) {
809
+ foreach ( $old_array as $row ) {
810
+ $key = array_shift( get_object_vars( $row ) );
811
+ if ( !isset( $new_array[ $key ] ) )
812
+ $new_array[ $key ] = $row;
813
+ }
814
+ }
815
+
816
+ return $new_array;
817
+ }
818
 
819
  ?>