NextGEN Gallery – WordPress Gallery Plugin - Version 1.9.10

Version Description

  • 12.18.2012 =
  • Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
  • Fixed: Restored compatibility with NextGEN Gallery Export Plugin
  • Fixed: Removed some remaining references to database upgrade code
  • Fixed: Deleted galleries within an album are handed gracefully without warning messages
  • Fixed: Correct use of register_uninstall_hook
  • Fixed: CSS and usability issues with the TinyMCE window used to display galleries

  • NEW: JW ImageRotator v3.17 is now bundled with the plugin and used by default.

  • Changed: Removed database upgrade code for versions of NextGEN Gallery earlier than 1.9.3

  • Fixed: Compatibility with WordPress v3.5 ( wpdb->prepare() warnings )

  • Fixed: Sorting by filename now produces expected results using a natural sorting algorithm

Download this release

Release Info

Developer photocrati
Plugin Icon 128x128 NextGEN Gallery – WordPress Gallery Plugin
Version 1.9.10
Comparing to
See all releases

Code changes from version 1.9.9 to 1.9.10

admin/admin.php CHANGED
@@ -104,14 +104,6 @@ class nggAdminPanel{
104
 
105
  global $ngg;
106
 
107
- // check for upgrade and show upgrade screen
108
- if( get_option( 'ngg_db_version' ) != NGG_DBVERSION ) {
109
- include_once ( dirname (__FILE__) . '/functions.php' );
110
- include_once ( dirname (__FILE__) . '/upgrade.php' );
111
- nggallery_upgrade_page();
112
- return;
113
- }
114
-
115
  // Set installation date
116
  if( empty($ngg->options['installDate']) ) {
117
  $ngg->options['installDate'] = time();
104
 
105
  global $ngg;
106
 
 
 
 
 
 
 
 
 
107
  // Set installation date
108
  if( empty($ngg->options['installDate']) ) {
109
  $ngg->options['installDate'] = time();
admin/css/jquery.ui.css CHANGED
@@ -86,7 +86,7 @@
86
  /* Overlays */
87
  .ui-widget-overlay { background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); }
88
  .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
89
-
90
  /* jQuery UI Resizable */
91
  .ui-resizable { position: relative;}
92
  .ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
@@ -104,7 +104,7 @@
104
  .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
105
  .ui-dialog { -moz-box-shadow: rgba(0,0,0,1) 0 4px 30px; -webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px; -khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px; box-shadow: rgba(0,0,0,1) 0 4px 30px; }
106
  .ui-dialog .ui-dialog-titlebar { padding: .5em 1em .3em; position: relative; }
107
- .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .2em 0; }
108
  .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
109
  .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
110
  .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
@@ -123,8 +123,8 @@
123
  #spinner {display: none; width:100px; height: 100px; position: fixed; top: 50%; left: 50%; background:url(../../images/loader.gif) no-repeat center #fff; padding:10px; border:1px solid #666; margin-left: -50px; margin-top: -50px; z-index:2; overflow: auto; }
124
 
125
  /* jQuery Autocomplete */
126
- .ui-autocomplete { position: absolute; cursor: default; }
127
- .ui-autocomplete-start { background: white url('images/dropdown.png') right center no-repeat; }
128
  * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
129
  .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
130
  /* this limit the height of the result list*/
@@ -136,4 +136,5 @@
136
  .ui-menu { list-style:none; padding: 1px; margin: 0; display:block; float: left; }
137
  .ui-menu .ui-menu { margin-top: -3px; }
138
  .ui-menu .ui-menu-item { margin:0; padding:0; zoom:1; float:left; clear:left; width:100%; }
139
- .ui-menu .ui-menu-item a { text-decoration:none; display:block; zoom:1; color: black;}
 
86
  /* Overlays */
87
  .ui-widget-overlay { background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); }
88
  .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
89
+
90
  /* jQuery UI Resizable */
91
  .ui-resizable { position: relative;}
92
  .ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
104
  .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
105
  .ui-dialog { -moz-box-shadow: rgba(0,0,0,1) 0 4px 30px; -webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px; -khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px; box-shadow: rgba(0,0,0,1) 0 4px 30px; }
106
  .ui-dialog .ui-dialog-titlebar { padding: .5em 1em .3em; position: relative; }
107
+ .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .2em 0; }
108
  .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
109
  .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
110
  .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
123
  #spinner {display: none; width:100px; height: 100px; position: fixed; top: 50%; left: 50%; background:url(../../images/loader.gif) no-repeat center #fff; padding:10px; border:1px solid #666; margin-left: -50px; margin-top: -50px; z-index:2; overflow: auto; }
124
 
125
  /* jQuery Autocomplete */
126
+ .ui-autocomplete { position: absolute; cursor: default; }
127
+ .ui-autocomplete-start { background: white url('images/dropdown.png') right center no-repeat; }
128
  * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
129
  .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
130
  /* this limit the height of the result list*/
136
  .ui-menu { list-style:none; padding: 1px; margin: 0; display:block; float: left; }
137
  .ui-menu .ui-menu { margin-top: -3px; }
138
  .ui-menu .ui-menu-item { margin:0; padding:0; zoom:1; float:left; clear:left; width:100%; }
139
+ .ui-menu .ui-menu-item a { text-decoration:none; display:block; zoom:1; color: black;}
140
+ .ui-helper-hidden-accessible {display: none}
admin/settings.php CHANGED
@@ -1,6 +1,105 @@
1
  <?php
2
  if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  class nggOptions {
5
 
6
  /**
@@ -99,7 +198,6 @@ class nggOptions {
99
 
100
  if ( isset($_POST['createslugs']) ) {
101
  check_admin_referer('ngg_settings');
102
- include_once (dirname (__FILE__) . '/upgrade.php');
103
  ngg_rebuild_unique_slugs::start_rebuild();
104
  }
105
 
1
  <?php
2
  if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
 
4
+ /**
5
+ * Rebuild slugs for albums, galleries and images via AJAX request
6
+ *
7
+ * @sine 1.7.0
8
+ * @access internal
9
+ */
10
+ class ngg_rebuild_unique_slugs {
11
+
12
+ function start_rebuild() {
13
+ global $wpdb;
14
+
15
+ $total = array();
16
+ // get the total number of images
17
+ $total['images'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
18
+ $total['gallery'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
19
+ $total['album'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
20
+
21
+ $messages = array(
22
+ 'images' => __( 'Rebuild image structure : %s / %s images', 'nggallery' ),
23
+ 'gallery' => __( 'Rebuild gallery structure : %s / %s galleries', 'nggallery' ),
24
+ 'album' => __( 'Rebuild album structure : %s / %s albums', 'nggallery' ),
25
+ );
26
+
27
+ ?>
28
+ <?php
29
+
30
+ foreach ( array_keys( $messages ) as $key ) {
31
+
32
+ $message = sprintf( $messages[ $key ] ,
33
+ "<span class='ngg-count-current'>0</span>",
34
+ "<span class='ngg-count-total'>" . $total[ $key ] . "</span>"
35
+ );
36
+
37
+ echo "<div class='$key updated'><p class='ngg'>$message</p></div>";
38
+ }
39
+
40
+ $ajax_url = add_query_arg( 'action', 'ngg_rebuild_unique_slugs', admin_url( 'admin-ajax.php' ) );
41
+ ?>
42
+ <script type="text/javascript">
43
+ jQuery(document).ready(function($) {
44
+ var ajax_url = '<?php echo $ajax_url; ?>',
45
+ _action = 'images',
46
+ images = <?php echo $total['images']; ?>,
47
+ gallery = <?php echo $total['gallery']; ?>,
48
+ album = <?php echo $total['album']; ?>,
49
+ total = 0,
50
+ offset = 0,
51
+ count = 50;
52
+
53
+ var $display = $('.ngg-count-current');
54
+ $('.finished, .gallery, .album').hide();
55
+ total = images;
56
+
57
+ function call_again() {
58
+ if ( offset > total ) {
59
+ offset = 0;
60
+ // 1st run finished
61
+ if (_action == 'images') {
62
+ _action = 'gallery';
63
+ total = gallery;
64
+ $('.images, .gallery').toggle();
65
+ $display.html(offset);
66
+ call_again();
67
+ return;
68
+ }
69
+ // 2nd run finished
70
+ if (_action == 'gallery') {
71
+ _action = 'album';
72
+ total = album;
73
+ $('.gallery, .album').toggle();
74
+ $display.html(offset);
75
+ call_again();
76
+ return;
77
+ }
78
+ // 3rd run finished, exit now
79
+ if (_action == 'album') {
80
+ $('.ngg')
81
+ .html('<?php _e( 'Done.', 'nggallery' ); ?>')
82
+ .parent('div').hide();
83
+ $('.finished').show();
84
+ return;
85
+ }
86
+ }
87
+
88
+ $.post(ajax_url, {'_action': _action, 'offset': offset}, function(response) {
89
+ $display.html(offset);
90
+
91
+ offset += count;
92
+ call_again();
93
+ });
94
+ }
95
+
96
+ call_again();
97
+ });
98
+ </script>
99
+ <?php
100
+ }
101
+ }
102
+
103
  class nggOptions {
104
 
105
  /**
198
 
199
  if ( isset($_POST['createslugs']) ) {
200
  check_admin_referer('ngg_settings');
 
201
  ngg_rebuild_unique_slugs::start_rebuild();
202
  }
203
 
admin/tinymce/window.php CHANGED
@@ -43,7 +43,7 @@ jQuery(document).ready(function(){
43
  });
44
  });
45
  </script>
46
- <body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
47
  <!-- <form onsubmit="insertLink();return false;" action="#"> -->
48
  <form name="NextGEN" action="#">
49
  <div class="tabs">
43
  });
44
  });
45
  </script>
46
+ <body class="nextgen_tinymce_window" id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
47
  <!-- <form onsubmit="insertLink();return false;" action="#"> -->
48
  <form name="NextGEN" action="#">
49
  <div class="tabs">
admin/upgrade.php DELETED
@@ -1,283 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * ngg_convert_tags() - Import the tags into the wp tables (only required for pre V1.00 versions)
5
- *
6
- * @return Success Message
7
- */
8
- function ngg_convert_tags() {
9
- global $wpdb, $wp_taxonomies;
10
-
11
- // get the obsolete tables
12
- $wpdb->nggtags = $wpdb->prefix . 'ngg_tags';
13
- $wpdb->nggpic2tags = $wpdb->prefix . 'ngg_pic2tags';
14
-
15
- $picturelist = $wpdb->get_col("SELECT pid FROM $wpdb->nggpictures");
16
- if ( is_array($picturelist) ) {
17
- foreach($picturelist as $id) {
18
- $tags = array();
19
- $tagarray = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggpic2tags AS t INNER JOIN $wpdb->nggtags AS tt ON t.tagid = tt.id WHERE t.picid = '$id' ORDER BY tt.slug ASC ");
20
- if (!empty($tagarray)){
21
- foreach($tagarray as $element) {
22
- $tags[$element->id] = $element->name;
23
- }
24
- wp_set_object_terms($id, $tags, 'ngg_tag');
25
- }
26
- }
27
- }
28
- }
29
-
30
- /**
31
- * ngg_convert_filestructure() - converter for old thumnail folder structure
32
- *
33
- * @return void
34
- */
35
- function ngg_convert_filestructure() {
36
- global $wpdb;
37
-
38
- $gallerylist = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY gid ASC", OBJECT_K);
39
- if ( is_array($gallerylist) ) {
40
- $errors = array();
41
- foreach($gallerylist as $gallery) {
42
- $gallerypath = WINABSPATH.$gallery->path;
43
-
44
- // old mygallery check, convert the wrong folder/ file name now
45
- if (@is_dir($gallerypath . '/tumbs')) {
46
- if ( !@rename($gallerypath . '/tumbs' , $gallerypath .'/thumbs') )
47
- $errors[] = $gallery->path . '/thumbs';
48
- // read list of images
49
- $imageslist = nggAdmin::scandir($gallerypath . '/thumbs');
50
- if ( !empty($imageslist)) {
51
- foreach($imageslist as $image) {
52
- $purename = substr($image, 4);
53
- if ( !@rename($gallerypath . '/thumbs/' . $image, $gallerypath . '/thumbs/thumbs_' . $purename ))
54
- $errors[] = $gallery->path . '/thumbs/thumbs_' . $purename ;
55
- }
56
- }
57
- }
58
- }
59
-
60
- if (!empty($errors)) {
61
- echo "<div class='error_inline'><p>". __('Some folders/files could not renamed, please recheck the permission and rescan the folder in the manage gallery section.', 'nggallery') ."</p>";
62
- foreach($errors as $value) {
63
- echo __('Rename failed', 'nggallery') . ' : <strong>' . $value . "</strong><br />\n";
64
- }
65
- echo '</div>';
66
- }
67
- }
68
- }
69
-
70
- /**
71
- * Move the imagerotator outside the plugin folder, as we remove it from the REPO with the next update
72
- *
73
- * @return string $path URL to the imagerotator
74
- */
75
- function ngg_move_imagerotator() {
76
-
77
- $upload = wp_upload_dir();
78
-
79
- // look first at the old place and move it
80
- if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
81
- @rename(NGGALLERY_ABSPATH . 'imagerotator.swf', $upload['basedir'] . '/imagerotator.swf');
82
-
83
- // If it's successful then we return the new path
84
- if ( file_exists( $upload['basedir'] . '/imagerotator.swf' ) )
85
- return $upload['baseurl'] . '/imagerotator.swf';
86
-
87
- //In some worse case it's still at the old place
88
- if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
89
- return NGGALLERY_URLPATH . 'imagerotator.swf';
90
-
91
- // if something failed, we must return a empty string
92
- return '';
93
- }
94
-
95
- /**
96
- * ngg_import_date_time() - Read the timestamp from exif and insert it into the database
97
- *
98
- * @return void
99
- */
100
- function ngg_import_date_time() {
101
- global $wpdb;
102
-
103
- $imagelist = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid ORDER BY tt.pid ASC");
104
- if ( is_array($imagelist) ) {
105
- foreach ($imagelist as $image) {
106
- $picture = new nggImage($image);
107
- $meta = new nggMeta($picture->pid, true);
108
- $date = $meta->get_date_time();
109
- $wpdb->query("UPDATE $wpdb->nggpictures SET imagedate = '$date' WHERE pid = '$picture->pid'");
110
- }
111
- }
112
- }
113
-
114
- /**
115
- * Adding a new column if needed
116
- * Example : ngg_maybe_add_column( $wpdb->nggpictures, 'imagedate', "DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER alttext");
117
- *
118
- * @param string $table_name Database table name.
119
- * @param string $column_name Database column name to create.
120
- * @param string $create_ddl SQL statement to create column
121
- * @return bool True, when done with execution.
122
- */
123
- function ngg_maybe_add_column($table_name, $column_name, $create_ddl) {
124
- global $wpdb;
125
-
126
- foreach ($wpdb->get_col("SHOW COLUMNS FROM $table_name") as $column ) {
127
- if ($column == $column_name)
128
- return true;
129
- }
130
-
131
- //didn't find it try to create it.
132
- $wpdb->query("ALTER TABLE $table_name ADD $column_name " . $create_ddl);
133
-
134
- // we cannot directly tell that whether this succeeded!
135
- foreach ($wpdb->get_col("SHOW COLUMNS FROM $table_name") as $column ) {
136
- if ($column == $column_name)
137
- return true;
138
- }
139
-
140
- echo("Could not add column $column_name in table $table_name<br />\n");
141
- return false;
142
- }
143
-
144
- /**
145
- * nggallery_upgrade_page() - This page showsup , when the database version doesn't fir to the script NGG_DBVERSION constant.
146
- *
147
- * @return Upgrade Message
148
- */
149
- function nggallery_upgrade_page() {
150
-
151
- $filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
152
-
153
- if ( isset($_GET['upgrade']) && $_GET['upgrade'] == 'now') {
154
- nggallery_start_upgrade($filepath);
155
- return;
156
- }
157
- ?>
158
- <div class="wrap">
159
- <h2><?php _e('Upgrade NextGEN Gallery', 'nggallery') ;?></h2>
160
- <p><?php _e('The script detect that you upgrade from a older version.', 'nggallery') ;?>
161
- <?php _e('Your database tables for NextGEN Gallery is out-of-date, and must be upgraded before you can continue.', 'nggallery'); ?>
162
- <?php _e('If you would like to downgrade later, please make first a complete backup of your database and the images.', 'nggallery') ;?></p>
163
- <p><?php _e('The upgrade process may take a while, so please be patient.', 'nggallery'); ?></p>
164
- <h3><a href="<?php echo $filepath;?>&amp;upgrade=now"><?php _e('Start upgrade now', 'nggallery'); ?>...</a></h3>
165
- </div>
166
- <?php
167
- }
168
-
169
- /**
170
- * nggallery_start_upgrade() - Proceed the upgrade routine
171
- *
172
- * @param mixed $filepath
173
- * @return void
174
- */
175
- function nggallery_start_upgrade($filepath) {
176
- ?>
177
- <div class="wrap">
178
- <h2><?php _e('Upgrade NextGEN Gallery', 'nggallery') ;?></h2>
179
- <p><?php ngg_upgrade();?></p>
180
- <p class="finished"><?php _e('Upgrade finished...', 'nggallery') ;?></p>
181
- <h3><a class="finished" href="<?php echo $filepath;?>"><?php _e('Continue', 'nggallery'); ?>...</a></h3>
182
- </div>
183
- <?php
184
- }
185
-
186
- /**
187
- * Rebuild slugs for albums, galleries and images via AJAX request
188
- *
189
- * @sine 1.7.0
190
- * @access internal
191
- */
192
- class ngg_rebuild_unique_slugs {
193
-
194
- function start_rebuild() {
195
- global $wpdb;
196
-
197
- $total = array();
198
- // get the total number of images
199
- $total['images'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
200
- $total['gallery'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
201
- $total['album'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
202
-
203
- $messages = array(
204
- 'images' => __( 'Rebuild image structure : %s / %s images', 'nggallery' ),
205
- 'gallery' => __( 'Rebuild gallery structure : %s / %s galleries', 'nggallery' ),
206
- 'album' => __( 'Rebuild album structure : %s / %s albums', 'nggallery' ),
207
- );
208
-
209
- ?>
210
- <?php
211
-
212
- foreach ( array_keys( $messages ) as $key ) {
213
-
214
- $message = sprintf( $messages[ $key ] ,
215
- "<span class='ngg-count-current'>0</span>",
216
- "<span class='ngg-count-total'>" . $total[ $key ] . "</span>"
217
- );
218
-
219
- echo "<div class='$key updated'><p class='ngg'>$message</p></div>";
220
- }
221
-
222
- $ajax_url = add_query_arg( 'action', 'ngg_rebuild_unique_slugs', admin_url( 'admin-ajax.php' ) );
223
- ?>
224
- <script type="text/javascript">
225
- jQuery(document).ready(function($) {
226
- var ajax_url = '<?php echo $ajax_url; ?>',
227
- _action = 'images',
228
- images = <?php echo $total['images']; ?>,
229
- gallery = <?php echo $total['gallery']; ?>,
230
- album = <?php echo $total['album']; ?>,
231
- total = 0,
232
- offset = 0,
233
- count = 50;
234
-
235
- var $display = $('.ngg-count-current');
236
- $('.finished, .gallery, .album').hide();
237
- total = images;
238
-
239
- function call_again() {
240
- if ( offset > total ) {
241
- offset = 0;
242
- // 1st run finished
243
- if (_action == 'images') {
244
- _action = 'gallery';
245
- total = gallery;
246
- $('.images, .gallery').toggle();
247
- $display.html(offset);
248
- call_again();
249
- return;
250
- }
251
- // 2nd run finished
252
- if (_action == 'gallery') {
253
- _action = 'album';
254
- total = album;
255
- $('.gallery, .album').toggle();
256
- $display.html(offset);
257
- call_again();
258
- return;
259
- }
260
- // 3rd run finished, exit now
261
- if (_action == 'album') {
262
- $('.ngg')
263
- .html('<?php _e( 'Done.', 'nggallery' ); ?>')
264
- .parent('div').hide();
265
- $('.finished').show();
266
- return;
267
- }
268
- }
269
-
270
- $.post(ajax_url, {'_action': _action, 'offset': offset}, function(response) {
271
- $display.html(offset);
272
-
273
- offset += count;
274
- call_again();
275
- });
276
- }
277
-
278
- call_again();
279
- });
280
- </script>
281
- <?php
282
- }
283
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
changelog.txt CHANGED
@@ -1,6 +1,14 @@
1
  NextGEN Gallery
2
  by Photocrati Media
3
 
 
 
 
 
 
 
 
 
4
  = V1.9.9 - 12.14.2012 =
5
  * NEW: JW ImageRotator v3.17 is now bundled with the plugin and used by default.
6
  * Changed: Removed database upgrade code for versions of NextGEN Gallery earlier than 1.9.3
1
  NextGEN Gallery
2
  by Photocrati Media
3
 
4
+ = V1.9.10 - 12.18.2012 =
5
+ * Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
6
+ * Fixed: Restored compatibility with NextGEN Gallery Export Plugin
7
+ * Fixed: Removed some remaining references to database upgrade code
8
+ * Fixed: Deleted galleries within an album are handed gracefully without warning messages
9
+ * Fixed: Correct use of register_uninstall_hook
10
+ * Fixed: CSS and usability issues with the TinyMCE window used to display galleries
11
+
12
  = V1.9.9 - 12.14.2012 =
13
  * NEW: JW ImageRotator v3.17 is now bundled with the plugin and used by default.
14
  * Changed: Removed database upgrade code for versions of NextGEN Gallery earlier than 1.9.3
lib/xmlrpc.php CHANGED
@@ -4,21 +4,21 @@
4
  *
5
  * @package NextGEN Gallery
6
  * @author Alex Rabe
7
- *
8
  */
9
  class nggXMLRPC{
10
-
11
  /**
12
  * Init the methods for the XMLRPC hook
13
- *
14
- */
15
  function __construct() {
16
-
17
  add_filter('xmlrpc_methods', array(&$this, 'add_methods') );
18
  }
19
-
20
  function add_methods($methods) {
21
-
22
  $methods['ngg.installed'] = array(&$this, 'nggInstalled');
23
  // Image methods
24
  $methods['ngg.getImage'] = array(&$this, 'getImage');
@@ -44,17 +44,17 @@ class nggXMLRPC{
44
 
45
  /**
46
  * Check if it's an csv string, then serialize it.
47
- *
48
  * @since 1.9.2
49
  * @param string $data
50
  * @return serialized string
51
  */
52
  function is_serialized( $data ) {
53
-
54
  // if it isn't a string, we don't serialize it.
55
  if ( ! is_string( $data ) )
56
  return false;
57
-
58
  if ($data && !strpos( $data , '{')) {
59
  $items = explode(',', $data);
60
  return serialize($items);
@@ -65,9 +65,9 @@ class nggXMLRPC{
65
 
66
  /**
67
  * Check if NextGEN Gallery is installed
68
- *
69
  * @since 1.4
70
- *
71
  * @param none
72
  * @return string version number
73
  */
@@ -75,7 +75,7 @@ class nggXMLRPC{
75
  global $ngg;
76
  return array( 'version' => $ngg->version );
77
  }
78
-
79
  /**
80
  * Log user in.
81
  *
@@ -86,12 +86,16 @@ class nggXMLRPC{
86
  * @return mixed WP_User object if authentication passed, false otherwise
87
  */
88
  function login($username, $password) {
89
- if ( !get_option( 'enable_xmlrpc' ) ) {
90
- $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
91
- return false;
 
 
 
 
92
  }
93
 
94
- $user = wp_authenticate($username, $password);
95
 
96
  if (is_wp_error($user)) {
97
  $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
@@ -107,7 +111,7 @@ class nggXMLRPC{
107
  * Uploads a image to a gallery
108
  *
109
  * @since 1.4
110
- *
111
  * @copyright addapted from WP Core
112
  * @param array $args Method parameters.
113
  * - int blog_id
@@ -116,15 +120,15 @@ class nggXMLRPC{
116
  * - struct data
117
  * o string name
118
  * o string type (optional)
119
- * o base64 bits
120
  * o bool overwrite (optional)
121
- * o int gallery
122
- * o int image_id (optional)
123
  * @return array with image meta data
124
  */
125
  function uploadImage($args) {
126
  global $wpdb;
127
-
128
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
129
  require_once ( 'meta.php' ); // meta data import
130
 
@@ -136,11 +140,11 @@ class nggXMLRPC{
136
  $name = $data['name'];
137
  $type = $data['type'];
138
  $bits = $data['bits'];
139
-
140
  // gallery & image id
141
  $gid = (int) $data['gallery']; // required field
142
  $pid = (int) $data['image_id']; // optional but more foolproof of overwrite
143
- $image = false; // container for the image object
144
 
145
  logIO('O', '(NGG) Received '.strlen($bits).' bytes');
146
 
@@ -153,43 +157,43 @@ class nggXMLRPC{
153
  $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
154
  return $this->error;
155
  }
156
-
157
  // Look for the gallery , could we find it ?
158
- if ( !$gallery = nggdb::find_gallery($gid) )
159
  return new IXR_Error(404, __('Could not find gallery ' . $gid ));
160
-
161
  // Now check if you have the correct capability for this gallery
162
  if ( !nggAdmin::can_manage_this_gallery($gallery->author) ) {
163
  logIO('O', '(NGG) User does not have upload_files capability');
164
  $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
165
  return $this->error;
166
- }
167
-
168
  //clean filename and extract extension
169
  $filepart = nggGallery::fileinfo( $name );
170
  $name = $filepart['basename'];
171
-
172
  // check for allowed extension and if it's an image file
173
- $ext = array('jpg', 'png', 'gif');
174
- if ( !in_array($filepart['extension'], $ext) ){
175
  logIO('O', '(NGG) Not allowed file type');
176
  $this->error = new IXR_Error(401, __('This is no valid image file.','nggallery'));
177
  return $this->error;
178
- }
179
 
180
  // in the case you would overwrite the image, let's delete the old one first
181
  if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) {
182
-
183
  // search for the image based on the filename, if it's not already provided
184
  if ($pid == 0)
185
  $pid = $wpdb->get_col(" SELECT pid FROM {$wpdb->nggpictures} WHERE filename = '{$name}' AND galleryid = '{$gid}' ");
186
-
187
  if ( !$image = nggdb::find_image( $pid ) )
188
- return new IXR_Error(404, __('Could not find image id ' . $pid ));
189
 
190
  // sync the gallery<->image parameter, otherwise we may copy it to the wrong gallery
191
  $gallery = $image;
192
-
193
  // delete now the image
194
  if ( !@unlink( $image->imagePath ) ) {
195
  $errorString = sprintf(__('Failed to delete image %1$s ','nggallery'), $image->imagePath);
@@ -205,10 +209,10 @@ class nggXMLRPC{
205
  logIO('O', '(NGG) ' . $errorString);
206
  return new IXR_Error(500, $errorString);
207
  }
208
-
209
- // this is the dir to the gallery
210
  $path = WINABSPATH . $gallery->path;
211
-
212
  // check if the filename already exist, if not add a counter index
213
  $filename = wp_unique_filename( $path, $name );
214
  $destination = $path . '/'. $filename;
@@ -219,7 +223,7 @@ class nggXMLRPC{
219
  logIO('O', '(NGG) ' . $errorString);
220
  return new IXR_Error(500, $errorString);
221
  }
222
-
223
  //add to database if it's a new image
224
  if(empty($data["overwrite"]) || ($data["overwrite"] == false)) {
225
  $pid_array = nggAdmin::add_Images( $gallery->gid, array( $filename ) );
@@ -227,14 +231,14 @@ class nggXMLRPC{
227
  if (count($pid_array) == 1)
228
  $pid = $pid_array[0];
229
  }
230
-
231
  //get all information about the image, in the case it's a new one
232
  if (!$image)
233
  $image = nggdb::find_image( $pid );
234
-
235
  // create again the thumbnail, should return a '1'
236
  nggAdmin::create_thumbnail( $image );
237
-
238
  return apply_filters( 'ngg_upload_image', $image );
239
 
240
  }
@@ -242,20 +246,20 @@ class nggXMLRPC{
242
  /**
243
  * Method "ngg.deleteImage"
244
  * Delete a Image from the database and gallery
245
- *
246
  * @since 1.7.3
247
- *
248
  * @param array $args Method parameters.
249
  * - int blog_id
250
  * - string username
251
  * - string password
252
- * - int image_id
253
  * @return true
254
  */
255
  function deleteImage($args) {
256
-
257
  global $nggdb, $ngg;
258
-
259
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
260
 
261
  $this->escape($args);
@@ -275,22 +279,22 @@ class nggXMLRPC{
275
 
276
  if ($ngg->options['deleteImg']) {
277
  @unlink($image->imagePath);
278
- @unlink($image->thumbPath);
279
  @unlink($image->imagePath . "_backup" );
280
- }
281
 
282
  nggdb::delete_image ( $id );
283
-
284
  return true;
285
-
286
  }
287
 
288
  /**
289
  * Method "ngg.editImage"
290
  * Edit a existing Image
291
- *
292
  * @since 1.7.3
293
- *
294
  * @param array $args Method parameters.
295
  * - int blog_id
296
  * - string username
@@ -302,11 +306,11 @@ class nggXMLRPC{
302
  * @return true if success
303
  */
304
  function editImage($args) {
305
-
306
  global $ngg;
307
 
308
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
309
-
310
  $this->escape($args);
311
  $blog_ID = (int) $args[0];
312
  $username = $args[1];
@@ -327,20 +331,20 @@ class nggXMLRPC{
327
 
328
  if ( !empty( $id ) )
329
  $result = nggdb::update_image($id, false, false, $description, $alttext, $exclude);
330
-
331
  if ( !$result )
332
  return new IXR_Error(500, __('Sorry, could not update the image'));
333
 
334
  return true;
335
-
336
  }
337
 
338
  /**
339
  * Method "ngg.newGallery"
340
  * Create a new gallery
341
- *
342
  * @since 1.4
343
- *
344
  * @param array $args Method parameters.
345
  * - int blog_id
346
  * - string username
@@ -349,11 +353,11 @@ class nggXMLRPC{
349
  * @return int with new gallery ID
350
  */
351
  function newGallery($args) {
352
-
353
  global $ngg;
354
 
355
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
356
-
357
  $this->escape($args);
358
  $blog_ID = (int) $args[0];
359
  $username = $args[1];
@@ -369,20 +373,20 @@ class nggXMLRPC{
369
 
370
  if ( !empty( $name ) )
371
  $id = nggAdmin::create_gallery($name, $ngg->options['gallerypath'], false);
372
-
373
  if ( !$id )
374
  return new IXR_Error(500, __('Sorry, could not create the gallery'));
375
 
376
  return($id);
377
-
378
  }
379
 
380
  /**
381
  * Method "ngg.editGallery"
382
  * Edit a existing gallery
383
- *
384
  * @since 1.7.0
385
- *
386
  * @param array $args Method parameters.
387
  * - int blog_id
388
  * - string username
@@ -390,16 +394,16 @@ class nggXMLRPC{
390
  * - int gallery ID
391
  * - string gallery name
392
  * - string title
393
- * - string description
394
- * - int ID of the preview picture
395
  * @return true if success
396
  */
397
  function editGallery($args) {
398
-
399
  global $ngg;
400
 
401
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
402
-
403
  $this->escape($args);
404
  $blog_ID = (int) $args[0];
405
  $username = $args[1];
@@ -421,20 +425,20 @@ class nggXMLRPC{
421
 
422
  if ( !empty( $name ) )
423
  $result = nggdb::update_gallery($id, $name, false, $title, $description, false, $previewpic);
424
-
425
  if ( !$result )
426
  return new IXR_Error(500, __('Sorry, could not update the gallery'));
427
 
428
  return true;
429
-
430
  }
431
 
432
  /**
433
  * Method "ngg.newAlbum"
434
  * Create a new album
435
- *
436
  * @since 1.7.0
437
- *
438
  * @param array $args Method parameters.
439
  * - int blog_id
440
  * - string username
@@ -446,7 +450,7 @@ class nggXMLRPC{
446
  * @return int with new album ID
447
  */
448
  function newAlbum($args) {
449
-
450
  global $ngg;
451
 
452
  $this->escape($args);
@@ -467,20 +471,20 @@ class nggXMLRPC{
467
 
468
  if ( !empty( $name ) )
469
  $id = $result = nggdb::add_album( $name, $preview, $description, $galleries );
470
-
471
  if ( !$id )
472
  return new IXR_Error(500, __('Sorry, could not create the album'));
473
 
474
  return($id);
475
-
476
  }
477
 
478
  /**
479
  * Method "ngg.editAlbum"
480
  * Edit a existing Album
481
- *
482
  * @since 1.7.0
483
- *
484
  * @param array $args Method parameters.
485
  * - int blog_id
486
  * - string username
@@ -493,11 +497,11 @@ class nggXMLRPC{
493
  * @return true if success
494
  */
495
  function editAlbum($args) {
496
-
497
  global $ngg;
498
 
499
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
500
-
501
  $this->escape($args);
502
  $blog_ID = (int) $args[0];
503
  $username = $args[1];
@@ -519,29 +523,29 @@ class nggXMLRPC{
519
 
520
  if ( !empty( $name ) )
521
  $result = nggdb::update_album($id, $name, $preview, $description, $galleries);
522
-
523
  if ( !$result )
524
  return new IXR_Error(500, __('Sorry, could not update the album'));
525
 
526
  return true;
527
-
528
  }
529
 
530
  /**
531
  * Method "ngg.deleteAlbum"
532
  * Delete a album from the database
533
- *
534
  * @since 1.7.0
535
- *
536
  * @param array $args Method parameters.
537
  * - int blog_id
538
  * - string username
539
  * - string password
540
- * - int album id
541
  * @return true
542
  */
543
  function deleteAlbum($args) {
544
-
545
  global $nggdb;
546
 
547
  $this->escape($args);
@@ -558,28 +562,28 @@ class nggXMLRPC{
558
 
559
  if( !current_user_can( 'NextGEN Edit album' ) && !nggGallery::current_user_can( 'NextGEN Add/Delete album' ) )
560
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage albums' ) );
561
-
562
  $nggdb->delete_album($id);
563
-
564
  return true;
565
-
566
  }
567
 
568
  /**
569
  * Method "ngg.deleteGallery"
570
  * Delete a gallery from the database, including all images
571
- *
572
  * @since 1.7.0
573
- *
574
  * @param array $args Method parameters.
575
  * - int blog_id
576
  * - string username
577
  * - string password
578
- * - int gallery_id
579
  * @return true
580
  */
581
  function deleteGallery($args) {
582
-
583
  global $nggdb;
584
 
585
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
@@ -598,19 +602,19 @@ class nggXMLRPC{
598
 
599
  if ( !current_user_can( 'NextGEN Manage gallery' ) && !nggAdmin::can_manage_this_gallery($gallery->author) )
600
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage galleries' ) );
601
-
602
  $nggdb->delete_gallery($id);
603
-
604
  return true;
605
-
606
  }
607
 
608
  /**
609
  * Method "ngg.getAlbums"
610
  * Return the list of all albums
611
- *
612
  * @since 1.7.0
613
- *
614
  * @param array $args Method parameters.
615
  * - int blog_id
616
  * - string username
@@ -618,7 +622,7 @@ class nggXMLRPC{
618
  * @return array with all galleries
619
  */
620
  function getAlbums($args) {
621
-
622
  global $nggdb;
623
 
624
  $this->escape($args);
@@ -631,11 +635,11 @@ class nggXMLRPC{
631
 
632
  if( !current_user_can( 'NextGEN Edit album' ) )
633
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage albums' ) );
634
-
635
  $album_list = $nggdb->find_all_album('id', 'ASC', 0, 0 );
636
-
637
  return($album_list);
638
-
639
  }
640
 
641
  /**
@@ -676,9 +680,9 @@ class nggXMLRPC{
676
  /**
677
  * Method "ngg.getGalleries"
678
  * Return the list of all galleries
679
- *
680
  * @since 1.4
681
- *
682
  * @param array $args Method parameters.
683
  * - int blog_id
684
  * - string username
@@ -686,7 +690,7 @@ class nggXMLRPC{
686
  * @return array with all galleries
687
  */
688
  function getGalleries($args) {
689
-
690
  global $nggdb;
691
 
692
  $this->escape($args);
@@ -699,11 +703,11 @@ class nggXMLRPC{
699
 
700
  if( !current_user_can( 'NextGEN Manage gallery' ) )
701
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage galleries' ) );
702
-
703
  $gallery_list = $nggdb->find_all_galleries('gid', 'asc', true, 0, 0, false);
704
-
705
  return($gallery_list);
706
-
707
  }
708
 
709
  /**
@@ -744,22 +748,22 @@ class nggXMLRPC{
744
  /**
745
  * Method "ngg.getImages"
746
  * Return the list of all images inside a gallery
747
- *
748
  * @since 1.4
749
- *
750
  * @param array $args Method parameters.
751
  * - int blog_id
752
  * - string username
753
  * - string password
754
- * - int gallery_id
755
  * @return array with all images
756
  */
757
  function getImages($args) {
758
-
759
  global $nggdb;
760
 
761
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
762
-
763
  $this->escape($args);
764
  $blog_ID = (int) $args[0];
765
  $username = $args[1];
@@ -770,7 +774,7 @@ class nggXMLRPC{
770
  return $this->error;
771
 
772
  // Look for the gallery , could we find it ?
773
- if ( !$gallery = nggdb::find_gallery( $gid ) )
774
  return new IXR_Error(404, __('Could not find gallery ' . $gid ));
775
 
776
  // Now check if you have the correct capability for this gallery
@@ -779,12 +783,12 @@ class nggXMLRPC{
779
  $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
780
  return $this->error;
781
  }
782
-
783
  // get picture values
784
  $picture_list = $nggdb->get_gallery( $gid, 'pid', 'ASC', false );
785
-
786
  return($picture_list);
787
-
788
  }
789
 
790
  /**
@@ -871,7 +875,7 @@ class nggXMLRPC{
871
  * @return bool Always true
872
  */
873
  function __destruct() {
874
-
875
  }
876
  }
877
 
4
  *
5
  * @package NextGEN Gallery
6
  * @author Alex Rabe
7
+ *
8
  */
9
  class nggXMLRPC{
10
+
11
  /**
12
  * Init the methods for the XMLRPC hook
13
+ *
14
+ */
15
  function __construct() {
16
+
17
  add_filter('xmlrpc_methods', array(&$this, 'add_methods') );
18
  }
19
+
20
  function add_methods($methods) {
21
+
22
  $methods['ngg.installed'] = array(&$this, 'nggInstalled');
23
  // Image methods
24
  $methods['ngg.getImage'] = array(&$this, 'getImage');
44
 
45
  /**
46
  * Check if it's an csv string, then serialize it.
47
+ *
48
  * @since 1.9.2
49
  * @param string $data
50
  * @return serialized string
51
  */
52
  function is_serialized( $data ) {
53
+
54
  // if it isn't a string, we don't serialize it.
55
  if ( ! is_string( $data ) )
56
  return false;
57
+
58
  if ($data && !strpos( $data , '{')) {
59
  $items = explode(',', $data);
60
  return serialize($items);
65
 
66
  /**
67
  * Check if NextGEN Gallery is installed
68
+ *
69
  * @since 1.4
70
+ *
71
  * @param none
72
  * @return string version number
73
  */
75
  global $ngg;
76
  return array( 'version' => $ngg->version );
77
  }
78
+
79
  /**
80
  * Log user in.
81
  *
86
  * @return mixed WP_User object if authentication passed, false otherwise
87
  */
88
  function login($username, $password) {
89
+ global $wp_version;
90
+
91
+ if (version_compare($wp_version,"3.5","<")) {
92
+ if ( !get_option( 'enable_xmlrpc' ) ) {
93
+ $this->error = new IXR_Error( 405, sprintf( __('XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
94
+ return false;
95
+ }
96
  }
97
 
98
+ $user = wp_authenticate($username, $password);
99
 
100
  if (is_wp_error($user)) {
101
  $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
111
  * Uploads a image to a gallery
112
  *
113
  * @since 1.4
114
+ *
115
  * @copyright addapted from WP Core
116
  * @param array $args Method parameters.
117
  * - int blog_id
120
  * - struct data
121
  * o string name
122
  * o string type (optional)
123
+ * o base64 bits
124
  * o bool overwrite (optional)
125
+ * o int gallery
126
+ * o int image_id (optional)
127
  * @return array with image meta data
128
  */
129
  function uploadImage($args) {
130
  global $wpdb;
131
+
132
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
133
  require_once ( 'meta.php' ); // meta data import
134
 
140
  $name = $data['name'];
141
  $type = $data['type'];
142
  $bits = $data['bits'];
143
+
144
  // gallery & image id
145
  $gid = (int) $data['gallery']; // required field
146
  $pid = (int) $data['image_id']; // optional but more foolproof of overwrite
147
+ $image = false; // container for the image object
148
 
149
  logIO('O', '(NGG) Received '.strlen($bits).' bytes');
150
 
157
  $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
158
  return $this->error;
159
  }
160
+
161
  // Look for the gallery , could we find it ?
162
+ if ( !$gallery = nggdb::find_gallery($gid) )
163
  return new IXR_Error(404, __('Could not find gallery ' . $gid ));
164
+
165
  // Now check if you have the correct capability for this gallery
166
  if ( !nggAdmin::can_manage_this_gallery($gallery->author) ) {
167
  logIO('O', '(NGG) User does not have upload_files capability');
168
  $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
169
  return $this->error;
170
+ }
171
+
172
  //clean filename and extract extension
173
  $filepart = nggGallery::fileinfo( $name );
174
  $name = $filepart['basename'];
175
+
176
  // check for allowed extension and if it's an image file
177
+ $ext = array('jpg', 'png', 'gif');
178
+ if ( !in_array($filepart['extension'], $ext) ){
179
  logIO('O', '(NGG) Not allowed file type');
180
  $this->error = new IXR_Error(401, __('This is no valid image file.','nggallery'));
181
  return $this->error;
182
+ }
183
 
184
  // in the case you would overwrite the image, let's delete the old one first
185
  if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) {
186
+
187
  // search for the image based on the filename, if it's not already provided
188
  if ($pid == 0)
189
  $pid = $wpdb->get_col(" SELECT pid FROM {$wpdb->nggpictures} WHERE filename = '{$name}' AND galleryid = '{$gid}' ");
190
+
191
  if ( !$image = nggdb::find_image( $pid ) )
192
+ return new IXR_Error(404, __('Could not find image id ' . $pid ));
193
 
194
  // sync the gallery<->image parameter, otherwise we may copy it to the wrong gallery
195
  $gallery = $image;
196
+
197
  // delete now the image
198
  if ( !@unlink( $image->imagePath ) ) {
199
  $errorString = sprintf(__('Failed to delete image %1$s ','nggallery'), $image->imagePath);
209
  logIO('O', '(NGG) ' . $errorString);
210
  return new IXR_Error(500, $errorString);
211
  }
212
+
213
+ // this is the dir to the gallery
214
  $path = WINABSPATH . $gallery->path;
215
+
216
  // check if the filename already exist, if not add a counter index
217
  $filename = wp_unique_filename( $path, $name );
218
  $destination = $path . '/'. $filename;
223
  logIO('O', '(NGG) ' . $errorString);
224
  return new IXR_Error(500, $errorString);
225
  }
226
+
227
  //add to database if it's a new image
228
  if(empty($data["overwrite"]) || ($data["overwrite"] == false)) {
229
  $pid_array = nggAdmin::add_Images( $gallery->gid, array( $filename ) );
231
  if (count($pid_array) == 1)
232
  $pid = $pid_array[0];
233
  }
234
+
235
  //get all information about the image, in the case it's a new one
236
  if (!$image)
237
  $image = nggdb::find_image( $pid );
238
+
239
  // create again the thumbnail, should return a '1'
240
  nggAdmin::create_thumbnail( $image );
241
+
242
  return apply_filters( 'ngg_upload_image', $image );
243
 
244
  }
246
  /**
247
  * Method "ngg.deleteImage"
248
  * Delete a Image from the database and gallery
249
+ *
250
  * @since 1.7.3
251
+ *
252
  * @param array $args Method parameters.
253
  * - int blog_id
254
  * - string username
255
  * - string password
256
+ * - int image_id
257
  * @return true
258
  */
259
  function deleteImage($args) {
260
+
261
  global $nggdb, $ngg;
262
+
263
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
264
 
265
  $this->escape($args);
279
 
280
  if ($ngg->options['deleteImg']) {
281
  @unlink($image->imagePath);
282
+ @unlink($image->thumbPath);
283
  @unlink($image->imagePath . "_backup" );
284
+ }
285
 
286
  nggdb::delete_image ( $id );
287
+
288
  return true;
289
+
290
  }
291
 
292
  /**
293
  * Method "ngg.editImage"
294
  * Edit a existing Image
295
+ *
296
  * @since 1.7.3
297
+ *
298
  * @param array $args Method parameters.
299
  * - int blog_id
300
  * - string username
306
  * @return true if success
307
  */
308
  function editImage($args) {
309
+
310
  global $ngg;
311
 
312
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
313
+
314
  $this->escape($args);
315
  $blog_ID = (int) $args[0];
316
  $username = $args[1];
331
 
332
  if ( !empty( $id ) )
333
  $result = nggdb::update_image($id, false, false, $description, $alttext, $exclude);
334
+
335
  if ( !$result )
336
  return new IXR_Error(500, __('Sorry, could not update the image'));
337
 
338
  return true;
339
+
340
  }
341
 
342
  /**
343
  * Method "ngg.newGallery"
344
  * Create a new gallery
345
+ *
346
  * @since 1.4
347
+ *
348
  * @param array $args Method parameters.
349
  * - int blog_id
350
  * - string username
353
  * @return int with new gallery ID
354
  */
355
  function newGallery($args) {
356
+
357
  global $ngg;
358
 
359
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
360
+
361
  $this->escape($args);
362
  $blog_ID = (int) $args[0];
363
  $username = $args[1];
373
 
374
  if ( !empty( $name ) )
375
  $id = nggAdmin::create_gallery($name, $ngg->options['gallerypath'], false);
376
+
377
  if ( !$id )
378
  return new IXR_Error(500, __('Sorry, could not create the gallery'));
379
 
380
  return($id);
381
+
382
  }
383
 
384
  /**
385
  * Method "ngg.editGallery"
386
  * Edit a existing gallery
387
+ *
388
  * @since 1.7.0
389
+ *
390
  * @param array $args Method parameters.
391
  * - int blog_id
392
  * - string username
394
  * - int gallery ID
395
  * - string gallery name
396
  * - string title
397
+ * - string description
398
+ * - int ID of the preview picture
399
  * @return true if success
400
  */
401
  function editGallery($args) {
402
+
403
  global $ngg;
404
 
405
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
406
+
407
  $this->escape($args);
408
  $blog_ID = (int) $args[0];
409
  $username = $args[1];
425
 
426
  if ( !empty( $name ) )
427
  $result = nggdb::update_gallery($id, $name, false, $title, $description, false, $previewpic);
428
+
429
  if ( !$result )
430
  return new IXR_Error(500, __('Sorry, could not update the gallery'));
431
 
432
  return true;
433
+
434
  }
435
 
436
  /**
437
  * Method "ngg.newAlbum"
438
  * Create a new album
439
+ *
440
  * @since 1.7.0
441
+ *
442
  * @param array $args Method parameters.
443
  * - int blog_id
444
  * - string username
450
  * @return int with new album ID
451
  */
452
  function newAlbum($args) {
453
+
454
  global $ngg;
455
 
456
  $this->escape($args);
471
 
472
  if ( !empty( $name ) )
473
  $id = $result = nggdb::add_album( $name, $preview, $description, $galleries );
474
+
475
  if ( !$id )
476
  return new IXR_Error(500, __('Sorry, could not create the album'));
477
 
478
  return($id);
479
+
480
  }
481
 
482
  /**
483
  * Method "ngg.editAlbum"
484
  * Edit a existing Album
485
+ *
486
  * @since 1.7.0
487
+ *
488
  * @param array $args Method parameters.
489
  * - int blog_id
490
  * - string username
497
  * @return true if success
498
  */
499
  function editAlbum($args) {
500
+
501
  global $ngg;
502
 
503
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
504
+
505
  $this->escape($args);
506
  $blog_ID = (int) $args[0];
507
  $username = $args[1];
523
 
524
  if ( !empty( $name ) )
525
  $result = nggdb::update_album($id, $name, $preview, $description, $galleries);
526
+
527
  if ( !$result )
528
  return new IXR_Error(500, __('Sorry, could not update the album'));
529
 
530
  return true;
531
+
532
  }
533
 
534
  /**
535
  * Method "ngg.deleteAlbum"
536
  * Delete a album from the database
537
+ *
538
  * @since 1.7.0
539
+ *
540
  * @param array $args Method parameters.
541
  * - int blog_id
542
  * - string username
543
  * - string password
544
+ * - int album id
545
  * @return true
546
  */
547
  function deleteAlbum($args) {
548
+
549
  global $nggdb;
550
 
551
  $this->escape($args);
562
 
563
  if( !current_user_can( 'NextGEN Edit album' ) && !nggGallery::current_user_can( 'NextGEN Add/Delete album' ) )
564
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage albums' ) );
565
+
566
  $nggdb->delete_album($id);
567
+
568
  return true;
569
+
570
  }
571
 
572
  /**
573
  * Method "ngg.deleteGallery"
574
  * Delete a gallery from the database, including all images
575
+ *
576
  * @since 1.7.0
577
+ *
578
  * @param array $args Method parameters.
579
  * - int blog_id
580
  * - string username
581
  * - string password
582
+ * - int gallery_id
583
  * @return true
584
  */
585
  function deleteGallery($args) {
586
+
587
  global $nggdb;
588
 
589
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
602
 
603
  if ( !current_user_can( 'NextGEN Manage gallery' ) && !nggAdmin::can_manage_this_gallery($gallery->author) )
604
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage galleries' ) );
605
+
606
  $nggdb->delete_gallery($id);
607
+
608
  return true;
609
+
610
  }
611
 
612
  /**
613
  * Method "ngg.getAlbums"
614
  * Return the list of all albums
615
+ *
616
  * @since 1.7.0
617
+ *
618
  * @param array $args Method parameters.
619
  * - int blog_id
620
  * - string username
622
  * @return array with all galleries
623
  */
624
  function getAlbums($args) {
625
+
626
  global $nggdb;
627
 
628
  $this->escape($args);
635
 
636
  if( !current_user_can( 'NextGEN Edit album' ) )
637
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage albums' ) );
638
+
639
  $album_list = $nggdb->find_all_album('id', 'ASC', 0, 0 );
640
+
641
  return($album_list);
642
+
643
  }
644
 
645
  /**
680
  /**
681
  * Method "ngg.getGalleries"
682
  * Return the list of all galleries
683
+ *
684
  * @since 1.4
685
+ *
686
  * @param array $args Method parameters.
687
  * - int blog_id
688
  * - string username
690
  * @return array with all galleries
691
  */
692
  function getGalleries($args) {
693
+
694
  global $nggdb;
695
 
696
  $this->escape($args);
703
 
704
  if( !current_user_can( 'NextGEN Manage gallery' ) )
705
  return new IXR_Error( 401, __( 'Sorry, you must be able to manage galleries' ) );
706
+
707
  $gallery_list = $nggdb->find_all_galleries('gid', 'asc', true, 0, 0, false);
708
+
709
  return($gallery_list);
710
+
711
  }
712
 
713
  /**
748
  /**
749
  * Method "ngg.getImages"
750
  * Return the list of all images inside a gallery
751
+ *
752
  * @since 1.4
753
+ *
754
  * @param array $args Method parameters.
755
  * - int blog_id
756
  * - string username
757
  * - string password
758
+ * - int gallery_id
759
  * @return array with all images
760
  */
761
  function getImages($args) {
762
+
763
  global $nggdb;
764
 
765
  require_once ( dirname ( dirname( __FILE__ ) ). '/admin/functions.php' ); // admin functions
766
+
767
  $this->escape($args);
768
  $blog_ID = (int) $args[0];
769
  $username = $args[1];
774
  return $this->error;
775
 
776
  // Look for the gallery , could we find it ?
777
+ if ( !$gallery = nggdb::find_gallery( $gid ) )
778
  return new IXR_Error(404, __('Could not find gallery ' . $gid ));
779
 
780
  // Now check if you have the correct capability for this gallery
783
  $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
784
  return $this->error;
785
  }
786
+
787
  // get picture values
788
  $picture_list = $nggdb->get_gallery( $gid, 'pid', 'ASC', false );
789
+
790
  return($picture_list);
791
+
792
  }
793
 
794
  /**
875
  * @return bool Always true
876
  */
877
  function __destruct() {
878
+
879
  }
880
  }
881
 
nggallery.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.nextgen-gallery.com/
5
  Description: A NextGENeration Photo Gallery for WordPress
6
  Author: Photocrati
7
  Author URI: http://www.photocrati.com/
8
- Version: 1.9.9
9
 
10
  Copyright (c) 2007-2011 by Alex Rabe & NextGEN DEV-Team
11
  Copyright (c) 2012 Photocrati Media
@@ -45,7 +45,7 @@ if (!class_exists('E_Clean_Exit')) {
45
  if (!class_exists('nggLoader')) {
46
  class nggLoader {
47
 
48
- var $version = '1.9.9';
49
  var $dbversion = '1.8.1';
50
  var $minimum_WP = '3.4';
51
  var $donators = 'http://www.nextgen-gallery.com/donators.php';
5
  Description: A NextGENeration Photo Gallery for WordPress
6
  Author: Photocrati
7
  Author URI: http://www.photocrati.com/
8
+ Version: 1.9.10
9
 
10
  Copyright (c) 2007-2011 by Alex Rabe & NextGEN DEV-Team
11
  Copyright (c) 2012 Photocrati Media
45
  if (!class_exists('nggLoader')) {
46
  class nggLoader {
47
 
48
+ var $version = '1.9.10';
49
  var $dbversion = '1.8.1';
50
  var $minimum_WP = '3.4';
51
  var $donators = 'http://www.nextgen-gallery.com/donators.php';
nggfunctions.php CHANGED
@@ -5,33 +5,33 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
5
  /**
6
  * Return a script for the Imagerotator flash slideshow. Can be used in any template with <?php echo nggShowSlideshow($galleryID, $width, $height) ?>
7
  * Require the script swfobject.js in the header or footer
8
- *
9
- * @access public
10
  * @param integer $galleryID ID of the gallery
11
  * @param integer $irWidth Width of the flash container
12
  * @param integer $irHeight Height of the flash container
13
  * @return the content
14
  */
15
  function nggShowSlideshow($galleryID, $width, $height) {
16
-
17
  require_once (dirname (__FILE__).'/lib/swfobject.php');
18
 
19
  $ngg_options = nggGallery::get_option('ngg_options');
20
 
21
  // remove media file from RSS feed
22
  if ( is_feed() ) {
23
- $out = '[' . nggGallery::i18n($ngg_options['galTextSlide']) . ']';
24
  return $out;
25
  }
26
 
27
  //Redirect all calls to the JavaScript slideshow if wanted
28
  if ( $ngg_options['enableIR'] !== '1' || nggGallery::detect_mobile_phone() === true )
29
  return nggShow_JS_Slideshow($galleryID, $width, $height);
30
-
31
  // If the Imagerotator didn't exist, skip the output
32
- if ( NGGALLERY_IREXIST == false )
33
- return;
34
-
35
  if (empty($width) ) $width = (int) $ngg_options['irWidth'];
36
  if (empty($height)) $height = (int) $ngg_options['irHeight'];
37
  // Doesn't work fine with zero
@@ -46,7 +46,7 @@ function nggShowSlideshow($galleryID, $width, $height) {
46
  $swfobject->add_attributes('styleclass', 'slideshow');
47
  $swfobject->add_attributes('name', 'so' . $galleryID);
48
 
49
- // adding the flash parameter
50
  $swfobject->add_flashvars( 'file', urlencode ( trailingslashit ( home_url() ) . 'index.php?callback=imagerotator&gid=' . $galleryID ) );
51
  $swfobject->add_flashvars( 'shuffle', $ngg_options['irShuffle'], 'true', 'bool');
52
  // option has oposite meaning : true should switch to next image
@@ -62,10 +62,10 @@ function nggShowSlideshow($galleryID, $width, $height) {
62
  $swfobject->add_flashvars( 'lightcolor', $ngg_options['irLightcolor'], '000000', 'string', '0x');
63
  $swfobject->add_flashvars( 'screencolor', $ngg_options['irScreencolor'], '000000', 'string', '0x');
64
  if ($ngg_options['irWatermark'])
65
- $swfobject->add_flashvars( 'logo', $ngg_options['wmPath'], '', 'string');
66
  $swfobject->add_flashvars( 'audio', $ngg_options['irAudio'], '', 'string');
67
  $swfobject->add_flashvars( 'width', $width, '260');
68
- $swfobject->add_flashvars( 'height', $height, '320');
69
  // create the output
70
  $out = '<div class="slideshow">' . $swfobject->output() . '</div>';
71
  // add now the script code
@@ -80,15 +80,15 @@ function nggShowSlideshow($galleryID, $width, $height) {
80
  $out .= "\n".'</script>';
81
 
82
  $out = apply_filters('ngg_show_slideshow_content', $out, $galleryID, $width, $height);
83
-
84
- return $out;
85
  }
86
 
87
  /**
88
  * Return a script for the jQuery based slideshow. Can be used in any template with <?php echo nggShow_JS_Slideshow($galleryID, $width, $height) ?>
89
  * Require the script jquery.cycle.all.js
90
- *
91
- * @since 1.6.0
92
  * @access public
93
  * @param integer $galleryID ID of the gallery
94
  * @param integer $width Width of the slideshow container
@@ -97,27 +97,27 @@ function nggShowSlideshow($galleryID, $width, $height) {
97
  * @return the content
98
  */
99
  function nggShow_JS_Slideshow($galleryID, $width, $height, $class = 'ngg-slideshow') {
100
-
101
  global $slideCounter;
102
-
103
  $ngg_options = nggGallery::get_option('ngg_options');
104
-
105
  // we need to know the current page id
106
  $current_page = (get_the_ID() == false) ? rand(5, 15) : get_the_ID();
107
  // look for a other slideshow instance
108
- if ( !isset($slideCounter) ) $slideCounter = 1;
109
  // create unique anchor
110
  $anchor = 'ngg-slideshow-' . $galleryID . '-' . $current_page . '-' . $slideCounter++;
111
-
112
  if (empty($width) ) $width = (int) $ngg_options['irWidth'];
113
  if (empty($height)) $height = (int) $ngg_options['irHeight'];
114
-
115
  //filter to resize images for mobile browser
116
  list($width, $height) = apply_filters('ngg_slideshow_size', array( $width, $height ) );
117
-
118
  $width = (int) $width;
119
  $height = (int) $height;
120
-
121
  $out = '<div id="' . $anchor . '" class="' . $class . '" style="height:' . $height . 'px;width:' . $width . 'px;">';
122
  $out .= "\n". '<div id="' . $anchor . '-loader" class="ngg-slideshow-loader" style="height:' . $height . 'px;width:' . $width . 'px;">';
123
  $out .= "\n". '<img src="'. NGGALLERY_URLPATH . 'images/loader.gif" alt="" />';
@@ -125,9 +125,9 @@ function nggShow_JS_Slideshow($galleryID, $width, $height, $class = 'ngg-slidesh
125
  $out .= '</div>'."\n";
126
  $out .= "\n".'<script type="text/javascript" defer="defer">';
127
  $out .= "\n" . 'jQuery(document).ready(function(){ ' . "\n" . 'jQuery("#' . $anchor . '").nggSlideshow( {' .
128
- 'id: ' . $galleryID . ',' .
129
  'fx:"' . $ngg_options['slideFx'] . '",' .
130
- 'width:' . $width . ',' .
131
  'height:' . $height . ',' .
132
  'domain: "' . trailingslashit ( home_url() ) . '",' .
133
  'timeout:' . $ngg_options['irRotatetime'] * 1000 .
@@ -138,24 +138,24 @@ function nggShow_JS_Slideshow($galleryID, $width, $height, $class = 'ngg-slidesh
138
  }
139
 
140
  /**
141
- * nggShowGallery() - return a gallery
142
- *
143
- * @access public
144
  * @param int | string ID or slug from a gallery
145
  * @param string $template (optional) name for a template file, look for gallery-$template
146
  * @param int $images (optional) number of images per page
147
  * @return the content
148
  */
149
  function nggShowGallery( $galleryID, $template = '', $images = false ) {
150
-
151
  global $nggRewrite;
152
 
153
  $ngg_options = nggGallery::get_option('ngg_options');
154
-
155
  //Set sort order value, if not used (upgrade issue)
156
  $ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
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']);
@@ -173,12 +173,12 @@ function nggShowGallery( $galleryID, $template = '', $images = false ) {
173
  $show = get_query_var('show');
174
  $pid = get_query_var('pid');
175
  $pageid = get_query_var('pageid');
176
-
177
  // set $show if slideshow first
178
  if ( empty( $show ) AND ($ngg_options['galShowOrder'] == 'slide')) {
179
- if ( is_home() )
180
  $pageid = get_the_ID();
181
-
182
  $show = 'slide';
183
  }
184
 
@@ -190,14 +190,14 @@ function nggShowGallery( $galleryID, $template = '', $images = false ) {
190
  }
191
 
192
  // go on only on this page
193
- if ( !is_home() || $pageid == get_the_ID() ) {
194
-
195
  // 1st look for ImageBrowser link
196
  if ( !empty($pid) && $ngg_options['galImgBrowser'] && ($template != 'carousel') ) {
197
  $out = nggShowImageBrowser( $galleryID, $template );
198
  return $out;
199
  }
200
-
201
  // 2nd look for slideshow
202
  if ( $show == 'slide' ) {
203
  $args['show'] = "gallery";
@@ -213,14 +213,14 @@ function nggShowGallery( $galleryID, $template = '', $images = false ) {
213
  // get all picture with this galleryid
214
  if ( is_array($picturelist) )
215
  $out = nggCreateGallery($picturelist, $galleryID, $template, $images);
216
-
217
  $out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID));
218
  return $out;
219
  }
220
 
221
  /**
222
  * Build a gallery output
223
- *
224
  * @access internal
225
  * @param array $picturelist
226
  * @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link
@@ -232,32 +232,32 @@ function nggCreateGallery($picturelist, $galleryID = false, $template = '', $ima
232
  global $nggRewrite;
233
 
234
  require_once (dirname (__FILE__) . '/lib/media-rss.php');
235
-
236
  $ngg_options = nggGallery::get_option('ngg_options');
237
 
238
  //the shortcode parameter will override global settings, TODO: rewrite this to a class
239
- $ngg_options['galImages'] = ( $images === false ) ? $ngg_options['galImages'] : (int) $images;
240
-
241
  $current_pid = false;
242
-
243
  // $_GET from wp_query
244
  $nggpage = get_query_var('nggpage');
245
  $pageid = get_query_var('pageid');
246
  $pid = get_query_var('pid');
247
-
248
  // in case of permalinks the pid is a slug, we need the id
249
  if( !is_numeric($pid) && !empty($pid) ) {
250
- $picture = nggdb::find_image($pid);
251
  $pid = $picture->pid;
252
- }
253
-
254
  // we need to know the current page id
255
  $current_page = (get_the_ID() == false) ? 0 : get_the_ID();
256
 
257
  if ( !is_array($picturelist) )
258
  $picturelist = array($picturelist);
259
-
260
- // Populate galleries values from the first image
261
  $first_image = current($picturelist);
262
  $gallery = new stdclass;
263
  $gallery->ID = (int) $galleryID;
@@ -272,16 +272,16 @@ function nggCreateGallery($picturelist, $galleryID = false, $template = '', $ima
272
 
273
  $maxElement = $ngg_options['galImages'];
274
  $thumbwidth = $ngg_options['thumbwidth'];
275
- $thumbheight = $ngg_options['thumbheight'];
276
-
277
  // fixed width if needed
278
  $gallery->columns = intval($ngg_options['galColumns']);
279
  $gallery->imagewidth = ($gallery->columns > 0) ? 'style="width:' . floor(100/$gallery->columns) . '%;"' : '';
280
-
281
  // obsolete in V1.4.0, but kept for compat reason
282
- // pre set thumbnail size, from the option, later we look for meta data.
283
  $thumbsize = ($ngg_options['thumbfix']) ? $thumbsize = 'width="' . $thumbwidth . '" height="'.$thumbheight . '"' : '';
284
-
285
  // show slideshow link
286
  if ($galleryID) {
287
  if ($ngg_options['galShowSlide']) {
@@ -289,7 +289,7 @@ function nggCreateGallery($picturelist, $galleryID = false, $template = '', $ima
289
  $gallery->slideshow_link = $nggRewrite->get_permalink(array ( 'show' => 'slide') );
290
  $gallery->slideshow_link_text = nggGallery::i18n($ngg_options['galTextSlide']);
291
  }
292
-
293
  if ($ngg_options['usePicLens']) {
294
  $gallery->show_piclens = true;
295
  $gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars( nggMediaRss::get_gallery_mrss_url($gallery->ID) ) . "'});";
@@ -298,48 +298,48 @@ function nggCreateGallery($picturelist, $galleryID = false, $template = '', $ima
298
 
299
  // check for page navigation
300
  if ($maxElement > 0) {
301
-
302
  if ( !is_home() || $pageid == $current_page )
303
  $page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
304
- else
305
  $page = 1;
306
-
307
  $start = $offset = ( $page - 1 ) * $maxElement;
308
-
309
  $total = count($picturelist);
310
 
311
  //we can work with display:hidden for some javascript effects
312
  if (!$ngg_options['galHiddenImg']){
313
  // remove the element if we didn't start at the beginning
314
- if ($start > 0 )
315
  array_splice($picturelist, 0, $start);
316
-
317
  // return the list of images we need
318
  array_splice($picturelist, $maxElement);
319
  }
320
 
321
- $nggNav = new nggNavigation;
322
  $navigation = $nggNav->create_navigation($page, $total, $maxElement);
323
  } else {
324
  $navigation = '<div class="ngg-clear"></div>';
325
- }
326
-
327
  //we cannot use the key as index, cause it's filled with the pid
328
  $index = 0;
329
  foreach ($picturelist as $key => $picture) {
330
 
331
  //needed for hidden images (THX to Sweigold for the main idea at : http://wordpress.org/support/topic/228743/ )
332
- $picturelist[$key]->hidden = false;
333
  $picturelist[$key]->style = $gallery->imagewidth;
334
-
335
  if ($maxElement > 0 && $ngg_options['galHiddenImg']) {
336
  if ( ($index < $start) || ($index > ($start + $maxElement -1)) ){
337
- $picturelist[$key]->hidden = true;
338
  $picturelist[$key]->style = ($gallery->columns > 0) ? 'style="width:' . floor(100/$gallery->columns) . '%;display: none;"' : 'style="display: none;"';
339
  }
340
  $index++;
341
  }
342
-
343
  // get the effect code
344
  if ($galleryID)
345
  $thumbcode = ($ngg_options['galImgBrowser']) ? '' : $picture->get_thumbcode('set_' . $galleryID);
@@ -350,13 +350,13 @@ function nggCreateGallery($picturelist, $galleryID = false, $template = '', $ima
350
  $args ['nggpage'] = empty($nggpage) || ($template != 'carousel') ? false : $nggpage; // only needed for carousel mode
351
  $args ['pid'] = ($ngg_options['usePermalinks']) ? $picture->image_slug : $picture->pid;
352
  $picturelist[$key]->pidlink = $nggRewrite->get_permalink( $args );
353
-
354
  // generate the thumbnail size if the meta data available
355
  if ( isset($picturelist[$key]->meta_data['thumbnail']) && is_array ($size = $picturelist[$key]->meta_data['thumbnail']) )
356
  $thumbsize = 'width="' . $size['width'] . '" height="' . $size['height'] . '"';
357
-
358
  // choose link between imagebrowser or effect
359
- $link = ($ngg_options['galImgBrowser']) ? $picturelist[$key]->pidlink : $picture->imageURL;
360
  // bad solution : for now we need the url always for the carousel, should be reworked in the future
361
  $picturelist[$key]->url = $picture->imageURL;
362
  // add a filter for the link
@@ -367,50 +367,50 @@ function nggCreateGallery($picturelist, $galleryID = false, $template = '', $ima
367
  $picturelist[$key]->caption = ( empty($picture->description) ) ? '&nbsp;' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) );
368
  $picturelist[$key]->description = ( empty($picture->description) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) );
369
  $picturelist[$key]->alttext = ( empty($picture->alttext) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) );
370
-
371
  // filter to add custom content for the output
372
  $picturelist[$key] = apply_filters('ngg_image_object', $picturelist[$key], $picture->pid);
373
 
374
  //check if $pid is in the array
375
- if ($picture->pid == $pid)
376
  $current_pid = $picturelist[$key];
377
  }
378
  reset($picturelist);
379
 
380
  //for paged galleries, take the first image in the array if it's not in the list
381
  $current_pid = ( empty($current_pid) ) ? current( $picturelist ) : $current_pid;
382
-
383
  // look for gallery-$template.php or pure gallery.php
384
  $filename = ( empty($template) ) ? 'gallery' : 'gallery-' . $template;
385
-
386
  //filter functions for custom addons
387
  $gallery = apply_filters( 'ngg_gallery_object', $gallery, $galleryID );
388
  $picturelist = apply_filters( 'ngg_picturelist_object', $picturelist, $galleryID );
389
-
390
  //additional navigation links
391
  $next = ( empty($nggNav->next) ) ? false : $nggNav->next;
392
  $prev = ( empty($nggNav->prev) ) ? false : $nggNav->prev;
393
 
394
  // create the output
395
  $out = nggGallery::capture ( $filename, array ('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation, 'current' => $current_pid, 'next' => $next, 'prev' => $prev) );
396
-
397
  // apply a filter after the output
398
  $out = apply_filters('ngg_gallery_output', $out, $picturelist);
399
-
400
  return $out;
401
  }
402
 
403
  /**
404
  * nggShowAlbum() - return a album based on the id
405
- *
406
- * @access public
407
  * @param int | string $albumID
408
  * @param string (optional) $template
409
  * @param string (optional) $gallery_template
410
  * @return the content
411
  */
412
  function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
413
-
414
  // $_GET from wp_query
415
  $gallery = get_query_var('gallery');
416
  $album = get_query_var('album');
@@ -418,43 +418,43 @@ function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
418
  // in the case somebody uses the '0', it should be 'all' to show all galleries
419
  $albumID = ($albumID == 0) ? 'all' : $albumID;
420
 
421
- // first look for gallery variable
422
  if (!empty( $gallery )) {
423
-
424
  // subalbum support only one instance, you can't use more of them in one post
425
  //TODO: causes problems with SFC plugin, due to a second filter callback
426
  if ( isset($GLOBALS['subalbum']) || isset($GLOBALS['nggShowGallery']) )
427
  return;
428
-
429
- // if gallery is submit , then show the gallery instead
430
  $out = nggShowGallery( $gallery, $gallery_template );
431
  $GLOBALS['nggShowGallery'] = true;
432
-
433
  return $out;
434
  }
435
-
436
  if ( (empty( $gallery )) && (isset($GLOBALS['subalbum'])) )
437
  return;
438
 
439
- //redirect to subalbum only one time
440
  if (!empty( $album )) {
441
  $GLOBALS['subalbum'] = true;
442
- $albumID = $album;
443
  }
444
 
445
  // lookup in the database
446
  $album = nggdb::find_album( $albumID );
447
 
448
  // still no success ? , die !
449
- if( !$album )
450
  return __('[Album not found]','nggallery');
451
 
452
  // ensure to set the slug for "all" albums
453
  $album->slug = ($albumID == 'all') ? $album->id : $album->slug;
454
-
455
  if ( is_array($album->gallery_ids) )
456
  $out = nggCreateAlbum( $album->gallery_ids, $template, $album );
457
-
458
  $out = apply_filters( 'ngg_show_album_content', $out, $album->id );
459
 
460
  return $out;
@@ -462,7 +462,7 @@ function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
462
 
463
  /**
464
  * create a gallery overview output
465
- *
466
  * @access internal
467
  * @param array $galleriesID
468
  * @param string (optional) $template name for a template file, look for album-$template
@@ -472,52 +472,53 @@ function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
472
  function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
473
 
474
  global $wpdb, $nggRewrite, $nggdb;
475
-
476
  // $_GET from wp_query
477
- $nggpage = get_query_var('nggpage');
478
-
479
  $ngg_options = nggGallery::get_option('ngg_options');
480
-
481
  //this option can currently only set via the custom fields
482
  $maxElement = (int) $ngg_options['galPagedGalleries'];
483
 
484
  $sortorder = $galleriesID;
485
  $galleries = array();
486
-
487
- // get the galleries information
488
  foreach ($galleriesID as $i => $value)
489
  $galleriesID[$i] = addslashes($value);
490
 
491
  $unsort_galleries = $wpdb->get_results('SELECT * FROM '.$wpdb->nggallery.' WHERE gid IN (\''.implode('\',\'', $galleriesID).'\')', OBJECT_K);
492
 
493
- //TODO: Check this, problem exist when previewpic = 0
494
  //$galleries = $wpdb->get_results('SELECT t.*, tt.* FROM '.$wpdb->nggallery.' AS t INNER JOIN '.$wpdb->nggpictures.' AS tt ON t.previewpic = tt.pid WHERE t.gid IN (\''.implode('\',\'', $galleriesID).'\')', OBJECT_K);
495
 
496
- // get the counter values
497
  $picturesCounter = $wpdb->get_results('SELECT galleryid, COUNT(*) as counter FROM '.$wpdb->nggpictures.' WHERE galleryid IN (\''.implode('\',\'', $galleriesID).'\') AND exclude != 1 GROUP BY galleryid', OBJECT_K);
498
  if ( is_array($picturesCounter) ) {
499
  foreach ($picturesCounter as $key => $value)
500
  $unsort_galleries[$key]->counter = $value->counter;
501
  }
502
-
503
  // get the id's of the preview images
504
  $imagesID = array();
505
  if ( is_array($unsort_galleries) ) {
506
  foreach ($unsort_galleries as $gallery_row)
507
  $imagesID[] = $gallery_row->previewpic;
508
- }
509
  $albumPreview = $wpdb->get_results('SELECT pid, filename FROM '.$wpdb->nggpictures.' WHERE pid IN (\''.implode('\',\'', $imagesID).'\')', OBJECT_K);
510
 
511
- // re-order them and populate some
512
  foreach ($sortorder as $key) {
513
-
514
  //if we have a prefix 'a' then it's a subalbum, instead a gallery
515
- if (substr( $key, 0, 1) == 'a') {
516
  // get the album content
517
  if ( !$subalbum = $nggdb->find_album(substr( $key, 1)) )
518
  continue;
519
-
520
  //populate the sub album values
 
521
  $galleries[$key]->counter = 0;
522
  $galleries[$key]->previewurl = '';
523
  // ensure that album contain a preview image
@@ -525,39 +526,39 @@ function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
525
  $image = $nggdb->find_image( $subalbum->previewpic );
526
  $galleries[$key]->previewurl = isset($image->thumbURL) ? $image->thumbURL : '';
527
  }
528
-
529
- $galleries[$key]->previewpic = $subalbum->previewpic;
530
  $galleries[$key]->previewname = $subalbum->name;
531
-
532
  //link to the subalbum
533
  $args['album'] = ( $ngg_options['usePermalinks'] ) ? $subalbum->slug : $subalbum->id;
534
- $args['gallery'] = false;
535
  $args['nggpage'] = false;
536
  $pageid = (isset($subalbum->pageid) ? $subalbum->pageid : 0);
537
  $galleries[$key]->pagelink = ($pageid > 0) ? get_permalink($pageid) : $nggRewrite->get_permalink($args);
538
  $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n($subalbum->albumdesc) );
539
- $galleries[$key]->title = html_entity_decode ( nggGallery::i18n($subalbum->name) );
540
-
541
  // apply a filter on gallery object before the output
542
  $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
543
-
544
  continue;
545
  }
546
-
547
  // If a gallery is not found it should be ignored
548
  if (!$unsort_galleries[$key])
549
  continue;
550
-
551
  // No images found, set counter to 0
552
  if (!isset($galleries[$key]->counter)){
553
  $galleries[$key]->counter = 0;
554
  $galleries[$key]->previewurl = '';
555
  }
556
-
557
  // Add the counter value if avaible
558
  $galleries[$key] = $unsort_galleries[$key];
559
-
560
- // add the file name and the link
561
  if ($galleries[$key]->previewpic != 0) {
562
  $galleries[$key]->previewname = $albumPreview[$galleries[$key]->previewpic]->filename;
563
  $galleries[$key]->previewurl = site_url().'/' . $galleries[$key]->path . '/thumbs/thumbs_' . $albumPreview[$galleries[$key]->previewpic]->filename;
@@ -566,52 +567,52 @@ function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
566
  if (isset($first_image)) {
567
  $galleries[$key]->previewpic = $first_image->pid;
568
  $galleries[$key]->previewname = $first_image->filename;
569
- $galleries[$key]->previewurl = site_url() . '/' . $galleries[$key]->path . '/thumbs/thumbs_' . $first_image->filename;
570
  }
571
  }
572
 
573
  // choose between variable and page link
574
  if ($ngg_options['galNoPages']) {
575
- $args['album'] = ( $ngg_options['usePermalinks'] ) ? $album->slug : $album->id;
576
  $args['gallery'] = ( $ngg_options['usePermalinks'] ) ? $galleries[$key]->slug : $key;
577
  $args['nggpage'] = false;
578
  $galleries[$key]->pagelink = $nggRewrite->get_permalink($args);
579
-
580
  } else {
581
  $galleries[$key]->pagelink = get_permalink( $galleries[$key]->pageid );
582
  }
583
-
584
  // description can contain HTML tags
585
  $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->galdesc), 'gal_' . $galleries[$key]->gid . '_description') ) ;
586
 
587
  // i18n
588
  $galleries[$key]->title = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->title), 'gal_' . $galleries[$key]->gid . '_title') ) ;
589
-
590
  // apply a filter on gallery object before the output
591
  $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
592
  }
593
-
594
  // apply a filter on gallery object before paging starts
595
  $galleries = apply_filters('ngg_album_galleries_before_paging', $galleries, $album);
596
-
597
  // check for page navigation
598
  if ($maxElement > 0) {
599
  if ( !is_home() || $pageid == get_the_ID() ) {
600
  $page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
601
  }
602
  else $page = 1;
603
-
604
  $start = $offset = ( $page - 1 ) * $maxElement;
605
-
606
  $total = count($galleries);
607
-
608
  // remove the element if we didn't start at the beginning
609
  if ($start > 0 ) array_splice($galleries, 0, $start);
610
-
611
  // return the list of images we need
612
  array_splice($galleries, $maxElement);
613
-
614
- $nggNav = new nggNavigation;
615
  $navigation = $nggNav->create_navigation($page, $total, $maxElement);
616
  } else {
617
  $navigation = '<div class="ngg-clear"></div>';
@@ -619,7 +620,7 @@ function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
619
 
620
  // apply a filter on $galleries before the output
621
  $galleries = apply_filters('ngg_album_galleries', $galleries);
622
-
623
  // if sombody didn't enter any template , take the extend version
624
  $filename = ( empty($template) ) ? 'album-extend' : 'album-' . $template ;
625
 
@@ -627,44 +628,44 @@ function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
627
  $out = nggGallery::capture ( $filename, array ('album' => $album, 'galleries' => $galleries, 'pagination' => $navigation) );
628
 
629
  return $out;
630
-
631
  }
632
 
633
  /**
634
  * nggShowImageBrowser()
635
- *
636
- * @access public
637
  * @param int|string $galleryID or gallery name
638
  * @param string $template (optional) name for a template file, look for imagebrowser-$template
639
  * @return the content
640
  */
641
  function nggShowImageBrowser($galleryID, $template = '') {
642
-
643
  global $wpdb;
644
-
645
  $ngg_options = nggGallery::get_option('ngg_options');
646
-
647
  //Set sort order value, if not used (upgrade issue)
648
  $ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
649
  $ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
650
-
651
  // get the pictures
652
  $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
653
-
654
  if ( is_array($picturelist) )
655
  $out = nggCreateImageBrowser($picturelist, $template);
656
  else
657
  $out = __('[Gallery not found]','nggallery');
658
-
659
  $out = apply_filters('ngg_show_imagebrowser_content', $out, $galleryID);
660
-
661
  return $out;
662
-
663
  }
664
 
665
  /**
666
  * nggCreateImageBrowser()
667
- *
668
  * @access internal
669
  * @param array $picturelist
670
  * @param string $template (optional) name for a template file, look for imagebrowser-$template
@@ -673,15 +674,15 @@ function nggShowImageBrowser($galleryID, $template = '') {
673
  function nggCreateImageBrowser($picturelist, $template = '') {
674
 
675
  global $nggRewrite, $ngg;
676
-
677
  require_once( dirname (__FILE__) . '/lib/meta.php' );
678
-
679
  // $_GET from wp_query
680
  $pid = get_query_var('pid');
681
-
682
  // we need to know the current page id
683
  $current_page = (get_the_ID() == false) ? 0 : get_the_ID();
684
-
685
  // create a array with id's for better walk inside
686
  foreach ($picturelist as $picture)
687
  $picarray[] = $picture->pid;
@@ -689,7 +690,7 @@ function nggCreateImageBrowser($picturelist, $template = '') {
689
  $total = count($picarray);
690
 
691
  if ( !empty( $pid )) {
692
- if ( is_numeric($pid) )
693
  $act_pid = intval($pid);
694
  else {
695
  // in the case it's a slug we need to search for the pid
@@ -698,13 +699,13 @@ function nggCreateImageBrowser($picturelist, $template = '') {
698
  $act_pid = $key;
699
  break;
700
  }
701
- }
702
  }
703
  } else {
704
  reset($picarray);
705
  $act_pid = current($picarray);
706
  }
707
-
708
  // get ids for back/next
709
  $key = array_search($act_pid, $picarray);
710
  if (!$key) {
@@ -713,14 +714,14 @@ function nggCreateImageBrowser($picturelist, $template = '') {
713
  }
714
  $back_pid = ( $key >= 1 ) ? $picarray[$key-1] : end($picarray) ;
715
  $next_pid = ( $key < ($total-1) ) ? $picarray[$key+1] : reset($picarray) ;
716
-
717
  // get the picture data
718
  $picture = nggdb::find_image($act_pid);
719
-
720
  // if we didn't get some data, exit now
721
  if ($picture == null)
722
  return;
723
-
724
  // add more variables for render output
725
  $picture->href_link = $picture->get_href_link();
726
  $args ['pid'] = ($ngg->options['usePermalinks']) ? $picturelist[$back_pid]->image_slug : $back_pid;
@@ -735,10 +736,10 @@ function nggCreateImageBrowser($picturelist, $template = '') {
735
  $picture->alttext = ( empty($picture->alttext) ) ? ' ' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) );
736
  $picture->description = ( empty($picture->description) ) ? ' ' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) );
737
  $picture->anchor = 'ngg-imagebrowser-' . $picture->galleryid . '-' . $current_page;
738
-
739
  // filter to add custom content for the output
740
  $picture = apply_filters('ngg_image_object', $picture, $act_pid);
741
-
742
  // let's get the meta data
743
  $meta = new nggMeta($act_pid);
744
  $meta->sanitize();
@@ -746,24 +747,24 @@ function nggCreateImageBrowser($picturelist, $template = '') {
746
  $iptc = $meta->get_IPTC();
747
  $xmp = $meta->get_XMP();
748
  $db = $meta->get_saved_meta();
749
-
750
- //if we get no exif information we try the database
751
  $exif = ($exif == false) ? $db : $exif;
752
-
753
  // look for imagebrowser-$template.php or pure imagebrowser.php
754
  $filename = ( empty($template) ) ? 'imagebrowser' : 'imagebrowser-' . $template;
755
 
756
  // create the output
757
  $out = nggGallery::capture ( $filename , array ('image' => $picture , 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db) );
758
-
759
  return $out;
760
-
761
  }
762
 
763
  /**
764
  * nggSinglePicture() - show a single picture based on the id
765
- *
766
- * @access public
767
  * @param int $imageID, db-ID of the image
768
  * @param int (optional) $width, width of the image
769
  * @param int (optional) $height, height of the image
@@ -776,48 +777,48 @@ function nggCreateImageBrowser($picturelist, $template = '') {
776
  */
777
  function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '' , $template = '', $caption = '', $link = '') {
778
  global $post;
779
-
780
  $ngg_options = nggGallery::get_option('ngg_options');
781
-
782
  // get picturedata
783
  $picture = nggdb::find_image($imageID);
784
-
785
  // if we didn't get some data, exit now
786
  if ($picture == null)
787
  return __('[SinglePic not found]','nggallery');
788
-
789
  // add float to img
790
  switch ($float) {
791
-
792
- case 'left':
793
  $float =' ngg-left';
794
  break;
795
-
796
- case 'right':
797
  $float =' ngg-right';
798
  break;
799
 
800
- case 'center':
801
  $float =' ngg-center';
802
  break;
803
-
804
- default:
805
  $float ='';
806
  break;
807
  }
808
-
809
- // clean mode if needed
810
  $mode = ( preg_match('/(web20|watermark)/i', $mode) ) ? $mode : '';
811
-
812
  //let's initiate the url
813
  $picture->thumbnailURL = false;
814
 
815
  // check fo cached picture
816
  if ( $post->post_status == 'publish' )
817
  $picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode );
818
-
819
- // if we didn't use a cached image then we take the on-the-fly mode
820
- if (!$picture->thumbnailURL)
821
  $picture->thumbnailURL = trailingslashit( home_url() ) . 'index.php?callback=image&amp;pid=' . $imageID . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=' . $mode;
822
 
823
  // add more variables for render output
@@ -842,10 +843,10 @@ function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $fl
842
  $iptc = $meta->get_IPTC();
843
  $xmp = $meta->get_XMP();
844
  $db = $meta->get_saved_meta();
845
-
846
- //if we get no exif information we try the database
847
  $exif = ($exif == false) ? $db : $exif;
848
-
849
  // look for singlepic-$template.php or pure singlepic.php
850
  $filename = ( empty($template) ) ? 'singlepic' : 'singlepic-' . $template;
851
 
@@ -853,28 +854,28 @@ function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $fl
853
  $out = nggGallery::capture ( $filename, array ('image' => $picture , 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db) );
854
 
855
  $out = apply_filters('ngg_show_singlepic_content', $out, $picture );
856
-
857
  return $out;
858
  }
859
 
860
  /**
861
  * nggShowGalleryTags() - create a gallery based on the tags
862
- *
863
- * @access public
864
  * @param string $taglist list of tags as csv
865
  * @return the content
866
  */
867
- function nggShowGalleryTags($taglist) {
868
 
869
  // $_GET from wp_query
870
  $pid = get_query_var('pid');
871
  $pageid = get_query_var('pageid');
872
-
873
  // get now the related images
874
  $picturelist = nggTags::find_images_for_tags($taglist , 'ASC');
875
 
876
  // look for ImageBrowser if we have a $_GET('pid')
877
- if ( $pageid == get_the_ID() || !is_home() )
878
  if (!empty( $pid )) {
879
  $out = nggCreateImageBrowser( $picturelist );
880
  return $out;
@@ -883,34 +884,34 @@ function nggShowGalleryTags($taglist) {
883
  // go on if not empty
884
  if ( empty($picturelist) )
885
  return;
886
-
887
  // show gallery
888
  if ( is_array($picturelist) )
889
  $out = nggCreateGallery($picturelist, false);
890
-
891
  $out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist);
892
  return $out;
893
  }
894
 
895
  /**
896
  * nggShowRelatedGallery() - create a gallery based on the tags
897
- *
898
- * @access public
899
  * @param string $taglist list of tags as csv
900
  * @param integer $maxImages (optional) limit the number of images to show
901
  * @return the content
902
- */
903
  function nggShowRelatedGallery($taglist, $maxImages = 0) {
904
-
905
  $ngg_options = nggGallery::get_option('ngg_options');
906
-
907
  // get now the related images
908
  $picturelist = nggTags::find_images_for_tags($taglist, 'RAND');
909
 
910
  // go on if not empty
911
  if ( empty($picturelist) )
912
  return;
913
-
914
  // cut the list to maxImages
915
  if ( $maxImages > 0 )
916
  array_splice($picturelist, $maxImages);
@@ -927,49 +928,49 @@ function nggShowRelatedGallery($taglist, $maxImages = 0) {
927
  $out .= '</a>' . "\n";
928
  }
929
  $out .= '</div>' . "\n";
930
-
931
  $out = apply_filters('ngg_show_related_gallery_content', $out, $taglist);
932
-
933
  return $out;
934
  }
935
 
936
  /**
937
  * nggShowAlbumTags() - create a gallery based on the tags
938
- *
939
- * @access public
940
  * @param string $taglist list of tags as csv
941
  * @return the content
942
  */
943
  function nggShowAlbumTags($taglist) {
944
-
945
  global $wpdb, $nggRewrite;
946
 
947
  // $_GET from wp_query
948
  $tag = get_query_var('gallerytag');
949
  $pageid = get_query_var('pageid');
950
-
951
- // look for gallerytag variable
952
  if ( $pageid == get_the_ID() || !is_home() ) {
953
  if (!empty( $tag )) {
954
-
955
  // avoid this evil code $sql = 'SELECT name FROM wp_ngg_tags WHERE slug = \'slug\' union select concat(0x7c,user_login,0x7c,user_pass,0x7c) from wp_users WHERE 1 = 1';
956
  $slug = esc_attr( $tag );
957
  $tagname = $wpdb->get_var( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE slug = %s", $slug ) );
958
  $out = '<div id="albumnav"><span><a href="' . get_permalink() . '" title="' . __('Overview', 'nggallery') .' ">'.__('Overview', 'nggallery').'</a> | '.$tagname.'</span></div>';
959
  $out .= nggShowGalleryTags($slug);
960
  return $out;
961
-
962
- }
963
  }
964
-
965
  // get now the related images
966
  $picturelist = nggTags::get_album_images($taglist);
967
 
968
  // go on if not empty
969
  if ( empty($picturelist) )
970
  return;
971
-
972
- // re-structure the object that we can use the standard template
973
  foreach ($picturelist as $key => $picture) {
974
  $picturelist[$key]->previewpic = $picture->pid;
975
  $picturelist[$key]->previewname = $picture->filename;
@@ -978,22 +979,22 @@ function nggShowAlbumTags($taglist) {
978
  $picturelist[$key]->title = $picture->name;
979
  $picturelist[$key]->pagelink = $nggRewrite->get_permalink( array('gallerytag'=>$picture->slug) );
980
  }
981
-
982
  //TODO: Add pagination later
983
  $navigation = '<div class="ngg-clear"></div>';
984
-
985
  // create the output
986
  $out = nggGallery::capture ('album-compact', array ('album' => 0, 'galleries' => $picturelist, 'pagination' => $navigation) );
987
-
988
  $out = apply_filters('ngg_show_album_tags_content', $out, $taglist);
989
-
990
  return $out;
991
  }
992
 
993
  /**
994
  * nggShowRelatedImages() - return related images based on category or tags
995
- *
996
- * @access public
997
  * @param string $type could be 'tags' or 'category'
998
  * @param integer $maxImages of images
999
  * @return the content
@@ -1010,9 +1011,9 @@ function nggShowRelatedImages($type = '', $maxImages = 0) {
1010
 
1011
  switch ($type) {
1012
  case 'tags':
1013
- if (function_exists('get_the_tags')) {
1014
  $taglist = get_the_tags();
1015
-
1016
  if (is_array($taglist)) {
1017
  foreach ($taglist as $tag) {
1018
  $sluglist[] = $tag->slug;
@@ -1020,10 +1021,10 @@ function nggShowRelatedImages($type = '', $maxImages = 0) {
1020
  }
1021
  }
1022
  break;
1023
-
1024
  case 'category':
1025
  $catlist = get_the_category();
1026
-
1027
  if (is_array($catlist)) {
1028
  foreach ($catlist as $cat) {
1029
  $sluglist[] = $cat->category_nicename;
@@ -1031,17 +1032,17 @@ function nggShowRelatedImages($type = '', $maxImages = 0) {
1031
  }
1032
  break;
1033
  }
1034
-
1035
  $sluglist = implode(',', $sluglist);
1036
  $out = nggShowRelatedGallery($sluglist, $maxImages);
1037
-
1038
  return $out;
1039
  }
1040
 
1041
  /**
1042
  * Template function for theme authors
1043
  *
1044
- * @access public
1045
  * @param string (optional) $type could be 'tags' or 'category'
1046
  * @param integer (optional) $maxNumbers of images
1047
  * @return void
@@ -1052,7 +1053,7 @@ function the_related_images($type = 'tags', $maxNumbers = 7) {
1052
 
1053
  /**
1054
  * nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images
1055
- *
1056
  * @access public
1057
  * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random'
1058
  * @param integer $maxImages of images
@@ -1061,11 +1062,11 @@ function the_related_images($type = 'tags', $maxNumbers = 7) {
1061
  * @return the content
1062
  */
1063
  function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0) {
1064
-
1065
  // $_GET from wp_query
1066
  $pid = get_query_var('pid');
1067
  $pageid = get_query_var('pageid');
1068
-
1069
  // get now the recent or random images
1070
  switch ($type) {
1071
  case 'random':
@@ -1086,7 +1087,7 @@ function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0)
1086
  }
1087
 
1088
  // look for ImageBrowser if we have a $_GET('pid')
1089
- if ( $pageid == get_the_ID() || !is_home() )
1090
  if (!empty( $pid )) {
1091
  $out = nggCreateImageBrowser( $picturelist );
1092
  return $out;
@@ -1095,19 +1096,19 @@ function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0)
1095
  // go on if not empty
1096
  if ( empty($picturelist) )
1097
  return;
1098
-
1099
  // show gallery
1100
  if ( is_array($picturelist) )
1101
  $out = nggCreateGallery($picturelist, false, $template);
1102
 
1103
  $out = apply_filters('ngg_show_images_content', $out, $picturelist);
1104
-
1105
  return $out;
1106
  }
1107
 
1108
  /**
1109
  * nggTagCloud() - return a tag cloud based on the wp core tag cloud system
1110
- *
1111
  * @param array $args
1112
  * @param string $template (optional) name for a template file, look for gallery-$template
1113
  * @return the content
@@ -1118,17 +1119,17 @@ function nggTagCloud($args ='', $template = '') {
1118
  // $_GET from wp_query
1119
  $tag = get_query_var('gallerytag');
1120
  $pageid = get_query_var('pageid');
1121
-
1122
- // look for gallerytag variable
1123
  if ( $pageid == get_the_ID() || !is_home() ) {
1124
  if (!empty( $tag )) {
1125
-
1126
  $slug = esc_attr( $tag );
1127
  $out = nggShowGalleryTags( $slug );
1128
  return $out;
1129
- }
1130
  }
1131
-
1132
  $defaults = array(
1133
  'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
1134
  'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
@@ -1143,9 +1144,9 @@ function nggTagCloud($args ='', $template = '') {
1143
  $tags[ $key ]->link = $nggRewrite->get_permalink(array ('gallerytag' => $tag->slug));
1144
  $tags[ $key ]->id = $tag->term_id;
1145
  }
1146
-
1147
  $out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud( $tags, $args ) . '</div>';
1148
-
1149
  return $out;
1150
  }
1151
  ?>
5
  /**
6
  * Return a script for the Imagerotator flash slideshow. Can be used in any template with <?php echo nggShowSlideshow($galleryID, $width, $height) ?>
7
  * Require the script swfobject.js in the header or footer
8
+ *
9
+ * @access public
10
  * @param integer $galleryID ID of the gallery
11
  * @param integer $irWidth Width of the flash container
12
  * @param integer $irHeight Height of the flash container
13
  * @return the content
14
  */
15
  function nggShowSlideshow($galleryID, $width, $height) {
16
+
17
  require_once (dirname (__FILE__).'/lib/swfobject.php');
18
 
19
  $ngg_options = nggGallery::get_option('ngg_options');
20
 
21
  // remove media file from RSS feed
22
  if ( is_feed() ) {
23
+ $out = '[' . nggGallery::i18n($ngg_options['galTextSlide']) . ']';
24
  return $out;
25
  }
26
 
27
  //Redirect all calls to the JavaScript slideshow if wanted
28
  if ( $ngg_options['enableIR'] !== '1' || nggGallery::detect_mobile_phone() === true )
29
  return nggShow_JS_Slideshow($galleryID, $width, $height);
30
+
31
  // If the Imagerotator didn't exist, skip the output
32
+ if ( NGGALLERY_IREXIST == false )
33
+ return;
34
+
35
  if (empty($width) ) $width = (int) $ngg_options['irWidth'];
36
  if (empty($height)) $height = (int) $ngg_options['irHeight'];
37
  // Doesn't work fine with zero
46
  $swfobject->add_attributes('styleclass', 'slideshow');
47
  $swfobject->add_attributes('name', 'so' . $galleryID);
48
 
49
+ // adding the flash parameter
50
  $swfobject->add_flashvars( 'file', urlencode ( trailingslashit ( home_url() ) . 'index.php?callback=imagerotator&gid=' . $galleryID ) );
51
  $swfobject->add_flashvars( 'shuffle', $ngg_options['irShuffle'], 'true', 'bool');
52
  // option has oposite meaning : true should switch to next image
62
  $swfobject->add_flashvars( 'lightcolor', $ngg_options['irLightcolor'], '000000', 'string', '0x');
63
  $swfobject->add_flashvars( 'screencolor', $ngg_options['irScreencolor'], '000000', 'string', '0x');
64
  if ($ngg_options['irWatermark'])
65
+ $swfobject->add_flashvars( 'logo', $ngg_options['wmPath'], '', 'string');
66
  $swfobject->add_flashvars( 'audio', $ngg_options['irAudio'], '', 'string');
67
  $swfobject->add_flashvars( 'width', $width, '260');
68
+ $swfobject->add_flashvars( 'height', $height, '320');
69
  // create the output
70
  $out = '<div class="slideshow">' . $swfobject->output() . '</div>';
71
  // add now the script code
80
  $out .= "\n".'</script>';
81
 
82
  $out = apply_filters('ngg_show_slideshow_content', $out, $galleryID, $width, $height);
83
+
84
+ return $out;
85
  }
86
 
87
  /**
88
  * Return a script for the jQuery based slideshow. Can be used in any template with <?php echo nggShow_JS_Slideshow($galleryID, $width, $height) ?>
89
  * Require the script jquery.cycle.all.js
90
+ *
91
+ * @since 1.6.0
92
  * @access public
93
  * @param integer $galleryID ID of the gallery
94
  * @param integer $width Width of the slideshow container
97
  * @return the content
98
  */
99
  function nggShow_JS_Slideshow($galleryID, $width, $height, $class = 'ngg-slideshow') {
100
+
101
  global $slideCounter;
102
+
103
  $ngg_options = nggGallery::get_option('ngg_options');
104
+
105
  // we need to know the current page id
106
  $current_page = (get_the_ID() == false) ? rand(5, 15) : get_the_ID();
107
  // look for a other slideshow instance
108
+ if ( !isset($slideCounter) ) $slideCounter = 1;
109
  // create unique anchor
110
  $anchor = 'ngg-slideshow-' . $galleryID . '-' . $current_page . '-' . $slideCounter++;
111
+
112
  if (empty($width) ) $width = (int) $ngg_options['irWidth'];
113
  if (empty($height)) $height = (int) $ngg_options['irHeight'];
114
+
115
  //filter to resize images for mobile browser
116
  list($width, $height) = apply_filters('ngg_slideshow_size', array( $width, $height ) );
117
+
118
  $width = (int) $width;
119
  $height = (int) $height;
120
+
121
  $out = '<div id="' . $anchor . '" class="' . $class . '" style="height:' . $height . 'px;width:' . $width . 'px;">';
122
  $out .= "\n". '<div id="' . $anchor . '-loader" class="ngg-slideshow-loader" style="height:' . $height . 'px;width:' . $width . 'px;">';
123
  $out .= "\n". '<img src="'. NGGALLERY_URLPATH . 'images/loader.gif" alt="" />';
125
  $out .= '</div>'."\n";
126
  $out .= "\n".'<script type="text/javascript" defer="defer">';
127
  $out .= "\n" . 'jQuery(document).ready(function(){ ' . "\n" . 'jQuery("#' . $anchor . '").nggSlideshow( {' .
128
+ 'id: ' . $galleryID . ',' .
129
  'fx:"' . $ngg_options['slideFx'] . '",' .
130
+ 'width:' . $width . ',' .
131
  'height:' . $height . ',' .
132
  'domain: "' . trailingslashit ( home_url() ) . '",' .
133
  'timeout:' . $ngg_options['irRotatetime'] * 1000 .
138
  }
139
 
140
  /**
141
+ * nggShowGallery() - return a gallery
142
+ *
143
+ * @access public
144
  * @param int | string ID or slug from a gallery
145
  * @param string $template (optional) name for a template file, look for gallery-$template
146
  * @param int $images (optional) number of images per page
147
  * @return the content
148
  */
149
  function nggShowGallery( $galleryID, $template = '', $images = false ) {
150
+
151
  global $nggRewrite;
152
 
153
  $ngg_options = nggGallery::get_option('ngg_options');
154
+
155
  //Set sort order value, if not used (upgrade issue)
156
  $ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
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']);
173
  $show = get_query_var('show');
174
  $pid = get_query_var('pid');
175
  $pageid = get_query_var('pageid');
176
+
177
  // set $show if slideshow first
178
  if ( empty( $show ) AND ($ngg_options['galShowOrder'] == 'slide')) {
179
+ if ( is_home() )
180
  $pageid = get_the_ID();
181
+
182
  $show = 'slide';
183
  }
184
 
190
  }
191
 
192
  // go on only on this page
193
+ if ( !is_home() || $pageid == get_the_ID() ) {
194
+
195
  // 1st look for ImageBrowser link
196
  if ( !empty($pid) && $ngg_options['galImgBrowser'] && ($template != 'carousel') ) {
197
  $out = nggShowImageBrowser( $galleryID, $template );
198
  return $out;
199
  }
200
+
201
  // 2nd look for slideshow
202
  if ( $show == 'slide' ) {
203
  $args['show'] = "gallery";
213
  // get all picture with this galleryid
214
  if ( is_array($picturelist) )
215
  $out = nggCreateGallery($picturelist, $galleryID, $template, $images);
216
+
217
  $out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID));
218
  return $out;
219
  }
220
 
221
  /**
222
  * Build a gallery output
223
+ *
224
  * @access internal
225
  * @param array $picturelist
226
  * @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link
232
  global $nggRewrite;
233
 
234
  require_once (dirname (__FILE__) . '/lib/media-rss.php');
235
+
236
  $ngg_options = nggGallery::get_option('ngg_options');
237
 
238
  //the shortcode parameter will override global settings, TODO: rewrite this to a class
239
+ $ngg_options['galImages'] = ( $images === false ) ? $ngg_options['galImages'] : (int) $images;
240
+
241
  $current_pid = false;
242
+
243
  // $_GET from wp_query
244
  $nggpage = get_query_var('nggpage');
245
  $pageid = get_query_var('pageid');
246
  $pid = get_query_var('pid');
247
+
248
  // in case of permalinks the pid is a slug, we need the id
249
  if( !is_numeric($pid) && !empty($pid) ) {
250
+ $picture = nggdb::find_image($pid);
251
  $pid = $picture->pid;
252
+ }
253
+
254
  // we need to know the current page id
255
  $current_page = (get_the_ID() == false) ? 0 : get_the_ID();
256
 
257
  if ( !is_array($picturelist) )
258
  $picturelist = array($picturelist);
259
+
260
+ // Populate galleries values from the first image
261
  $first_image = current($picturelist);
262
  $gallery = new stdclass;
263
  $gallery->ID = (int) $galleryID;
272
 
273
  $maxElement = $ngg_options['galImages'];
274
  $thumbwidth = $ngg_options['thumbwidth'];
275
+ $thumbheight = $ngg_options['thumbheight'];
276
+
277
  // fixed width if needed
278
  $gallery->columns = intval($ngg_options['galColumns']);
279
  $gallery->imagewidth = ($gallery->columns > 0) ? 'style="width:' . floor(100/$gallery->columns) . '%;"' : '';
280
+
281
  // obsolete in V1.4.0, but kept for compat reason
282
+ // pre set thumbnail size, from the option, later we look for meta data.
283
  $thumbsize = ($ngg_options['thumbfix']) ? $thumbsize = 'width="' . $thumbwidth . '" height="'.$thumbheight . '"' : '';
284
+
285
  // show slideshow link
286
  if ($galleryID) {
287
  if ($ngg_options['galShowSlide']) {
289
  $gallery->slideshow_link = $nggRewrite->get_permalink(array ( 'show' => 'slide') );
290
  $gallery->slideshow_link_text = nggGallery::i18n($ngg_options['galTextSlide']);
291
  }
292
+
293
  if ($ngg_options['usePicLens']) {
294
  $gallery->show_piclens = true;
295
  $gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars( nggMediaRss::get_gallery_mrss_url($gallery->ID) ) . "'});";
298
 
299
  // check for page navigation
300
  if ($maxElement > 0) {
301
+
302
  if ( !is_home() || $pageid == $current_page )
303
  $page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
304
+ else
305
  $page = 1;
306
+
307
  $start = $offset = ( $page - 1 ) * $maxElement;
308
+
309
  $total = count($picturelist);
310
 
311
  //we can work with display:hidden for some javascript effects
312
  if (!$ngg_options['galHiddenImg']){
313
  // remove the element if we didn't start at the beginning
314
+ if ($start > 0 )
315
  array_splice($picturelist, 0, $start);
316
+
317
  // return the list of images we need
318
  array_splice($picturelist, $maxElement);
319
  }
320
 
321
+ $nggNav = new nggNavigation;
322
  $navigation = $nggNav->create_navigation($page, $total, $maxElement);
323
  } else {
324
  $navigation = '<div class="ngg-clear"></div>';
325
+ }
326
+
327
  //we cannot use the key as index, cause it's filled with the pid
328
  $index = 0;
329
  foreach ($picturelist as $key => $picture) {
330
 
331
  //needed for hidden images (THX to Sweigold for the main idea at : http://wordpress.org/support/topic/228743/ )
332
+ $picturelist[$key]->hidden = false;
333
  $picturelist[$key]->style = $gallery->imagewidth;
334
+
335
  if ($maxElement > 0 && $ngg_options['galHiddenImg']) {
336
  if ( ($index < $start) || ($index > ($start + $maxElement -1)) ){
337
+ $picturelist[$key]->hidden = true;
338
  $picturelist[$key]->style = ($gallery->columns > 0) ? 'style="width:' . floor(100/$gallery->columns) . '%;display: none;"' : 'style="display: none;"';
339
  }
340
  $index++;
341
  }
342
+
343
  // get the effect code
344
  if ($galleryID)
345
  $thumbcode = ($ngg_options['galImgBrowser']) ? '' : $picture->get_thumbcode('set_' . $galleryID);
350
  $args ['nggpage'] = empty($nggpage) || ($template != 'carousel') ? false : $nggpage; // only needed for carousel mode
351
  $args ['pid'] = ($ngg_options['usePermalinks']) ? $picture->image_slug : $picture->pid;
352
  $picturelist[$key]->pidlink = $nggRewrite->get_permalink( $args );
353
+
354
  // generate the thumbnail size if the meta data available
355
  if ( isset($picturelist[$key]->meta_data['thumbnail']) && is_array ($size = $picturelist[$key]->meta_data['thumbnail']) )
356
  $thumbsize = 'width="' . $size['width'] . '" height="' . $size['height'] . '"';
357
+
358
  // choose link between imagebrowser or effect
359
+ $link = ($ngg_options['galImgBrowser']) ? $picturelist[$key]->pidlink : $picture->imageURL;
360
  // bad solution : for now we need the url always for the carousel, should be reworked in the future
361
  $picturelist[$key]->url = $picture->imageURL;
362
  // add a filter for the link
367
  $picturelist[$key]->caption = ( empty($picture->description) ) ? '&nbsp;' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) );
368
  $picturelist[$key]->description = ( empty($picture->description) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) );
369
  $picturelist[$key]->alttext = ( empty($picture->alttext) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) );
370
+
371
  // filter to add custom content for the output
372
  $picturelist[$key] = apply_filters('ngg_image_object', $picturelist[$key], $picture->pid);
373
 
374
  //check if $pid is in the array
375
+ if ($picture->pid == $pid)
376
  $current_pid = $picturelist[$key];
377
  }
378
  reset($picturelist);
379
 
380
  //for paged galleries, take the first image in the array if it's not in the list
381
  $current_pid = ( empty($current_pid) ) ? current( $picturelist ) : $current_pid;
382
+
383
  // look for gallery-$template.php or pure gallery.php
384
  $filename = ( empty($template) ) ? 'gallery' : 'gallery-' . $template;
385
+
386
  //filter functions for custom addons
387
  $gallery = apply_filters( 'ngg_gallery_object', $gallery, $galleryID );
388
  $picturelist = apply_filters( 'ngg_picturelist_object', $picturelist, $galleryID );
389
+
390
  //additional navigation links
391
  $next = ( empty($nggNav->next) ) ? false : $nggNav->next;
392
  $prev = ( empty($nggNav->prev) ) ? false : $nggNav->prev;
393
 
394
  // create the output
395
  $out = nggGallery::capture ( $filename, array ('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation, 'current' => $current_pid, 'next' => $next, 'prev' => $prev) );
396
+
397
  // apply a filter after the output
398
  $out = apply_filters('ngg_gallery_output', $out, $picturelist);
399
+
400
  return $out;
401
  }
402
 
403
  /**
404
  * nggShowAlbum() - return a album based on the id
405
+ *
406
+ * @access public
407
  * @param int | string $albumID
408
  * @param string (optional) $template
409
  * @param string (optional) $gallery_template
410
  * @return the content
411
  */
412
  function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
413
+
414
  // $_GET from wp_query
415
  $gallery = get_query_var('gallery');
416
  $album = get_query_var('album');
418
  // in the case somebody uses the '0', it should be 'all' to show all galleries
419
  $albumID = ($albumID == 0) ? 'all' : $albumID;
420
 
421
+ // first look for gallery variable
422
  if (!empty( $gallery )) {
423
+
424
  // subalbum support only one instance, you can't use more of them in one post
425
  //TODO: causes problems with SFC plugin, due to a second filter callback
426
  if ( isset($GLOBALS['subalbum']) || isset($GLOBALS['nggShowGallery']) )
427
  return;
428
+
429
+ // if gallery is submit , then show the gallery instead
430
  $out = nggShowGallery( $gallery, $gallery_template );
431
  $GLOBALS['nggShowGallery'] = true;
432
+
433
  return $out;
434
  }
435
+
436
  if ( (empty( $gallery )) && (isset($GLOBALS['subalbum'])) )
437
  return;
438
 
439
+ //redirect to subalbum only one time
440
  if (!empty( $album )) {
441
  $GLOBALS['subalbum'] = true;
442
+ $albumID = $album;
443
  }
444
 
445
  // lookup in the database
446
  $album = nggdb::find_album( $albumID );
447
 
448
  // still no success ? , die !
449
+ if( !$album )
450
  return __('[Album not found]','nggallery');
451
 
452
  // ensure to set the slug for "all" albums
453
  $album->slug = ($albumID == 'all') ? $album->id : $album->slug;
454
+
455
  if ( is_array($album->gallery_ids) )
456
  $out = nggCreateAlbum( $album->gallery_ids, $template, $album );
457
+
458
  $out = apply_filters( 'ngg_show_album_content', $out, $album->id );
459
 
460
  return $out;
462
 
463
  /**
464
  * create a gallery overview output
465
+ *
466
  * @access internal
467
  * @param array $galleriesID
468
  * @param string (optional) $template name for a template file, look for album-$template
472
  function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
473
 
474
  global $wpdb, $nggRewrite, $nggdb;
475
+
476
  // $_GET from wp_query
477
+ $nggpage = get_query_var('nggpage');
478
+
479
  $ngg_options = nggGallery::get_option('ngg_options');
480
+
481
  //this option can currently only set via the custom fields
482
  $maxElement = (int) $ngg_options['galPagedGalleries'];
483
 
484
  $sortorder = $galleriesID;
485
  $galleries = array();
486
+
487
+ // get the galleries information
488
  foreach ($galleriesID as $i => $value)
489
  $galleriesID[$i] = addslashes($value);
490
 
491
  $unsort_galleries = $wpdb->get_results('SELECT * FROM '.$wpdb->nggallery.' WHERE gid IN (\''.implode('\',\'', $galleriesID).'\')', OBJECT_K);
492
 
493
+ //TODO: Check this, problem exist when previewpic = 0
494
  //$galleries = $wpdb->get_results('SELECT t.*, tt.* FROM '.$wpdb->nggallery.' AS t INNER JOIN '.$wpdb->nggpictures.' AS tt ON t.previewpic = tt.pid WHERE t.gid IN (\''.implode('\',\'', $galleriesID).'\')', OBJECT_K);
495
 
496
+ // get the counter values
497
  $picturesCounter = $wpdb->get_results('SELECT galleryid, COUNT(*) as counter FROM '.$wpdb->nggpictures.' WHERE galleryid IN (\''.implode('\',\'', $galleriesID).'\') AND exclude != 1 GROUP BY galleryid', OBJECT_K);
498
  if ( is_array($picturesCounter) ) {
499
  foreach ($picturesCounter as $key => $value)
500
  $unsort_galleries[$key]->counter = $value->counter;
501
  }
502
+
503
  // get the id's of the preview images
504
  $imagesID = array();
505
  if ( is_array($unsort_galleries) ) {
506
  foreach ($unsort_galleries as $gallery_row)
507
  $imagesID[] = $gallery_row->previewpic;
508
+ }
509
  $albumPreview = $wpdb->get_results('SELECT pid, filename FROM '.$wpdb->nggpictures.' WHERE pid IN (\''.implode('\',\'', $imagesID).'\')', OBJECT_K);
510
 
511
+ // re-order them and populate some
512
  foreach ($sortorder as $key) {
513
+
514
  //if we have a prefix 'a' then it's a subalbum, instead a gallery
515
+ if (substr( $key, 0, 1) == 'a') {
516
  // get the album content
517
  if ( !$subalbum = $nggdb->find_album(substr( $key, 1)) )
518
  continue;
519
+
520
  //populate the sub album values
521
+ if (!isset($galleries[$key])) $galleries[$key] = new stdClass;
522
  $galleries[$key]->counter = 0;
523
  $galleries[$key]->previewurl = '';
524
  // ensure that album contain a preview image
526
  $image = $nggdb->find_image( $subalbum->previewpic );
527
  $galleries[$key]->previewurl = isset($image->thumbURL) ? $image->thumbURL : '';
528
  }
529
+
530
+ $galleries[$key]->previewpic = $subalbum->previewpic;
531
  $galleries[$key]->previewname = $subalbum->name;
532
+
533
  //link to the subalbum
534
  $args['album'] = ( $ngg_options['usePermalinks'] ) ? $subalbum->slug : $subalbum->id;
535
+ $args['gallery'] = false;
536
  $args['nggpage'] = false;
537
  $pageid = (isset($subalbum->pageid) ? $subalbum->pageid : 0);
538
  $galleries[$key]->pagelink = ($pageid > 0) ? get_permalink($pageid) : $nggRewrite->get_permalink($args);
539
  $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n($subalbum->albumdesc) );
540
+ $galleries[$key]->title = html_entity_decode ( nggGallery::i18n($subalbum->name) );
541
+
542
  // apply a filter on gallery object before the output
543
  $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
544
+
545
  continue;
546
  }
547
+
548
  // If a gallery is not found it should be ignored
549
  if (!$unsort_galleries[$key])
550
  continue;
551
+
552
  // No images found, set counter to 0
553
  if (!isset($galleries[$key]->counter)){
554
  $galleries[$key]->counter = 0;
555
  $galleries[$key]->previewurl = '';
556
  }
557
+
558
  // Add the counter value if avaible
559
  $galleries[$key] = $unsort_galleries[$key];
560
+
561
+ // add the file name and the link
562
  if ($galleries[$key]->previewpic != 0) {
563
  $galleries[$key]->previewname = $albumPreview[$galleries[$key]->previewpic]->filename;
564
  $galleries[$key]->previewurl = site_url().'/' . $galleries[$key]->path . '/thumbs/thumbs_' . $albumPreview[$galleries[$key]->previewpic]->filename;
567
  if (isset($first_image)) {
568
  $galleries[$key]->previewpic = $first_image->pid;
569
  $galleries[$key]->previewname = $first_image->filename;
570
+ $galleries[$key]->previewurl = site_url() . '/' . $galleries[$key]->path . '/thumbs/thumbs_' . $first_image->filename;
571
  }
572
  }
573
 
574
  // choose between variable and page link
575
  if ($ngg_options['galNoPages']) {
576
+ $args['album'] = ( $ngg_options['usePermalinks'] ) ? $album->slug : $album->id;
577
  $args['gallery'] = ( $ngg_options['usePermalinks'] ) ? $galleries[$key]->slug : $key;
578
  $args['nggpage'] = false;
579
  $galleries[$key]->pagelink = $nggRewrite->get_permalink($args);
580
+
581
  } else {
582
  $galleries[$key]->pagelink = get_permalink( $galleries[$key]->pageid );
583
  }
584
+
585
  // description can contain HTML tags
586
  $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->galdesc), 'gal_' . $galleries[$key]->gid . '_description') ) ;
587
 
588
  // i18n
589
  $galleries[$key]->title = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->title), 'gal_' . $galleries[$key]->gid . '_title') ) ;
590
+
591
  // apply a filter on gallery object before the output
592
  $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
593
  }
594
+
595
  // apply a filter on gallery object before paging starts
596
  $galleries = apply_filters('ngg_album_galleries_before_paging', $galleries, $album);
597
+
598
  // check for page navigation
599
  if ($maxElement > 0) {
600
  if ( !is_home() || $pageid == get_the_ID() ) {
601
  $page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
602
  }
603
  else $page = 1;
604
+
605
  $start = $offset = ( $page - 1 ) * $maxElement;
606
+
607
  $total = count($galleries);
608
+
609
  // remove the element if we didn't start at the beginning
610
  if ($start > 0 ) array_splice($galleries, 0, $start);
611
+
612
  // return the list of images we need
613
  array_splice($galleries, $maxElement);
614
+
615
+ $nggNav = new nggNavigation;
616
  $navigation = $nggNav->create_navigation($page, $total, $maxElement);
617
  } else {
618
  $navigation = '<div class="ngg-clear"></div>';
620
 
621
  // apply a filter on $galleries before the output
622
  $galleries = apply_filters('ngg_album_galleries', $galleries);
623
+
624
  // if sombody didn't enter any template , take the extend version
625
  $filename = ( empty($template) ) ? 'album-extend' : 'album-' . $template ;
626
 
628
  $out = nggGallery::capture ( $filename, array ('album' => $album, 'galleries' => $galleries, 'pagination' => $navigation) );
629
 
630
  return $out;
631
+
632
  }
633
 
634
  /**
635
  * nggShowImageBrowser()
636
+ *
637
+ * @access public
638
  * @param int|string $galleryID or gallery name
639
  * @param string $template (optional) name for a template file, look for imagebrowser-$template
640
  * @return the content
641
  */
642
  function nggShowImageBrowser($galleryID, $template = '') {
643
+
644
  global $wpdb;
645
+
646
  $ngg_options = nggGallery::get_option('ngg_options');
647
+
648
  //Set sort order value, if not used (upgrade issue)
649
  $ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
650
  $ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
651
+
652
  // get the pictures
653
  $picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
654
+
655
  if ( is_array($picturelist) )
656
  $out = nggCreateImageBrowser($picturelist, $template);
657
  else
658
  $out = __('[Gallery not found]','nggallery');
659
+
660
  $out = apply_filters('ngg_show_imagebrowser_content', $out, $galleryID);
661
+
662
  return $out;
663
+
664
  }
665
 
666
  /**
667
  * nggCreateImageBrowser()
668
+ *
669
  * @access internal
670
  * @param array $picturelist
671
  * @param string $template (optional) name for a template file, look for imagebrowser-$template
674
  function nggCreateImageBrowser($picturelist, $template = '') {
675
 
676
  global $nggRewrite, $ngg;
677
+
678
  require_once( dirname (__FILE__) . '/lib/meta.php' );
679
+
680
  // $_GET from wp_query
681
  $pid = get_query_var('pid');
682
+
683
  // we need to know the current page id
684
  $current_page = (get_the_ID() == false) ? 0 : get_the_ID();
685
+
686
  // create a array with id's for better walk inside
687
  foreach ($picturelist as $picture)
688
  $picarray[] = $picture->pid;
690
  $total = count($picarray);
691
 
692
  if ( !empty( $pid )) {
693
+ if ( is_numeric($pid) )
694
  $act_pid = intval($pid);
695
  else {
696
  // in the case it's a slug we need to search for the pid
699
  $act_pid = $key;
700
  break;
701
  }
702
+ }
703
  }
704
  } else {
705
  reset($picarray);
706
  $act_pid = current($picarray);
707
  }
708
+
709
  // get ids for back/next
710
  $key = array_search($act_pid, $picarray);
711
  if (!$key) {
714
  }
715
  $back_pid = ( $key >= 1 ) ? $picarray[$key-1] : end($picarray) ;
716
  $next_pid = ( $key < ($total-1) ) ? $picarray[$key+1] : reset($picarray) ;
717
+
718
  // get the picture data
719
  $picture = nggdb::find_image($act_pid);
720
+
721
  // if we didn't get some data, exit now
722
  if ($picture == null)
723
  return;
724
+
725
  // add more variables for render output
726
  $picture->href_link = $picture->get_href_link();
727
  $args ['pid'] = ($ngg->options['usePermalinks']) ? $picturelist[$back_pid]->image_slug : $back_pid;
736
  $picture->alttext = ( empty($picture->alttext) ) ? ' ' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) );
737
  $picture->description = ( empty($picture->description) ) ? ' ' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) );
738
  $picture->anchor = 'ngg-imagebrowser-' . $picture->galleryid . '-' . $current_page;
739
+
740
  // filter to add custom content for the output
741
  $picture = apply_filters('ngg_image_object', $picture, $act_pid);
742
+
743
  // let's get the meta data
744
  $meta = new nggMeta($act_pid);
745
  $meta->sanitize();
747
  $iptc = $meta->get_IPTC();
748
  $xmp = $meta->get_XMP();
749
  $db = $meta->get_saved_meta();
750
+
751
+ //if we get no exif information we try the database
752
  $exif = ($exif == false) ? $db : $exif;
753
+
754
  // look for imagebrowser-$template.php or pure imagebrowser.php
755
  $filename = ( empty($template) ) ? 'imagebrowser' : 'imagebrowser-' . $template;
756
 
757
  // create the output
758
  $out = nggGallery::capture ( $filename , array ('image' => $picture , 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db) );
759
+
760
  return $out;
761
+
762
  }
763
 
764
  /**
765
  * nggSinglePicture() - show a single picture based on the id
766
+ *
767
+ * @access public
768
  * @param int $imageID, db-ID of the image
769
  * @param int (optional) $width, width of the image
770
  * @param int (optional) $height, height of the image
777
  */
778
  function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '' , $template = '', $caption = '', $link = '') {
779
  global $post;
780
+
781
  $ngg_options = nggGallery::get_option('ngg_options');
782
+
783
  // get picturedata
784
  $picture = nggdb::find_image($imageID);
785
+
786
  // if we didn't get some data, exit now
787
  if ($picture == null)
788
  return __('[SinglePic not found]','nggallery');
789
+
790
  // add float to img
791
  switch ($float) {
792
+
793
+ case 'left':
794
  $float =' ngg-left';
795
  break;
796
+
797
+ case 'right':
798
  $float =' ngg-right';
799
  break;
800
 
801
+ case 'center':
802
  $float =' ngg-center';
803
  break;
804
+
805
+ default:
806
  $float ='';
807
  break;
808
  }
809
+
810
+ // clean mode if needed
811
  $mode = ( preg_match('/(web20|watermark)/i', $mode) ) ? $mode : '';
812
+
813
  //let's initiate the url
814
  $picture->thumbnailURL = false;
815
 
816
  // check fo cached picture
817
  if ( $post->post_status == 'publish' )
818
  $picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode );
819
+
820
+ // if we didn't use a cached image then we take the on-the-fly mode
821
+ if (!$picture->thumbnailURL)
822
  $picture->thumbnailURL = trailingslashit( home_url() ) . 'index.php?callback=image&amp;pid=' . $imageID . '&amp;width=' . $width . '&amp;height=' . $height . '&amp;mode=' . $mode;
823
 
824
  // add more variables for render output
843
  $iptc = $meta->get_IPTC();
844
  $xmp = $meta->get_XMP();
845
  $db = $meta->get_saved_meta();
846
+
847
+ //if we get no exif information we try the database
848
  $exif = ($exif == false) ? $db : $exif;
849
+
850
  // look for singlepic-$template.php or pure singlepic.php
851
  $filename = ( empty($template) ) ? 'singlepic' : 'singlepic-' . $template;
852
 
854
  $out = nggGallery::capture ( $filename, array ('image' => $picture , 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp, 'db' => $db) );
855
 
856
  $out = apply_filters('ngg_show_singlepic_content', $out, $picture );
857
+
858
  return $out;
859
  }
860
 
861
  /**
862
  * nggShowGalleryTags() - create a gallery based on the tags
863
+ *
864
+ * @access public
865
  * @param string $taglist list of tags as csv
866
  * @return the content
867
  */
868
+ function nggShowGalleryTags($taglist) {
869
 
870
  // $_GET from wp_query
871
  $pid = get_query_var('pid');
872
  $pageid = get_query_var('pageid');
873
+
874
  // get now the related images
875
  $picturelist = nggTags::find_images_for_tags($taglist , 'ASC');
876
 
877
  // look for ImageBrowser if we have a $_GET('pid')
878
+ if ( $pageid == get_the_ID() || !is_home() )
879
  if (!empty( $pid )) {
880
  $out = nggCreateImageBrowser( $picturelist );
881
  return $out;
884
  // go on if not empty
885
  if ( empty($picturelist) )
886
  return;
887
+
888
  // show gallery
889
  if ( is_array($picturelist) )
890
  $out = nggCreateGallery($picturelist, false);
891
+
892
  $out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist);
893
  return $out;
894
  }
895
 
896
  /**
897
  * nggShowRelatedGallery() - create a gallery based on the tags
898
+ *
899
+ * @access public
900
  * @param string $taglist list of tags as csv
901
  * @param integer $maxImages (optional) limit the number of images to show
902
  * @return the content
903
+ */
904
  function nggShowRelatedGallery($taglist, $maxImages = 0) {
905
+
906
  $ngg_options = nggGallery::get_option('ngg_options');
907
+
908
  // get now the related images
909
  $picturelist = nggTags::find_images_for_tags($taglist, 'RAND');
910
 
911
  // go on if not empty
912
  if ( empty($picturelist) )
913
  return;
914
+
915
  // cut the list to maxImages
916
  if ( $maxImages > 0 )
917
  array_splice($picturelist, $maxImages);
928
  $out .= '</a>' . "\n";
929
  }
930
  $out .= '</div>' . "\n";
931
+
932
  $out = apply_filters('ngg_show_related_gallery_content', $out, $taglist);
933
+
934
  return $out;
935
  }
936
 
937
  /**
938
  * nggShowAlbumTags() - create a gallery based on the tags
939
+ *
940
+ * @access public
941
  * @param string $taglist list of tags as csv
942
  * @return the content
943
  */
944
  function nggShowAlbumTags($taglist) {
945
+
946
  global $wpdb, $nggRewrite;
947
 
948
  // $_GET from wp_query
949
  $tag = get_query_var('gallerytag');
950
  $pageid = get_query_var('pageid');
951
+
952
+ // look for gallerytag variable
953
  if ( $pageid == get_the_ID() || !is_home() ) {
954
  if (!empty( $tag )) {
955
+
956
  // avoid this evil code $sql = 'SELECT name FROM wp_ngg_tags WHERE slug = \'slug\' union select concat(0x7c,user_login,0x7c,user_pass,0x7c) from wp_users WHERE 1 = 1';
957
  $slug = esc_attr( $tag );
958
  $tagname = $wpdb->get_var( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE slug = %s", $slug ) );
959
  $out = '<div id="albumnav"><span><a href="' . get_permalink() . '" title="' . __('Overview', 'nggallery') .' ">'.__('Overview', 'nggallery').'</a> | '.$tagname.'</span></div>';
960
  $out .= nggShowGalleryTags($slug);
961
  return $out;
962
+
963
+ }
964
  }
965
+
966
  // get now the related images
967
  $picturelist = nggTags::get_album_images($taglist);
968
 
969
  // go on if not empty
970
  if ( empty($picturelist) )
971
  return;
972
+
973
+ // re-structure the object that we can use the standard template
974
  foreach ($picturelist as $key => $picture) {
975
  $picturelist[$key]->previewpic = $picture->pid;
976
  $picturelist[$key]->previewname = $picture->filename;
979
  $picturelist[$key]->title = $picture->name;
980
  $picturelist[$key]->pagelink = $nggRewrite->get_permalink( array('gallerytag'=>$picture->slug) );
981
  }
982
+
983
  //TODO: Add pagination later
984
  $navigation = '<div class="ngg-clear"></div>';
985
+
986
  // create the output
987
  $out = nggGallery::capture ('album-compact', array ('album' => 0, 'galleries' => $picturelist, 'pagination' => $navigation) );
988
+
989
  $out = apply_filters('ngg_show_album_tags_content', $out, $taglist);
990
+
991
  return $out;
992
  }
993
 
994
  /**
995
  * nggShowRelatedImages() - return related images based on category or tags
996
+ *
997
+ * @access public
998
  * @param string $type could be 'tags' or 'category'
999
  * @param integer $maxImages of images
1000
  * @return the content
1011
 
1012
  switch ($type) {
1013
  case 'tags':
1014
+ if (function_exists('get_the_tags')) {
1015
  $taglist = get_the_tags();
1016
+
1017
  if (is_array($taglist)) {
1018
  foreach ($taglist as $tag) {
1019
  $sluglist[] = $tag->slug;
1021
  }
1022
  }
1023
  break;
1024
+
1025
  case 'category':
1026
  $catlist = get_the_category();
1027
+
1028
  if (is_array($catlist)) {
1029
  foreach ($catlist as $cat) {
1030
  $sluglist[] = $cat->category_nicename;
1032
  }
1033
  break;
1034
  }
1035
+
1036
  $sluglist = implode(',', $sluglist);
1037
  $out = nggShowRelatedGallery($sluglist, $maxImages);
1038
+
1039
  return $out;
1040
  }
1041
 
1042
  /**
1043
  * Template function for theme authors
1044
  *
1045
+ * @access public
1046
  * @param string (optional) $type could be 'tags' or 'category'
1047
  * @param integer (optional) $maxNumbers of images
1048
  * @return void
1053
 
1054
  /**
1055
  * nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images
1056
+ *
1057
  * @access public
1058
  * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random'
1059
  * @param integer $maxImages of images
1062
  * @return the content
1063
  */
1064
  function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0) {
1065
+
1066
  // $_GET from wp_query
1067
  $pid = get_query_var('pid');
1068
  $pageid = get_query_var('pageid');
1069
+
1070
  // get now the recent or random images
1071
  switch ($type) {
1072
  case 'random':
1087
  }
1088
 
1089
  // look for ImageBrowser if we have a $_GET('pid')
1090
+ if ( $pageid == get_the_ID() || !is_home() )
1091
  if (!empty( $pid )) {
1092
  $out = nggCreateImageBrowser( $picturelist );
1093
  return $out;
1096
  // go on if not empty
1097
  if ( empty($picturelist) )
1098
  return;
1099
+
1100
  // show gallery
1101
  if ( is_array($picturelist) )
1102
  $out = nggCreateGallery($picturelist, false, $template);
1103
 
1104
  $out = apply_filters('ngg_show_images_content', $out, $picturelist);
1105
+
1106
  return $out;
1107
  }
1108
 
1109
  /**
1110
  * nggTagCloud() - return a tag cloud based on the wp core tag cloud system
1111
+ *
1112
  * @param array $args
1113
  * @param string $template (optional) name for a template file, look for gallery-$template
1114
  * @return the content
1119
  // $_GET from wp_query
1120
  $tag = get_query_var('gallerytag');
1121
  $pageid = get_query_var('pageid');
1122
+
1123
+ // look for gallerytag variable
1124
  if ( $pageid == get_the_ID() || !is_home() ) {
1125
  if (!empty( $tag )) {
1126
+
1127
  $slug = esc_attr( $tag );
1128
  $out = nggShowGalleryTags( $slug );
1129
  return $out;
1130
+ }
1131
  }
1132
+
1133
  $defaults = array(
1134
  'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
1135
  'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
1144
  $tags[ $key ]->link = $nggRewrite->get_permalink(array ('gallerytag' => $tag->slug));
1145
  $tags[ $key ]->id = $tag->term_id;
1146
  }
1147
+
1148
  $out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud( $tags, $args ) . '</div>';
1149
+
1150
  return $out;
1151
  }
1152
  ?>
readme.txt CHANGED
@@ -10,9 +10,9 @@ The most popular WordPress gallery plugin with tons of features and over 6 milli
10
 
11
  == Description ==
12
 
13
- NextGEN Gallery is the most popular **WordPress gallery plugin**, and one of the most popular WordPress plugins of any kind, with over 6 million downloads.
14
 
15
- It provides a powerful engine for uploading and managing galleries of images, with the ability to batch upload, import meta data, add/delete/rearrange/sort images, edit thumbnails, group galleries into albums, and more. It also provides two front-end display styles (slideshows and thumbnail galleries), both of which come with a wide array of options for controlling size, style, timing, transitions, controls, lightbox effects, and more.
16
 
17
  *The NextGEN Gallery WordPress plugin is now proudly maintained by <a href='http://www.photocrati.com'>Photocrati Media</a>. Special thanks to Alex Rabe who created and maintained NextGEN from 2007 through 2011.*
18
 
@@ -70,7 +70,7 @@ You should have received a copy of the GNU General Public License along with thi
70
 
71
  ** Please note **
72
 
73
- The JW Image Rotator (Flash Slideshow) is not part of this license and is available under a Creative Commons License, which allowing you to use, modify and redistribute them for noncommercial purposes.
74
 
75
  For commercial use please look at the Jeroen's homepage : http://www.longtailvideo.com/
76
 
@@ -88,7 +88,7 @@ http://www.youtube.com/watch?v=Le_ZsNSuIvM
88
 
89
  == Screenshots ==
90
 
91
- 1. Screenshot Admin Area
92
  2. Screenshot Album Selection
93
  3. Screenshot Shutter Effect
94
  4. Screenshot Watermark function
@@ -133,32 +133,32 @@ http://www.youtube.com/watch?v=Le_ZsNSuIvM
133
 
134
  Part of what makes NextGEN so popular is its flexibility - it works with the vast majority of premium and free themes, without requiring any coding.
135
 
136
-
137
  = Are the galleries flash based? =
138
 
139
  No, NextGEN Gallery uses Javascript (J-Query) based displays to ensure compatibility across the widest range of displays possible.
140
-
141
 
142
  = Are the galleries mobile friendly? =
143
 
144
  Yes, since we use Javascript rather than flash, NextGEN Gallery is compatible with Android, iOS, and Blackberry.
145
 
146
-
147
  = What is the difference between a gallery and an album? =
148
 
149
  In the simplest of terms, Galleries contain your images and Albums contain your Galleries. Albums act as links and placeholders to quickly and easily navigate your galleries - Galleries will actually display your images.
150
 
151
-
152
  = Can I upload multiple images at once? =
153
 
154
  Yes, you can batch upload entire galleries at a time.
155
 
156
-
157
  = Can I password protect galleries? =
158
 
159
  Yes, Wordpress allows you to password protect pages by default - which includes all galleries and content for the entire page. Password protection of pages can be turned on and off at any time, with just a few clicks.
160
 
161
-
162
  = Can I add a watermark to the images/slideshows? =
163
 
164
  Yes, you can add text or image watermarks to your gallery images.
@@ -168,22 +168,22 @@ Yes, you can add text or image watermarks to your gallery images.
168
 
169
  Yes, each thumbnail image can be individually adjusted to suit your needs.
170
 
171
-
172
  = Is there pagination for galleries? =
173
 
174
  Yes, and you can adjust the amount of images to be shown on a page at any time.
175
 
176
-
177
  = Can I customize the lightbox? =
178
 
179
  Yes, the lightbox can be configured with multiple options directly from the Dashboard, and there are multiple CSS styles which can be applied and modified as well.
180
 
181
-
182
  = Can I add HTML to the captions? =
183
 
184
  Yes, caption areas are fully HMTL capable.
185
 
186
-
187
  = Can I add an external links to galleries? =
188
 
189
  Since the captions are fully HTML capable, you can add external links and any other type of mark up you wish.
@@ -192,9 +192,16 @@ Since the captions are fully HTML capable, you can add external links and any ot
192
 
193
  Yes, NextGEN Gallery has been translated into dozens of languages - <a href="http://www.nextgen-gallery.com/languages/" target="_blank">click here to find out more.</a>
194
 
195
- == Changelog ==
 
 
 
 
 
 
 
 
196
 
197
- = V1.9.9 - 12.14.2012 =
198
  * NEW: JW ImageRotator v3.17 is now bundled with the plugin and used by default.
199
  * Changed: Removed database upgrade code for versions of NextGEN Gallery earlier than 1.9.3
200
  * Fixed: Compatibility with WordPress v3.5 ( wpdb->prepare() warnings )
@@ -250,10 +257,10 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
250
  * Bugfix : Security hardness for untrusted filenames/meta data (THX to Brian St. Pierre)
251
  * Bugfix : Fixed security vulnerability (TXH to Jon Cave)
252
  * Bugfix : Load piclens script via other function
253
- * Bugfix : IE7 script fix for add gallery
254
  * Bugfix : IE7/IE8 width set correctly for edit album autocomplete field
255
 
256
- = V1.9.0 - 27.11.2011 =
257
  * NEW : Keep images transparency for PNG and GIF format
258
  * NEW : Switch to Plupload, support now HTML5 Upload (only with WordPress 3.3)
259
  * NEW : Added client side resize feature (only with WordPress 3.3)
@@ -274,7 +281,7 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
274
 
275
  = V1.8.3 - 07.08.2011 =
276
  * Changed : Support for simple custom permalink structures (i.e. /%category%/%postname%/)
277
- * Bugfix : Sub-Albums in Albums didn't create the correct link
278
  * Bugfix : AJAX Pagination didn't work anymore
279
  * Bugfix : Adding index.php to home_url()
280
  * Bugfix : Preview picture lost on backend gallery page 2 or higher
@@ -297,7 +304,7 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
297
  * NEW : Adding sort operation for galleries overview page
298
  * Changed : Updated pagination to new WP3.1 style
299
  * Bugfix : Create unique slug in a better way
300
- * Bugfix : Rework screen options filter for gallery and image table
301
  * Bugfix : Empty values in XMLRPC update calls are ignored
302
  * Bugfix : Create gallery failed when safe-mode on
303
  * Bugfix : Permalink didn't work in combination with album & imagebrowser
@@ -357,7 +364,7 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
357
 
358
  = V1.6.0 - 07.09.2010 =
359
  * NEW : Wordpress 3.0 Network (Multi-Site) support
360
- * NEW : Integrate jQuery Cycle as NON-Flash slideshow
361
  * NEW : Adding jQuery File Tree for import folder (THX to Sergey Pasyuk )
362
  * NEW : Added action hook 'ngg_show_imagebrowser_first' on custom request
363
  * NEW : Added filter hook 'ngg_slideshow_size' to resize sildeshow for mobile browser plugins
@@ -385,11 +392,11 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
385
  * Changed : Perpare new filter to replace slideshow
386
  * Bugfix : Remove non-breaking space from navigation
387
  * Bugfix : Pagination of galleries
388
- * Bugfix : Fixed brackets position for old shortcode query
389
- * Bugfix : Slideshow option 'Show next image on click" has wrong default value
390
 
391
  = V1.5.2 - 25.03.2010 =
392
- * Bugfix : XSS security vulnerability (THX to Core Security Advisories Team , Pedro Varangot)
393
  * Bugfix : Missing $wpdb in shortcodes.php
394
 
395
  = V1.5.1 - 23.03.2010 =
@@ -406,7 +413,7 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
406
  * NEW : Auto downloader for translation file
407
  * Changed : Rename query var from slideshow to callback for compat reason with other plugin
408
  * Changed : Convert widget function to new WP structure
409
- * Changed : Include lookup for tags into the backend search
410
  * Changed : Restructure addgallery and settings page to enable custom tabs
411
  * Bugfix : Select album preview from gallery preview pics instead random list
412
  * Bugfix : Keep fix dimension in edit thumbnail operation
10
 
11
  == Description ==
12
 
13
+ NextGEN Gallery is the most popular **WordPress gallery plugin**, and one of the most popular WordPress plugins of any kind, with over 6 million downloads.
14
 
15
+ It provides a powerful engine for uploading and managing galleries of images, with the ability to batch upload, import meta data, add/delete/rearrange/sort images, edit thumbnails, group galleries into albums, and more. It also provides two front-end display styles (slideshows and thumbnail galleries), both of which come with a wide array of options for controlling size, style, timing, transitions, controls, lightbox effects, and more.
16
 
17
  *The NextGEN Gallery WordPress plugin is now proudly maintained by <a href='http://www.photocrati.com'>Photocrati Media</a>. Special thanks to Alex Rabe who created and maintained NextGEN from 2007 through 2011.*
18
 
70
 
71
  ** Please note **
72
 
73
+ The JW Image Rotator (Flash Slideshow) is not part of this license and is available under a Creative Commons License, which allowing you to use, modify and redistribute them for noncommercial purposes.
74
 
75
  For commercial use please look at the Jeroen's homepage : http://www.longtailvideo.com/
76
 
88
 
89
  == Screenshots ==
90
 
91
+ 1. Screenshot Admin Area
92
  2. Screenshot Album Selection
93
  3. Screenshot Shutter Effect
94
  4. Screenshot Watermark function
133
 
134
  Part of what makes NextGEN so popular is its flexibility - it works with the vast majority of premium and free themes, without requiring any coding.
135
 
136
+
137
  = Are the galleries flash based? =
138
 
139
  No, NextGEN Gallery uses Javascript (J-Query) based displays to ensure compatibility across the widest range of displays possible.
140
+
141
 
142
  = Are the galleries mobile friendly? =
143
 
144
  Yes, since we use Javascript rather than flash, NextGEN Gallery is compatible with Android, iOS, and Blackberry.
145
 
146
+
147
  = What is the difference between a gallery and an album? =
148
 
149
  In the simplest of terms, Galleries contain your images and Albums contain your Galleries. Albums act as links and placeholders to quickly and easily navigate your galleries - Galleries will actually display your images.
150
 
151
+
152
  = Can I upload multiple images at once? =
153
 
154
  Yes, you can batch upload entire galleries at a time.
155
 
156
+
157
  = Can I password protect galleries? =
158
 
159
  Yes, Wordpress allows you to password protect pages by default - which includes all galleries and content for the entire page. Password protection of pages can be turned on and off at any time, with just a few clicks.
160
 
161
+
162
  = Can I add a watermark to the images/slideshows? =
163
 
164
  Yes, you can add text or image watermarks to your gallery images.
168
 
169
  Yes, each thumbnail image can be individually adjusted to suit your needs.
170
 
171
+
172
  = Is there pagination for galleries? =
173
 
174
  Yes, and you can adjust the amount of images to be shown on a page at any time.
175
 
176
+
177
  = Can I customize the lightbox? =
178
 
179
  Yes, the lightbox can be configured with multiple options directly from the Dashboard, and there are multiple CSS styles which can be applied and modified as well.
180
 
181
+
182
  = Can I add HTML to the captions? =
183
 
184
  Yes, caption areas are fully HMTL capable.
185
 
186
+
187
  = Can I add an external links to galleries? =
188
 
189
  Since the captions are fully HTML capable, you can add external links and any other type of mark up you wish.
192
 
193
  Yes, NextGEN Gallery has been translated into dozens of languages - <a href="http://www.nextgen-gallery.com/languages/" target="_blank">click here to find out more.</a>
194
 
195
+ == Changelog ==
196
+
197
+ = V1.9.10 - 12.18.2012 =
198
+ * Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
199
+ * Fixed: Restored compatibility with NextGEN Gallery Export Plugin
200
+ * Fixed: Removed some remaining references to database upgrade code
201
+ * Fixed: Deleted galleries within an album are handed gracefully without warning messages
202
+ * Fixed: Correct use of register_uninstall_hook
203
+ * Fixed: CSS and usability issues with the TinyMCE window used to display galleries
204
 
 
205
  * NEW: JW ImageRotator v3.17 is now bundled with the plugin and used by default.
206
  * Changed: Removed database upgrade code for versions of NextGEN Gallery earlier than 1.9.3
207
  * Fixed: Compatibility with WordPress v3.5 ( wpdb->prepare() warnings )
257
  * Bugfix : Security hardness for untrusted filenames/meta data (THX to Brian St. Pierre)
258
  * Bugfix : Fixed security vulnerability (TXH to Jon Cave)
259
  * Bugfix : Load piclens script via other function
260
+ * Bugfix : IE7 script fix for add gallery
261
  * Bugfix : IE7/IE8 width set correctly for edit album autocomplete field
262
 
263
+ = V1.9.0 - 27.11.2011 =
264
  * NEW : Keep images transparency for PNG and GIF format
265
  * NEW : Switch to Plupload, support now HTML5 Upload (only with WordPress 3.3)
266
  * NEW : Added client side resize feature (only with WordPress 3.3)
281
 
282
  = V1.8.3 - 07.08.2011 =
283
  * Changed : Support for simple custom permalink structures (i.e. /%category%/%postname%/)
284
+ * Bugfix : Sub-Albums in Albums didn't create the correct link
285
  * Bugfix : AJAX Pagination didn't work anymore
286
  * Bugfix : Adding index.php to home_url()
287
  * Bugfix : Preview picture lost on backend gallery page 2 or higher
304
  * NEW : Adding sort operation for galleries overview page
305
  * Changed : Updated pagination to new WP3.1 style
306
  * Bugfix : Create unique slug in a better way
307
+ * Bugfix : Rework screen options filter for gallery and image table
308
  * Bugfix : Empty values in XMLRPC update calls are ignored
309
  * Bugfix : Create gallery failed when safe-mode on
310
  * Bugfix : Permalink didn't work in combination with album & imagebrowser
364
 
365
  = V1.6.0 - 07.09.2010 =
366
  * NEW : Wordpress 3.0 Network (Multi-Site) support
367
+ * NEW : Integrate jQuery Cycle as NON-Flash slideshow
368
  * NEW : Adding jQuery File Tree for import folder (THX to Sergey Pasyuk )
369
  * NEW : Added action hook 'ngg_show_imagebrowser_first' on custom request
370
  * NEW : Added filter hook 'ngg_slideshow_size' to resize sildeshow for mobile browser plugins
392
  * Changed : Perpare new filter to replace slideshow
393
  * Bugfix : Remove non-breaking space from navigation
394
  * Bugfix : Pagination of galleries
395
+ * Bugfix : Fixed brackets position for old shortcode query
396
+ * Bugfix : Slideshow option 'Show next image on click" has wrong default value
397
 
398
  = V1.5.2 - 25.03.2010 =
399
+ * Bugfix : XSS security vulnerability (THX to Core Security Advisories Team , Pedro Varangot)
400
  * Bugfix : Missing $wpdb in shortcodes.php
401
 
402
  = V1.5.1 - 23.03.2010 =
413
  * NEW : Auto downloader for translation file
414
  * Changed : Rename query var from slideshow to callback for compat reason with other plugin
415
  * Changed : Convert widget function to new WP structure
416
+ * Changed : Include lookup for tags into the backend search
417
  * Changed : Restructure addgallery and settings page to enable custom tabs
418
  * Bugfix : Select album preview from gallery preview pics instead random list
419
  * Bugfix : Keep fix dimension in edit thumbnail operation