NextGEN Gallery – WordPress Gallery Plugin - Version 1.9.11

Version Description

  • 02.12.2013 =
  • NEW: Added the ability to detect JQuery conflicts on NGG Admin Pages and auto-resolve
  • Changed: Added "nggalbum" shortcode. Use this when Jetpack is installed.
  • Changed: Using natural sorting algorithm for alphanumeric values
  • Changed: Database schema is automatically updated when out-of-date
  • Fixed: Fixed several incompatibility issues with Jetpack
  • Fixed: Empty drop-down for "Page Link To"
  • Fixed: Alphabetical image sorting
  • Fixed: Compatibility with Arjuna X theme
  • Fixed: Creating default object from empty value on album page
  • Fixed: Compatibility issues with PHP 5.4 on album page
  • Fixed: E_DEPRECATED warning when using get_userdatabylogin() function
  • Fixed: Removed many E_NOTICE errors
  • Fixed: Correct use of register_uninstall_hook across all PHP versions
Download this release

Release Info

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

Code changes from version 1.9.10 to 1.9.11

admin/admin.php CHANGED
@@ -21,6 +21,11 @@ class nggAdminPanel{
21
  add_action('admin_print_scripts', array(&$this, 'load_scripts') );
22
  add_action('admin_print_styles', array(&$this, 'load_styles') );
23
 
 
 
 
 
 
24
  //TODO: remove after release of Wordpress 3.3
25
  add_filter('contextual_help', array(&$this, 'show_help'), 10, 2);
26
  add_filter('current_screen', array(&$this, 'edit_current_screen'));
@@ -30,6 +35,88 @@ class nggAdminPanel{
30
 
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  // integrate the menu
34
  function add_menu() {
35
 
21
  add_action('admin_print_scripts', array(&$this, 'load_scripts') );
22
  add_action('admin_print_styles', array(&$this, 'load_styles') );
23
 
24
+ // Try to detect plugins that embed their own jQuery and jQuery UI
25
+ // libraries and load them in NGG's admin pages
26
+ add_action('admin_enqueue_scripts', array(&$this, 'buffer_scripts'), 0);
27
+ add_action('admin_print_scripts', array(&$this, 'output_scripts'), PHP_INT_MAX);
28
+
29
  //TODO: remove after release of Wordpress 3.3
30
  add_filter('contextual_help', array(&$this, 'show_help'), 10, 2);
31
  add_filter('current_screen', array(&$this, 'edit_current_screen'));
35
 
36
  }
37
 
38
+ /**
39
+ * If a NGG page is being requested, we buffer any rendering of <script>
40
+ * tags to detect conflicts and remove them if need be
41
+ */
42
+ function buffer_scripts()
43
+ {
44
+ // Is this a NGG admin page?
45
+ if (isset($_REQUEST['page']) && strpos($_REQUEST['page'] ,'nggallery') !== FALSE) {
46
+ ob_start();
47
+ }
48
+ }
49
+
50
+ function output_scripts()
51
+ {
52
+ // Is this a NGG admin page?
53
+ if (isset($_REQUEST['page']) && strpos($_REQUEST['page'] ,'nggallery') !== FALSE) {
54
+ $plugin_folder = NGGFOLDER;
55
+ $skipjs_count = 0;
56
+ $html = ob_get_contents();
57
+ ob_end_clean();
58
+
59
+ if (!defined('NGG_JQUERY_CONFLICT_DETECTION')) {
60
+ define('NGG_JQUERY_CONFLICT_DETECTION', TRUE);
61
+ }
62
+
63
+ if (NGG_JQUERY_CONFLICT_DETECTION) {
64
+ // Detect custom jQuery script
65
+ if (preg_match_all("/<script.*wp-content.*jquery[-_\.](min\.)?js.*<\script>/", $html, $matches, PREG_SET_ORDER)) {
66
+ foreach ($matches as $match) {
67
+ $old_script = array_shift($match);
68
+ if (strpos($old_script, NGGFOLDER) === FALSE)
69
+ $html = str_replace($old_script, '', $html);
70
+ }
71
+ }
72
+
73
+ // Detect custom jQuery UI script and remove
74
+ if (preg_match_all("/<script.*wp-content.*jquery[-_\.]ui.*<\/script>/", $html, $matches, PREG_SET_ORDER)) {
75
+ $detected_jquery_ui = TRUE;
76
+ foreach ($matches as $match) {
77
+ $old_script = array_shift($match);
78
+ if (strpos($old_script, NGGFOLDER) === FALSE)
79
+ $html = str_replace($old_script, '', $html);
80
+ }
81
+ }
82
+
83
+ if (isset($_REQUEST['skipjs'])) {
84
+ foreach ($_REQUEST['skipjs'] as $js) {
85
+ $js = preg_quote($js);
86
+ if (preg_match_all("#<script.*{$js}.*</script>#", $html, $matches, PREG_SET_ORDER)) {
87
+ foreach ($matches as $match) {
88
+ $old_script = array_shift($match);
89
+ if (strpos($old_script, NGGFOLDER) === FALSE)
90
+ $html = str_replace($old_script, '', $html);
91
+ }
92
+ }
93
+ }
94
+ $skipjs_count = count($_REQUEST['skipjs']);
95
+ }
96
+
97
+
98
+ // Use WordPress built-in version of jQuery
99
+ $jquery_url = includes_url('js/jquery/jquery.js');
100
+ $html = implode('', array(
101
+ "<script type='text/javascript' src='{$jquery_url}'></script>\n",
102
+ "<script type='text/javascript'>window.onerror = function(msg, url, line){
103
+ console.log(msg);
104
+ if (window.location.search.length > 0) {
105
+ window.location.search += '&skipjs[{$skipjs_count}]='+url;
106
+ }
107
+ else {
108
+ window.location.search = '?skipjs[{$skipjs_count}]='+url;
109
+ }
110
+ return true;
111
+ };</script>\n",
112
+ $html
113
+ ));
114
+ }
115
+
116
+ echo $html;
117
+ }
118
+ }
119
+
120
  // integrate the menu
121
  function add_menu() {
122
 
admin/css/menu.css CHANGED
@@ -1,3 +1,3 @@
1
- #icon-nextgen-gallery {
2
- background:url("../images/nextgen_32_grey.png") no-repeat scroll 1px 1px transparent;
3
  }
1
+ #icon-nextgen-gallery {
2
+ background:url("../images/nextgen_32_grey.png") no-repeat scroll 1px 1px transparent;
3
  }
admin/css/nggColorPicker.css CHANGED
@@ -1,14 +1,14 @@
1
- #colorSelector{
2
- background:transparent url(../images/select.png) repeat scroll 0 0;
3
- height:36px;
4
- position:relative;
5
- width:36px;
6
- }
7
- #colorSelector div{
8
- background:transparent url(../images/select.png) repeat scroll center center;
9
- height:30px;
10
- left:3px;
11
- position:absolute;
12
- top:3px;
13
- width:30px;
14
  }
1
+ #colorSelector{
2
+ background:transparent url(../images/select.png) repeat scroll 0 0;
3
+ height:36px;
4
+ position:relative;
5
+ width:36px;
6
+ }
7
+ #colorSelector div{
8
+ background:transparent url(../images/select.png) repeat scroll center center;
9
+ height:30px;
10
+ left:3px;
11
+ position:absolute;
12
+ top:3px;
13
+ width:30px;
14
  }
admin/css/nggadmin.css CHANGED
@@ -1,409 +1,412 @@
1
- /*
2
- ** NextGEN Gallery Style for Wordpress 3.3
3
- */
4
-
5
- /* SETTINGS FOR Overview Gallery */
6
-
7
- #newversion {
8
- border-color:#CCCCCC;
9
- border-style:solid;
10
- border-width:1px;
11
- margin-right:7px;
12
- margin-top:10px;
13
- padding:2px;
14
- }
15
-
16
- .ngg-dashboard-widget ul.settings span {
17
- padding-left : 10px;
18
- color:#2583AD;
19
- font-weight:bold;
20
- }
21
-
22
- .ngg-overview .postbox .handlediv {
23
- float:right;
24
- height:24px;
25
- width:24px;
26
- }
27
-
28
- .warning {
29
- color: #9F6000;
30
- background-color: #FEEFB3;
31
- border: 1px solid;
32
- margin: 5px 0px;
33
- padding:5px;
34
- }
35
-
36
- #donator_message {
37
- margin:5px 0 15px;
38
- background-color:#BDE5F8;
39
- border-color:#00529B;
40
- -moz-border-radius-bottomleft:3px;
41
- -moz-border-radius-bottomright:3px;
42
- -moz-border-radius-topleft:3px;
43
- -moz-border-radius-topright:3px;
44
- border-style:solid;
45
- border-width:1px;
46
- margin:5px 15px 2px;
47
- padding:0 0.6em;
48
- }
49
-
50
- #donator_message p{
51
- line-height:1;
52
- margin:0.5em 0;
53
- padding:2px;
54
- padding-bottom:10px;
55
- }
56
-
57
- #donator_message span{
58
- padding-top:10px;
59
- float:right;
60
- }
61
-
62
- #plugin_check img {
63
- float: right;
64
- }
65
-
66
- #plugin_check p.message {
67
- font-size: 90%;
68
- color: #666;
69
- }
70
- /* SETTING FOR FLASH UPLOAD BUTTON */
71
- .swfupload {
72
- position:absolute;
73
- z-index:1;
74
- vertical-align:top;
75
- }
76
-
77
- /* SETTINGS FOR THE OPTIONS TABLE */
78
- .ngg-options th {
79
- width:22%;
80
- }
81
-
82
- a.switch-expert {
83
- text-decoration:none;
84
- }
85
-
86
- /* WATERMARK */
87
- #wm-preview {
88
- float:right;
89
- font-size:90%;
90
- width:35%;
91
- border-color:#EBEBEB rgb(204, 204, 204) rgb(204, 204, 204) rgb(235, 235, 235);
92
- border-style:solid;
93
- border-width:1px;
94
- margin-bottom:10px;
95
- margin-left:10px;
96
- margin-right:8px;
97
- padding:2px;
98
- }
99
- #wm-preview h3{
100
- background:#F9F9F9 none repeat scroll 0%;
101
- font-size:14px;
102
- font-weight:bold;
103
- margin:0pt 0pt 10px;
104
- padding:8px 5px;
105
- }
106
-
107
- #wm-position {
108
- width:100%;
109
- margin-left:40px;
110
- }
111
-
112
- .wm-table {
113
- border-collapse:collapse;
114
- margin-top:1em;
115
- width: 60%;
116
- clear:none;
117
- }
118
- .wm-table td {
119
- border-bottom:8px solid #FFFFFF;
120
- line-height:20px;
121
- margin-bottom:9px;
122
- padding:10px;
123
- }
124
- .wm-table th {
125
- border-bottom:8px solid #FFFFFF;
126
- padding:10px;
127
- text-align:left;
128
- }
129
- .wm-table tr {
130
- background:#F9F9F9 none repeat scroll 0%;
131
- }
132
-
133
- /* SETTINGS FOR MANAGE TABLE */
134
-
135
- div#poststuff #gallerydiv {
136
- cursor:pointer;
137
- }
138
-
139
- p#ngg-inlinebutton {
140
- float:right;
141
- margin:0pt;
142
- position:relative;
143
- top:-25pt;
144
- }
145
-
146
- .fixed tbody th.column-cb {
147
- padding:7px 0 22px;
148
- }
149
-
150
- .fixed .column-thumbnail{
151
- width:85px;
152
- }
153
-
154
- .fixed .column-thumbnail img{
155
- max-height:80px;
156
- max-width:80px;
157
- }
158
-
159
- .fixed .column-id {
160
- width: 5em;
161
- }
162
-
163
- .fixed .column-title {
164
- width: 25%;
165
- }
166
-
167
- .fixed .column-description {
168
- width: 40%;
169
- }
170
-
171
- .fixed .column-exclude, .fixed .column-action, .fixed .column-delete {
172
- width: 10%;
173
- }
174
-
175
- /* SETTINGS FOR PROGRESS BAR */
176
-
177
- div .progressborder {
178
- border:1px solid #DDDDDD;
179
- display: block;
180
- height: 30px;
181
- background-color: #464646;
182
- width: 100%;
183
- margin-top: 15px;
184
- margin-bottom: 15px;
185
- -moz-border-radius: 5px;
186
- -webkit-border-radius: 5px;
187
- border-radius: 5px;
188
- }
189
-
190
- div .progressbar {
191
- border: medium none ;
192
- display: block;
193
- height: 30px;
194
- background-color: #D54E21;
195
- width: 0%;
196
- -moz-border-radius: 5px;
197
- -webkit-border-radius: 5px;
198
- border-radius: 5px;
199
- }
200
-
201
- div .progressbar span {
202
- display: inline;
203
- position: absolute;
204
- color: white;
205
- font-weight: bold;
206
- padding: 5px 0 0 5px;
207
- }
208
-
209
- .show_details
210
- {
211
- height: 16px;
212
- line-height: 20px;
213
- overflow: hidden;
214
- min-width: 8em;
215
- padding: 3px;
216
- cursor:pointer;
217
- }
218
-
219
- .show_details span
220
- {
221
- border-bottom:1px solid #999;
222
- white-space:pre;
223
- }
224
- .show_details:hover
225
- {
226
- height: auto;
227
- overflow: visible;
228
- border: 1px solid #999;
229
- }
230
-
231
- /* SETTINGS FOR ALBUM PAGE */
232
-
233
- .albumnav select[name="act_album"] {
234
- width:150px;
235
- }
236
-
237
- .albumnav span {
238
- padding-left: 50px;
239
- }
240
-
241
- div .groupItem
242
- {
243
- cursor: move;
244
- width: 295px;
245
- padding: 5px;
246
- line-height: 1.5;
247
- }
248
-
249
- div .innerhandle {
250
- background-color:#FBFBFB;
251
- }
252
-
253
- .groupItem .item_top
254
- {
255
- background-color:#2683AE;
256
- color: #FFFFFF;
257
- font-weight:bold;
258
- line-height: 28px;
259
- height: 28px;
260
- padding: 0 5px;
261
- -moz-border-radius: 3px;
262
- -khtml-border-radius: 3px;
263
- -webkit-border-radius: 3px;
264
- border-radius: 3px;
265
- }
266
-
267
- .groupItem .album_obj
268
- {
269
- background-color:#D54E21;
270
- }
271
-
272
- .groupItem .item_top a
273
- {
274
- color:#FFFFFF;
275
- float:right;
276
- text-decoration: none;
277
- }
278
-
279
- .groupItem .item_top a:hover
280
- {
281
- color:#FFFFFF;
282
- }
283
-
284
- .itemContent {
285
- border-color:#DFDFDF;
286
- border-style:none solid solid;
287
- border-width:0 1px 1px;
288
- padding:2px 0 20px 2px;
289
- }
290
-
291
- .itemContent p {
292
- border: 0;
293
- margin: 0;
294
- padding: 0;
295
- }
296
-
297
- .inlinepicture
298
- {
299
- float:left;
300
- display:inline;
301
- margin:0pt;
302
- padding:0pt 3px 1px;
303
- }
304
-
305
- .inlinepicture img
306
- {
307
- margin:3px;
308
- max-height:60px;
309
- }
310
-
311
- .sort_placeholder
312
- {
313
- border:1px dashed #bba !important;
314
- margin: 5px;
315
- background: #F9F9F9;
316
- }
317
-
318
- .container {
319
- margin-top: 10px;
320
- }
321
-
322
- .target-album {
323
- margin:10px 685px 10px 10px;
324
- }
325
-
326
- .widget-right {
327
- float:right;
328
- margin:0pt 10px;
329
- width:315px;
330
- }
331
-
332
- .widget-holder {
333
- min-height: 400px;
334
- padding-top:1px;
335
- }
336
-
337
- .target {
338
- background-color:#F1F1F1;
339
- }
340
-
341
- div.widget-top h3 {
342
- text-align:center;
343
- line-height:25px;
344
- margin: 0;
345
- padding: 5px 12px;
346
- font-size: 13px;
347
- }
348
-
349
- div.widget-top {
350
- text-shadow:0 1px 0 #FFFFFF;
351
- background-repeat: repeat-x;
352
- background-position: 0 0;
353
- font-size: 13px;
354
- }
355
-
356
- .ui-autocomplete-start { background-position: 99% center; }
357
-
358
- /* SETTINGS FOR SORT GALLERY */
359
-
360
- #sortGallery {
361
- position:relative;
362
- }
363
-
364
- p#sortButton{
365
- margin:0;
366
- position:absolute;
367
- right:0;
368
- top:0;
369
- }
370
-
371
- .imageBox,.imageBoxHighlighted{
372
- width:130px; /* Total width of each image box */
373
- height:160px; /* Total height of each image box */
374
- float:left;
375
- }
376
- .imageBox_theImage{
377
- width:110px; /* Width of image */
378
- height:125px; /* Height of image */
379
-
380
- background-position: center;
381
- background-repeat: no-repeat;
382
- margin: 0 auto;
383
- margin-bottom:2px;
384
- }
385
-
386
- .imageBox_label{ /* Title of images - both selected and not selected */
387
- text-align:center;
388
- font-family: arial;
389
- font-size:11px;
390
- padding-top:2px;
391
- margin: 0 auto;
392
- }
393
-
394
- /* UPGRADE PAGE */
395
-
396
- .error_inline {
397
- background:#FFEBE8 none repeat scroll 0%;
398
- border:1px solid #CC0000;
399
- margin:5px auto;
400
- padding:10px;
401
- }
402
-
403
- /* ABOUT PAGE */
404
- .ngg-list {
405
- font-size:11px;
406
- margin-left:15px;
407
- list-style-position:inside;
408
- list-style-type:disc;
409
- }
 
 
 
1
+ /*
2
+ ** NextGEN Gallery Style for Wordpress 3.3
3
+ */
4
+
5
+ /* SETTINGS FOR Overview Gallery */
6
+
7
+ #newversion {
8
+ border-color:#CCCCCC;
9
+ border-style:solid;
10
+ border-width:1px;
11
+ margin-right:7px;
12
+ margin-top:10px;
13
+ padding:2px;
14
+ }
15
+
16
+ .ngg-dashboard-widget ul.settings span {
17
+ padding-left : 10px;
18
+ color:#2583AD;
19
+ font-weight:bold;
20
+ }
21
+
22
+ .ngg-overview .postbox .handlediv {
23
+ float:right;
24
+ height:24px;
25
+ width:24px;
26
+ }
27
+
28
+ .warning {
29
+ color: #9F6000;
30
+ background-color: #FEEFB3;
31
+ border: 1px solid;
32
+ margin: 5px 0px;
33
+ padding:5px;
34
+ }
35
+
36
+ #donator_message {
37
+ margin:5px 0 15px;
38
+ background-color:#BDE5F8;
39
+ border-color:#00529B;
40
+ -moz-border-radius-bottomleft:3px;
41
+ -moz-border-radius-bottomright:3px;
42
+ -moz-border-radius-topleft:3px;
43
+ -moz-border-radius-topright:3px;
44
+ border-style:solid;
45
+ border-width:1px;
46
+ margin:5px 15px 2px;
47
+ padding:0 0.6em;
48
+ }
49
+
50
+ #donator_message p{
51
+ line-height:1;
52
+ margin:0.5em 0;
53
+ padding:2px;
54
+ padding-bottom:10px;
55
+ }
56
+
57
+ #donator_message span{
58
+ padding-top:10px;
59
+ float:right;
60
+ }
61
+
62
+ #plugin_check img {
63
+ float: right;
64
+ }
65
+
66
+ #plugin_check p.message {
67
+ font-size: 90%;
68
+ color: #666;
69
+ }
70
+ /* SETTING FOR FLASH UPLOAD BUTTON */
71
+ .swfupload {
72
+ position:absolute;
73
+ z-index:1;
74
+ vertical-align:top;
75
+ }
76
+
77
+ /* SETTINGS FOR THE OPTIONS TABLE */
78
+ .ngg-options th {
79
+ width:22%;
80
+ }
81
+
82
+ a.switch-expert {
83
+ text-decoration:none;
84
+ }
85
+
86
+ /* WATERMARK */
87
+ #wm-preview {
88
+ float:right;
89
+ font-size:90%;
90
+ width:35%;
91
+ border-color:#EBEBEB rgb(204, 204, 204) rgb(204, 204, 204) rgb(235, 235, 235);
92
+ border-style:solid;
93
+ border-width:1px;
94
+ margin-bottom:10px;
95
+ margin-left:10px;
96
+ margin-right:8px;
97
+ padding:2px;
98
+ }
99
+ #wm-preview h3{
100
+ background:#F9F9F9 none repeat scroll 0%;
101
+ font-size:14px;
102
+ font-weight:bold;
103
+ margin:0pt 0pt 10px;
104
+ padding:8px 5px;
105
+ }
106
+
107
+ #wm-position {
108
+ width:100%;
109
+ margin-left:40px;
110
+ }
111
+
112
+ .wm-table {
113
+ border-collapse:collapse;
114
+ margin-top:1em;
115
+ width: 60%;
116
+ clear:none;
117
+ }
118
+ .wm-table td {
119
+ border-bottom:8px solid #FFFFFF;
120
+ line-height:20px;
121
+ margin-bottom:9px;
122
+ padding:10px;
123
+ }
124
+ .wm-table th {
125
+ border-bottom:8px solid #FFFFFF;
126
+ padding:10px;
127
+ text-align:left;
128
+ }
129
+ .wm-table tr {
130
+ background:#F9F9F9 none repeat scroll 0%;
131
+ }
132
+
133
+ /* SETTINGS FOR MANAGE TABLE */
134
+
135
+ div#poststuff #gallerydiv {
136
+ cursor:pointer;
137
+ }
138
+
139
+ p#ngg-inlinebutton {
140
+ float:right;
141
+ margin:0pt;
142
+ position:relative;
143
+ top:-25pt;
144
+ }
145
+
146
+ .fixed tbody th.column-cb {
147
+ padding:7px 0 22px;
148
+ }
149
+
150
+ .fixed .column-thumbnail{
151
+ width:85px;
152
+ }
153
+
154
+ .fixed .column-thumbnail img{
155
+ max-height:80px;
156
+ max-width:80px;
157
+ }
158
+
159
+ .fixed .column-id {
160
+ width: 5em;
161
+ }
162
+
163
+ .fixed .column-title {
164
+ width: 25%;
165
+ }
166
+
167
+ .fixed .column-description {
168
+ width: 40%;
169
+ }
170
+
171
+ .fixed .column-exclude, .fixed .column-action, .fixed .column-delete {
172
+ width: 10%;
173
+ }
174
+
175
+ /* SETTINGS FOR PROGRESS BAR */
176
+
177
+ div .progressborder {
178
+ border:1px solid #DDDDDD;
179
+ display: block;
180
+ height: 30px;
181
+ background-color: #464646;
182
+ width: 100%;
183
+ margin-top: 15px;
184
+ margin-bottom: 15px;
185
+ -moz-border-radius: 5px;
186
+ -webkit-border-radius: 5px;
187
+ border-radius: 5px;
188
+ }
189
+
190
+ div .progressbar {
191
+ border: medium none ;
192
+ display: block;
193
+ height: 30px;
194
+ background-color: #D54E21;
195
+ width: 0%;
196
+ -moz-border-radius: 5px;
197
+ -webkit-border-radius: 5px;
198
+ border-radius: 5px;
199
+ }
200
+
201
+ div .progressbar span {
202
+ display: inline;
203
+ position: absolute;
204
+ color: white;
205
+ font-weight: bold;
206
+ padding: 5px 0 0 5px;
207
+ }
208
+
209
+ .show_details
210
+ {
211
+ height: 16px;
212
+ line-height: 20px;
213
+ overflow: hidden;
214
+ min-width: 8em;
215
+ padding: 3px;
216
+ cursor:pointer;
217
+ }
218
+
219
+ .show_details span
220
+ {
221
+ border-bottom:1px solid #999;
222
+ white-space:pre;
223
+ }
224
+ .show_details:hover
225
+ {
226
+ height: auto;
227
+ overflow: visible;
228
+ border: 1px solid #999;
229
+ }
230
+
231
+ /* SETTINGS FOR ALBUM PAGE */
232
+
233
+ .albumnav select[name="act_album"] {
234
+ width:150px;
235
+ }
236
+
237
+ .albumnav span {
238
+ padding-left: 50px;
239
+ }
240
+
241
+ div .groupItem
242
+ {
243
+ cursor: move;
244
+ width: 295px;
245
+ padding: 5px;
246
+ line-height: 1.5;
247
+ }
248
+
249
+ div .innerhandle {
250
+ background-color:#FBFBFB;
251
+ }
252
+
253
+ .groupItem .item_top
254
+ {
255
+ background-color:#2683AE;
256
+ color: #FFFFFF;
257
+ font-weight:bold;
258
+ line-height: 28px;
259
+ height: 28px;
260
+ padding: 0 5px;
261
+ -moz-border-radius: 3px;
262
+ -khtml-border-radius: 3px;
263
+ -webkit-border-radius: 3px;
264
+ border-radius: 3px;
265
+ }
266
+
267
+ .groupItem .album_obj
268
+ {
269
+ background-color:#D54E21;
270
+ }
271
+
272
+ .groupItem .item_top a
273
+ {
274
+ color:#FFFFFF;
275
+ float:right;
276
+ text-decoration: none;
277
+ }
278
+
279
+ .groupItem .item_top a:hover
280
+ {
281
+ color:#FFFFFF;
282
+ }
283
+
284
+ .itemContent {
285
+ border-color:#DFDFDF;
286
+ border-style:none solid solid;
287
+ border-width:0 1px 1px;
288
+ padding:2px 0 20px 2px;
289
+ }
290
+
291
+ .itemContent p {
292
+ border: 0;
293
+ margin: 0;
294
+ padding: 0;
295
+ }
296
+
297
+ .inlinepicture
298
+ {
299
+ float:left;
300
+ display:inline;
301
+ margin:0pt;
302
+ padding:0pt 3px 1px;
303
+ }
304
+
305
+ .inlinepicture img
306
+ {
307
+ margin:3px;
308
+ max-height:60px;
309
+ }
310
+
311
+ .sort_placeholder
312
+ {
313
+ border:1px dashed #bba !important;
314
+ margin: 5px;
315
+ background: #F9F9F9;
316
+ }
317
+
318
+ .container {
319
+ margin-top: 10px;
320
+ }
321
+
322
+ .target-album {
323
+ margin:10px 685px 10px 10px;
324
+ }
325
+
326
+ .widget-right {
327
+ float:right;
328
+ margin:0pt 10px;
329
+ width:315px;
330
+ }
331
+
332
+ .widget-holder {
333
+ min-height: 400px;
334
+ padding-top:1px;
335
+ }
336
+
337
+ .target {
338
+ background-color:#F1F1F1;
339
+ }
340
+
341
+ div.widget-top h3 {
342
+ text-align:center;
343
+ line-height:25px;
344
+ margin: 0;
345
+ padding: 5px 12px;
346
+ font-size: 13px;
347
+ }
348
+
349
+ div.widget-top {
350
+ text-shadow:0 1px 0 #FFFFFF;
351
+ background-repeat: repeat-x;
352
+ background-position: 0 0;
353
+ font-size: 13px;
354
+ }
355
+
356
+ .ui-autocomplete-start { background-position: 99% center; }
357
+
358
+ /* SETTINGS FOR SORT GALLERY */
359
+
360
+ #sortGallery {
361
+ position:relative;
362
+ }
363
+
364
+ p#sortButton{
365
+ margin:0;
366
+ position:absolute;
367
+ right:0;
368
+ top:0;
369
+ }
370
+
371
+ .imageBox,.imageBoxHighlighted{
372
+ width:130px; /* Total width of each image box */
373
+ height:160px; /* Total height of each image box */
374
+ float:left;
375
+ overflow: hidden;
376
+ text-overflow: ellipsis;
377
+ padding: 5px;
378
+ }
379
+ .imageBox_theImage{
380
+ width:110px; /* Width of image */
381
+ height:125px; /* Height of image */
382
+
383
+ background-position: center;
384
+ background-repeat: no-repeat;
385
+ margin: 0 auto;
386
+ margin-bottom:2px;
387
+ }
388
+
389
+ .imageBox_label{ /* Title of images - both selected and not selected */
390
+ text-align:center;
391
+ font-family: arial;
392
+ font-size:11px;
393
+ padding-top:2px;
394
+ margin: 0 auto;
395
+ }
396
+
397
+ /* UPGRADE PAGE */
398
+
399
+ .error_inline {
400
+ background:#FFEBE8 none repeat scroll 0%;
401
+ border:1px solid #CC0000;
402
+ margin:5px auto;
403
+ padding:10px;
404
+ }
405
+
406
+ /* ABOUT PAGE */
407
+ .ngg-list {
408
+ font-size:11px;
409
+ margin-left:15px;
410
+ list-style-position:inside;
411
+ list-style-type:disc;
412
+ }
admin/css/tags-admin.css CHANGED
@@ -1,10 +1,10 @@
1
- .ngg_wrap .auto_list{width:98%;margin:3px 0;padding:3px 5px;}
2
- .ngg_wrap .list_tags {width:240px;vertical-align:top;}
3
- .ngg_wrap .forms_manage {vertical-align:top;}
4
- .ngg_wrap .forms_manage h3 {margin-bottom:5px;}
5
- .ngg_wrap .forms_manage .form-table {margin-top:0;}
6
- .ngg_wrap .sort_order h3 {margin:0;}
7
- .ngg_wrap #ajax_area_tagslist {}
8
- .ngg_wrap #ajax_area_tagslist ul{list-style:square;margin:10px 0 10px 20px;padding:0;}
9
- .ngg_wrap #ajax_area_tagslist ul li{margin:0;padding:0;line-height:1.4;}
10
  .ngg_wrap #ajax_area_tagslist ul li span{cursor:pointer;}
1
+ .ngg_wrap .auto_list{width:98%;margin:3px 0;padding:3px 5px;}
2
+ .ngg_wrap .list_tags {width:240px;vertical-align:top;}
3
+ .ngg_wrap .forms_manage {vertical-align:top;}
4
+ .ngg_wrap .forms_manage h3 {margin-bottom:5px;}
5
+ .ngg_wrap .forms_manage .form-table {margin-top:0;}
6
+ .ngg_wrap .sort_order h3 {margin:0;}
7
+ .ngg_wrap #ajax_area_tagslist {}
8
+ .ngg_wrap #ajax_area_tagslist ul{list-style:square;margin:10px 0 10px 20px;padding:0;}
9
+ .ngg_wrap #ajax_area_tagslist ul li{margin:0;padding:0;line-height:1.4;}
10
  .ngg_wrap #ajax_area_tagslist ul li span{cursor:pointer;}
admin/install.php CHANGED
@@ -51,61 +51,51 @@ function nggallery_install () {
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 ,
60
- post_id BIGINT(20) DEFAULT '0' NOT NULL ,
61
- galleryid BIGINT(20) DEFAULT '0' NOT NULL ,
62
- filename VARCHAR(255) NOT NULL ,
63
- description MEDIUMTEXT NULL ,
64
- alttext MEDIUMTEXT NULL ,
65
- imagedate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
66
- exclude TINYINT NULL DEFAULT '0' ,
67
- sortorder BIGINT(20) DEFAULT '0' NOT NULL ,
68
- meta_data LONGTEXT,
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 ,
81
- slug VARCHAR(255) NOT NULL ,
82
- path MEDIUMTEXT NULL ,
83
- title MEDIUMTEXT NULL ,
84
- galdesc MEDIUMTEXT NULL ,
85
- pageid BIGINT(20) DEFAULT '0' NOT NULL ,
86
- previewpic BIGINT(20) DEFAULT '0' 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 ,
99
- slug VARCHAR(255) NOT NULL ,
100
- previewpic BIGINT(20) DEFAULT '0' NOT NULL ,
101
- albumdesc MEDIUMTEXT NULL ,
102
- sortorder LONGTEXT NOT NULL,
103
- pageid BIGINT(20) DEFAULT '0' NOT NULL,
104
- PRIMARY KEY id (id)
105
- ) $charset_collate;";
106
-
107
- dbDelta($sql);
108
- }
109
 
110
  // check one table again, to be sure
111
  if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggpictures'" ) ) {
51
  $nggallery = $wpdb->prefix . 'ngg_gallery';
52
  $nggalbum = $wpdb->prefix . 'ngg_album';
53
 
54
+ // Create pictures table
55
+ $sql = "CREATE TABLE " . $nggpictures . " (
56
+ pid BIGINT(20) NOT NULL AUTO_INCREMENT ,
57
+ image_slug VARCHAR(255) NOT NULL ,
58
+ post_id BIGINT(20) DEFAULT '0' NOT NULL ,
59
+ galleryid BIGINT(20) DEFAULT '0' NOT NULL ,
60
+ filename VARCHAR(255) NOT NULL ,
61
+ description MEDIUMTEXT NULL ,
62
+ alttext MEDIUMTEXT NULL ,
63
+ imagedate DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
64
+ exclude TINYINT NULL DEFAULT '0' ,
65
+ sortorder BIGINT(20) DEFAULT '0' NOT NULL ,
66
+ meta_data LONGTEXT,
67
+ PRIMARY KEY (pid),
68
+ KEY post_id (post_id)
69
+ ) $charset_collate;";
70
+ dbDelta($sql);
71
+
72
+ // Create gallery table
73
+ $sql = "CREATE TABLE " . $nggallery . " (
74
+ gid BIGINT(20) NOT NULL AUTO_INCREMENT ,
75
+ name VARCHAR(255) NOT NULL ,
76
+ slug VARCHAR(255) NOT NULL ,
77
+ path MEDIUMTEXT NULL ,
78
+ title MEDIUMTEXT NULL ,
79
+ galdesc MEDIUMTEXT NULL ,
80
+ pageid BIGINT(20) DEFAULT '0' NOT NULL ,
81
+ previewpic BIGINT(20) DEFAULT '0' NOT NULL ,
82
+ author BIGINT(20) DEFAULT '0' NOT NULL ,
83
+ PRIMARY KEY (gid)
84
+ ) $charset_collate;";
85
+ dbDelta($sql);
86
+
87
+ // Create albums table
88
+ $sql = "CREATE TABLE " . $nggalbum . " (
89
+ id BIGINT(20) NOT NULL AUTO_INCREMENT ,
90
+ name VARCHAR(255) NOT NULL ,
91
+ slug VARCHAR(255) NOT NULL ,
92
+ previewpic BIGINT(20) DEFAULT '0' NOT NULL ,
93
+ albumdesc MEDIUMTEXT NULL ,
94
+ sortorder LONGTEXT NOT NULL,
95
+ pageid BIGINT(20) DEFAULT '0' NOT NULL,
96
+ PRIMARY KEY (id)
97
+ ) $charset_collate;";
98
+ dbDelta($sql);
 
 
 
 
 
 
 
 
 
 
99
 
100
  // check one table again, to be sure
101
  if( !$wpdb->get_var( "SHOW TABLES LIKE '$nggpictures'" ) ) {
admin/js/colorpicker/css/colorpicker.css CHANGED
@@ -1,161 +1,161 @@
1
- .colorpicker {
2
- width: 356px;
3
- height: 176px;
4
- overflow: hidden;
5
- position: absolute;
6
- background: url(../images/colorpicker_background.png);
7
- font-family: Arial, Helvetica, sans-serif;
8
- display: none;
9
- }
10
- .colorpicker_color {
11
- width: 150px;
12
- height: 150px;
13
- left: 14px;
14
- top: 13px;
15
- position: absolute;
16
- background: #f00;
17
- overflow: hidden;
18
- cursor: crosshair;
19
- }
20
- .colorpicker_color div {
21
- position: absolute;
22
- top: 0;
23
- left: 0;
24
- width: 150px;
25
- height: 150px;
26
- background: url(../images/colorpicker_overlay.png);
27
- }
28
- .colorpicker_color div div {
29
- position: absolute;
30
- top: 0;
31
- left: 0;
32
- width: 11px;
33
- height: 11px;
34
- overflow: hidden;
35
- background: url(../images/colorpicker_select.gif);
36
- margin: -5px 0 0 -5px;
37
- }
38
- .colorpicker_hue {
39
- position: absolute;
40
- top: 13px;
41
- left: 171px;
42
- width: 35px;
43
- height: 150px;
44
- cursor: n-resize;
45
- }
46
- .colorpicker_hue div {
47
- position: absolute;
48
- width: 35px;
49
- height: 9px;
50
- overflow: hidden;
51
- background: url(../images/colorpicker_indic.gif) left top;
52
- margin: -4px 0 0 0;
53
- left: 0px;
54
- }
55
- .colorpicker_new_color {
56
- position: absolute;
57
- width: 60px;
58
- height: 30px;
59
- left: 213px;
60
- top: 13px;
61
- background: #f00;
62
- }
63
- .colorpicker_current_color {
64
- position: absolute;
65
- width: 60px;
66
- height: 30px;
67
- left: 283px;
68
- top: 13px;
69
- background: #f00;
70
- }
71
- .colorpicker input {
72
- background-color: transparent;
73
- border: 1px solid transparent;
74
- position: absolute;
75
- font-size: 10px;
76
- font-family: Arial, Helvetica, sans-serif;
77
- color: #898989;
78
- top: 4px;
79
- right: 11px;
80
- text-align: right;
81
- margin: 0;
82
- padding: 0;
83
- height: 13px;
84
- }
85
- .colorpicker_hex {
86
- position: absolute;
87
- width: 72px;
88
- height: 22px;
89
- background: url(../images/colorpicker_hex.png) top;
90
- left: 212px;
91
- top: 142px;
92
- }
93
- .colorpicker_hex input {
94
- right: 6px;
95
- }
96
- .colorpicker_field {
97
- height: 22px;
98
- width: 62px;
99
- background-position: top;
100
- position: absolute;
101
- }
102
- .colorpicker_field span {
103
- position: absolute;
104
- width: 12px;
105
- height: 22px;
106
- overflow: hidden;
107
- top: 0;
108
- right: 0;
109
- cursor: n-resize;
110
- }
111
- .colorpicker_rgb_r {
112
- background-image: url(../images/colorpicker_rgb_r.png);
113
- top: 52px;
114
- left: 212px;
115
- }
116
- .colorpicker_rgb_g {
117
- background-image: url(../images/colorpicker_rgb_g.png);
118
- top: 82px;
119
- left: 212px;
120
- }
121
- .colorpicker_rgb_b {
122
- background-image: url(../images/colorpicker_rgb_b.png);
123
- top: 112px;
124
- left: 212px;
125
- }
126
- .colorpicker_hsb_h {
127
- background-image: url(../images/colorpicker_hsb_h.png);
128
- top: 52px;
129
- left: 282px;
130
- }
131
- .colorpicker_hsb_s {
132
- background-image: url(../images/colorpicker_hsb_s.png);
133
- top: 82px;
134
- left: 282px;
135
- }
136
- .colorpicker_hsb_b {
137
- background-image: url(../images/colorpicker_hsb_b.png);
138
- top: 112px;
139
- left: 282px;
140
- }
141
- .colorpicker_submit {
142
- position: absolute;
143
- width: 22px;
144
- height: 22px;
145
- background: url(../images/colorpicker_submit.png) top;
146
- left: 322px;
147
- top: 142px;
148
- overflow: hidden;
149
- }
150
- .colorpicker_focus {
151
- background-position: center;
152
- }
153
- .colorpicker_hex.colorpicker_focus {
154
- background-position: bottom;
155
- }
156
- .colorpicker_submit.colorpicker_focus {
157
- background-position: bottom;
158
- }
159
- .colorpicker_slider {
160
- background-position: bottom;
161
- }
1
+ .colorpicker {
2
+ width: 356px;
3
+ height: 176px;
4
+ overflow: hidden;
5
+ position: absolute;
6
+ background: url(../images/colorpicker_background.png);
7
+ font-family: Arial, Helvetica, sans-serif;
8
+ display: none;
9
+ }
10
+ .colorpicker_color {
11
+ width: 150px;
12
+ height: 150px;
13
+ left: 14px;
14
+ top: 13px;
15
+ position: absolute;
16
+ background: #f00;
17
+ overflow: hidden;
18
+ cursor: crosshair;
19
+ }
20
+ .colorpicker_color div {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ width: 150px;
25
+ height: 150px;
26
+ background: url(../images/colorpicker_overlay.png);
27
+ }
28
+ .colorpicker_color div div {
29
+ position: absolute;
30
+ top: 0;
31
+ left: 0;
32
+ width: 11px;
33
+ height: 11px;
34
+ overflow: hidden;
35
+ background: url(../images/colorpicker_select.gif);
36
+ margin: -5px 0 0 -5px;
37
+ }
38
+ .colorpicker_hue {
39
+ position: absolute;
40
+ top: 13px;
41
+ left: 171px;
42
+ width: 35px;
43
+ height: 150px;
44
+ cursor: n-resize;
45
+ }
46
+ .colorpicker_hue div {
47
+ position: absolute;
48
+ width: 35px;
49
+ height: 9px;
50
+ overflow: hidden;
51
+ background: url(../images/colorpicker_indic.gif) left top;
52
+ margin: -4px 0 0 0;
53
+ left: 0px;
54
+ }
55
+ .colorpicker_new_color {
56
+ position: absolute;
57
+ width: 60px;
58
+ height: 30px;
59
+ left: 213px;
60
+ top: 13px;
61
+ background: #f00;
62
+ }
63
+ .colorpicker_current_color {
64
+ position: absolute;
65
+ width: 60px;
66
+ height: 30px;
67
+ left: 283px;
68
+ top: 13px;
69
+ background: #f00;
70
+ }
71
+ .colorpicker input {
72
+ background-color: transparent;
73
+ border: 1px solid transparent;
74
+ position: absolute;
75
+ font-size: 10px;
76
+ font-family: Arial, Helvetica, sans-serif;
77
+ color: #898989;
78
+ top: 4px;
79
+ right: 11px;
80
+ text-align: right;
81
+ margin: 0;
82
+ padding: 0;
83
+ height: 13px;
84
+ }
85
+ .colorpicker_hex {
86
+ position: absolute;
87
+ width: 72px;
88
+ height: 22px;
89
+ background: url(../images/colorpicker_hex.png) top;
90
+ left: 212px;
91
+ top: 142px;
92
+ }
93
+ .colorpicker_hex input {
94
+ right: 6px;
95
+ }
96
+ .colorpicker_field {
97
+ height: 22px;
98
+ width: 62px;
99
+ background-position: top;
100
+ position: absolute;
101
+ }
102
+ .colorpicker_field span {
103
+ position: absolute;
104
+ width: 12px;
105
+ height: 22px;
106
+ overflow: hidden;
107
+ top: 0;
108
+ right: 0;
109
+ cursor: n-resize;
110
+ }
111
+ .colorpicker_rgb_r {
112
+ background-image: url(../images/colorpicker_rgb_r.png);
113
+ top: 52px;
114
+ left: 212px;
115
+ }
116
+ .colorpicker_rgb_g {
117
+ background-image: url(../images/colorpicker_rgb_g.png);
118
+ top: 82px;
119
+ left: 212px;
120
+ }
121
+ .colorpicker_rgb_b {
122
+ background-image: url(../images/colorpicker_rgb_b.png);
123
+ top: 112px;
124
+ left: 212px;
125
+ }
126
+ .colorpicker_hsb_h {
127
+ background-image: url(../images/colorpicker_hsb_h.png);
128
+ top: 52px;
129
+ left: 282px;
130
+ }
131
+ .colorpicker_hsb_s {
132
+ background-image: url(../images/colorpicker_hsb_s.png);
133
+ top: 82px;
134
+ left: 282px;
135
+ }
136
+ .colorpicker_hsb_b {
137
+ background-image: url(../images/colorpicker_hsb_b.png);
138
+ top: 112px;
139
+ left: 282px;
140
+ }
141
+ .colorpicker_submit {
142
+ position: absolute;
143
+ width: 22px;
144
+ height: 22px;
145
+ background: url(../images/colorpicker_submit.png) top;
146
+ left: 322px;
147
+ top: 142px;
148
+ overflow: hidden;
149
+ }
150
+ .colorpicker_focus {
151
+ background-position: center;
152
+ }
153
+ .colorpicker_hex.colorpicker_focus {
154
+ background-position: bottom;
155
+ }
156
+ .colorpicker_submit.colorpicker_focus {
157
+ background-position: bottom;
158
+ }
159
+ .colorpicker_slider {
160
+ background-position: bottom;
161
+ }
admin/js/colorpicker/js/colorpicker.js CHANGED
@@ -1,484 +1,484 @@
1
- /**
2
- *
3
- * Color picker
4
- * Author: Stefan Petre www.eyecon.ro
5
- *
6
- * Dual licensed under the MIT and GPL licenses
7
- *
8
- */
9
- (function ($) {
10
- var ColorPicker = function () {
11
- var
12
- ids = {},
13
- inAction,
14
- charMin = 65,
15
- visible,
16
- tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
17
- defaults = {
18
- eventName: 'click',
19
- onShow: function () {},
20
- onBeforeShow: function(){},
21
- onHide: function () {},
22
- onChange: function () {},
23
- onSubmit: function () {},
24
- color: 'ff0000',
25
- livePreview: true,
26
- flat: false
27
- },
28
- fillRGBFields = function (hsb, cal) {
29
- var rgb = HSBToRGB(hsb);
30
- $(cal).data('colorpicker').fields
31
- .eq(1).val(rgb.r).end()
32
- .eq(2).val(rgb.g).end()
33
- .eq(3).val(rgb.b).end();
34
- },
35
- fillHSBFields = function (hsb, cal) {
36
- $(cal).data('colorpicker').fields
37
- .eq(4).val(hsb.h).end()
38
- .eq(5).val(hsb.s).end()
39
- .eq(6).val(hsb.b).end();
40
- },
41
- fillHexFields = function (hsb, cal) {
42
- $(cal).data('colorpicker').fields
43
- .eq(0).val(HSBToHex(hsb)).end();
44
- },
45
- setSelector = function (hsb, cal) {
46
- $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
47
- $(cal).data('colorpicker').selectorIndic.css({
48
- left: parseInt(150 * hsb.s/100, 10),
49
- top: parseInt(150 * (100-hsb.b)/100, 10)
50
- });
51
- },
52
- setHue = function (hsb, cal) {
53
- $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
54
- },
55
- setCurrentColor = function (hsb, cal) {
56
- $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
57
- },
58
- setNewColor = function (hsb, cal) {
59
- $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
60
- },
61
- keyDown = function (ev) {
62
- var pressedKey = ev.charCode || ev.keyCode || -1;
63
- if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
64
- return false;
65
- }
66
- var cal = $(this).parent().parent();
67
- if (cal.data('colorpicker').livePreview === true) {
68
- change.apply(this);
69
- }
70
- },
71
- change = function (ev) {
72
- var cal = $(this).parent().parent(), col;
73
- if (this.parentNode.className.indexOf('_hex') > 0) {
74
- cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
75
- } else if (this.parentNode.className.indexOf('_hsb') > 0) {
76
- cal.data('colorpicker').color = col = fixHSB({
77
- h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
78
- s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
79
- b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
80
- });
81
- } else {
82
- cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
83
- r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
84
- g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
85
- b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
86
- }));
87
- }
88
- if (ev) {
89
- fillRGBFields(col, cal.get(0));
90
- fillHexFields(col, cal.get(0));
91
- fillHSBFields(col, cal.get(0));
92
- }
93
- setSelector(col, cal.get(0));
94
- setHue(col, cal.get(0));
95
- setNewColor(col, cal.get(0));
96
- cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
97
- },
98
- blur = function (ev) {
99
- var cal = $(this).parent().parent();
100
- cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
101
- },
102
- focus = function () {
103
- charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
104
- $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
105
- $(this).parent().addClass('colorpicker_focus');
106
- },
107
- downIncrement = function (ev) {
108
- var field = $(this).parent().find('input').focus();
109
- var current = {
110
- el: $(this).parent().addClass('colorpicker_slider'),
111
- max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
112
- y: ev.pageY,
113
- field: field,
114
- val: parseInt(field.val(), 10),
115
- preview: $(this).parent().parent().data('colorpicker').livePreview
116
- };
117
- $(document).bind('mouseup', current, upIncrement);
118
- $(document).bind('mousemove', current, moveIncrement);
119
- },
120
- moveIncrement = function (ev) {
121
- ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
122
- if (ev.data.preview) {
123
- change.apply(ev.data.field.get(0), [true]);
124
- }
125
- return false;
126
- },
127
- upIncrement = function (ev) {
128
- change.apply(ev.data.field.get(0), [true]);
129
- ev.data.el.removeClass('colorpicker_slider').find('input').focus();
130
- $(document).unbind('mouseup', upIncrement);
131
- $(document).unbind('mousemove', moveIncrement);
132
- return false;
133
- },
134
- downHue = function (ev) {
135
- var current = {
136
- cal: $(this).parent(),
137
- y: $(this).offset().top
138
- };
139
- current.preview = current.cal.data('colorpicker').livePreview;
140
- $(document).bind('mouseup', current, upHue);
141
- $(document).bind('mousemove', current, moveHue);
142
- },
143
- moveHue = function (ev) {
144
- change.apply(
145
- ev.data.cal.data('colorpicker')
146
- .fields
147
- .eq(4)
148
- .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
149
- .get(0),
150
- [ev.data.preview]
151
- );
152
- return false;
153
- },
154
- upHue = function (ev) {
155
- fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
156
- fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
157
- $(document).unbind('mouseup', upHue);
158
- $(document).unbind('mousemove', moveHue);
159
- return false;
160
- },
161
- downSelector = function (ev) {
162
- var current = {
163
- cal: $(this).parent(),
164
- pos: $(this).offset()
165
- };
166
- current.preview = current.cal.data('colorpicker').livePreview;
167
- $(document).bind('mouseup', current, upSelector);
168
- $(document).bind('mousemove', current, moveSelector);
169
- },
170
- moveSelector = function (ev) {
171
- change.apply(
172
- ev.data.cal.data('colorpicker')
173
- .fields
174
- .eq(6)
175
- .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
176
- .end()
177
- .eq(5)
178
- .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
179
- .get(0),
180
- [ev.data.preview]
181
- );
182
- return false;
183
- },
184
- upSelector = function (ev) {
185
- fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
186
- fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
187
- $(document).unbind('mouseup', upSelector);
188
- $(document).unbind('mousemove', moveSelector);
189
- return false;
190
- },
191
- enterSubmit = function (ev) {
192
- $(this).addClass('colorpicker_focus');
193
- },
194
- leaveSubmit = function (ev) {
195
- $(this).removeClass('colorpicker_focus');
196
- },
197
- clickSubmit = function (ev) {
198
- var cal = $(this).parent();
199
- var col = cal.data('colorpicker').color;
200
- cal.data('colorpicker').origColor = col;
201
- setCurrentColor(col, cal.get(0));
202
- cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
203
- },
204
- show = function (ev) {
205
- var cal = $('#' + $(this).data('colorpickerId'));
206
- cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
207
- var pos = $(this).offset();
208
- var viewPort = getViewport();
209
- var top = pos.top + this.offsetHeight;
210
- var left = pos.left;
211
- if (top + 176 > viewPort.t + viewPort.h) {
212
- top -= this.offsetHeight + 176;
213
- }
214
- if (left + 356 > viewPort.l + viewPort.w) {
215
- left -= 356;
216
- }
217
- cal.css({left: left + 'px', top: top + 'px'});
218
- if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
219
- cal.show();
220
- }
221
- $(document).bind('mousedown', {cal: cal}, hide);
222
- return false;
223
- },
224
- hide = function (ev) {
225
- if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
226
- if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
227
- ev.data.cal.hide();
228
- }
229
- $(document).unbind('mousedown', hide);
230
- }
231
- },
232
- isChildOf = function(parentEl, el, container) {
233
- if (parentEl == el) {
234
- return true;
235
- }
236
- if (parentEl.contains) {
237
- return parentEl.contains(el);
238
- }
239
- if ( parentEl.compareDocumentPosition ) {
240
- return !!(parentEl.compareDocumentPosition(el) & 16);
241
- }
242
- var prEl = el.parentNode;
243
- while(prEl && prEl != container) {
244
- if (prEl == parentEl)
245
- return true;
246
- prEl = prEl.parentNode;
247
- }
248
- return false;
249
- },
250
- getViewport = function () {
251
- var m = document.compatMode == 'CSS1Compat';
252
- return {
253
- l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
254
- t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
255
- w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
256
- h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
257
- };
258
- },
259
- fixHSB = function (hsb) {
260
- return {
261
- h: Math.min(360, Math.max(0, hsb.h)),
262
- s: Math.min(100, Math.max(0, hsb.s)),
263
- b: Math.min(100, Math.max(0, hsb.b))
264
- };
265
- },
266
- fixRGB = function (rgb) {
267
- return {
268
- r: Math.min(255, Math.max(0, rgb.r)),
269
- g: Math.min(255, Math.max(0, rgb.g)),
270
- b: Math.min(255, Math.max(0, rgb.b))
271
- };
272
- },
273
- fixHex = function (hex) {
274
- var len = 6 - hex.length;
275
- if (len > 0) {
276
- var o = [];
277
- for (var i=0; i<len; i++) {
278
- o.push('0');
279
- }
280
- o.push(hex);
281
- hex = o.join('');
282
- }
283
- return hex;
284
- },
285
- HexToRGB = function (hex) {
286
- var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
287
- return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
288
- },
289
- HexToHSB = function (hex) {
290
- return RGBToHSB(HexToRGB(hex));
291
- },
292
- RGBToHSB = function (rgb) {
293
- var hsb = {
294
- h: 0,
295
- s: 0,
296
- b: 0
297
- };
298
- var min = Math.min(rgb.r, rgb.g, rgb.b);
299
- var max = Math.max(rgb.r, rgb.g, rgb.b);
300
- var delta = max - min;
301
- hsb.b = max;
302
- if (max != 0) {
303
-
304
- }
305
- hsb.s = max != 0 ? 255 * delta / max : 0;
306
- if (hsb.s != 0) {
307
- if (rgb.r == max) {
308
- hsb.h = (rgb.g - rgb.b) / delta;
309
- } else if (rgb.g == max) {
310
- hsb.h = 2 + (rgb.b - rgb.r) / delta;
311
- } else {
312
- hsb.h = 4 + (rgb.r - rgb.g) / delta;
313
- }
314
- } else {
315
- hsb.h = -1;
316
- }
317
- hsb.h *= 60;
318
- if (hsb.h < 0) {
319
- hsb.h += 360;
320
- }
321
- hsb.s *= 100/255;
322
- hsb.b *= 100/255;
323
- return hsb;
324
- },
325
- HSBToRGB = function (hsb) {
326
- var rgb = {};
327
- var h = Math.round(hsb.h);
328
- var s = Math.round(hsb.s*255/100);
329
- var v = Math.round(hsb.b*255/100);
330
- if(s == 0) {
331
- rgb.r = rgb.g = rgb.b = v;
332
- } else {
333
- var t1 = v;
334
- var t2 = (255-s)*v/255;
335
- var t3 = (t1-t2)*(h%60)/60;
336
- if(h==360) h = 0;
337
- if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
338
- else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
339
- else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
340
- else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
341
- else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
342
- else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
343
- else {rgb.r=0; rgb.g=0; rgb.b=0}
344
- }
345
- return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
346
- },
347
- RGBToHex = function (rgb) {
348
- var hex = [
349
- rgb.r.toString(16),
350
- rgb.g.toString(16),
351
- rgb.b.toString(16)
352
- ];
353
- $.each(hex, function (nr, val) {
354
- if (val.length == 1) {
355
- hex[nr] = '0' + val;
356
- }
357
- });
358
- return hex.join('');
359
- },
360
- HSBToHex = function (hsb) {
361
- return RGBToHex(HSBToRGB(hsb));
362
- },
363
- restoreOriginal = function () {
364
- var cal = $(this).parent();
365
- var col = cal.data('colorpicker').origColor;
366
- cal.data('colorpicker').color = col;
367
- fillRGBFields(col, cal.get(0));
368
- fillHexFields(col, cal.get(0));
369
- fillHSBFields(col, cal.get(0));
370
- setSelector(col, cal.get(0));
371
- setHue(col, cal.get(0));
372
- setNewColor(col, cal.get(0));
373
- };
374
- return {
375
- init: function (opt) {
376
- opt = $.extend({}, defaults, opt||{});
377
- if (typeof opt.color == 'string') {
378
- opt.color = HexToHSB(opt.color);
379
- } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
380
- opt.color = RGBToHSB(opt.color);
381
- } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
382
- opt.color = fixHSB(opt.color);
383
- } else {
384
- return this;
385
- }
386
- return this.each(function () {
387
- if (!$(this).data('colorpickerId')) {
388
- var options = $.extend({}, opt);
389
- options.origColor = opt.color;
390
- var id = 'collorpicker_' + parseInt(Math.random() * 1000);
391
- $(this).data('colorpickerId', id);
392
- var cal = $(tpl).attr('id', id);
393
- if (options.flat) {
394
- cal.appendTo(this).show();
395
- } else {
396
- cal.appendTo(document.body);
397
- }
398
- options.fields = cal
399
- .find('input')
400
- .bind('keyup', keyDown)
401
- .bind('change', change)
402
- .bind('blur', blur)
403
- .bind('focus', focus);
404
- cal
405
- .find('span').bind('mousedown', downIncrement).end()
406
- .find('>div.colorpicker_current_color').bind('click', restoreOriginal);
407
- options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
408
- options.selectorIndic = options.selector.find('div div');
409
- options.el = this;
410
- options.hue = cal.find('div.colorpicker_hue div');
411
- cal.find('div.colorpicker_hue').bind('mousedown', downHue);
412
- options.newColor = cal.find('div.colorpicker_new_color');
413
- options.currentColor = cal.find('div.colorpicker_current_color');
414
- cal.data('colorpicker', options);
415
- cal.find('div.colorpicker_submit')
416
- .bind('mouseenter', enterSubmit)
417
- .bind('mouseleave', leaveSubmit)
418
- .bind('click', clickSubmit);
419
- fillRGBFields(options.color, cal.get(0));
420
- fillHSBFields(options.color, cal.get(0));
421
- fillHexFields(options.color, cal.get(0));
422
- setHue(options.color, cal.get(0));
423
- setSelector(options.color, cal.get(0));
424
- setCurrentColor(options.color, cal.get(0));
425
- setNewColor(options.color, cal.get(0));
426
- if (options.flat) {
427
- cal.css({
428
- position: 'relative',
429
- display: 'block'
430
- });
431
- } else {
432
- $(this).bind(options.eventName, show);
433
- }
434
- }
435
- });
436
- },
437
- showPicker: function() {
438
- return this.each( function () {
439
- if ($(this).data('colorpickerId')) {
440
- show.apply(this);
441
- }
442
- });
443
- },
444
- hidePicker: function() {
445
- return this.each( function () {
446
- if ($(this).data('colorpickerId')) {
447
- $('#' + $(this).data('colorpickerId')).hide();
448
- }
449
- });
450
- },
451
- setColor: function(col) {
452
- if (typeof col == 'string') {
453
- col = HexToHSB(col);
454
- } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
455
- col = RGBToHSB(col);
456
- } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
457
- col = fixHSB(col);
458
- } else {
459
- return this;
460
- }
461
- return this.each(function(){
462
- if ($(this).data('colorpickerId')) {
463
- var cal = $('#' + $(this).data('colorpickerId'));
464
- cal.data('colorpicker').color = col;
465
- cal.data('colorpicker').origColor = col;
466
- fillRGBFields(col, cal.get(0));
467
- fillHSBFields(col, cal.get(0));
468
- fillHexFields(col, cal.get(0));
469
- setHue(col, cal.get(0));
470
- setSelector(col, cal.get(0));
471
- setCurrentColor(col, cal.get(0));
472
- setNewColor(col, cal.get(0));
473
- }
474
- });
475
- }
476
- };
477
- }();
478
- $.fn.extend({
479
- ColorPicker: ColorPicker.init,
480
- ColorPickerHide: ColorPicker.hidePicker,
481
- ColorPickerShow: ColorPicker.showPicker,
482
- ColorPickerSetColor: ColorPicker.setColor
483
- });
484
  })(jQuery)
1
+ /**
2
+ *
3
+ * Color picker
4
+ * Author: Stefan Petre www.eyecon.ro
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses
7
+ *
8
+ */
9
+ (function ($) {
10
+ var ColorPicker = function () {
11
+ var
12
+ ids = {},
13
+ inAction,
14
+ charMin = 65,
15
+ visible,
16
+ tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
17
+ defaults = {
18
+ eventName: 'click',
19
+ onShow: function () {},
20
+ onBeforeShow: function(){},
21
+ onHide: function () {},
22
+ onChange: function () {},
23
+ onSubmit: function () {},
24
+ color: 'ff0000',
25
+ livePreview: true,
26
+ flat: false
27
+ },
28
+ fillRGBFields = function (hsb, cal) {
29
+ var rgb = HSBToRGB(hsb);
30
+ $(cal).data('colorpicker').fields
31
+ .eq(1).val(rgb.r).end()
32
+ .eq(2).val(rgb.g).end()
33
+ .eq(3).val(rgb.b).end();
34
+ },
35
+ fillHSBFields = function (hsb, cal) {
36
+ $(cal).data('colorpicker').fields
37
+ .eq(4).val(hsb.h).end()
38
+ .eq(5).val(hsb.s).end()
39
+ .eq(6).val(hsb.b).end();
40
+ },
41
+ fillHexFields = function (hsb, cal) {
42
+ $(cal).data('colorpicker').fields
43
+ .eq(0).val(HSBToHex(hsb)).end();
44
+ },
45
+ setSelector = function (hsb, cal) {
46
+ $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
47
+ $(cal).data('colorpicker').selectorIndic.css({
48
+ left: parseInt(150 * hsb.s/100, 10),
49
+ top: parseInt(150 * (100-hsb.b)/100, 10)
50
+ });
51
+ },
52
+ setHue = function (hsb, cal) {
53
+ $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
54
+ },
55
+ setCurrentColor = function (hsb, cal) {
56
+ $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
57
+ },
58
+ setNewColor = function (hsb, cal) {
59
+ $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
60
+ },
61
+ keyDown = function (ev) {
62
+ var pressedKey = ev.charCode || ev.keyCode || -1;
63
+ if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
64
+ return false;
65
+ }
66
+ var cal = $(this).parent().parent();
67
+ if (cal.data('colorpicker').livePreview === true) {
68
+ change.apply(this);
69
+ }
70
+ },
71
+ change = function (ev) {
72
+ var cal = $(this).parent().parent(), col;
73
+ if (this.parentNode.className.indexOf('_hex') > 0) {
74
+ cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
75
+ } else if (this.parentNode.className.indexOf('_hsb') > 0) {
76
+ cal.data('colorpicker').color = col = fixHSB({
77
+ h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
78
+ s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
79
+ b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
80
+ });
81
+ } else {
82
+ cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
83
+ r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
84
+ g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
85
+ b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
86
+ }));
87
+ }
88
+ if (ev) {
89
+ fillRGBFields(col, cal.get(0));
90
+ fillHexFields(col, cal.get(0));
91
+ fillHSBFields(col, cal.get(0));
92
+ }
93
+ setSelector(col, cal.get(0));
94
+ setHue(col, cal.get(0));
95
+ setNewColor(col, cal.get(0));
96
+ cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
97
+ },
98
+ blur = function (ev) {
99
+ var cal = $(this).parent().parent();
100
+ cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
101
+ },
102
+ focus = function () {
103
+ charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
104
+ $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
105
+ $(this).parent().addClass('colorpicker_focus');
106
+ },
107
+ downIncrement = function (ev) {
108
+ var field = $(this).parent().find('input').focus();
109
+ var current = {
110
+ el: $(this).parent().addClass('colorpicker_slider'),
111
+ max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
112
+ y: ev.pageY,
113
+ field: field,
114
+ val: parseInt(field.val(), 10),
115
+ preview: $(this).parent().parent().data('colorpicker').livePreview
116
+ };
117
+ $(document).bind('mouseup', current, upIncrement);
118
+ $(document).bind('mousemove', current, moveIncrement);
119
+ },
120
+ moveIncrement = function (ev) {
121
+ ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
122
+ if (ev.data.preview) {
123
+ change.apply(ev.data.field.get(0), [true]);
124
+ }
125
+ return false;
126
+ },
127
+ upIncrement = function (ev) {
128
+ change.apply(ev.data.field.get(0), [true]);
129
+ ev.data.el.removeClass('colorpicker_slider').find('input').focus();
130
+ $(document).unbind('mouseup', upIncrement);
131
+ $(document).unbind('mousemove', moveIncrement);
132
+ return false;
133
+ },
134
+ downHue = function (ev) {
135
+ var current = {
136
+ cal: $(this).parent(),
137
+ y: $(this).offset().top
138
+ };
139
+ current.preview = current.cal.data('colorpicker').livePreview;
140
+ $(document).bind('mouseup', current, upHue);
141
+ $(document).bind('mousemove', current, moveHue);
142
+ },
143
+ moveHue = function (ev) {
144
+ change.apply(
145
+ ev.data.cal.data('colorpicker')
146
+ .fields
147
+ .eq(4)
148
+ .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
149
+ .get(0),
150
+ [ev.data.preview]
151
+ );
152
+ return false;
153
+ },
154
+ upHue = function (ev) {
155
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
156
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
157
+ $(document).unbind('mouseup', upHue);
158
+ $(document).unbind('mousemove', moveHue);
159
+ return false;
160
+ },
161
+ downSelector = function (ev) {
162
+ var current = {
163
+ cal: $(this).parent(),
164
+ pos: $(this).offset()
165
+ };
166
+ current.preview = current.cal.data('colorpicker').livePreview;
167
+ $(document).bind('mouseup', current, upSelector);
168
+ $(document).bind('mousemove', current, moveSelector);
169
+ },
170
+ moveSelector = function (ev) {
171
+ change.apply(
172
+ ev.data.cal.data('colorpicker')
173
+ .fields
174
+ .eq(6)
175
+ .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
176
+ .end()
177
+ .eq(5)
178
+ .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
179
+ .get(0),
180
+ [ev.data.preview]
181
+ );
182
+ return false;
183
+ },
184
+ upSelector = function (ev) {
185
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
186
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
187
+ $(document).unbind('mouseup', upSelector);
188
+ $(document).unbind('mousemove', moveSelector);
189
+ return false;
190
+ },
191
+ enterSubmit = function (ev) {
192
+ $(this).addClass('colorpicker_focus');
193
+ },
194
+ leaveSubmit = function (ev) {
195
+ $(this).removeClass('colorpicker_focus');
196
+ },
197
+ clickSubmit = function (ev) {
198
+ var cal = $(this).parent();
199
+ var col = cal.data('colorpicker').color;
200
+ cal.data('colorpicker').origColor = col;
201
+ setCurrentColor(col, cal.get(0));
202
+ cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
203
+ },
204
+ show = function (ev) {
205
+ var cal = $('#' + $(this).data('colorpickerId'));
206
+ cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
207
+ var pos = $(this).offset();
208
+ var viewPort = getViewport();
209
+ var top = pos.top + this.offsetHeight;
210
+ var left = pos.left;
211
+ if (top + 176 > viewPort.t + viewPort.h) {
212
+ top -= this.offsetHeight + 176;
213
+ }
214
+ if (left + 356 > viewPort.l + viewPort.w) {
215
+ left -= 356;
216
+ }
217
+ cal.css({left: left + 'px', top: top + 'px'});
218
+ if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
219
+ cal.show();
220
+ }
221
+ $(document).bind('mousedown', {cal: cal}, hide);
222
+ return false;
223
+ },
224
+ hide = function (ev) {
225
+ if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
226
+ if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
227
+ ev.data.cal.hide();
228
+ }
229
+ $(document).unbind('mousedown', hide);
230
+ }
231
+ },
232
+ isChildOf = function(parentEl, el, container) {
233
+ if (parentEl == el) {
234
+ return true;
235
+ }
236
+ if (parentEl.contains) {
237
+ return parentEl.contains(el);
238
+ }
239
+ if ( parentEl.compareDocumentPosition ) {
240
+ return !!(parentEl.compareDocumentPosition(el) & 16);
241
+ }
242
+ var prEl = el.parentNode;
243
+ while(prEl && prEl != container) {
244
+ if (prEl == parentEl)
245
+ return true;
246
+ prEl = prEl.parentNode;
247
+ }
248
+ return false;
249
+ },
250
+ getViewport = function () {
251
+ var m = document.compatMode == 'CSS1Compat';
252
+ return {
253
+ l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
254
+ t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
255
+ w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
256
+ h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
257
+ };
258
+ },
259
+ fixHSB = function (hsb) {
260
+ return {
261
+ h: Math.min(360, Math.max(0, hsb.h)),
262
+ s: Math.min(100, Math.max(0, hsb.s)),
263
+ b: Math.min(100, Math.max(0, hsb.b))
264
+ };
265
+ },
266
+ fixRGB = function (rgb) {
267
+ return {
268
+ r: Math.min(255, Math.max(0, rgb.r)),
269
+ g: Math.min(255, Math.max(0, rgb.g)),
270
+ b: Math.min(255, Math.max(0, rgb.b))
271
+ };
272
+ },
273
+ fixHex = function (hex) {
274
+ var len = 6 - hex.length;
275
+ if (len > 0) {
276
+ var o = [];
277
+ for (var i=0; i<len; i++) {
278
+ o.push('0');
279
+ }
280
+ o.push(hex);
281
+ hex = o.join('');
282
+ }
283
+ return hex;
284
+ },
285
+ HexToRGB = function (hex) {
286
+ var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
287
+ return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
288
+ },
289
+ HexToHSB = function (hex) {
290
+ return RGBToHSB(HexToRGB(hex));
291
+ },
292
+ RGBToHSB = function (rgb) {
293
+ var hsb = {
294
+ h: 0,
295
+ s: 0,
296
+ b: 0
297
+ };
298
+ var min = Math.min(rgb.r, rgb.g, rgb.b);
299
+ var max = Math.max(rgb.r, rgb.g, rgb.b);
300
+ var delta = max - min;
301
+ hsb.b = max;
302
+ if (max != 0) {
303
+
304
+ }
305
+ hsb.s = max != 0 ? 255 * delta / max : 0;
306
+ if (hsb.s != 0) {
307
+ if (rgb.r == max) {
308
+ hsb.h = (rgb.g - rgb.b) / delta;
309
+ } else if (rgb.g == max) {
310
+ hsb.h = 2 + (rgb.b - rgb.r) / delta;
311
+ } else {
312
+ hsb.h = 4 + (rgb.r - rgb.g) / delta;
313
+ }
314
+ } else {
315
+ hsb.h = -1;
316
+ }
317
+ hsb.h *= 60;
318
+ if (hsb.h < 0) {
319
+ hsb.h += 360;
320
+ }
321
+ hsb.s *= 100/255;
322
+ hsb.b *= 100/255;
323
+ return hsb;
324
+ },
325
+ HSBToRGB = function (hsb) {
326
+ var rgb = {};
327
+ var h = Math.round(hsb.h);
328
+ var s = Math.round(hsb.s*255/100);
329
+ var v = Math.round(hsb.b*255/100);
330
+ if(s == 0) {
331
+ rgb.r = rgb.g = rgb.b = v;
332
+ } else {
333
+ var t1 = v;
334
+ var t2 = (255-s)*v/255;
335
+ var t3 = (t1-t2)*(h%60)/60;
336
+ if(h==360) h = 0;
337
+ if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
338
+ else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
339
+ else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
340
+ else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
341
+ else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
342
+ else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
343
+ else {rgb.r=0; rgb.g=0; rgb.b=0}
344
+ }
345
+ return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
346
+ },
347
+ RGBToHex = function (rgb) {
348
+ var hex = [
349
+ rgb.r.toString(16),
350
+ rgb.g.toString(16),
351
+ rgb.b.toString(16)
352
+ ];
353
+ $.each(hex, function (nr, val) {
354
+ if (val.length == 1) {
355
+ hex[nr] = '0' + val;
356
+ }
357
+ });
358
+ return hex.join('');
359
+ },
360
+ HSBToHex = function (hsb) {
361
+ return RGBToHex(HSBToRGB(hsb));
362
+ },
363
+ restoreOriginal = function () {
364
+ var cal = $(this).parent();
365
+ var col = cal.data('colorpicker').origColor;
366
+ cal.data('colorpicker').color = col;
367
+ fillRGBFields(col, cal.get(0));
368
+ fillHexFields(col, cal.get(0));
369
+ fillHSBFields(col, cal.get(0));
370
+ setSelector(col, cal.get(0));
371
+ setHue(col, cal.get(0));
372
+ setNewColor(col, cal.get(0));
373
+ };
374
+ return {
375
+ init: function (opt) {
376
+ opt = $.extend({}, defaults, opt||{});
377
+ if (typeof opt.color == 'string') {
378
+ opt.color = HexToHSB(opt.color);
379
+ } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
380
+ opt.color = RGBToHSB(opt.color);
381
+ } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
382
+ opt.color = fixHSB(opt.color);
383
+ } else {
384
+ return this;
385
+ }
386
+ return this.each(function () {
387
+ if (!$(this).data('colorpickerId')) {
388
+ var options = $.extend({}, opt);
389
+ options.origColor = opt.color;
390
+ var id = 'collorpicker_' + parseInt(Math.random() * 1000);
391
+ $(this).data('colorpickerId', id);
392
+ var cal = $(tpl).attr('id', id);
393
+ if (options.flat) {
394
+ cal.appendTo(this).show();
395
+ } else {
396
+ cal.appendTo(document.body);
397
+ }
398
+ options.fields = cal
399
+ .find('input')
400
+ .bind('keyup', keyDown)
401
+ .bind('change', change)
402
+ .bind('blur', blur)
403
+ .bind('focus', focus);
404
+ cal
405
+ .find('span').bind('mousedown', downIncrement).end()
406
+ .find('>div.colorpicker_current_color').bind('click', restoreOriginal);
407
+ options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
408
+ options.selectorIndic = options.selector.find('div div');
409
+ options.el = this;
410
+ options.hue = cal.find('div.colorpicker_hue div');
411
+ cal.find('div.colorpicker_hue').bind('mousedown', downHue);
412
+ options.newColor = cal.find('div.colorpicker_new_color');
413
+ options.currentColor = cal.find('div.colorpicker_current_color');
414
+ cal.data('colorpicker', options);
415
+ cal.find('div.colorpicker_submit')
416
+ .bind('mouseenter', enterSubmit)
417
+ .bind('mouseleave', leaveSubmit)
418
+ .bind('click', clickSubmit);
419
+ fillRGBFields(options.color, cal.get(0));
420
+ fillHSBFields(options.color, cal.get(0));
421
+ fillHexFields(options.color, cal.get(0));
422
+ setHue(options.color, cal.get(0));
423
+ setSelector(options.color, cal.get(0));
424
+ setCurrentColor(options.color, cal.get(0));
425
+ setNewColor(options.color, cal.get(0));
426
+ if (options.flat) {
427
+ cal.css({
428
+ position: 'relative',
429
+ display: 'block'
430
+ });
431
+ } else {
432
+ $(this).bind(options.eventName, show);
433
+ }
434
+ }
435
+ });
436
+ },
437
+ showPicker: function() {
438
+ return this.each( function () {
439
+ if ($(this).data('colorpickerId')) {
440
+ show.apply(this);
441
+ }
442
+ });
443
+ },
444
+ hidePicker: function() {
445
+ return this.each( function () {
446
+ if ($(this).data('colorpickerId')) {
447
+ $('#' + $(this).data('colorpickerId')).hide();
448
+ }
449
+ });
450
+ },
451
+ setColor: function(col) {
452
+ if (typeof col == 'string') {
453
+ col = HexToHSB(col);
454
+ } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
455
+ col = RGBToHSB(col);
456
+ } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
457
+ col = fixHSB(col);
458
+ } else {
459
+ return this;
460
+ }
461
+ return this.each(function(){
462
+ if ($(this).data('colorpickerId')) {
463
+ var cal = $('#' + $(this).data('colorpickerId'));
464
+ cal.data('colorpicker').color = col;
465
+ cal.data('colorpicker').origColor = col;
466
+ fillRGBFields(col, cal.get(0));
467
+ fillHSBFields(col, cal.get(0));
468
+ fillHexFields(col, cal.get(0));
469
+ setHue(col, cal.get(0));
470
+ setSelector(col, cal.get(0));
471
+ setCurrentColor(col, cal.get(0));
472
+ setNewColor(col, cal.get(0));
473
+ }
474
+ });
475
+ }
476
+ };
477
+ }();
478
+ $.fn.extend({
479
+ ColorPicker: ColorPicker.init,
480
+ ColorPickerHide: ColorPicker.hidePicker,
481
+ ColorPickerShow: ColorPicker.showPicker,
482
+ ColorPickerSetColor: ColorPicker.setColor
483
+ });
484
  })(jQuery)
admin/js/jqueryFileTree/jqueryFileTree.css CHANGED
@@ -1,81 +1,81 @@
1
- #file_browser {
2
- border: 2px solid #999;
3
- height: 200px;
4
- overflow: auto;
5
- padding: 4px 8px;
6
- background: #fff;
7
- margin: 4px 0px;
8
- width: 350px;
9
- position:relative;
10
- display:none;
11
- }
12
- .browsefiles {margin-left:5px;}
13
-
14
- ul.jqueryDirTree {
15
- font-family: Verdana, sans-serif;
16
- font-size: 11px;
17
- line-height: 18px;
18
- padding: 0px;
19
- margin: 0px;
20
- }
21
-
22
- ul.jqueryDirTree li {
23
- list-style: none;
24
- padding: 2px 0px;
25
- padding-left: 20px;
26
- margin: 0px;
27
- white-space: nowrap;
28
- }
29
-
30
- ul.jqueryDirTree a {
31
- color: #333;
32
- text-decoration: none;
33
- display: block;
34
- padding: 0px 2px;
35
- }
36
-
37
- ul.jqueryDirTree a:hover {
38
- background: #bdf;
39
- }
40
- ul.jqueryDirTree li.active a {
41
- background: #bdf;
42
- }
43
- ul.jqueryDirTree li.active li a {
44
- background: none;
45
- }
46
- ul.jqueryDirTree li.active li a:hover {
47
- background: #bdf;
48
- }
49
-
50
- /* Core Styles */
51
- .jqueryDirTree li.directory { background: url(images/directory.png) left top no-repeat; }
52
- .jqueryDirTree li.expanded { background: url(images/folder_open.png) left top no-repeat; }
53
- .jqueryDirTree li.file { background: url(images/file.png) left top no-repeat; }
54
- .jqueryDirTree li.wait { background: url(images/spinner.gif) left top no-repeat; }
55
- /* File Extensions*/
56
- .jqueryDirTree li.ext_3gp { background: url(images/film.png) left top no-repeat; }
57
- .jqueryDirTree li.ext_avi { background: url(images/film.png) left top no-repeat; }
58
- .jqueryDirTree li.ext_bat { background: url(images/application.png) left top no-repeat; }
59
- .jqueryDirTree li.ext_bmp { background: url(images/picture.png) left top no-repeat; }
60
- .jqueryDirTree li.ext_com { background: url(images/application.png) left top no-repeat; }
61
- .jqueryDirTree li.ext_exe { background: url(images/application.png) left top no-repeat; }
62
- .jqueryDirTree li.ext_gif { background: url(images/picture.png) left top no-repeat; }
63
- .jqueryDirTree li.ext_fla { background: url(images/flash.png) left top no-repeat; }
64
- .jqueryDirTree li.ext_jpg { background: url(images/picture.png) left top no-repeat; }
65
- .jqueryDirTree li.ext_jpeg { background: url(images/picture.png) left top no-repeat; }
66
- .jqueryDirTree li.ext_m4p { background: url(images/music.png) left top no-repeat; }
67
- .jqueryDirTree li.ext_mov { background: url(images/film.png) left top no-repeat; }
68
- .jqueryDirTree li.ext_mp3 { background: url(images/music.png) left top no-repeat; }
69
- .jqueryDirTree li.ext_mp4 { background: url(images/film.png) left top no-repeat; }
70
- .jqueryDirTree li.ext_mpg { background: url(images/film.png) left top no-repeat; }
71
- .jqueryDirTree li.ext_mpeg { background: url(images/film.png) left top no-repeat; }
72
- .jqueryDirTree li.ext_ogg { background: url(images/music.png) left top no-repeat; }
73
- .jqueryDirTree li.ext_pcx { background: url(images/picture.png) left top no-repeat; }
74
- .jqueryDirTree li.ext_pdf { background: url(images/pdf.png) left top no-repeat; }
75
- .jqueryDirTree li.ext_png { background: url(images/picture.png) left top no-repeat; }
76
- .jqueryDirTree li.ext_swf { background: url(images/flash.png) left top no-repeat; }
77
- .jqueryDirTree li.ext_tif { background: url(images/picture.png) left top no-repeat; }
78
- .jqueryDirTree li.ext_tiff { background: url(images/picture.png) left top no-repeat; }
79
- .jqueryDirTree li.ext_wav { background: url(images/music.png) left top no-repeat; }
80
- .jqueryDirTree li.ext_wmv { background: url(images/film.png) left top no-repeat; }
81
  .jqueryDirTree li.ext_zip { background: url(images/zip.png) left top no-repeat; }
1
+ #file_browser {
2
+ border: 2px solid #999;
3
+ height: 200px;
4
+ overflow: auto;
5
+ padding: 4px 8px;
6
+ background: #fff;
7
+ margin: 4px 0px;
8
+ width: 350px;
9
+ position:relative;
10
+ display:none;
11
+ }
12
+ .browsefiles {margin-left:5px;}
13
+
14
+ ul.jqueryDirTree {
15
+ font-family: Verdana, sans-serif;
16
+ font-size: 11px;
17
+ line-height: 18px;
18
+ padding: 0px;
19
+ margin: 0px;
20
+ }
21
+
22
+ ul.jqueryDirTree li {
23
+ list-style: none;
24
+ padding: 2px 0px;
25
+ padding-left: 20px;
26
+ margin: 0px;
27
+ white-space: nowrap;
28
+ }
29
+
30
+ ul.jqueryDirTree a {
31
+ color: #333;
32
+ text-decoration: none;
33
+ display: block;
34
+ padding: 0px 2px;
35
+ }
36
+
37
+ ul.jqueryDirTree a:hover {
38
+ background: #bdf;
39
+ }
40
+ ul.jqueryDirTree li.active a {
41
+ background: #bdf;
42
+ }
43
+ ul.jqueryDirTree li.active li a {
44
+ background: none;
45
+ }
46
+ ul.jqueryDirTree li.active li a:hover {
47
+ background: #bdf;
48
+ }
49
+
50
+ /* Core Styles */
51
+ .jqueryDirTree li.directory { background: url(images/directory.png) left top no-repeat; }
52
+ .jqueryDirTree li.expanded { background: url(images/folder_open.png) left top no-repeat; }
53
+ .jqueryDirTree li.file { background: url(images/file.png) left top no-repeat; }
54
+ .jqueryDirTree li.wait { background: url(images/spinner.gif) left top no-repeat; }
55
+ /* File Extensions*/
56
+ .jqueryDirTree li.ext_3gp { background: url(images/film.png) left top no-repeat; }
57
+ .jqueryDirTree li.ext_avi { background: url(images/film.png) left top no-repeat; }
58
+ .jqueryDirTree li.ext_bat { background: url(images/application.png) left top no-repeat; }
59
+ .jqueryDirTree li.ext_bmp { background: url(images/picture.png) left top no-repeat; }
60
+ .jqueryDirTree li.ext_com { background: url(images/application.png) left top no-repeat; }
61
+ .jqueryDirTree li.ext_exe { background: url(images/application.png) left top no-repeat; }
62
+ .jqueryDirTree li.ext_gif { background: url(images/picture.png) left top no-repeat; }
63
+ .jqueryDirTree li.ext_fla { background: url(images/flash.png) left top no-repeat; }
64
+ .jqueryDirTree li.ext_jpg { background: url(images/picture.png) left top no-repeat; }
65
+ .jqueryDirTree li.ext_jpeg { background: url(images/picture.png) left top no-repeat; }
66
+ .jqueryDirTree li.ext_m4p { background: url(images/music.png) left top no-repeat; }
67
+ .jqueryDirTree li.ext_mov { background: url(images/film.png) left top no-repeat; }
68
+ .jqueryDirTree li.ext_mp3 { background: url(images/music.png) left top no-repeat; }
69
+ .jqueryDirTree li.ext_mp4 { background: url(images/film.png) left top no-repeat; }
70
+ .jqueryDirTree li.ext_mpg { background: url(images/film.png) left top no-repeat; }
71
+ .jqueryDirTree li.ext_mpeg { background: url(images/film.png) left top no-repeat; }
72
+ .jqueryDirTree li.ext_ogg { background: url(images/music.png) left top no-repeat; }
73
+ .jqueryDirTree li.ext_pcx { background: url(images/picture.png) left top no-repeat; }
74
+ .jqueryDirTree li.ext_pdf { background: url(images/pdf.png) left top no-repeat; }
75
+ .jqueryDirTree li.ext_png { background: url(images/picture.png) left top no-repeat; }
76
+ .jqueryDirTree li.ext_swf { background: url(images/flash.png) left top no-repeat; }
77
+ .jqueryDirTree li.ext_tif { background: url(images/picture.png) left top no-repeat; }
78
+ .jqueryDirTree li.ext_tiff { background: url(images/picture.png) left top no-repeat; }
79
+ .jqueryDirTree li.ext_wav { background: url(images/music.png) left top no-repeat; }
80
+ .jqueryDirTree li.ext_wmv { background: url(images/film.png) left top no-repeat; }
81
  .jqueryDirTree li.ext_zip { background: url(images/zip.png) left top no-repeat; }
admin/js/ngg.autocomplete.js CHANGED
@@ -1,77 +1,77 @@
1
- /*
2
- * Implementation of jQuery UI Autocomplete
3
- * see http://jqueryui.com/demos/autocomplete/
4
- * Version: 1.0.1
5
- * Author : Alex Rabe
6
- *
7
- */
8
- jQuery.fn.nggAutocomplete = function ( args ) {
9
-
10
- var defaults = { type: 'image',
11
- domain: '',
12
- limit: 50 };
13
-
14
- var s = jQuery.extend( {}, defaults, args);
15
-
16
- var settings = { method: 'autocomplete',
17
- type: s.type,
18
- format: 'json',
19
- callback: 'json',
20
- limit: s.limit };
21
-
22
- var obj = this.selector;
23
- var id = jQuery(this).attr('id');
24
- var cache = {}, lastXhr;
25
-
26
- // get current value of drop down field
27
- var c_text = jQuery(obj + ' :selected').text();
28
- var c_val = jQuery(obj).val();
29
- // IE7 / IE 8 didnt get often the correct width
30
- if (s.width == undefined)
31
- var c_width = jQuery(this).width();
32
- else
33
- var c_width = s.width;
34
- //hide first the drop down field
35
- jQuery(obj).hide();
36
- jQuery(obj).after('<input name="' + id + '_ac" type="text" id="' + id + '_ac"/>');
37
- // Fill up current value & style
38
- jQuery(obj + "_ac").val(c_text);
39
- jQuery(obj + "_ac").css('width', c_width);
40
- // Add the dropdown icon
41
- jQuery(obj + "_ac").addClass('ui-autocomplete-start')
42
- jQuery(obj + "_ac").autocomplete({
43
- source: function( request, response ) {
44
- var term = request.term;
45
- if ( term in cache ) {
46
- response( cache[ term ] );
47
- return;
48
- }
49
- // adding more $_GET parameter
50
- request = jQuery.extend( {}, settings, request);
51
- lastXhr = jQuery.getJSON( s.domain, request, function( data, status, xhr ) {
52
- // add term to cache
53
- cache[ term ] = data;
54
- if ( xhr === lastXhr )
55
- response( data );
56
- });
57
- },
58
- minLength: 0,
59
- select: function( event, ui ) {
60
- // adding this to the dropdown list
61
- jQuery(obj).append( new Option(ui.item.label, ui.item.id) );
62
- // now select it
63
- jQuery(obj).val(ui.item.id);
64
- jQuery(obj + "_ac").removeClass('ui-autocomplete-start');
65
- }
66
- });
67
-
68
- jQuery(obj + "_ac").click(function() {
69
-
70
- var search = jQuery(obj + "_ac").val();
71
- // if the value is prefilled, we pass a empty string
72
- if ( search == c_text)
73
- search = '';
74
- // pass empty string as value to search for, displaying all results
75
- jQuery(obj + "_ac").autocomplete('search', search );
76
- });
77
- }
1
+ /*
2
+ * Implementation of jQuery UI Autocomplete
3
+ * see http://jqueryui.com/demos/autocomplete/
4
+ * Version: 1.0.1
5
+ * Author : Alex Rabe
6
+ *
7
+ */
8
+ jQuery.fn.nggAutocomplete = function ( args ) {
9
+
10
+ var defaults = { type: 'image',
11
+ domain: '',
12
+ limit: 50 };
13
+
14
+ var s = jQuery.extend( {}, defaults, args);
15
+
16
+ var settings = { method: 'autocomplete',
17
+ type: s.type,
18
+ format: 'json',
19
+ callback: 'json',
20
+ limit: s.limit };
21
+
22
+ var obj = this.selector;
23
+ var id = jQuery(this).attr('id');
24
+ var cache = {}, lastXhr;
25
+
26
+ // get current value of drop down field
27
+ var c_text = jQuery(obj + ' :selected').text();
28
+ var c_val = jQuery(obj).val();
29
+ // IE7 / IE 8 didnt get often the correct width
30
+ if (s.width == undefined)
31
+ var c_width = jQuery(this).width();
32
+ else
33
+ var c_width = s.width;
34
+ //hide first the drop down field
35
+ jQuery(obj).hide();
36
+ jQuery(obj).after('<input name="' + id + '_ac" type="text" id="' + id + '_ac"/>');
37
+ // Fill up current value & style
38
+ jQuery(obj + "_ac").val(c_text);
39
+ jQuery(obj + "_ac").css('width', c_width);
40
+ // Add the dropdown icon
41
+ jQuery(obj + "_ac").addClass('ui-autocomplete-start')
42
+ jQuery(obj + "_ac").autocomplete({
43
+ source: function( request, response ) {
44
+ var term = request.term;
45
+ if ( term in cache ) {
46
+ response( cache[ term ] );
47
+ return;
48
+ }
49
+ // adding more $_GET parameter
50
+ request = jQuery.extend( {}, settings, request);
51
+ lastXhr = jQuery.getJSON( s.domain, request, function( data, status, xhr ) {
52
+ // add term to cache
53
+ cache[ term ] = data;
54
+ if ( xhr === lastXhr )
55
+ response( data );
56
+ });
57
+ },
58
+ minLength: 0,
59
+ select: function( event, ui ) {
60
+ // adding this to the dropdown list
61
+ jQuery(obj).append( new Option(ui.item.label, ui.item.id) );
62
+ // now select it
63
+ jQuery(obj).val(ui.item.id);
64
+ jQuery(obj + "_ac").removeClass('ui-autocomplete-start');
65
+ }
66
+ });
67
+
68
+ jQuery(obj + "_ac").click(function() {
69
+
70
+ var search = jQuery(obj + "_ac").val();
71
+ // if the value is prefilled, we pass a empty string
72
+ if ( search == c_text)
73
+ search = '';
74
+ // pass empty string as value to search for, displaying all results
75
+ jQuery(obj + "_ac").autocomplete('search', search );
76
+ });
77
+ }
admin/js/plupload.handler.js CHANGED
@@ -1,244 +1,244 @@
1
- /**
2
- * NextGEN Gallery - plupload Handlers
3
- *
4
- * Built on top of the plupload library
5
- * http://www.plupload.com version 1.4.2
6
- *
7
- * version 1.0.0
8
- */
9
-
10
- // on load change the upload to plupload
11
- function initUploader() {
12
-
13
- jQuery(document).ready(function($){
14
-
15
- /* Not working in chrome, needs rework
16
- var dropElm = jQuery('#' + uploader.settings.drop_element);
17
- if (dropElm.length && uploader.features.dragdrop) {
18
- dropElm.bind('dragenter', function() {
19
- jQuery(this).css('border', '3px dashed #cccccc');
20
- });
21
- dropElm.bind('dragout drop', function() {
22
- jQuery(this).css('border', 'none');
23
- });
24
- }*/
25
-
26
- // enable or disable the resize feature
27
- jQuery('#image_resize').bind('change', function() {
28
- var arg = jQuery(this).prop('checked');
29
- setResize( arg );
30
-
31
- if ( arg )
32
- setUserSetting('ngg_upload_resize', '1');
33
- else
34
- deleteUserSetting('ngg_upload_resize');
35
- });
36
-
37
- // get user settings from cookie
38
- setResize( getUserSetting('ngg_upload_resize', false) );
39
-
40
- if ( uploader.features.dragdrop )
41
- jQuery('.ngg-dragdrop-info').show();
42
-
43
- jQuery("#uploadimage_btn").after("<input class='button-primary' type='button' name='uploadimage' id='plupload_btn' value='" + uploader.settings.i18n.upload + "' />")
44
- .remove();
45
- jQuery("#plupload_btn").click( function() { uploader.start(); } );
46
- });
47
- }
48
-
49
- // called when a file is added
50
- function fileQueued( fileObj ) {
51
- debug('[FilesAdded]', fileObj);
52
-
53
- filesize = " (" + plupload.formatSize(fileObj.size) + ") ";
54
- jQuery("#txtFileName").val(fileObj.name);
55
- jQuery("#uploadQueue")
56
- .append("<div id='" + fileObj.id + "' class='nggUploadItem'> [<a href=''>" + uploader.settings.i18n.remove + "</a>] " + fileObj.name + filesize + "</div>")
57
- .children("div:last").slideDown("slow")
58
- .end();
59
- jQuery('#' + fileObj.id + ' a').click(function(e) {
60
- jQuery('#' + fileObj.id).remove();
61
- uploader.removeFile(fileObj);
62
- e.preventDefault();
63
- });
64
- }
65
-
66
- // called before the uploads start
67
- function uploadStart(fileObj) {
68
- debug('[uploadStart]');
69
- nggProgressBar.init(nggAjaxOptions);
70
- // check if a gallery is selected
71
- if (jQuery('#galleryselect').val() > "0") {
72
- debug('[gallery selected]');
73
- // update the selected gallery in the post_params
74
- uploader.settings.multipart_params.galleryselect = jQuery('#galleryselect').val();
75
- } else {
76
- debug('[gallery not selected]');
77
- jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"-1\">");
78
- jQuery("#uploadimage_form").submit();
79
- }
80
- return true;
81
- }
82
-
83
- // called during the upload progress
84
- function uploadProgress(fileObj, bytesDone, bytesTotal) {
85
- var percent = Math.ceil((bytesDone / bytesTotal) * 100);
86
- debug('[uploadProgress]', fileObj.name + ' : ' + percent + "%");
87
- nggProgressBar.increase( percent );
88
- jQuery("#progressbar span").text(percent + "% - " + fileObj.name);
89
- }
90
-
91
- // called when all files are uploaded
92
- function uploadComplete(fileObj) {
93
- debug('[uploadComplete]');
94
-
95
- // Upload the next file until queue is empty
96
- if ( uploader.total.queued == 0) {
97
- //TODO: we submit here no error code
98
- jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"0\">");
99
- nggProgressBar.finished();
100
- jQuery("#uploadimage_form").submit();
101
- }
102
- }
103
-
104
- // called when the file is uploaded
105
- function uploadSuccess(fileObj, serverData) {
106
- debug('[uploadSuccess]', serverData);
107
-
108
- if (serverData.response != 0)
109
- nggProgressBar.addNote("<strong>ERROR</strong>: " + fileObj.name + " : " + serverData.response);
110
-
111
- jQuery("#" + fileObj.id).hide("slow");
112
- jQuery("#" + fileObj.id).remove();
113
- }
114
-
115
- function cancelUpload() {
116
- uploader.stop();
117
- jQuery.each(uploader.files, function(i,file) {
118
- if (file.status == plupload.STOPPED)
119
- jQuery('#' + file.id).remove();
120
- });
121
- }
122
-
123
- function uploadError(fileObj, errorCode, message) {
124
- debug('[uploadError]', errorCode, message);
125
- switch (errorCode) {
126
- case plupload.FAILED:
127
- error_name = fileObj.name + " : " + pluploadL10n.upload_failed;
128
- break;
129
- case plupload.FILE_EXTENSION_ERROR:
130
- error_name = fileObj.name + " : " + pluploadL10n.invalid_filetype;
131
- break;
132
- case plupload.FILE_SIZE_ERROR:
133
- error_name = fileObj.name + " : " + pluploadL10n.upload_limit_exceeded;
134
- break;
135
- case plupload.IMAGE_FORMAT_ERROR:
136
- error_name = fileObj.name + " : " + pluploadL10n.not_an_image;
137
- break;
138
- case plupload.IMAGE_MEMORY_ERROR:
139
- error_name = fileObj.name + " : " + pluploadL10n.image_memory_exceeded;
140
- break;
141
- case plupload.IMAGE_DIMENSIONS_ERROR:
142
- error_name = fileObj.name + " : " + pluploadL10n.image_dimensions_exceeded;
143
- break;
144
- case plupload.GENERIC_ERROR:
145
- error_name = pluploadL10n.upload_failed;
146
- break;
147
- case plupload.IO_ERROR:
148
- error_name = pluploadL10n.io_error;
149
- break;
150
- case plupload.HTTP_ERROR:
151
- error_name = pluploadL10n.http_error;
152
- break;
153
- case plupload.INIT_ERROR:
154
- /* what should we do in this case ? */
155
- //switchUploader(0);
156
- //jQuery('.upload-html-bypass').hide();
157
- break;
158
- case plupload.SECURITY_ERROR:
159
- error_name = pluploadL10n.security_error;
160
- break;
161
- case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
162
- case plupload.UPLOAD_ERROR.FILE_CANCELLED:
163
- break;
164
- default:
165
- FileError(fileObj, pluploadL10n.default_error);
166
- }
167
- nggProgressBar.addNote("<strong>ERROR " + error_name + " </strong>: " + message);
168
- jQuery("#" + fileObj.id).hide("slow");
169
- jQuery("#" + fileObj.id).remove();
170
- }
171
-
172
- // client side resize feature
173
- function setResize(arg) {
174
- if ( arg ) {
175
- debug('[enable resize]');
176
- if ( uploader.features.jpgresize )
177
- uploader.settings['resize'] = { width: resize_width, height: resize_height, quality: 100 };
178
- else
179
- uploader.settings.multipart_params.image_resize = true;
180
- } else {
181
- debug('[disable resize]');
182
- delete(uploader.settings.resize);
183
- delete(uploader.settings.multipart_params.image_resize);
184
- }
185
- }
186
-
187
- function debug() {
188
- if ( uploader.settings.debug ) {
189
- plupload.each(arguments, function(message) {
190
- var exceptionMessage, exceptionValues = [];
191
-
192
- // Check for an exception object and print it nicely
193
- if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
194
- for (var key in message) {
195
- if (message.hasOwnProperty(key)) {
196
- exceptionValues.push(key + ": " + message[key]);
197
- }
198
- }
199
- exceptionMessage = exceptionValues.join("\n") || "";
200
- exceptionValues = exceptionMessage.split("\n");
201
- exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
202
- if (window.console)
203
- console.log(exceptionMessage);
204
- else
205
- debugConsole(exceptionMessage);
206
- } else {
207
- if (window.console)
208
- console.log(message);
209
- else
210
- debugConsole(message);
211
- }
212
- });
213
- }
214
- };
215
-
216
- function debugConsole(message) {
217
- var console, documentForm;
218
-
219
- try {
220
- console = document.getElementById("plupload_Console");
221
-
222
- if (!console) {
223
- documentForm = document.createElement("form");
224
- document.getElementsByTagName("body")[0].appendChild(documentForm);
225
-
226
- console = document.createElement("textarea");
227
- console.id = "plupload_Console";
228
- console.style.fontFamily = "monospace";
229
- console.setAttribute("wrap", "off");
230
- console.wrap = "off";
231
- console.style.overflow = "auto";
232
- console.style.width = "99%";
233
- console.style.height = "350px";
234
- console.style.margin = "5px";
235
- documentForm.appendChild(console);
236
- }
237
-
238
- console.value += message + "\n";
239
-
240
- console.scrollTop = console.scrollHeight - console.clientHeight;
241
- } catch (ex) {
242
- alert("Exception: " + ex.name + " Message: " + ex.message);
243
- }
244
- };
1
+ /**
2
+ * NextGEN Gallery - plupload Handlers
3
+ *
4
+ * Built on top of the plupload library
5
+ * http://www.plupload.com version 1.4.2
6
+ *
7
+ * version 1.0.0
8
+ */
9
+
10
+ // on load change the upload to plupload
11
+ function initUploader() {
12
+
13
+ jQuery(document).ready(function($){
14
+
15
+ /* Not working in chrome, needs rework
16
+ var dropElm = jQuery('#' + uploader.settings.drop_element);
17
+ if (dropElm.length && uploader.features.dragdrop) {
18
+ dropElm.bind('dragenter', function() {
19
+ jQuery(this).css('border', '3px dashed #cccccc');
20
+ });
21
+ dropElm.bind('dragout drop', function() {
22
+ jQuery(this).css('border', 'none');
23
+ });
24
+ }*/
25
+
26
+ // enable or disable the resize feature
27
+ jQuery('#image_resize').bind('change', function() {
28
+ var arg = jQuery(this).prop('checked');
29
+ setResize( arg );
30
+
31
+ if ( arg )
32
+ setUserSetting('ngg_upload_resize', '1');
33
+ else
34
+ deleteUserSetting('ngg_upload_resize');
35
+ });
36
+
37
+ // get user settings from cookie
38
+ setResize( getUserSetting('ngg_upload_resize', false) );
39
+
40
+ if ( uploader.features.dragdrop )
41
+ jQuery('.ngg-dragdrop-info').show();
42
+
43
+ jQuery("#uploadimage_btn").after("<input class='button-primary' type='button' name='uploadimage' id='plupload_btn' value='" + uploader.settings.i18n.upload + "' />")
44
+ .remove();
45
+ jQuery("#plupload_btn").click( function() { uploader.start(); } );
46
+ });
47
+ }
48
+
49
+ // called when a file is added
50
+ function fileQueued( fileObj ) {
51
+ debug('[FilesAdded]', fileObj);
52
+
53
+ filesize = " (" + plupload.formatSize(fileObj.size) + ") ";
54
+ jQuery("#txtFileName").val(fileObj.name);
55
+ jQuery("#uploadQueue")
56
+ .append("<div id='" + fileObj.id + "' class='nggUploadItem'> [<a href=''>" + uploader.settings.i18n.remove + "</a>] " + fileObj.name + filesize + "</div>")
57
+ .children("div:last").slideDown("slow")
58
+ .end();
59
+ jQuery('#' + fileObj.id + ' a').click(function(e) {
60
+ jQuery('#' + fileObj.id).remove();
61
+ uploader.removeFile(fileObj);
62
+ e.preventDefault();
63
+ });
64
+ }
65
+
66
+ // called before the uploads start
67
+ function uploadStart(fileObj) {
68
+ debug('[uploadStart]');
69
+ nggProgressBar.init(nggAjaxOptions);
70
+ // check if a gallery is selected
71
+ if (jQuery('#galleryselect').val() > "0") {
72
+ debug('[gallery selected]');
73
+ // update the selected gallery in the post_params
74
+ uploader.settings.multipart_params.galleryselect = jQuery('#galleryselect').val();
75
+ } else {
76
+ debug('[gallery not selected]');
77
+ jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"-1\">");
78
+ jQuery("#uploadimage_form").submit();
79
+ }
80
+ return true;
81
+ }
82
+
83
+ // called during the upload progress
84
+ function uploadProgress(fileObj, bytesDone, bytesTotal) {
85
+ var percent = Math.ceil((bytesDone / bytesTotal) * 100);
86
+ debug('[uploadProgress]', fileObj.name + ' : ' + percent + "%");
87
+ nggProgressBar.increase( percent );
88
+ jQuery("#progressbar span").text(percent + "% - " + fileObj.name);
89
+ }
90
+
91
+ // called when all files are uploaded
92
+ function uploadComplete(fileObj) {
93
+ debug('[uploadComplete]');
94
+
95
+ // Upload the next file until queue is empty
96
+ if ( uploader.total.queued == 0) {
97
+ //TODO: we submit here no error code
98
+ jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"0\">");
99
+ nggProgressBar.finished();
100
+ jQuery("#uploadimage_form").submit();
101
+ }
102
+ }
103
+
104
+ // called when the file is uploaded
105
+ function uploadSuccess(fileObj, serverData) {
106
+ debug('[uploadSuccess]', serverData);
107
+
108
+ if (serverData.response != 0)
109
+ nggProgressBar.addNote("<strong>ERROR</strong>: " + fileObj.name + " : " + serverData.response);
110
+
111
+ jQuery("#" + fileObj.id).hide("slow");
112
+ jQuery("#" + fileObj.id).remove();
113
+ }
114
+
115
+ function cancelUpload() {
116
+ uploader.stop();
117
+ jQuery.each(uploader.files, function(i,file) {
118
+ if (file.status == plupload.STOPPED)
119
+ jQuery('#' + file.id).remove();
120
+ });
121
+ }
122
+
123
+ function uploadError(fileObj, errorCode, message) {
124
+ debug('[uploadError]', errorCode, message);
125
+ switch (errorCode) {
126
+ case plupload.FAILED:
127
+ error_name = fileObj.name + " : " + pluploadL10n.upload_failed;
128
+ break;
129
+ case plupload.FILE_EXTENSION_ERROR:
130
+ error_name = fileObj.name + " : " + pluploadL10n.invalid_filetype;
131
+ break;
132
+ case plupload.FILE_SIZE_ERROR:
133
+ error_name = fileObj.name + " : " + pluploadL10n.upload_limit_exceeded;
134
+ break;
135
+ case plupload.IMAGE_FORMAT_ERROR:
136
+ error_name = fileObj.name + " : " + pluploadL10n.not_an_image;
137
+ break;
138
+ case plupload.IMAGE_MEMORY_ERROR:
139
+ error_name = fileObj.name + " : " + pluploadL10n.image_memory_exceeded;
140
+ break;
141
+ case plupload.IMAGE_DIMENSIONS_ERROR:
142
+ error_name = fileObj.name + " : " + pluploadL10n.image_dimensions_exceeded;
143
+ break;
144
+ case plupload.GENERIC_ERROR:
145
+ error_name = pluploadL10n.upload_failed;
146
+ break;
147
+ case plupload.IO_ERROR:
148
+ error_name = pluploadL10n.io_error;
149
+ break;
150
+ case plupload.HTTP_ERROR:
151
+ error_name = pluploadL10n.http_error;
152
+ break;
153
+ case plupload.INIT_ERROR:
154
+ /* what should we do in this case ? */
155
+ //switchUploader(0);
156
+ //jQuery('.upload-html-bypass').hide();
157
+ break;
158
+ case plupload.SECURITY_ERROR:
159
+ error_name = pluploadL10n.security_error;
160
+ break;
161
+ case plupload.UPLOAD_ERROR.UPLOAD_STOPPED:
162
+ case plupload.UPLOAD_ERROR.FILE_CANCELLED:
163
+ break;
164
+ default:
165
+ FileError(fileObj, pluploadL10n.default_error);
166
+ }
167
+ nggProgressBar.addNote("<strong>ERROR " + error_name + " </strong>: " + message);
168
+ jQuery("#" + fileObj.id).hide("slow");
169
+ jQuery("#" + fileObj.id).remove();
170
+ }
171
+
172
+ // client side resize feature
173
+ function setResize(arg) {
174
+ if ( arg ) {
175
+ debug('[enable resize]');
176
+ if ( uploader.features.jpgresize )
177
+ uploader.settings['resize'] = { width: resize_width, height: resize_height, quality: 100 };
178
+ else
179
+ uploader.settings.multipart_params.image_resize = true;
180
+ } else {
181
+ debug('[disable resize]');
182
+ delete(uploader.settings.resize);
183
+ delete(uploader.settings.multipart_params.image_resize);
184
+ }
185
+ }
186
+
187
+ function debug() {
188
+ if ( uploader.settings.debug ) {
189
+ plupload.each(arguments, function(message) {
190
+ var exceptionMessage, exceptionValues = [];
191
+
192
+ // Check for an exception object and print it nicely
193
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
194
+ for (var key in message) {
195
+ if (message.hasOwnProperty(key)) {
196
+ exceptionValues.push(key + ": " + message[key]);
197
+ }
198
+ }
199
+ exceptionMessage = exceptionValues.join("\n") || "";
200
+ exceptionValues = exceptionMessage.split("\n");
201
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
202
+ if (window.console)
203
+ console.log(exceptionMessage);
204
+ else
205
+ debugConsole(exceptionMessage);
206
+ } else {
207
+ if (window.console)
208
+ console.log(message);
209
+ else
210
+ debugConsole(message);
211
+ }
212
+ });
213
+ }
214
+ };
215
+
216
+ function debugConsole(message) {
217
+ var console, documentForm;
218
+
219
+ try {
220
+ console = document.getElementById("plupload_Console");
221
+
222
+ if (!console) {
223
+ documentForm = document.createElement("form");
224
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
225
+
226
+ console = document.createElement("textarea");
227
+ console.id = "plupload_Console";
228
+ console.style.fontFamily = "monospace";
229
+ console.setAttribute("wrap", "off");
230
+ console.wrap = "off";
231
+ console.style.overflow = "auto";
232
+ console.style.width = "99%";
233
+ console.style.height = "350px";
234
+ console.style.margin = "5px";
235
+ documentForm.appendChild(console);
236
+ }
237
+
238
+ console.value += message + "\n";
239
+
240
+ console.scrollTop = console.scrollHeight - console.clientHeight;
241
+ } catch (ex) {
242
+ alert("Exception: " + ex.name + " Message: " + ex.message);
243
+ }
244
+ };
admin/manage-images.php CHANGED
@@ -258,7 +258,9 @@ jQuery(document).ready( function() {
258
  <th align="left">
259
  <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery page id' ); ?> name="pageid" style="width:95%">
260
  <option value="0" ><?php _e('Not linked', 'nggallery') ?></option>
261
- <?php parent_dropdown($gallery->pageid); ?>
 
 
262
  </select>
263
  </th>
264
  </tr>
@@ -311,7 +313,9 @@ jQuery(document).ready( function() {
311
  <th align="left">
312
  <select name="parent_id" style="width:95%">
313
  <option value="0"><?php _e ('Main page (No parent)', 'nggallery'); ?></option>
 
314
  <?php parent_dropdown (); ?>
 
315
  </select>
316
  <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e ('Add page', 'nggallery'); ?>" id="group"/>
317
  </th>
258
  <th align="left">
259
  <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery page id' ); ?> name="pageid" style="width:95%">
260
  <option value="0" ><?php _e('Not linked', 'nggallery') ?></option>
261
+ <?php $err = error_reporting(0); ?>
262
+ <?php parent_dropdown(intval($gallery->pageid)); ?>
263
+ <?php error_reporting($err); ?>
264
  </select>
265
  </th>
266
  </tr>
313
  <th align="left">
314
  <select name="parent_id" style="width:95%">
315
  <option value="0"><?php _e ('Main page (No parent)', 'nggallery'); ?></option>
316
+ <?php if (get_post()): ?>
317
  <?php parent_dropdown (); ?>
318
+ <?php endif ?>
319
  </select>
320
  <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e ('Add page', 'nggallery'); ?>" id="group"/>
321
  </th>
admin/publish.php CHANGED
@@ -1,64 +1,64 @@
1
- <?php
2
-
3
- require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
4
- require_once( NGGALLERY_ABSPATH . '/lib/image.php' );
5
-
6
- if ( !is_user_logged_in() )
7
- die(__('Cheatin&#8217; uh?'));
8
-
9
- if ( !current_user_can('NextGEN Manage gallery') )
10
- die(__('Cheatin&#8217; uh?'));
11
-
12
- if ( !current_user_can( 'publish_posts' ) )
13
- die(__('Cheatin&#8217; uh?'));
14
-
15
- global $wpdb;
16
-
17
- $id = (int) $_GET['id'];
18
-
19
- // let's get the image data
20
- $picture = nggdb::find_image($id);
21
-
22
- // use defaults the first time
23
- $width = empty ($ngg->options['publish_width']) ? $ngg->options['thumbwidth'] : $ngg->options['publish_width'];
24
- $height = empty ($ngg->options['publish_height']) ? $ngg->options['thumbheight'] : $ngg->options['publish_height'];
25
- $align = empty ($ngg->options['publish_align']) ? 'none' : $ngg->options['publish_align'];
26
-
27
- ?>
28
-
29
- <form id="form-publish-post" method="POST" accept-charset="utf-8">
30
- <?php wp_nonce_field('publish-post') ?>
31
- <input type="hidden" name="page" value="publish-post" />
32
- <input type="hidden" name="pid" value="<?php echo $picture->pid; ?>" />
33
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
34
- <tr valign="top">
35
- <th align="left"><?php _e('Post title','nggallery') ?></th>
36
- <td><input type="text" size="70" name="post_title" value="<?php echo esc_attr( $picture->alttext); ?>" />
37
- <br /><small><?php _e('Enter the post title ','nggallery') ?></small></td>
38
- </tr>
39
- <tr valign="top">
40
- <th align="left"><?php _e('Width x height (in pixel)','nggallery') ?></th>
41
- <td><input type="text" size="5" maxlength="5" name="width" value="<?php echo $width; ?>" /> x <input type="text" size="5" maxlength="5" name="height" value="<?php echo $height; ?>" />
42
- <br /><small><?php _e('Size of the image','nggallery') ?></small></td>
43
- </tr>
44
- <tr valign="top">
45
- <th align="left"><?php _e('Alignment','nggallery') ?></th>
46
- <td><input type="radio" value="none" <?php checked('none', $align); ?> id="image-align-none" name="align"/>
47
- <label class="align" for="image-align-none"><?php _e('None','nggallery'); ?></label>
48
- <input type="radio" value="left" <?php checked('left', $align); ?> id="image-align-left" name="align"/>
49
- <label class="align" for="image-align-left"><?php _e('Left','nggallery'); ?></label>
50
- <input type="radio" value="center" <?php checked('center', $align); ?> id="image-align-center" name="align"/>
51
- <label class="align" for="image-align-center"><?php _e('Center','nggallery'); ?></label>
52
- <input type="radio" value="right" <?php checked('right', $align); ?> id="image-align-right" name="align"/>
53
- <label class="align" for="image-align-right"><?php _e('Right','nggallery'); ?></label>
54
- </td>
55
- </tr>
56
- <tr align="right">
57
- <td colspan="2" class="submit">
58
- <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish', 'nggallery');?>" />
59
- &nbsp;
60
- <input class="button-secondary" type="submit" name="draft" value="&nbsp;<?php _e('Draft', 'nggallery'); ?>&nbsp;" />
61
- </td>
62
- </tr>
63
- </table>
64
  </form>
1
+ <?php
2
+
3
+ require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
4
+ require_once( NGGALLERY_ABSPATH . '/lib/image.php' );
5
+
6
+ if ( !is_user_logged_in() )
7
+ die(__('Cheatin&#8217; uh?'));
8
+
9
+ if ( !current_user_can('NextGEN Manage gallery') )
10
+ die(__('Cheatin&#8217; uh?'));
11
+
12
+ if ( !current_user_can( 'publish_posts' ) )
13
+ die(__('Cheatin&#8217; uh?'));
14
+
15
+ global $wpdb;
16
+
17
+ $id = (int) $_GET['id'];
18
+
19
+ // let's get the image data
20
+ $picture = nggdb::find_image($id);
21
+
22
+ // use defaults the first time
23
+ $width = empty ($ngg->options['publish_width']) ? $ngg->options['thumbwidth'] : $ngg->options['publish_width'];
24
+ $height = empty ($ngg->options['publish_height']) ? $ngg->options['thumbheight'] : $ngg->options['publish_height'];
25
+ $align = empty ($ngg->options['publish_align']) ? 'none' : $ngg->options['publish_align'];
26
+
27
+ ?>
28
+
29
+ <form id="form-publish-post" method="POST" accept-charset="utf-8">
30
+ <?php wp_nonce_field('publish-post') ?>
31
+ <input type="hidden" name="page" value="publish-post" />
32
+ <input type="hidden" name="pid" value="<?php echo $picture->pid; ?>" />
33
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
34
+ <tr valign="top">
35
+ <th align="left"><?php _e('Post title','nggallery') ?></th>
36
+ <td><input type="text" size="70" name="post_title" value="<?php echo esc_attr( $picture->alttext); ?>" />
37
+ <br /><small><?php _e('Enter the post title ','nggallery') ?></small></td>
38
+ </tr>
39
+ <tr valign="top">
40
+ <th align="left"><?php _e('Width x height (in pixel)','nggallery') ?></th>
41
+ <td><input type="text" size="5" maxlength="5" name="width" value="<?php echo $width; ?>" /> x <input type="text" size="5" maxlength="5" name="height" value="<?php echo $height; ?>" />
42
+ <br /><small><?php _e('Size of the image','nggallery') ?></small></td>
43
+ </tr>
44
+ <tr valign="top">
45
+ <th align="left"><?php _e('Alignment','nggallery') ?></th>
46
+ <td><input type="radio" value="none" <?php checked('none', $align); ?> id="image-align-none" name="align"/>
47
+ <label class="align" for="image-align-none"><?php _e('None','nggallery'); ?></label>
48
+ <input type="radio" value="left" <?php checked('left', $align); ?> id="image-align-left" name="align"/>
49
+ <label class="align" for="image-align-left"><?php _e('Left','nggallery'); ?></label>
50
+ <input type="radio" value="center" <?php checked('center', $align); ?> id="image-align-center" name="align"/>
51
+ <label class="align" for="image-align-center"><?php _e('Center','nggallery'); ?></label>
52
+ <input type="radio" value="right" <?php checked('right', $align); ?> id="image-align-right" name="align"/>
53
+ <label class="align" for="image-align-right"><?php _e('Right','nggallery'); ?></label>
54
+ </td>
55
+ </tr>
56
+ <tr align="right">
57
+ <td colspan="2" class="submit">
58
+ <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish', 'nggallery');?>" />
59
+ &nbsp;
60
+ <input class="button-secondary" type="submit" name="draft" value="&nbsp;<?php _e('Draft', 'nggallery'); ?>&nbsp;" />
61
+ </td>
62
+ </tr>
63
+ </table>
64
  </form>
admin/settings.php CHANGED
@@ -198,6 +198,7 @@ class nggOptions {
198
 
199
  if ( isset($_POST['createslugs']) ) {
200
  check_admin_referer('ngg_settings');
 
201
  ngg_rebuild_unique_slugs::start_rebuild();
202
  }
203
 
198
 
199
  if ( isset($_POST['createslugs']) ) {
200
  check_admin_referer('ngg_settings');
201
+ include_once (dirname (__FILE__) . '/upgrade.php');
202
  ngg_rebuild_unique_slugs::start_rebuild();
203
  }
204
 
admin/tinymce/tinymce.js CHANGED
@@ -20,13 +20,13 @@ function getCheckedValue(radioObj) {
20
  }
21
 
22
  function insertNGGLink() {
23
-
24
  var tagtext;
25
-
26
  var gallery = document.getElementById('gallery_panel');
27
  var album = document.getElementById('album_panel');
28
  var singlepic = document.getElementById('singlepic_panel');
29
-
30
  // who is active ?
31
  if (gallery.className.indexOf('current') != -1) {
32
  var galleryid = document.getElementById('gallerytag').value;
@@ -41,7 +41,7 @@ function insertNGGLink() {
41
  var albumid = document.getElementById('albumtag').value;
42
  var showtype = getCheckedValue(document.getElementsByName('albumtype'));
43
  if (albumid != 0 )
44
- tagtext = "[album id=" + albumid + " template=" + showtype + "]";
45
  else
46
  tinyMCEPopup.close();
47
  }
@@ -62,12 +62,12 @@ function insertNGGLink() {
62
  tinyMCEPopup.close();
63
  }
64
  }
65
-
66
  if(window.tinyMCE) {
67
  window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, tagtext);
68
- //Peforms a clean up of the current editor HTML.
69
  //tinyMCEPopup.editor.execCommand('mceCleanup');
70
- //Repaints the editor. Sometimes the browser has graphic glitches.
71
  tinyMCEPopup.editor.execCommand('mceRepaint');
72
  tinyMCEPopup.close();
73
  }
20
  }
21
 
22
  function insertNGGLink() {
23
+
24
  var tagtext;
25
+
26
  var gallery = document.getElementById('gallery_panel');
27
  var album = document.getElementById('album_panel');
28
  var singlepic = document.getElementById('singlepic_panel');
29
+
30
  // who is active ?
31
  if (gallery.className.indexOf('current') != -1) {
32
  var galleryid = document.getElementById('gallerytag').value;
41
  var albumid = document.getElementById('albumtag').value;
42
  var showtype = getCheckedValue(document.getElementsByName('albumtype'));
43
  if (albumid != 0 )
44
+ tagtext = "[nggalbum id=" + albumid + " template=" + showtype + "]";
45
  else
46
  tinyMCEPopup.close();
47
  }
62
  tinyMCEPopup.close();
63
  }
64
  }
65
+
66
  if(window.tinyMCE) {
67
  window.tinyMCE.execInstanceCommand(window.tinyMCE.activeEditor.id, 'mceInsertContent', false, tagtext);
68
+ //Peforms a clean up of the current editor HTML.
69
  //tinyMCEPopup.editor.execCommand('mceCleanup');
70
+ //Repaints the editor. Sometimes the browser has graphic glitches.
71
  tinyMCEPopup.editor.execCommand('mceRepaint');
72
  tinyMCEPopup.close();
73
  }
admin/upload.php CHANGED
@@ -23,7 +23,7 @@ if (wp_validate_auth_cookie()) {
23
  $logged_in = FALSE;
24
  if (isset($results['username']) && isset($results['expiration'])) {
25
  if (time() < floatval($results['expiration'])) {
26
- if (($userdata = get_userdatabylogin($results['username'])))
27
  $logged_in = $userdata->ID;
28
  }
29
  }
23
  $logged_in = FALSE;
24
  if (isset($results['username']) && isset($results['expiration'])) {
25
  if (time() < floatval($results['expiration'])) {
26
+ if (($userdata = get_user_by('login', $results['username'])))
27
  $logged_in = $userdata->ID;
28
  }
29
  }
changelog.txt CHANGED
@@ -1,5 +1,18 @@
1
  NextGEN Gallery
2
  by Photocrati Media
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  = V1.9.10 - 12.18.2012 =
5
  * Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
1
  NextGEN Gallery
2
  by Photocrati Media
3
+ = V1.9.11 - 02.12.2013 =
4
+ * NEW: Added the ability to detect JQuery conflicts on NGG Admin Pages and auto-resolve
5
+ * Changed: Added "nggalbum" shortcode. Use this when Jetpack is installed.
6
+ * Changed: Using natural sorting algorithm for alphanumeric values
7
+ * Changed: Database schema is automatically updated when out-of-date
8
+ * Fixed: Empty drop-down for "Page Link To"
9
+ * Fixed: Alphabetical image sorting
10
+ * Fixed: Compatibility with Arjuna X theme
11
+ * Fixed: “Creating default object from empty value” on album page
12
+ * Fixed: Compatibility issues with PHP 5.4 on album page
13
+ * Fixed: E_DEPRECATED warning when using get_userdatabylogin() function
14
+ * Fixed: Removed many E_NOTICE errors
15
+ * Fixed: Correct use of register_uninstall_hook across all PHP versions
16
 
17
  = V1.9.10 - 12.18.2012 =
18
  * Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
css/nggallery.css CHANGED
@@ -76,7 +76,6 @@ html>body .ngg-album {
76
 
77
  .ngg-album-compact {
78
  float:left;
79
- height:180px;
80
  padding-right:6px !important;
81
  margin:0px !important;
82
  text-align:left;
@@ -161,6 +160,7 @@ html>body .ngg-album {
161
 
162
  .ngg-clear {
163
  clear: both;
 
164
  }
165
 
166
  /* ----------- Gallery navigation -------------*/
76
 
77
  .ngg-album-compact {
78
  float:left;
 
79
  padding-right:6px !important;
80
  margin:0px !important;
81
  text-align:left;
160
 
161
  .ngg-clear {
162
  clear: both;
163
+ float: none;
164
  }
165
 
166
  /* ----------- Gallery navigation -------------*/
lib/core.php CHANGED
@@ -1,63 +1,63 @@
1
  <?php
2
  /**
3
  * Main PHP class for the WordPress plugin NextGEN Gallery
4
- *
5
  * @author Alex Rabe
6
- *
7
- *
8
  */
9
  class nggGallery {
10
-
11
  /**
12
  * Show a error messages
13
  */
14
- function show_error($message) {
15
  echo '<div class="wrap"><h2></h2><div class="error" id="error"><p>' . $message . '</p></div></div>' . "\n";
16
  }
17
-
18
  /**
19
  * Show a system messages
20
  */
21
- function show_message($message) {
22
  echo '<div class="wrap"><h2></h2><div class="updated fade" id="message"><p>' . $message . '</p></div></div>' . "\n";
23
  }
24
 
25
  /**
26
  * get the thumbnail url to the image
27
  */
28
- function get_thumbnail_url($imageID, $picturepath = '', $fileName = ''){
29
-
30
  // get the complete url to the thumbnail
31
  global $wpdb;
32
-
33
  // safety first
34
  $imageID = (int) $imageID;
35
-
36
  // get gallery values
37
  if ( empty($fileName) ) {
38
  list($fileName, $picturepath ) = $wpdb->get_row("SELECT p.filename, g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ", ARRAY_N);
39
  }
40
-
41
  if ( empty($picturepath) ) {
42
  $picturepath = $wpdb->get_var("SELECT g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ");
43
  }
44
-
45
  // set gallery url
46
  $folder_url = site_url() . '/' . $picturepath.nggGallery::get_thumbnail_folder($picturepath, FALSE);
47
  $thumbnailURL = $folder_url . 'thumbs_' . $fileName;
48
-
49
  return $thumbnailURL;
50
  }
51
-
52
  /**
53
  * get the complete url to the image
54
  */
55
- function get_image_url($imageID, $picturepath = '', $fileName = '') {
56
  global $wpdb;
57
 
58
  // safety first
59
  $imageID = (int) $imageID;
60
-
61
  // get gallery values
62
  if (empty($fileName)) {
63
  list($fileName, $picturepath ) = $wpdb->get_row("SELECT p.filename, g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ", ARRAY_N);
@@ -66,38 +66,38 @@ class nggGallery {
66
  if (empty($picturepath)) {
67
  $picturepath = $wpdb->get_var("SELECT g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ");
68
  }
69
-
70
  // set gallery url
71
  $imageURL = site_url() . '/' . $picturepath . '/' . $fileName;
72
-
73
- return $imageURL;
74
  }
75
 
76
  /**
77
  * nggGallery::get_thumbnail_folder()
78
- *
79
  * @param mixed $gallerypath
80
  * @param bool $include_Abspath
81
  * @return string $foldername
82
  */
83
- function create_thumbnail_folder($gallerypath, $include_Abspath = TRUE) {
84
  if (!$include_Abspath) {
85
  $gallerypath = WINABSPATH . $gallerypath;
86
  }
87
-
88
  if (!file_exists($gallerypath)) {
89
  return FALSE;
90
  }
91
-
92
  if (is_dir($gallerypath . '/thumbs/')) {
93
  return '/thumbs/';
94
  }
95
-
96
  if (is_admin()) {
97
  if (!is_dir($gallerypath . '/thumbs/')) {
98
  if ( !wp_mkdir_p($gallerypath . '/thumbs/') ) {
99
  if (SAFE_MODE) {
100
- nggAdmin::check_safemode($gallerypath . '/thumbs/');
101
  } else {
102
  nggGallery::show_error(__('Unable to create directory ', 'nggallery') . $gallerypath . '/thumbs !');
103
  }
@@ -106,57 +106,57 @@ class nggGallery {
106
  return '/thumbs/';
107
  }
108
  }
109
-
110
  return FALSE;
111
-
112
  }
113
 
114
  /**
115
  * nggGallery::get_thumbnail_folder()
116
- *
117
  * @param mixed $gallerypath
118
  * @param bool $include_Abspath
119
  * @deprecated use create_thumbnail_folder() if needed;
120
  * @return string $foldername
121
  */
122
- function get_thumbnail_folder($gallerypath, $include_Abspath = TRUE) {
123
  return nggGallery::create_thumbnail_folder($gallerypath, $include_Abspath);
124
  }
125
-
126
  /**
127
  * nggGallery::get_thumbnail_prefix() - obsolete
128
- *
129
  * @param string $gallerypath
130
  * @param bool $include_Abspath
131
  * @deprecated prefix is now fixed to "thumbs_";
132
  * @return string "thumbs_";
133
  */
134
- function get_thumbnail_prefix($gallerypath, $include_Abspath = TRUE) {
135
- return 'thumbs_';
136
  }
137
-
138
  /**
139
  * nggGallery::get_option() - get the options and overwrite them with custom meta settings
140
  *
141
  * @param string $key
142
  * @return array $options
143
  */
144
- function get_option($key) {
145
  global $post;
146
-
147
- // get first the options from the database
148
  $options = get_option($key);
149
 
150
  if ( $post == null )
151
  return $options;
152
-
153
- // Get all key/value data for the current post.
154
  $meta_array = get_post_custom();
155
-
156
  // Ensure that this is a array
157
  if ( !is_array($meta_array) )
158
  $meta_array = array($meta_array);
159
-
160
  // assign meta key to db setting key
161
  $meta_tags = array(
162
  'string' => array(
@@ -194,7 +194,7 @@ class nggGallery {
194
  'ngg_ir_Kenburns' => 'irKenburns'
195
  )
196
  );
197
-
198
  foreach ($meta_tags as $typ => $meta_keys){
199
  foreach ($meta_keys as $key => $db_value){
200
  // if the kex exist overwrite it with the custom field
@@ -208,29 +208,29 @@ class nggGallery {
208
  break;
209
  case 'bool':
210
  $options[$db_value] = (bool) $meta_array[$key][0];
211
- break;
212
  }
213
  }
214
  }
215
  }
216
-
217
  return $options;
218
  }
219
-
220
  /**
221
  * nggGallery::scale_image() - Scale down a image
222
- *
223
  * @param mixed $location (filename)
224
  * @param int $maxw - max width
225
  * @param int $maxh - max height
226
- * @return array (width, heigth)
227
  */
228
- function scale_image($location, $maxw = 0, $maxh = 0){
229
  $img = @getimagesize($location);
230
  if ($img){
231
  $w = $img[0];
232
  $h = $img[1];
233
-
234
  $dim = array('w','h');
235
  foreach($dim AS $val) {
236
  $max = "max{$val}";
@@ -241,12 +241,12 @@ class nggGallery {
241
  ${$alt} = ${$val} * $ratio;
242
  }
243
  }
244
-
245
  return array( $w, $h );
246
  }
247
  return false;
248
- }
249
-
250
  /**
251
  * Renders a section of user display code. The code is first checked for in the current theme display directory
252
  * before defaulting to the plugin
@@ -258,14 +258,14 @@ class nggGallery {
258
  * @param bool $callback In case we check we didn't find template we tested it one time more (optional)
259
  * @return void
260
  **/
261
- function render($template_name, $vars = array (), $callback = false) {
262
  foreach ($vars AS $key => $val) {
263
  $$key = $val;
264
  }
265
-
266
  // hook into the render feature to allow other plugins to include templates
267
  $custom_template = apply_filters( 'ngg_render_template', false, $template_name );
268
-
269
  if ( ( $custom_template != false ) && file_exists ($custom_template) ) {
270
  include ( $custom_template );
271
  } else if (file_exists (STYLESHEETPATH . "/nggallery/$template_name.php")) {
@@ -273,14 +273,14 @@ class nggGallery {
273
  } else if (file_exists (NGGALLERY_ABSPATH . "/view/$template_name.php")) {
274
  include (NGGALLERY_ABSPATH . "/view/$template_name.php");
275
  } else if ( $callback === true ) {
276
- echo "<p>Rendering of template $template_name.php failed</p>";
277
  } else {
278
  //test without the "-template" name one time more
279
  $template_name = array_shift( explode('-', $template_name , 2) );
280
  nggGallery::render ($template_name, $vars , true);
281
  }
282
  }
283
-
284
  /**
285
  * Captures an section of user display code.
286
  *
@@ -289,232 +289,232 @@ class nggGallery {
289
  * @param string $vars Array of variable name=>value that is available to the display code (optional)
290
  * @return void
291
  **/
292
- function capture ($template_name, $vars = array ()) {
293
  ob_start ();
294
  nggGallery::render ($template_name, $vars);
295
  $output = ob_get_contents ();
296
  ob_end_clean ();
297
-
298
  return $output;
299
  }
300
-
301
  /**
302
  * nggGallery::graphic_library() - switch between GD and ImageMagick
303
- *
304
  * @return path to the selected library
305
  */
306
- function graphic_library() {
307
-
308
  $ngg_options = get_option('ngg_options');
309
-
310
  if ( $ngg_options['graphicLibrary'] == 'im')
311
  return NGGALLERY_ABSPATH . '/lib/imagemagick.inc.php';
312
  else
313
  return NGGALLERY_ABSPATH . '/lib/gd.thumbnail.inc.php';
314
-
315
  }
316
-
317
  /**
318
  * Look for the stylesheet in the theme folder
319
- *
320
  * @return string path to stylesheet
321
  */
322
- function get_theme_css_file() {
323
-
324
  // allow other plugins to include a custom stylesheet
325
  $stylesheet = apply_filters( 'ngg_load_stylesheet', false );
326
-
327
  if ( $stylesheet !== false )
328
  return ( $stylesheet );
329
  elseif ( file_exists (STYLESHEETPATH . '/nggallery.css') )
330
  return get_stylesheet_directory_uri() . '/nggallery.css';
331
  else
332
- return false;
333
  }
334
 
335
  /**
336
  * Support for i18n with wpml, polyglot or qtrans
337
- *
338
  * @param string $in
339
  * @param string $name (optional) required for wpml to determine the type of translation
340
  * @return string $in localized
341
  */
342
- function i18n($in, $name = null) {
343
-
344
  if ( function_exists( 'langswitch_filter_langs_with_message' ) )
345
  $in = langswitch_filter_langs_with_message($in);
346
-
347
  if ( function_exists( 'polyglot_filter' ))
348
  $in = polyglot_filter($in);
349
-
350
  if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ))
351
  $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in);
352
 
353
  if (is_string($name) && !empty($name) && function_exists('icl_translate'))
354
  $in = icl_translate('plugin_ngg', $name, $in, true);
355
-
356
  $in = apply_filters('localization', $in);
357
-
358
  return $in;
359
  }
360
 
361
  /**
362
  * This function register strings for the use with WPML plugin (see http://wpml.org/ )
363
- *
364
  * @param object $image
365
  * @return void
366
  */
367
- function RegisterString($image) {
368
  if (function_exists('icl_register_string')) {
369
  global $wpdb;
370
  icl_register_string('plugin_ngg', 'pic_' . $image->pid . '_description', $image->description, TRUE);
371
  icl_register_string('plugin_ngg', 'pic_' . $image->pid . '_alttext', $image->alttext, TRUE);
372
  }
373
  }
374
-
375
  /**
376
  * Check the memory_limit and calculate a recommended memory size
377
- *
378
  * @since V1.2.0
379
  * @return string message about recommended image size
380
  */
381
- function check_memory_limit() {
382
 
383
  if ( (function_exists('memory_get_usage')) && (ini_get('memory_limit')) ) {
384
-
385
  // get memory limit
386
  $memory_limit = ini_get('memory_limit');
387
  if ($memory_limit != '')
388
  $memory_limit = substr($memory_limit, 0, -1) * 1024 * 1024;
389
-
390
- // calculate the free memory
391
  $freeMemory = $memory_limit - memory_get_usage();
392
-
393
  // build the test sizes
394
  $sizes = array();
395
  $sizes[] = array ( 'width' => 800, 'height' => 600);
396
  $sizes[] = array ( 'width' => 1024, 'height' => 768);
397
- $sizes[] = array ( 'width' => 1280, 'height' => 960); // 1MP
398
  $sizes[] = array ( 'width' => 1600, 'height' => 1200); // 2MP
399
  $sizes[] = array ( 'width' => 2016, 'height' => 1512); // 3MP
400
  $sizes[] = array ( 'width' => 2272, 'height' => 1704); // 4MP
401
  $sizes[] = array ( 'width' => 2560, 'height' => 1920); // 5MP
402
-
403
  // test the classic sizes
404
  foreach ($sizes as $size){
405
  // very, very rough estimation
406
  if ($freeMemory < round( $size['width'] * $size['height'] * 5.09 )) {
407
- $result = sprintf( __( 'Note : Based on your server memory limit you should not upload larger images then <strong>%d x %d</strong> pixel', 'nggallery' ), $size['width'], $size['height']);
408
  return $result;
409
  }
410
  }
411
  }
412
  return;
413
  }
414
-
415
  /**
416
  * Slightly modfifed version of pathinfo(), clean up filename & rename jpeg to jpg
417
- *
418
- * @param string $name The name being checked.
419
  * @return array containing information about file
420
  */
421
- function fileinfo( $name ) {
422
-
423
  //Sanitizes a filename replacing whitespace with dashes
424
  $name = sanitize_file_name($name);
425
-
426
  //get the parts of the name
427
  $filepart = pathinfo ( strtolower($name) );
428
-
429
  if ( empty($filepart) )
430
  return false;
431
-
432
  // required until PHP 5.2.0
433
- if ( empty($filepart['filename']) )
434
  $filepart['filename'] = substr($filepart['basename'],0 ,strlen($filepart['basename']) - (strlen($filepart['extension']) + 1) );
435
-
436
  $filepart['filename'] = sanitize_title_with_dashes( $filepart['filename'] );
437
-
438
  //extension jpeg will not be recognized by the slideshow, so we rename it
439
  $filepart['extension'] = ($filepart['extension'] == 'jpeg') ? 'jpg' : $filepart['extension'];
440
-
441
  //combine the new file name
442
  $filepart['basename'] = $filepart['filename'] . '.' . $filepart['extension'];
443
-
444
  return $filepart;
445
  }
446
-
447
  /**
448
  * Check for extended capabilites. Must previously registers with add_ngg_capabilites()
449
- *
450
  * @since 1.5.0
451
  * @param string $capability
452
  * @return bool $result of capability check
453
  */
454
- function current_user_can( $capability ) {
455
-
456
  global $_ngg_capabilites;
457
-
458
  if ( is_array($_ngg_capabilites) )
459
  if ( in_array($capability , $_ngg_capabilites) )
460
- return current_user_can( $capability );
461
-
462
  return true;
463
  }
464
 
465
  /**
466
  * Check for extended capabilites and echo disabled="disabled" for input form
467
- *
468
  * @since 1.5.0
469
  * @param string $capability
470
  * @return void
471
  */
472
- function current_user_can_form( $capability ) {
473
-
474
  if ( !nggGallery::current_user_can( $capability ))
475
  echo 'disabled="disabled"';
476
  }
477
 
478
  /**
479
  * Register more capabilities for custom use and add it to the administrator
480
- *
481
  * @since 1.5.0
482
  * @param string $capability
483
- * @param bool $register the new capability automatic to the admin role
484
  * @return void
485
  */
486
- function add_capabilites( $capability , $register = true ) {
487
  global $_ngg_capabilites;
488
-
489
  if ( !is_array($_ngg_capabilites) )
490
  $_ngg_capabilites = array();
491
-
492
  $_ngg_capabilites[] = $capability;
493
-
494
  if ( $register ) {
495
  $role = get_role('administrator');
496
  if ( !empty($role) )
497
  $role->add_cap( $capability );
498
  }
499
-
500
  }
501
-
502
  /**
503
  * Check for mobile user agent
504
- *
505
  * @since 1.6.0
506
  * @author Part taken from WPtouch plugin (http://www.bravenewcode.com)
507
  * @return bool $result of check
508
  */
509
- function detect_mobile_phone() {
510
-
511
  $useragents = array();
512
-
513
  // Check if WPtouch is running
514
  if ( function_exists('bnc_wptouch_get_user_agents') )
515
  $useragents = bnc_wptouch_get_user_agents();
516
- else {
517
- $useragents = array(
518
  "iPhone", // Apple iPhone
519
  "iPod", // Apple iPod touch
520
  "Android", // 1.5+ Android
@@ -529,14 +529,14 @@ class nggGallery {
529
  "incognito", // Other iPhone browser
530
  "webmate" // Other iPhone browser
531
  );
532
-
533
  asort( $useragents );
534
  }
535
-
536
  // Godfather Steve says no to flash
537
  if ( is_array($useragents) )
538
  $useragents[] = "iPad"; // Apple iPad;
539
-
540
  // WPtouch User Agent Filter
541
  $useragents = apply_filters( 'wptouch_user_agents', $useragents );
542
 
@@ -544,48 +544,48 @@ class nggGallery {
544
  if ( preg_match( "#$useragent#i", $_SERVER['HTTP_USER_AGENT'] ) )
545
  return true;
546
  }
547
-
548
- return false;
549
  }
550
-
551
  /**
552
  * get_memory_usage
553
- *
554
  * @access only for debug purpose
555
  * @since 1.8.3
556
  * @param string $text
557
  * @return void
558
  */
559
- function get_memory( $text = '' ) {
560
  global $memory;
561
 
562
  $memory_peak = memory_get_usage();
563
  $diff = 0;
564
-
565
  if ( isset($memory) )
566
  $diff = $memory_peak - $memory;
567
-
568
  $exp = ($diff < 0) ? '-' : '';
569
  $diff = ($exp == '-') ? 0 - $diff : $diff;
570
-
571
  $memory = $memory_peak;
572
-
573
  $unit = array('b','kb','mb','gb','tb','pb');
574
  $rounded = @round($diff/pow(1024,($i=floor(log($diff,1024)))),2).' '.$unit[$i];
575
-
576
- echo $text . ': ' . $exp . $rounded .'<br />';
577
-
578
  }
579
-
580
  /**
581
  * Show NextGEN Version in header
582
  * @since 1.9.0
583
- *
584
  * @return void
585
  */
586
- function nextgen_version() {
587
  global $ngg;
588
- echo apply_filters('show_nextgen_version', '<!-- <meta name="NextGEN" version="'. $ngg->version . '" /> -->' . "\n");
589
  }
590
  }
591
  ?>
1
  <?php
2
  /**
3
  * Main PHP class for the WordPress plugin NextGEN Gallery
4
+ *
5
  * @author Alex Rabe
6
+ *
7
+ *
8
  */
9
  class nggGallery {
10
+
11
  /**
12
  * Show a error messages
13
  */
14
+ static function show_error($message) {
15
  echo '<div class="wrap"><h2></h2><div class="error" id="error"><p>' . $message . '</p></div></div>' . "\n";
16
  }
17
+
18
  /**
19
  * Show a system messages
20
  */
21
+ static function show_message($message) {
22
  echo '<div class="wrap"><h2></h2><div class="updated fade" id="message"><p>' . $message . '</p></div></div>' . "\n";
23
  }
24
 
25
  /**
26
  * get the thumbnail url to the image
27
  */
28
+ static function get_thumbnail_url($imageID, $picturepath = '', $fileName = ''){
29
+
30
  // get the complete url to the thumbnail
31
  global $wpdb;
32
+
33
  // safety first
34
  $imageID = (int) $imageID;
35
+
36
  // get gallery values
37
  if ( empty($fileName) ) {
38
  list($fileName, $picturepath ) = $wpdb->get_row("SELECT p.filename, g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ", ARRAY_N);
39
  }
40
+
41
  if ( empty($picturepath) ) {
42
  $picturepath = $wpdb->get_var("SELECT g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ");
43
  }
44
+
45
  // set gallery url
46
  $folder_url = site_url() . '/' . $picturepath.nggGallery::get_thumbnail_folder($picturepath, FALSE);
47
  $thumbnailURL = $folder_url . 'thumbs_' . $fileName;
48
+
49
  return $thumbnailURL;
50
  }
51
+
52
  /**
53
  * get the complete url to the image
54
  */
55
+ static function get_image_url($imageID, $picturepath = '', $fileName = '') {
56
  global $wpdb;
57
 
58
  // safety first
59
  $imageID = (int) $imageID;
60
+
61
  // get gallery values
62
  if (empty($fileName)) {
63
  list($fileName, $picturepath ) = $wpdb->get_row("SELECT p.filename, g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ", ARRAY_N);
66
  if (empty($picturepath)) {
67
  $picturepath = $wpdb->get_var("SELECT g.path FROM $wpdb->nggpictures AS p INNER JOIN $wpdb->nggallery AS g ON (p.galleryid = g.gid) WHERE p.pid = '$imageID' ");
68
  }
69
+
70
  // set gallery url
71
  $imageURL = site_url() . '/' . $picturepath . '/' . $fileName;
72
+
73
+ return $imageURL;
74
  }
75
 
76
  /**
77
  * nggGallery::get_thumbnail_folder()
78
+ *
79
  * @param mixed $gallerypath
80
  * @param bool $include_Abspath
81
  * @return string $foldername
82
  */
83
+ static function create_thumbnail_folder($gallerypath, $include_Abspath = TRUE) {
84
  if (!$include_Abspath) {
85
  $gallerypath = WINABSPATH . $gallerypath;
86
  }
87
+
88
  if (!file_exists($gallerypath)) {
89
  return FALSE;
90
  }
91
+
92
  if (is_dir($gallerypath . '/thumbs/')) {
93
  return '/thumbs/';
94
  }
95
+
96
  if (is_admin()) {
97
  if (!is_dir($gallerypath . '/thumbs/')) {
98
  if ( !wp_mkdir_p($gallerypath . '/thumbs/') ) {
99
  if (SAFE_MODE) {
100
+ nggAdmin::check_safemode($gallerypath . '/thumbs/');
101
  } else {
102
  nggGallery::show_error(__('Unable to create directory ', 'nggallery') . $gallerypath . '/thumbs !');
103
  }
106
  return '/thumbs/';
107
  }
108
  }
109
+
110
  return FALSE;
111
+
112
  }
113
 
114
  /**
115
  * nggGallery::get_thumbnail_folder()
116
+ *
117
  * @param mixed $gallerypath
118
  * @param bool $include_Abspath
119
  * @deprecated use create_thumbnail_folder() if needed;
120
  * @return string $foldername
121
  */
122
+ static function get_thumbnail_folder($gallerypath, $include_Abspath = TRUE) {
123
  return nggGallery::create_thumbnail_folder($gallerypath, $include_Abspath);
124
  }
125
+
126
  /**
127
  * nggGallery::get_thumbnail_prefix() - obsolete
128
+ *
129
  * @param string $gallerypath
130
  * @param bool $include_Abspath
131
  * @deprecated prefix is now fixed to "thumbs_";
132
  * @return string "thumbs_";
133
  */
134
+ static function get_thumbnail_prefix($gallerypath, $include_Abspath = TRUE) {
135
+ return 'thumbs_';
136
  }
137
+
138
  /**
139
  * nggGallery::get_option() - get the options and overwrite them with custom meta settings
140
  *
141
  * @param string $key
142
  * @return array $options
143
  */
144
+ static function get_option($key) {
145
  global $post;
146
+
147
+ // get first the options from the database
148
  $options = get_option($key);
149
 
150
  if ( $post == null )
151
  return $options;
152
+
153
+ // Get all key/value data for the current post.
154
  $meta_array = get_post_custom();
155
+
156
  // Ensure that this is a array
157
  if ( !is_array($meta_array) )
158
  $meta_array = array($meta_array);
159
+
160
  // assign meta key to db setting key
161
  $meta_tags = array(
162
  'string' => array(
194
  'ngg_ir_Kenburns' => 'irKenburns'
195
  )
196
  );
197
+
198
  foreach ($meta_tags as $typ => $meta_keys){
199
  foreach ($meta_keys as $key => $db_value){
200
  // if the kex exist overwrite it with the custom field
208
  break;
209
  case 'bool':
210
  $options[$db_value] = (bool) $meta_array[$key][0];
211
+ break;
212
  }
213
  }
214
  }
215
  }
216
+
217
  return $options;
218
  }
219
+
220
  /**
221
  * nggGallery::scale_image() - Scale down a image
222
+ *
223
  * @param mixed $location (filename)
224
  * @param int $maxw - max width
225
  * @param int $maxh - max height
226
+ * @return array (width, heigth)
227
  */
228
+ static function scale_image($location, $maxw = 0, $maxh = 0){
229
  $img = @getimagesize($location);
230
  if ($img){
231
  $w = $img[0];
232
  $h = $img[1];
233
+
234
  $dim = array('w','h');
235
  foreach($dim AS $val) {
236
  $max = "max{$val}";
241
  ${$alt} = ${$val} * $ratio;
242
  }
243
  }
244
+
245
  return array( $w, $h );
246
  }
247
  return false;
248
+ }
249
+
250
  /**
251
  * Renders a section of user display code. The code is first checked for in the current theme display directory
252
  * before defaulting to the plugin
258
  * @param bool $callback In case we check we didn't find template we tested it one time more (optional)
259
  * @return void
260
  **/
261
+ static function render($template_name, $vars = array (), $callback = false) {
262
  foreach ($vars AS $key => $val) {
263
  $$key = $val;
264
  }
265
+
266
  // hook into the render feature to allow other plugins to include templates
267
  $custom_template = apply_filters( 'ngg_render_template', false, $template_name );
268
+
269
  if ( ( $custom_template != false ) && file_exists ($custom_template) ) {
270
  include ( $custom_template );
271
  } else if (file_exists (STYLESHEETPATH . "/nggallery/$template_name.php")) {
273
  } else if (file_exists (NGGALLERY_ABSPATH . "/view/$template_name.php")) {
274
  include (NGGALLERY_ABSPATH . "/view/$template_name.php");
275
  } else if ( $callback === true ) {
276
+ echo "<p>Rendering of template $template_name.php failed</p>";
277
  } else {
278
  //test without the "-template" name one time more
279
  $template_name = array_shift( explode('-', $template_name , 2) );
280
  nggGallery::render ($template_name, $vars , true);
281
  }
282
  }
283
+
284
  /**
285
  * Captures an section of user display code.
286
  *
289
  * @param string $vars Array of variable name=>value that is available to the display code (optional)
290
  * @return void
291
  **/
292
+ static function capture ($template_name, $vars = array ()) {
293
  ob_start ();
294
  nggGallery::render ($template_name, $vars);
295
  $output = ob_get_contents ();
296
  ob_end_clean ();
297
+
298
  return $output;
299
  }
300
+
301
  /**
302
  * nggGallery::graphic_library() - switch between GD and ImageMagick
303
+ *
304
  * @return path to the selected library
305
  */
306
+ static function graphic_library() {
307
+
308
  $ngg_options = get_option('ngg_options');
309
+
310
  if ( $ngg_options['graphicLibrary'] == 'im')
311
  return NGGALLERY_ABSPATH . '/lib/imagemagick.inc.php';
312
  else
313
  return NGGALLERY_ABSPATH . '/lib/gd.thumbnail.inc.php';
314
+
315
  }
316
+
317
  /**
318
  * Look for the stylesheet in the theme folder
319
+ *
320
  * @return string path to stylesheet
321
  */
322
+ static function get_theme_css_file() {
323
+
324
  // allow other plugins to include a custom stylesheet
325
  $stylesheet = apply_filters( 'ngg_load_stylesheet', false );
326
+
327
  if ( $stylesheet !== false )
328
  return ( $stylesheet );
329
  elseif ( file_exists (STYLESHEETPATH . '/nggallery.css') )
330
  return get_stylesheet_directory_uri() . '/nggallery.css';
331
  else
332
+ return false;
333
  }
334
 
335
  /**
336
  * Support for i18n with wpml, polyglot or qtrans
337
+ *
338
  * @param string $in
339
  * @param string $name (optional) required for wpml to determine the type of translation
340
  * @return string $in localized
341
  */
342
+ static function i18n($in, $name = null) {
343
+
344
  if ( function_exists( 'langswitch_filter_langs_with_message' ) )
345
  $in = langswitch_filter_langs_with_message($in);
346
+
347
  if ( function_exists( 'polyglot_filter' ))
348
  $in = polyglot_filter($in);
349
+
350
  if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ))
351
  $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in);
352
 
353
  if (is_string($name) && !empty($name) && function_exists('icl_translate'))
354
  $in = icl_translate('plugin_ngg', $name, $in, true);
355
+
356
  $in = apply_filters('localization', $in);
357
+
358
  return $in;
359
  }
360
 
361
  /**
362
  * This function register strings for the use with WPML plugin (see http://wpml.org/ )
363
+ *
364
  * @param object $image
365
  * @return void
366
  */
367
+ static function RegisterString($image) {
368
  if (function_exists('icl_register_string')) {
369
  global $wpdb;
370
  icl_register_string('plugin_ngg', 'pic_' . $image->pid . '_description', $image->description, TRUE);
371
  icl_register_string('plugin_ngg', 'pic_' . $image->pid . '_alttext', $image->alttext, TRUE);
372
  }
373
  }
374
+
375
  /**
376
  * Check the memory_limit and calculate a recommended memory size
377
+ *
378
  * @since V1.2.0
379
  * @return string message about recommended image size
380
  */
381
+ static function check_memory_limit() {
382
 
383
  if ( (function_exists('memory_get_usage')) && (ini_get('memory_limit')) ) {
384
+
385
  // get memory limit
386
  $memory_limit = ini_get('memory_limit');
387
  if ($memory_limit != '')
388
  $memory_limit = substr($memory_limit, 0, -1) * 1024 * 1024;
389
+
390
+ // calculate the free memory
391
  $freeMemory = $memory_limit - memory_get_usage();
392
+
393
  // build the test sizes
394
  $sizes = array();
395
  $sizes[] = array ( 'width' => 800, 'height' => 600);
396
  $sizes[] = array ( 'width' => 1024, 'height' => 768);
397
+ $sizes[] = array ( 'width' => 1280, 'height' => 960); // 1MP
398
  $sizes[] = array ( 'width' => 1600, 'height' => 1200); // 2MP
399
  $sizes[] = array ( 'width' => 2016, 'height' => 1512); // 3MP
400
  $sizes[] = array ( 'width' => 2272, 'height' => 1704); // 4MP
401
  $sizes[] = array ( 'width' => 2560, 'height' => 1920); // 5MP
402
+
403
  // test the classic sizes
404
  foreach ($sizes as $size){
405
  // very, very rough estimation
406
  if ($freeMemory < round( $size['width'] * $size['height'] * 5.09 )) {
407
+ $result = sprintf( __( 'Note : Based on your server memory limit you should not upload larger images then <strong>%d x %d</strong> pixel', 'nggallery' ), $size['width'], $size['height']);
408
  return $result;
409
  }
410
  }
411
  }
412
  return;
413
  }
414
+
415
  /**
416
  * Slightly modfifed version of pathinfo(), clean up filename & rename jpeg to jpg
417
+ *
418
+ * @param string $name The name being checked.
419
  * @return array containing information about file
420
  */
421
+ static function fileinfo( $name ) {
422
+
423
  //Sanitizes a filename replacing whitespace with dashes
424
  $name = sanitize_file_name($name);
425
+
426
  //get the parts of the name
427
  $filepart = pathinfo ( strtolower($name) );
428
+
429
  if ( empty($filepart) )
430
  return false;
431
+
432
  // required until PHP 5.2.0
433
+ if ( empty($filepart['filename']) )
434
  $filepart['filename'] = substr($filepart['basename'],0 ,strlen($filepart['basename']) - (strlen($filepart['extension']) + 1) );
435
+
436
  $filepart['filename'] = sanitize_title_with_dashes( $filepart['filename'] );
437
+
438
  //extension jpeg will not be recognized by the slideshow, so we rename it
439
  $filepart['extension'] = ($filepart['extension'] == 'jpeg') ? 'jpg' : $filepart['extension'];
440
+
441
  //combine the new file name
442
  $filepart['basename'] = $filepart['filename'] . '.' . $filepart['extension'];
443
+
444
  return $filepart;
445
  }
446
+
447
  /**
448
  * Check for extended capabilites. Must previously registers with add_ngg_capabilites()
449
+ *
450
  * @since 1.5.0
451
  * @param string $capability
452
  * @return bool $result of capability check
453
  */
454
+ static function current_user_can( $capability ) {
455
+
456
  global $_ngg_capabilites;
457
+
458
  if ( is_array($_ngg_capabilites) )
459
  if ( in_array($capability , $_ngg_capabilites) )
460
+ return current_user_can( $capability );
461
+
462
  return true;
463
  }
464
 
465
  /**
466
  * Check for extended capabilites and echo disabled="disabled" for input form
467
+ *
468
  * @since 1.5.0
469
  * @param string $capability
470
  * @return void
471
  */
472
+ static function current_user_can_form( $capability ) {
473
+
474
  if ( !nggGallery::current_user_can( $capability ))
475
  echo 'disabled="disabled"';
476
  }
477
 
478
  /**
479
  * Register more capabilities for custom use and add it to the administrator
480
+ *
481
  * @since 1.5.0
482
  * @param string $capability
483
+ * @param bool $register the new capability automatic to the admin role
484
  * @return void
485
  */
486
+ static function add_capabilites( $capability , $register = true ) {
487
  global $_ngg_capabilites;
488
+
489
  if ( !is_array($_ngg_capabilites) )
490
  $_ngg_capabilites = array();
491
+
492
  $_ngg_capabilites[] = $capability;
493
+
494
  if ( $register ) {
495
  $role = get_role('administrator');
496
  if ( !empty($role) )
497
  $role->add_cap( $capability );
498
  }
499
+
500
  }
501
+
502
  /**
503
  * Check for mobile user agent
504
+ *
505
  * @since 1.6.0
506
  * @author Part taken from WPtouch plugin (http://www.bravenewcode.com)
507
  * @return bool $result of check
508
  */
509
+ static function detect_mobile_phone() {
510
+
511
  $useragents = array();
512
+
513
  // Check if WPtouch is running
514
  if ( function_exists('bnc_wptouch_get_user_agents') )
515
  $useragents = bnc_wptouch_get_user_agents();
516
+ else {
517
+ $useragents = array(
518
  "iPhone", // Apple iPhone
519
  "iPod", // Apple iPod touch
520
  "Android", // 1.5+ Android
529
  "incognito", // Other iPhone browser
530
  "webmate" // Other iPhone browser
531
  );
532
+
533
  asort( $useragents );
534
  }
535
+
536
  // Godfather Steve says no to flash
537
  if ( is_array($useragents) )
538
  $useragents[] = "iPad"; // Apple iPad;
539
+
540
  // WPtouch User Agent Filter
541
  $useragents = apply_filters( 'wptouch_user_agents', $useragents );
542
 
544
  if ( preg_match( "#$useragent#i", $_SERVER['HTTP_USER_AGENT'] ) )
545
  return true;
546
  }
547
+
548
+ return false;
549
  }
550
+
551
  /**
552
  * get_memory_usage
553
+ *
554
  * @access only for debug purpose
555
  * @since 1.8.3
556
  * @param string $text
557
  * @return void
558
  */
559
+ static function get_memory( $text = '' ) {
560
  global $memory;
561
 
562
  $memory_peak = memory_get_usage();
563
  $diff = 0;
564
+
565
  if ( isset($memory) )
566
  $diff = $memory_peak - $memory;
567
+
568
  $exp = ($diff < 0) ? '-' : '';
569
  $diff = ($exp == '-') ? 0 - $diff : $diff;
570
+
571
  $memory = $memory_peak;
572
+
573
  $unit = array('b','kb','mb','gb','tb','pb');
574
  $rounded = @round($diff/pow(1024,($i=floor(log($diff,1024)))),2).' '.$unit[$i];
575
+
576
+ echo $text . ': ' . $exp . $rounded .'<br />';
577
+
578
  }
579
+
580
  /**
581
  * Show NextGEN Version in header
582
  * @since 1.9.0
583
+ *
584
  * @return void
585
  */
586
+ static function nextgen_version() {
587
  global $ngg;
588
+ echo apply_filters('show_nextgen_version', '<!-- <meta name="NextGEN" version="'. $ngg->version . '" /> -->' . "\n");
589
  }
590
  }
591
  ?>
lib/meta.php CHANGED
@@ -3,12 +3,12 @@
3
  /**
4
  * Image METADATA PHP class for the WordPress plugin NextGEN Gallery
5
  * nggmeta.lib.php
6
- *
7
  * @author Alex Rabe
8
- *
9
- *
10
  */
11
-
12
  class nggMeta{
13
 
14
  /**** Image Data ****/
@@ -21,23 +21,23 @@ class nggMeta{
21
  var $exif_array = false; // EXIF data array
22
  var $iptc_array = false; // IPTC data array
23
  var $xmp_array = false; // XMP data array
24
-
25
  var $sanitize = false; // sanitize meta data on request
26
 
27
  /**
28
  * nggMeta::nggMeta()
29
- *
30
  * @param int $image path to a image
31
  * @param bool $onlyEXIF parse only exif if needed
32
  * @return
33
  */
34
  function nggMeta($pic_id, $onlyEXIF = false) {
35
-
36
  //get the path and other data about the image
37
  $this->image = nggdb::find_image( $pic_id );
38
-
39
- $this->image = apply_filters( 'ngg_find_image_meta', $this->image );
40
-
41
  if ( !file_exists( $this->image->imagePath ) )
42
  return false;
43
 
@@ -48,7 +48,7 @@ class nggMeta{
48
  // get exif - data
49
  if ( is_callable('exif_read_data'))
50
  $this->exif_data = @exif_read_data($this->image->imagePath , 0, true );
51
-
52
  // stop here if we didn't need other meta data
53
  if ($onlyEXIF)
54
  return true;
@@ -60,48 +60,48 @@ class nggMeta{
60
  // get the xmp data in a XML format
61
  if ( is_callable('xml_parser_create'))
62
  $this->xmp_data = $this->extract_XMP($this->image->imagePath );
63
-
64
  return true;
65
  }
66
-
67
  return false;
68
  }
69
-
70
  /**
71
  * return the saved meta data from the database
72
- *
73
  * @since 1.4.0
74
  * @param string $object (optional)
75
  * @return array|mixed return either the complete array or the single object
76
  */
77
  function get_saved_meta($object = false) {
78
-
79
  $meta = $this->image->meta_data;
80
-
81
  //check if we already import the meta data to the database
82
  if (!is_array($meta) || ($meta['saved'] != true))
83
  return false;
84
-
85
- // return one element if requested
86
  if ($object)
87
  return $meta[$object];
88
-
89
  //removed saved parameter we don't need that to show
90
  unset($meta['saved']);
91
-
92
  // and remove empty tags
93
  foreach ($meta as $key => $value) {
94
  if ( empty($value) )
95
- unset($meta[$key]);
96
  }
97
 
98
  // on request sanitize the output
99
- if ( $this->sanitize == true )
100
- array_walk( $meta , create_function('&$value', '$value = esc_html($value);'));
101
-
102
  return $meta;
103
  }
104
-
105
  /**
106
  * nggMeta::get_EXIF()
107
  * See also http://trac.wordpress.org/changeset/6313
@@ -109,17 +109,17 @@ class nggMeta{
109
  * @return structured EXIF data
110
  */
111
  function get_EXIF($object = false) {
112
-
113
  if ( !$this->exif_data )
114
  return false;
115
-
116
  if (!is_array($this->exif_array)){
117
-
118
  $meta= array();
119
-
120
- if ( isset($this->exif_data['EXIF']) ) {
121
  $exif = $this->exif_data['EXIF'];
122
-
123
  if (!empty($exif['FNumber']))
124
  $meta['aperture'] = 'F ' . round( $this->exif_frac2dec( $exif['FNumber'] ), 2 );
125
  if (!empty($exif['Model']))
@@ -134,18 +134,18 @@ class nggMeta{
134
  $meta['iso'] = $exif['ISOSpeedRatings'];
135
  if (!empty($exif['ExposureTime'])) {
136
  $meta['shutter_speed'] = $this->exif_frac2dec ($exif['ExposureTime']);
137
- $meta['shutter_speed'] =($meta['shutter_speed'] > 0.0 and $meta['shutter_speed'] < 1.0) ? ( '1/' . round( 1 / $meta['shutter_speed'], -1) ) : ($meta['shutter_speed']);
138
  $meta['shutter_speed'] .= __(' sec','nggallery');
139
  }
140
  //Bit 0 indicates the flash firing status
141
  if (!empty($exif['Flash']))
142
  $meta['flash'] = ( $exif['Flash'] & 1 ) ? __('Fired', 'nggallery') : __('Not fired',' nggallery');
143
  }
144
-
145
  // additional information
146
- if ( isset($this->exif_data['IFD0']) ) {
147
  $exif = $this->exif_data['IFD0'];
148
-
149
  if (!empty($exif['Model']))
150
  $meta['camera'] = $exif['Model'];
151
  if (!empty($exif['Make']))
@@ -155,7 +155,7 @@ class nggMeta{
155
  if (!empty($exif['Orientation']))
156
  $meta['Orientation'] = $exif['Orientation'];
157
  }
158
-
159
  // this is done by Windows
160
  if ( isset($this->exif_data['WINXP']) ) {
161
  $exif = $this->exif_data['WINXP'];
@@ -171,24 +171,24 @@ class nggMeta{
171
  if (!empty($exif['Comments']))
172
  $meta['caption'] = utf8_encode($exif['Comments']);
173
  }
174
-
175
  $this->exif_array = $meta;
176
  }
177
-
178
- // return one element if requested
179
  if ( $object == true ) {
180
  $value = isset($this->exif_array[$object]) ? $this->exif_array[$object] : false;
181
  return $value;
182
  }
183
-
184
  // on request sanitize the output
185
- if ( $this->sanitize == true )
186
- array_walk( $this->exif_array , create_function('&$value', '$value = esc_html($value);'));
187
-
188
  return $this->exif_array;
189
-
190
  }
191
-
192
  // convert a fraction string to a decimal
193
  function exif_frac2dec($str) {
194
  @list( $n, $d ) = explode( '/', $str );
@@ -196,16 +196,16 @@ class nggMeta{
196
  return $n / $d;
197
  return $str;
198
  }
199
-
200
  // convert the exif date format to a unix timestamp
201
  function exif_date2ts($str) {
202
  // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'?
203
  @list( $date, $time ) = explode( ' ', trim($str) );
204
  @list( $y, $m, $d ) = explode( ':', $date );
205
-
206
  return strtotime( "{$y}-{$m}-{$d} {$time}" );
207
  }
208
-
209
  /**
210
  * nggMeta::readIPTC() - IPTC Data Information for EXIF Display
211
  *
@@ -213,12 +213,12 @@ class nggMeta{
213
  * @return IPTC-tags
214
  */
215
  function get_IPTC($object = false) {
216
-
217
  if (!$this->iptc_data)
218
  return false;
219
 
220
  if (!is_array($this->iptc_array)){
221
-
222
  // --------- Set up Array Functions --------- //
223
  $iptcTags = array (
224
  "2#005" => 'title',
@@ -242,32 +242,32 @@ class nggMeta{
242
  "2#118" => 'contact',
243
  "2#120" => 'caption'
244
  );
245
-
246
  // var_dump($this->iptc_data);
247
  $meta = array();
248
  foreach ($iptcTags as $key => $value) {
249
  if (isset ( $this->iptc_data[$key] ) )
250
  $meta[$value] = trim(utf8_encode(implode(", ", $this->iptc_data[$key])));
251
-
252
  }
253
  $this->iptc_array = $meta;
254
  }
255
-
256
- // return one element if requested
257
  if ($object)
258
  return (isset($this->iptc_array[$object])) ? $this->iptc_array[$object] : NULL;
259
 
260
  // on request sanitize the output
261
- if ( $this->sanitize == true )
262
- array_walk( $this->iptc_array , create_function('&$value', '$value = esc_html($value);'));
263
-
264
  return $this->iptc_array;
265
  }
266
 
267
  /**
268
  * nggMeta::extract_XMP()
269
- * get XMP DATA
270
- * code by Pekka Saarinen http://photography-on-the.net
271
  *
272
  * @param mixed $filename
273
  * @return XML data
@@ -287,8 +287,8 @@ class nggMeta{
287
  $xmp_data = substr($source, $start, $lenght+12 );
288
  unset($source);
289
  return $xmp_data;
290
- }
291
-
292
  unset($source);
293
  return false;
294
  }
@@ -302,29 +302,29 @@ class nggMeta{
302
  *
303
  */
304
  function get_XMP($object = false) {
305
-
306
  if(!$this->xmp_data)
307
  return false;
308
-
309
- if (!is_array($this->xmp_array)){
310
-
311
  $parser = xml_parser_create();
312
  xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); // Dont mess with my cAsE sEtTings
313
  xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); // Dont bother with empty info
314
  xml_parse_into_struct($parser, $this->xmp_data, $values);
315
  xml_parser_free($parser);
316
-
317
  $xmlarray = array(); // The XML array
318
  $this->xmp_array = array(); // The returned array
319
  $stack = array(); // tmp array used for stacking
320
  $list_array = array(); // tmp array for list elements
321
  $list_element = false; // rdf:li indicator
322
-
323
  foreach($values as $val) {
324
-
325
  if($val['type'] == "open") {
326
  array_push($stack, $val['tag']);
327
-
328
  } elseif($val['type'] == "close") {
329
  // reset the compared stack
330
  if ($list_element == false)
@@ -332,7 +332,7 @@ class nggMeta{
332
  // reset the rdf:li indicator & array
333
  $list_element = false;
334
  $list_array = array();
335
-
336
  } elseif($val['type'] == "complete") {
337
  if ($val['tag'] == "rdf:li") {
338
  // first go one element back
@@ -340,9 +340,9 @@ class nggMeta{
340
  array_pop($stack);
341
  $list_element = true;
342
  // do not parse empty tags
343
- if ( empty($val['value']) ) continue;
344
  // save it in our temp array
345
- $list_array[] = $val['value'];
346
  // in the case it's a list element we seralize it
347
  $value = implode(",", $list_array);
348
  $this->setArrayValue($xmlarray, $stack, $value);
@@ -354,16 +354,16 @@ class nggMeta{
354
  array_pop($stack);
355
  }
356
  }
357
-
358
  } // foreach
359
-
360
  // don't parse a empty array
361
  if( empty($xmlarray) || empty($xmlarray['x:xmpmeta']) )
362
  return false;
363
-
364
  // cut off the useless tags
365
  $xmlarray = $xmlarray['x:xmpmeta']['rdf:RDF']['rdf:Description'];
366
-
367
  // --------- Some values from the XMP format--------- //
368
  $xmpTags = array (
369
  'xap:CreateDate' => 'created_timestamp',
@@ -386,26 +386,26 @@ class nggMeta{
386
  case 'xap:CreateDate':
387
  case 'xap:ModifyDate':
388
  $this->xmp_array[$value] = date_i18n(get_option('date_format').' '.get_option('time_format'), strtotime($xmlarray[$key]));
389
- break;
390
  default :
391
  $this->xmp_array[$value] = $xmlarray[$key];
392
  }
393
  }
394
  }
395
-
396
  }
397
-
398
- // return one element if requested
399
  if ($object != false )
400
- return isset($this->xmp_array[$object]) ? $this->xmp_array[$object] : false;
401
-
402
  // on request sanitize the output
403
- if ( $this->sanitize == true )
404
- array_walk( $this->xmp_array , create_function('&$value', '$value = esc_html($value);'));
405
-
406
  return $this->xmp_array;
407
  }
408
-
409
  function setArrayValue(&$array, $stack, $value) {
410
  if ($stack) {
411
  $key = array_shift($stack);
@@ -415,15 +415,15 @@ class nggMeta{
415
  $array = $value;
416
  }
417
  }
418
-
419
  /**
420
- * nggMeta::get_META() - return a meta value form the available list
421
  *
422
  * @param string $object
423
  * @return mixed $value
424
  */
425
  function get_META($object = false) {
426
-
427
  // defined order first look into database, then XMP, IPTC and EXIF.
428
  if ($value = $this->get_saved_meta($object))
429
  return $value;
@@ -433,11 +433,11 @@ class nggMeta{
433
  return $value;
434
  if ($value = $this->get_EXIF($object))
435
  return $value;
436
-
437
  // nothing found ?
438
  return false;
439
  }
440
-
441
  /**
442
  * nggMeta::i8n_name() - localize the tag name
443
  *
@@ -445,7 +445,7 @@ class nggMeta{
445
  * @return translated $key
446
  */
447
  function i8n_name($key) {
448
-
449
  $tagnames = array(
450
  'aperture' => __('Aperture','nggallery'),
451
  'credit' => __('Credit','nggallery'),
@@ -485,58 +485,55 @@ class nggMeta{
485
  'flash' => __('Flash','nggallery')
486
  );
487
 
488
- if ( isset($tagnames[$key]) )
489
  $key = $tagnames[$key];
490
-
491
  return($key);
492
 
493
- }
494
 
495
  /**
496
  * Return the Timestamp from the image , if possible it's read from exif data
497
- *
498
  * @return
499
  */
500
  function get_date_time() {
501
-
502
  $date_time = false;
503
-
504
  // get exif - data
505
  if ( isset( $this->exif_data['EXIF']) ) {
506
-
507
  // try to read the date / time from the exif
508
- if ( empty($this->exif_data['EXIF']['DateTimeDigitized']) )
509
- $date_time = $this->exif_data['EXIF']['DateTimeOriginal'];
510
- else
511
- $date_time = $this->exif_data['EXIF']['DateTimeDigitized'];
512
-
513
- // if we didn't get the correct exif value we take filetime
514
- if ($date_time == null)
515
- $date_time = $this->exif_data['FILE']['FileDateTime'];
516
- else
517
- $date_time = $this->exif_date2ts($date_time);
518
-
519
  } else {
520
  // if no other date available, get the filetime
521
- $date_time = @filectime($this->image->imagePath );
522
  }
523
-
524
- // Return the MySQL format
525
  $date_time = date( 'Y-m-d H:i:s', $date_time );
526
 
527
  return $date_time;
528
  }
529
-
530
  /**
531
  * This function return the most common metadata, via a filter we can add more
532
  * Reason : GD manipulation removes that options
533
- *
534
  * @since V1.4.0
535
  * @return void
536
  */
537
  function get_common_meta() {
538
  global $wpdb;
539
-
540
  $meta = array(
541
  'aperture' => 0,
542
  'credit' => '',
@@ -551,27 +548,27 @@ class nggMeta{
551
  'title' => '',
552
  'keywords' => ''
553
  );
554
-
555
  $meta = apply_filters( 'ngg_read_image_metadata', $meta );
556
-
557
  // meta should be still an array
558
  if ( !is_array($meta) )
559
  return false;
560
-
561
  foreach ($meta as $key => $value) {
562
- $meta[$key] = $this->get_META($key);
563
  }
564
-
565
- //let's add now the size of the image
566
  $meta['width'] = $this->size[0];
567
  $meta['height'] = $this->size[1];
568
-
569
- return $meta;
570
  }
571
-
572
  /**
573
- * If needed sanitize each value before output
574
- *
575
  * @return void
576
  */
577
  function sanitize () {
3
  /**
4
  * Image METADATA PHP class for the WordPress plugin NextGEN Gallery
5
  * nggmeta.lib.php
6
+ *
7
  * @author Alex Rabe
8
+ *
9
+ *
10
  */
11
+
12
  class nggMeta{
13
 
14
  /**** Image Data ****/
21
  var $exif_array = false; // EXIF data array
22
  var $iptc_array = false; // IPTC data array
23
  var $xmp_array = false; // XMP data array
24
+
25
  var $sanitize = false; // sanitize meta data on request
26
 
27
  /**
28
  * nggMeta::nggMeta()
29
+ *
30
  * @param int $image path to a image
31
  * @param bool $onlyEXIF parse only exif if needed
32
  * @return
33
  */
34
  function nggMeta($pic_id, $onlyEXIF = false) {
35
+
36
  //get the path and other data about the image
37
  $this->image = nggdb::find_image( $pic_id );
38
+
39
+ $this->image = apply_filters( 'ngg_find_image_meta', $this->image );
40
+
41
  if ( !file_exists( $this->image->imagePath ) )
42
  return false;
43
 
48
  // get exif - data
49
  if ( is_callable('exif_read_data'))
50
  $this->exif_data = @exif_read_data($this->image->imagePath , 0, true );
51
+
52
  // stop here if we didn't need other meta data
53
  if ($onlyEXIF)
54
  return true;
60
  // get the xmp data in a XML format
61
  if ( is_callable('xml_parser_create'))
62
  $this->xmp_data = $this->extract_XMP($this->image->imagePath );
63
+
64
  return true;
65
  }
66
+
67
  return false;
68
  }
69
+
70
  /**
71
  * return the saved meta data from the database
72
+ *
73
  * @since 1.4.0
74
  * @param string $object (optional)
75
  * @return array|mixed return either the complete array or the single object
76
  */
77
  function get_saved_meta($object = false) {
78
+
79
  $meta = $this->image->meta_data;
80
+
81
  //check if we already import the meta data to the database
82
  if (!is_array($meta) || ($meta['saved'] != true))
83
  return false;
84
+
85
+ // return one element if requested
86
  if ($object)
87
  return $meta[$object];
88
+
89
  //removed saved parameter we don't need that to show
90
  unset($meta['saved']);
91
+
92
  // and remove empty tags
93
  foreach ($meta as $key => $value) {
94
  if ( empty($value) )
95
+ unset($meta[$key]);
96
  }
97
 
98
  // on request sanitize the output
99
+ if ( $this->sanitize == true )
100
+ array_walk( $meta , create_function('&$value', '$value = esc_html($value);'));
101
+
102
  return $meta;
103
  }
104
+
105
  /**
106
  * nggMeta::get_EXIF()
107
  * See also http://trac.wordpress.org/changeset/6313
109
  * @return structured EXIF data
110
  */
111
  function get_EXIF($object = false) {
112
+
113
  if ( !$this->exif_data )
114
  return false;
115
+
116
  if (!is_array($this->exif_array)){
117
+
118
  $meta= array();
119
+
120
+ if ( isset($this->exif_data['EXIF']) ) {
121
  $exif = $this->exif_data['EXIF'];
122
+
123
  if (!empty($exif['FNumber']))
124
  $meta['aperture'] = 'F ' . round( $this->exif_frac2dec( $exif['FNumber'] ), 2 );
125
  if (!empty($exif['Model']))
134
  $meta['iso'] = $exif['ISOSpeedRatings'];
135
  if (!empty($exif['ExposureTime'])) {
136
  $meta['shutter_speed'] = $this->exif_frac2dec ($exif['ExposureTime']);
137
+ $meta['shutter_speed'] =($meta['shutter_speed'] > 0.0 and $meta['shutter_speed'] < 1.0) ? ( '1/' . round( 1 / $meta['shutter_speed'], -1) ) : ($meta['shutter_speed']);
138
  $meta['shutter_speed'] .= __(' sec','nggallery');
139
  }
140
  //Bit 0 indicates the flash firing status
141
  if (!empty($exif['Flash']))
142
  $meta['flash'] = ( $exif['Flash'] & 1 ) ? __('Fired', 'nggallery') : __('Not fired',' nggallery');
143
  }
144
+
145
  // additional information
146
+ if ( isset($this->exif_data['IFD0']) ) {
147
  $exif = $this->exif_data['IFD0'];
148
+
149
  if (!empty($exif['Model']))
150
  $meta['camera'] = $exif['Model'];
151
  if (!empty($exif['Make']))
155
  if (!empty($exif['Orientation']))
156
  $meta['Orientation'] = $exif['Orientation'];
157
  }
158
+
159
  // this is done by Windows
160
  if ( isset($this->exif_data['WINXP']) ) {
161
  $exif = $this->exif_data['WINXP'];
171
  if (!empty($exif['Comments']))
172
  $meta['caption'] = utf8_encode($exif['Comments']);
173
  }
174
+
175
  $this->exif_array = $meta;
176
  }
177
+
178
+ // return one element if requested
179
  if ( $object == true ) {
180
  $value = isset($this->exif_array[$object]) ? $this->exif_array[$object] : false;
181
  return $value;
182
  }
183
+
184
  // on request sanitize the output
185
+ if ( $this->sanitize == true )
186
+ array_walk( $this->exif_array , create_function('&$value', '$value = esc_html($value);'));
187
+
188
  return $this->exif_array;
189
+
190
  }
191
+
192
  // convert a fraction string to a decimal
193
  function exif_frac2dec($str) {
194
  @list( $n, $d ) = explode( '/', $str );
196
  return $n / $d;
197
  return $str;
198
  }
199
+
200
  // convert the exif date format to a unix timestamp
201
  function exif_date2ts($str) {
202
  // seriously, who formats a date like 'YYYY:MM:DD hh:mm:ss'?
203
  @list( $date, $time ) = explode( ' ', trim($str) );
204
  @list( $y, $m, $d ) = explode( ':', $date );
205
+
206
  return strtotime( "{$y}-{$m}-{$d} {$time}" );
207
  }
208
+
209
  /**
210
  * nggMeta::readIPTC() - IPTC Data Information for EXIF Display
211
  *
213
  * @return IPTC-tags
214
  */
215
  function get_IPTC($object = false) {
216
+
217
  if (!$this->iptc_data)
218
  return false;
219
 
220
  if (!is_array($this->iptc_array)){
221
+
222
  // --------- Set up Array Functions --------- //
223
  $iptcTags = array (
224
  "2#005" => 'title',
242
  "2#118" => 'contact',
243
  "2#120" => 'caption'
244
  );
245
+
246
  // var_dump($this->iptc_data);
247
  $meta = array();
248
  foreach ($iptcTags as $key => $value) {
249
  if (isset ( $this->iptc_data[$key] ) )
250
  $meta[$value] = trim(utf8_encode(implode(", ", $this->iptc_data[$key])));
251
+
252
  }
253
  $this->iptc_array = $meta;
254
  }
255
+
256
+ // return one element if requested
257
  if ($object)
258
  return (isset($this->iptc_array[$object])) ? $this->iptc_array[$object] : NULL;
259
 
260
  // on request sanitize the output
261
+ if ( $this->sanitize == true )
262
+ array_walk( $this->iptc_array , create_function('&$value', '$value = esc_html($value);'));
263
+
264
  return $this->iptc_array;
265
  }
266
 
267
  /**
268
  * nggMeta::extract_XMP()
269
+ * get XMP DATA
270
+ * code by Pekka Saarinen http://photography-on-the.net
271
  *
272
  * @param mixed $filename
273
  * @return XML data
287
  $xmp_data = substr($source, $start, $lenght+12 );
288
  unset($source);
289
  return $xmp_data;
290
+ }
291
+
292
  unset($source);
293
  return false;
294
  }
302
  *
303
  */
304
  function get_XMP($object = false) {
305
+
306
  if(!$this->xmp_data)
307
  return false;
308
+
309
+ if (!is_array($this->xmp_array)){
310
+
311
  $parser = xml_parser_create();
312
  xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); // Dont mess with my cAsE sEtTings
313
  xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); // Dont bother with empty info
314
  xml_parse_into_struct($parser, $this->xmp_data, $values);
315
  xml_parser_free($parser);
316
+
317
  $xmlarray = array(); // The XML array
318
  $this->xmp_array = array(); // The returned array
319
  $stack = array(); // tmp array used for stacking
320
  $list_array = array(); // tmp array for list elements
321
  $list_element = false; // rdf:li indicator
322
+
323
  foreach($values as $val) {
324
+
325
  if($val['type'] == "open") {
326
  array_push($stack, $val['tag']);
327
+
328
  } elseif($val['type'] == "close") {
329
  // reset the compared stack
330
  if ($list_element == false)
332
  // reset the rdf:li indicator & array
333
  $list_element = false;
334
  $list_array = array();
335
+
336
  } elseif($val['type'] == "complete") {
337
  if ($val['tag'] == "rdf:li") {
338
  // first go one element back
340
  array_pop($stack);
341
  $list_element = true;
342
  // do not parse empty tags
343
+ if ( empty($val['value']) ) continue;
344
  // save it in our temp array
345
+ $list_array[] = $val['value'];
346
  // in the case it's a list element we seralize it
347
  $value = implode(",", $list_array);
348
  $this->setArrayValue($xmlarray, $stack, $value);
354
  array_pop($stack);
355
  }
356
  }
357
+
358
  } // foreach
359
+
360
  // don't parse a empty array
361
  if( empty($xmlarray) || empty($xmlarray['x:xmpmeta']) )
362
  return false;
363
+
364
  // cut off the useless tags
365
  $xmlarray = $xmlarray['x:xmpmeta']['rdf:RDF']['rdf:Description'];
366
+
367
  // --------- Some values from the XMP format--------- //
368
  $xmpTags = array (
369
  'xap:CreateDate' => 'created_timestamp',
386
  case 'xap:CreateDate':
387
  case 'xap:ModifyDate':
388
  $this->xmp_array[$value] = date_i18n(get_option('date_format').' '.get_option('time_format'), strtotime($xmlarray[$key]));
389
+ break;
390
  default :
391
  $this->xmp_array[$value] = $xmlarray[$key];
392
  }
393
  }
394
  }
395
+
396
  }
397
+
398
+ // return one element if requested
399
  if ($object != false )
400
+ return isset($this->xmp_array[$object]) ? $this->xmp_array[$object] : false;
401
+
402
  // on request sanitize the output
403
+ if ( $this->sanitize == true )
404
+ array_walk( $this->xmp_array , create_function('&$value', '$value = esc_html($value);'));
405
+
406
  return $this->xmp_array;
407
  }
408
+
409
  function setArrayValue(&$array, $stack, $value) {
410
  if ($stack) {
411
  $key = array_shift($stack);
415
  $array = $value;
416
  }
417
  }
418
+
419
  /**
420
+ * nggMeta::get_META() - return a meta value form the available list
421
  *
422
  * @param string $object
423
  * @return mixed $value
424
  */
425
  function get_META($object = false) {
426
+
427
  // defined order first look into database, then XMP, IPTC and EXIF.
428
  if ($value = $this->get_saved_meta($object))
429
  return $value;
433
  return $value;
434
  if ($value = $this->get_EXIF($object))
435
  return $value;
436
+
437
  // nothing found ?
438
  return false;
439
  }
440
+
441
  /**
442
  * nggMeta::i8n_name() - localize the tag name
443
  *
445
  * @return translated $key
446
  */
447
  function i8n_name($key) {
448
+
449
  $tagnames = array(
450
  'aperture' => __('Aperture','nggallery'),
451
  'credit' => __('Credit','nggallery'),
485
  'flash' => __('Flash','nggallery')
486
  );
487
 
488
+ if ( isset($tagnames[$key]) )
489
  $key = $tagnames[$key];
490
+
491
  return($key);
492
 
493
+ }
494
 
495
  /**
496
  * Return the Timestamp from the image , if possible it's read from exif data
497
+ *
498
  * @return
499
  */
500
  function get_date_time() {
501
+
502
  $date_time = false;
503
+
504
  // get exif - data
505
  if ( isset( $this->exif_data['EXIF']) ) {
506
+
507
  // try to read the date / time from the exif
508
+ foreach (array('DateTimeDigitized', 'DateTimeOriginal', 'FileDateTime') as $key) {
509
+ if (isset($this->exif_data['EXIF'][$key])) {
510
+ $date_time = $this->exif_data['EXIF'][$key];
511
+ }
512
+ }
513
+
514
+ if (!$date_time) $date_time = $this->exif_date2ts($date_time);
515
+
 
 
 
516
  } else {
517
  // if no other date available, get the filetime
518
+ $date_time = @filectime($this->image->imagePath );
519
  }
520
+
521
+ // Return the MySQL format
522
  $date_time = date( 'Y-m-d H:i:s', $date_time );
523
 
524
  return $date_time;
525
  }
526
+
527
  /**
528
  * This function return the most common metadata, via a filter we can add more
529
  * Reason : GD manipulation removes that options
530
+ *
531
  * @since V1.4.0
532
  * @return void
533
  */
534
  function get_common_meta() {
535
  global $wpdb;
536
+
537
  $meta = array(
538
  'aperture' => 0,
539
  'credit' => '',
548
  'title' => '',
549
  'keywords' => ''
550
  );
551
+
552
  $meta = apply_filters( 'ngg_read_image_metadata', $meta );
553
+
554
  // meta should be still an array
555
  if ( !is_array($meta) )
556
  return false;
557
+
558
  foreach ($meta as $key => $value) {
559
+ $meta[$key] = $this->get_META($key);
560
  }
561
+
562
+ //let's add now the size of the image
563
  $meta['width'] = $this->size[0];
564
  $meta['height'] = $this->size[1];
565
+
566
+ return $meta;
567
  }
568
+
569
  /**
570
+ * If needed sanitize each value before output
571
+ *
572
  * @return void
573
  */
574
  function sanitize () {
lib/multisite.php CHANGED
@@ -1,57 +1,57 @@
1
- <?php
2
- /**
3
- * Main PHP Class for Multisite setup
4
- *
5
- * @author Alex Rabe
6
- *
7
- *
8
- */
9
- class nggWPMU{
10
-
11
- /**
12
- * Check the Quota under WPMU. Only needed for this case
13
- *
14
- * @class nggWPMU
15
- * @return bool $result
16
- */
17
- function check_quota() {
18
- if ( get_site_option( 'upload_space_check_disabled' ) )
19
- return false;
20
-
21
- if ( (is_multisite()) && nggWPMU::wpmu_enable_function('wpmuQuotaCheck'))
22
- if( $error = upload_is_user_over_quota( false ) ) {
23
- nggGallery::show_error( __( 'Sorry, you have used your space allocation. Please delete some files to upload more files.','nggallery' ) );
24
- return true;
25
- }
26
- return false;
27
- }
28
-
29
- /**
30
- * Check for site admin
31
- *
32
- * @return
33
- */
34
- function wpmu_site_admin() {
35
-
36
- if ( function_exists('is_super_admin') )
37
- if ( is_super_admin() )
38
- return true;
39
-
40
- return false;
41
- }
42
-
43
- /**
44
- * Check for site wide options
45
- *
46
- * @param string $value
47
- * @return value
48
- */
49
- function wpmu_enable_function($value) {
50
- if (is_multisite()) {
51
- $ngg_options = get_site_option('ngg_options');
52
- return $ngg_options[$value];
53
- }
54
- // if this is not WPMU, enable it !
55
- return true;
56
- }
57
- }
1
+ <?php
2
+ /**
3
+ * Main PHP Class for Multisite setup
4
+ *
5
+ * @author Alex Rabe
6
+ *
7
+ *
8
+ */
9
+ class nggWPMU{
10
+
11
+ /**
12
+ * Check the Quota under WPMU. Only needed for this case
13
+ *
14
+ * @class nggWPMU
15
+ * @return bool $result
16
+ */
17
+ function check_quota() {
18
+ if ( get_site_option( 'upload_space_check_disabled' ) )
19
+ return false;
20
+
21
+ if ( (is_multisite()) && nggWPMU::wpmu_enable_function('wpmuQuotaCheck'))
22
+ if( $error = upload_is_user_over_quota( false ) ) {
23
+ nggGallery::show_error( __( 'Sorry, you have used your space allocation. Please delete some files to upload more files.','nggallery' ) );
24
+ return true;
25
+ }
26
+ return false;
27
+ }
28
+
29
+ /**
30
+ * Check for site admin
31
+ *
32
+ * @return
33
+ */
34
+ function wpmu_site_admin() {
35
+
36
+ if ( function_exists('is_super_admin') )
37
+ if ( is_super_admin() )
38
+ return true;
39
+
40
+ return false;
41
+ }
42
+
43
+ /**
44
+ * Check for site wide options
45
+ *
46
+ * @param string $value
47
+ * @return value
48
+ */
49
+ function wpmu_enable_function($value) {
50
+ if (is_multisite()) {
51
+ $ngg_options = get_site_option('ngg_options');
52
+ return $ngg_options[$value];
53
+ }
54
+ // if this is not WPMU, enable it !
55
+ return true;
56
+ }
57
+ }
lib/ngg-db.php CHANGED
@@ -226,17 +226,19 @@ class nggdb {
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) {
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
+ $order_clause = "ABS(tt.{$order_by}) {$order_dir}, tt.{$order_by} {$order_dir}";
232
+ // $order_clause = "LENGTH(tt.{$order_by}) {$order_dir}, tt.{$order_by} {$order_dir}";
233
 
234
  // Should we limit this query ?
235
  $limit_by = ( $limit > 0 ) ? 'LIMIT ' . intval($start) . ',' . intval($limit) : '';
236
 
237
  // Query database
238
  if( is_numeric($id) )
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.gid = %d {$exclude_clause} ORDER BY {$order_clause} {$limit_by}", $id ), OBJECT_K );
240
  else
241
+ $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 {$order_clause} {$limit_by}", $id ), OBJECT_K );
242
 
243
  // Count the number of images and calculate the pagination
244
  if ($limit > 0) {
lib/shortcodes.php CHANGED
@@ -1,29 +1,30 @@
1
  <?php
2
  /**
3
- * @author Alex Rabe, Vincent Prat
4
- *
5
  * @since 1.0.0
6
  * @description Use WordPress Shortcode API for more features
7
  * @Docs http://codex.wordpress.org/Shortcode_API
8
  */
9
 
10
  class NextGEN_shortcodes {
11
-
12
- // register the new shortcodes
13
- function NextGEN_shortcodes() {
14
-
15
  //Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553
16
  @ini_set('pcre.backtrack_limit', 500000);
17
-
18
  // convert the old shortcode
19
  add_filter('the_content', array(&$this, 'convert_shortcode'));
20
-
 
21
  // do_shortcode on the_excerpt could causes several unwanted output. Uncomment it on your own risk
22
  // add_filter('the_excerpt', array(&$this, 'convert_shortcode'));
23
  // add_filter('the_excerpt', 'do_shortcode', 11);
24
-
25
  add_shortcode( 'singlepic', array(&$this, 'show_singlepic' ) );
26
  add_shortcode( 'album', array(&$this, 'show_album' ) );
 
27
  add_shortcode( 'nggallery', array(&$this, 'show_gallery') );
28
  add_shortcode( 'imagebrowser', array(&$this, 'show_imagebrowser' ) );
29
  add_shortcode( 'slideshow', array(&$this, 'show_slideshow' ) );
@@ -32,20 +33,26 @@ class NextGEN_shortcodes {
32
  add_shortcode( 'random', array(&$this, 'show_random' ) );
33
  add_shortcode( 'recent', array(&$this, 'show_recent' ) );
34
  add_shortcode( 'tagcloud', array(&$this, 'show_tagcloud' ) );
35
- }
 
 
 
 
 
 
36
 
37
  /**
38
  * NextGEN_shortcodes::convert_shortcode()
39
  * convert old shortcodes to the new WordPress core style
40
  * [gallery=1] ->> [nggallery id=1]
41
- *
42
  * @param string $content Content to search for shortcodes
43
  * @return string Content with new shortcodes.
44
  */
45
  function convert_shortcode($content) {
46
-
47
  $ngg_options = nggGallery::get_option('ngg_options');
48
-
49
  if ( stristr( $content, '[singlepic' )) {
50
  $search = "@\[singlepic=(\d+)(|,\d+|,)(|,\d+|,)(|,watermark|,web20|,)(|,right|,center|,left|,)\]@i";
51
  if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
@@ -53,9 +60,9 @@ class NextGEN_shortcodes {
53
  foreach ($matches as $match) {
54
  // remove the comma
55
  $match[2] = ltrim($match[2], ',');
56
- $match[3] = ltrim($match[3], ',');
57
- $match[4] = ltrim($match[4], ',');
58
- $match[5] = ltrim($match[5], ',');
59
  $replace = "[singlepic id=\"{$match[1]}\" w=\"{$match[2]}\" h=\"{$match[3]}\" mode=\"{$match[4]}\" float=\"{$match[5]}\" ]";
60
  $content = str_replace ($match[0], $replace, $content);
61
  }
@@ -63,7 +70,7 @@ class NextGEN_shortcodes {
63
  }
64
 
65
  if ( stristr( $content, '[album' )) {
66
- $search = "@(?:<p>)*\s*\[album\s*=\s*(\w+|^\+)(|,extend|,compact)\]\s*(?:</p>)*@i";
67
  if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
68
 
69
  foreach ($matches as $match) {
@@ -73,7 +80,7 @@ class NextGEN_shortcodes {
73
  $content = str_replace ($match[0], $replace, $content);
74
  }
75
  }
76
- }
77
 
78
  if ( stristr( $content, '[gallery' )) {
79
  $search = "@(?:<p>)*\s*\[gallery\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
@@ -84,7 +91,7 @@ class NextGEN_shortcodes {
84
  $content = str_replace ($match[0], $replace, $content);
85
  }
86
  }
87
- }
88
 
89
  if ( stristr( $content, '[imagebrowser' )) {
90
  $search = "@(?:<p>)*\s*\[imagebrowser\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
@@ -104,7 +111,7 @@ class NextGEN_shortcodes {
104
  foreach ($matches as $match) {
105
  // remove the comma
106
  $match[3] = ltrim($match[3],',');
107
- $match[5] = ltrim($match[5],',');
108
  $replace = "[slideshow id=\"{$match[1]}\" w=\"{$match[3]}\" h=\"{$match[5]}\"]";
109
  $content = str_replace ($match[0], $replace, $content);
110
  }
@@ -121,7 +128,7 @@ class NextGEN_shortcodes {
121
  }
122
  }
123
  }
124
-
125
  if ( stristr( $content, '[albumtags' )) {
126
  $search = "@(?:<p>)*\s*\[albumtags\s*=\s*(.*?)\s*\]\s*(?:</p>)*@i";
127
  if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
@@ -134,15 +141,15 @@ class NextGEN_shortcodes {
134
  }
135
 
136
  // attach related images based on category or tags
137
- if ($ngg_options['activateTags'])
138
  $content .= nggShowRelatedImages();
139
-
140
  return $content;
141
  }
142
-
143
  /**
144
  * Function to show a single picture:
145
- *
146
  * [singlepic id="10" float="none|left|right" width="" height="" mode="none|watermark|web20" link="url" "template="filename" /]
147
  *
148
  * where
@@ -153,18 +160,18 @@ class NextGEN_shortcodes {
153
  * - mode is one of none, watermark or web20 (transformation applied to the picture)
154
  * - link is optional and could link to a other url instead the full image
155
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
156
- *
157
  * If the tag contains some text, this will be inserted as an additional caption to the picture too. Example:
158
  * [singlepic id="10"]This is an additional caption[/singlepic]
159
- * This tag will show a picture with under it two HTML span elements containing respectively the alttext of the picture
160
- * and the additional caption specified in the tag.
161
- *
162
  * @param array $atts
163
  * @param string $caption text
164
  * @return the content
165
  */
166
  function show_singlepic( $atts, $content = '' ) {
167
-
168
  extract(shortcode_atts(array(
169
  'id' => 0,
170
  'w' => '',
@@ -174,215 +181,215 @@ class NextGEN_shortcodes {
174
  'link' => '',
175
  'template' => ''
176
  ), $atts ));
177
-
178
  $out = nggSinglePicture($id, $w, $h, $mode, $float, $template, $content, $link);
179
-
180
  return $out;
181
  }
182
 
183
  /**
184
  * Function to show a collection of galleries:
185
- *
186
  * [album id="1,2,4,5,..." template="filename" gallery="filename" /]
187
- * where
188
  * - id of a album
189
  * - template is a name for a album template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
190
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
191
- *
192
  * @param array $atts
193
  * @return the_content
194
  */
195
  function show_album( $atts ) {
196
-
197
  extract(shortcode_atts(array(
198
  'id' => 0,
199
  'template' => 'extend',
200
- 'gallery' => ''
201
  ), $atts ));
202
-
203
  $out = nggShowAlbum($id, $template, $gallery);
204
-
205
  return $out;
206
  }
207
  /**
208
  * Function to show a thumbnail or a set of thumbnails with shortcode of type:
209
- *
210
  * [gallery id="1,2,4,5,..." template="filename" images="number of images per page" /]
211
- * where
212
  * - id of a gallery
213
  * - images is the number of images per page (optional), 0 will show all images
214
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
215
- *
216
  * @param array $atts
217
  * @return the_content
218
  */
219
  function show_gallery( $atts ) {
220
-
221
  global $wpdb;
222
-
223
  extract(shortcode_atts(array(
224
  'id' => 0,
225
- 'template' => '',
226
  'images' => false
227
  ), $atts ));
228
-
229
  // backward compat for user which uses the name instead, still deprecated
230
  if( !is_numeric($id) )
231
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) );
232
-
233
  $out = nggShowGallery( $id, $template, $images );
234
-
235
  return $out;
236
  }
237
 
238
  function show_imagebrowser( $atts ) {
239
-
240
  global $wpdb;
241
-
242
  extract(shortcode_atts(array(
243
  'id' => 0,
244
- 'template' => ''
245
  ), $atts ));
246
 
247
  $out = nggShowImageBrowser($id, $template);
248
-
249
  return $out;
250
  }
251
-
252
  function show_slideshow( $atts ) {
253
-
254
  global $wpdb;
255
-
256
  extract(shortcode_atts(array(
257
  'id' => 0,
258
  'w' => '',
259
  'h' => ''
260
  ), $atts ));
261
-
262
  if( !is_numeric($id) )
263
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) );
264
 
265
  if( !empty( $id ) )
266
  $out = nggShowSlideshow($id, $w, $h);
267
- else
268
  $out = __('[Gallery not found]','nggallery');
269
-
270
  return $out;
271
  }
272
-
273
  function show_tags( $atts ) {
274
-
275
  extract(shortcode_atts(array(
276
  'gallery' => '',
277
  'album' => ''
278
  ), $atts ));
279
-
280
  if ( !empty($album) )
281
  $out = nggShowAlbumTags($album);
282
  else
283
  $out = nggShowGalleryTags($gallery);
284
-
285
  return $out;
286
  }
287
 
288
  /**
289
  * Function to show a thumbnail or a set of thumbnails with shortcode of type:
290
- *
291
  * [thumb id="1,2,4,5,..." template="filename" /]
292
- * where
293
  * - id is one or more picture ids
294
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
295
- *
296
  * @param array $atts
297
  * @return the_content
298
  */
299
  function show_thumbs( $atts ) {
300
-
301
  extract(shortcode_atts(array(
302
  'id' => '',
303
  'template' => ''
304
  ), $atts));
305
-
306
  // make an array out of the ids
307
  $pids = explode( ',', $id );
308
-
309
  // Some error checks
310
  if ( count($pids) == 0 )
311
  return __('[Pictures not found]','nggallery');
312
-
313
  $picturelist = nggdb::find_images_in_list( $pids );
314
-
315
  // show gallery
316
  if ( is_array($picturelist) )
317
  $out = nggCreateGallery($picturelist, false, $template);
318
-
319
  return $out;
320
  }
321
 
322
  /**
323
  * Function to show a gallery of random or the most recent images with shortcode of type:
324
- *
325
  * [random max="7" template="filename" id="2" /]
326
  * [recent max="7" template="filename" id="3" mode="date" /]
327
- * where
328
  * - max is the maximum number of random or recent images to show
329
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
330
  * - id is the gallery id, if the recent/random pictures shall be taken from a specific gallery only
331
- * - mode is either "id" (which takes the latest additions to the databse, default)
332
- * or "date" (which takes the latest pictures by EXIF date)
333
  * or "sort" (which takes the pictures by user sort order)
334
- *
335
  * @param array $atts
336
  * @return the_content
337
  */
338
  function show_random( $atts ) {
339
-
340
  extract(shortcode_atts(array(
341
  'max' => '',
342
  'template' => '',
343
  'id' => 0
344
  ), $atts));
345
-
346
  $out = nggShowRandomRecent('random', $max, $template, $id);
347
-
348
  return $out;
349
  }
350
 
351
  function show_recent( $atts ) {
352
-
353
  extract(shortcode_atts(array(
354
  'max' => '',
355
  'template' => '',
356
  'id' => 0,
357
  'mode' => 'id'
358
  ), $atts));
359
-
360
  $out = nggShowRandomRecent($mode, $max, $template, $id);
361
-
362
  return $out;
363
  }
364
 
365
  /**
366
  * Shortcode for the Image tag cloud
367
  * Usage : [tagcloud template="filename" /]
368
- *
369
  * @param array $atts
370
  * @return the content
371
  */
372
  function show_tagcloud( $atts ) {
373
-
374
  extract(shortcode_atts(array(
375
  'template' => ''
376
  ), $atts));
377
-
378
  $out = nggTagCloud( '', $template );
379
-
380
  return $out;
381
  }
382
 
383
  }
384
 
385
  // let's use it
386
- $nggShortcodes = new NextGEN_Shortcodes;
387
 
388
  ?>
1
  <?php
2
  /**
3
+ * @author Alex Rabe, Vincent Prat
4
+ *
5
  * @since 1.0.0
6
  * @description Use WordPress Shortcode API for more features
7
  * @Docs http://codex.wordpress.org/Shortcode_API
8
  */
9
 
10
  class NextGEN_shortcodes {
11
+
12
+ function __construct()
13
+ {
 
14
  //Long posts should require a higher limit, see http://core.trac.wordpress.org/ticket/8553
15
  @ini_set('pcre.backtrack_limit', 500000);
16
+
17
  // convert the old shortcode
18
  add_filter('the_content', array(&$this, 'convert_shortcode'));
19
+ add_filter('loop_start', array(&$this, 'reset_globals'));
20
+
21
  // do_shortcode on the_excerpt could causes several unwanted output. Uncomment it on your own risk
22
  // add_filter('the_excerpt', array(&$this, 'convert_shortcode'));
23
  // add_filter('the_excerpt', 'do_shortcode', 11);
24
+
25
  add_shortcode( 'singlepic', array(&$this, 'show_singlepic' ) );
26
  add_shortcode( 'album', array(&$this, 'show_album' ) );
27
+ add_shortcode( 'nggalbum', array(&$this, 'show_album' ) );
28
  add_shortcode( 'nggallery', array(&$this, 'show_gallery') );
29
  add_shortcode( 'imagebrowser', array(&$this, 'show_imagebrowser' ) );
30
  add_shortcode( 'slideshow', array(&$this, 'show_slideshow' ) );
33
  add_shortcode( 'random', array(&$this, 'show_random' ) );
34
  add_shortcode( 'recent', array(&$this, 'show_recent' ) );
35
  add_shortcode( 'tagcloud', array(&$this, 'show_tagcloud' ) );
36
+ }
37
+
38
+ function reset_globals()
39
+ {
40
+ unset($GLOBALS['subalbum']);
41
+ unset($GLOBALS['nggShowGallery']);
42
+ }
43
 
44
  /**
45
  * NextGEN_shortcodes::convert_shortcode()
46
  * convert old shortcodes to the new WordPress core style
47
  * [gallery=1] ->> [nggallery id=1]
48
+ *
49
  * @param string $content Content to search for shortcodes
50
  * @return string Content with new shortcodes.
51
  */
52
  function convert_shortcode($content) {
53
+
54
  $ngg_options = nggGallery::get_option('ngg_options');
55
+
56
  if ( stristr( $content, '[singlepic' )) {
57
  $search = "@\[singlepic=(\d+)(|,\d+|,)(|,\d+|,)(|,watermark|,web20|,)(|,right|,center|,left|,)\]@i";
58
  if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
60
  foreach ($matches as $match) {
61
  // remove the comma
62
  $match[2] = ltrim($match[2], ',');
63
+ $match[3] = ltrim($match[3], ',');
64
+ $match[4] = ltrim($match[4], ',');
65
+ $match[5] = ltrim($match[5], ',');
66
  $replace = "[singlepic id=\"{$match[1]}\" w=\"{$match[2]}\" h=\"{$match[3]}\" mode=\"{$match[4]}\" float=\"{$match[5]}\" ]";
67
  $content = str_replace ($match[0], $replace, $content);
68
  }
70
  }
71
 
72
  if ( stristr( $content, '[album' )) {
73
+ $search = "@(?:<p>)*\s*\[album\s*=\s*(\w+|^\+)(|,extend|,compact)\]\s*(?:</p>)*@i";
74
  if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
75
 
76
  foreach ($matches as $match) {
80
  $content = str_replace ($match[0], $replace, $content);
81
  }
82
  }
83
+ }
84
 
85
  if ( stristr( $content, '[gallery' )) {
86
  $search = "@(?:<p>)*\s*\[gallery\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
91
  $content = str_replace ($match[0], $replace, $content);
92
  }
93
  }
94
+ }
95
 
96
  if ( stristr( $content, '[imagebrowser' )) {
97
  $search = "@(?:<p>)*\s*\[imagebrowser\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
111
  foreach ($matches as $match) {
112
  // remove the comma
113
  $match[3] = ltrim($match[3],',');
114
+ $match[5] = ltrim($match[5],',');
115
  $replace = "[slideshow id=\"{$match[1]}\" w=\"{$match[3]}\" h=\"{$match[5]}\"]";
116
  $content = str_replace ($match[0], $replace, $content);
117
  }
128
  }
129
  }
130
  }
131
+
132
  if ( stristr( $content, '[albumtags' )) {
133
  $search = "@(?:<p>)*\s*\[albumtags\s*=\s*(.*?)\s*\]\s*(?:</p>)*@i";
134
  if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
141
  }
142
 
143
  // attach related images based on category or tags
144
+ if ($ngg_options['activateTags'])
145
  $content .= nggShowRelatedImages();
146
+
147
  return $content;
148
  }
149
+
150
  /**
151
  * Function to show a single picture:
152
+ *
153
  * [singlepic id="10" float="none|left|right" width="" height="" mode="none|watermark|web20" link="url" "template="filename" /]
154
  *
155
  * where
160
  * - mode is one of none, watermark or web20 (transformation applied to the picture)
161
  * - link is optional and could link to a other url instead the full image
162
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
163
+ *
164
  * If the tag contains some text, this will be inserted as an additional caption to the picture too. Example:
165
  * [singlepic id="10"]This is an additional caption[/singlepic]
166
+ * This tag will show a picture with under it two HTML span elements containing respectively the alttext of the picture
167
+ * and the additional caption specified in the tag.
168
+ *
169
  * @param array $atts
170
  * @param string $caption text
171
  * @return the content
172
  */
173
  function show_singlepic( $atts, $content = '' ) {
174
+
175
  extract(shortcode_atts(array(
176
  'id' => 0,
177
  'w' => '',
181
  'link' => '',
182
  'template' => ''
183
  ), $atts ));
184
+
185
  $out = nggSinglePicture($id, $w, $h, $mode, $float, $template, $content, $link);
186
+
187
  return $out;
188
  }
189
 
190
  /**
191
  * Function to show a collection of galleries:
192
+ *
193
  * [album id="1,2,4,5,..." template="filename" gallery="filename" /]
194
+ * where
195
  * - id of a album
196
  * - template is a name for a album template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
197
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
198
+ *
199
  * @param array $atts
200
  * @return the_content
201
  */
202
  function show_album( $atts ) {
203
+
204
  extract(shortcode_atts(array(
205
  'id' => 0,
206
  'template' => 'extend',
207
+ 'gallery' => ''
208
  ), $atts ));
209
+
210
  $out = nggShowAlbum($id, $template, $gallery);
211
+
212
  return $out;
213
  }
214
  /**
215
  * Function to show a thumbnail or a set of thumbnails with shortcode of type:
216
+ *
217
  * [gallery id="1,2,4,5,..." template="filename" images="number of images per page" /]
218
+ * where
219
  * - id of a gallery
220
  * - images is the number of images per page (optional), 0 will show all images
221
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
222
+ *
223
  * @param array $atts
224
  * @return the_content
225
  */
226
  function show_gallery( $atts ) {
227
+
228
  global $wpdb;
229
+
230
  extract(shortcode_atts(array(
231
  'id' => 0,
232
+ 'template' => '',
233
  'images' => false
234
  ), $atts ));
235
+
236
  // backward compat for user which uses the name instead, still deprecated
237
  if( !is_numeric($id) )
238
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) );
239
+
240
  $out = nggShowGallery( $id, $template, $images );
241
+
242
  return $out;
243
  }
244
 
245
  function show_imagebrowser( $atts ) {
246
+
247
  global $wpdb;
248
+
249
  extract(shortcode_atts(array(
250
  'id' => 0,
251
+ 'template' => ''
252
  ), $atts ));
253
 
254
  $out = nggShowImageBrowser($id, $template);
255
+
256
  return $out;
257
  }
258
+
259
  function show_slideshow( $atts ) {
260
+
261
  global $wpdb;
262
+
263
  extract(shortcode_atts(array(
264
  'id' => 0,
265
  'w' => '',
266
  'h' => ''
267
  ), $atts ));
268
+
269
  if( !is_numeric($id) )
270
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) );
271
 
272
  if( !empty( $id ) )
273
  $out = nggShowSlideshow($id, $w, $h);
274
+ else
275
  $out = __('[Gallery not found]','nggallery');
276
+
277
  return $out;
278
  }
279
+
280
  function show_tags( $atts ) {
281
+
282
  extract(shortcode_atts(array(
283
  'gallery' => '',
284
  'album' => ''
285
  ), $atts ));
286
+
287
  if ( !empty($album) )
288
  $out = nggShowAlbumTags($album);
289
  else
290
  $out = nggShowGalleryTags($gallery);
291
+
292
  return $out;
293
  }
294
 
295
  /**
296
  * Function to show a thumbnail or a set of thumbnails with shortcode of type:
297
+ *
298
  * [thumb id="1,2,4,5,..." template="filename" /]
299
+ * where
300
  * - id is one or more picture ids
301
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
302
+ *
303
  * @param array $atts
304
  * @return the_content
305
  */
306
  function show_thumbs( $atts ) {
307
+
308
  extract(shortcode_atts(array(
309
  'id' => '',
310
  'template' => ''
311
  ), $atts));
312
+
313
  // make an array out of the ids
314
  $pids = explode( ',', $id );
315
+
316
  // Some error checks
317
  if ( count($pids) == 0 )
318
  return __('[Pictures not found]','nggallery');
319
+
320
  $picturelist = nggdb::find_images_in_list( $pids );
321
+
322
  // show gallery
323
  if ( is_array($picturelist) )
324
  $out = nggCreateGallery($picturelist, false, $template);
325
+
326
  return $out;
327
  }
328
 
329
  /**
330
  * Function to show a gallery of random or the most recent images with shortcode of type:
331
+ *
332
  * [random max="7" template="filename" id="2" /]
333
  * [recent max="7" template="filename" id="3" mode="date" /]
334
+ * where
335
  * - max is the maximum number of random or recent images to show
336
  * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
337
  * - id is the gallery id, if the recent/random pictures shall be taken from a specific gallery only
338
+ * - mode is either "id" (which takes the latest additions to the databse, default)
339
+ * or "date" (which takes the latest pictures by EXIF date)
340
  * or "sort" (which takes the pictures by user sort order)
341
+ *
342
  * @param array $atts
343
  * @return the_content
344
  */
345
  function show_random( $atts ) {
346
+
347
  extract(shortcode_atts(array(
348
  'max' => '',
349
  'template' => '',
350
  'id' => 0
351
  ), $atts));
352
+
353
  $out = nggShowRandomRecent('random', $max, $template, $id);
354
+
355
  return $out;
356
  }
357
 
358
  function show_recent( $atts ) {
359
+
360
  extract(shortcode_atts(array(
361
  'max' => '',
362
  'template' => '',
363
  'id' => 0,
364
  'mode' => 'id'
365
  ), $atts));
366
+
367
  $out = nggShowRandomRecent($mode, $max, $template, $id);
368
+
369
  return $out;
370
  }
371
 
372
  /**
373
  * Shortcode for the Image tag cloud
374
  * Usage : [tagcloud template="filename" /]
375
+ *
376
  * @param array $atts
377
  * @return the content
378
  */
379
  function show_tagcloud( $atts ) {
380
+
381
  extract(shortcode_atts(array(
382
  'template' => ''
383
  ), $atts));
384
+
385
  $out = nggTagCloud( '', $template );
386
+
387
  return $out;
388
  }
389
 
390
  }
391
 
392
  // let's use it
393
+ $nggShortcodes = new NextGEN_Shortcodes;
394
 
395
  ?>
lib/sitemap.php CHANGED
@@ -1,30 +1,30 @@
1
  <?php
2
  /**
3
  * Main PHP Class for XML Image Sitemaps
4
- *
5
- * @author Alex Rabe
6
  * @version 1.0
7
  * @copyright Copyright 2011
8
- *
9
  */
10
  class nggSitemaps {
11
-
12
- var $images = false;
13
-
14
  /**
15
  * nggSitemaps::__construct()
16
- *
17
  * @return
18
  */
19
  function __construct() {
20
-
21
  add_filter('wpseo_sitemap_urlimages', array( &$this, 'add_wpseo_xml_sitemap_images'), 10, 2);
22
-
23
  }
24
 
25
  /**
26
  * Filter support for WordPress SEO by Yoast 0.4.0 or higher ( http://wordpress.org/extend/plugins/wordpress-seo/ )
27
- *
28
  * @since Version 1.8.0
29
  * @param array $images
30
  * @param int $post ID
@@ -39,10 +39,10 @@ class nggSitemaps {
39
 
40
  // Backward check for older images
41
  $p->post_content = NextGEN_Shortcodes::convert_shortcode($p->post_content);
42
-
43
  // Don't process the images in the normal way
44
  remove_all_shortcodes();
45
-
46
  // We cannot parse at this point a album, just galleries & single images
47
  add_shortcode( 'singlepic', array(&$this, 'add_images' ) );
48
  add_shortcode( 'thumb', array(&$this, 'add_images' ) );
@@ -52,28 +52,28 @@ class nggSitemaps {
52
 
53
  // Search now for shortcodes
54
  do_shortcode( $p->post_content );
55
-
56
  return $this->images;
57
  }
58
 
59
  /**
60
  * Parse the gallery/imagebrowser/slideshow shortcode and return all images into an array
61
- *
62
  * @param string $atts
63
  * @return
64
  */
65
  function add_gallery( $atts ) {
66
-
67
  global $wpdb;
68
-
69
  extract(shortcode_atts(array(
70
  'id' => 0
71
  ), $atts ));
72
-
73
  // backward compat for user which uses the name instead, still deprecated
74
  if( !is_numeric($id) )
75
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) );
76
-
77
  $images = nggdb::get_gallery($id, 'pid', 'ASC', true, 1000);
78
 
79
  foreach ($images as $image) {
@@ -81,46 +81,46 @@ class nggSitemaps {
81
  $newimage['src'] = $newimage['sc'] = $image->imageURL;
82
  if ( !empty($image->title) )
83
  $newimage['title'] = $image->title;
84
- if ( !empty($image->alttext) )
85
  $newimage['alt'] = $image->alttext;
86
  $this->images[] = $newimage;
87
  }
88
-
89
- return;
90
  }
91
 
92
  /**
93
  * Parse the single image shortcode and return all images into an array
94
- *
95
  * @param array $atts
96
  * @return
97
  */
98
  function add_images( $atts ) {
99
-
100
  extract(shortcode_atts(array(
101
  'id' => 0
102
  ), $atts ));
103
-
104
  // make an array out of the ids (for thumbs shortcode))
105
  $pids = explode( ',', $id );
106
-
107
  // Some error checks
108
  if ( count($pids) == 0 )
109
  return;
110
-
111
  $images = nggdb::find_images_in_list( $pids );
112
-
113
  foreach ($images as $image) {
114
  $newimage = array();
115
  $newimage['src'] = $newimage['sc'] = $image->imageURL;
116
  if ( !empty($image->title) )
117
  $newimage['title'] = $image->title;
118
- if ( !empty($image->alttext) )
119
  $newimage['alt'] = $image->alttext;
120
  $this->images[] = $newimage;
121
  }
122
 
123
- return;
124
  }
125
 
126
  }
1
  <?php
2
  /**
3
  * Main PHP Class for XML Image Sitemaps
4
+ *
5
+ * @author Alex Rabe
6
  * @version 1.0
7
  * @copyright Copyright 2011
8
+ *
9
  */
10
  class nggSitemaps {
11
+
12
+ var $images = array();
13
+
14
  /**
15
  * nggSitemaps::__construct()
16
+ *
17
  * @return
18
  */
19
  function __construct() {
20
+
21
  add_filter('wpseo_sitemap_urlimages', array( &$this, 'add_wpseo_xml_sitemap_images'), 10, 2);
22
+
23
  }
24
 
25
  /**
26
  * Filter support for WordPress SEO by Yoast 0.4.0 or higher ( http://wordpress.org/extend/plugins/wordpress-seo/ )
27
+ *
28
  * @since Version 1.8.0
29
  * @param array $images
30
  * @param int $post ID
39
 
40
  // Backward check for older images
41
  $p->post_content = NextGEN_Shortcodes::convert_shortcode($p->post_content);
42
+
43
  // Don't process the images in the normal way
44
  remove_all_shortcodes();
45
+
46
  // We cannot parse at this point a album, just galleries & single images
47
  add_shortcode( 'singlepic', array(&$this, 'add_images' ) );
48
  add_shortcode( 'thumb', array(&$this, 'add_images' ) );
52
 
53
  // Search now for shortcodes
54
  do_shortcode( $p->post_content );
55
+
56
  return $this->images;
57
  }
58
 
59
  /**
60
  * Parse the gallery/imagebrowser/slideshow shortcode and return all images into an array
61
+ *
62
  * @param string $atts
63
  * @return
64
  */
65
  function add_gallery( $atts ) {
66
+
67
  global $wpdb;
68
+
69
  extract(shortcode_atts(array(
70
  'id' => 0
71
  ), $atts ));
72
+
73
  // backward compat for user which uses the name instead, still deprecated
74
  if( !is_numeric($id) )
75
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $id) );
76
+
77
  $images = nggdb::get_gallery($id, 'pid', 'ASC', true, 1000);
78
 
79
  foreach ($images as $image) {
81
  $newimage['src'] = $newimage['sc'] = $image->imageURL;
82
  if ( !empty($image->title) )
83
  $newimage['title'] = $image->title;
84
+ if ( !empty($image->alttext) )
85
  $newimage['alt'] = $image->alttext;
86
  $this->images[] = $newimage;
87
  }
88
+
89
+ return '';
90
  }
91
 
92
  /**
93
  * Parse the single image shortcode and return all images into an array
94
+ *
95
  * @param array $atts
96
  * @return
97
  */
98
  function add_images( $atts ) {
99
+
100
  extract(shortcode_atts(array(
101
  'id' => 0
102
  ), $atts ));
103
+
104
  // make an array out of the ids (for thumbs shortcode))
105
  $pids = explode( ',', $id );
106
+
107
  // Some error checks
108
  if ( count($pids) == 0 )
109
  return;
110
+
111
  $images = nggdb::find_images_in_list( $pids );
112
+
113
  foreach ($images as $image) {
114
  $newimage = array();
115
  $newimage['src'] = $newimage['sc'] = $image->imageURL;
116
  if ( !empty($image->title) )
117
  $newimage['title'] = $image->title;
118
+ if ( !empty($image->alttext) )
119
  $newimage['alt'] = $image->alttext;
120
  $this->images[] = $newimage;
121
  }
122
 
123
+ return '';
124
  }
125
 
126
  }
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.10
9
 
10
  Copyright (c) 2007-2011 by Alex Rabe & NextGEN DEV-Team
11
  Copyright (c) 2012 Photocrati Media
@@ -45,9 +45,9 @@ if (!class_exists('E_Clean_Exit')) {
45
  if (!class_exists('nggLoader')) {
46
  class nggLoader {
47
 
48
- var $version = '1.9.10';
49
  var $dbversion = '1.8.1';
50
- var $minimum_WP = '3.4';
51
  var $donators = 'http://www.nextgen-gallery.com/donators.php';
52
  var $options = '';
53
  var $manage_page;
@@ -76,7 +76,7 @@ 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(&$this, 'uninstall') );
80
 
81
  // Start this plugin once all other plugins are fully loaded
82
  add_action( 'plugins_loaded', array(&$this, 'start_plugin') );
5
  Description: A NextGENeration Photo Gallery for WordPress
6
  Author: Photocrati
7
  Author URI: http://www.photocrati.com/
8
+ Version: 1.9.11
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.11';
49
  var $dbversion = '1.8.1';
50
+ var $minimum_WP = '3.5';
51
  var $donators = 'http://www.nextgen-gallery.com/donators.php';
52
  var $options = '';
53
  var $manage_page;
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(__CLASS__, 'uninstall') );
80
 
81
  // Start this plugin once all other plugins are fully loaded
82
  add_action( 'plugins_loaded', array(&$this, 'start_plugin') );
nggfunctions.php CHANGED
@@ -423,7 +423,8 @@ function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
423
 
424
  // subalbum support only one instance, you can't use more of them in one post
425
  //TODO: causes problems with SFC plugin, due to a second filter callback
426
- if ( isset($GLOBALS['subalbum']) || isset($GLOBALS['nggShowGallery']) )
 
427
  return;
428
 
429
  // if gallery is submit , then show the gallery instead
@@ -470,13 +471,13 @@ function nggShowAlbum($albumID, $template = 'extend', $gallery_template = '') {
470
  * @return the content
471
  */
472
  function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
473
-
474
- global $wpdb, $nggRewrite, $nggdb;
475
 
476
  // $_GET from wp_query
477
  $nggpage = get_query_var('nggpage');
478
 
479
- $ngg_options = nggGallery::get_option('ngg_options');
 
480
 
481
  //this option can currently only set via the custom fields
482
  $maxElement = (int) $ngg_options['galPagedGalleries'];
@@ -511,82 +512,70 @@ function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
511
  // re-order them and populate some
512
  foreach ($sortorder as $key) {
513
 
 
 
 
 
514
  //if we have a prefix 'a' then it's a subalbum, instead a gallery
515
  if (substr( $key, 0, 1) == 'a') {
516
- // get the album content
517
- if ( !$subalbum = $nggdb->find_album(substr( $key, 1)) )
518
- continue;
519
-
520
- //populate the sub album values
521
- if (!isset($galleries[$key])) $galleries[$key] = new stdClass;
522
- $galleries[$key]->counter = 0;
523
- $galleries[$key]->previewurl = '';
524
- // ensure that album contain a preview image
525
- if ($subalbum->previewpic > 0){
526
- $image = $nggdb->find_image( $subalbum->previewpic );
527
- $galleries[$key]->previewurl = isset($image->thumbURL) ? $image->thumbURL : '';
 
 
 
 
 
528
  }
529
-
530
- $galleries[$key]->previewpic = $subalbum->previewpic;
531
- $galleries[$key]->previewname = $subalbum->name;
532
-
533
- //link to the subalbum
534
- $args['album'] = ( $ngg_options['usePermalinks'] ) ? $subalbum->slug : $subalbum->id;
535
- $args['gallery'] = false;
536
- $args['nggpage'] = false;
537
- $pageid = (isset($subalbum->pageid) ? $subalbum->pageid : 0);
538
- $galleries[$key]->pagelink = ($pageid > 0) ? get_permalink($pageid) : $nggRewrite->get_permalink($args);
539
- $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n($subalbum->albumdesc) );
540
- $galleries[$key]->title = html_entity_decode ( nggGallery::i18n($subalbum->name) );
541
-
542
- // apply a filter on gallery object before the output
543
- $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
544
-
545
- continue;
546
  }
 
 
547
 
548
- // If a gallery is not found it should be ignored
549
- if (!$unsort_galleries[$key])
550
- continue;
551
-
552
- // No images found, set counter to 0
553
- if (!isset($galleries[$key]->counter)){
554
- $galleries[$key]->counter = 0;
555
- $galleries[$key]->previewurl = '';
556
- }
557
 
558
- // Add the counter value if avaible
559
- $galleries[$key] = $unsort_galleries[$key];
560
-
561
- // add the file name and the link
562
- if ($galleries[$key]->previewpic != 0) {
563
- $galleries[$key]->previewname = $albumPreview[$galleries[$key]->previewpic]->filename;
564
- $galleries[$key]->previewurl = site_url().'/' . $galleries[$key]->path . '/thumbs/thumbs_' . $albumPreview[$galleries[$key]->previewpic]->filename;
565
- } else {
566
- $first_image = $wpdb->get_row('SELECT * FROM '. $wpdb->nggpictures .' WHERE exclude != 1 AND galleryid = '. $key .' ORDER by pid DESC limit 0,1');
567
- if (isset($first_image)) {
568
- $galleries[$key]->previewpic = $first_image->pid;
569
- $galleries[$key]->previewname = $first_image->filename;
570
- $galleries[$key]->previewurl = site_url() . '/' . $galleries[$key]->path . '/thumbs/thumbs_' . $first_image->filename;
571
- }
572
- }
573
 
574
- // choose between variable and page link
575
- if ($ngg_options['galNoPages']) {
576
- $args['album'] = ( $ngg_options['usePermalinks'] ) ? $album->slug : $album->id;
577
- $args['gallery'] = ( $ngg_options['usePermalinks'] ) ? $galleries[$key]->slug : $key;
578
- $args['nggpage'] = false;
579
- $galleries[$key]->pagelink = $nggRewrite->get_permalink($args);
580
 
581
- } else {
582
- $galleries[$key]->pagelink = get_permalink( $galleries[$key]->pageid );
583
- }
584
 
585
- // description can contain HTML tags
586
- $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->galdesc), 'gal_' . $galleries[$key]->gid . '_description') ) ;
587
 
588
- // i18n
589
- $galleries[$key]->title = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->title), 'gal_' . $galleries[$key]->gid . '_title') ) ;
 
590
 
591
  // apply a filter on gallery object before the output
592
  $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
423
 
424
  // subalbum support only one instance, you can't use more of them in one post
425
  //TODO: causes problems with SFC plugin, due to a second filter callback
426
+ global $wp_current_filter;
427
+ if ( isset($GLOBALS['subalbum']) || isset($GLOBALS['nggShowGallery']))
428
  return;
429
 
430
  // if gallery is submit , then show the gallery instead
471
  * @return the content
472
  */
473
  function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
474
+ global $wpdb, $nggRewrite, $nggdb, $ngg;
 
475
 
476
  // $_GET from wp_query
477
  $nggpage = get_query_var('nggpage');
478
 
479
+ // Get options
480
+ $ngg_options = $ngg->options;
481
 
482
  //this option can currently only set via the custom fields
483
  $maxElement = (int) $ngg_options['galPagedGalleries'];
512
  // re-order them and populate some
513
  foreach ($sortorder as $key) {
514
 
515
+ // Create a gallery object
516
+ if (isset($unsort_galleries[$key])) $galleries[$key] = $unsort_galleries[$key];
517
+ else $galleries[$key] = new stdClass;
518
+
519
  //if we have a prefix 'a' then it's a subalbum, instead a gallery
520
  if (substr( $key, 0, 1) == 'a') {
521
+ if (($subalbum = $nggdb->find_album(substr($key, 1)))) {
522
+ $galleries[$key]->counter = count($subalbum->gallery_ids);
523
+ if ($subalbum->previewpic > 0){
524
+ $image = $nggdb->find_image( $subalbum->previewpic );
525
+ $galleries[$key]->previewurl = isset($image->thumbURL) ? $image->thumbURL : '';
526
+ }
527
+ $galleries[$key]->previewpic = $subalbum->previewpic;
528
+ $galleries[$key]->previewname = $subalbum->name;
529
+
530
+ //link to the subalbum
531
+ $args['album'] = ( $ngg_options['usePermalinks'] ) ? $subalbum->slug : $subalbum->id;
532
+ $args['gallery'] = false;
533
+ $args['nggpage'] = false;
534
+ $pageid = (isset($subalbum->pageid) ? $subalbum->pageid : 0);
535
+ $galleries[$key]->pagelink = ($pageid > 0) ? get_permalink($pageid) : $nggRewrite->get_permalink($args);
536
+ $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n($subalbum->albumdesc) );
537
+ $galleries[$key]->title = html_entity_decode ( nggGallery::i18n($subalbum->name) );
538
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  }
540
+ elseif (isset($unsort_galleries[$key])) {
541
+ $galleries[$key] = $unsort_galleries[$key];
542
 
543
+ // No images found, set counter to 0
544
+ if (!isset($galleries[$key]->counter)){
545
+ $galleries[$key]->counter = 0;
546
+ $galleries[$key]->previewurl = '';
547
+ }
 
 
 
 
548
 
549
+ // add the file name and the link
550
+ if ($galleries[$key]->previewpic != 0) {
551
+ $galleries[$key]->previewname = $albumPreview[$galleries[$key]->previewpic]->filename;
552
+ $galleries[$key]->previewurl = site_url().'/' . $galleries[$key]->path . '/thumbs/thumbs_' . $albumPreview[$galleries[$key]->previewpic]->filename;
553
+ } else {
554
+ $first_image = $wpdb->get_row('SELECT * FROM '. $wpdb->nggpictures .' WHERE exclude != 1 AND galleryid = '. $key .' ORDER by pid DESC limit 0,1');
555
+ if (isset($first_image)) {
556
+ $galleries[$key]->previewpic = $first_image->pid;
557
+ $galleries[$key]->previewname = $first_image->filename;
558
+ $galleries[$key]->previewurl = site_url() . '/' . $galleries[$key]->path . '/thumbs/thumbs_' . $first_image->filename;
559
+ }
560
+ }
 
 
 
561
 
562
+ // choose between variable and page link
563
+ if ($ngg_options['galNoPages']) {
564
+ $args['album'] = ( $ngg_options['usePermalinks'] ) ? $album->slug : $album->id;
565
+ $args['gallery'] = ( $ngg_options['usePermalinks'] ) ? $galleries[$key]->slug : $key;
566
+ $args['nggpage'] = false;
567
+ $galleries[$key]->pagelink = $nggRewrite->get_permalink($args);
568
 
569
+ } else {
570
+ $galleries[$key]->pagelink = get_permalink( $galleries[$key]->pageid );
571
+ }
572
 
573
+ // description can contain HTML tags
574
+ $galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->galdesc), 'gal_' . $galleries[$key]->gid . '_description') ) ;
575
 
576
+ // i18n
577
+ $galleries[$key]->title = html_entity_decode ( nggGallery::i18n( stripslashes($galleries[$key]->title), 'gal_' . $galleries[$key]->gid . '_title') ) ;
578
+ }
579
 
580
  // apply a filter on gallery object before the output
581
  $galleries[$key] = apply_filters('ngg_album_galleryobject', $galleries[$key]);
readme.txt CHANGED
@@ -1,51 +1,53 @@
1
  === NextGEN Gallery ===
2
  Contributors: photocrati
3
  Tags:gallery,image,images,photo,photos,picture,pictures,slideshow,flash,media,thumbnails,photo-albums,nextgen-gallery,nextgen
4
- Requires at least: 3.4
5
- Tested up to: 3.4.1
6
  Stable tag: trunk
7
  License: GPLv2
8
 
9
- The most popular WordPress gallery plugin with tons of features and over 6 million downloads.
10
 
11
  == Description ==
12
 
13
- NextGEN Gallery is the most popular **WordPress gallery plugin**, and one of the most popular WordPress plugins of any kind, with over 6 million downloads.
 
 
14
 
15
  It provides a powerful engine for uploading and managing galleries of images, with the ability to batch upload, import meta data, add/delete/rearrange/sort images, edit thumbnails, group galleries into albums, and more. It also provides two front-end display styles (slideshows and thumbnail galleries), both of which come with a wide array of options for controlling size, style, timing, transitions, controls, lightbox effects, and more.
16
 
17
- *The NextGEN Gallery WordPress plugin is now proudly maintained by <a href='http://www.photocrati.com'>Photocrati Media</a>. Special thanks to Alex Rabe who created and maintained NextGEN from 2007 through 2011.*
18
 
19
 
20
- = NextGEN WordPress Gallery Plugin - Features =
21
 
22
 
23
  *Upload Galleries*
24
 
25
- * Our WordPress gallery plugin offers diverse and powerful functionality for getting images from your desktop to your website. You can easily upload batches of images via a standard WordPress-style uploader, or upload images via zip file or FTP. NextGEN will automatically import your images’ meta data.
26
 
27
  *Manage Galleries*
28
 
29
  * Centralized gallery management. Enjoy a single location where you can see and manage all your galleries.
30
  * Edit galleries. Add or exclude images, change gallery title and description, reorder of images, resize thumbnails.
31
- * Thumbnail Management. Turn thumbnail cropping on off, customize how individual thumbnails are cropped, and bulk resize thumbnails across one more galleries.
32
- * Edit Individual Images. Edit meta data and image tags, rotate images, exclude images.
33
  * Watermarks. Quickly add watermarks to batches or galleries of images.
34
- * Albums. Create and organize collections of galleries (“albums”), and display them in either compact or extended format.
35
 
36
  *Display Galleries*
37
 
38
  * Two Gallery Types. Choose between two main display styles: Slideshow and Thumbnail, and allow visitors to toggle between the two.
39
- * Slideshow Galleries. Choose from a vast array of options for slideshows, including slideshow size, transition style, speed, image order, optional navigation bar.
40
- * Thumbnail Galleries. Choose from a wide range of options to customize thumbnail galleries, including 5 different lightboxs for individual images, optional thumbnails cropping and editing, thumbnail styles, captions, and more.
41
  * Single Image Displays. Display and format single images.
42
- * Work with Options Panel or ShortCodes.
43
 
44
- = NextGEN WordPress Gallery Plugin - Community & Extensions =
45
 
46
  NextGEN has been the dominant WordPress gallery plugin for years. As a result, there is large and great community of users and developers, as well as a large number of dedicated extension plugins. For a list of extension plugins, just search for NextGEN in the WordPress.org plugin repository, or visit our <a href="http://www.nextgen-gallery.com/nextgen-gallery-extension-plugins/">Complete List of NextGEN Extension Plugins</a>.
47
 
48
- = NextGEN WordPress Gallery Plugin - Resources =
49
 
50
  *Visit the NextGEN <a href="http://www.nextgen-gallery.com" target="_blank">WordPress Gallery Plugin</a> official homepage<br>
51
  *View <a href="http://www.nextgen-gallery.com/nextgen-gallery-demos/" target="_blank">NextGEN Gallery Demos</a><br>
@@ -70,19 +72,17 @@ You should have received a copy of the GNU General Public License along with thi
70
 
71
  ** Please note **
72
 
73
- The JW Image Rotator (Flash Slideshow) is not part of this license and is available under a Creative Commons License, which allowing you to use, modify and redistribute them for noncommercial purposes.
74
-
75
- For commercial use please look at the Jeroen's homepage : http://www.longtailvideo.com/
76
 
77
  == Installation ==
78
 
79
- 1. Download, install, and activate the NextGEN Gallery plugin.
80
 
81
  2. From your Wordpress Dashboard, go to Gallery > Add Gallery/Images > Follow the on-screen cues.
82
 
83
  3. Go to a post/page, and select the NextGEN Gallery button from the Kitchen Sink. Follow the on-screen cues to select, adjust, and publish your gallery.
84
 
85
- That's it ... Have fun
86
 
87
  http://www.youtube.com/watch?v=Le_ZsNSuIvM
88
 
@@ -127,11 +127,13 @@ http://www.youtube.com/watch?v=Le_ZsNSuIvM
127
  [ media id=6 width=320 height=240 plugins=revolt-1 ]<br>
128
  [ media id=3 width=320 height=240 plugins=rateit-2 ]<br>
129
 
 
 
130
  == Frequently Asked Questions ==
131
 
132
  = Will NextGEN Gallery work with my theme? =
133
 
134
- Part of what makes NextGEN so popular is its flexibility - it works with the vast majority of premium and free themes, without requiring any coding.
135
 
136
 
137
  = Are the galleries flash based? =
@@ -156,7 +158,7 @@ Yes, you can batch upload entire galleries at a time.
156
 
157
  = Can I password protect galleries? =
158
 
159
- Yes, Wordpress allows you to password protect pages by default - which includes all galleries and content for the entire page. Password protection of pages can be turned on and off at any time, with just a few clicks.
160
 
161
 
162
  = Can I add a watermark to the images/slideshows? =
@@ -188,12 +190,33 @@ Yes, caption areas are fully HMTL capable.
188
 
189
  Since the captions are fully HTML capable, you can add external links and any other type of mark up you wish.
190
 
 
191
  = Is NextGEN Gallery available in foreign languages? =
192
 
193
- Yes, NextGEN Gallery has been translated into dozens of languages - <a href="http://www.nextgen-gallery.com/languages/" target="_blank">click here to find out more.</a>
 
 
 
 
 
194
 
195
  == Changelog ==
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  = V1.9.10 - 12.18.2012 =
198
  * Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
199
  * Fixed: Restored compatibility with NextGEN Gallery Export Plugin
@@ -425,4 +448,4 @@ Yes, NextGEN Gallery has been translated into dozens of languages - <a href="htt
425
  == Upgrade Notice ==
426
 
427
  = 1.5.5 =
428
- * Compat issue for post thumbnails with WP2.9 and WP3.0. No Database changes...
1
  === NextGEN Gallery ===
2
  Contributors: photocrati
3
  Tags:gallery,image,images,photo,photos,picture,pictures,slideshow,flash,media,thumbnails,photo-albums,nextgen-gallery,nextgen
4
+ Requires at least: 3.5
5
+ Tested up to: 3.5.1
6
  Stable tag: trunk
7
  License: GPLv2
8
 
9
+ The most popular WordPress gallery plugin and one of the most popular plugins of all time with over 6 million downloads.
10
 
11
  == Description ==
12
 
13
+ = WordPress Gallery Plugin =
14
+
15
+ NextGEN Gallery is the most popular **WordPress gallery plugin**, and one of the most popular WordPress plugins of all time, with over 6 million downloads.
16
 
17
  It provides a powerful engine for uploading and managing galleries of images, with the ability to batch upload, import meta data, add/delete/rearrange/sort images, edit thumbnails, group galleries into albums, and more. It also provides two front-end display styles (slideshows and thumbnail galleries), both of which come with a wide array of options for controlling size, style, timing, transitions, controls, lightbox effects, and more.
18
 
19
+ *The NextGEN Gallery WordPress gallery plugin is now proudly maintained by <a href='http://www.photocrati.com'>Photocrati Media</a>. Special thanks to Alex Rabe who created and maintained NextGEN from 2007 through 2011.*
20
 
21
 
22
+ = NextGEN WordPress Gallery Plugin Features =
23
 
24
 
25
  *Upload Galleries*
26
 
27
+ * Our WordPress gallery plugin offers diverse and powerful functionality for getting images from your desktop to your website. You can easily upload batches of images via a standard WordPress-style uploader, or upload images via zip file or FTP. NextGEN will automatically import your images meta data.
28
 
29
  *Manage Galleries*
30
 
31
  * Centralized gallery management. Enjoy a single location where you can see and manage all your galleries.
32
  * Edit galleries. Add or exclude images, change gallery title and description, reorder of images, resize thumbnails.
33
+ * Thumbnail Management. Turn thumbnail cropping on and off, customize how individual thumbnails are cropped, and bulk resize thumbnails across one or more galleries.
34
+ * Edit Individual Images. Edit meta data and image tags, rotate images, and exclude images.
35
  * Watermarks. Quickly add watermarks to batches or galleries of images.
36
+ * Albums. Create and organize collections of galleries, and display them in either compact or extended format.
37
 
38
  *Display Galleries*
39
 
40
  * Two Gallery Types. Choose between two main display styles: Slideshow and Thumbnail, and allow visitors to toggle between the two.
41
+ * Slideshow Galleries. Choose from a vast array of options for slideshows, including slideshow size, transition style, speed, image order, and optional navigation bar.
42
+ * Thumbnail Galleries. Choose from a wide range of options to customize thumbnail galleries, including 5 different lightboxes for individual images, optional thumbnail cropping and editing, thumbnail styles, captions, and more.
43
  * Single Image Displays. Display and format single images.
44
+ * Work with Options Panel or Shortcodes.
45
 
46
+ = NextGEN WordPress Gallery Plugin Community & Extensions =
47
 
48
  NextGEN has been the dominant WordPress gallery plugin for years. As a result, there is large and great community of users and developers, as well as a large number of dedicated extension plugins. For a list of extension plugins, just search for NextGEN in the WordPress.org plugin repository, or visit our <a href="http://www.nextgen-gallery.com/nextgen-gallery-extension-plugins/">Complete List of NextGEN Extension Plugins</a>.
49
 
50
+ = NextGEN WordPress Gallery Plugin Resources =
51
 
52
  *Visit the NextGEN <a href="http://www.nextgen-gallery.com" target="_blank">WordPress Gallery Plugin</a> official homepage<br>
53
  *View <a href="http://www.nextgen-gallery.com/nextgen-gallery-demos/" target="_blank">NextGEN Gallery Demos</a><br>
72
 
73
  ** Please note **
74
 
75
+ NextGEN Gallery's flash slideshow option is powered by the JW Image Rotator from Long Tail Video. The Image Rotator is provided free as part of our plugin package thanks to a special commercial license with Long Tail Video. It is NOT released under GNU General Public License, and cannot be redistributed. A free version of the Image Rotator was previously available under a Creative Commons License, but it has been discontinued. Over time, we will be moving away from reliance on this file. For more information, see the Long Tail Video website: http://www.longtailvideo.com.
 
 
76
 
77
  == Installation ==
78
 
79
+ 1. Download, upload and install .zip under Plugins >> Add New > Upload, and activate the NextGEN Gallery WordPress gallery plugin.
80
 
81
  2. From your Wordpress Dashboard, go to Gallery > Add Gallery/Images > Follow the on-screen cues.
82
 
83
  3. Go to a post/page, and select the NextGEN Gallery button from the Kitchen Sink. Follow the on-screen cues to select, adjust, and publish your gallery.
84
 
85
+ That's it ... have fun! For more information, feel free to visit the official website for the NextGEN Gallery <a href="http://www.nextgen-gallery.com" target="_blank">WordPress Gallery Plugin</a>.
86
 
87
  http://www.youtube.com/watch?v=Le_ZsNSuIvM
88
 
127
  [ media id=6 width=320 height=240 plugins=revolt-1 ]<br>
128
  [ media id=3 width=320 height=240 plugins=rateit-2 ]<br>
129
 
130
+ For more information, feel free to visit the official website for the NextGEN Gallery <a href="http://www.nextgen-gallery.com" target="_blank">WordPress Gallery Plugin</a>.
131
+
132
  == Frequently Asked Questions ==
133
 
134
  = Will NextGEN Gallery work with my theme? =
135
 
136
+ Part of what makes the NextGEN Gallery WordPress gallery plugin so popular is its flexibility - it works with the vast majority of premium and free themes, without requiring any coding.
137
 
138
 
139
  = Are the galleries flash based? =
158
 
159
  = Can I password protect galleries? =
160
 
161
+ Yes, WordPress allows you to password protect pages by default - which includes all galleries and content for the entire page. Password protection of pages can be turned on and off at any time, with just a few clicks.
162
 
163
 
164
  = Can I add a watermark to the images/slideshows? =
190
 
191
  Since the captions are fully HTML capable, you can add external links and any other type of mark up you wish.
192
 
193
+
194
  = Is NextGEN Gallery available in foreign languages? =
195
 
196
+ Yes, the NextGEN Gallery WordPress gallery plugin has been translated into dozens of languages - <a href="http://www.nextgen-gallery.com/languages/" target="_blank">click here to find out more.</a>
197
+
198
+ = More Information =
199
+
200
+ For more information, feel free to visit the official website for the NextGEN Gallery <a href="http://www.nextgen-gallery.com" target="_blank">WordPress Gallery Plugin</a>.
201
+
202
 
203
  == Changelog ==
204
 
205
+ = V1.9.11 - 02.12.2013 =
206
+ * NEW: Added the ability to detect JQuery conflicts on NGG Admin Pages and auto-resolve
207
+ * Changed: Added "nggalbum" shortcode. Use this when Jetpack is installed.
208
+ * Changed: Using natural sorting algorithm for alphanumeric values
209
+ * Changed: Database schema is automatically updated when out-of-date
210
+ * Fixed: Fixed several incompatibility issues with Jetpack
211
+ * Fixed: Empty drop-down for "Page Link To"
212
+ * Fixed: Alphabetical image sorting
213
+ * Fixed: Compatibility with Arjuna X theme
214
+ * Fixed: “Creating default object from empty value” on album page
215
+ * Fixed: Compatibility issues with PHP 5.4 on album page
216
+ * Fixed: E_DEPRECATED warning when using get_userdatabylogin() function
217
+ * Fixed: Removed many E_NOTICE errors
218
+ * Fixed: Correct use of register_uninstall_hook across all PHP versions
219
+
220
  = V1.9.10 - 12.18.2012 =
221
  * Fixed: XML-RPC error displayed when authenticating using WordPress 3.5
222
  * Fixed: Restored compatibility with NextGEN Gallery Export Plugin
448
  == Upgrade Notice ==
449
 
450
  = 1.5.5 =
451
+ * Compatibility issue for post thumbnails with WP2.9 and WP3.0. No Database changes...
view/album-compact.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  Template Page for the album overview
4
 
@@ -14,11 +14,11 @@ Follow variables are useable :
14
  ?>
15
  <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($galleries)) : ?>
16
 
17
- <div class="ngg-albumoverview">
18
 
19
  <!-- List of galleries -->
20
  <?php foreach ($galleries as $gallery) : ?>
21
-
22
  <div class="ngg-album-compact">
23
  <div class="ngg-album-compactbox">
24
  <div class="ngg-album-link">
@@ -34,10 +34,9 @@ Follow variables are useable :
34
  </div>
35
 
36
  <?php endforeach; ?>
37
-
38
  <!-- Pagination -->
39
  <?php echo $pagination ?>
40
-
41
  </div>
42
 
43
  <?php endif; ?>
1
+ <?php
2
  /**
3
  Template Page for the album overview
4
 
14
  ?>
15
  <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($galleries)) : ?>
16
 
17
+ <div class="ngg-albumoverview">
18
 
19
  <!-- List of galleries -->
20
  <?php foreach ($galleries as $gallery) : ?>
21
+
22
  <div class="ngg-album-compact">
23
  <div class="ngg-album-compactbox">
24
  <div class="ngg-album-link">
34
  </div>
35
 
36
  <?php endforeach; ?>
37
+
38
  <!-- Pagination -->
39
  <?php echo $pagination ?>
 
40
  </div>
41
 
42
  <?php endif; ?>
xml/ajax.php CHANGED
@@ -1,40 +1,40 @@
1
- <?php
2
- // see http://codex.wordpress.org/AJAX_in_Plugins
3
-
4
- // check if we have all needed parameter
5
- if ( !defined('ABSPATH') || (!isset($_GET['galleryid']) || !is_numeric($_GET['galleryid'])) || (!isset($_GET['p']) || !is_numeric($_GET['p'])) || !isset($_GET['type'])){
6
- // if it's not ajax request, back to main page
7
- if($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest')
8
- header('Location: http://'. $_SERVER['HTTP_HOST']);
9
- die();
10
- }
11
-
12
- switch ($_GET['type']) {
13
- case 'gallery':
14
-
15
- // get the navigation page
16
- set_query_var('nggpage', intval($_GET['nggpage']));
17
-
18
- // get the current page/post id
19
- set_query_var('pageid', intval($_GET['p']));
20
- set_query_var('show', 'gallery');
21
- $GLOBALS['id'] = intval($_GET['p']);
22
-
23
- echo nggShowGallery( intval($_GET['galleryid']) );
24
-
25
- break;
26
- case 'browser':
27
-
28
- // which image should be shown ?
29
- set_query_var('pid', intval($_GET['pid']));
30
-
31
- // get the current page/post id
32
- set_query_var('pageid', intval($_GET['p']));
33
- $GLOBALS['id'] = intval($_GET['p']);
34
-
35
- echo nggShowImageBrowser( intval($_GET['galleryid']) );
36
-
37
- break;
38
- default:
39
- echo 'Wrong request type specified.';
40
  }
1
+ <?php
2
+ // see http://codex.wordpress.org/AJAX_in_Plugins
3
+
4
+ // check if we have all needed parameter
5
+ if ( !defined('ABSPATH') || (!isset($_GET['galleryid']) || !is_numeric($_GET['galleryid'])) || (!isset($_GET['p']) || !is_numeric($_GET['p'])) || !isset($_GET['type'])){
6
+ // if it's not ajax request, back to main page
7
+ if($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest')
8
+ header('Location: http://'. $_SERVER['HTTP_HOST']);
9
+ die();
10
+ }
11
+
12
+ switch ($_GET['type']) {
13
+ case 'gallery':
14
+
15
+ // get the navigation page
16
+ set_query_var('nggpage', intval($_GET['nggpage']));
17
+
18
+ // get the current page/post id
19
+ set_query_var('pageid', intval($_GET['p']));
20
+ set_query_var('show', 'gallery');
21
+ $GLOBALS['id'] = intval($_GET['p']);
22
+
23
+ echo nggShowGallery( intval($_GET['galleryid']) );
24
+
25
+ break;
26
+ case 'browser':
27
+
28
+ // which image should be shown ?
29
+ set_query_var('pid', intval($_GET['pid']));
30
+
31
+ // get the current page/post id
32
+ set_query_var('pageid', intval($_GET['p']));
33
+ $GLOBALS['id'] = intval($_GET['p']);
34
+
35
+ echo nggShowImageBrowser( intval($_GET['galleryid']) );
36
+
37
+ break;
38
+ default:
39
+ echo 'Wrong request type specified.';
40
  }
xml/json.php CHANGED
@@ -1,275 +1,275 @@
1
- <?php
2
- /**
3
- * REST Application Programming Interface PHP class for the WordPress plugin NextGEN Gallery
4
- * Should emulate some kind of Flickr JSON callback : ?callback=json&format=json&api_key=1234567890&method=search&term=myterm
5
- *
6
- * @version 1.1.0
7
- * @author Alex Rabe
8
- *
9
- * @require PHP 5.2.0 or higher
10
- *
11
- */
12
-
13
- class nggAPI {
14
-
15
- /**
16
- * $_GET Variables
17
- *
18
- * @since 1.5.0
19
- * @access private
20
- * @var string
21
- */
22
- var $format = false; // $_GET['format'] : Return a XML oder JSON output
23
- var $api_key = false; // $_GET['api_key'] : Protect the access via a random key (required if user is not logged into backend)
24
- var $method = false; // $_GET['method'] : search | gallery | image | album | tag | autocomplete
25
- var $term = false; // $_GET['term'] : The search term (required for method search | tag)
26
- var $id = false; // $_GET['id'] : object id (required for method gallery | image | album )
27
- var $limit = false; // $_GET['limit'] : maximum of images which we request
28
- var $type = false; // $_GET['type'] : gallery | image | album (required for method autocomplete)
29
-
30
- /**
31
- * Contain the final output
32
- *
33
- * @since 1.5.0
34
- * @access private
35
- * @var string
36
- */
37
- var $output = '';
38
-
39
- /**
40
- * Holds the requested information as array
41
- *
42
- * @since 1.5.0
43
- * @access private
44
- * @var array
45
- */
46
- var $result = '';
47
-
48
- /**
49
- * Init the variables
50
- *
51
- */
52
- function __construct() {
53
-
54
- if ( !defined('ABSPATH') )
55
- die('You are not allowed to call this page directly.');
56
-
57
- if ( !function_exists('json_encode') )
58
- wp_die('Json_encode not available. You need to use PHP 5.2');
59
-
60
- // Read the parameter on init
61
- $this->format = isset($_GET['format']) ? strtolower( $_GET['format'] ) : false;
62
- $this->api_key = isset($_GET['api_key'])? $_GET['api_key'] : false;
63
- $this->method = isset($_GET['method']) ? strtolower( $_GET['method'] ) : false;
64
- $this->term = isset($_GET['term']) ? urldecode( $_GET['term'] ) : false;
65
- $this->id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
66
- $this->limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 0;
67
- $this->type = isset($_GET['type']) ? strtolower( $_GET['type'] ) : false;
68
- $this->result = array();
69
- $this->list = false;
70
-
71
- $this->start_process();
72
- $this->render_output();
73
- }
74
-
75
- function start_process() {
76
-
77
- global $ngg;
78
-
79
- if ( !$this->valid_access() )
80
- return;
81
-
82
- switch ( $this->method ) {
83
- case 'search' :
84
- //search for some images
85
- $this->result['images'] = array_merge( (array) nggdb::search_for_images( $this->term ), (array) nggTags::find_images_for_tags( $this->term , 'ASC' ));
86
- break;
87
- case 'album' :
88
- //search for some album //TODO : Get images for each gallery, could end in a big db query
89
- $this->result['album'] = nggdb::find_album( $this->id );
90
- break;
91
- case 'gallery' :
92
- //search for some gallery
93
- $this->result['images'] = ($this->id == 0) ? nggdb::find_last_images( 0 , 100 ) : nggdb::get_gallery( $this->id, $ngg->options['galSort'], $ngg->options['galSortDir'], true, 0, 0, true );
94
- break;
95
- case 'image' :
96
- //search for some image
97
- $this->result['images'] = nggdb::find_image( $this->id );
98
- break;
99
- case 'tag' :
100
- //search for images based on tags
101
- $this->result['images'] = nggTags::find_images_for_tags( $this->term , 'ASC' );
102
- break;
103
- case 'recent' :
104
- //search for images based on tags
105
- $this->result['images'] = nggdb::find_last_images( 0 , $this->limit );
106
- break;
107
- case 'autocomplete' :
108
- //return images, galleries or albums for autocomplete drop down list
109
- return $this->autocomplete();
110
- break;
111
- case 'version' :
112
- $this->result = array ('stat' => 'ok', 'version' => $ngg->version);
113
- return;
114
- break;
115
- default :
116
- $this->result = array ('stat' => 'fail', 'code' => '98', 'message' => 'Method not known.');
117
- return false;
118
- break;
119
- }
120
-
121
- // result should be fine
122
- $this->result['stat'] = 'ok';
123
- }
124
-
125
- function valid_access() {
126
-
127
- // if we are logged in, then we can go on
128
- if ( is_user_logged_in() )
129
- return true;
130
-
131
- //TODO:Implement an API KEY check later
132
- if ($this->api_key != false)
133
- return true;
134
-
135
- $this->result = array ('stat' => 'fail', 'code' => '99', 'message' => 'Insufficient permissions. Method requires read privileges; none granted.');
136
- return false;
137
- }
138
-
139
- /**
140
- * return search result for autocomplete request from backend
141
- *
142
- * @since 1.7.0
143
- * @return void
144
- */
145
- function autocomplete() {
146
- global $nggdb;
147
-
148
- switch ( $this->type ) {
149
- case 'image' :
150
-
151
- // return the last entries in case of an empty search string
152
- if ( empty($this->term) )
153
- $list = $nggdb->find_last_images(0, $this->limit, false);
154
- else
155
- $list = $nggdb->search_for_images($this->term, $this->limit);
156
-
157
- if( is_array($list) ) {
158
- foreach($list as $image) {
159
- // reorder result to array-object
160
- $obj = new stdClass();
161
- $obj->id = $image->pid;
162
- $name = ( empty($image->alttext) ? $image->filename : $image->alttext );
163
- //TODO : need to rework save/load
164
- $name = stripslashes( htmlspecialchars_decode($name, ENT_QUOTES));
165
- $obj->label = $image->pid . ' - ' . $name;
166
- $obj->value = $name;
167
- $this->result[] = $obj;
168
- }
169
- }
170
-
171
- return $this->result;
172
- break;
173
- case 'gallery' :
174
-
175
- if ( empty($this->term) )
176
- $list = $nggdb->find_all_galleries('gid', 'DESC', false, $this->limit );
177
- else
178
- $list = $nggdb->search_for_galleries($this->term, $this->limit);
179
-
180
- if( is_array($list) ) {
181
- foreach($list as $gallery) {
182
- // reorder result to array-object
183
- $obj = new stdClass();
184
- $obj->id = $gallery->gid;
185
- $name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
186
- $name = stripslashes( htmlspecialchars_decode($name, ENT_QUOTES));
187
- $obj->label = $gallery->gid . ' - ' . $name;
188
- $obj->value = $name;
189
- $this->result[] = $obj;
190
- }
191
- }
192
- return $this->result;
193
- break;
194
- case 'album' :
195
-
196
- if ( empty($this->term) )
197
- $list = $nggdb->find_all_album('id', 'DESC', $this->limit );
198
- else
199
- $list = $nggdb->search_for_albums($this->term, $this->limit);
200
-
201
- if( is_array($list) ) {
202
- foreach($list as $album) {
203
- // reorder result to array-object
204
- $obj = new stdClass();
205
- $obj->id = $album->id;
206
- $album->name = stripslashes( htmlspecialchars_decode($album->name, ENT_QUOTES));
207
- $obj->label = $album->id . ' - ' . $album->name;
208
- $obj->value = $album->name;
209
- $this->result[] = $obj;
210
- }
211
- }
212
- return $this->result;
213
- break;
214
- default :
215
- $this->result = array ('stat' => 'fail', 'code' => '98', 'message' => 'Type not known.');
216
- return false;
217
- break;
218
- }
219
- }
220
-
221
- /**
222
- * Iterates through a multidimensional array
223
- *
224
- * @author Boris Glumpler
225
- * @param array $arr
226
- * @return void
227
- */
228
- function create_xml_array( &$arr )
229
- {
230
- $xml = '';
231
-
232
- if( is_object( $arr ) )
233
- $arr = get_object_vars( $arr );
234
-
235
- foreach( (array)$arr as $k => $v ) {
236
- if( is_object( $v ) )
237
- $v = get_object_vars( $v );
238
- //nodes must contain letters
239
- if( is_numeric( $k ) )
240
- $k = 'id-'.$k;
241
- if( is_array( $v ) )
242
- $xml .= "<$k>\n". $this->create_xml_array( $v ). "</$k>\n";
243
- else
244
- $xml .= "<$k>$v</$k>\n";
245
- }
246
-
247
- return $xml;
248
- }
249
-
250
- function render_output() {
251
-
252
- if ($this->format == 'json') {
253
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
254
- $this->output = json_encode($this->result);
255
- } else {
256
- header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
257
- $this->output = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n";
258
- $this->output .= "<nextgen-gallery>" . $this->create_xml_array( $this->result ) . "</nextgen-gallery>\n";
259
- }
260
-
261
- }
262
-
263
- /**
264
- * PHP5 style destructor and will run when the class is finished.
265
- *
266
- * @return output
267
- */
268
- function __destruct() {
269
- echo $this->output;
270
- }
271
-
272
- }
273
-
274
- // let's use it
275
- $nggAPI = new nggAPI;
1
+ <?php
2
+ /**
3
+ * REST Application Programming Interface PHP class for the WordPress plugin NextGEN Gallery
4
+ * Should emulate some kind of Flickr JSON callback : ?callback=json&format=json&api_key=1234567890&method=search&term=myterm
5
+ *
6
+ * @version 1.1.0
7
+ * @author Alex Rabe
8
+ *
9
+ * @require PHP 5.2.0 or higher
10
+ *
11
+ */
12
+
13
+ class nggAPI {
14
+
15
+ /**
16
+ * $_GET Variables
17
+ *
18
+ * @since 1.5.0
19
+ * @access private
20
+ * @var string
21
+ */
22
+ var $format = false; // $_GET['format'] : Return a XML oder JSON output
23
+ var $api_key = false; // $_GET['api_key'] : Protect the access via a random key (required if user is not logged into backend)
24
+ var $method = false; // $_GET['method'] : search | gallery | image | album | tag | autocomplete
25
+ var $term = false; // $_GET['term'] : The search term (required for method search | tag)
26
+ var $id = false; // $_GET['id'] : object id (required for method gallery | image | album )
27
+ var $limit = false; // $_GET['limit'] : maximum of images which we request
28
+ var $type = false; // $_GET['type'] : gallery | image | album (required for method autocomplete)
29
+
30
+ /**
31
+ * Contain the final output
32
+ *
33
+ * @since 1.5.0
34
+ * @access private
35
+ * @var string
36
+ */
37
+ var $output = '';
38
+
39
+ /**
40
+ * Holds the requested information as array
41
+ *
42
+ * @since 1.5.0
43
+ * @access private
44
+ * @var array
45
+ */
46
+ var $result = '';
47
+
48
+ /**
49
+ * Init the variables
50
+ *
51
+ */
52
+ function __construct() {
53
+
54
+ if ( !defined('ABSPATH') )
55
+ die('You are not allowed to call this page directly.');
56
+
57
+ if ( !function_exists('json_encode') )
58
+ wp_die('Json_encode not available. You need to use PHP 5.2');
59
+
60
+ // Read the parameter on init
61
+ $this->format = isset($_GET['format']) ? strtolower( $_GET['format'] ) : false;
62
+ $this->api_key = isset($_GET['api_key'])? $_GET['api_key'] : false;
63
+ $this->method = isset($_GET['method']) ? strtolower( $_GET['method'] ) : false;
64
+ $this->term = isset($_GET['term']) ? urldecode( $_GET['term'] ) : false;
65
+ $this->id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
66
+ $this->limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 0;
67
+ $this->type = isset($_GET['type']) ? strtolower( $_GET['type'] ) : false;
68
+ $this->result = array();
69
+ $this->list = false;
70
+
71
+ $this->start_process();
72
+ $this->render_output();
73
+ }
74
+
75
+ function start_process() {
76
+
77
+ global $ngg;
78
+
79
+ if ( !$this->valid_access() )
80
+ return;
81
+
82
+ switch ( $this->method ) {
83
+ case 'search' :
84
+ //search for some images
85
+ $this->result['images'] = array_merge( (array) nggdb::search_for_images( $this->term ), (array) nggTags::find_images_for_tags( $this->term , 'ASC' ));
86
+ break;
87
+ case 'album' :
88
+ //search for some album //TODO : Get images for each gallery, could end in a big db query
89
+ $this->result['album'] = nggdb::find_album( $this->id );
90
+ break;
91
+ case 'gallery' :
92
+ //search for some gallery
93
+ $this->result['images'] = ($this->id == 0) ? nggdb::find_last_images( 0 , 100 ) : nggdb::get_gallery( $this->id, $ngg->options['galSort'], $ngg->options['galSortDir'], true, 0, 0, true );
94
+ break;
95
+ case 'image' :
96
+ //search for some image
97
+ $this->result['images'] = nggdb::find_image( $this->id );
98
+ break;
99
+ case 'tag' :
100
+ //search for images based on tags
101
+ $this->result['images'] = nggTags::find_images_for_tags( $this->term , 'ASC' );
102
+ break;
103
+ case 'recent' :
104
+ //search for images based on tags
105
+ $this->result['images'] = nggdb::find_last_images( 0 , $this->limit );
106
+ break;
107
+ case 'autocomplete' :
108
+ //return images, galleries or albums for autocomplete drop down list
109
+ return $this->autocomplete();
110
+ break;
111
+ case 'version' :
112
+ $this->result = array ('stat' => 'ok', 'version' => $ngg->version);
113
+ return;
114
+ break;
115
+ default :
116
+ $this->result = array ('stat' => 'fail', 'code' => '98', 'message' => 'Method not known.');
117
+ return false;
118
+ break;
119
+ }
120
+
121
+ // result should be fine
122
+ $this->result['stat'] = 'ok';
123
+ }
124
+
125
+ function valid_access() {
126
+
127
+ // if we are logged in, then we can go on
128
+ if ( is_user_logged_in() )
129
+ return true;
130
+
131
+ //TODO:Implement an API KEY check later
132
+ if ($this->api_key != false)
133
+ return true;
134
+
135
+ $this->result = array ('stat' => 'fail', 'code' => '99', 'message' => 'Insufficient permissions. Method requires read privileges; none granted.');
136
+ return false;
137
+ }
138
+
139
+ /**
140
+ * return search result for autocomplete request from backend
141
+ *
142
+ * @since 1.7.0
143
+ * @return void
144
+ */
145
+ function autocomplete() {
146
+ global $nggdb;
147
+
148
+ switch ( $this->type ) {
149
+ case 'image' :
150
+
151
+ // return the last entries in case of an empty search string
152
+ if ( empty($this->term) )
153
+ $list = $nggdb->find_last_images(0, $this->limit, false);
154
+ else
155
+ $list = $nggdb->search_for_images($this->term, $this->limit);
156
+
157
+ if( is_array($list) ) {
158
+ foreach($list as $image) {
159
+ // reorder result to array-object
160
+ $obj = new stdClass();
161
+ $obj->id = $image->pid;
162
+ $name = ( empty($image->alttext) ? $image->filename : $image->alttext );
163
+ //TODO : need to rework save/load
164
+ $name = stripslashes( htmlspecialchars_decode($name, ENT_QUOTES));
165
+ $obj->label = $image->pid . ' - ' . $name;
166
+ $obj->value = $name;
167
+ $this->result[] = $obj;
168
+ }
169
+ }
170
+
171
+ return $this->result;
172
+ break;
173
+ case 'gallery' :
174
+
175
+ if ( empty($this->term) )
176
+ $list = $nggdb->find_all_galleries('gid', 'DESC', false, $this->limit );
177
+ else
178
+ $list = $nggdb->search_for_galleries($this->term, $this->limit);
179
+
180
+ if( is_array($list) ) {
181
+ foreach($list as $gallery) {
182
+ // reorder result to array-object
183
+ $obj = new stdClass();
184
+ $obj->id = $gallery->gid;
185
+ $name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
186
+ $name = stripslashes( htmlspecialchars_decode($name, ENT_QUOTES));
187
+ $obj->label = $gallery->gid . ' - ' . $name;
188
+ $obj->value = $name;
189
+ $this->result[] = $obj;
190
+ }
191
+ }
192
+ return $this->result;
193
+ break;
194
+ case 'album' :
195
+
196
+ if ( empty($this->term) )
197
+ $list = $nggdb->find_all_album('id', 'DESC', $this->limit );
198
+ else
199
+ $list = $nggdb->search_for_albums($this->term, $this->limit);
200
+
201
+ if( is_array($list) ) {
202
+ foreach($list as $album) {
203
+ // reorder result to array-object
204
+ $obj = new stdClass();
205
+ $obj->id = $album->id;
206
+ $album->name = stripslashes( htmlspecialchars_decode($album->name, ENT_QUOTES));
207
+ $obj->label = $album->id . ' - ' . $album->name;
208
+ $obj->value = $album->name;
209
+ $this->result[] = $obj;
210
+ }
211
+ }
212
+ return $this->result;
213
+ break;
214
+ default :
215
+ $this->result = array ('stat' => 'fail', 'code' => '98', 'message' => 'Type not known.');
216
+ return false;
217
+ break;
218
+ }
219
+ }
220
+
221
+ /**
222
+ * Iterates through a multidimensional array
223
+ *
224
+ * @author Boris Glumpler
225
+ * @param array $arr
226
+ * @return void
227
+ */
228
+ function create_xml_array( &$arr )
229
+ {
230
+ $xml = '';
231
+
232
+ if( is_object( $arr ) )
233
+ $arr = get_object_vars( $arr );
234
+
235
+ foreach( (array)$arr as $k => $v ) {
236
+ if( is_object( $v ) )
237
+ $v = get_object_vars( $v );
238
+ //nodes must contain letters
239
+ if( is_numeric( $k ) )
240
+ $k = 'id-'.$k;
241
+ if( is_array( $v ) )
242
+ $xml .= "<$k>\n". $this->create_xml_array( $v ). "</$k>\n";
243
+ else
244
+ $xml .= "<$k>$v</$k>\n";
245
+ }
246
+
247
+ return $xml;
248
+ }
249
+
250
+ function render_output() {
251
+
252
+ if ($this->format == 'json') {
253
+ header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
254
+ $this->output = json_encode($this->result);
255
+ } else {
256
+ header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
257
+ $this->output = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n";
258
+ $this->output .= "<nextgen-gallery>" . $this->create_xml_array( $this->result ) . "</nextgen-gallery>\n";
259
+ }
260
+
261
+ }
262
+
263
+ /**
264
+ * PHP5 style destructor and will run when the class is finished.
265
+ *
266
+ * @return output
267
+ */
268
+ function __destruct() {
269
+ echo $this->output;
270
+ }
271
+
272
+ }
273
+
274
+ // let's use it
275
+ $nggAPI = new nggAPI;