Version Description
- 12.14.2012 =
- 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 | NextGEN Gallery – WordPress Gallery Plugin |
Version | 1.9.9 |
Comparing to | |
See all releases |
Code changes from version 1.9.8 to 1.9.9
- admin/addgallery.php +0 -1
- admin/install.php +42 -42
- admin/pointer.php +0 -98
- admin/settings.php +9 -7
- admin/upgrade.php +38 -235
- changelog.txt +6 -0
- imagerotator.swf +0 -0
- lib/ngg-db.php +260 -260
- lib/tags.php +58 -58
- nggallery.php +8 -45
- readme.txt +6 -0
admin/addgallery.php
CHANGED
@@ -498,7 +498,6 @@ class nggAddGallery {
|
|
498 |
<div id='uploadQueue'></div>
|
499 |
<p><label><input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
|
500 |
<?php printf( __( 'Scale images to max width %1$dpx or max height %2$dpx', 'nggallery' ), (int) $ngg->options['imgWidth' ], (int) $ngg->options[ 'imgHeight' ] ); ?>
|
501 |
-
<div id='image_resize_pointer'> </div>
|
502 |
</label>
|
503 |
</p>
|
504 |
|
498 |
<div id='uploadQueue'></div>
|
499 |
<p><label><input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
|
500 |
<?php printf( __( 'Scale images to max width %1$dpx or max height %2$dpx', 'nggallery' ), (int) $ngg->options['imgWidth' ], (int) $ngg->options[ 'imgHeight' ] ); ?>
|
|
|
501 |
</label>
|
502 |
</p>
|
503 |
|
admin/install.php
CHANGED
@@ -4,18 +4,18 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
|
|
4 |
/**
|
5 |
* creates all tables for the gallery
|
6 |
* called during register_activation hook
|
7 |
-
*
|
8 |
* @access internal
|
9 |
* @return void
|
10 |
*/
|
11 |
function nggallery_install () {
|
12 |
-
|
13 |
global $wpdb , $wp_roles, $wp_version;
|
14 |
-
|
15 |
// Check for capability
|
16 |
-
if ( !current_user_can('activate_plugins') )
|
17 |
return;
|
18 |
-
|
19 |
// Set the capabilities for the administrator
|
20 |
$role = get_role('administrator');
|
21 |
// We need this role, no other chance
|
@@ -23,7 +23,7 @@ function nggallery_install () {
|
|
23 |
update_option( "ngg_init_check", __('Sorry, NextGEN Gallery works only with a role called administrator',"nggallery") );
|
24 |
return;
|
25 |
}
|
26 |
-
|
27 |
$role->add_cap('NextGEN Gallery overview');
|
28 |
$role->add_cap('NextGEN Use TinyMCE');
|
29 |
$role->add_cap('NextGEN Upload images');
|
@@ -33,10 +33,10 @@ function nggallery_install () {
|
|
33 |
$role->add_cap('NextGEN Edit album');
|
34 |
$role->add_cap('NextGEN Change style');
|
35 |
$role->add_cap('NextGEN Change options');
|
36 |
-
|
37 |
-
// upgrade function changed in WordPress 2.3
|
38 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
39 |
-
|
40 |
// add charset & collate like wp core
|
41 |
$charset_collate = '';
|
42 |
|
@@ -46,14 +46,14 @@ function nggallery_install () {
|
|
46 |
if ( ! empty($wpdb->collate) )
|
47 |
$charset_collate .= " COLLATE $wpdb->collate";
|
48 |
}
|
49 |
-
|
50 |
$nggpictures = $wpdb->prefix . 'ngg_pictures';
|
51 |
$nggallery = $wpdb->prefix . 'ngg_gallery';
|
52 |
$nggalbum = $wpdb->prefix . 'ngg_album';
|
53 |
|
54 |
// could be case senstive : http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html
|
55 |
if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggpictures'" ) ) {
|
56 |
-
|
57 |
$sql = "CREATE TABLE " . $nggpictures . " (
|
58 |
pid BIGINT(20) NOT NULL AUTO_INCREMENT ,
|
59 |
image_slug VARCHAR(255) NOT NULL ,
|
@@ -69,12 +69,12 @@ function nggallery_install () {
|
|
69 |
PRIMARY KEY pid (pid),
|
70 |
KEY post_id (post_id)
|
71 |
) $charset_collate;";
|
72 |
-
|
73 |
dbDelta($sql);
|
74 |
}
|
75 |
|
76 |
if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggallery'" )) {
|
77 |
-
|
78 |
$sql = "CREATE TABLE " . $nggallery . " (
|
79 |
gid BIGINT(20) NOT NULL AUTO_INCREMENT ,
|
80 |
name VARCHAR(255) NOT NULL ,
|
@@ -87,12 +87,12 @@ function nggallery_install () {
|
|
87 |
author BIGINT(20) DEFAULT '0' NOT NULL ,
|
88 |
PRIMARY KEY gid (gid)
|
89 |
) $charset_collate;";
|
90 |
-
|
91 |
dbDelta($sql);
|
92 |
}
|
93 |
-
|
94 |
if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggalbum'" )) {
|
95 |
-
|
96 |
$sql = "CREATE TABLE " . $nggalbum . " (
|
97 |
id BIGINT(20) NOT NULL AUTO_INCREMENT ,
|
98 |
name VARCHAR(255) NOT NULL ,
|
@@ -103,7 +103,7 @@ function nggallery_install () {
|
|
103 |
pageid BIGINT(20) DEFAULT '0' NOT NULL,
|
104 |
PRIMARY KEY id (id)
|
105 |
) $charset_collate;";
|
106 |
-
|
107 |
dbDelta($sql);
|
108 |
}
|
109 |
|
@@ -112,12 +112,12 @@ function nggallery_install () {
|
|
112 |
update_option( "ngg_init_check", __('NextGEN Gallery : Tables could not created, please check your database settings',"nggallery") );
|
113 |
return;
|
114 |
}
|
115 |
-
|
116 |
$options = get_option('ngg_options');
|
117 |
// set the default settings, if we didn't upgrade
|
118 |
-
if ( empty( $options ) )
|
119 |
ngg_default_options();
|
120 |
-
|
121 |
// if all is passed , save the DBVERSION
|
122 |
add_option("ngg_db_version", NGG_DBVERSION);
|
123 |
|
@@ -125,13 +125,13 @@ function nggallery_install () {
|
|
125 |
|
126 |
/**
|
127 |
* Setup the default option array for the gallery
|
128 |
-
*
|
129 |
* @access internal
|
130 |
-
* @since version 0.33
|
131 |
* @return void
|
132 |
*/
|
133 |
function ngg_default_options() {
|
134 |
-
|
135 |
global $blog_id, $ngg;
|
136 |
|
137 |
$ngg_options['gallerypath'] = 'wp-content/gallery/'; // set default path to the gallery
|
@@ -143,25 +143,25 @@ function ngg_default_options() {
|
|
143 |
$ngg_options['imageMagickDir'] = '/usr/local/bin/'; // default path to ImageMagick
|
144 |
$ngg_options['useMediaRSS'] = false; // activate the global Media RSS file
|
145 |
$ngg_options['usePicLens'] = false; // activate the PicLens Link for galleries
|
146 |
-
|
147 |
// Tags / categories
|
148 |
$ngg_options['activateTags'] = false; // append related images
|
149 |
$ngg_options['appendType'] = 'tags'; // look for category or tags
|
150 |
$ngg_options['maxImages'] = 7; // number of images toshow
|
151 |
-
|
152 |
// Thumbnail Settings
|
153 |
$ngg_options['thumbwidth'] = 100; // Thumb Width
|
154 |
$ngg_options['thumbheight'] = 75; // Thumb height
|
155 |
$ngg_options['thumbfix'] = true; // Fix the dimension
|
156 |
$ngg_options['thumbquality'] = 100; // Thumb Quality
|
157 |
-
|
158 |
// Image Settings
|
159 |
$ngg_options['imgWidth'] = 800; // Image Width
|
160 |
$ngg_options['imgHeight'] = 600; // Image height
|
161 |
$ngg_options['imgQuality'] = 85; // Image Quality
|
162 |
$ngg_options['imgBackup'] = true; // Create a backup
|
163 |
$ngg_options['imgAutoResize'] = false; // Resize after upload
|
164 |
-
|
165 |
// Gallery Settings
|
166 |
$ngg_options['galImages'] = '20'; // Number of images per page
|
167 |
$ngg_options['galPagedGalleries'] = 0; // Number of galleries per page (in a album)
|
@@ -179,7 +179,7 @@ function ngg_default_options() {
|
|
179 |
|
180 |
// Thumbnail Effect
|
181 |
$ngg_options['thumbEffect'] = 'shutter'; // select effect
|
182 |
-
$ngg_options['thumbCode'] = 'class="shutterset_%GALLERY_NAME%"';
|
183 |
|
184 |
// Watermark settings
|
185 |
$ngg_options['wmPos'] = 'botRight'; // Postion
|
@@ -193,13 +193,13 @@ function ngg_default_options() {
|
|
193 |
$ngg_options['wmColor'] = '000000'; // Font Color
|
194 |
$ngg_options['wmOpaque'] = '100'; // Font Opaque
|
195 |
|
196 |
-
// Image Rotator settings
|
197 |
$ngg_options['enableIR'] = false;
|
198 |
$ngg_options['slideFx'] = 'fade';
|
199 |
-
$ngg_options['irURL'] = '';
|
200 |
$ngg_options['irXHTMLvalid'] = false;
|
201 |
$ngg_options['irAudio'] = '';
|
202 |
-
$ngg_options['irWidth'] = 320;
|
203 |
$ngg_options['irHeight'] = 240;
|
204 |
$ngg_options['irShuffle'] = true;
|
205 |
$ngg_options['irLinkfromdisplay'] = true;
|
@@ -213,35 +213,35 @@ function ngg_default_options() {
|
|
213 |
$ngg_options['irBackcolor'] = '000000';
|
214 |
$ngg_options['irFrontcolor'] = 'FFFFFF';
|
215 |
$ngg_options['irLightcolor'] = 'CC0000';
|
216 |
-
$ngg_options['irScreencolor'] = '000000';
|
217 |
|
218 |
// CSS Style
|
219 |
$ngg_options['activateCSS'] = true; // activate the CSS file
|
220 |
$ngg_options['CSSfile'] = 'nggallery.css'; // set default css filename
|
221 |
-
|
222 |
-
// special overrides for WPMU
|
223 |
if (is_multisite()) {
|
224 |
// get the site options
|
225 |
$ngg_wpmu_options = get_site_option('ngg_options');
|
226 |
-
|
227 |
// get the default value during first installation
|
228 |
if (!is_array($ngg_wpmu_options)) {
|
229 |
$ngg_wpmu_options['gallerypath'] = 'wp-content/blogs.dir/%BLOG_ID%/files/';
|
230 |
$ngg_wpmu_options['wpmuCSSfile'] = 'nggallery.css';
|
231 |
update_site_option('ngg_options', $ngg_wpmu_options);
|
232 |
}
|
233 |
-
|
234 |
$ngg_options['gallerypath'] = str_replace("%BLOG_ID%", $blog_id , $ngg_wpmu_options['gallerypath']);
|
235 |
$ngg_options['CSSfile'] = $ngg_wpmu_options['wpmuCSSfile'];
|
236 |
-
}
|
237 |
-
|
238 |
update_option('ngg_options', $ngg_options);
|
239 |
|
240 |
}
|
241 |
|
242 |
/**
|
243 |
* Deregister a capability from all classic roles
|
244 |
-
*
|
245 |
* @access internal
|
246 |
* @param string $capability name of the capability which should be deregister
|
247 |
* @return void
|
@@ -261,18 +261,18 @@ function ngg_remove_capability($capability){
|
|
261 |
/**
|
262 |
* Uninstall all settings and tables
|
263 |
* Called via Setup and register_unstall hook
|
264 |
-
*
|
265 |
* @access internal
|
266 |
* @return void
|
267 |
*/
|
268 |
function nggallery_uninstall() {
|
269 |
global $wpdb;
|
270 |
-
|
271 |
// first remove all tables
|
272 |
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_pictures");
|
273 |
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_gallery");
|
274 |
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_album");
|
275 |
-
|
276 |
// then remove all options
|
277 |
delete_option( 'ngg_options' );
|
278 |
delete_option( 'ngg_db_version' );
|
4 |
/**
|
5 |
* creates all tables for the gallery
|
6 |
* called during register_activation hook
|
7 |
+
*
|
8 |
* @access internal
|
9 |
* @return void
|
10 |
*/
|
11 |
function nggallery_install () {
|
12 |
+
|
13 |
global $wpdb , $wp_roles, $wp_version;
|
14 |
+
|
15 |
// Check for capability
|
16 |
+
if ( !current_user_can('activate_plugins') )
|
17 |
return;
|
18 |
+
|
19 |
// Set the capabilities for the administrator
|
20 |
$role = get_role('administrator');
|
21 |
// We need this role, no other chance
|
23 |
update_option( "ngg_init_check", __('Sorry, NextGEN Gallery works only with a role called administrator',"nggallery") );
|
24 |
return;
|
25 |
}
|
26 |
+
|
27 |
$role->add_cap('NextGEN Gallery overview');
|
28 |
$role->add_cap('NextGEN Use TinyMCE');
|
29 |
$role->add_cap('NextGEN Upload images');
|
33 |
$role->add_cap('NextGEN Edit album');
|
34 |
$role->add_cap('NextGEN Change style');
|
35 |
$role->add_cap('NextGEN Change options');
|
36 |
+
|
37 |
+
// upgrade function changed in WordPress 2.3
|
38 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
39 |
+
|
40 |
// add charset & collate like wp core
|
41 |
$charset_collate = '';
|
42 |
|
46 |
if ( ! empty($wpdb->collate) )
|
47 |
$charset_collate .= " COLLATE $wpdb->collate";
|
48 |
}
|
49 |
+
|
50 |
$nggpictures = $wpdb->prefix . 'ngg_pictures';
|
51 |
$nggallery = $wpdb->prefix . 'ngg_gallery';
|
52 |
$nggalbum = $wpdb->prefix . 'ngg_album';
|
53 |
|
54 |
// could be case senstive : http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html
|
55 |
if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggpictures'" ) ) {
|
56 |
+
|
57 |
$sql = "CREATE TABLE " . $nggpictures . " (
|
58 |
pid BIGINT(20) NOT NULL AUTO_INCREMENT ,
|
59 |
image_slug VARCHAR(255) NOT NULL ,
|
69 |
PRIMARY KEY pid (pid),
|
70 |
KEY post_id (post_id)
|
71 |
) $charset_collate;";
|
72 |
+
|
73 |
dbDelta($sql);
|
74 |
}
|
75 |
|
76 |
if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggallery'" )) {
|
77 |
+
|
78 |
$sql = "CREATE TABLE " . $nggallery . " (
|
79 |
gid BIGINT(20) NOT NULL AUTO_INCREMENT ,
|
80 |
name VARCHAR(255) NOT NULL ,
|
87 |
author BIGINT(20) DEFAULT '0' NOT NULL ,
|
88 |
PRIMARY KEY gid (gid)
|
89 |
) $charset_collate;";
|
90 |
+
|
91 |
dbDelta($sql);
|
92 |
}
|
93 |
+
|
94 |
if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggalbum'" )) {
|
95 |
+
|
96 |
$sql = "CREATE TABLE " . $nggalbum . " (
|
97 |
id BIGINT(20) NOT NULL AUTO_INCREMENT ,
|
98 |
name VARCHAR(255) NOT NULL ,
|
103 |
pageid BIGINT(20) DEFAULT '0' NOT NULL,
|
104 |
PRIMARY KEY id (id)
|
105 |
) $charset_collate;";
|
106 |
+
|
107 |
dbDelta($sql);
|
108 |
}
|
109 |
|
112 |
update_option( "ngg_init_check", __('NextGEN Gallery : Tables could not created, please check your database settings',"nggallery") );
|
113 |
return;
|
114 |
}
|
115 |
+
|
116 |
$options = get_option('ngg_options');
|
117 |
// set the default settings, if we didn't upgrade
|
118 |
+
if ( empty( $options ) )
|
119 |
ngg_default_options();
|
120 |
+
|
121 |
// if all is passed , save the DBVERSION
|
122 |
add_option("ngg_db_version", NGG_DBVERSION);
|
123 |
|
125 |
|
126 |
/**
|
127 |
* Setup the default option array for the gallery
|
128 |
+
*
|
129 |
* @access internal
|
130 |
+
* @since version 0.33
|
131 |
* @return void
|
132 |
*/
|
133 |
function ngg_default_options() {
|
134 |
+
|
135 |
global $blog_id, $ngg;
|
136 |
|
137 |
$ngg_options['gallerypath'] = 'wp-content/gallery/'; // set default path to the gallery
|
143 |
$ngg_options['imageMagickDir'] = '/usr/local/bin/'; // default path to ImageMagick
|
144 |
$ngg_options['useMediaRSS'] = false; // activate the global Media RSS file
|
145 |
$ngg_options['usePicLens'] = false; // activate the PicLens Link for galleries
|
146 |
+
|
147 |
// Tags / categories
|
148 |
$ngg_options['activateTags'] = false; // append related images
|
149 |
$ngg_options['appendType'] = 'tags'; // look for category or tags
|
150 |
$ngg_options['maxImages'] = 7; // number of images toshow
|
151 |
+
|
152 |
// Thumbnail Settings
|
153 |
$ngg_options['thumbwidth'] = 100; // Thumb Width
|
154 |
$ngg_options['thumbheight'] = 75; // Thumb height
|
155 |
$ngg_options['thumbfix'] = true; // Fix the dimension
|
156 |
$ngg_options['thumbquality'] = 100; // Thumb Quality
|
157 |
+
|
158 |
// Image Settings
|
159 |
$ngg_options['imgWidth'] = 800; // Image Width
|
160 |
$ngg_options['imgHeight'] = 600; // Image height
|
161 |
$ngg_options['imgQuality'] = 85; // Image Quality
|
162 |
$ngg_options['imgBackup'] = true; // Create a backup
|
163 |
$ngg_options['imgAutoResize'] = false; // Resize after upload
|
164 |
+
|
165 |
// Gallery Settings
|
166 |
$ngg_options['galImages'] = '20'; // Number of images per page
|
167 |
$ngg_options['galPagedGalleries'] = 0; // Number of galleries per page (in a album)
|
179 |
|
180 |
// Thumbnail Effect
|
181 |
$ngg_options['thumbEffect'] = 'shutter'; // select effect
|
182 |
+
$ngg_options['thumbCode'] = 'class="shutterset_%GALLERY_NAME%"';
|
183 |
|
184 |
// Watermark settings
|
185 |
$ngg_options['wmPos'] = 'botRight'; // Postion
|
193 |
$ngg_options['wmColor'] = '000000'; // Font Color
|
194 |
$ngg_options['wmOpaque'] = '100'; // Font Opaque
|
195 |
|
196 |
+
// Image Rotator settings
|
197 |
$ngg_options['enableIR'] = false;
|
198 |
$ngg_options['slideFx'] = 'fade';
|
199 |
+
$ngg_options['irURL'] = path_join(NGGALLERY_URLPATH, 'imagerotator.swf');
|
200 |
$ngg_options['irXHTMLvalid'] = false;
|
201 |
$ngg_options['irAudio'] = '';
|
202 |
+
$ngg_options['irWidth'] = 320;
|
203 |
$ngg_options['irHeight'] = 240;
|
204 |
$ngg_options['irShuffle'] = true;
|
205 |
$ngg_options['irLinkfromdisplay'] = true;
|
213 |
$ngg_options['irBackcolor'] = '000000';
|
214 |
$ngg_options['irFrontcolor'] = 'FFFFFF';
|
215 |
$ngg_options['irLightcolor'] = 'CC0000';
|
216 |
+
$ngg_options['irScreencolor'] = '000000';
|
217 |
|
218 |
// CSS Style
|
219 |
$ngg_options['activateCSS'] = true; // activate the CSS file
|
220 |
$ngg_options['CSSfile'] = 'nggallery.css'; // set default css filename
|
221 |
+
|
222 |
+
// special overrides for WPMU
|
223 |
if (is_multisite()) {
|
224 |
// get the site options
|
225 |
$ngg_wpmu_options = get_site_option('ngg_options');
|
226 |
+
|
227 |
// get the default value during first installation
|
228 |
if (!is_array($ngg_wpmu_options)) {
|
229 |
$ngg_wpmu_options['gallerypath'] = 'wp-content/blogs.dir/%BLOG_ID%/files/';
|
230 |
$ngg_wpmu_options['wpmuCSSfile'] = 'nggallery.css';
|
231 |
update_site_option('ngg_options', $ngg_wpmu_options);
|
232 |
}
|
233 |
+
|
234 |
$ngg_options['gallerypath'] = str_replace("%BLOG_ID%", $blog_id , $ngg_wpmu_options['gallerypath']);
|
235 |
$ngg_options['CSSfile'] = $ngg_wpmu_options['wpmuCSSfile'];
|
236 |
+
}
|
237 |
+
|
238 |
update_option('ngg_options', $ngg_options);
|
239 |
|
240 |
}
|
241 |
|
242 |
/**
|
243 |
* Deregister a capability from all classic roles
|
244 |
+
*
|
245 |
* @access internal
|
246 |
* @param string $capability name of the capability which should be deregister
|
247 |
* @return void
|
261 |
/**
|
262 |
* Uninstall all settings and tables
|
263 |
* Called via Setup and register_unstall hook
|
264 |
+
*
|
265 |
* @access internal
|
266 |
* @return void
|
267 |
*/
|
268 |
function nggallery_uninstall() {
|
269 |
global $wpdb;
|
270 |
+
|
271 |
// first remove all tables
|
272 |
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_pictures");
|
273 |
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_gallery");
|
274 |
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_album");
|
275 |
+
|
276 |
// then remove all options
|
277 |
delete_option( 'ngg_options' );
|
278 |
delete_option( 'ngg_db_version' );
|
admin/pointer.php
DELETED
@@ -1,98 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* NGG_Pointers Class for WordPress 3.3, Thanks to the pre-work of the YOAST (WP-Seo)
|
4 |
-
* @example http://theme.fm/?p=2407 and http://core.trac.wordpress.org/ticket/18693
|
5 |
-
*
|
6 |
-
* @package NextGEN-Gallery
|
7 |
-
* @version 0.9.0
|
8 |
-
* @since 1.9.0
|
9 |
-
* @access public
|
10 |
-
*/
|
11 |
-
class NGG_Pointers {
|
12 |
-
|
13 |
-
var $pointers = array();
|
14 |
-
var $settings = array();
|
15 |
-
|
16 |
-
function __construct() {
|
17 |
-
|
18 |
-
// create an array if pointers for each page
|
19 |
-
$this->pointers = array(
|
20 |
-
'nggallery-add-gallery' => array(
|
21 |
-
'id' => 'image_resize_pointer',
|
22 |
-
'content' => __('<h3>Client side resize</h3><p>You can now resize the images before you start with the upload.</p>', 'nggallery'),
|
23 |
-
'posititon'=> 'top'
|
24 |
-
)
|
25 |
-
);
|
26 |
-
|
27 |
-
$page = ( isset($_GET['page']) ) ? $_GET['page'] : '';
|
28 |
-
$this->settings = ( isset( $this->pointers[$page] ) ) ? $this->pointers[$page] : array();
|
29 |
-
|
30 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue' ) );
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Deleting settings would reset them to the defaults.
|
35 |
-
* This function has to be used before any output has started as it calls setcookie()
|
36 |
-
*
|
37 |
-
* @return void
|
38 |
-
*/
|
39 |
-
function delete_user_setting() {
|
40 |
-
if ( isset( $_GET['ngg_restart_tour'] ) )
|
41 |
-
delete_user_setting('nextgen_tour_pointer');
|
42 |
-
}
|
43 |
-
|
44 |
-
function enqueue() {
|
45 |
-
|
46 |
-
//TODO : Reset currently all pointer tours, needs to be more specific
|
47 |
-
if ( isset( $_GET['ngg_restart_tour'] ) )
|
48 |
-
delete_user_meta(get_current_user_id(), 'dismissed_wp_pointers' );
|
49 |
-
|
50 |
-
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
51 |
-
|
52 |
-
// if we are not on the correct page we will notenqueue the pointer scripts
|
53 |
-
if ( !empty( $this->settings ) ) {
|
54 |
-
|
55 |
-
// exit if the user already closed it
|
56 |
-
if ( in_array( 'ngg-' . $this->settings['id'], $dismissed ) )
|
57 |
-
return;
|
58 |
-
|
59 |
-
wp_enqueue_style( 'wp-pointer' );
|
60 |
-
wp_enqueue_script( 'wp-pointer' );
|
61 |
-
add_action( 'admin_print_footer_scripts', array( &$this, 'print_scripts' ), 99 );
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
function print_scripts() {
|
66 |
-
// show up the pointer dialog with the correct settings
|
67 |
-
$this->show_pointer( $this->settings );
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Show up the pointer
|
72 |
-
*
|
73 |
-
* @param array $settings
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
function show_pointer( $settings ) {
|
77 |
-
?>
|
78 |
-
<script type="text/javascript">
|
79 |
-
//<![CDATA[
|
80 |
-
jQuery(document).ready( function() {
|
81 |
-
jQuery('#<?php echo $settings['id']; ?>').pointer({
|
82 |
-
content: '<?php echo addslashes( $settings['content'] ); ?>',
|
83 |
-
position: '<?php echo $settings['posititon']; ?>',
|
84 |
-
close: function() {
|
85 |
-
jQuery.post( ajaxurl, {
|
86 |
-
pointer: 'ngg-<?php echo $settings['id']; ?>',
|
87 |
-
action: 'dismiss-wp-pointer'
|
88 |
-
});
|
89 |
-
}
|
90 |
-
}).pointer('open');
|
91 |
-
});
|
92 |
-
//]]>
|
93 |
-
</script>
|
94 |
-
<?php
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
$ngg_pointers = new NGG_Pointers;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/settings.php
CHANGED
@@ -644,14 +644,16 @@ class nggOptions {
|
|
644 |
</tr>
|
645 |
</table>
|
646 |
<h3 class="expert" ><?php _e('Settings for the JW Image Rotator','nggallery') ?></h3>
|
647 |
-
|
648 |
-
|
649 |
-
|
|
|
|
|
650 |
<?php if (empty($ngg->options['irURL']) && ($ngg->options['enableIR'] == '1')) { ?>
|
651 |
<div id="message" class="error inline">
|
652 |
<p>
|
653 |
-
<?php _e('The path to
|
654 |
-
|
655 |
</p>
|
656 |
</div>
|
657 |
<?php }?>
|
@@ -662,11 +664,11 @@ class nggOptions {
|
|
662 |
<span class="setting-description"><?php _e('Integrate the flash based slideshow for all flash supported devices','nggallery') ?></span></td>
|
663 |
</tr>
|
664 |
<tr>
|
665 |
-
<th><?php _e('Path to the
|
666 |
<td>
|
667 |
<input type="text" size="50" id="irURL" name="irURL" value="<?php echo $ngg->options['irURL']; ?>" />
|
668 |
<input type="submit" name="irDetect" class="button-secondary" value="<?php _e('Search now','nggallery') ;?> »"/>
|
669 |
-
<br /><span class="setting-description"><?php _e('Press the button to search
|
670 |
</td>
|
671 |
</tr>
|
672 |
<tr>
|
644 |
</tr>
|
645 |
</table>
|
646 |
<h3 class="expert" ><?php _e('Settings for the JW Image Rotator','nggallery') ?></h3>
|
647 |
+
<p>
|
648 |
+
NextGEN Galery flash slideshows use the JW Image Rotator Version 3.17 by <a target='_blank' href='http://www.longtailvideo.com/players/jw-image-rotator/'>Long Tail Video</a>.
|
649 |
+
This file is bundled with NextGEN Gallery 1.9.9 and above. Press the button below to search for it automatically. For earlier versions of NextGEN Gallery, you'll need to
|
650 |
+
upload the file manually to the <a href='http://codex.wordpress.org/Uploading_Files' target='_blank'>WordPress Uploads directory</a>.
|
651 |
+
</p>
|
652 |
<?php if (empty($ngg->options['irURL']) && ($ngg->options['enableIR'] == '1')) { ?>
|
653 |
<div id="message" class="error inline">
|
654 |
<p>
|
655 |
+
<?php _e('The path to JW Image Rotator is not defined, the slideshow will not work.','nggallery'); ?><br />
|
656 |
+
Press the button below to search for the file.
|
657 |
</p>
|
658 |
</div>
|
659 |
<?php }?>
|
664 |
<span class="setting-description"><?php _e('Integrate the flash based slideshow for all flash supported devices','nggallery') ?></span></td>
|
665 |
</tr>
|
666 |
<tr>
|
667 |
+
<th><?php _e('Path to the JW Image Rotator (URL)','nggallery') ?></th>
|
668 |
<td>
|
669 |
<input type="text" size="50" id="irURL" name="irURL" value="<?php echo $ngg->options['irURL']; ?>" />
|
670 |
<input type="submit" name="irDetect" class="button-secondary" value="<?php _e('Search now','nggallery') ;?> »"/>
|
671 |
+
<br /><span class="setting-description"><?php _e('Press the button below to search for the JW Image Rotator','nggallery') ?></span>
|
672 |
</td>
|
673 |
</tr>
|
674 |
<tr>
|
admin/upgrade.php
CHANGED
@@ -1,214 +1,17 @@
|
|
1 |
<?php
|
2 |
-
/**
|
3 |
-
* ngg_upgrade() - update routine for older version
|
4 |
-
*
|
5 |
-
* @return Success message
|
6 |
-
*/
|
7 |
-
function ngg_upgrade() {
|
8 |
-
|
9 |
-
global $wpdb, $user_ID, $nggRewrite;
|
10 |
-
|
11 |
-
// get the current user ID
|
12 |
-
get_currentuserinfo();
|
13 |
-
|
14 |
-
// in multisite environment the pointer $wpdb->nggpictures need to be set again
|
15 |
-
$wpdb->nggpictures = $wpdb->prefix . 'ngg_pictures';
|
16 |
-
$wpdb->nggallery = $wpdb->prefix . 'ngg_gallery';
|
17 |
-
$wpdb->nggalbum = $wpdb->prefix . 'ngg_album';
|
18 |
-
|
19 |
-
// Be sure that the tables exist, avoid case sensitive : http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html
|
20 |
-
if( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->nggpictures'" ) ) {
|
21 |
-
|
22 |
-
echo __('Upgrade database structure...', 'nggallery');
|
23 |
-
$wpdb->show_errors();
|
24 |
-
|
25 |
-
$installed_ver = get_option( 'ngg_db_version' );
|
26 |
-
|
27 |
-
// 0.9.7 is smaller that 0.97, my fault :-)
|
28 |
-
if ( $installed_ver == '0.9.7' ) $installed_ver = '0.97';
|
29 |
-
|
30 |
-
// v0.33 -> v.071
|
31 |
-
if (version_compare($installed_ver, '0.71', '<')) {
|
32 |
-
$wpdb->query("ALTER TABLE $wpdb->nggpictures CHANGE pid pid BIGINT(20) NOT NULL AUTO_INCREMENT ");
|
33 |
-
$wpdb->query("ALTER TABLE $wpdb->nggpictures CHANGE galleryid galleryid BIGINT(20) NOT NULL ");
|
34 |
-
$wpdb->query("ALTER TABLE $wpdb->nggallery CHANGE gid gid BIGINT(20) NOT NULL AUTO_INCREMENT ");
|
35 |
-
$wpdb->query("ALTER TABLE $wpdb->nggallery CHANGE pageid pageid BIGINT(20) NULL DEFAULT '0'");
|
36 |
-
$wpdb->query("ALTER TABLE $wpdb->nggallery CHANGE previewpic previewpic BIGINT(20) NULL DEFAULT '0'");
|
37 |
-
$wpdb->query("ALTER TABLE $wpdb->nggallery CHANGE gid gid BIGINT(20) NOT NULL AUTO_INCREMENT ");
|
38 |
-
$wpdb->query("ALTER TABLE $wpdb->nggallery CHANGE description galdesc MEDIUMTEXT NULL");
|
39 |
-
}
|
40 |
-
|
41 |
-
// v0.71 -> v0.84
|
42 |
-
if (version_compare($installed_ver, '0.84', '<')) {
|
43 |
-
ngg_maybe_add_column( $wpdb->nggpictures, 'sortorder', "BIGINT(20) DEFAULT '0' NOT NULL AFTER exclude");
|
44 |
-
}
|
45 |
-
|
46 |
-
// v0.84 -> v0.95
|
47 |
-
if (version_compare($installed_ver, '0.95', '<')) {
|
48 |
-
// first add the author field and set it to the current administrator
|
49 |
-
ngg_maybe_add_column( $wpdb->nggallery, 'author', "BIGINT(20) NOT NULL DEFAULT '$user_ID' AFTER previewpic");
|
50 |
-
// switch back to zero
|
51 |
-
$wpdb->query("ALTER TABLE $wpdb->nggallery CHANGE author author BIGINT(20) NOT NULL DEFAULT '0'");
|
52 |
-
}
|
53 |
-
|
54 |
-
// v0.95 -> v0.97
|
55 |
-
if (version_compare($installed_ver, '0.96', '<')) {
|
56 |
-
// Convert into WordPress Core taxonomy scheme
|
57 |
-
ngg_convert_tags();
|
58 |
-
// Drop tables, we don't need them anymore
|
59 |
-
$wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "ngg_tags");
|
60 |
-
$wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "ngg_pic2tags");
|
61 |
-
|
62 |
-
// New capability for administrator role
|
63 |
-
$role = get_role('administrator');
|
64 |
-
$role->add_cap('NextGEN Manage tags');
|
65 |
-
|
66 |
-
// Add new option
|
67 |
-
$ngg_options = get_option('ngg_options');
|
68 |
-
$ngg_options['graphicLibrary'] = 'gd';
|
69 |
-
update_option('ngg_options', $ngg_options);
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
// v0.97 -> v1.00
|
74 |
-
if (version_compare($installed_ver, '0.97', '<')) {
|
75 |
-
ngg_maybe_add_column( $wpdb->nggpictures, 'imagedate', "DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER alttext");
|
76 |
-
}
|
77 |
-
|
78 |
-
// v0.97 -> v1.3.0
|
79 |
-
if (version_compare($installed_ver, '1.3.0', '<')) {
|
80 |
-
ngg_maybe_add_column( $wpdb->nggpictures, 'post_id', "BIGINT(20) DEFAULT '0' NOT NULL AFTER pid");
|
81 |
-
ngg_maybe_add_column( $wpdb->nggpictures, 'meta_data', "LONGTEXT AFTER sortorder");
|
82 |
-
$wpdb->query("ALTER TABLE " . $wpdb->nggpictures . " ADD INDEX post_id ( post_id )");
|
83 |
-
}
|
84 |
-
|
85 |
-
// v1.3.0 -> v1.3.1
|
86 |
-
if (version_compare($installed_ver, '1.3.1', '<')) {
|
87 |
-
// add description and previewpic for the album itself
|
88 |
-
ngg_maybe_add_column( $wpdb->nggalbum, 'previewpic', "BIGINT(20) DEFAULT '0' NOT NULL AFTER name");
|
89 |
-
ngg_maybe_add_column( $wpdb->nggalbum, 'albumdesc', "MEDIUMTEXT NULL AFTER previewpic");
|
90 |
-
}
|
91 |
-
|
92 |
-
// v1.3.5 -> v1.4.0
|
93 |
-
if (version_compare($installed_ver, '1.4.0', '<')) {
|
94 |
-
// add link from album to a page
|
95 |
-
ngg_maybe_add_column( $wpdb->nggalbum, 'pageid', "BIGINT(20) DEFAULT '0' NOT NULL AFTER sortorder");
|
96 |
-
}
|
97 |
-
|
98 |
-
// v1.4.0 -> v1.7.0
|
99 |
-
if (version_compare($installed_ver, '1.7.0', '<')) {
|
100 |
-
// add slug fields
|
101 |
-
ngg_maybe_add_column( $wpdb->nggpictures, 'image_slug', "VARCHAR(255) NOT NULL AFTER pid");
|
102 |
-
ngg_maybe_add_column( $wpdb->nggalbum, 'slug', "VARCHAR(255) NOT NULL AFTER name");
|
103 |
-
ngg_maybe_add_column( $wpdb->nggallery, 'slug', "VARCHAR(255) NOT NULL AFTER name");
|
104 |
-
}
|
105 |
-
|
106 |
-
// update now the database
|
107 |
-
update_option( "ngg_db_version", NGG_DBVERSION );
|
108 |
-
echo __('finished', 'nggallery') . "<br />\n";
|
109 |
-
|
110 |
-
$wpdb->hide_errors();
|
111 |
-
|
112 |
-
// *** From here we start file operation which could failed sometimes,
|
113 |
-
// *** ensure that the DB changes are not performed two times...
|
114 |
-
|
115 |
-
// Change all thumbnail folders to "thumbs"
|
116 |
-
if (version_compare($installed_ver, '0.96', '<')) {
|
117 |
-
echo __('Update file structure...', 'nggallery');
|
118 |
-
ngg_convert_filestructure();
|
119 |
-
echo __('finished', 'nggallery') . "<br />\n";
|
120 |
-
}
|
121 |
-
|
122 |
-
// On some reason the import / date sometimes failed, due to the memory limit
|
123 |
-
if (version_compare($installed_ver, '0.97', '<')) {
|
124 |
-
echo __('Import date and time information...', 'nggallery');
|
125 |
-
ngg_import_date_time();
|
126 |
-
echo __('finished', 'nggallery') . "<br />\n";
|
127 |
-
}
|
128 |
-
|
129 |
-
// Move imagerotator outside the plugin folder
|
130 |
-
if (version_compare($installed_ver, '1.1.0', '<')) {
|
131 |
-
$ngg_options = get_option('ngg_options');
|
132 |
-
echo __('Move imagerotator to new location...', 'nggallery');
|
133 |
-
$ngg_options['irURL'] = ngg_move_imagerotator();
|
134 |
-
$ngg_options['galPagedGalleries'] = 0;
|
135 |
-
$ngg_options['galColumns'] = 0;
|
136 |
-
update_option('ngg_options', $ngg_options);
|
137 |
-
echo __('finished', 'nggallery') . "<br />\n";
|
138 |
-
}
|
139 |
-
|
140 |
-
// Remove thumbcrop setting, thumbfix and quare size do the same
|
141 |
-
if (version_compare($installed_ver, '1.4.0', '<')) {
|
142 |
-
$ngg_options = get_option('ngg_options');
|
143 |
-
echo __('Update settings...', 'nggallery');
|
144 |
-
if ( $ngg_options['thumpcrop'] ) {
|
145 |
-
$ngg_options['thumbfix'] = true;
|
146 |
-
$ngg_options['thumbheight'] = $ngg_options['thumbwidth'] ;
|
147 |
-
$ngg_options['galAjaxNav'] = true;
|
148 |
-
}
|
149 |
-
$ngg_options['galHiddenImg'] = false;
|
150 |
-
update_option('ngg_options', $ngg_options);
|
151 |
-
echo __('finished', 'nggallery') . "<br />\n";
|
152 |
-
}
|
153 |
-
|
154 |
-
// Remove the old widget options
|
155 |
-
if (version_compare($installed_ver, '1.4.4', '<')) {
|
156 |
-
delete_option( 'ngg_widget' );
|
157 |
-
echo __('Updated widget structure. If you used NextGEN Widgets, you need to setup them again...', 'nggallery');
|
158 |
-
}
|
159 |
-
|
160 |
-
if (version_compare($installed_ver, '1.6.0', '<')) {
|
161 |
-
$ngg_options = get_option('ngg_options');
|
162 |
-
$ngg_options['enableIR'] = '1';
|
163 |
-
$ngg_options['slideFx'] = 'fade';
|
164 |
-
update_option('ngg_options', $ngg_options);
|
165 |
-
echo __('Updated options.', 'nggallery');
|
166 |
-
}
|
167 |
-
|
168 |
-
if (version_compare($installed_ver, '1.7.0', '<')) {
|
169 |
-
// Network blogs need to call this manually
|
170 |
-
if ( !is_multisite() ) {
|
171 |
-
?>
|
172 |
-
<h2><?php _e('Create unique slug', 'nggallery') ;?></h2>
|
173 |
-
<p><?php _e('One of the upcomming features are a reworked permalinks structure.', 'nggallery') ;?>
|
174 |
-
<?php _e('Therefore it\'s needed to have a unique identifier for each image, gallery and album.', 'nggallery'); ?><br />
|
175 |
-
<?php _e('Depend on the amount of database entries this will take a while, don\'t reload this page.', 'nggallery') ;?></p>
|
176 |
-
<?php
|
177 |
-
ngg_rebuild_unique_slugs::start_rebuild();
|
178 |
-
}
|
179 |
-
|
180 |
-
}
|
181 |
-
|
182 |
-
if (version_compare($installed_ver, '1.8.0', '<')) {
|
183 |
-
$ngg_options = get_option('ngg_options');
|
184 |
-
// new permalink structure
|
185 |
-
$ngg_options['permalinkSlug'] = 'nggallery';
|
186 |
-
update_option('ngg_options', $ngg_options);
|
187 |
-
echo __('Updated options.', 'nggallery');
|
188 |
-
}
|
189 |
-
|
190 |
-
// better to flush rewrite rules after upgrades
|
191 |
-
$nggRewrite->flush();
|
192 |
-
return;
|
193 |
-
}
|
194 |
-
|
195 |
-
echo __('Could not find NextGEN Gallery database tables, upgrade failed !', 'nggallery');
|
196 |
-
|
197 |
-
return;
|
198 |
-
}
|
199 |
|
200 |
/**
|
201 |
* ngg_convert_tags() - Import the tags into the wp tables (only required for pre V1.00 versions)
|
202 |
-
*
|
203 |
* @return Success Message
|
204 |
*/
|
205 |
function ngg_convert_tags() {
|
206 |
global $wpdb, $wp_taxonomies;
|
207 |
-
|
208 |
// get the obsolete tables
|
209 |
$wpdb->nggtags = $wpdb->prefix . 'ngg_tags';
|
210 |
$wpdb->nggpic2tags = $wpdb->prefix . 'ngg_pic2tags';
|
211 |
-
|
212 |
$picturelist = $wpdb->get_col("SELECT pid FROM $wpdb->nggpictures");
|
213 |
if ( is_array($picturelist) ) {
|
214 |
foreach($picturelist as $id) {
|
@@ -226,12 +29,12 @@ function ngg_convert_tags() {
|
|
226 |
|
227 |
/**
|
228 |
* ngg_convert_filestructure() - converter for old thumnail folder structure
|
229 |
-
*
|
230 |
* @return void
|
231 |
*/
|
232 |
function ngg_convert_filestructure() {
|
233 |
global $wpdb;
|
234 |
-
|
235 |
$gallerylist = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY gid ASC", OBJECT_K);
|
236 |
if ( is_array($gallerylist) ) {
|
237 |
$errors = array();
|
@@ -253,7 +56,7 @@ function ngg_convert_filestructure() {
|
|
253 |
}
|
254 |
}
|
255 |
}
|
256 |
-
|
257 |
if (!empty($errors)) {
|
258 |
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>";
|
259 |
foreach($errors as $value) {
|
@@ -266,17 +69,17 @@ function ngg_convert_filestructure() {
|
|
266 |
|
267 |
/**
|
268 |
* Move the imagerotator outside the plugin folder, as we remove it from the REPO with the next update
|
269 |
-
*
|
270 |
* @return string $path URL to the imagerotator
|
271 |
*/
|
272 |
function ngg_move_imagerotator() {
|
273 |
-
|
274 |
$upload = wp_upload_dir();
|
275 |
-
|
276 |
// look first at the old place and move it
|
277 |
if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
|
278 |
@rename(NGGALLERY_ABSPATH . 'imagerotator.swf', $upload['basedir'] . '/imagerotator.swf');
|
279 |
-
|
280 |
// If it's successful then we return the new path
|
281 |
if ( file_exists( $upload['basedir'] . '/imagerotator.swf' ) )
|
282 |
return $upload['baseurl'] . '/imagerotator.swf';
|
@@ -284,19 +87,19 @@ function ngg_move_imagerotator() {
|
|
284 |
//In some worse case it's still at the old place
|
285 |
if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
|
286 |
return NGGALLERY_URLPATH . 'imagerotator.swf';
|
287 |
-
|
288 |
// if something failed, we must return a empty string
|
289 |
-
return '';
|
290 |
}
|
291 |
|
292 |
/**
|
293 |
* ngg_import_date_time() - Read the timestamp from exif and insert it into the database
|
294 |
-
*
|
295 |
* @return void
|
296 |
*/
|
297 |
function ngg_import_date_time() {
|
298 |
global $wpdb;
|
299 |
-
|
300 |
$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");
|
301 |
if ( is_array($imagelist) ) {
|
302 |
foreach ($imagelist as $image) {
|
@@ -304,14 +107,14 @@ function ngg_import_date_time() {
|
|
304 |
$meta = new nggMeta($picture->pid, true);
|
305 |
$date = $meta->get_date_time();
|
306 |
$wpdb->query("UPDATE $wpdb->nggpictures SET imagedate = '$date' WHERE pid = '$picture->pid'");
|
307 |
-
}
|
308 |
-
}
|
309 |
}
|
310 |
|
311 |
/**
|
312 |
* Adding a new column if needed
|
313 |
* Example : ngg_maybe_add_column( $wpdb->nggpictures, 'imagedate', "DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER alttext");
|
314 |
-
*
|
315 |
* @param string $table_name Database table name.
|
316 |
* @param string $column_name Database column name to create.
|
317 |
* @param string $create_ddl SQL statement to create column
|
@@ -319,34 +122,34 @@ function ngg_import_date_time() {
|
|
319 |
*/
|
320 |
function ngg_maybe_add_column($table_name, $column_name, $create_ddl) {
|
321 |
global $wpdb;
|
322 |
-
|
323 |
foreach ($wpdb->get_col("SHOW COLUMNS FROM $table_name") as $column ) {
|
324 |
if ($column == $column_name)
|
325 |
return true;
|
326 |
}
|
327 |
-
|
328 |
//didn't find it try to create it.
|
329 |
$wpdb->query("ALTER TABLE $table_name ADD $column_name " . $create_ddl);
|
330 |
-
|
331 |
// we cannot directly tell that whether this succeeded!
|
332 |
foreach ($wpdb->get_col("SHOW COLUMNS FROM $table_name") as $column ) {
|
333 |
if ($column == $column_name)
|
334 |
return true;
|
335 |
}
|
336 |
-
|
337 |
echo("Could not add column $column_name in table $table_name<br />\n");
|
338 |
return false;
|
339 |
}
|
340 |
|
341 |
/**
|
342 |
* nggallery_upgrade_page() - This page showsup , when the database version doesn't fir to the script NGG_DBVERSION constant.
|
343 |
-
*
|
344 |
* @return Upgrade Message
|
345 |
*/
|
346 |
function nggallery_upgrade_page() {
|
347 |
-
|
348 |
$filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
|
349 |
-
|
350 |
if ( isset($_GET['upgrade']) && $_GET['upgrade'] == 'now') {
|
351 |
nggallery_start_upgrade($filepath);
|
352 |
return;
|
@@ -358,14 +161,14 @@ function nggallery_upgrade_page() {
|
|
358 |
<?php _e('Your database tables for NextGEN Gallery is out-of-date, and must be upgraded before you can continue.', 'nggallery'); ?>
|
359 |
<?php _e('If you would like to downgrade later, please make first a complete backup of your database and the images.', 'nggallery') ;?></p>
|
360 |
<p><?php _e('The upgrade process may take a while, so please be patient.', 'nggallery'); ?></p>
|
361 |
-
<h3><a href="<?php echo $filepath;?>&upgrade=now"><?php _e('Start upgrade now', 'nggallery'); ?>...</a></h3>
|
362 |
</div>
|
363 |
<?php
|
364 |
}
|
365 |
|
366 |
/**
|
367 |
* nggallery_start_upgrade() - Proceed the upgrade routine
|
368 |
-
*
|
369 |
* @param mixed $filepath
|
370 |
* @return void
|
371 |
*/
|
@@ -382,7 +185,7 @@ function nggallery_start_upgrade($filepath) {
|
|
382 |
|
383 |
/**
|
384 |
* Rebuild slugs for albums, galleries and images via AJAX request
|
385 |
-
*
|
386 |
* @sine 1.7.0
|
387 |
* @access internal
|
388 |
*/
|
@@ -390,13 +193,13 @@ class ngg_rebuild_unique_slugs {
|
|
390 |
|
391 |
function start_rebuild() {
|
392 |
global $wpdb;
|
393 |
-
|
394 |
$total = array();
|
395 |
// get the total number of images
|
396 |
$total['images'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
|
397 |
$total['gallery'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
|
398 |
$total['album'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
|
399 |
-
|
400 |
$messages = array(
|
401 |
'images' => __( 'Rebuild image structure : %s / %s images', 'nggallery' ),
|
402 |
'gallery' => __( 'Rebuild gallery structure : %s / %s galleries', 'nggallery' ),
|
@@ -405,17 +208,17 @@ class ngg_rebuild_unique_slugs {
|
|
405 |
|
406 |
?>
|
407 |
<?php
|
408 |
-
|
409 |
foreach ( array_keys( $messages ) as $key ) {
|
410 |
-
|
411 |
$message = sprintf( $messages[ $key ] ,
|
412 |
"<span class='ngg-count-current'>0</span>",
|
413 |
"<span class='ngg-count-total'>" . $total[ $key ] . "</span>"
|
414 |
);
|
415 |
-
|
416 |
echo "<div class='$key updated'><p class='ngg'>$message</p></div>";
|
417 |
}
|
418 |
-
|
419 |
$ajax_url = add_query_arg( 'action', 'ngg_rebuild_unique_slugs', admin_url( 'admin-ajax.php' ) );
|
420 |
?>
|
421 |
<script type="text/javascript">
|
@@ -432,11 +235,11 @@ jQuery(document).ready(function($) {
|
|
432 |
var $display = $('.ngg-count-current');
|
433 |
$('.finished, .gallery, .album').hide();
|
434 |
total = images;
|
435 |
-
|
436 |
function call_again() {
|
437 |
if ( offset > total ) {
|
438 |
offset = 0;
|
439 |
-
// 1st run finished
|
440 |
if (_action == 'images') {
|
441 |
_action = 'gallery';
|
442 |
total = gallery;
|
@@ -444,7 +247,7 @@ jQuery(document).ready(function($) {
|
|
444 |
$display.html(offset);
|
445 |
call_again();
|
446 |
return;
|
447 |
-
}
|
448 |
// 2nd run finished
|
449 |
if (_action == 'gallery') {
|
450 |
_action = 'album';
|
@@ -453,13 +256,13 @@ jQuery(document).ready(function($) {
|
|
453 |
$display.html(offset);
|
454 |
call_again();
|
455 |
return;
|
456 |
-
}
|
457 |
// 3rd run finished, exit now
|
458 |
if (_action == 'album') {
|
459 |
$('.ngg')
|
460 |
.html('<?php _e( 'Done.', 'nggallery' ); ?>')
|
461 |
.parent('div').hide();
|
462 |
-
$('.finished').show();
|
463 |
return;
|
464 |
}
|
465 |
}
|
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) {
|
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();
|
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) {
|
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';
|
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) {
|
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
|
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;
|
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;?>&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 |
*/
|
185 |
|
186 |
/**
|
187 |
* Rebuild slugs for albums, galleries and images via AJAX request
|
188 |
+
*
|
189 |
* @sine 1.7.0
|
190 |
* @access internal
|
191 |
*/
|
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' ),
|
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">
|
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;
|
247 |
$display.html(offset);
|
248 |
call_again();
|
249 |
return;
|
250 |
+
}
|
251 |
// 2nd run finished
|
252 |
if (_action == 'gallery') {
|
253 |
_action = 'album';
|
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 |
}
|
changelog.txt
CHANGED
@@ -1,6 +1,12 @@
|
|
1 |
NextGEN Gallery
|
2 |
by Photocrati Media
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
= V1.9.8 - 12.05.2012 =
|
5 |
* Secured: Removed bundled version of swfupload. See fix below for SCM information.
|
6 |
* Changed: All transients created by NextGEN are flushed when the plugin is activated.
|
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
|
7 |
+
* Fixed: Compatibility with WordPress v3.5 ( wpdb->prepare() warnings )
|
8 |
+
* Fixed: Sorting by filename now produces expected results using a natural sorting algorithm
|
9 |
+
|
10 |
= V1.9.8 - 12.05.2012 =
|
11 |
* Secured: Removed bundled version of swfupload. See fix below for SCM information.
|
12 |
* Changed: All transients created by NextGEN are flushed when the plugin is activated.
|
imagerotator.swf
ADDED
Binary file
|
lib/ngg-db.php
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
if ( !class_exists('nggdb') ) :
|
3 |
/**
|
4 |
* NextGEN Gallery Database Class
|
5 |
-
*
|
6 |
* @author Alex Rabe, Vincent Prat
|
7 |
-
*
|
8 |
* @since 1.0.0
|
9 |
*/
|
10 |
class nggdb {
|
11 |
-
|
12 |
/**
|
13 |
* Holds the list of all galleries
|
14 |
*
|
@@ -35,7 +35,7 @@ class nggdb {
|
|
35 |
* @var object|array
|
36 |
*/
|
37 |
var $albums = false;
|
38 |
-
|
39 |
/**
|
40 |
* The array for the pagination
|
41 |
*
|
@@ -44,10 +44,10 @@ class nggdb {
|
|
44 |
* @var array
|
45 |
*/
|
46 |
var $paged = false;
|
47 |
-
|
48 |
/**
|
49 |
* PHP4 compatibility layer for calling the PHP5 constructor.
|
50 |
-
*
|
51 |
*/
|
52 |
function nggdb() {
|
53 |
return $this->__construct();
|
@@ -55,20 +55,20 @@ class nggdb {
|
|
55 |
|
56 |
/**
|
57 |
* Init the Database Abstraction layer for NextGEN Gallery
|
58 |
-
*
|
59 |
-
*/
|
60 |
function __construct() {
|
61 |
global $wpdb;
|
62 |
-
|
63 |
$this->galleries = array();
|
64 |
$this->images = array();
|
65 |
$this->albums = array();
|
66 |
$this->paged = array();
|
67 |
-
|
68 |
register_shutdown_function(array(&$this, '__destruct'));
|
69 |
-
|
70 |
}
|
71 |
-
|
72 |
/**
|
73 |
* PHP5 style destructor and will run when database object is destroyed.
|
74 |
*
|
@@ -76,11 +76,11 @@ class nggdb {
|
|
76 |
*/
|
77 |
function __destruct() {
|
78 |
return true;
|
79 |
-
}
|
80 |
|
81 |
/**
|
82 |
* Get all the album and unserialize the content
|
83 |
-
*
|
84 |
* @since 1.3.0
|
85 |
* @param string $order_by
|
86 |
* @param string $order_dir
|
@@ -88,29 +88,29 @@ class nggdb {
|
|
88 |
* @param int $start the start index for paged albums
|
89 |
* @return array $album
|
90 |
*/
|
91 |
-
function find_all_album( $order_by = 'id', $order_dir = 'ASC', $limit = 0, $start = 0) {
|
92 |
-
global $wpdb;
|
93 |
-
|
94 |
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
95 |
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
|
96 |
$this->albums = $wpdb->get_results("SELECT * FROM $wpdb->nggalbum ORDER BY {$order_by} {$order_dir} {$limit_by}" , OBJECT_K );
|
97 |
-
|
98 |
if ( !$this->albums )
|
99 |
return array();
|
100 |
-
|
101 |
foreach ($this->albums as $key => $value) {
|
102 |
$this->albums[$key]->galleries = empty ($this->albums[$key]->sortorder) ? array() : (array) unserialize($this->albums[$key]->sortorder) ;
|
103 |
-
$this->albums[$key]->name = stripslashes( $this->albums[$key]->name );
|
104 |
$this->albums[$key]->albumdesc = stripslashes( $this->albums[$key]->albumdesc );
|
105 |
-
wp_cache_add($key, $this->albums[$key], 'ngg_album');
|
106 |
}
|
107 |
-
|
108 |
return $this->albums;
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Get all the galleries
|
113 |
-
*
|
114 |
* @param string $order_by
|
115 |
* @param string $order_dir
|
116 |
* @param bool $counter (optional) Select true when you need to count the images
|
@@ -119,26 +119,26 @@ class nggdb {
|
|
119 |
* @param bool $exclude
|
120 |
* @return array $galleries
|
121 |
*/
|
122 |
-
function find_all_galleries($order_by = 'gid', $order_dir = 'ASC', $counter = false, $limit = 0, $start = 0, $exclude = true) {
|
123 |
-
global $wpdb;
|
124 |
-
|
125 |
// Check for the exclude setting
|
126 |
$exclude_clause = ($exclude) ? ' AND exclude<>1 ' : '';
|
127 |
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
128 |
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
|
129 |
$this->galleries = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->nggallery ORDER BY {$order_by} {$order_dir} {$limit_by}", OBJECT_K );
|
130 |
-
|
131 |
// Count the number of galleries and calculate the pagination
|
132 |
if ($limit > 0) {
|
133 |
$this->paged['total_objects'] = intval ( $wpdb->get_var( "SELECT FOUND_ROWS()" ) );
|
134 |
$this->paged['objects_per_page'] = max ( count( $this->galleries ), $limit );
|
135 |
$this->paged['max_objects_per_page'] = ( $limit > 0 ) ? ceil( $this->paged['total_objects'] / intval($limit)) : 1;
|
136 |
}
|
137 |
-
|
138 |
if ( !$this->galleries )
|
139 |
return array();
|
140 |
-
|
141 |
-
// get the galleries information
|
142 |
foreach ($this->galleries as $key => $value) {
|
143 |
$galleriesID[] = $key;
|
144 |
// init the counter values
|
@@ -146,67 +146,67 @@ class nggdb {
|
|
146 |
$this->galleries[$key]->title = stripslashes($this->galleries[$key]->title);
|
147 |
$this->galleries[$key]->galdesc = stripslashes($this->galleries[$key]->galdesc);
|
148 |
$this->galleries[$key]->abspath = WINABSPATH . $this->galleries[$key]->path;
|
149 |
-
wp_cache_add($key, $this->galleries[$key], 'ngg_gallery');
|
150 |
}
|
151 |
|
152 |
// if we didn't need to count the images then stop here
|
153 |
if ( !$counter )
|
154 |
return $this->galleries;
|
155 |
-
|
156 |
-
// get the counter values
|
157 |
$picturesCounter = $wpdb->get_results('SELECT galleryid, COUNT(*) as counter FROM '.$wpdb->nggpictures.' WHERE galleryid IN (\''.implode('\',\'', $galleriesID).'\') ' . $exclude_clause . ' GROUP BY galleryid', OBJECT_K);
|
158 |
|
159 |
if ( !$picturesCounter )
|
160 |
return $this->galleries;
|
161 |
-
|
162 |
-
// add the counter to the gallery objekt
|
163 |
foreach ($picturesCounter as $key => $value) {
|
164 |
$this->galleries[$value->galleryid]->counter = $value->counter;
|
165 |
wp_cache_set($value->galleryid, $this->galleries[$value->galleryid], 'ngg_gallery');
|
166 |
}
|
167 |
-
|
168 |
return $this->galleries;
|
169 |
}
|
170 |
-
|
171 |
/**
|
172 |
* Get a gallery given its ID
|
173 |
-
*
|
174 |
* @param int|string $id or $slug
|
175 |
* @return A nggGallery object (null if not found)
|
176 |
*/
|
177 |
-
function find_gallery( $id ) {
|
178 |
global $wpdb;
|
179 |
-
|
180 |
if( is_numeric($id) ) {
|
181 |
-
|
182 |
if ( $gallery = wp_cache_get($id, 'ngg_gallery') )
|
183 |
return $gallery;
|
184 |
-
|
185 |
$gallery = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggallery WHERE gid = %d", $id ) );
|
186 |
|
187 |
} else
|
188 |
$gallery = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggallery WHERE slug = %s", $id ) );
|
189 |
-
|
190 |
// Build the object from the query result
|
191 |
if ($gallery) {
|
192 |
// it was a bad idea to use a object, stripslashes_deep() could not used here, learn from it
|
193 |
$gallery->title = stripslashes($gallery->title);
|
194 |
$gallery->galdesc = stripslashes($gallery->galdesc);
|
195 |
-
|
196 |
$gallery->abspath = WINABSPATH . $gallery->path;
|
197 |
//TODO:Possible failure , $id could be a number or name
|
198 |
wp_cache_add($id, $gallery, 'ngg_gallery');
|
199 |
-
|
200 |
-
return $gallery;
|
201 |
-
} else
|
202 |
return false;
|
203 |
}
|
204 |
-
|
205 |
/**
|
206 |
* This function return all information about the gallery and the images inside
|
207 |
-
*
|
208 |
* @param int|string $id or $name
|
209 |
-
* @param string $order_by
|
210 |
* @param string $order_dir (ASC |DESC)
|
211 |
* @param bool $exclude
|
212 |
* @param int $limit number of paged galleries, 0 shows all galleries
|
@@ -221,22 +221,22 @@ class nggdb {
|
|
221 |
// init the gallery as empty array
|
222 |
$gallery = array();
|
223 |
$i = 0;
|
224 |
-
|
225 |
// Check for the exclude setting
|
226 |
$exclude_clause = ($exclude) ? ' AND tt.exclude<>1 ' : '';
|
227 |
-
|
228 |
// Say no to any other value
|
229 |
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
230 |
$order_by = ( empty($order_by) ) ? 'sortorder' : $order_by;
|
231 |
-
|
232 |
// Should we limit this query ?
|
233 |
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
|
234 |
-
|
235 |
// Query database
|
236 |
if( is_numeric($id) )
|
237 |
-
$result = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = %d {$exclude_clause} ORDER BY tt.{$order_by} {$order_dir} {$limit_by}", $id ), OBJECT_K );
|
238 |
else
|
239 |
-
$result = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.slug = %s {$exclude_clause} ORDER BY tt.{$order_by} {$order_dir} {$limit_by}", $id ), OBJECT_K );
|
240 |
|
241 |
// Count the number of images and calculate the pagination
|
242 |
if ($limit > 0) {
|
@@ -244,31 +244,31 @@ class nggdb {
|
|
244 |
$this->paged['objects_per_page'] = max ( count( $result ), $limit );
|
245 |
$this->paged['max_objects_per_page'] = ( $limit > 0 ) ? ceil( $this->paged['total_objects'] / intval($limit)) : 1;
|
246 |
}
|
247 |
-
|
248 |
// Build the object
|
249 |
if ($result) {
|
250 |
-
|
251 |
// Now added all image data
|
252 |
foreach ($result as $key => $value) {
|
253 |
-
// due to a browser bug we need to remove the key for associative array for json request
|
254 |
// (see http://code.google.com/p/chromium/issues/detail?id=883)
|
255 |
-
if ($json) $key = $i++;
|
256 |
$gallery[$key] = new nggImage( $value ); // keep in mind each request require 8-16 kb memory usage
|
257 |
-
|
258 |
}
|
259 |
}
|
260 |
-
|
261 |
// Could not add to cache, the structure is different to find_gallery() cache_add, need rework
|
262 |
//wp_cache_add($id, $gallery, 'ngg_gallery');
|
263 |
|
264 |
-
return $gallery;
|
265 |
}
|
266 |
-
|
267 |
/**
|
268 |
* This function return all information about the gallery and the images inside
|
269 |
-
*
|
270 |
* @param int|string $id or $name
|
271 |
-
* @param string $orderby
|
272 |
* @param string $order (ASC |DESC)
|
273 |
* @param bool $exclude
|
274 |
* @return An array containing the nggImage objects representing the images in the gallery.
|
@@ -276,54 +276,54 @@ class nggdb {
|
|
276 |
function get_ids_from_gallery($id, $order_by = 'sortorder', $order_dir = 'ASC', $exclude = true) {
|
277 |
|
278 |
global $wpdb;
|
279 |
-
|
280 |
// Check for the exclude setting
|
281 |
$exclude_clause = ($exclude) ? ' AND tt.exclude<>1 ' : '';
|
282 |
-
|
283 |
// Say no to any other value
|
284 |
-
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
285 |
$order_by = ( empty($order_by) ) ? 'sortorder' : $order_by;
|
286 |
-
|
287 |
// Query database
|
288 |
if( is_numeric($id) )
|
289 |
$result = $wpdb->get_col( $wpdb->prepare( "SELECT tt.pid FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = %d $exclude_clause ORDER BY tt.{$order_by} $order_dir", $id ) );
|
290 |
else
|
291 |
$result = $wpdb->get_col( $wpdb->prepare( "SELECT tt.pid FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.slug = %s $exclude_clause ORDER BY tt.{$order_by} $order_dir", $id ) );
|
292 |
|
293 |
-
return $result;
|
294 |
-
}
|
295 |
-
|
296 |
/**
|
297 |
* Delete a gallery AND all the pictures associated to this gallery!
|
298 |
-
*
|
299 |
* @id The gallery ID
|
300 |
*/
|
301 |
-
function delete_gallery( $id ) {
|
302 |
global $wpdb;
|
303 |
-
|
304 |
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggpictures WHERE galleryid = %d", $id) );
|
305 |
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggallery WHERE gid = %d", $id) );
|
306 |
-
|
307 |
wp_cache_delete($id, 'ngg_gallery');
|
308 |
-
|
309 |
//TODO:Remove all tag relationship
|
310 |
return true;
|
311 |
}
|
312 |
|
313 |
/**
|
314 |
* Get an album given its ID
|
315 |
-
*
|
316 |
* @id The album ID or name
|
317 |
* @return A nggGallery object (false if not found)
|
318 |
*/
|
319 |
-
function find_album( $id ) {
|
320 |
global $wpdb;
|
321 |
-
|
322 |
// Query database
|
323 |
if ( is_numeric($id) && $id != 0 ) {
|
324 |
if ( $album = wp_cache_get($id, 'ngg_album') )
|
325 |
return $album;
|
326 |
-
|
327 |
$album = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggalbum WHERE id = %d", $id) );
|
328 |
} elseif ( $id == 'all' || (is_numeric($id) && $id == 0) ) {
|
329 |
// init the object and fill it
|
@@ -336,57 +336,57 @@ class nggdb {
|
|
336 |
} else {
|
337 |
$album = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggalbum WHERE slug = %s", $id) );
|
338 |
}
|
339 |
-
|
340 |
// Unserialize the galleries inside the album
|
341 |
if ( $album ) {
|
342 |
-
if ( !empty( $album->sortorder ) )
|
343 |
$album->gallery_ids = unserialize( $album->sortorder );
|
344 |
-
|
345 |
// it was a bad idea to use a object, stripslashes_deep() could not used here, learn from it
|
346 |
$album->albumdesc = stripslashes($album->albumdesc);
|
347 |
$album->name = stripslashes($album->name);
|
348 |
-
|
349 |
-
wp_cache_add($album->id, $album, 'ngg_album');
|
350 |
return $album;
|
351 |
-
}
|
352 |
-
|
353 |
return false;
|
354 |
}
|
355 |
-
|
356 |
/**
|
357 |
* Delete an album
|
358 |
-
*
|
359 |
* @id The album ID
|
360 |
*/
|
361 |
-
function delete_album( $id ) {
|
362 |
global $wpdb;
|
363 |
-
|
364 |
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggalbum WHERE id = %d", $id) );
|
365 |
wp_cache_delete($id, 'ngg_album');
|
366 |
-
|
367 |
return $result;
|
368 |
}
|
369 |
|
370 |
/**
|
371 |
* Insert an image in the database
|
372 |
-
*
|
373 |
* @return the ID of the inserted image
|
374 |
*/
|
375 |
function insert_image($gid, $filename, $alttext, $desc, $exclude) {
|
376 |
global $wpdb;
|
377 |
-
|
378 |
$result = $wpdb->query(
|
379 |
"INSERT INTO $wpdb->nggpictures (galleryid, filename, description, alttext, exclude) VALUES "
|
380 |
. "('$gid', '$filename', '$desc', '$alttext', '$exclude');");
|
381 |
$pid = (int) $wpdb->insert_id;
|
382 |
wp_cache_delete($gid, 'ngg_gallery');
|
383 |
-
|
384 |
return $pid;
|
385 |
}
|
386 |
|
387 |
/**
|
388 |
* nggdb::update_image() - Update an image in the database
|
389 |
-
*
|
390 |
* @param int $pid id of the image
|
391 |
* @param (optional) string|int $galleryid
|
392 |
* @param (optional) string $filename
|
@@ -399,13 +399,13 @@ class nggdb {
|
|
399 |
function update_image($pid, $galleryid = false, $filename = false, $description = false, $alttext = false, $exclude = false, $sortorder = false) {
|
400 |
|
401 |
global $wpdb;
|
402 |
-
|
403 |
$sql = array();
|
404 |
$pid = (int) $pid;
|
405 |
-
|
406 |
-
// slug must be unique, we use the alttext for that
|
407 |
$slug = nggdb::get_unique_slug( sanitize_title( $alttext ), 'image' );
|
408 |
-
|
409 |
$update = array(
|
410 |
'image_slug' => $slug,
|
411 |
'galleryid' => $galleryid,
|
@@ -414,26 +414,26 @@ class nggdb {
|
|
414 |
'alttext' => $alttext,
|
415 |
'exclude' => $exclude,
|
416 |
'sortorder' => $sortorder);
|
417 |
-
|
418 |
// create the sql parameter "name = value"
|
419 |
foreach ($update as $key => $value)
|
420 |
if ($value !== false)
|
421 |
$sql[] = $key . " = '" . $value . "'";
|
422 |
-
|
423 |
// create the final string
|
424 |
$sql = implode(', ', $sql);
|
425 |
-
|
426 |
if ( !empty($sql) && $pid != 0)
|
427 |
$result = $wpdb->query( "UPDATE $wpdb->nggpictures SET $sql WHERE pid = $pid" );
|
428 |
-
|
429 |
-
wp_cache_delete($pid, 'ngg_image');
|
430 |
|
431 |
return $result;
|
432 |
}
|
433 |
-
|
434 |
/**
|
435 |
* nggdb::update_gallery() - Update an gallery in the database
|
436 |
-
*
|
437 |
* @since V1.7.0
|
438 |
* @param int $id id of the gallery
|
439 |
* @param (optional) string $title or name of the gallery
|
@@ -441,19 +441,19 @@ class nggdb {
|
|
441 |
* @param (optional) string $description
|
442 |
* @param (optional) int $pageid
|
443 |
* @param (optional) int $previewpic
|
444 |
-
* @param (optional) int $author
|
445 |
* @return bool result of update query
|
446 |
*/
|
447 |
function update_gallery($id, $name = false, $path = false, $title = false, $description = false, $pageid = false, $previewpic = false, $author = false) {
|
448 |
|
449 |
global $wpdb;
|
450 |
-
|
451 |
$sql = array();
|
452 |
$id = (int) $id;
|
453 |
-
|
454 |
-
// slug must be unique, we use the title for that
|
455 |
$slug = nggdb::get_unique_slug( sanitize_title( $title ), 'gallery' );
|
456 |
-
|
457 |
$update = array(
|
458 |
'name' => $name,
|
459 |
'slug' => $slug,
|
@@ -463,45 +463,45 @@ class nggdb {
|
|
463 |
'pageid' => $pageid,
|
464 |
'previewpic' => $previewpic,
|
465 |
'author' => $author);
|
466 |
-
|
467 |
// create the sql parameter "name = value"
|
468 |
foreach ($update as $key => $value)
|
469 |
if ($value !== false)
|
470 |
$sql[] = $key . " = '" . $value . "'";
|
471 |
-
|
472 |
// create the final string
|
473 |
$sql = implode(', ', $sql);
|
474 |
-
|
475 |
if ( !empty($sql) && $id != 0)
|
476 |
$result = $wpdb->query( "UPDATE $wpdb->nggallery SET $sql WHERE gid = $id" );
|
477 |
-
|
478 |
-
wp_cache_delete($id, 'ngg_gallery');
|
479 |
|
480 |
return $result;
|
481 |
}
|
482 |
|
483 |
/**
|
484 |
* nggdb::update_album() - Update an album in the database
|
485 |
-
*
|
486 |
* @since V1.7.0
|
487 |
* @param int $ id id of the album
|
488 |
* @param (optional) string $title
|
489 |
* @param (optional) int $previewpic
|
490 |
* @param (optional) string $description
|
491 |
-
* @param (optional) serialized array $sortorder
|
492 |
* @param (optional) int $pageid
|
493 |
* @return bool result of update query
|
494 |
*/
|
495 |
function update_album($id, $name = false, $previewpic = false, $description = false, $sortorder = false, $pageid = false ) {
|
496 |
|
497 |
global $wpdb;
|
498 |
-
|
499 |
$sql = array();
|
500 |
$id = (int) $id;
|
501 |
-
|
502 |
-
// slug must be unique, we use the title for that
|
503 |
$slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album' );
|
504 |
-
|
505 |
$update = array(
|
506 |
'name' => $name,
|
507 |
'slug' => $slug,
|
@@ -509,26 +509,26 @@ class nggdb {
|
|
509 |
'albumdesc' => $description,
|
510 |
'sortorder' => $sortorder,
|
511 |
'pageid' => $pageid);
|
512 |
-
|
513 |
// create the sql parameter "name = value"
|
514 |
foreach ($update as $key => $value)
|
515 |
if ($value !== false)
|
516 |
$sql[] = $key . " = '" . $value . "'";
|
517 |
-
|
518 |
// create the final string
|
519 |
$sql = implode(', ', $sql);
|
520 |
-
|
521 |
if ( !empty($sql) && $id != 0)
|
522 |
$result = $wpdb->query( "UPDATE $wpdb->nggalbum SET $sql WHERE id = $id" );
|
523 |
-
|
524 |
wp_cache_delete($id, 'ngg_album');
|
525 |
|
526 |
return $result;
|
527 |
}
|
528 |
-
|
529 |
/**
|
530 |
* Get an image given its ID
|
531 |
-
*
|
532 |
* @param int|string The image ID or Slug
|
533 |
* @return object A nggImage object representing the image (false if not found)
|
534 |
*/
|
@@ -536,58 +536,58 @@ class nggdb {
|
|
536 |
global $wpdb;
|
537 |
|
538 |
if( is_numeric($id) ) {
|
539 |
-
|
540 |
if ( $image = wp_cache_get($id, 'ngg_image') )
|
541 |
return $image;
|
542 |
-
|
543 |
$result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.pid = %d ", $id ) );
|
544 |
} else
|
545 |
-
$result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.image_slug = %s ", $id ) );
|
546 |
-
|
547 |
// Build the object from the query result
|
548 |
if ($result) {
|
549 |
$image = new nggImage($result);
|
550 |
return $image;
|
551 |
-
}
|
552 |
-
|
553 |
return false;
|
554 |
}
|
555 |
-
|
556 |
/**
|
557 |
-
* Get images given a list of IDs
|
558 |
-
*
|
559 |
* @param $pids array of picture_ids
|
560 |
* @return An array of nggImage objects representing the images
|
561 |
*/
|
562 |
function find_images_in_list( $pids, $exclude = false, $order = 'ASC' ) {
|
563 |
global $wpdb;
|
564 |
-
|
565 |
$result = array();
|
566 |
-
|
567 |
// Check for the exclude setting
|
568 |
$exclude_clause = ($exclude) ? ' AND t.exclude <> 1 ' : '';
|
569 |
|
570 |
// Check for the exclude setting
|
571 |
$order_clause = ($order == 'RAND') ? 'ORDER BY rand() ' : ' ORDER BY t.pid ASC' ;
|
572 |
-
|
573 |
if ( is_array($pids) ) {
|
574 |
$id_list = "'" . implode("', '", $pids) . "'";
|
575 |
-
|
576 |
// Save Query database
|
577 |
$images = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggpictures AS t INNER JOIN $wpdb->nggallery AS tt ON t.galleryid = tt.gid WHERE t.pid IN ($id_list) $exclude_clause $order_clause", OBJECT_K);
|
578 |
-
|
579 |
// Build the image objects from the query result
|
580 |
-
if ($images) {
|
581 |
-
foreach ($images as $key => $image)
|
582 |
$result[$key] = new nggImage( $image );
|
583 |
-
}
|
584 |
}
|
585 |
return $result;
|
586 |
}
|
587 |
|
588 |
/**
|
589 |
* Add an image to the database
|
590 |
-
*
|
591 |
* @since V1.4.0
|
592 |
* @param int $pid id of the gallery
|
593 |
* @param (optional) string|int $galleryid
|
@@ -603,109 +603,109 @@ class nggdb {
|
|
603 |
*/
|
604 |
function add_image( $id = false, $filename = false, $description = '', $alttext = '', $meta_data = false, $post_id = 0, $imagedate = '0000-00-00 00:00:00', $exclude = 0, $sortorder = 0 ) {
|
605 |
global $wpdb;
|
606 |
-
|
607 |
if ( is_array($meta_data) )
|
608 |
$meta_data = serialize($meta_data);
|
609 |
|
610 |
-
// slug must be unique, we use the alttext for that
|
611 |
$slug = nggdb::get_unique_slug( sanitize_title( $alttext ), 'image' );
|
612 |
|
613 |
// Add the image
|
614 |
-
if ( false === $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggpictures (image_slug, galleryid, filename, description, alttext, meta_data, post_id, imagedate, exclude, sortorder)
|
615 |
VALUES (%s, %d, %s, %s, %s, %s, %d, %s, %d, %d)", $slug, $id, $filename, $description, $alttext, $meta_data, $post_id, $imagedate, $exclude, $sortorder ) ) ) {
|
616 |
return false;
|
617 |
}
|
618 |
-
|
619 |
$imageID = (int) $wpdb->insert_id;
|
620 |
-
|
621 |
// Remove from cache the galley, needs to be rebuild now
|
622 |
wp_cache_delete( $id, 'ngg_gallery');
|
623 |
-
|
624 |
-
//and give me the new id
|
625 |
return $imageID;
|
626 |
}
|
627 |
-
|
628 |
/**
|
629 |
* Add an album to the database
|
630 |
-
*
|
631 |
* @since V1.7.0
|
632 |
* @param (optional) string $title
|
633 |
* @param (optional) int $previewpic
|
634 |
* @param (optional) string $description
|
635 |
-
* @param (optional) serialized array $sortorder
|
636 |
* @param (optional) int $pageid
|
637 |
* @return bool result of the ID of the inserted album
|
638 |
*/
|
639 |
function add_album( $name = false, $previewpic = 0, $description = '', $sortorder = 0, $pageid = 0 ) {
|
640 |
global $wpdb;
|
641 |
-
|
642 |
-
// name must be unique, we use the title for that
|
643 |
$slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album' );
|
644 |
-
|
645 |
// Add the album
|
646 |
-
if ( false === $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggalbum (name, slug, previewpic, albumdesc, sortorder, pageid)
|
647 |
VALUES (%s, %s, %d, %s, %s, %d)", $name, $slug, $previewpic, $description, $sortorder, $pageid ) ) ) {
|
648 |
return false;
|
649 |
}
|
650 |
-
|
651 |
$albumID = (int) $wpdb->insert_id;
|
652 |
-
|
653 |
-
//and give me the new id
|
654 |
return $albumID;
|
655 |
}
|
656 |
|
657 |
/**
|
658 |
* Add an gallery to the database
|
659 |
-
*
|
660 |
* @since V1.7.0
|
661 |
* @param (optional) string $title or name of the gallery
|
662 |
* @param (optional) string $path
|
663 |
* @param (optional) string $description
|
664 |
* @param (optional) int $pageid
|
665 |
* @param (optional) int $previewpic
|
666 |
-
* @param (optional) int $author
|
667 |
* @return bool result of the ID of the inserted gallery
|
668 |
*/
|
669 |
function add_gallery( $title = '', $path = '', $description = '', $pageid = 0, $previewpic = 0, $author = 0 ) {
|
670 |
global $wpdb;
|
671 |
-
|
672 |
-
// slug must be unique, we use the title for that
|
673 |
$slug = nggdb::get_unique_slug( sanitize_title( $title ), 'gallery' );
|
674 |
-
|
675 |
// Note : The field 'name' is deprecated, it's currently kept only for compat reason with older shortcodes, we copy the slug into this field
|
676 |
-
if ( false === $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggallery (name, slug, path, title, galdesc, pageid, previewpic, author)
|
677 |
VALUES (%s, %s, %s, %s, %s, %d, %d, %d)", $slug, $slug, $path, $title, $description, $pageid, $previewpic, $author ) ) ) {
|
678 |
return false;
|
679 |
}
|
680 |
-
|
681 |
$galleryID = (int) $wpdb->insert_id;
|
682 |
-
|
683 |
-
//and give me the new id
|
684 |
return $galleryID;
|
685 |
}
|
686 |
-
|
687 |
/**
|
688 |
* Delete an image entry from the database
|
689 |
* @param integer $id is the Image ID
|
690 |
*/
|
691 |
function delete_image( $id ) {
|
692 |
global $wpdb;
|
693 |
-
|
694 |
// Delete the image
|
695 |
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggpictures WHERE pid = %d", $id) );
|
696 |
-
|
697 |
// Delete tag references
|
698 |
wp_delete_object_term_relationships( $id, 'ngg_tag');
|
699 |
-
|
700 |
// Remove from cache
|
701 |
-
wp_cache_delete( $id, 'ngg_image');
|
702 |
-
|
703 |
return $result;
|
704 |
}
|
705 |
-
|
706 |
/**
|
707 |
* Get the last images registered in the database with a maximum number of $limit results
|
708 |
-
*
|
709 |
* @param integer $page start offset as page number (0,1,2,3,4...)
|
710 |
* @param integer $limit the number of result
|
711 |
* @param bool $exclude do not show exluded images
|
@@ -715,15 +715,15 @@ class nggdb {
|
|
715 |
*/
|
716 |
function find_last_images($page = 0, $limit = 30, $exclude = true, $galleryId = 0, $orderby = "id") {
|
717 |
global $wpdb;
|
718 |
-
|
719 |
// Check for the exclude setting
|
720 |
$exclude_clause = ($exclude) ? ' AND exclude<>1 ' : '';
|
721 |
-
|
722 |
// a limit of 0 makes no sense
|
723 |
$limit = ($limit == 0) ? 30 : $limit;
|
724 |
// calculate the offset based on the pagr number
|
725 |
$offset = (int) $page * $limit;
|
726 |
-
|
727 |
$galleryId = (int) $galleryId;
|
728 |
$gallery_clause = ($galleryId === 0) ? '' : ' AND galleryid = ' . $galleryId . ' ';
|
729 |
|
@@ -737,103 +737,103 @@ class nggdb {
|
|
737 |
$order = 'sortorder ASC';
|
738 |
break;
|
739 |
}
|
740 |
-
|
741 |
$result = array();
|
742 |
$gallery_cache = array();
|
743 |
-
|
744 |
// Query database
|
745 |
$images = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures WHERE 1=1 $exclude_clause $gallery_clause ORDER BY $order LIMIT $offset, $limit");
|
746 |
-
|
747 |
// Build the object from the query result
|
748 |
-
if ($images) {
|
749 |
foreach ($images as $key => $image) {
|
750 |
-
|
751 |
// cache a gallery , so we didn't need to lookup twice
|
752 |
if (!array_key_exists($image->galleryid, $gallery_cache))
|
753 |
$gallery_cache[$image->galleryid] = nggdb::find_gallery($image->galleryid);
|
754 |
-
|
755 |
-
// Join gallery information with picture information
|
756 |
foreach ($gallery_cache[$image->galleryid] as $index => $value)
|
757 |
$image->$index = $value;
|
758 |
-
|
759 |
// Now get the complete image data
|
760 |
$result[$key] = new nggImage( $image );
|
761 |
}
|
762 |
}
|
763 |
-
|
764 |
return $result;
|
765 |
}
|
766 |
-
|
767 |
/**
|
768 |
* nggdb::get_random_images() - Get an random image from one ore more gally
|
769 |
-
*
|
770 |
* @param integer $number of images
|
771 |
* @param integer $galleryID optional a Gallery
|
772 |
* @return A nggImage object representing the image (null if not found)
|
773 |
*/
|
774 |
function get_random_images($number = 1, $galleryID = 0) {
|
775 |
global $wpdb;
|
776 |
-
|
777 |
$number = (int) $number;
|
778 |
$galleryID = (int) $galleryID;
|
779 |
$images = array();
|
780 |
-
|
781 |
// Query database
|
782 |
if ($galleryID == 0)
|
783 |
$result = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 ORDER by rand() limit $number");
|
784 |
else
|
785 |
$result = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = $galleryID AND tt.exclude != 1 ORDER by rand() limit {$number}");
|
786 |
-
|
787 |
// Return the object from the query result
|
788 |
if ($result) {
|
789 |
foreach ($result as $image) {
|
790 |
$images[] = new nggImage( $image );
|
791 |
}
|
792 |
return $images;
|
793 |
-
}
|
794 |
-
|
795 |
return null;
|
796 |
}
|
797 |
|
798 |
/**
|
799 |
* Get all the images from a given album
|
800 |
-
*
|
801 |
-
* @param object|int $album The album object or the id
|
802 |
* @param string $order_by
|
803 |
* @param string $order_dir
|
804 |
* @param bool $exclude
|
805 |
* @return An array containing the nggImage objects representing the images in the album.
|
806 |
*/
|
807 |
-
function find_images_in_album($album, $order_by = 'galleryid', $order_dir = 'ASC', $exclude = true) {
|
808 |
global $wpdb;
|
809 |
-
|
810 |
if ( !is_object($album) )
|
811 |
$album = nggdb::find_album( $album );
|
812 |
|
813 |
-
// Get gallery list
|
814 |
-
$gallery_list = implode(',', $album->gallery_ids);
|
815 |
// Check for the exclude setting
|
816 |
$exclude_clause = ($exclude) ? ' AND tt.exclude<>1 ' : '';
|
817 |
|
818 |
// Say no to any other value
|
819 |
-
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
820 |
$order_by = ( empty($order_by) ) ? 'galleryid' : $order_by;
|
821 |
-
|
822 |
-
$result = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.galleryid IN ($gallery_list) $exclude_clause ORDER BY tt.$order_by $order_dir");
|
823 |
// Return the object from the query result
|
824 |
if ($result) {
|
825 |
foreach ($result as $image) {
|
826 |
$images[] = new nggImage( $image );
|
827 |
}
|
828 |
return $images;
|
829 |
-
}
|
830 |
|
831 |
-
return null;
|
832 |
}
|
833 |
|
834 |
/**
|
835 |
* search for images and return the result
|
836 |
-
*
|
837 |
* @since 1.3.0
|
838 |
* @param string $request
|
839 |
* @param int $limit number of results, 0 shows all results
|
@@ -841,37 +841,37 @@ class nggdb {
|
|
841 |
*/
|
842 |
function search_for_images( $request, $limit = 0 ) {
|
843 |
global $wpdb;
|
844 |
-
|
845 |
// If a search pattern is specified, load the posts that match
|
846 |
if ( !empty($request) ) {
|
847 |
// added slashes screw with quote grouping when done early, so done later
|
848 |
$request = stripslashes($request);
|
849 |
-
|
850 |
// split the words it a array if seperated by a space or comma
|
851 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $request, $matches);
|
852 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
853 |
-
|
854 |
$n = '%';
|
855 |
$searchand = '';
|
856 |
$search = '';
|
857 |
-
|
858 |
foreach( (array) $search_terms as $term) {
|
859 |
$term = addslashes_gpc($term);
|
860 |
$search .= "{$searchand}((tt.description LIKE '{$n}{$term}{$n}') OR (tt.alttext LIKE '{$n}{$term}{$n}') OR (tt.filename LIKE '{$n}{$term}{$n}'))";
|
861 |
$searchand = ' AND ';
|
862 |
}
|
863 |
-
|
864 |
$term = $wpdb->escape($request);
|
865 |
if (count($search_terms) > 1 && $search_terms[0] != $request )
|
866 |
$search .= " OR (tt.description LIKE '{$n}{$term}{$n}') OR (tt.alttext LIKE '{$n}{$term}{$n}') OR (tt.filename LIKE '{$n}{$term}{$n}')";
|
867 |
|
868 |
if ( !empty($search) )
|
869 |
$search = " AND ({$search}) ";
|
870 |
-
|
871 |
-
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($limit) : '';
|
872 |
} else
|
873 |
return false;
|
874 |
-
|
875 |
// build the final query
|
876 |
$query = "SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE 1=1 $search ORDER BY tt.pid ASC $limit_by";
|
877 |
$result = $wpdb->get_results($query);
|
@@ -886,14 +886,14 @@ class nggdb {
|
|
886 |
$images[] = new nggImage( $image );
|
887 |
}
|
888 |
return $images;
|
889 |
-
}
|
890 |
|
891 |
return null;
|
892 |
}
|
893 |
|
894 |
/**
|
895 |
* search for galleries and return the result
|
896 |
-
*
|
897 |
* @since 1.7.0
|
898 |
* @param string $request
|
899 |
* @param int $limit number of results, 0 shows all results
|
@@ -901,37 +901,37 @@ class nggdb {
|
|
901 |
*/
|
902 |
function search_for_galleries( $request, $limit = 0 ) {
|
903 |
global $wpdb;
|
904 |
-
|
905 |
// If a search pattern is specified, load the posts that match
|
906 |
if ( !empty($request) ) {
|
907 |
// added slashes screw with quote grouping when done early, so done later
|
908 |
$request = stripslashes($request);
|
909 |
-
|
910 |
// split the words it a array if seperated by a space or comma
|
911 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $request, $matches);
|
912 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
913 |
-
|
914 |
$n = '%';
|
915 |
$searchand = '';
|
916 |
$search = '';
|
917 |
-
|
918 |
foreach( (array) $search_terms as $term) {
|
919 |
$term = addslashes_gpc($term);
|
920 |
$search .= "{$searchand}((title LIKE '{$n}{$term}{$n}') OR (name LIKE '{$n}{$term}{$n}') )";
|
921 |
$searchand = ' AND ';
|
922 |
}
|
923 |
-
|
924 |
$term = $wpdb->escape($request);
|
925 |
if (count($search_terms) > 1 && $search_terms[0] != $request )
|
926 |
$search .= " OR (title LIKE '{$n}{$term}{$n}') OR (name LIKE '{$n}{$term}{$n}')";
|
927 |
|
928 |
if ( !empty($search) )
|
929 |
$search = " AND ({$search}) ";
|
930 |
-
|
931 |
-
$limit = ( $limit > 0 ) ? 'LIMIT ' . intval($limit) : '';
|
932 |
} else
|
933 |
return false;
|
934 |
-
|
935 |
// build the final query
|
936 |
$query = "SELECT * FROM $wpdb->nggallery WHERE 1=1 $search ORDER BY title ASC $limit";
|
937 |
$result = $wpdb->get_results($query);
|
@@ -941,7 +941,7 @@ class nggdb {
|
|
941 |
|
942 |
/**
|
943 |
* search for albums and return the result
|
944 |
-
*
|
945 |
* @since 1.7.0
|
946 |
* @param string $request
|
947 |
* @param int $limit number of results, 0 shows all results
|
@@ -949,37 +949,37 @@ class nggdb {
|
|
949 |
*/
|
950 |
function search_for_albums( $request, $limit = 0 ) {
|
951 |
global $wpdb;
|
952 |
-
|
953 |
// If a search pattern is specified, load the posts that match
|
954 |
if ( !empty($request) ) {
|
955 |
// added slashes screw with quote grouping when done early, so done later
|
956 |
$request = stripslashes($request);
|
957 |
-
|
958 |
// split the words it a array if seperated by a space or comma
|
959 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $request, $matches);
|
960 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
961 |
-
|
962 |
$n = '%';
|
963 |
$searchand = '';
|
964 |
$search = '';
|
965 |
-
|
966 |
foreach( (array) $search_terms as $term) {
|
967 |
$term = addslashes_gpc($term);
|
968 |
$search .= "{$searchand}(name LIKE '{$n}{$term}{$n}')";
|
969 |
$searchand = ' AND ';
|
970 |
}
|
971 |
-
|
972 |
$term = $wpdb->escape($request);
|
973 |
if (count($search_terms) > 1 && $search_terms[0] != $request )
|
974 |
$search .= " OR (name LIKE '{$n}{$term}{$n}')";
|
975 |
|
976 |
if ( !empty($search) )
|
977 |
$search = " AND ({$search}) ";
|
978 |
-
|
979 |
-
$limit = ( $limit > 0 ) ? 'LIMIT ' . intval($limit) : '';
|
980 |
} else
|
981 |
return false;
|
982 |
-
|
983 |
// build the final query
|
984 |
$query = "SELECT * FROM $wpdb->nggalbum WHERE 1=1 $search ORDER BY name ASC $limit";
|
985 |
$result = $wpdb->get_results($query);
|
@@ -989,7 +989,7 @@ class nggdb {
|
|
989 |
|
990 |
/**
|
991 |
* search for a filename
|
992 |
-
*
|
993 |
* @since 1.4.0
|
994 |
* @param string $filename
|
995 |
* @param int (optional) $galleryID
|
@@ -997,19 +997,19 @@ class nggdb {
|
|
997 |
*/
|
998 |
function search_for_file( $filename, $galleryID = false ) {
|
999 |
global $wpdb;
|
1000 |
-
|
1001 |
// If a search pattern is specified, load the posts that match
|
1002 |
if ( !empty($filename) ) {
|
1003 |
// added slashes screw with quote grouping when done early, so done later
|
1004 |
$term = $wpdb->escape($filename);
|
1005 |
-
|
1006 |
$where_clause = '';
|
1007 |
if ( is_numeric($galleryID) ) {
|
1008 |
$id = (int) $galleryID;
|
1009 |
$where_clause = " AND tt.galleryid = {$id}";
|
1010 |
}
|
1011 |
}
|
1012 |
-
|
1013 |
// build the final query
|
1014 |
$query = "SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.filename = '{$term}' {$where_clause} ORDER BY tt.pid ASC ";
|
1015 |
$result = $wpdb->get_row($query);
|
@@ -1018,34 +1018,34 @@ class nggdb {
|
|
1018 |
if ($result) {
|
1019 |
$image = new nggImage( $result );
|
1020 |
return $image;
|
1021 |
-
}
|
1022 |
|
1023 |
return null;
|
1024 |
}
|
1025 |
|
1026 |
-
|
1027 |
/**
|
1028 |
* Update or add meta data for an image
|
1029 |
-
*
|
1030 |
* @since 1.4.0
|
1031 |
* @param int $id The image ID
|
1032 |
* @param array $values An array with existing or new values
|
1033 |
* @return bool result of query
|
1034 |
-
*/
|
1035 |
function update_image_meta( $id, $new_values ) {
|
1036 |
global $wpdb;
|
1037 |
-
|
1038 |
// Query database for existing values
|
1039 |
// Use cache object
|
1040 |
$old_values = $wpdb->get_var( $wpdb->prepare( "SELECT meta_data FROM $wpdb->nggpictures WHERE pid = %d ", $id ) );
|
1041 |
$old_values = unserialize( $old_values );
|
1042 |
|
1043 |
$meta = array_merge( (array)$old_values, (array)$new_values );
|
1044 |
-
|
1045 |
$result = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->nggpictures SET meta_data = %s WHERE pid = %d", serialize($meta), $id) );
|
1046 |
-
|
1047 |
wp_cache_delete($id, 'ngg_image');
|
1048 |
-
|
1049 |
return $result;
|
1050 |
}
|
1051 |
|
@@ -1060,9 +1060,9 @@ class nggdb {
|
|
1060 |
* @return string unique slug for the object, based on $slug (with a -1, -2, etc. suffix)
|
1061 |
*/
|
1062 |
function get_unique_slug( $slug, $type, $id = 0 ) {
|
1063 |
-
|
1064 |
global $wpdb;
|
1065 |
-
|
1066 |
switch ($type) {
|
1067 |
case 'image':
|
1068 |
$check_sql = "SELECT image_slug FROM $wpdb->nggpictures WHERE image_slug = %s AND NOT pid = %d LIMIT 1";
|
@@ -1076,11 +1076,11 @@ class nggdb {
|
|
1076 |
default:
|
1077 |
return false;
|
1078 |
}
|
1079 |
-
|
1080 |
//if you didn't give us a name we take the type
|
1081 |
$slug = empty($slug) ? $type: $slug;
|
1082 |
-
|
1083 |
-
// Slugs must be unique across all objects.
|
1084 |
$slug_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $id ) );
|
1085 |
|
1086 |
if ( $slug_check ) {
|
@@ -1091,8 +1091,8 @@ class nggdb {
|
|
1091 |
$suffix++;
|
1092 |
} while ( $slug_check );
|
1093 |
$slug = $alt_name;
|
1094 |
-
}
|
1095 |
-
|
1096 |
return $slug;
|
1097 |
}
|
1098 |
|
2 |
if ( !class_exists('nggdb') ) :
|
3 |
/**
|
4 |
* NextGEN Gallery Database Class
|
5 |
+
*
|
6 |
* @author Alex Rabe, Vincent Prat
|
7 |
+
*
|
8 |
* @since 1.0.0
|
9 |
*/
|
10 |
class nggdb {
|
11 |
+
|
12 |
/**
|
13 |
* Holds the list of all galleries
|
14 |
*
|
35 |
* @var object|array
|
36 |
*/
|
37 |
var $albums = false;
|
38 |
+
|
39 |
/**
|
40 |
* The array for the pagination
|
41 |
*
|
44 |
* @var array
|
45 |
*/
|
46 |
var $paged = false;
|
47 |
+
|
48 |
/**
|
49 |
* PHP4 compatibility layer for calling the PHP5 constructor.
|
50 |
+
*
|
51 |
*/
|
52 |
function nggdb() {
|
53 |
return $this->__construct();
|
55 |
|
56 |
/**
|
57 |
* Init the Database Abstraction layer for NextGEN Gallery
|
58 |
+
*
|
59 |
+
*/
|
60 |
function __construct() {
|
61 |
global $wpdb;
|
62 |
+
|
63 |
$this->galleries = array();
|
64 |
$this->images = array();
|
65 |
$this->albums = array();
|
66 |
$this->paged = array();
|
67 |
+
|
68 |
register_shutdown_function(array(&$this, '__destruct'));
|
69 |
+
|
70 |
}
|
71 |
+
|
72 |
/**
|
73 |
* PHP5 style destructor and will run when database object is destroyed.
|
74 |
*
|
76 |
*/
|
77 |
function __destruct() {
|
78 |
return true;
|
79 |
+
}
|
80 |
|
81 |
/**
|
82 |
* Get all the album and unserialize the content
|
83 |
+
*
|
84 |
* @since 1.3.0
|
85 |
* @param string $order_by
|
86 |
* @param string $order_dir
|
88 |
* @param int $start the start index for paged albums
|
89 |
* @return array $album
|
90 |
*/
|
91 |
+
function find_all_album( $order_by = 'id', $order_dir = 'ASC', $limit = 0, $start = 0) {
|
92 |
+
global $wpdb;
|
93 |
+
|
94 |
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
95 |
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
|
96 |
$this->albums = $wpdb->get_results("SELECT * FROM $wpdb->nggalbum ORDER BY {$order_by} {$order_dir} {$limit_by}" , OBJECT_K );
|
97 |
+
|
98 |
if ( !$this->albums )
|
99 |
return array();
|
100 |
+
|
101 |
foreach ($this->albums as $key => $value) {
|
102 |
$this->albums[$key]->galleries = empty ($this->albums[$key]->sortorder) ? array() : (array) unserialize($this->albums[$key]->sortorder) ;
|
103 |
+
$this->albums[$key]->name = stripslashes( $this->albums[$key]->name );
|
104 |
$this->albums[$key]->albumdesc = stripslashes( $this->albums[$key]->albumdesc );
|
105 |
+
wp_cache_add($key, $this->albums[$key], 'ngg_album');
|
106 |
}
|
107 |
+
|
108 |
return $this->albums;
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Get all the galleries
|
113 |
+
*
|
114 |
* @param string $order_by
|
115 |
* @param string $order_dir
|
116 |
* @param bool $counter (optional) Select true when you need to count the images
|
119 |
* @param bool $exclude
|
120 |
* @return array $galleries
|
121 |
*/
|
122 |
+
function find_all_galleries($order_by = 'gid', $order_dir = 'ASC', $counter = false, $limit = 0, $start = 0, $exclude = true) {
|
123 |
+
global $wpdb;
|
124 |
+
|
125 |
// Check for the exclude setting
|
126 |
$exclude_clause = ($exclude) ? ' AND exclude<>1 ' : '';
|
127 |
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
128 |
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
|
129 |
$this->galleries = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->nggallery ORDER BY {$order_by} {$order_dir} {$limit_by}", OBJECT_K );
|
130 |
+
|
131 |
// Count the number of galleries and calculate the pagination
|
132 |
if ($limit > 0) {
|
133 |
$this->paged['total_objects'] = intval ( $wpdb->get_var( "SELECT FOUND_ROWS()" ) );
|
134 |
$this->paged['objects_per_page'] = max ( count( $this->galleries ), $limit );
|
135 |
$this->paged['max_objects_per_page'] = ( $limit > 0 ) ? ceil( $this->paged['total_objects'] / intval($limit)) : 1;
|
136 |
}
|
137 |
+
|
138 |
if ( !$this->galleries )
|
139 |
return array();
|
140 |
+
|
141 |
+
// get the galleries information
|
142 |
foreach ($this->galleries as $key => $value) {
|
143 |
$galleriesID[] = $key;
|
144 |
// init the counter values
|
146 |
$this->galleries[$key]->title = stripslashes($this->galleries[$key]->title);
|
147 |
$this->galleries[$key]->galdesc = stripslashes($this->galleries[$key]->galdesc);
|
148 |
$this->galleries[$key]->abspath = WINABSPATH . $this->galleries[$key]->path;
|
149 |
+
wp_cache_add($key, $this->galleries[$key], 'ngg_gallery');
|
150 |
}
|
151 |
|
152 |
// if we didn't need to count the images then stop here
|
153 |
if ( !$counter )
|
154 |
return $this->galleries;
|
155 |
+
|
156 |
+
// get the counter values
|
157 |
$picturesCounter = $wpdb->get_results('SELECT galleryid, COUNT(*) as counter FROM '.$wpdb->nggpictures.' WHERE galleryid IN (\''.implode('\',\'', $galleriesID).'\') ' . $exclude_clause . ' GROUP BY galleryid', OBJECT_K);
|
158 |
|
159 |
if ( !$picturesCounter )
|
160 |
return $this->galleries;
|
161 |
+
|
162 |
+
// add the counter to the gallery objekt
|
163 |
foreach ($picturesCounter as $key => $value) {
|
164 |
$this->galleries[$value->galleryid]->counter = $value->counter;
|
165 |
wp_cache_set($value->galleryid, $this->galleries[$value->galleryid], 'ngg_gallery');
|
166 |
}
|
167 |
+
|
168 |
return $this->galleries;
|
169 |
}
|
170 |
+
|
171 |
/**
|
172 |
* Get a gallery given its ID
|
173 |
+
*
|
174 |
* @param int|string $id or $slug
|
175 |
* @return A nggGallery object (null if not found)
|
176 |
*/
|
177 |
+
function find_gallery( $id ) {
|
178 |
global $wpdb;
|
179 |
+
|
180 |
if( is_numeric($id) ) {
|
181 |
+
|
182 |
if ( $gallery = wp_cache_get($id, 'ngg_gallery') )
|
183 |
return $gallery;
|
184 |
+
|
185 |
$gallery = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggallery WHERE gid = %d", $id ) );
|
186 |
|
187 |
} else
|
188 |
$gallery = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggallery WHERE slug = %s", $id ) );
|
189 |
+
|
190 |
// Build the object from the query result
|
191 |
if ($gallery) {
|
192 |
// it was a bad idea to use a object, stripslashes_deep() could not used here, learn from it
|
193 |
$gallery->title = stripslashes($gallery->title);
|
194 |
$gallery->galdesc = stripslashes($gallery->galdesc);
|
195 |
+
|
196 |
$gallery->abspath = WINABSPATH . $gallery->path;
|
197 |
//TODO:Possible failure , $id could be a number or name
|
198 |
wp_cache_add($id, $gallery, 'ngg_gallery');
|
199 |
+
|
200 |
+
return $gallery;
|
201 |
+
} else
|
202 |
return false;
|
203 |
}
|
204 |
+
|
205 |
/**
|
206 |
* This function return all information about the gallery and the images inside
|
207 |
+
*
|
208 |
* @param int|string $id or $name
|
209 |
+
* @param string $order_by
|
210 |
* @param string $order_dir (ASC |DESC)
|
211 |
* @param bool $exclude
|
212 |
* @param int $limit number of paged galleries, 0 shows all galleries
|
221 |
// init the gallery as empty array
|
222 |
$gallery = array();
|
223 |
$i = 0;
|
224 |
+
|
225 |
// Check for the exclude setting
|
226 |
$exclude_clause = ($exclude) ? ' AND tt.exclude<>1 ' : '';
|
227 |
+
|
228 |
// Say no to any other value
|
229 |
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
230 |
$order_by = ( empty($order_by) ) ? 'sortorder' : $order_by;
|
231 |
+
|
232 |
// Should we limit this query ?
|
233 |
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
|
234 |
+
|
235 |
// Query database
|
236 |
if( is_numeric($id) )
|
237 |
+
$result = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = %d {$exclude_clause} ORDER BY ABS(tt.{$order_by}) {$order_dir} {$limit_by}", $id ), OBJECT_K );
|
238 |
else
|
239 |
+
$result = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.slug = %s {$exclude_clause} ORDER BY ABS(tt.{$order_by}) {$order_dir} {$limit_by}", $id ), OBJECT_K );
|
240 |
|
241 |
// Count the number of images and calculate the pagination
|
242 |
if ($limit > 0) {
|
244 |
$this->paged['objects_per_page'] = max ( count( $result ), $limit );
|
245 |
$this->paged['max_objects_per_page'] = ( $limit > 0 ) ? ceil( $this->paged['total_objects'] / intval($limit)) : 1;
|
246 |
}
|
247 |
+
|
248 |
// Build the object
|
249 |
if ($result) {
|
250 |
+
|
251 |
// Now added all image data
|
252 |
foreach ($result as $key => $value) {
|
253 |
+
// due to a browser bug we need to remove the key for associative array for json request
|
254 |
// (see http://code.google.com/p/chromium/issues/detail?id=883)
|
255 |
+
if ($json) $key = $i++;
|
256 |
$gallery[$key] = new nggImage( $value ); // keep in mind each request require 8-16 kb memory usage
|
257 |
+
|
258 |
}
|
259 |
}
|
260 |
+
|
261 |
// Could not add to cache, the structure is different to find_gallery() cache_add, need rework
|
262 |
//wp_cache_add($id, $gallery, 'ngg_gallery');
|
263 |
|
264 |
+
return $gallery;
|
265 |
}
|
266 |
+
|
267 |
/**
|
268 |
* This function return all information about the gallery and the images inside
|
269 |
+
*
|
270 |
* @param int|string $id or $name
|
271 |
+
* @param string $orderby
|
272 |
* @param string $order (ASC |DESC)
|
273 |
* @param bool $exclude
|
274 |
* @return An array containing the nggImage objects representing the images in the gallery.
|
276 |
function get_ids_from_gallery($id, $order_by = 'sortorder', $order_dir = 'ASC', $exclude = true) {
|
277 |
|
278 |
global $wpdb;
|
279 |
+
|
280 |
// Check for the exclude setting
|
281 |
$exclude_clause = ($exclude) ? ' AND tt.exclude<>1 ' : '';
|
282 |
+
|
283 |
// Say no to any other value
|
284 |
+
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
285 |
$order_by = ( empty($order_by) ) ? 'sortorder' : $order_by;
|
286 |
+
|
287 |
// Query database
|
288 |
if( is_numeric($id) )
|
289 |
$result = $wpdb->get_col( $wpdb->prepare( "SELECT tt.pid FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = %d $exclude_clause ORDER BY tt.{$order_by} $order_dir", $id ) );
|
290 |
else
|
291 |
$result = $wpdb->get_col( $wpdb->prepare( "SELECT tt.pid FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.slug = %s $exclude_clause ORDER BY tt.{$order_by} $order_dir", $id ) );
|
292 |
|
293 |
+
return $result;
|
294 |
+
}
|
295 |
+
|
296 |
/**
|
297 |
* Delete a gallery AND all the pictures associated to this gallery!
|
298 |
+
*
|
299 |
* @id The gallery ID
|
300 |
*/
|
301 |
+
function delete_gallery( $id ) {
|
302 |
global $wpdb;
|
303 |
+
|
304 |
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggpictures WHERE galleryid = %d", $id) );
|
305 |
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggallery WHERE gid = %d", $id) );
|
306 |
+
|
307 |
wp_cache_delete($id, 'ngg_gallery');
|
308 |
+
|
309 |
//TODO:Remove all tag relationship
|
310 |
return true;
|
311 |
}
|
312 |
|
313 |
/**
|
314 |
* Get an album given its ID
|
315 |
+
*
|
316 |
* @id The album ID or name
|
317 |
* @return A nggGallery object (false if not found)
|
318 |
*/
|
319 |
+
function find_album( $id ) {
|
320 |
global $wpdb;
|
321 |
+
|
322 |
// Query database
|
323 |
if ( is_numeric($id) && $id != 0 ) {
|
324 |
if ( $album = wp_cache_get($id, 'ngg_album') )
|
325 |
return $album;
|
326 |
+
|
327 |
$album = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggalbum WHERE id = %d", $id) );
|
328 |
} elseif ( $id == 'all' || (is_numeric($id) && $id == 0) ) {
|
329 |
// init the object and fill it
|
336 |
} else {
|
337 |
$album = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->nggalbum WHERE slug = %s", $id) );
|
338 |
}
|
339 |
+
|
340 |
// Unserialize the galleries inside the album
|
341 |
if ( $album ) {
|
342 |
+
if ( !empty( $album->sortorder ) )
|
343 |
$album->gallery_ids = unserialize( $album->sortorder );
|
344 |
+
|
345 |
// it was a bad idea to use a object, stripslashes_deep() could not used here, learn from it
|
346 |
$album->albumdesc = stripslashes($album->albumdesc);
|
347 |
$album->name = stripslashes($album->name);
|
348 |
+
|
349 |
+
wp_cache_add($album->id, $album, 'ngg_album');
|
350 |
return $album;
|
351 |
+
}
|
352 |
+
|
353 |
return false;
|
354 |
}
|
355 |
+
|
356 |
/**
|
357 |
* Delete an album
|
358 |
+
*
|
359 |
* @id The album ID
|
360 |
*/
|
361 |
+
function delete_album( $id ) {
|
362 |
global $wpdb;
|
363 |
+
|
364 |
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggalbum WHERE id = %d", $id) );
|
365 |
wp_cache_delete($id, 'ngg_album');
|
366 |
+
|
367 |
return $result;
|
368 |
}
|
369 |
|
370 |
/**
|
371 |
* Insert an image in the database
|
372 |
+
*
|
373 |
* @return the ID of the inserted image
|
374 |
*/
|
375 |
function insert_image($gid, $filename, $alttext, $desc, $exclude) {
|
376 |
global $wpdb;
|
377 |
+
|
378 |
$result = $wpdb->query(
|
379 |
"INSERT INTO $wpdb->nggpictures (galleryid, filename, description, alttext, exclude) VALUES "
|
380 |
. "('$gid', '$filename', '$desc', '$alttext', '$exclude');");
|
381 |
$pid = (int) $wpdb->insert_id;
|
382 |
wp_cache_delete($gid, 'ngg_gallery');
|
383 |
+
|
384 |
return $pid;
|
385 |
}
|
386 |
|
387 |
/**
|
388 |
* nggdb::update_image() - Update an image in the database
|
389 |
+
*
|
390 |
* @param int $pid id of the image
|
391 |
* @param (optional) string|int $galleryid
|
392 |
* @param (optional) string $filename
|
399 |
function update_image($pid, $galleryid = false, $filename = false, $description = false, $alttext = false, $exclude = false, $sortorder = false) {
|
400 |
|
401 |
global $wpdb;
|
402 |
+
|
403 |
$sql = array();
|
404 |
$pid = (int) $pid;
|
405 |
+
|
406 |
+
// slug must be unique, we use the alttext for that
|
407 |
$slug = nggdb::get_unique_slug( sanitize_title( $alttext ), 'image' );
|
408 |
+
|
409 |
$update = array(
|
410 |
'image_slug' => $slug,
|
411 |
'galleryid' => $galleryid,
|
414 |
'alttext' => $alttext,
|
415 |
'exclude' => $exclude,
|
416 |
'sortorder' => $sortorder);
|
417 |
+
|
418 |
// create the sql parameter "name = value"
|
419 |
foreach ($update as $key => $value)
|
420 |
if ($value !== false)
|
421 |
$sql[] = $key . " = '" . $value . "'";
|
422 |
+
|
423 |
// create the final string
|
424 |
$sql = implode(', ', $sql);
|
425 |
+
|
426 |
if ( !empty($sql) && $pid != 0)
|
427 |
$result = $wpdb->query( "UPDATE $wpdb->nggpictures SET $sql WHERE pid = $pid" );
|
428 |
+
|
429 |
+
wp_cache_delete($pid, 'ngg_image');
|
430 |
|
431 |
return $result;
|
432 |
}
|
433 |
+
|
434 |
/**
|
435 |
* nggdb::update_gallery() - Update an gallery in the database
|
436 |
+
*
|
437 |
* @since V1.7.0
|
438 |
* @param int $id id of the gallery
|
439 |
* @param (optional) string $title or name of the gallery
|
441 |
* @param (optional) string $description
|
442 |
* @param (optional) int $pageid
|
443 |
* @param (optional) int $previewpic
|
444 |
+
* @param (optional) int $author
|
445 |
* @return bool result of update query
|
446 |
*/
|
447 |
function update_gallery($id, $name = false, $path = false, $title = false, $description = false, $pageid = false, $previewpic = false, $author = false) {
|
448 |
|
449 |
global $wpdb;
|
450 |
+
|
451 |
$sql = array();
|
452 |
$id = (int) $id;
|
453 |
+
|
454 |
+
// slug must be unique, we use the title for that
|
455 |
$slug = nggdb::get_unique_slug( sanitize_title( $title ), 'gallery' );
|
456 |
+
|
457 |
$update = array(
|
458 |
'name' => $name,
|
459 |
'slug' => $slug,
|
463 |
'pageid' => $pageid,
|
464 |
'previewpic' => $previewpic,
|
465 |
'author' => $author);
|
466 |
+
|
467 |
// create the sql parameter "name = value"
|
468 |
foreach ($update as $key => $value)
|
469 |
if ($value !== false)
|
470 |
$sql[] = $key . " = '" . $value . "'";
|
471 |
+
|
472 |
// create the final string
|
473 |
$sql = implode(', ', $sql);
|
474 |
+
|
475 |
if ( !empty($sql) && $id != 0)
|
476 |
$result = $wpdb->query( "UPDATE $wpdb->nggallery SET $sql WHERE gid = $id" );
|
477 |
+
|
478 |
+
wp_cache_delete($id, 'ngg_gallery');
|
479 |
|
480 |
return $result;
|
481 |
}
|
482 |
|
483 |
/**
|
484 |
* nggdb::update_album() - Update an album in the database
|
485 |
+
*
|
486 |
* @since V1.7.0
|
487 |
* @param int $ id id of the album
|
488 |
* @param (optional) string $title
|
489 |
* @param (optional) int $previewpic
|
490 |
* @param (optional) string $description
|
491 |
+
* @param (optional) serialized array $sortorder
|
492 |
* @param (optional) int $pageid
|
493 |
* @return bool result of update query
|
494 |
*/
|
495 |
function update_album($id, $name = false, $previewpic = false, $description = false, $sortorder = false, $pageid = false ) {
|
496 |
|
497 |
global $wpdb;
|
498 |
+
|
499 |
$sql = array();
|
500 |
$id = (int) $id;
|
501 |
+
|
502 |
+
// slug must be unique, we use the title for that
|
503 |
$slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album' );
|
504 |
+
|
505 |
$update = array(
|
506 |
'name' => $name,
|
507 |
'slug' => $slug,
|
509 |
'albumdesc' => $description,
|
510 |
'sortorder' => $sortorder,
|
511 |
'pageid' => $pageid);
|
512 |
+
|
513 |
// create the sql parameter "name = value"
|
514 |
foreach ($update as $key => $value)
|
515 |
if ($value !== false)
|
516 |
$sql[] = $key . " = '" . $value . "'";
|
517 |
+
|
518 |
// create the final string
|
519 |
$sql = implode(', ', $sql);
|
520 |
+
|
521 |
if ( !empty($sql) && $id != 0)
|
522 |
$result = $wpdb->query( "UPDATE $wpdb->nggalbum SET $sql WHERE id = $id" );
|
523 |
+
|
524 |
wp_cache_delete($id, 'ngg_album');
|
525 |
|
526 |
return $result;
|
527 |
}
|
528 |
+
|
529 |
/**
|
530 |
* Get an image given its ID
|
531 |
+
*
|
532 |
* @param int|string The image ID or Slug
|
533 |
* @return object A nggImage object representing the image (false if not found)
|
534 |
*/
|
536 |
global $wpdb;
|
537 |
|
538 |
if( is_numeric($id) ) {
|
539 |
+
|
540 |
if ( $image = wp_cache_get($id, 'ngg_image') )
|
541 |
return $image;
|
542 |
+
|
543 |
$result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.pid = %d ", $id ) );
|
544 |
} else
|
545 |
+
$result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.*, t.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.image_slug = %s ", $id ) );
|
546 |
+
|
547 |
// Build the object from the query result
|
548 |
if ($result) {
|
549 |
$image = new nggImage($result);
|
550 |
return $image;
|
551 |
+
}
|
552 |
+
|
553 |
return false;
|
554 |
}
|
555 |
+
|
556 |
/**
|
557 |
+
* Get images given a list of IDs
|
558 |
+
*
|
559 |
* @param $pids array of picture_ids
|
560 |
* @return An array of nggImage objects representing the images
|
561 |
*/
|
562 |
function find_images_in_list( $pids, $exclude = false, $order = 'ASC' ) {
|
563 |
global $wpdb;
|
564 |
+
|
565 |
$result = array();
|
566 |
+
|
567 |
// Check for the exclude setting
|
568 |
$exclude_clause = ($exclude) ? ' AND t.exclude <> 1 ' : '';
|
569 |
|
570 |
// Check for the exclude setting
|
571 |
$order_clause = ($order == 'RAND') ? 'ORDER BY rand() ' : ' ORDER BY t.pid ASC' ;
|
572 |
+
|
573 |
if ( is_array($pids) ) {
|
574 |
$id_list = "'" . implode("', '", $pids) . "'";
|
575 |
+
|
576 |
// Save Query database
|
577 |
$images = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggpictures AS t INNER JOIN $wpdb->nggallery AS tt ON t.galleryid = tt.gid WHERE t.pid IN ($id_list) $exclude_clause $order_clause", OBJECT_K);
|
578 |
+
|
579 |
// Build the image objects from the query result
|
580 |
+
if ($images) {
|
581 |
+
foreach ($images as $key => $image)
|
582 |
$result[$key] = new nggImage( $image );
|
583 |
+
}
|
584 |
}
|
585 |
return $result;
|
586 |
}
|
587 |
|
588 |
/**
|
589 |
* Add an image to the database
|
590 |
+
*
|
591 |
* @since V1.4.0
|
592 |
* @param int $pid id of the gallery
|
593 |
* @param (optional) string|int $galleryid
|
603 |
*/
|
604 |
function add_image( $id = false, $filename = false, $description = '', $alttext = '', $meta_data = false, $post_id = 0, $imagedate = '0000-00-00 00:00:00', $exclude = 0, $sortorder = 0 ) {
|
605 |
global $wpdb;
|
606 |
+
|
607 |
if ( is_array($meta_data) )
|
608 |
$meta_data = serialize($meta_data);
|
609 |
|
610 |
+
// slug must be unique, we use the alttext for that
|
611 |
$slug = nggdb::get_unique_slug( sanitize_title( $alttext ), 'image' );
|
612 |
|
613 |
// Add the image
|
614 |
+
if ( false === $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggpictures (image_slug, galleryid, filename, description, alttext, meta_data, post_id, imagedate, exclude, sortorder)
|
615 |
VALUES (%s, %d, %s, %s, %s, %s, %d, %s, %d, %d)", $slug, $id, $filename, $description, $alttext, $meta_data, $post_id, $imagedate, $exclude, $sortorder ) ) ) {
|
616 |
return false;
|
617 |
}
|
618 |
+
|
619 |
$imageID = (int) $wpdb->insert_id;
|
620 |
+
|
621 |
// Remove from cache the galley, needs to be rebuild now
|
622 |
wp_cache_delete( $id, 'ngg_gallery');
|
623 |
+
|
624 |
+
//and give me the new id
|
625 |
return $imageID;
|
626 |
}
|
627 |
+
|
628 |
/**
|
629 |
* Add an album to the database
|
630 |
+
*
|
631 |
* @since V1.7.0
|
632 |
* @param (optional) string $title
|
633 |
* @param (optional) int $previewpic
|
634 |
* @param (optional) string $description
|
635 |
+
* @param (optional) serialized array $sortorder
|
636 |
* @param (optional) int $pageid
|
637 |
* @return bool result of the ID of the inserted album
|
638 |
*/
|
639 |
function add_album( $name = false, $previewpic = 0, $description = '', $sortorder = 0, $pageid = 0 ) {
|
640 |
global $wpdb;
|
641 |
+
|
642 |
+
// name must be unique, we use the title for that
|
643 |
$slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album' );
|
644 |
+
|
645 |
// Add the album
|
646 |
+
if ( false === $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggalbum (name, slug, previewpic, albumdesc, sortorder, pageid)
|
647 |
VALUES (%s, %s, %d, %s, %s, %d)", $name, $slug, $previewpic, $description, $sortorder, $pageid ) ) ) {
|
648 |
return false;
|
649 |
}
|
650 |
+
|
651 |
$albumID = (int) $wpdb->insert_id;
|
652 |
+
|
653 |
+
//and give me the new id
|
654 |
return $albumID;
|
655 |
}
|
656 |
|
657 |
/**
|
658 |
* Add an gallery to the database
|
659 |
+
*
|
660 |
* @since V1.7.0
|
661 |
* @param (optional) string $title or name of the gallery
|
662 |
* @param (optional) string $path
|
663 |
* @param (optional) string $description
|
664 |
* @param (optional) int $pageid
|
665 |
* @param (optional) int $previewpic
|
666 |
+
* @param (optional) int $author
|
667 |
* @return bool result of the ID of the inserted gallery
|
668 |
*/
|
669 |
function add_gallery( $title = '', $path = '', $description = '', $pageid = 0, $previewpic = 0, $author = 0 ) {
|
670 |
global $wpdb;
|
671 |
+
|
672 |
+
// slug must be unique, we use the title for that
|
673 |
$slug = nggdb::get_unique_slug( sanitize_title( $title ), 'gallery' );
|
674 |
+
|
675 |
// Note : The field 'name' is deprecated, it's currently kept only for compat reason with older shortcodes, we copy the slug into this field
|
676 |
+
if ( false === $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->nggallery (name, slug, path, title, galdesc, pageid, previewpic, author)
|
677 |
VALUES (%s, %s, %s, %s, %s, %d, %d, %d)", $slug, $slug, $path, $title, $description, $pageid, $previewpic, $author ) ) ) {
|
678 |
return false;
|
679 |
}
|
680 |
+
|
681 |
$galleryID = (int) $wpdb->insert_id;
|
682 |
+
|
683 |
+
//and give me the new id
|
684 |
return $galleryID;
|
685 |
}
|
686 |
+
|
687 |
/**
|
688 |
* Delete an image entry from the database
|
689 |
* @param integer $id is the Image ID
|
690 |
*/
|
691 |
function delete_image( $id ) {
|
692 |
global $wpdb;
|
693 |
+
|
694 |
// Delete the image
|
695 |
$result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->nggpictures WHERE pid = %d", $id) );
|
696 |
+
|
697 |
// Delete tag references
|
698 |
wp_delete_object_term_relationships( $id, 'ngg_tag');
|
699 |
+
|
700 |
// Remove from cache
|
701 |
+
wp_cache_delete( $id, 'ngg_image');
|
702 |
+
|
703 |
return $result;
|
704 |
}
|
705 |
+
|
706 |
/**
|
707 |
* Get the last images registered in the database with a maximum number of $limit results
|
708 |
+
*
|
709 |
* @param integer $page start offset as page number (0,1,2,3,4...)
|
710 |
* @param integer $limit the number of result
|
711 |
* @param bool $exclude do not show exluded images
|
715 |
*/
|
716 |
function find_last_images($page = 0, $limit = 30, $exclude = true, $galleryId = 0, $orderby = "id") {
|
717 |
global $wpdb;
|
718 |
+
|
719 |
// Check for the exclude setting
|
720 |
$exclude_clause = ($exclude) ? ' AND exclude<>1 ' : '';
|
721 |
+
|
722 |
// a limit of 0 makes no sense
|
723 |
$limit = ($limit == 0) ? 30 : $limit;
|
724 |
// calculate the offset based on the pagr number
|
725 |
$offset = (int) $page * $limit;
|
726 |
+
|
727 |
$galleryId = (int) $galleryId;
|
728 |
$gallery_clause = ($galleryId === 0) ? '' : ' AND galleryid = ' . $galleryId . ' ';
|
729 |
|
737 |
$order = 'sortorder ASC';
|
738 |
break;
|
739 |
}
|
740 |
+
|
741 |
$result = array();
|
742 |
$gallery_cache = array();
|
743 |
+
|
744 |
// Query database
|
745 |
$images = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures WHERE 1=1 $exclude_clause $gallery_clause ORDER BY $order LIMIT $offset, $limit");
|
746 |
+
|
747 |
// Build the object from the query result
|
748 |
+
if ($images) {
|
749 |
foreach ($images as $key => $image) {
|
750 |
+
|
751 |
// cache a gallery , so we didn't need to lookup twice
|
752 |
if (!array_key_exists($image->galleryid, $gallery_cache))
|
753 |
$gallery_cache[$image->galleryid] = nggdb::find_gallery($image->galleryid);
|
754 |
+
|
755 |
+
// Join gallery information with picture information
|
756 |
foreach ($gallery_cache[$image->galleryid] as $index => $value)
|
757 |
$image->$index = $value;
|
758 |
+
|
759 |
// Now get the complete image data
|
760 |
$result[$key] = new nggImage( $image );
|
761 |
}
|
762 |
}
|
763 |
+
|
764 |
return $result;
|
765 |
}
|
766 |
+
|
767 |
/**
|
768 |
* nggdb::get_random_images() - Get an random image from one ore more gally
|
769 |
+
*
|
770 |
* @param integer $number of images
|
771 |
* @param integer $galleryID optional a Gallery
|
772 |
* @return A nggImage object representing the image (null if not found)
|
773 |
*/
|
774 |
function get_random_images($number = 1, $galleryID = 0) {
|
775 |
global $wpdb;
|
776 |
+
|
777 |
$number = (int) $number;
|
778 |
$galleryID = (int) $galleryID;
|
779 |
$images = array();
|
780 |
+
|
781 |
// Query database
|
782 |
if ($galleryID == 0)
|
783 |
$result = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 ORDER by rand() limit $number");
|
784 |
else
|
785 |
$result = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = $galleryID AND tt.exclude != 1 ORDER by rand() limit {$number}");
|
786 |
+
|
787 |
// Return the object from the query result
|
788 |
if ($result) {
|
789 |
foreach ($result as $image) {
|
790 |
$images[] = new nggImage( $image );
|
791 |
}
|
792 |
return $images;
|
793 |
+
}
|
794 |
+
|
795 |
return null;
|
796 |
}
|
797 |
|
798 |
/**
|
799 |
* Get all the images from a given album
|
800 |
+
*
|
801 |
+
* @param object|int $album The album object or the id
|
802 |
* @param string $order_by
|
803 |
* @param string $order_dir
|
804 |
* @param bool $exclude
|
805 |
* @return An array containing the nggImage objects representing the images in the album.
|
806 |
*/
|
807 |
+
function find_images_in_album($album, $order_by = 'galleryid', $order_dir = 'ASC', $exclude = true) {
|
808 |
global $wpdb;
|
809 |
+
|
810 |
if ( !is_object($album) )
|
811 |
$album = nggdb::find_album( $album );
|
812 |
|
813 |
+
// Get gallery list
|
814 |
+
$gallery_list = implode(',', $album->gallery_ids);
|
815 |
// Check for the exclude setting
|
816 |
$exclude_clause = ($exclude) ? ' AND tt.exclude<>1 ' : '';
|
817 |
|
818 |
// Say no to any other value
|
819 |
+
$order_dir = ( $order_dir == 'DESC') ? 'DESC' : 'ASC';
|
820 |
$order_by = ( empty($order_by) ) ? 'galleryid' : $order_by;
|
821 |
+
|
822 |
+
$result = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.galleryid IN ($gallery_list) $exclude_clause ORDER BY tt.$order_by $order_dir");
|
823 |
// Return the object from the query result
|
824 |
if ($result) {
|
825 |
foreach ($result as $image) {
|
826 |
$images[] = new nggImage( $image );
|
827 |
}
|
828 |
return $images;
|
829 |
+
}
|
830 |
|
831 |
+
return null;
|
832 |
}
|
833 |
|
834 |
/**
|
835 |
* search for images and return the result
|
836 |
+
*
|
837 |
* @since 1.3.0
|
838 |
* @param string $request
|
839 |
* @param int $limit number of results, 0 shows all results
|
841 |
*/
|
842 |
function search_for_images( $request, $limit = 0 ) {
|
843 |
global $wpdb;
|
844 |
+
|
845 |
// If a search pattern is specified, load the posts that match
|
846 |
if ( !empty($request) ) {
|
847 |
// added slashes screw with quote grouping when done early, so done later
|
848 |
$request = stripslashes($request);
|
849 |
+
|
850 |
// split the words it a array if seperated by a space or comma
|
851 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $request, $matches);
|
852 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
853 |
+
|
854 |
$n = '%';
|
855 |
$searchand = '';
|
856 |
$search = '';
|
857 |
+
|
858 |
foreach( (array) $search_terms as $term) {
|
859 |
$term = addslashes_gpc($term);
|
860 |
$search .= "{$searchand}((tt.description LIKE '{$n}{$term}{$n}') OR (tt.alttext LIKE '{$n}{$term}{$n}') OR (tt.filename LIKE '{$n}{$term}{$n}'))";
|
861 |
$searchand = ' AND ';
|
862 |
}
|
863 |
+
|
864 |
$term = $wpdb->escape($request);
|
865 |
if (count($search_terms) > 1 && $search_terms[0] != $request )
|
866 |
$search .= " OR (tt.description LIKE '{$n}{$term}{$n}') OR (tt.alttext LIKE '{$n}{$term}{$n}') OR (tt.filename LIKE '{$n}{$term}{$n}')";
|
867 |
|
868 |
if ( !empty($search) )
|
869 |
$search = " AND ({$search}) ";
|
870 |
+
|
871 |
+
$limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($limit) : '';
|
872 |
} else
|
873 |
return false;
|
874 |
+
|
875 |
// build the final query
|
876 |
$query = "SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE 1=1 $search ORDER BY tt.pid ASC $limit_by";
|
877 |
$result = $wpdb->get_results($query);
|
886 |
$images[] = new nggImage( $image );
|
887 |
}
|
888 |
return $images;
|
889 |
+
}
|
890 |
|
891 |
return null;
|
892 |
}
|
893 |
|
894 |
/**
|
895 |
* search for galleries and return the result
|
896 |
+
*
|
897 |
* @since 1.7.0
|
898 |
* @param string $request
|
899 |
* @param int $limit number of results, 0 shows all results
|
901 |
*/
|
902 |
function search_for_galleries( $request, $limit = 0 ) {
|
903 |
global $wpdb;
|
904 |
+
|
905 |
// If a search pattern is specified, load the posts that match
|
906 |
if ( !empty($request) ) {
|
907 |
// added slashes screw with quote grouping when done early, so done later
|
908 |
$request = stripslashes($request);
|
909 |
+
|
910 |
// split the words it a array if seperated by a space or comma
|
911 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $request, $matches);
|
912 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
913 |
+
|
914 |
$n = '%';
|
915 |
$searchand = '';
|
916 |
$search = '';
|
917 |
+
|
918 |
foreach( (array) $search_terms as $term) {
|
919 |
$term = addslashes_gpc($term);
|
920 |
$search .= "{$searchand}((title LIKE '{$n}{$term}{$n}') OR (name LIKE '{$n}{$term}{$n}') )";
|
921 |
$searchand = ' AND ';
|
922 |
}
|
923 |
+
|
924 |
$term = $wpdb->escape($request);
|
925 |
if (count($search_terms) > 1 && $search_terms[0] != $request )
|
926 |
$search .= " OR (title LIKE '{$n}{$term}{$n}') OR (name LIKE '{$n}{$term}{$n}')";
|
927 |
|
928 |
if ( !empty($search) )
|
929 |
$search = " AND ({$search}) ";
|
930 |
+
|
931 |
+
$limit = ( $limit > 0 ) ? 'LIMIT ' . intval($limit) : '';
|
932 |
} else
|
933 |
return false;
|
934 |
+
|
935 |
// build the final query
|
936 |
$query = "SELECT * FROM $wpdb->nggallery WHERE 1=1 $search ORDER BY title ASC $limit";
|
937 |
$result = $wpdb->get_results($query);
|
941 |
|
942 |
/**
|
943 |
* search for albums and return the result
|
944 |
+
*
|
945 |
* @since 1.7.0
|
946 |
* @param string $request
|
947 |
* @param int $limit number of results, 0 shows all results
|
949 |
*/
|
950 |
function search_for_albums( $request, $limit = 0 ) {
|
951 |
global $wpdb;
|
952 |
+
|
953 |
// If a search pattern is specified, load the posts that match
|
954 |
if ( !empty($request) ) {
|
955 |
// added slashes screw with quote grouping when done early, so done later
|
956 |
$request = stripslashes($request);
|
957 |
+
|
958 |
// split the words it a array if seperated by a space or comma
|
959 |
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $request, $matches);
|
960 |
$search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
961 |
+
|
962 |
$n = '%';
|
963 |
$searchand = '';
|
964 |
$search = '';
|
965 |
+
|
966 |
foreach( (array) $search_terms as $term) {
|
967 |
$term = addslashes_gpc($term);
|
968 |
$search .= "{$searchand}(name LIKE '{$n}{$term}{$n}')";
|
969 |
$searchand = ' AND ';
|
970 |
}
|
971 |
+
|
972 |
$term = $wpdb->escape($request);
|
973 |
if (count($search_terms) > 1 && $search_terms[0] != $request )
|
974 |
$search .= " OR (name LIKE '{$n}{$term}{$n}')";
|
975 |
|
976 |
if ( !empty($search) )
|
977 |
$search = " AND ({$search}) ";
|
978 |
+
|
979 |
+
$limit = ( $limit > 0 ) ? 'LIMIT ' . intval($limit) : '';
|
980 |
} else
|
981 |
return false;
|
982 |
+
|
983 |
// build the final query
|
984 |
$query = "SELECT * FROM $wpdb->nggalbum WHERE 1=1 $search ORDER BY name ASC $limit";
|
985 |
$result = $wpdb->get_results($query);
|
989 |
|
990 |
/**
|
991 |
* search for a filename
|
992 |
+
*
|
993 |
* @since 1.4.0
|
994 |
* @param string $filename
|
995 |
* @param int (optional) $galleryID
|
997 |
*/
|
998 |
function search_for_file( $filename, $galleryID = false ) {
|
999 |
global $wpdb;
|
1000 |
+
|
1001 |
// If a search pattern is specified, load the posts that match
|
1002 |
if ( !empty($filename) ) {
|
1003 |
// added slashes screw with quote grouping when done early, so done later
|
1004 |
$term = $wpdb->escape($filename);
|
1005 |
+
|
1006 |
$where_clause = '';
|
1007 |
if ( is_numeric($galleryID) ) {
|
1008 |
$id = (int) $galleryID;
|
1009 |
$where_clause = " AND tt.galleryid = {$id}";
|
1010 |
}
|
1011 |
}
|
1012 |
+
|
1013 |
// build the final query
|
1014 |
$query = "SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.filename = '{$term}' {$where_clause} ORDER BY tt.pid ASC ";
|
1015 |
$result = $wpdb->get_row($query);
|
1018 |
if ($result) {
|
1019 |
$image = new nggImage( $result );
|
1020 |
return $image;
|
1021 |
+
}
|
1022 |
|
1023 |
return null;
|
1024 |
}
|
1025 |
|
1026 |
+
|
1027 |
/**
|
1028 |
* Update or add meta data for an image
|
1029 |
+
*
|
1030 |
* @since 1.4.0
|
1031 |
* @param int $id The image ID
|
1032 |
* @param array $values An array with existing or new values
|
1033 |
* @return bool result of query
|
1034 |
+
*/
|
1035 |
function update_image_meta( $id, $new_values ) {
|
1036 |
global $wpdb;
|
1037 |
+
|
1038 |
// Query database for existing values
|
1039 |
// Use cache object
|
1040 |
$old_values = $wpdb->get_var( $wpdb->prepare( "SELECT meta_data FROM $wpdb->nggpictures WHERE pid = %d ", $id ) );
|
1041 |
$old_values = unserialize( $old_values );
|
1042 |
|
1043 |
$meta = array_merge( (array)$old_values, (array)$new_values );
|
1044 |
+
|
1045 |
$result = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->nggpictures SET meta_data = %s WHERE pid = %d", serialize($meta), $id) );
|
1046 |
+
|
1047 |
wp_cache_delete($id, 'ngg_image');
|
1048 |
+
|
1049 |
return $result;
|
1050 |
}
|
1051 |
|
1060 |
* @return string unique slug for the object, based on $slug (with a -1, -2, etc. suffix)
|
1061 |
*/
|
1062 |
function get_unique_slug( $slug, $type, $id = 0 ) {
|
1063 |
+
|
1064 |
global $wpdb;
|
1065 |
+
|
1066 |
switch ($type) {
|
1067 |
case 'image':
|
1068 |
$check_sql = "SELECT image_slug FROM $wpdb->nggpictures WHERE image_slug = %s AND NOT pid = %d LIMIT 1";
|
1076 |
default:
|
1077 |
return false;
|
1078 |
}
|
1079 |
+
|
1080 |
//if you didn't give us a name we take the type
|
1081 |
$slug = empty($slug) ? $type: $slug;
|
1082 |
+
|
1083 |
+
// Slugs must be unique across all objects.
|
1084 |
$slug_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $id ) );
|
1085 |
|
1086 |
if ( $slug_check ) {
|
1091 |
$suffix++;
|
1092 |
} while ( $slug_check );
|
1093 |
$slug = $alt_name;
|
1094 |
+
}
|
1095 |
+
|
1096 |
return $slug;
|
1097 |
}
|
1098 |
|
lib/tags.php
CHANGED
@@ -3,34 +3,34 @@
|
|
3 |
/**
|
4 |
* Tag PHP class for the WordPress plugin NextGEN Gallery
|
5 |
* nggallery.lib.php
|
6 |
-
*
|
7 |
-
* @author Alex Rabe
|
8 |
-
*
|
9 |
-
*
|
10 |
*/
|
11 |
class nggTags {
|
12 |
-
|
13 |
/**
|
14 |
* Copy tags
|
15 |
*/
|
16 |
-
function copy_tags($src_pid, $dest_pid) {
|
17 |
$tags = wp_get_object_terms( $src_pid, 'ngg_tag', 'fields=ids' );
|
18 |
$tags = array_map('intval', $tags);
|
19 |
wp_set_object_terms( $dest_pid, $tags, 'ngg_tag', true );
|
20 |
-
|
21 |
return implode(',', $tags);
|
22 |
}
|
23 |
-
|
24 |
/**
|
25 |
* Rename tags
|
26 |
*/
|
27 |
function rename_tags($old = '', $new = '') {
|
28 |
-
|
29 |
$return_value = array(
|
30 |
'status' => 'ok',
|
31 |
'message' => ''
|
32 |
-
);
|
33 |
-
|
34 |
if ( trim( str_replace(',', '', stripslashes($new)) ) == '' ) {
|
35 |
$return_value['message'] = __('No new tag specified!', 'nggallery');
|
36 |
$return_value['status'] = 'error';
|
@@ -68,14 +68,14 @@ class nggTags {
|
|
68 |
|
69 |
// Delete old term
|
70 |
wp_delete_term( $term->term_id, 'ngg_tag' );
|
71 |
-
|
72 |
// Set objects to new term ! (Append no replace)
|
73 |
foreach ( (array) $objects_id as $object_id ) {
|
74 |
wp_set_object_terms( $object_id, $new_name, 'ngg_tag', true );
|
75 |
}
|
76 |
-
|
77 |
// Clean cache
|
78 |
-
clean_object_term_cache( $objects_id, 'ngg_tag');
|
79 |
clean_term_cache($term->term_id, 'ngg_tag');
|
80 |
|
81 |
// Increment
|
@@ -132,9 +132,9 @@ class nggTags {
|
|
132 |
nggTags::edit_tag_slug( $new_tag, $slug );
|
133 |
unset($slug);
|
134 |
}
|
135 |
-
|
136 |
// Clean cache
|
137 |
-
clean_object_term_cache( $objects_id, 'ngg_tag');
|
138 |
clean_term_cache($terms_id, 'ngg_tag');
|
139 |
|
140 |
if ( $counter == 0 ) {
|
@@ -146,10 +146,10 @@ class nggTags {
|
|
146 |
$return_value['message'] = sprintf(__('Error. No enough tags for rename. Too for merge. Choose !', 'nggallery'), $old);
|
147 |
$return_value['status'] = 'error';
|
148 |
}
|
149 |
-
|
150 |
return $return_value;
|
151 |
}
|
152 |
-
|
153 |
/**
|
154 |
* Delete tags
|
155 |
*/
|
@@ -157,8 +157,8 @@ class nggTags {
|
|
157 |
$return_value = array(
|
158 |
'status' => 'ok',
|
159 |
'message' => ''
|
160 |
-
);
|
161 |
-
|
162 |
if ( trim( str_replace(',', '', stripslashes($delete)) ) == '' ) {
|
163 |
$return_value['message'] = __('No tag specified!', 'nggallery');
|
164 |
$return_value['status'] = 'error';
|
@@ -168,14 +168,14 @@ class nggTags {
|
|
168 |
// In array + filter
|
169 |
$delete_tags = explode(',', $delete);
|
170 |
$delete_tags = array_filter($delete_tags, 'nggtags_delete_empty_element');
|
171 |
-
|
172 |
// Delete tags
|
173 |
$counter = 0;
|
174 |
foreach ( (array) $delete_tags as $tag ) {
|
175 |
$term = get_term_by('name', $tag, 'ngg_tag');
|
176 |
$term_id = (int) $term->term_id;
|
177 |
|
178 |
-
if ( $term_id != 0 ) {
|
179 |
wp_delete_term( $term_id, 'ngg_tag');
|
180 |
clean_term_cache( $term_id, 'ngg_tag');
|
181 |
$counter++;
|
@@ -188,7 +188,7 @@ class nggTags {
|
|
188 |
$return_value['message'] = sprintf(__('%1s tag(s) deleted.', 'nggallery'), $counter);
|
189 |
}
|
190 |
}
|
191 |
-
|
192 |
/**
|
193 |
* Edit tag slug given the name of the tag
|
194 |
*/
|
@@ -196,8 +196,8 @@ class nggTags {
|
|
196 |
$return_value = array(
|
197 |
'status' => 'ok',
|
198 |
'message' => ''
|
199 |
-
);
|
200 |
-
|
201 |
if ( trim( str_replace(',', '', stripslashes($slugs)) ) == '' ) {
|
202 |
$return_value['message'] = __('No new slug(s) specified!', 'nggallery');
|
203 |
$return_value['status'] = 'error';
|
@@ -231,7 +231,7 @@ class nggTags {
|
|
231 |
|
232 |
// Update term
|
233 |
wp_update_term($term->term_id, 'ngg_tag', array('slug' => $new_slug));
|
234 |
-
|
235 |
// Clean cache
|
236 |
clean_term_cache($term->term_id, 'ngg_tag');
|
237 |
}
|
@@ -242,28 +242,28 @@ class nggTags {
|
|
242 |
} else {
|
243 |
$return_value['message'] = sprintf(__('%s slug(s) edited.', 'nggallery'), $counter);
|
244 |
}
|
245 |
-
|
246 |
return $return_value;
|
247 |
}
|
248 |
-
|
249 |
/**
|
250 |
* Get a list of the tags used by the images
|
251 |
*/
|
252 |
function find_all_tags() {
|
253 |
return get_terms('ngg_tag', '');
|
254 |
}
|
255 |
-
|
256 |
/**
|
257 |
-
*
|
258 |
*/
|
259 |
function find_tags( $args = '', $skip_cache = false ) {
|
260 |
$taxonomy = 'ngg_tag';
|
261 |
-
|
262 |
if ( $skip_cache == true ) {
|
263 |
$terms = get_terms( $taxonomy, $args );
|
264 |
} else {
|
265 |
$key = md5(serialize($args));
|
266 |
-
|
267 |
// Get cache if exist
|
268 |
//--
|
269 |
if ( $cache = wp_cache_get( 'ngg_get_tags', 'nggallery' ) ) {
|
@@ -286,13 +286,13 @@ class nggTags {
|
|
286 |
$terms = apply_filters('get_tags', $terms, $args);
|
287 |
return $terms;
|
288 |
}
|
289 |
-
|
290 |
/**
|
291 |
* Get images corresponding to a list of tags
|
292 |
*/
|
293 |
/**
|
294 |
* nggTags::find_images_for_tags()
|
295 |
-
*
|
296 |
* @param mixed $taglist
|
297 |
* @param string $mode could be 'ASC' or 'RAND'
|
298 |
* @return array of images
|
@@ -300,67 +300,67 @@ class nggTags {
|
|
300 |
function find_images_for_tags($taglist, $mode = "ASC") {
|
301 |
// return the images based on the tag
|
302 |
global $wpdb;
|
303 |
-
|
304 |
// extract it into a array
|
305 |
$taglist = explode(",", $taglist);
|
306 |
-
|
307 |
if ( !is_array($taglist) )
|
308 |
$taglist = array($taglist);
|
309 |
-
|
310 |
$taglist = array_map('trim', $taglist);
|
311 |
$new_slugarray = array_map('sanitize_title', $taglist);
|
312 |
$sluglist = "'" . implode("', '", $new_slugarray) . "'";
|
313 |
-
|
314 |
//Treat % as a litteral in the database, for unicode support
|
315 |
$sluglist=str_replace("%","%%",$sluglist);
|
316 |
|
317 |
-
// first get all $term_ids with this tag
|
318 |
-
$term_ids = $wpdb->get_col( $wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE slug IN ($sluglist) ORDER BY term_id ASC "));
|
319 |
$picids = get_objects_in_term($term_ids, 'ngg_tag');
|
320 |
|
321 |
//Now lookup in the database
|
322 |
if ($mode == 'RAND')
|
323 |
$pictures = nggdb::find_images_in_list($picids, true, 'RAND' );
|
324 |
else
|
325 |
-
$pictures = nggdb::find_images_in_list($picids, true, 'ASC');
|
326 |
|
327 |
return $pictures;
|
328 |
}
|
329 |
-
|
330 |
/**
|
331 |
* Return one image based on the tag. Required for a tag based album overview
|
332 |
*/
|
333 |
function get_album_images($taglist) {
|
334 |
global $wpdb;
|
335 |
-
|
336 |
$taxonomy = 'ngg_tag';
|
337 |
|
338 |
// extract it into a array
|
339 |
$taglist = explode(',', $taglist);
|
340 |
-
|
341 |
if (!is_array($taglist)) {
|
342 |
$taglist = array($taglist);
|
343 |
}
|
344 |
-
|
345 |
$taglist = array_map('trim', $taglist);
|
346 |
$slugarray = array_map('sanitize_title', $taglist);
|
347 |
$slugarray = array_unique($slugarray);
|
348 |
|
349 |
$picarray = array();
|
350 |
|
351 |
-
foreach($slugarray as $slug) {
|
352 |
-
// get random picture of tag
|
353 |
-
$tsql = "SELECT p.*, g.*, t.*, tt.* FROM $wpdb->term_relationships AS tr";
|
354 |
-
$tsql .= " INNER JOIN $wpdb->nggpictures AS p ON (tr.object_id = p.pid)";
|
355 |
-
$tsql .= " INNER JOIN $wpdb->nggallery AS g ON (g.gid = p.galleryid)";
|
356 |
-
$tsql .= " INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)";
|
357 |
-
$tsql .= " INNER JOIN $wpdb->terms AS t ON (tt.term_id = t.term_id)";
|
358 |
-
$tsql .= " WHERE tt.taxonomy = '$taxonomy' AND t.slug = '$slug' ORDER BY rand() limit 1 ";
|
359 |
-
$pic_data = $wpdb->get_row($tsql, OBJECT);
|
360 |
-
|
361 |
-
if ($pic_data) $picarray[] = $pic_data;
|
362 |
-
}
|
363 |
-
|
364 |
return $picarray;
|
365 |
}
|
366 |
}
|
3 |
/**
|
4 |
* Tag PHP class for the WordPress plugin NextGEN Gallery
|
5 |
* nggallery.lib.php
|
6 |
+
*
|
7 |
+
* @author Alex Rabe
|
8 |
+
*
|
9 |
+
*
|
10 |
*/
|
11 |
class nggTags {
|
12 |
+
|
13 |
/**
|
14 |
* Copy tags
|
15 |
*/
|
16 |
+
function copy_tags($src_pid, $dest_pid) {
|
17 |
$tags = wp_get_object_terms( $src_pid, 'ngg_tag', 'fields=ids' );
|
18 |
$tags = array_map('intval', $tags);
|
19 |
wp_set_object_terms( $dest_pid, $tags, 'ngg_tag', true );
|
20 |
+
|
21 |
return implode(',', $tags);
|
22 |
}
|
23 |
+
|
24 |
/**
|
25 |
* Rename tags
|
26 |
*/
|
27 |
function rename_tags($old = '', $new = '') {
|
28 |
+
|
29 |
$return_value = array(
|
30 |
'status' => 'ok',
|
31 |
'message' => ''
|
32 |
+
);
|
33 |
+
|
34 |
if ( trim( str_replace(',', '', stripslashes($new)) ) == '' ) {
|
35 |
$return_value['message'] = __('No new tag specified!', 'nggallery');
|
36 |
$return_value['status'] = 'error';
|
68 |
|
69 |
// Delete old term
|
70 |
wp_delete_term( $term->term_id, 'ngg_tag' );
|
71 |
+
|
72 |
// Set objects to new term ! (Append no replace)
|
73 |
foreach ( (array) $objects_id as $object_id ) {
|
74 |
wp_set_object_terms( $object_id, $new_name, 'ngg_tag', true );
|
75 |
}
|
76 |
+
|
77 |
// Clean cache
|
78 |
+
clean_object_term_cache( $objects_id, 'ngg_tag');
|
79 |
clean_term_cache($term->term_id, 'ngg_tag');
|
80 |
|
81 |
// Increment
|
132 |
nggTags::edit_tag_slug( $new_tag, $slug );
|
133 |
unset($slug);
|
134 |
}
|
135 |
+
|
136 |
// Clean cache
|
137 |
+
clean_object_term_cache( $objects_id, 'ngg_tag');
|
138 |
clean_term_cache($terms_id, 'ngg_tag');
|
139 |
|
140 |
if ( $counter == 0 ) {
|
146 |
$return_value['message'] = sprintf(__('Error. No enough tags for rename. Too for merge. Choose !', 'nggallery'), $old);
|
147 |
$return_value['status'] = 'error';
|
148 |
}
|
149 |
+
|
150 |
return $return_value;
|
151 |
}
|
152 |
+
|
153 |
/**
|
154 |
* Delete tags
|
155 |
*/
|
157 |
$return_value = array(
|
158 |
'status' => 'ok',
|
159 |
'message' => ''
|
160 |
+
);
|
161 |
+
|
162 |
if ( trim( str_replace(',', '', stripslashes($delete)) ) == '' ) {
|
163 |
$return_value['message'] = __('No tag specified!', 'nggallery');
|
164 |
$return_value['status'] = 'error';
|
168 |
// In array + filter
|
169 |
$delete_tags = explode(',', $delete);
|
170 |
$delete_tags = array_filter($delete_tags, 'nggtags_delete_empty_element');
|
171 |
+
|
172 |
// Delete tags
|
173 |
$counter = 0;
|
174 |
foreach ( (array) $delete_tags as $tag ) {
|
175 |
$term = get_term_by('name', $tag, 'ngg_tag');
|
176 |
$term_id = (int) $term->term_id;
|
177 |
|
178 |
+
if ( $term_id != 0 ) {
|
179 |
wp_delete_term( $term_id, 'ngg_tag');
|
180 |
clean_term_cache( $term_id, 'ngg_tag');
|
181 |
$counter++;
|
188 |
$return_value['message'] = sprintf(__('%1s tag(s) deleted.', 'nggallery'), $counter);
|
189 |
}
|
190 |
}
|
191 |
+
|
192 |
/**
|
193 |
* Edit tag slug given the name of the tag
|
194 |
*/
|
196 |
$return_value = array(
|
197 |
'status' => 'ok',
|
198 |
'message' => ''
|
199 |
+
);
|
200 |
+
|
201 |
if ( trim( str_replace(',', '', stripslashes($slugs)) ) == '' ) {
|
202 |
$return_value['message'] = __('No new slug(s) specified!', 'nggallery');
|
203 |
$return_value['status'] = 'error';
|
231 |
|
232 |
// Update term
|
233 |
wp_update_term($term->term_id, 'ngg_tag', array('slug' => $new_slug));
|
234 |
+
|
235 |
// Clean cache
|
236 |
clean_term_cache($term->term_id, 'ngg_tag');
|
237 |
}
|
242 |
} else {
|
243 |
$return_value['message'] = sprintf(__('%s slug(s) edited.', 'nggallery'), $counter);
|
244 |
}
|
245 |
+
|
246 |
return $return_value;
|
247 |
}
|
248 |
+
|
249 |
/**
|
250 |
* Get a list of the tags used by the images
|
251 |
*/
|
252 |
function find_all_tags() {
|
253 |
return get_terms('ngg_tag', '');
|
254 |
}
|
255 |
+
|
256 |
/**
|
257 |
+
*
|
258 |
*/
|
259 |
function find_tags( $args = '', $skip_cache = false ) {
|
260 |
$taxonomy = 'ngg_tag';
|
261 |
+
|
262 |
if ( $skip_cache == true ) {
|
263 |
$terms = get_terms( $taxonomy, $args );
|
264 |
} else {
|
265 |
$key = md5(serialize($args));
|
266 |
+
|
267 |
// Get cache if exist
|
268 |
//--
|
269 |
if ( $cache = wp_cache_get( 'ngg_get_tags', 'nggallery' ) ) {
|
286 |
$terms = apply_filters('get_tags', $terms, $args);
|
287 |
return $terms;
|
288 |
}
|
289 |
+
|
290 |
/**
|
291 |
* Get images corresponding to a list of tags
|
292 |
*/
|
293 |
/**
|
294 |
* nggTags::find_images_for_tags()
|
295 |
+
*
|
296 |
* @param mixed $taglist
|
297 |
* @param string $mode could be 'ASC' or 'RAND'
|
298 |
* @return array of images
|
300 |
function find_images_for_tags($taglist, $mode = "ASC") {
|
301 |
// return the images based on the tag
|
302 |
global $wpdb;
|
303 |
+
|
304 |
// extract it into a array
|
305 |
$taglist = explode(",", $taglist);
|
306 |
+
|
307 |
if ( !is_array($taglist) )
|
308 |
$taglist = array($taglist);
|
309 |
+
|
310 |
$taglist = array_map('trim', $taglist);
|
311 |
$new_slugarray = array_map('sanitize_title', $taglist);
|
312 |
$sluglist = "'" . implode("', '", $new_slugarray) . "'";
|
313 |
+
|
314 |
//Treat % as a litteral in the database, for unicode support
|
315 |
$sluglist=str_replace("%","%%",$sluglist);
|
316 |
|
317 |
+
// first get all $term_ids with this tag
|
318 |
+
$term_ids = $wpdb->get_col( $wpdb->prepare("SELECT term_id FROM $wpdb->terms WHERE slug IN ($sluglist) ORDER BY term_id ASC ", NULL));
|
319 |
$picids = get_objects_in_term($term_ids, 'ngg_tag');
|
320 |
|
321 |
//Now lookup in the database
|
322 |
if ($mode == 'RAND')
|
323 |
$pictures = nggdb::find_images_in_list($picids, true, 'RAND' );
|
324 |
else
|
325 |
+
$pictures = nggdb::find_images_in_list($picids, true, 'ASC');
|
326 |
|
327 |
return $pictures;
|
328 |
}
|
329 |
+
|
330 |
/**
|
331 |
* Return one image based on the tag. Required for a tag based album overview
|
332 |
*/
|
333 |
function get_album_images($taglist) {
|
334 |
global $wpdb;
|
335 |
+
|
336 |
$taxonomy = 'ngg_tag';
|
337 |
|
338 |
// extract it into a array
|
339 |
$taglist = explode(',', $taglist);
|
340 |
+
|
341 |
if (!is_array($taglist)) {
|
342 |
$taglist = array($taglist);
|
343 |
}
|
344 |
+
|
345 |
$taglist = array_map('trim', $taglist);
|
346 |
$slugarray = array_map('sanitize_title', $taglist);
|
347 |
$slugarray = array_unique($slugarray);
|
348 |
|
349 |
$picarray = array();
|
350 |
|
351 |
+
foreach($slugarray as $slug) {
|
352 |
+
// get random picture of tag
|
353 |
+
$tsql = "SELECT p.*, g.*, t.*, tt.* FROM $wpdb->term_relationships AS tr";
|
354 |
+
$tsql .= " INNER JOIN $wpdb->nggpictures AS p ON (tr.object_id = p.pid)";
|
355 |
+
$tsql .= " INNER JOIN $wpdb->nggallery AS g ON (g.gid = p.galleryid)";
|
356 |
+
$tsql .= " INNER JOIN $wpdb->term_taxonomy AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)";
|
357 |
+
$tsql .= " INNER JOIN $wpdb->terms AS t ON (tt.term_id = t.term_id)";
|
358 |
+
$tsql .= " WHERE tt.taxonomy = '$taxonomy' AND t.slug = '$slug' ORDER BY rand() limit 1 ";
|
359 |
+
$pic_data = $wpdb->get_row($tsql, OBJECT);
|
360 |
+
|
361 |
+
if ($pic_data) $picarray[] = $pic_data;
|
362 |
+
}
|
363 |
+
|
364 |
return $picarray;
|
365 |
}
|
366 |
}
|
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 |
|
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.
|
49 |
var $dbversion = '1.8.1';
|
50 |
var $minimum_WP = '3.4';
|
51 |
var $donators = 'http://www.nextgen-gallery.com/donators.php';
|
@@ -76,16 +76,13 @@ if (!class_exists('nggLoader')) {
|
|
76 |
register_deactivation_hook( $this->plugin_name, array(&$this, 'deactivate') );
|
77 |
|
78 |
// Register a uninstall hook to remove all tables & option automatic
|
79 |
-
register_uninstall_hook( $this->plugin_name, array(
|
80 |
|
81 |
// Start this plugin once all other plugins are fully loaded
|
82 |
add_action( 'plugins_loaded', array(&$this, 'start_plugin') );
|
83 |
|
84 |
// Register_taxonomy must be used during the init
|
85 |
add_action( 'init', array(&$this, 'register_taxonomy') );
|
86 |
-
|
87 |
-
// Hook to upgrade all blogs with one click and adding a new one later
|
88 |
-
add_action( 'wpmu_upgrade_site', array(&$this, 'multisite_upgrade') );
|
89 |
add_action( 'wpmu_new_blog', array(&$this, 'multisite_new_blog'), 10, 6);
|
90 |
|
91 |
// Add a message for PHP4 Users, can disable the update message later on
|
@@ -116,9 +113,6 @@ if (!class_exists('nggLoader')) {
|
|
116 |
$this->translator = '<p class="hint">'. __('<strong>Translation by : </strong><a target="_blank" href="http://alexrabe.de/wordpress-plugins/nextgen-gallery/languages/">See here</a>', 'nggallery') . '</p>';
|
117 |
$this->translator .= '<p class="hint">'. __('<strong>This translation is not yet updated for Version 1.9.0</strong>. If you would like to help with translation, download the current po from the plugin folder and read <a href="http://alexrabe.de/wordpress-plugins/wordtube/translation-of-plugins/">here</a> how you can translate the plugin.', 'nggallery') . '</p>';
|
118 |
|
119 |
-
// Check for upgrade
|
120 |
-
$this->check_for_upgrade();
|
121 |
-
|
122 |
// Content Filters
|
123 |
add_filter('ngg_gallery_name', 'sanitize_title');
|
124 |
|
@@ -225,23 +219,6 @@ if (!class_exists('nggLoader')) {
|
|
225 |
|
226 |
}
|
227 |
|
228 |
-
function check_for_upgrade() {
|
229 |
-
|
230 |
-
// Inform about a database upgrade
|
231 |
-
if( get_option( 'ngg_db_version' ) != NGG_DBVERSION ) {
|
232 |
-
if ( isset ($_GET['page']) && $_GET['page'] == NGGFOLDER ) return;
|
233 |
-
add_action(
|
234 |
-
'admin_notices',
|
235 |
-
create_function(
|
236 |
-
'',
|
237 |
-
'echo \'<div id="message" class="error"><p><strong>' . __('Please update the database of NextGEN Gallery.', 'nggallery') . ' <a href="admin.php?page=nextgen-gallery">' . __('Click here to proceed.', 'nggallery') . '</a>' . '</strong></p></div>\';'
|
238 |
-
)
|
239 |
-
);
|
240 |
-
}
|
241 |
-
|
242 |
-
return;
|
243 |
-
}
|
244 |
-
|
245 |
function define_tables() {
|
246 |
global $wpdb;
|
247 |
|
@@ -335,8 +312,6 @@ if (!class_exists('nggLoader')) {
|
|
335 |
if ( is_admin() ) {
|
336 |
require_once (dirname (__FILE__) . '/admin/admin.php');
|
337 |
require_once (dirname (__FILE__) . '/admin/media-upload.php');
|
338 |
-
if ( defined('IS_WP_3_3') )
|
339 |
-
require_once (dirname (__FILE__) . '/admin/pointer.php');
|
340 |
$this->nggAdminPanel = new nggAdminPanel();
|
341 |
}
|
342 |
}
|
@@ -459,7 +434,7 @@ if (!class_exists('nggLoader')) {
|
|
459 |
* Removes all transients created by NextGEN. Called during activation
|
460 |
* and deactivation routines
|
461 |
*/
|
462 |
-
function remove_transients()
|
463 |
{
|
464 |
global $wpdb, $_wp_using_ext_object_cache;
|
465 |
|
@@ -496,7 +471,7 @@ if (!class_exists('nggLoader')) {
|
|
496 |
}
|
497 |
|
498 |
// Clean up transients
|
499 |
-
|
500 |
|
501 |
include_once (dirname (__FILE__) . '/admin/install.php');
|
502 |
|
@@ -508,7 +483,7 @@ if (!class_exists('nggLoader')) {
|
|
508 |
|
509 |
if ($isNetwork and $isActivation){
|
510 |
$old_blog = $wpdb->blogid;
|
511 |
-
$blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
|
512 |
foreach ($blogids as $blog_id) {
|
513 |
switch_to_blog($blog_id);
|
514 |
nggallery_install();
|
@@ -532,29 +507,17 @@ if (!class_exists('nggLoader')) {
|
|
532 |
delete_option( 'ngg_update_exists' );
|
533 |
|
534 |
// Clean up transients
|
535 |
-
|
536 |
}
|
537 |
|
538 |
function uninstall() {
|
539 |
// Clean up transients
|
540 |
-
|
541 |
|
542 |
include_once (dirname (__FILE__) . '/admin/install.php');
|
543 |
nggallery_uninstall();
|
544 |
}
|
545 |
|
546 |
-
function multisite_upgrade ( $blog_id ) {
|
547 |
-
global $wpdb;
|
548 |
-
|
549 |
-
include_once (dirname (__FILE__) . '/admin/upgrade.php');
|
550 |
-
|
551 |
-
$current_blog = $wpdb->blogid;
|
552 |
-
switch_to_blog( $blog_id );
|
553 |
-
ngg_upgrade();
|
554 |
-
switch_to_blog($current_blog);
|
555 |
-
return;
|
556 |
-
}
|
557 |
-
|
558 |
function disable_upgrade($option){
|
559 |
|
560 |
// PHP5.2 is required for NGG V1.4.0
|
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 |
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';
|
76 |
register_deactivation_hook( $this->plugin_name, array(&$this, 'deactivate') );
|
77 |
|
78 |
// Register a uninstall hook to remove all tables & option automatic
|
79 |
+
register_uninstall_hook( $this->plugin_name, array(&$this, 'uninstall') );
|
80 |
|
81 |
// Start this plugin once all other plugins are fully loaded
|
82 |
add_action( 'plugins_loaded', array(&$this, 'start_plugin') );
|
83 |
|
84 |
// Register_taxonomy must be used during the init
|
85 |
add_action( 'init', array(&$this, 'register_taxonomy') );
|
|
|
|
|
|
|
86 |
add_action( 'wpmu_new_blog', array(&$this, 'multisite_new_blog'), 10, 6);
|
87 |
|
88 |
// Add a message for PHP4 Users, can disable the update message later on
|
113 |
$this->translator = '<p class="hint">'. __('<strong>Translation by : </strong><a target="_blank" href="http://alexrabe.de/wordpress-plugins/nextgen-gallery/languages/">See here</a>', 'nggallery') . '</p>';
|
114 |
$this->translator .= '<p class="hint">'. __('<strong>This translation is not yet updated for Version 1.9.0</strong>. If you would like to help with translation, download the current po from the plugin folder and read <a href="http://alexrabe.de/wordpress-plugins/wordtube/translation-of-plugins/">here</a> how you can translate the plugin.', 'nggallery') . '</p>';
|
115 |
|
|
|
|
|
|
|
116 |
// Content Filters
|
117 |
add_filter('ngg_gallery_name', 'sanitize_title');
|
118 |
|
219 |
|
220 |
}
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
function define_tables() {
|
223 |
global $wpdb;
|
224 |
|
312 |
if ( is_admin() ) {
|
313 |
require_once (dirname (__FILE__) . '/admin/admin.php');
|
314 |
require_once (dirname (__FILE__) . '/admin/media-upload.php');
|
|
|
|
|
315 |
$this->nggAdminPanel = new nggAdminPanel();
|
316 |
}
|
317 |
}
|
434 |
* Removes all transients created by NextGEN. Called during activation
|
435 |
* and deactivation routines
|
436 |
*/
|
437 |
+
static function remove_transients()
|
438 |
{
|
439 |
global $wpdb, $_wp_using_ext_object_cache;
|
440 |
|
471 |
}
|
472 |
|
473 |
// Clean up transients
|
474 |
+
self::remove_transients();
|
475 |
|
476 |
include_once (dirname (__FILE__) . '/admin/install.php');
|
477 |
|
483 |
|
484 |
if ($isNetwork and $isActivation){
|
485 |
$old_blog = $wpdb->blogid;
|
486 |
+
$blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs", NULL));
|
487 |
foreach ($blogids as $blog_id) {
|
488 |
switch_to_blog($blog_id);
|
489 |
nggallery_install();
|
507 |
delete_option( 'ngg_update_exists' );
|
508 |
|
509 |
// Clean up transients
|
510 |
+
self::remove_transients();
|
511 |
}
|
512 |
|
513 |
function uninstall() {
|
514 |
// Clean up transients
|
515 |
+
self::remove_transients();
|
516 |
|
517 |
include_once (dirname (__FILE__) . '/admin/install.php');
|
518 |
nggallery_uninstall();
|
519 |
}
|
520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
function disable_upgrade($option){
|
522 |
|
523 |
// PHP5.2 is required for NGG V1.4.0
|
readme.txt
CHANGED
@@ -194,6 +194,12 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
|
|
194 |
|
195 |
== Changelog ==
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
= V1.9.8 - 12.05.2012 =
|
198 |
* Secured: Removed bundled version of swfupload. See fix below for SCM information.
|
199 |
* Changed: All transients created by NextGEN are flushed when the plugin is activated.
|
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 )
|
201 |
+
* Fixed: Sorting by filename now produces expected results using a natural sorting algorithm
|
202 |
+
|
203 |
= V1.9.8 - 12.05.2012 =
|
204 |
* Secured: Removed bundled version of swfupload. See fix below for SCM information.
|
205 |
* Changed: All transients created by NextGEN are flushed when the plugin is activated.
|