NextCellent Gallery – NextGEN Legacy - Version 1.9.17

Version Description

  • 17.03.2014 =

What's in it for you?

  • Fixes to layout and more (credits to Niko Strijbol)
  • Added ability to change image upload + Ajax (credits to Richard Bale)
  • Russian translation (credits to Vladimir Vasilenko)
  • Finnish translation (credits to Vesa Tiirikainen)
  • Album and gallery template extension (currently in revision, credits to Stefano Sudati)
  • Improved nggtags shortcode implementing Tony Howden's suggestions (see http://howden.net.au/thowden/2012/12/nextgen-gallery-wordpress-nggtags-template-caption-option/) added modes ASC,DESC and RAND

VERY IMPORTANT: Read ON!

NextCellent Gallery provides backward compatibility for older NextGEN until version 1.9.13 .

  • this plugin will gracefully deactivate if detects NextGEN is working (any version) to avoid compatibility issues.

  • Please remember to READ THE FAQ!!! Issues for failing to read the FAQ will be IGNORED!!!

  • If you like it, please spread the word and rate it accordingly. I guess a lot of annoyed users can take advantage of NextCellent. Thank you!

Download this release

Release Info

Developer WPReady
Plugin Icon NextCellent Gallery – NextGEN Legacy
Version 1.9.17
Comparing to
See all releases

Code changes from version 1.9.15 to 1.9.17

Files changed (69) hide show
  1. admin/about.php +58 -178
  2. admin/addgallery.php +536 -537
  3. admin/admin.php +558 -576
  4. admin/ajax.php +433 -433
  5. admin/album.php +585 -588
  6. admin/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  7. admin/css/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  8. admin/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  9. admin/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  10. admin/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  11. admin/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  12. admin/css/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  13. admin/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  14. admin/css/images/ui-icons_2e83ff_256x240.png +0 -0
  15. admin/css/images/ui-icons_454545_256x240.png +0 -0
  16. admin/css/images/ui-icons_888888_256x240.png +0 -0
  17. admin/css/images/ui-icons_cd0a0a_256x240.png +0 -0
  18. admin/css/jquery.ui.css +141 -140
  19. admin/css/jquery.ui.datepicker.css +66 -0
  20. admin/css/jquery.ui.tabs.css +64 -158
  21. admin/css/ngg_social_media.css +33 -32
  22. admin/css/nggadmin.css +84 -29
  23. admin/edit-thumbnail.php +165 -170
  24. admin/functions.php +1501 -1501
  25. admin/install.php +281 -281
  26. admin/js/Jcrop/css/jquery.Jcrop.css +35 -35
  27. admin/js/Jcrop/js/jquery.Jcrop.js +1197 -1197
  28. admin/js/jquery.MultiFile.js +535 -535
  29. admin/js/jquery.MultiFile.pack.js +10 -10
  30. admin/js/jquery.ui.autocomplete.js +612 -612
  31. admin/js/jquery.ui.autocomplete.min.js +31 -31
  32. admin/js/jqueryFileTree/jqueryFileTree.css +1 -1
  33. admin/js/jqueryFileTree/jqueryFileTree.js +97 -97
  34. admin/js/ngg.ajax.js +118 -118
  35. admin/js/ngg.progressbar.js +96 -96
  36. admin/js/ngg_social_media.js +7 -7
  37. admin/js/swfupload.handler.js +153 -153
  38. admin/manage-galleries.php +428 -426
  39. admin/manage-images.php +744 -715
  40. admin/manage-sort.php +122 -122
  41. admin/manage.php +658 -657
  42. admin/media-upload.php +282 -282
  43. admin/overview.php +849 -866
  44. admin/roles.php +138 -139
  45. admin/rotate.php +92 -93
  46. admin/settings.php +914 -929
  47. admin/setup.php +58 -58
  48. admin/showmeta.php +122 -123
  49. admin/style.php +250 -251
  50. admin/tags.php +289 -291
  51. admin/templates/facebook_like_button.php +2 -2
  52. admin/templates/social_media_buttons.php +5 -5
  53. admin/templates/twitter_follow_link.php +7 -7
  54. admin/tinymce/editor_plugin.js +77 -77
  55. admin/tinymce/langs/de.js +6 -6
  56. admin/tinymce/langs/de_de.js +6 -6
  57. admin/tinymce/langs/en.js +6 -6
  58. admin/tinymce/langs/en_US.js +6 -6
  59. admin/tinymce/tinymce.js +75 -75
  60. admin/tinymce/tinymce.php +102 -102
  61. admin/tinymce/window.php +151 -151
  62. admin/upload.php +48 -48
  63. admin/wpmu.php +117 -117
  64. changelog.txt +5 -5
  65. css/Black_Minimalism.css +374 -374
  66. css/hovereffect.css +424 -424
  67. css/ngg_dkret3.css +318 -318
  68. css/ngg_k2.css +330 -330
  69. css/ngg_shadow.css +0 -7
admin/about.php CHANGED
@@ -1,178 +1,58 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- function nggallery_admin_about() {
5
-
6
- ?>
7
-
8
- <div class="wrap">
9
- <?php include('templates/social_media_buttons.php'); ?>
10
- <?php screen_icon( 'nextgen-gallery' ); ?>
11
- <h2><?php _e('Copyright notes / Credits', 'nggallery') ;?></h2>
12
- <div id="poststuff">
13
-
14
- <div class="postbox">
15
- <h3 class="hndle"><span><?php _e('Contributors / Tribute to', 'nggallery'); ?></span></h3>
16
- <div class="inside">
17
- <p><?php _e('If you study the code of this plugin, you\'ll find we\'ve included a lot of good, existing code and ideas. We\'d like to thank the following people for their work:', 'nggallery') ;?></p>
18
- <ul class="ngg-list">
19
- <li><a href="http://wordpress.org" target="_blank">The WordPress Team</a> <?php _e('for their great documented code', 'nggallery') ;?></li>
20
- <li><a href="http://jquery.com" target="_blank">The jQuery Team</a> <?php _e('for jQuery, which is the best Web2.0 framework', 'nggallery') ;?></li>
21
- <li><a href="http://www.gen-x-design.com" target="_blank">Ian Selby</a> <?php _e('for the fantastic PHP Thumbnail Class', 'nggallery') ;?></li>
22
- <li><a href="http://www.lesterchan.net/" target="_blank">GaMerZ</a> <?php _e('for a lot of very useful plugins and ideas', 'nggallery') ;?></li>
23
- <li><a href="http://www.laptoptips.ca/" target="_blank">Andrew Ozz</a> <?php _e('for Shutter Reloaded, a real lightweight image effect', 'nggallery') ;?></li>
24
- <li><a href="http://www.jeroenwijering.com/" target="_blank">Jeroen Wijering</a> <?php _e('for the best Media Flash Scripts on earth', 'nggallery') ;?></li>
25
- <li><a href="http://field2.com" target="_blank">Ben Dunkle</a> <?php _e('for the Gallery Icon', 'nggallery') ;?></li>
26
- <li><a href="http://watermark.malcherek.com/" target="_blank">Marek Malcherek</a> <?php _e('for the Watermark plugin', 'nggallery') ;?></li>
27
- </ul>
28
- <p><?php _e('If you don\'t see your name on this list and we\'ve integrated some of your code into the plugin, don\'t hesitate to email me.', 'nggallery') ;?></p>
29
- </div>
30
- </div>
31
- <div class="postbox">
32
- <h3 class="hndle"><span><?php _e('NextCellent', 'nggallery'); ?></span></h3>
33
- <div class="inside">
34
- <p><?php _e('NextCellent Gallery is based on code originally thanks to Alex Rabe who maintained it through 2011. Special thanks to Photocrati Media which followed the work.', 'nggallery') ;?></p>
35
- <p><?php ngg_list_contributors(); ?></p>
36
- </div>
37
- </div>
38
- <div class="postbox">
39
- <h3 class="hndle"><span><?php _e('How to support ?', 'nggallery'); ?></span></h3>
40
- <div class="inside">
41
- <p><?php _e('There are several ways to contribute:', 'nggallery') ;?></p>
42
- <ul class="ngg-list">
43
- <li><strong><?php _e('Send us bugfixes / code changes', 'nggallery') ;?></strong><br /><?php _e('The most motivated support for this plugin are your ideas and brain work.', 'nggallery') ;?></li>
44
- <li><strong><?php _e('Translate the plugin', 'nggallery') ;?></strong><br /><?php _e('To help people to work with this plugin, we would like to have it in all available languages.', 'nggallery') ;?></li>
45
- <li><strong><?php _e('Place a link to the plugin in your blog/webpage', 'nggallery') ;?></strong><br /><?php _e('Yes, sharing and linking are also supportive and helpful.', 'nggallery') ;?></li>
46
- </ul>
47
- </div>
48
- </div>
49
-
50
- </div>
51
- </div>
52
-
53
- <?php
54
- }
55
-
56
- /*
57
- 20131004: Disabled by Photocrati. There is no more ngg_list_support
58
- <div class="postbox" id="donators">
59
- <h3 class="hndle"><span><?php _e('Thanks!', 'nggallery'); ?></span></h3>
60
- <div class="inside">
61
- <p><?php _e('We would like to thank the following people who have supported the NextGEN Gallery plugin:', 'nggallery'); ?></p>
62
- <p><a href="http://www.boelinger.com/heike/" target="_blank">HEIKE</a>, < ? php ngg_list_support(); ? ></p>
63
- </div>
64
- </div>
65
-
66
- */
67
-
68
- function ngg_list_contributors() {
69
- /* The list of my contributors. Thanks to all of them !*/
70
-
71
- $contributors = array(
72
- 'Anty (Code contributor)' => 'http://www.anty.at/',
73
- 'Bjoern von Prollius (Code contributor)' => 'http://www.prollius.de/',
74
- 'Simone Fumagalli (Code contributor)' => 'http://www.iliveinperego.com/',
75
- 'Vincent Prat (Code contributor)' => 'http://www.vincentprat.info',
76
- 'Frederic De Ranter (AJAX code contributor)' => 'http://li.deranter.com/',
77
- 'Christian Arnold (Code contributor)' => 'http://blog.arctic-media.de/',
78
- 'Thomas Matzke (Album code contributor)' => 'http://mufuschnu.mu.funpic.de/',
79
- 'KeViN (Sidebar Widget developer)' => 'http://www.kev.hu/',
80
- 'Lazy (German Translation)' => 'http://www.lazychris.de/',
81
- 'Lise (French Translation)' => 'http://liseweb.fr/',
82
- 'Anja (Dutch Translation)' => 'http://www.werkgroepen.net/wordpress',
83
- 'Adrian (Indonesian Translation)' => 'http://adrian.web.id/',
84
- 'Gaspard Tseng / SillyCCSmile (Chinese Translation)' => '',
85
- 'Mika Pennanen (Finnish Translation)' => 'http://kapsi.fi/~penni',
86
- 'Wojciech Owczarek (Polish Translation)' => 'http://www.owczi.net',
87
- 'Dilip Ramirez (Spanish Translation)' => 'http://jmtd.110mb.com/blog',
88
- 'Oleinikov Vedmak Evgeny (Russian Translation)' => 'http://ka-2-03.mirea.org/',
89
- 'Sebastien MALHERBE (Logo design)' => 'http://www.7vision.com/',
90
- 'Claudia (German documentation)' => 'http://www.blog-werkstatt.de/',
91
- 'Robert (German documentation)' => 'http://www.curlyrob.de/',
92
- 'Pierpaolo Mannone (Italian Translation)' => 'http://www.interscambiocasa.com/',
93
- 'Mattias Tengblad (Swedish Translation)' => 'http://wp-support.se/',
94
- 'M&uuml;fit Kiper (Swedish Translation)' => 'http://www.kiper.se/',
95
- 'Gil Yaker (Documentation)' => 'http://bamboosoup.com/',
96
- 'Morten Johansen (Danish Translation)' => 'http://www.fr3ak.dk/',
97
- 'Vidar Seland (Norwegian Translation)' => 'http://www.viidar.net/',
98
- 'Emre G&uuml;ler (Turkish Translation)' => 'http://www.emreguler.com/',
99
- 'Emilio Lauretti (Italian Translation)' => '',
100
- 'Jan Angelovic (Czech Translation)' => 'http://www.angelovic.cz/',
101
- 'Laki (Slovak Translation)' => 'http://www.laki.sk/',
102
- 'Rowan Crane (WPMU support)' => 'http://blog.rowancrane.com/',
103
- 'Kuba Zwolinski (Polish Translation)' => 'http://kubazwolinski.com/',
104
- 'Rina Jiang (Chinese Translation)' => 'http://http://mysticecho.net/',
105
- 'Anthony (Chinese Translation)' => 'http://www.angryouth.com/',
106
- 'Milan Vasicek (Czech Translation)' => 'http://www.NoWorkTeam.cz/',
107
- 'Joo Gi-young (Korean Translation)' => 'http://lombric.linuxstudy.pe.kr/wp/',
108
- 'Oleg A. Safonov (Russian Translation)' => 'http://blog.olart.ru',
109
- 'AleXander Kirichev (Bulgarian Translation)' => 'http://xsakex.art-bg.org/',
110
- 'Richer Yang (Chinese Translation)' => 'http://fantasyworld.idv.tw/',
111
- 'Bill Jones (Forums contributor)' => 'http://jonesphoto.bluehorizoninternet.com/',
112
- 'TheDonSansone (Forums contributor)' => 'http://abseiling.200blogs.co.uk/',
113
- 'Komyshov (Russian Translation)' => 'http://kf-web.ru/',
114
- 'aleX Zhang (Chinese Translation)' => 'http://zhangfei.info/',
115
- 'TheSoloist (Chinese Translation)' => 'http://www.soloist-ic.cn/',
116
- 'Nica Luigi Cristian (Romanian Translation)' => 'http://www.cristiannica.com/',
117
- 'Zdenek Hatas (Czech Translation)' => '',
118
- 'David Potter (Documentation and Help)' => 'http://dpotter.net/',
119
- 'Carlale Chen (Chinese Translation)' => 'http://0-o-0.cc/',
120
- 'Nica Luigi Cristian (Romanian Translation)' => 'http://www.cristiannica.com/',
121
- 'Igor Shevkoplyas (Russian Translation)' => 'http://www.russian-translation-matters.com',
122
- 'Alexandr Kindras (Code contributor)' => 'http://www.fixdev.com',
123
- 'Manabu Togawa (Japanese Translation)' => 'http://www.churadesign.com/',
124
- 'Serhiy Tretyak (Ukrainian Translation)' => 'http://designpoint.com.ua/',
125
- 'Janis Grinvalds (Latvian Translation)' => 'http://riga.bmxrace.lv/',
126
- 'Kristoffer Th&oslash;ring (Norwegian Translation)' => '',
127
- 'Flactarus (Italian Translation)' => 'http://www.giroevago.it',
128
- 'Felip Alfred Galit&oacute; i Trilla (Catalan Translation)' => 'http://www.bratac.cat',
129
- 'Luka Komac (Slovenian Translation)' => 'http://www.komac.biz',
130
- 'Dimitris Ikonomou / Nikos Mouratidis (Greek Translation)' => 'http://www.kepik.gr'
131
- );
132
-
133
- ksort($contributors);
134
- $i = count($contributors);
135
- foreach ($contributors as $name => $url)
136
- {
137
- if ($url)
138
- echo "<a href=\"$url\" target=\"_blank\">$name</a>";
139
- else
140
- echo $name;
141
- $i--;
142
- if ($i == 1)
143
- echo " & ";
144
- elseif ($i)
145
- echo ", ";
146
- }
147
- }
148
-
149
- /**
150
- * 20131004: Deprecated since this list dissapear.
151
- */
152
- function ngg_list_support() {
153
- /* The list of my supporters. Thanks to all of them !*/
154
-
155
- global $ngg;
156
-
157
- $supporter = nggAdminPanel::get_remote_array($ngg->donators);
158
-
159
- // Ensure that this is a array
160
- if ( !is_array($supporter) )
161
- return _e('and all donators...', 'nggallery');
162
-
163
- ksort($supporter);
164
- $i = count($supporter);
165
- foreach ($supporter as $name => $url)
166
- {
167
- if ($url)
168
- echo "<a href=\"$url\" target=\"_blank\">$name</a>";
169
- else
170
- echo $name;
171
- $i--;
172
- if ($i == 1)
173
- echo " & ";
174
- elseif ($i)
175
- echo ", ";
176
- }
177
- }
178
- ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ function nggallery_admin_about() {
5
+
6
+ ?>
7
+ <div class="wrap">
8
+ <?php screen_icon( 'nextgen-gallery' ); ?>
9
+ <h2><?php _e('About', 'nggallery') ;?></h2>
10
+ <div id="poststuff">
11
+ <div class="postbox">
12
+ <h3 class="hndle"><span><?php _e('Contributors', 'nggallery'); ?></span></h3>
13
+ <div class="inside">
14
+ <p><?php _e('This plugin is made possible by the great work of a lot of people. A special thanks the following people:', 'nggallery') ;?></p>
15
+ <ul class="ngg-list">
16
+ <li><a href="http://wordpress.org" target="_blank">The WordPress Team</a> <?php _e('for their great documented code', 'nggallery') ;?></li>
17
+ <li><a href="http://jquery.com" target="_blank">The jQuery Team</a> <?php _e('for jQuery, which is the best Web2.0 framework', 'nggallery') ;?></li>
18
+ <li><a href="http://www.gen-x-design.com" target="_blank">Ian Selby</a> <?php _e('for the fantastic PHP Thumbnail Class', 'nggallery') ;?></li>
19
+ <li><a href="http://www.lesterchan.net/" target="_blank">GaMerZ</a> <?php _e('for a lot of very useful plugins and ideas', 'nggallery') ;?></li>
20
+ <li><a href="http://www.laptoptips.ca/" target="_blank">Andrew Ozz</a> <?php _e('for Shutter Reloaded, a real lightweight image effect', 'nggallery') ;?></li>
21
+ <li><a href="http://www.jeroenwijering.com/" target="_blank">Jeroen Wijering</a> <?php _e('for the best Media Flash Scripts on earth', 'nggallery') ;?></li>
22
+ <li><a href="http://field2.com" target="_blank">Ben Dunkle</a> <?php _e('for the Gallery Icon', 'nggallery') ;?></li>
23
+ <li><a href="http://watermark.malcherek.com/" target="_blank">Marek Malcherek</a> <?php _e('for the Watermark plugin', 'nggallery') ;?></li>
24
+ <li><a href="http://wpgetready.com/" target="_blank">WPGetReady</a> <?php _e('for maintaining this fork of NextGen Gallery', 'nggallery') ;?></li>
25
+ <li><?php _e('The original translators for NextGen Gallery, who made the translations', 'nggallery') ;?></li>
26
+ </ul>
27
+ </div>
28
+ </div>
29
+ <div class="postbox">
30
+ <h3 class="hndle"><span><?php _e('NextCellent', 'nggallery'); ?></span></h3>
31
+ <div class="inside">
32
+ <p><?php _e('NextCellent Gallery is based on the 1.9.13 version of the NextGen Gallery by Photocrati Media, which is the succesor to the work by Alex Rabe.', 'nggallery') ;?></p>
33
+ <h4><?php _e('What do you get with NextCellent Gallery?', 'nggallery') ;?></h4>
34
+ <ul class="ngg-list">
35
+ <li><?php _e('Backward compatibility with NextGEN plugin version (1.9.13)', 'nggallery') ;?></li>
36
+ <li><?php _e('Slow evolving code path, made only by NextGEN user\'s suggestions. Yep, you read it right: slow in counterpart as fast. Older code is good enough to keep a community and it worked (and works) for most people.', 'nggallery') ;?></li>
37
+ <li><?php _e('A reliable way to work with already installed NextGEN galleries.', 'nggallery') ;?></li>
38
+ <li><?php _e('A place for updating the plugin without using FTP manual updates, but WordPress plugin repository.', 'nggallery') ;?></li>
39
+ <li><?php _e('Alternative path preserving backward compatibility (while possible).', 'nggallery') ;?></li>
40
+ </li>
41
+ </ul>
42
+ </div>
43
+ </div>
44
+ <div class="postbox">
45
+ <h3 class="hndle"><span><?php _e('How to support us?', 'nggallery'); ?></span></h3>
46
+ <div class="inside">
47
+ <p><?php _e('There are several ways to contribute:', 'nggallery') ;?></p>
48
+ <ul class="ngg-list">
49
+ <li><strong><?php _e('Send us bugfixes / code changes', 'nggallery') ;?></strong><br /><?php _e('The most motivated support for this plugin are your ideas and brain work.', 'nggallery') ;?></li>
50
+ <li><strong><?php _e('Translate the plugin', 'nggallery') ;?></strong><br /><?php _e('To help people to work with this plugin, we would like to have it in all available languages.', 'nggallery') ;?></li>
51
+ <li><strong><?php _e('Place a link to the plugin in your blog/webpage', 'nggallery') ;?></strong><br /><?php _e('Yes, sharing and linking are also supportive and helpful.', 'nggallery') ;?></li>
52
+ </ul>
53
+ </div>
54
+ </div>
55
+
56
+ </div>
57
+ </div>
58
+ <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/addgallery.php CHANGED
@@ -1,537 +1,536 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- class nggAddGallery {
5
-
6
- /**
7
- * nggAddGallery::__construct()
8
- *
9
- * @return void
10
- */
11
- function __construct() {
12
-
13
- // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
14
- $this->filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
15
-
16
- //Look for POST updates
17
- if ( !empty($_POST) )
18
- $this->processor();
19
- }
20
-
21
- /**
22
- * Perform the upload and add a new hook for plugins
23
- *
24
- * @return void
25
- */
26
- function processor() {
27
- global $wpdb, $ngg, $nggdb;
28
-
29
- $defaultpath = $ngg->options['gallerypath'];
30
-
31
- if ( isset($_POST['addgallery']) ){
32
- check_admin_referer('ngg_addgallery');
33
-
34
- if ( !nggGallery::current_user_can( 'NextGEN Add new gallery' ))
35
- wp_die(__('Cheatin&#8217; uh?'));
36
-
37
- $newgallery = esc_attr( $_POST['galleryname']);
38
- if ( !empty($newgallery) )
39
- nggAdmin::create_gallery($newgallery, $defaultpath);
40
- }
41
-
42
- if ( isset($_POST['zipupload']) ){
43
- check_admin_referer('ngg_addgallery');
44
-
45
- if ( !nggGallery::current_user_can( 'NextGEN Upload a zip' ))
46
- wp_die(__('Cheatin&#8217; uh?'));
47
-
48
- if ($_FILES['zipfile']['error'] == 0 || (!empty($_POST['zipurl'])))
49
- nggAdmin::import_zipfile( intval( $_POST['zipgalselect'] ) );
50
- else
51
- nggGallery::show_error( __('Upload failed!','nggallery') );
52
- }
53
-
54
- if ( isset($_POST['importfolder']) ){
55
- check_admin_referer('ngg_addgallery');
56
-
57
- if ( !nggGallery::current_user_can( 'NextGEN Import image folder' ))
58
- wp_die(__('Cheatin&#8217; uh?'));
59
-
60
- $galleryfolder = $_POST['galleryfolder'];
61
- if ( ( !empty($galleryfolder) ) AND ($defaultpath != $galleryfolder) )
62
- nggAdmin::import_gallery($galleryfolder);
63
- }
64
-
65
- if ( isset($_POST['uploadimage']) ){
66
- check_admin_referer('ngg_addgallery');
67
-
68
- if ( !nggGallery::current_user_can( 'NextGEN Upload in all galleries' ))
69
- wp_die(__('Cheatin&#8217; uh?'));
70
-
71
- if ( $_FILES['imagefiles']['error'][0] == 0 )
72
- $messagetext = nggAdmin::upload_images();
73
- else
74
- nggGallery::show_error( __('Upload failed! ' . nggAdmin::decode_upload_error( $_FILES['imagefiles']['error'][0]),'nggallery') );
75
- }
76
-
77
- if ( isset($_POST['swf_callback']) ){
78
- if ($_POST['galleryselect'] == '0' )
79
- nggGallery::show_error(__('No gallery selected !','nggallery'));
80
- else {
81
- if ($_POST['swf_callback'] == '-1' )
82
- nggGallery::show_error( __('Upload failed! ','nggallery') );
83
- else {
84
- $gallery = $nggdb->find_gallery( (int) $_POST['galleryselect'] );
85
- nggAdmin::import_gallery( $gallery->path );
86
- }
87
- }
88
- }
89
-
90
- if ( isset($_POST['disable_flash']) ){
91
- check_admin_referer('ngg_addgallery');
92
- $ngg->options['swfUpload'] = false;
93
- update_option('ngg_options', $ngg->options);
94
- }
95
-
96
- if ( isset($_POST['enable_flash']) ){
97
- check_admin_referer('ngg_addgallery');
98
- $ngg->options['swfUpload'] = true;
99
- update_option('ngg_options', $ngg->options);
100
- }
101
-
102
- do_action( 'ngg_update_addgallery_page' );
103
-
104
- }
105
-
106
- /**
107
- * Render the page content
108
- *
109
- * @return void
110
- */
111
- function controller() {
112
- global $ngg, $nggdb;
113
-
114
- // check for the max image size
115
- $this->maxsize = nggGallery::check_memory_limit();
116
-
117
- //get all galleries (after we added new ones)
118
- $this->gallerylist = $nggdb->find_all_galleries('gid', 'DESC');
119
-
120
- $this->defaultpath = $ngg->options['gallerypath'];
121
-
122
- // link for the flash file
123
- $swf_upload_link = admin_url('/?nggupload');
124
-
125
- // get list of tabs
126
- $tabs = $this->tabs_order();
127
-
128
- // with this filter you can add custom file types
129
- $file_types = apply_filters( 'ngg_swf_file_types', '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG' );
130
-
131
- // Set the post params, which plupload will post back with the file, and pass them through a filter.
132
- $post_params = array(
133
- "auth_cookie" => (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]),
134
- "logged_in_cookie" => $_COOKIE[LOGGED_IN_COOKIE],
135
- "_wpnonce" => wp_create_nonce('ngg_swfupload'),
136
- "galleryselect" => "0",
137
- );
138
- $p = array();
139
-
140
- foreach ( $post_params as $param => $val ) {
141
- $val = esc_js( $val );
142
- $p[] = "'$param' : '$val'";
143
- }
144
-
145
- $post_params_str = implode( ',', $p ). "\n";
146
- ?>
147
-
148
- <?php include('templates/social_media_buttons.php'); ?>
149
-
150
- <?php if($ngg->options['swfUpload'] && !empty ($this->gallerylist) ) { ?>
151
- <?php if ( defined('IS_WP_3_3') ) { ?>
152
- <!-- plupload script -->
153
- <script type="text/javascript">
154
- //<![CDATA[
155
- var resize_height = <?php echo (int) $ngg->options['imgHeight']; ?>,
156
- resize_width = <?php echo (int) $ngg->options['imgWidth']; ?>;
157
-
158
- jQuery(document).ready(function($) {
159
- window.uploader = new plupload.Uploader({
160
- runtimes: '<?php echo apply_filters('plupload_runtimes', 'html5,flash,silverlight,html4,'); ?>',
161
- browse_button: 'plupload-browse-button',
162
- container: 'plupload-upload-ui',
163
- drop_element: 'uploadimage',
164
- file_data_name: 'Filedata',
165
- max_file_size: '<?php echo round( (int) wp_max_upload_size() / 1024 ); ?>kb',
166
- url: '<?php echo esc_js( $swf_upload_link ); ?>',
167
- flash_swf_url: '<?php echo esc_js( includes_url('js/plupload/plupload.flash.swf') ); ?>',
168
- silverlight_xap_url: '<?php echo esc_js( includes_url('js/plupload/plupload.silverlight.xap') ); ?>',
169
- filters: [
170
- {title: '<?php echo esc_js( __('Image Files', 'nggallery') ); ?>', extensions: '<?php echo esc_js( str_replace( array('*.', ';'), array('', ','), $file_types) ); ?>'}
171
- ],
172
- multipart: true,
173
- urlstream_upload: true,
174
- multipart_params : {
175
- <?php echo $post_params_str; ?>
176
- },
177
- debug: false,
178
- preinit : {
179
- Init: function(up, info) {
180
- debug('[Init]', 'Info :', info, 'Features :', up.features);
181
- if (navigator.appVersion.indexOf("MSIE 10") > -1) {
182
- up.features.triggerDialog = true;
183
- }
184
- initUploader();
185
- }
186
- },
187
- i18n : {
188
- 'remove' : '<?php _e('remove', 'nggallery') ;?>',
189
- 'browse' : '<?php _e('Browse...', 'nggallery') ;?>',
190
- 'upload' : '<?php _e('Upload images', 'nggallery') ;?>'
191
- }
192
- });
193
-
194
- uploader.bind('FilesAdded', function(up, files) {
195
- $.each(files, function(i, file) {
196
- fileQueued(file);
197
- });
198
-
199
- up.refresh();
200
- });
201
-
202
- uploader.bind('BeforeUpload', function(up, file) {
203
- uploadStart(file);
204
- });
205
-
206
- uploader.bind('UploadProgress', function(up, file) {
207
- uploadProgress(file, file.loaded, file.size);
208
- });
209
-
210
- uploader.bind('Error', function(up, err) {
211
- uploadError(err.file, err.code, err.message);
212
-
213
- up.refresh();
214
- });
215
-
216
- uploader.bind('FileUploaded', function(up, file, response) {
217
- uploadSuccess(file, response);
218
- });
219
-
220
- uploader.bind('UploadComplete', function(up, file) {
221
- uploadComplete(file);
222
- });
223
-
224
- // on load change the upload to plupload
225
- uploader.init();
226
-
227
- nggAjaxOptions = {
228
- header: "<?php _e('Upload images', 'nggallery') ;?>",
229
- maxStep: 100
230
- };
231
-
232
- });
233
- //]]>
234
- </script>
235
- <?php } else { ?>
236
- <!-- SWFUpload script -->
237
- <script type="text/javascript">
238
- var ngg_swf_upload;
239
-
240
- window.onload = function () {
241
- ngg_swf_upload = new SWFUpload({
242
- // Backend settings
243
- upload_url : "<?php echo esc_js( $swf_upload_link ); ?>",
244
- flash_url : "<?php echo esc_js( includes_url('js/swfupload/swfupload.swf') ); ?>",
245
-
246
- // Button Settings
247
- button_placeholder_id : "spanButtonPlaceholder",
248
- button_width: 300,
249
- button_height: 27,
250
- button_text_top_padding: 3,
251
- button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
252
- button_cursor: SWFUpload.CURSOR.HAND,
253
-
254
- // File Upload Settings
255
- file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
256
- file_types : "<?php echo $file_types; ?>",
257
- file_types_description : "<?php _e('Image Files', 'nggallery') ;?>",
258
-
259
- // Queue handler
260
- file_queued_handler : fileQueued,
261
-
262
- // Upload handler
263
- upload_start_handler : uploadStart,
264
- upload_progress_handler : uploadProgress,
265
- upload_error_handler : uploadError,
266
- upload_success_handler : uploadSuccess,
267
- upload_complete_handler : uploadComplete,
268
-
269
- post_params : {
270
- "auth_cookie" : "<?php echo (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]); ?>",
271
- "logged_in_cookie": "<?php echo $_COOKIE[LOGGED_IN_COOKIE]; ?>",
272
- "_wpnonce" : "<?php echo wp_create_nonce('ngg_swfupload'); ?>",
273
- "galleryselect" : "0"
274
- },
275
-
276
- // i18names
277
- custom_settings : {
278
- "remove" : "<?php _e('remove', 'nggallery') ;?>",
279
- "browse" : "<?php _e('Browse...', 'nggallery') ;?>",
280
- "upload" : "<?php _e('Upload images', 'nggallery') ;?>"
281
- },
282
-
283
- // Debug settings
284
- debug: false
285
-
286
- });
287
-
288
- // on load change the upload to swfupload
289
- initSWFUpload();
290
-
291
- nggAjaxOptions = {
292
- header: "<?php _e('Upload images', 'nggallery') ;?>",
293
- maxStep: 100
294
- };
295
-
296
- };
297
- </script>
298
- <?php } ?>
299
- <?php } else { ?>
300
- <!-- MultiFile script -->
301
- <script type="text/javascript">
302
- /* <![CDATA[ */
303
- jQuery(document).ready(function(){
304
- jQuery('#imagefiles').MultiFile({
305
- STRING: {
306
- remove:'[<?php _e('remove', 'nggallery') ;?>]'
307
- }
308
- });
309
- });
310
- /* ]]> */
311
- </script>
312
- <?php } ?>
313
- <!-- jQuery Tabs script -->
314
- <script type="text/javascript">
315
- /* <![CDATA[ */
316
- jQuery(document).ready(function(){
317
- jQuery('html,body').scrollTop(0);
318
- jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' });
319
- jQuery('#slider').css('display', 'block');
320
- });
321
-
322
- // File Tree implementation
323
- jQuery(function() {
324
- jQuery("span.browsefiles").show().click(function(){
325
- jQuery("#file_browser").fileTree({
326
- script: "admin-ajax.php?action=ngg_file_browser&nonce=<?php echo wp_create_nonce( 'ngg-ajax' ) ;?>",
327
- root: jQuery("#galleryfolder").val()
328
- }, function(folder) {
329
- jQuery("#galleryfolder").val( folder );
330
- });
331
- jQuery("#file_browser").show('slide');
332
- });
333
- });
334
- /* ]]> */
335
- </script>
336
- <div id="slider" class="wrap" style="display: none;">
337
- <ul id="tabs">
338
- <?php
339
- foreach($tabs as $tab_key => $tab_name) {
340
- echo "\n\t\t<li><a href='#$tab_key'>$tab_name</a></li>";
341
- }
342
- ?>
343
- </ul>
344
- <?php
345
- foreach($tabs as $tab_key => $tab_name) {
346
- echo "\n\t<div id='$tab_key'>\n";
347
- // Looks for the internal class function, otherwise enable a hook for plugins
348
- if ( method_exists( $this, "tab_$tab_key" ))
349
- call_user_func( array( &$this , "tab_$tab_key") );
350
- else
351
- do_action( 'ngg_tab_content_' . $tab_key );
352
- echo "\n\t</div>";
353
- }
354
- ?>
355
- </div>
356
- <?php
357
-
358
- }
359
-
360
- /**
361
- * Create array for tabs and add a filter for other plugins to inject more tabs
362
- *
363
- * @return array $tabs
364
- */
365
- function tabs_order() {
366
-
367
- $tabs = array();
368
-
369
- if ( !empty ($this->gallerylist) )
370
- $tabs['uploadimage'] = __( 'Upload Images', 'nggallery' );
371
-
372
- if ( nggGallery::current_user_can( 'NextGEN Add new gallery' ))
373
- $tabs['addgallery'] = __('Add new gallery', 'nggallery');
374
-
375
- if ( wpmu_enable_function('wpmuZipUpload') && nggGallery::current_user_can( 'NextGEN Upload a zip' ) )
376
- $tabs['zipupload'] = __('Upload a Zip-File', 'nggallery');
377
-
378
- if ( wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can( 'NextGEN Import image folder' ) )
379
- $tabs['importfolder'] = __('Import image folder', 'nggallery');
380
-
381
- $tabs = apply_filters('ngg_addgallery_tabs', $tabs);
382
-
383
- return $tabs;
384
-
385
- }
386
-
387
- function tab_addgallery() {
388
- ?>
389
- <!-- create gallery -->
390
- <h2><?php _e('Add new gallery', 'nggallery') ;?></h2>
391
- <form name="addgallery" id="addgallery_form" method="POST" action="<?php echo $this->filepath; ?>" accept-charset="utf-8" >
392
- <?php wp_nonce_field('ngg_addgallery') ?>
393
- <table class="form-table">
394
- <tr valign="top">
395
- <th scope="row"><?php _e('New Gallery', 'nggallery') ;?>:</th>
396
- <td><input type="text" size="35" name="galleryname" value="" /><br />
397
- <?php if(!is_multisite()) { ?>
398
- <?php _e('Create a new , empty gallery below the folder', 'nggallery') ;?> <strong><?php echo $this->defaultpath ?></strong><br />
399
- <?php } ?>
400
- <i>( <?php _e('Allowed characters for file and folder names are', 'nggallery') ;?>: a-z, A-Z, 0-9, -, _ )</i></td>
401
- </tr>
402
- <?php do_action('ngg_add_new_gallery_form'); ?>
403
- </table>
404
- <div class="submit"><input class="button-primary" type="submit" name= "addgallery" value="<?php _e('Add gallery', 'nggallery') ;?>"/></div>
405
- </form>
406
- <?php
407
- }
408
-
409
- function tab_zipupload() {
410
- ?>
411
- <!-- zip-file operation -->
412
- <h2><?php _e('Upload a Zip-File', 'nggallery') ;?></h2>
413
- <form name="zipupload" id="zipupload_form" method="POST" enctype="multipart/form-data" action="<?php echo $this->filepath.'#zipupload'; ?>" accept-charset="utf-8" >
414
- <?php wp_nonce_field('ngg_addgallery') ?>
415
- <table class="form-table">
416
- <tr valign="top">
417
- <th scope="row"><?php _e('Select Zip-File', 'nggallery') ;?>:</th>
418
- <td><input type="file" name="zipfile" id="zipfile" size="35" class="uploadform"/><br />
419
- <?php _e('Upload a zip file with images', 'nggallery') ;?></td>
420
- </tr>
421
- <?php if (function_exists('curl_init')) : ?>
422
- <tr valign="top">
423
- <th scope="row"><?php _e('or enter a Zip-File URL', 'nggallery') ;?>:</th>
424
- <td><input type="text" name="zipurl" id="zipurl" size="35" class="uploadform"/><br />
425
- <?php _e('Import a zip file with images from a url', 'nggallery') ;?></td>
426
- </tr>
427
- <?php endif; ?>
428
- <tr valign="top">
429
- <th scope="row"><?php _e('in to', 'nggallery') ;?></th>
430
- <td><select name="zipgalselect">
431
- <option value="0" ><?php _e('a new gallery', 'nggallery') ?></option>
432
- <?php
433
- foreach($this->gallerylist as $gallery) {
434
- if ( !nggAdmin::can_manage_this_gallery($gallery->author) )
435
- continue;
436
- $name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
437
- echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr( $name ). '</option>' . "\n";
438
- }
439
- ?>
440
- </select>
441
- <br /><?php echo $this->maxsize; ?>
442
- <br /><?php echo _e('Note : The upload limit on your server is ','nggallery') . "<strong>" . ini_get('upload_max_filesize') . "Byte</strong>\n"; ?>
443
- <br /><?php if ( (is_multisite()) && wpmu_enable_function('wpmuQuotaCheck') ) display_space_usage(); ?></td>
444
- </tr>
445
- </table>
446
- <div class="submit"><input class="button-primary" type="submit" name= "zipupload" value="<?php _e('Start upload', 'nggallery') ;?>"/></div>
447
- </form>
448
- <?php
449
- }
450
-
451
- function tab_importfolder() {
452
- ?>
453
- <!-- import folder -->
454
- <h2><?php _e('Import image folder', 'nggallery') ;?></h2>
455
- <form name="importfolder" id="importfolder_form" method="POST" action="<?php echo $this->filepath.'#importfolder'; ?>" accept-charset="utf-8" >
456
- <?php wp_nonce_field('ngg_addgallery') ?>
457
- <table class="form-table">
458
- <tr valign="top">
459
- <th scope="row"><?php _e('Import from Server path:', 'nggallery') ;?></th>
460
- <td><input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php echo $this->defaultpath; ?>" /><span class="browsefiles button" style="display:none"><?php _e('Browse...', 'nggallery'); ?></span><br />
461
- <div id="file_browser"></div>
462
- <br /><i>( <?php _e('Note : Change the default path in the gallery settings', 'nggallery') ;?> )</i>
463
- <br /><?php echo $this->maxsize; ?>
464
- <?php if (SAFE_MODE) {?><br /><?php _e(' Please note : For safe-mode = ON you need to add the subfolder thumbs manually', 'nggallery') ;?><?php }; ?></td>
465
- </tr>
466
- </table>
467
- <div class="submit"><input class="button-primary" type="submit" name= "importfolder" value="<?php _e('Import folder', 'nggallery') ;?>"/></div>
468
- </form>
469
- <?php
470
- }
471
-
472
- function tab_uploadimage() {
473
- global $ngg;
474
- // check the cookie for the current setting
475
- $checked = get_user_setting('ngg_upload_resize') ? ' checked="true"' : '';
476
- ?>
477
- <!-- upload images -->
478
- <h2><?php _e('Upload Images', 'nggallery') ;?></h2>
479
- <form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php echo $this->filepath.'#uploadimage'; ?>" accept-charset="utf-8" >
480
- <?php wp_nonce_field('ngg_addgallery') ?>
481
- <table class="form-table">
482
-
483
- <tr valign="top">
484
- <th scope="row"><?php _e('Upload image', 'nggallery') ;?></th>
485
- <?php if ($ngg->options['swfUpload'] && defined('IS_WP_3_3') ) { ?>
486
- <td>
487
- <div id="plupload-upload-ui">
488
- <div>
489
- <?php _e( 'Choose files to upload' ); ?>
490
- <input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" />
491
- </div>
492
- <p class="ngg-dragdrop-info howto" style="display:none;" ><?php _e('Or you can drop the files into this window.'); ?></p>
493
- <div id='uploadQueue'></div>
494
- <p><label><input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
495
- <?php printf( __( 'Scale images to max width %1$dpx or max height %2$dpx', 'nggallery' ), (int) $ngg->options['imgWidth' ], (int) $ngg->options[ 'imgHeight' ] ); ?>
496
- </label>
497
- </p>
498
-
499
- </div>
500
- </td>
501
- <?php } else { ?>
502
- <td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></td>
503
- <?php } ?>
504
- </tr>
505
- <tr valign="top">
506
- <th scope="row"><?php _e('in to', 'nggallery') ;?></th>
507
- <td><select name="galleryselect" id="galleryselect">
508
- <option value="0" ><?php _e('Choose gallery', 'nggallery') ?></option>
509
- <?php
510
- foreach($this->gallerylist as $gallery) {
511
-
512
- //special case : we check if a user has this cap, then we override the second cap check
513
- if ( !current_user_can( 'NextGEN Upload in all galleries' ) )
514
- if ( !nggAdmin::can_manage_this_gallery($gallery->author) )
515
- continue;
516
-
517
- $name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
518
- echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr( $name ) . '</option>' . "\n";
519
- } ?>
520
- </select>
521
- <br /><?php echo $this->maxsize; ?>
522
- <br /><?php if ((is_multisite()) && wpmu_enable_function('wpmuQuotaCheck')) display_space_usage(); ?></td>
523
- </tr>
524
- </table>
525
- <div class="submit">
526
- <?php if ($ngg->options['swfUpload']) { ?>
527
- <input type="submit" name="disable_flash" id="disable_flash" title="<?php _e('The batch upload requires Adobe Flash 10, disable it if you have problems','nggallery') ?>" value="<?php _e('Disable flash upload', 'nggallery') ;?>" />
528
- <?php } else { ?>
529
- <input type="submit" name="enable_flash" id="enable_flash" title="<?php _e('Upload multiple files at once by ctrl/shift-selecting in dialog','nggallery') ?>" value="<?php _e('Enable flash based upload', 'nggallery') ;?>" />
530
- <?php } ?>
531
- <input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php _e('Upload images', 'nggallery') ;?>" />
532
- </div>
533
- </form>
534
- <?php
535
- }
536
- }
537
- ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ class nggAddGallery {
5
+
6
+ /**
7
+ * nggAddGallery::__construct()
8
+ *
9
+ * @return void
10
+ */
11
+ function __construct() {
12
+
13
+ // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
14
+ $this->filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
15
+
16
+ //Look for POST updates
17
+ if ( !empty($_POST) )
18
+ $this->processor();
19
+ }
20
+
21
+ /**
22
+ * Perform the upload and add a new hook for plugins
23
+ *
24
+ * @return void
25
+ */
26
+ function processor() {
27
+ global $wpdb, $ngg, $nggdb;
28
+
29
+ $defaultpath = $ngg->options['gallerypath'];
30
+
31
+ if ( isset($_POST['addgallery']) ){
32
+ check_admin_referer('ngg_addgallery');
33
+
34
+ if ( !nggGallery::current_user_can( 'NextGEN Add new gallery' ))
35
+ wp_die(__('Cheatin&#8217; uh?'));
36
+
37
+ $newgallery = esc_attr( $_POST['galleryname']);
38
+ if ( !empty($newgallery) )
39
+ nggAdmin::create_gallery($newgallery, $defaultpath);
40
+ }
41
+
42
+ if ( isset($_POST['zipupload']) ){
43
+ check_admin_referer('ngg_addgallery');
44
+
45
+ if ( !nggGallery::current_user_can( 'NextGEN Upload a zip' ))
46
+ wp_die(__('Cheatin&#8217; uh?'));
47
+
48
+ if ($_FILES['zipfile']['error'] == 0 || (!empty($_POST['zipurl'])))
49
+ nggAdmin::import_zipfile( intval( $_POST['zipgalselect'] ) );
50
+ else
51
+ nggGallery::show_error( __('Upload failed!','nggallery') );
52
+ }
53
+
54
+ if ( isset($_POST['importfolder']) ){
55
+ check_admin_referer('ngg_addgallery');
56
+
57
+ if ( !nggGallery::current_user_can( 'NextGEN Import image folder' ))
58
+ wp_die(__('Cheatin&#8217; uh?'));
59
+
60
+ $galleryfolder = $_POST['galleryfolder'];
61
+ if ( ( !empty($galleryfolder) ) AND ($defaultpath != $galleryfolder) )
62
+ nggAdmin::import_gallery($galleryfolder);
63
+ }
64
+
65
+ if ( isset($_POST['uploadimage']) ){
66
+ check_admin_referer('ngg_addgallery');
67
+
68
+ if ( !nggGallery::current_user_can( 'NextGEN Upload in all galleries' ))
69
+ wp_die(__('Cheatin&#8217; uh?'));
70
+
71
+ if ( $_FILES['imagefiles']['error'][0] == 0 )
72
+ nggAdmin::upload_images();
73
+ else
74
+ nggGallery::show_error( __('Upload failed! ' . nggAdmin::decode_upload_error( $_FILES['imagefiles']['error'][0]),'nggallery') );
75
+ }
76
+
77
+ if ( isset($_POST['swf_callback']) ){
78
+ if ($_POST['galleryselect'] == '0' )
79
+ nggGallery::show_error(__('You didn\'t select a gallery!','nggallery'));
80
+ else {
81
+ if ($_POST['swf_callback'] == '-1' )
82
+ nggGallery::show_error( __('Upload failed!','nggallery') );
83
+ else {
84
+ $gallery = $nggdb->find_gallery( (int) $_POST['galleryselect'] );
85
+ nggAdmin::import_gallery( $gallery->path );
86
+ }
87
+ }
88
+ }
89
+
90
+ if ( isset($_POST['disable_flash']) ){
91
+ check_admin_referer('ngg_addgallery');
92
+ $ngg->options['swfUpload'] = false;
93
+ update_option('ngg_options', $ngg->options);
94
+ }
95
+
96
+ if ( isset($_POST['enable_flash']) ){
97
+ check_admin_referer('ngg_addgallery');
98
+ $ngg->options['swfUpload'] = true;
99
+ update_option('ngg_options', $ngg->options);
100
+ }
101
+
102
+ do_action( 'ngg_update_addgallery_page' );
103
+
104
+ }
105
+
106
+ /**
107
+ * Render the page content
108
+ *
109
+ * @return void
110
+ */
111
+ function controller() {
112
+ global $ngg, $nggdb;
113
+
114
+ // check for the max image size
115
+ $this->maxsize = nggGallery::check_memory_limit();
116
+
117
+ //get all galleries (after we added new ones)
118
+ $this->gallerylist = $nggdb->find_all_galleries('gid', 'DESC');
119
+
120
+ $this->defaultpath = $ngg->options['gallerypath'];
121
+
122
+ // link for the flash file
123
+ $swf_upload_link = admin_url('/?nggupload');
124
+
125
+ // get list of tabs
126
+ $tabs = $this->tabs_order();
127
+
128
+ // with this filter you can add custom file types
129
+ $file_types = apply_filters( 'ngg_swf_file_types', '*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG' );
130
+
131
+ // Set the post params, which plupload will post back with the file, and pass them through a filter.
132
+ $post_params = array(
133
+ "auth_cookie" => (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]),
134
+ "logged_in_cookie" => $_COOKIE[LOGGED_IN_COOKIE],
135
+ "_wpnonce" => wp_create_nonce('ngg_swfupload'),
136
+ "galleryselect" => "0",
137
+ );
138
+ $p = array();
139
+
140
+ foreach ( $post_params as $param => $val ) {
141
+ $val = esc_js( $val );
142
+ $p[] = "'$param' : '$val'";
143
+ }
144
+
145
+ $post_params_str = implode( ',', $p ). "\n";
146
+ ?>
147
+ <div class="wrap ngg-wrap">
148
+ <?php screen_icon( 'nextgen-gallery' ); ?>
149
+ <h2><?php _e('Add Gallery / Images', 'nggallery') ?></h2>
150
+ </div>
151
+
152
+ <?php if($ngg->options['swfUpload'] && !empty ($this->gallerylist) ) { ?>
153
+ <?php if ( defined('IS_WP_3_3') ) { ?>
154
+ <!-- plupload script -->
155
+ <script type="text/javascript">
156
+ //<![CDATA[
157
+ var resize_height = <?php echo (int) $ngg->options['imgHeight']; ?>,
158
+ resize_width = <?php echo (int) $ngg->options['imgWidth']; ?>;
159
+
160
+ jQuery(document).ready(function($) {
161
+ window.uploader = new plupload.Uploader({
162
+ runtimes: '<?php echo apply_filters('plupload_runtimes', 'html5,flash,silverlight,html4,'); ?>',
163
+ browse_button: 'plupload-browse-button',
164
+ container: 'plupload-upload-ui',
165
+ drop_element: 'uploadimage',
166
+ file_data_name: 'Filedata',
167
+ max_file_size: '<?php echo round( (int) wp_max_upload_size() / 1024 ); ?>kb',
168
+ url: '<?php echo esc_js( $swf_upload_link ); ?>',
169
+ flash_swf_url: '<?php echo esc_js( includes_url('js/plupload/plupload.flash.swf') ); ?>',
170
+ silverlight_xap_url: '<?php echo esc_js( includes_url('js/plupload/plupload.silverlight.xap') ); ?>',
171
+ filters: [
172
+ {title: '<?php echo esc_js( __('Image Files', 'nggallery') ); ?>', extensions: '<?php echo esc_js( str_replace( array('*.', ';'), array('', ','), $file_types) ); ?>'}
173
+ ],
174
+ multipart: true,
175
+ urlstream_upload: true,
176
+ multipart_params : {
177
+ <?php echo $post_params_str; ?>
178
+ },
179
+ debug: false,
180
+ preinit : {
181
+ Init: function(up, info) {
182
+ debug('[Init]', 'Info :', info, 'Features :', up.features);
183
+ if (navigator.appVersion.indexOf("MSIE 10") > -1) {
184
+ up.features.triggerDialog = true;
185
+ }
186
+ initUploader();
187
+ }
188
+ },
189
+ i18n : {
190
+ 'remove' : '<?php _e('remove', 'nggallery') ;?>',
191
+ 'browse' : '<?php _e('Browse...', 'nggallery') ;?>',
192
+ 'upload' : '<?php _e('Upload images', 'nggallery') ;?>'
193
+ }
194
+ });
195
+
196
+ uploader.bind('FilesAdded', function(up, files) {
197
+ $.each(files, function(i, file) {
198
+ fileQueued(file);
199
+ });
200
+
201
+ up.refresh();
202
+ });
203
+
204
+ uploader.bind('BeforeUpload', function(up, file) {
205
+ uploadStart(file);
206
+ });
207
+
208
+ uploader.bind('UploadProgress', function(up, file) {
209
+ uploadProgress(file, file.loaded, file.size);
210
+ });
211
+
212
+ uploader.bind('Error', function(up, err) {
213
+ uploadError(err.file, err.code, err.message);
214
+
215
+ up.refresh();
216
+ });
217
+
218
+ uploader.bind('FileUploaded', function(up, file, response) {
219
+ uploadSuccess(file, response);
220
+ });
221
+
222
+ uploader.bind('UploadComplete', function(up, file) {
223
+ uploadComplete(file);
224
+ });
225
+
226
+ // on load change the upload to plupload
227
+ uploader.init();
228
+
229
+ nggAjaxOptions = {
230
+ header: "<?php _e('Upload images', 'nggallery') ;?>",
231
+ maxStep: 100
232
+ };
233
+
234
+ });
235
+ //]]>
236
+ </script>
237
+ <?php } else { ?>
238
+ <!-- SWFUpload script -->
239
+ <script type="text/javascript">
240
+ var ngg_swf_upload;
241
+
242
+ window.onload = function () {
243
+ ngg_swf_upload = new SWFUpload({
244
+ // Backend settings
245
+ upload_url : "<?php echo esc_js( $swf_upload_link ); ?>",
246
+ flash_url : "<?php echo esc_js( includes_url('js/swfupload/swfupload.swf') ); ?>",
247
+
248
+ // Button Settings
249
+ button_placeholder_id : "spanButtonPlaceholder",
250
+ button_width: 300,
251
+ button_height: 27,
252
+ button_text_top_padding: 3,
253
+ button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
254
+ button_cursor: SWFUpload.CURSOR.HAND,
255
+
256
+ // File Upload Settings
257
+ file_size_limit : "<?php echo wp_max_upload_size(); ?>b",
258
+ file_types : "<?php echo $file_types; ?>",
259
+ file_types_description : "<?php _e('Image Files', 'nggallery') ;?>",
260
+
261
+ // Queue handler
262
+ file_queued_handler : fileQueued,
263
+
264
+ // Upload handler
265
+ upload_start_handler : uploadStart,
266
+ upload_progress_handler : uploadProgress,
267
+ upload_error_handler : uploadError,
268
+ upload_success_handler : uploadSuccess,
269
+ upload_complete_handler : uploadComplete,
270
+
271
+ post_params : {
272
+ "auth_cookie" : "<?php echo (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]); ?>",
273
+ "logged_in_cookie": "<?php echo $_COOKIE[LOGGED_IN_COOKIE]; ?>",
274
+ "_wpnonce" : "<?php echo wp_create_nonce('ngg_swfupload'); ?>",
275
+ "galleryselect" : "0"
276
+ },
277
+
278
+ // i18names
279
+ custom_settings : {
280
+ "remove" : "<?php _e('remove', 'nggallery') ;?>",
281
+ "browse" : "<?php _e('Browse...', 'nggallery') ;?>",
282
+ "upload" : "<?php _e('Upload images', 'nggallery') ;?>"
283
+ },
284
+
285
+ // Debug settings
286
+ debug: false
287
+
288
+ });
289
+
290
+ // on load change the upload to swfupload
291
+ initSWFUpload();
292
+
293
+ nggAjaxOptions = {
294
+ header: "<?php _e('Upload images', 'nggallery') ;?>",
295
+ maxStep: 100
296
+ };
297
+
298
+ };
299
+ </script>
300
+ <?php } ?>
301
+ <?php } else { ?>
302
+ <!-- MultiFile script -->
303
+ <script type="text/javascript">
304
+ /* <![CDATA[ */
305
+ jQuery(document).ready(function(){
306
+ jQuery('#imagefiles').MultiFile({
307
+ STRING: {
308
+ remove:'[<?php _e('remove', 'nggallery') ;?>]'
309
+ }
310
+ });
311
+ });
312
+ /* ]]> */
313
+ </script>
314
+ <?php } ?>
315
+ <!-- jQuery Tabs script -->
316
+ <script type="text/javascript">
317
+ /* <![CDATA[ */
318
+ jQuery(document).ready(function(){
319
+ jQuery('html,body').scrollTop(0);
320
+ jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' }).css({ 'display': 'block', 'margin': '4px 15px 0 0' });
321
+ });
322
+
323
+ // File Tree implementation
324
+ jQuery(function() {
325
+ jQuery("span.browsefiles").show().click(function(){
326
+ jQuery("#file_browser").fileTree({
327
+ script: "admin-ajax.php?action=ngg_file_browser&nonce=<?php echo wp_create_nonce( 'ngg-ajax' ) ;?>",
328
+ root: jQuery("#galleryfolder").val()
329
+ }, function(folder) {
330
+ jQuery("#galleryfolder").val( folder );
331
+ });
332
+ jQuery("#file_browser").show('slide');
333
+ });
334
+ });
335
+ /* ]]> */
336
+ </script>
337
+ <div id="slider" class="wrap" style="display: none;">
338
+ <ul id="tabs">
339
+ <?php
340
+ foreach($tabs as $tab_key => $tab_name) {
341
+ echo "\n\t\t<li><a class='nav-tab' href='#$tab_key'>$tab_name</a></li>";
342
+ }
343
+ ?>
344
+ </ul>
345
+ <?php
346
+ foreach($tabs as $tab_key => $tab_name) {
347
+ echo "\n\t<div id='$tab_key'>\n";
348
+ // Looks for the internal class function, otherwise enable a hook for plugins
349
+ if ( method_exists( $this, "tab_$tab_key" ))
350
+ call_user_func( array( &$this , "tab_$tab_key") );
351
+ else
352
+ do_action( 'ngg_tab_content_' . $tab_key );
353
+ echo "\n\t</div>";
354
+ }
355
+ ?>
356
+ </div>
357
+ <?php
358
+
359
+ }
360
+
361
+ /**
362
+ * Create array for tabs and add a filter for other plugins to inject more tabs
363
+ *
364
+ * @return array $tabs
365
+ */
366
+ function tabs_order() {
367
+
368
+ $tabs = array();
369
+
370
+ if ( nggGallery::current_user_can( 'NextGEN Add new gallery' ))
371
+ $tabs['addgallery'] = __('New gallery', 'nggallery');
372
+
373
+ if ( !empty ($this->gallerylist) )
374
+ $tabs['uploadimage'] = __( 'Images', 'nggallery' );
375
+
376
+ if ( wpmu_enable_function('wpmuZipUpload') && nggGallery::current_user_can( 'NextGEN Upload a zip' ) )
377
+ $tabs['zipupload'] = __('ZIP file', 'nggallery');
378
+
379
+ if ( wpmu_enable_function('wpmuImportFolder') && nggGallery::current_user_can( 'NextGEN Import image folder' ) )
380
+ $tabs['importfolder'] = __('Import folder', 'nggallery');
381
+
382
+ $tabs = apply_filters('ngg_addgallery_tabs', $tabs);
383
+
384
+ return $tabs;
385
+
386
+ }
387
+
388
+ function tab_addgallery() {
389
+ ?>
390
+ <!-- create gallery -->
391
+ <h3><?php _e('Add a new gallery', 'nggallery') ;?></h3>
392
+ <form name="addgallery" id="addgallery_form" method="POST" action="<?php echo $this->filepath; ?>" accept-charset="utf-8" >
393
+ <?php wp_nonce_field('ngg_addgallery') ?>
394
+ <table class="form-table">
395
+ <tr valign="top">
396
+ <th scope="row"><?php _e('Name', 'nggallery') ;?>:</th>
397
+ <td><input type="text" size="35" name="galleryname" value="" /><br />
398
+ <?php if(!is_multisite()) { ?>
399
+ <?php _e('Create a new, empty gallery in the folder', 'nggallery') ;?> <strong><?php echo $this->defaultpath ?></strong>
400
+ <?php } ?>
401
+ <p class="description"><?php _e('Allowed characters for file and folder names are', 'nggallery') ;?>: a-z, A-Z, 0-9, -, _</p></td>
402
+ </tr>
403
+ <?php do_action('ngg_add_new_gallery_form'); ?>
404
+ </table>
405
+ <div class="submit"><input class="button-primary" type="submit" name= "addgallery" value="<?php _e('Add gallery', 'nggallery') ;?>"/></div>
406
+ </form>
407
+ <?php
408
+ }
409
+
410
+ function tab_zipupload() {
411
+ ?>
412
+ <!-- zip-file operation -->
413
+ <h3><?php _e('Upload a ZIP File', 'nggallery') ;?></h3>
414
+ <form name="zipupload" id="zipupload_form" method="POST" enctype="multipart/form-data" action="<?php echo $this->filepath.'#zipupload'; ?>" accept-charset="utf-8" >
415
+ <?php wp_nonce_field('ngg_addgallery') ?>
416
+ <table class="form-table">
417
+ <tr valign="top">
418
+ <th scope="row"><?php _e('Select ZIP file', 'nggallery') ;?>:</th>
419
+ <td><input type="file" name="zipfile" id="zipfile" size="35" class="uploadform"/><p class="description">
420
+ <?php _e('Upload a ZIP file with images', 'nggallery') ;?></p></td>
421
+ </tr>
422
+ <?php if (function_exists('curl_init')) : ?>
423
+ <tr valign="top">
424
+ <th scope="row"><?php _e('or enter URL', 'nggallery') ;?>:</th>
425
+ <td><input type="text" name="zipurl" id="zipurl" size="35" class="uploadform"/>
426
+ <p class="description"><?php _e('Import a ZIP file from a URL', 'nggallery') ;?></p></td>
427
+ </tr>
428
+ <?php endif; ?>
429
+ <tr valign="top">
430
+ <th scope="row"><?php _e('in to', 'nggallery') ;?></th>
431
+ <td><select name="zipgalselect">
432
+ <option value="0" ><?php _e('a new gallery', 'nggallery') ?></option>
433
+ <?php
434
+ foreach($this->gallerylist as $gallery) {
435
+ if ( !nggAdmin::can_manage_this_gallery($gallery->author) )
436
+ continue;
437
+ $name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
438
+ echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr( $name ). '</option>' . "\n";
439
+ }
440
+ ?>
441
+ </select>
442
+ <br /><?php echo $this->maxsize; ?>
443
+ <p class="description"><?php echo _e('Note: the upload limit on your server is ','nggallery') . "<strong>" . ini_get('upload_max_filesize') . "B</strong>\n"; ?></p>
444
+ <br /><?php if ( (is_multisite()) && wpmu_enable_function('wpmuQuotaCheck') ) display_space_usage(); ?></td>
445
+ </tr>
446
+ </table>
447
+ <div class="submit"><input class="button-primary" type="submit" name= "zipupload" value="<?php _e('Start upload', 'nggallery') ;?>"/></div>
448
+ </form>
449
+ <?php
450
+ }
451
+
452
+ function tab_importfolder() {
453
+ ?>
454
+ <!-- import folder -->
455
+ <h3><?php _e('Import an image folder', 'nggallery') ;?></h3>
456
+ <form name="importfolder" id="importfolder_form" method="POST" action="<?php echo $this->filepath.'#importfolder'; ?>" accept-charset="utf-8" >
457
+ <?php wp_nonce_field('ngg_addgallery') ?>
458
+ <table class="form-table">
459
+ <tr valign="top">
460
+ <th scope="row"><?php _e('Import from server:', 'nggallery') ;?></th>
461
+ <td><input type="text" size="35" id="galleryfolder" name="galleryfolder" value="<?php echo $this->defaultpath; ?>" /><span class="browsefiles button" style="display:none"><?php _e('Browse...', 'nggallery'); ?></span><br />
462
+ <div id="file_browser"></div>
463
+ <p class="description"><?php _e('Note: you can change the default path in the gallery settings', 'nggallery') ;?></p>
464
+ <br /><?php echo $this->maxsize; ?>
465
+ <?php if (SAFE_MODE) {?><p class="description"><?php _e('Please note: If safe-mode is ON, you need to add the subfolder with thumbs manually', 'nggallery') ;?></p><?php }; ?></td>
466
+ </tr>
467
+ </table>
468
+ <div class="submit"><input class="button-primary" type="submit" name= "importfolder" value="<?php _e('Import folder', 'nggallery') ;?>"/></div>
469
+ </form>
470
+ <?php
471
+ }
472
+
473
+ function tab_uploadimage() {
474
+ global $ngg;
475
+ // check the cookie for the current setting
476
+ $checked = get_user_setting('ngg_upload_resize') ? ' checked="true"' : '';
477
+ ?>
478
+ <!-- upload images -->
479
+ <h3><?php _e('Upload images', 'nggallery') ;?></h3>
480
+ <form name="uploadimage" id="uploadimage_form" method="POST" enctype="multipart/form-data" action="<?php echo $this->filepath.'#uploadimage'; ?>" accept-charset="utf-8" >
481
+ <?php wp_nonce_field('ngg_addgallery') ?>
482
+ <table class="form-table">
483
+
484
+ <tr valign="top">
485
+ <th scope="row"><?php _e('Upload image', 'nggallery') ;?></th>
486
+ <?php if ($ngg->options['swfUpload'] && defined('IS_WP_3_3') ) { ?>
487
+ <td>
488
+ <div id="plupload-upload-ui">
489
+ <div>
490
+ <?php _e( 'Choose files to upload' ); ?>
491
+ <input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" />
492
+ </div>
493
+ <p class="ngg-dragdrop-info howto" style="display:none;" ><?php _e('Or you can drop the files into this window.'); ?></p>
494
+ <div id='uploadQueue'></div>
495
+ <p><label><input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
496
+ <?php printf( __( 'Scale images to max width %1$dpx or max height %2$dpx', 'nggallery' ), (int) $ngg->options['imgWidth' ], (int) $ngg->options[ 'imgHeight' ] ); ?>
497
+ </label>
498
+ </p>
499
+ </div>
500
+ </td>
501
+ <?php } else { ?>
502
+ <td><span id='spanButtonPlaceholder'></span><input type="file" name="imagefiles[]" id="imagefiles" size="35" class="imagefiles"/></td>
503
+ <?php } ?>
504
+ </tr>
505
+ <tr valign="top">
506
+ <th scope="row"><?php _e('in to', 'nggallery') ;?></th>
507
+ <td><select name="galleryselect" id="galleryselect">
508
+ <option value="0" ><?php _e('Choose gallery', 'nggallery') ?></option>
509
+ <?php
510
+ foreach($this->gallerylist as $gallery) {
511
+ //special case : we check if a user has this cap, then we override the second cap check
512
+ if ( !current_user_can( 'NextGEN Upload in all galleries' ) )
513
+ if ( !nggAdmin::can_manage_this_gallery($gallery->author) )
514
+ continue;
515
+
516
+ $name = ( empty($gallery->title) ) ? $gallery->name : $gallery->title;
517
+ echo '<option value="' . $gallery->gid . '" >' . $gallery->gid . ' - ' . esc_attr( $name ) . '</option>' . "\n";
518
+ } ?>
519
+ </select>
520
+ <br /><?php echo $this->maxsize; ?>
521
+ <br /><?php if ((is_multisite()) && wpmu_enable_function('wpmuQuotaCheck')) display_space_usage(); ?></td>
522
+ </tr>
523
+ </table>
524
+ <div class="submit">
525
+ <?php if ($ngg->options['swfUpload']) { ?>
526
+ <input class="button action" type="submit" name="disable_flash" id="disable_flash" title="<?php _e('The batch upload requires Adobe Flash 10, disable it if you have problems','nggallery') ?>" value="<?php _e('Disable flash upload', 'nggallery') ;?>" />
527
+ <?php } else { ?>
528
+ <input class="button action" type="submit" name="enable_flash" id="enable_flash" title="<?php _e('Upload multiple files at once by ctrl/shift-selecting in dialog','nggallery') ?>" value="<?php _e('Enable flash based upload', 'nggallery') ;?>" />
529
+ <?php } ?>
530
+ <input class="button-primary" type="submit" name="uploadimage" id="uploadimage_btn" value="<?php _e('Upload images', 'nggallery') ;?>" />
531
+ </div>
532
+ </form>
533
+ <?php
534
+ }
535
+ }
536
+ ?>
 
admin/admin.php CHANGED
@@ -1,576 +1,558 @@
1
- <?php
2
- /**
3
- * nggAdminPanel - Admin Section for NextGEN Gallery
4
- *
5
- * @package NextGEN Gallery
6
- * @author Alex Rabe
7
- *
8
- * @since 1.0.0
9
- */
10
- class nggAdminPanel{
11
-
12
- // constructor
13
- function __construct() {
14
-
15
- // Add the admin menu
16
- add_action( 'admin_menu', array (&$this, 'add_menu') );
17
- add_action( 'admin_bar_menu', array(&$this, 'admin_bar_menu'), 99 );
18
- add_action( 'network_admin_menu', array (&$this, 'add_network_admin_menu') );
19
-
20
- // Add the script and style files
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'));
32
-
33
- // Add WPML hook to register description / alt text for translation
34
- add_action('ngg_image_updated', array('nggGallery', 'RegisterString') );
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'>
103
- window.onerror = function(msg, url, line){
104
- if (url.match(/\.js$|\.js\?/)) {
105
- if (window.location.search.length > 0) {
106
- if (window.location.search.indexOf(url) == -1)
107
- window.location.search += '&skipjs[{$skipjs_count}]='+url;
108
- }
109
- else {
110
- window.location.search = '?skipjs[{$skipjs_count}]='+url;
111
- }
112
- }
113
- return true;
114
- };</script>\n",
115
- $html
116
- ));
117
- }
118
-
119
- echo $html;
120
- }
121
- }
122
-
123
- // integrate the menu
124
- function add_menu() {
125
-
126
- add_menu_page( _n( 'Gallery', 'Galleries', 1, 'nggallery' ), _n( 'Gallery', 'Galleries', 1, 'nggallery' ), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'), path_join(NGGALLERY_URLPATH, 'admin/images/nextgen_16_color.png') );
127
- add_submenu_page( NGGFOLDER , __('Overview', 'nggallery'), __('Overview', 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'));
128
- add_submenu_page( NGGFOLDER , __('Add Gallery / Images', 'nggallery'), __('Add Gallery / Images', 'nggallery'), 'NextGEN Upload images', 'nggallery-add-gallery', array (&$this, 'show_menu'));
129
- add_submenu_page( NGGFOLDER , __('Manage Gallery', 'nggallery'), __('Manage Gallery', 'nggallery'), 'NextGEN Manage gallery', 'nggallery-manage-gallery', array (&$this, 'show_menu'));
130
- add_submenu_page( NGGFOLDER , _n( 'Album', 'Albums', 1, 'nggallery' ), _n( 'Album', 'Albums', 1, 'nggallery' ), 'NextGEN Edit album', 'nggallery-manage-album', array (&$this, 'show_menu'));
131
- add_submenu_page( NGGFOLDER , __('Tags', 'nggallery'), __('Tags', 'nggallery'), 'NextGEN Manage tags', 'nggallery-tags', array (&$this, 'show_menu'));
132
- add_submenu_page( NGGFOLDER , __('Options', 'nggallery'), __('Options', 'nggallery'), 'NextGEN Change options', 'nggallery-options', array (&$this, 'show_menu'));
133
- if ( wpmu_enable_function('wpmuStyle') )
134
- add_submenu_page( NGGFOLDER , __('Style', 'nggallery'), __('Style', 'nggallery'), 'NextGEN Change style', 'nggallery-style', array (&$this, 'show_menu'));
135
- if ( wpmu_enable_function('wpmuRoles') || wpmu_site_admin() )
136
- add_submenu_page( NGGFOLDER , __('Roles', 'nggallery'), __('Roles', 'nggallery'), 'activate_plugins', 'nggallery-roles', array (&$this, 'show_menu'));
137
- add_submenu_page( NGGFOLDER , __('About this Gallery', 'nggallery'), __('About', 'nggallery'), 'NextGEN Gallery overview', 'nggallery-about', array (&$this, 'show_menu'));
138
-
139
- if ( !is_multisite() || wpmu_site_admin() )
140
- add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu'));
141
-
142
- //register the column fields
143
- $this->register_columns();
144
- }
145
-
146
- // integrate the network menu
147
- function add_network_admin_menu() {
148
-
149
- add_menu_page( _n( 'Gallery', 'Galleries', 1, 'nggallery' ), _n( 'Gallery', 'Galleries', 1, 'nggallery' ), 'nggallery-wpmu', NGGFOLDER, array (&$this, 'show_network_settings'), path_join(NGGALLERY_URLPATH, 'admin/images/nextgen_16_color.png') );
150
- add_submenu_page( NGGFOLDER , __('Network settings', 'nggallery'), __('Network settings', 'nggallery'), 'nggallery-wpmu', NGGFOLDER, array (&$this, 'show_network_settings'));
151
- add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu'));
152
- }
153
-
154
- /**
155
- * Adding NextGEN Gallery to the Admin bar
156
- *
157
- * @since 1.9.0
158
- *
159
- * @return void
160
- */
161
- function admin_bar_menu() {
162
- // If the current user can't write posts, this is all of no use, so let's not output an admin menu
163
- if ( !current_user_can('NextGEN Gallery overview') )
164
- return;
165
-
166
- global $wp_admin_bar;
167
-
168
- $wp_admin_bar->add_menu( array( 'id' => 'ngg-menu', 'title' => __( 'Gallery' ), 'href' => admin_url('admin.php?page='. NGGFOLDER) ) );
169
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-overview', 'title' => __('Overview', 'nggallery'), 'href' => admin_url('admin.php?page='. NGGFOLDER) ) );
170
- if ( current_user_can('NextGEN Upload images') )
171
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-add-gallery', 'title' => __('Add Gallery / Images', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-add-gallery') ) );
172
- if ( current_user_can('NextGEN Manage gallery') )
173
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-manage-gallery', 'title' => __('Manage Gallery', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-manage-gallery') ) );
174
- if ( current_user_can('NextGEN Edit album') )
175
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-manage-album', 'title' => _n( 'Album', 'Albums', 1, 'nggallery' ), 'href' => admin_url('admin.php?page=nggallery-manage-album') ) );
176
- if ( current_user_can('NextGEN Manage tags') )
177
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-tags', 'title' => __('Tags', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-tags') ) );
178
- if ( current_user_can('NextGEN Change options') )
179
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-options', 'title' => __('Options', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-options') ) );
180
- if ( wpmu_enable_function('wpmuStyle') && ( current_user_can('NextGEN Change style') ))
181
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-style', 'title' => __('Style', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-style') ) );
182
- $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-about', 'title' => __('About', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-about') ) );
183
- }
184
-
185
- // show the network page
186
- function show_network_settings() {
187
- include_once ( dirname (__FILE__) . '/style.php' );
188
- include_once ( dirname (__FILE__) . '/wpmu.php' );
189
- nggallery_wpmu_setup();
190
- }
191
-
192
- // load the script for the defined page and load only this code
193
- function show_menu() {
194
-
195
- global $ngg;
196
-
197
- // Set installation date
198
- if( empty($ngg->options['installDate']) ) {
199
- $ngg->options['installDate'] = time();
200
- update_option('ngg_options', $ngg->options);
201
- }
202
-
203
- // Show donation message only one time.
204
- if (isset ( $_GET['hide_donation']) ) {
205
- $ngg->options['hideDonation'] = true;
206
- update_option('ngg_options', $ngg->options);
207
- }
208
-
209
- switch ($_GET['page']){
210
- case "nggallery-add-gallery" :
211
- include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
212
- include_once ( dirname (__FILE__) . '/addgallery.php' ); // nggallery_admin_add_gallery
213
- $ngg->addgallery_page = new nggAddGallery ();
214
- $ngg->addgallery_page->controller();
215
- break;
216
- case "nggallery-manage-gallery" :
217
- include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
218
- include_once ( dirname (__FILE__) . '/manage.php' ); // nggallery_admin_manage_gallery
219
- // Initate the Manage Gallery page
220
- $ngg->manage_page = new nggManageGallery ();
221
- // Render the output now, because you cannot access a object during the constructor is not finished
222
- $ngg->manage_page->controller();
223
- break;
224
- case "nggallery-manage-album" :
225
- include_once ( dirname (__FILE__) . '/album.php' ); // nggallery_admin_manage_album
226
- $ngg->manage_album = new nggManageAlbum ();
227
- $ngg->manage_album->controller();
228
- break;
229
- case "nggallery-options" :
230
- include_once ( dirname (__FILE__) . '/settings.php' ); // nggallery_admin_options
231
- $ngg->option_page = new nggOptions ();
232
- $ngg->option_page->controller();
233
- break;
234
- case "nggallery-tags" :
235
- include_once ( dirname (__FILE__) . '/tags.php' ); // nggallery_admin_tags
236
- break;
237
- case "nggallery-style" :
238
- include_once ( dirname (__FILE__) . '/style.php' ); // nggallery_admin_style
239
- nggallery_admin_style();
240
- break;
241
- case "nggallery-setup" :
242
- include_once ( dirname (__FILE__) . '/setup.php' ); // nggallery_admin_setup
243
- nggallery_admin_setup();
244
- break;
245
- case "nggallery-roles" :
246
- include_once ( dirname (__FILE__) . '/roles.php' ); // nggallery_admin_roles
247
- nggallery_admin_roles();
248
- break;
249
- case "nggallery-import" :
250
- include_once ( dirname (__FILE__) . '/myimport.php' ); // nggallery_admin_import
251
- nggallery_admin_import();
252
- break;
253
- case "nggallery-about" :
254
- include_once ( dirname (__FILE__) . '/about.php' ); // nggallery_admin_about
255
- nggallery_admin_about();
256
- break;
257
- case "nggallery" :
258
- default :
259
- include_once ( dirname (__FILE__) . '/overview.php' ); // nggallery_admin_overview
260
- nggallery_admin_overview();
261
- break;
262
- }
263
- }
264
-
265
- function load_scripts() {
266
- global $wp_version;
267
-
268
- // no need to go on if it's not a plugin page
269
- if( !isset($_GET['page']) )
270
- return;
271
-
272
- // If we're on a NextGen Page
273
- if (preg_match("/ngg|nextgen-gallery/", $_GET['page'])) {
274
- wp_register_script('ngg_social_media', path_join(
275
- NGGALLERY_URLPATH,
276
- 'admin/js/ngg_social_media.js'
277
- ), array('jquery'));
278
-
279
- wp_register_style('ngg_social_media', path_join(
280
- NGGALLERY_URLPATH,
281
- 'admin/css/ngg_social_media.css'
282
- ));
283
-
284
- wp_enqueue_style('ngg_social_media');
285
- wp_enqueue_script('ngg_social_media');
286
- }
287
-
288
- wp_register_script('ngg-ajax', NGGALLERY_URLPATH . 'admin/js/ngg.ajax.js', array('jquery'), '1.4.1');
289
- wp_localize_script('ngg-ajax', 'nggAjaxSetup', array(
290
- 'url' => admin_url('admin-ajax.php'),
291
- 'action' => 'ngg_ajax_operation',
292
- 'operation' => '',
293
- 'nonce' => wp_create_nonce( 'ngg-ajax' ),
294
- 'ids' => '',
295
- 'permission' => __('You do not have the correct permission', 'nggallery'),
296
- 'error' => __('Unexpected Error', 'nggallery'),
297
- 'failure' => __('A failure occurred', 'nggallery')
298
- ) );
299
- wp_register_script( 'ngg-plupload-handler', NGGALLERY_URLPATH .'admin/js/plupload.handler.js', array('plupload-all'), '0.0.1' );
300
- wp_localize_script( 'ngg-plupload-handler', 'pluploadL10n', array(
301
- 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
302
- 'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
303
- 'zero_byte_file' => __('This file is empty. Please try another.'),
304
- 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
305
- 'not_an_image' => __('This file is not an image. Please try another.'),
306
- 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
307
- 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
308
- 'default_error' => __('An error occurred in the upload. Please try again later.'),
309
- 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
310
- 'upload_limit_exceeded' => __('You may only upload 1 file.'),
311
- 'http_error' => __('HTTP error.'),
312
- 'upload_failed' => __('Upload failed.'),
313
- 'io_error' => __('IO error.'),
314
- 'security_error' => __('Security error.'),
315
- 'file_cancelled' => __('File canceled.'),
316
- 'upload_stopped' => __('Upload stopped.'),
317
- 'dismiss' => __('Dismiss'),
318
- 'crunching' => __('Crunching&hellip;'),
319
- 'deleted' => __('moved to the trash.'),
320
- 'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error')
321
- ) );
322
- wp_register_script('ngg-progressbar', NGGALLERY_URLPATH .'admin/js/ngg.progressbar.js', array('jquery'), '2.0.1');
323
- wp_register_script('jquery-ui-autocomplete', NGGALLERY_URLPATH .'admin/js/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.15');
324
-
325
- switch ($_GET['page']) {
326
- case NGGFOLDER :
327
- wp_enqueue_script( 'postbox' );
328
- add_thickbox();
329
- break;
330
- case "nggallery-manage-gallery" :
331
- wp_enqueue_script( 'postbox' );
332
- wp_enqueue_script( 'ngg-ajax' );
333
- wp_enqueue_script( 'ngg-progressbar' );
334
- wp_enqueue_script( 'jquery-ui-dialog' );
335
- wp_enqueue_script( 'jquery-ui-sortable' );
336
- wp_register_script('shutter', NGGALLERY_URLPATH .'shutter/shutter-reloaded.js', false ,'1.3.2');
337
- wp_localize_script('shutter', 'shutterSettings', array(
338
- 'msgLoading' => __('L O A D I N G', 'nggallery'),
339
- 'msgClose' => __('Click to Close', 'nggallery'),
340
- 'imageCount' => '1'
341
- ) );
342
- wp_enqueue_script( 'shutter' );
343
- break;
344
- case "nggallery-manage-album" :
345
- wp_enqueue_script( 'jquery-ui-autocomplete' );
346
- wp_enqueue_script( 'jquery-ui-dialog' );
347
- wp_enqueue_script( 'jquery-ui-sortable' );
348
- wp_enqueue_script( 'ngg-autocomplete', NGGALLERY_URLPATH .'admin/js/ngg.autocomplete.js', array('jquery-ui-autocomplete'), '1.0.1');
349
- break;
350
- case "nggallery-options" :
351
- wp_enqueue_script( 'jquery-ui-tabs' );
352
- //wp_enqueue_script( 'ngg-colorpicker', NGGALLERY_URLPATH .'admin/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
353
- break;
354
- case "nggallery-add-gallery" :
355
- wp_enqueue_script( 'jquery-ui-tabs' );
356
- wp_enqueue_script( 'multifile', NGGALLERY_URLPATH .'admin/js/jquery.MultiFile.js', array('jquery'), '1.4.4' );
357
- if ( defined('IS_WP_3_3') )
358
- wp_enqueue_script( 'ngg-plupload-handler' );
359
- else
360
- wp_enqueue_script( 'ngg-swfupload-handler', NGGALLERY_URLPATH .'admin/js/swfupload.handler.js', array('jquery', 'swfupload'), '1.0.3' );
361
- wp_enqueue_script( 'ngg-ajax' );
362
- wp_enqueue_script( 'ngg-progressbar' );
363
- wp_enqueue_script( 'jquery-ui-dialog' );
364
- wp_enqueue_script( 'jqueryFileTree', NGGALLERY_URLPATH .'admin/js/jqueryFileTree/jqueryFileTree.js', array('jquery'), '1.0.1' );
365
- break;
366
- case "nggallery-style" :
367
- wp_enqueue_script( 'codepress' );
368
- wp_enqueue_script( 'ngg-colorpicker', NGGALLERY_URLPATH .'admin/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
369
- break;
370
-
371
- }
372
- }
373
-
374
- function load_styles() {
375
- // load the icon for the navigation menu
376
- wp_enqueue_style( 'nggmenu', NGGALLERY_URLPATH .'admin/css/menu.css', array() );
377
- wp_register_style( 'nggadmin', NGGALLERY_URLPATH .'admin/css/nggadmin.css', false, '2.8.1', 'screen' );
378
- wp_register_style( 'ngg-jqueryui', NGGALLERY_URLPATH .'admin/css/jquery.ui.css', false, '1.8.5', 'screen' );
379
-
380
- // no need to go on if it's not a plugin page
381
- if( !isset($_GET['page']) )
382
- return;
383
-
384
- switch ($_GET['page']) {
385
- case NGGFOLDER :
386
- wp_enqueue_style( 'thickbox' );
387
- case "nggallery-about" :
388
- wp_enqueue_style( 'nggadmin' );
389
- //TODO:Remove after WP 3.3 release
390
- if ( !defined('IS_WP_3_3') )
391
- wp_admin_css( 'css/dashboard' );
392
- break;
393
- case "nggallery-add-gallery" :
394
- wp_enqueue_style( 'ngg-jqueryui' );
395
- wp_enqueue_style( 'jqueryFileTree', NGGALLERY_URLPATH .'admin/js/jqueryFileTree/jqueryFileTree.css', false, '1.0.1', 'screen' );
396
- case "nggallery-options" :
397
- wp_enqueue_style( 'nggtabs', NGGALLERY_URLPATH .'admin/css/jquery.ui.tabs.css', false, '2.5.0', 'screen' );
398
- wp_enqueue_style( 'nggadmin' );
399
- break;
400
- case "nggallery-manage-gallery" :
401
- wp_enqueue_style('shutter', NGGALLERY_URLPATH .'shutter/shutter-reloaded.css', false, '1.3.2', 'screen');
402
- case "nggallery-roles" :
403
- case "nggallery-manage-album" :
404
- wp_enqueue_style( 'ngg-jqueryui' );
405
- wp_enqueue_style( 'nggadmin' );
406
- break;
407
- case "nggallery-tags" :
408
- wp_enqueue_style( 'nggtags', NGGALLERY_URLPATH .'admin/css/tags-admin.css', false, '2.6.1', 'screen' );
409
- break;
410
- case "nggallery-style" :
411
- wp_admin_css( 'css/theme-editor' );
412
- wp_enqueue_style('nggcolorpicker', NGGALLERY_URLPATH.'admin/js/colorpicker/css/colorpicker.css', false, '1.0', 'screen');
413
- wp_enqueue_style('nggadmincp', NGGALLERY_URLPATH.'admin/css/nggColorPicker.css', false, '1.0', 'screen');
414
- break;
415
- }
416
- }
417
-
418
- function show_help($help, $screen) {
419
-
420
- // since WP3.0 it's an object
421
- if ( is_object($screen) )
422
- $screen = $screen->id;
423
-
424
- $link = '';
425
- // menu title is localized...
426
- $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) );
427
-
428
- switch ($screen) {
429
- case 'toplevel_page_' . NGGFOLDER :
430
- $link = __('<a href="http://www.wpgetready.com" target="_blank">Introduction</a>', 'nggallery');
431
- break;
432
- case "{$i18n}_page_nggallery-about" :
433
- $link = __('<a href="http://www.nextgen-gallery.com/languages" target="_blank">Languages</a>', 'nggallery');
434
- break;
435
- }
436
-
437
- if ( !empty($link) ) {
438
- $help = '<h5>' . __('Get help with NextCellent Gallery', 'nggallery') . '</h5>';
439
- $help .= '<div class="metabox-prefs">';
440
- $help .= $link;
441
- $help .= "</div>\n";
442
- $help .= '<h5>' . __('More Help & Info', 'nggallery') . '</h5>';
443
- $help .= '<div class="metabox-prefs">';
444
- $help .= __('<a href="http://wordpress.org/tags/nextcellent-gallery-nextgen-legacy" target="_blank">Support Forums</a>', 'nggallery');
445
- // $help .= ' | <a href="http://www.nextgen-gallery.com/faq/" target="_blank">' . __('FAQ', 'nggallery') . '</a>';
446
- // $help .= ' | <a href="https://bitbucket.org/photocrati/nextgen-gallery/issues" target="_blank">' . __('Feature request', 'nggallery') . '</a>';
447
- // $help .= ' | <a href="http://www.nextgen-gallery.com/languages" target="_blank">' . __('Get your language pack', 'nggallery') . '</a>';
448
- // $help .= ' | <a href="https://bitbucket.org/photocrati/nextgen-gallery" target="_blank">' . __('Contribute development', 'nggallery') . '</a>';
449
- $help .= ' | <a href="http://wordpress.org/plugins/nextcellent-gallery-nextgen-legacy/" target="_blank">' . __('Download latest version', 'nggallery') . '</a>';
450
- $help .= "</div>\n";
451
- }
452
-
453
- return $help;
454
- }
455
-
456
- /**
457
- * New wrapper for WordPress 3.3, so contextual help will be added to the admin bar
458
- * Rework this see http://wpdevel.wordpress.com/2011/12/06/help-and-screen-api-changes-in-3-3/
459
- *
460
- * @since 1.9.0
461
- * @param object $screen
462
- * @return void
463
- */
464
- function add_contextual_help($screen) {
465
-
466
- $help = $this->show_help('', $screen);
467
- //add_contextual_help( $screen, $help );
468
- }
469
-
470
- /**
471
- * We need to manipulate the current_screen name so that we can show the correct column screen options
472
- *
473
- * @since 1.8.0
474
- * @param object $screen
475
- * @return object $screen
476
- */
477
- function edit_current_screen($screen) {
478
-
479
- if ( is_string($screen) )
480
- $screen = convert_to_screen($screen);
481
-
482
- // menu title is localized, so we need to change the toplevel name
483
- $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) );
484
-
485
- switch ($screen->id) {
486
- case "{$i18n}_page_nggallery-manage-gallery" :
487
- // we would like to have screen option only at the manage images / gallery page
488
- if ( isset ($_POST['sortGallery']) )
489
- $screen = $screen;
490
- else if ( (isset($_GET['mode']) && $_GET['mode'] == 'edit') || isset ($_POST['backToGallery']) )
491
- $screen->base = $screen->id = 'nggallery-manage-images';
492
- else if ( (isset($_GET['mode']) && $_GET['mode'] == 'sort') )
493
- $screen = $screen;
494
- else
495
- $screen->base = $screen->id = 'nggallery-manage-gallery';
496
- break;
497
- }
498
-
499
- if ( defined('IS_WP_3_3') )
500
- $this->add_contextual_help($screen);
501
-
502
- return $screen;
503
- }
504
-
505
- /**
506
- * We need to register the columns at a very early point
507
- *
508
- * @return void
509
- */
510
- function register_columns() {
511
- include_once ( dirname (__FILE__) . '/manage-images.php' );
512
-
513
- $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
514
-
515
- include_once ( dirname (__FILE__) . '/manage-galleries.php' );
516
-
517
- $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
518
- }
519
-
520
- /**
521
- * Read an array from a remote url
522
- *
523
- * @param string $url
524
- * @return array of the content
525
- */
526
- static function get_remote_array($url) {
527
-
528
- if ( function_exists('wp_remote_request') ) {
529
-
530
- if ( false === ( $content = get_transient( 'ngg_request_' . md5($url) ) ) ) {
531
-
532
- $options = array();
533
- $options['headers'] = array(
534
- 'User-Agent' => 'NextGEN Gallery Information Reader V' . NGGVERSION . '; (' . get_bloginfo('url') .')'
535
- );
536
-
537
- $response = wp_remote_request($url, $options);
538
-
539
- if ( is_wp_error( $response ) )
540
- return false;
541
-
542
- if ( 200 != $response['response']['code'] )
543
- return false;
544
-
545
- $content = $response['body'];
546
- set_transient( 'ngg_request_' . md5($url), $content, 60*60*48 );
547
- }
548
-
549
- $content = unserialize($content);
550
-
551
- if (is_array($content))
552
- return $content;
553
- }
554
-
555
- return false;
556
- }
557
-
558
- }
559
-
560
- function wpmu_site_admin() {
561
- // Check for site admin
562
- if ( function_exists('is_super_admin') )
563
- if ( is_super_admin() )
564
- return true;
565
-
566
- return false;
567
- }
568
-
569
- function wpmu_enable_function($value) {
570
- if (is_multisite()) {
571
- $ngg_options = get_site_option('ngg_options');
572
- return $ngg_options[$value];
573
- }
574
- // if this is not WPMU, enable it !
575
- return true;
576
- }
1
+ <?php
2
+ /**
3
+ * nggAdminPanel - Admin Section for NextGEN Gallery
4
+ *
5
+ * @package NextGEN Gallery
6
+ * @author Alex Rabe
7
+ *
8
+ * @since 1.0.0
9
+ */
10
+ class nggAdminPanel{
11
+
12
+ // constructor
13
+ function __construct() {
14
+
15
+ // Add the admin menu
16
+ add_action( 'admin_menu', array (&$this, 'add_menu') );
17
+ add_action( 'admin_bar_menu', array(&$this, 'admin_bar_menu'), 99 );
18
+ add_action( 'network_admin_menu', array (&$this, 'add_network_admin_menu') );
19
+
20
+ // Add the script and style files
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'));
32
+
33
+ // Add WPML hook to register description / alt text for translation
34
+ add_action('ngg_image_updated', array('nggGallery', 'RegisterString') );
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'>
103
+ window.onerror = function(msg, url, line){
104
+ if (url.match(/\.js$|\.js\?/)) {
105
+ if (window.location.search.length > 0) {
106
+ if (window.location.search.indexOf(url) == -1)
107
+ window.location.search += '&skipjs[{$skipjs_count}]='+url;
108
+ }
109
+ else {
110
+ window.location.search = '?skipjs[{$skipjs_count}]='+url;
111
+ }
112
+ }
113
+ return true;
114
+ };</script>\n",
115
+ $html
116
+ ));
117
+ }
118
+
119
+ echo $html;
120
+ }
121
+ }
122
+
123
+ // integrate the menu
124
+ function add_menu() {
125
+ add_menu_page( __( 'Galleries', 'nggallery' ), __( 'Galleries', 'nggallery' ), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'), 'dashicons-format-gallery' );
126
+ add_submenu_page( NGGFOLDER , __('Overview', 'nggallery'), __('Overview', 'nggallery'), 'NextGEN Gallery overview', NGGFOLDER, array (&$this, 'show_menu'));
127
+ add_submenu_page( NGGFOLDER , __('Add Gallery / Images', 'nggallery'), __('Add Gallery / Images', 'nggallery'), 'NextGEN Upload images', 'nggallery-add-gallery', array (&$this, 'show_menu'));
128
+ add_submenu_page( NGGFOLDER , __('Galleries', 'nggallery'), __('Galleries', 'nggallery'), 'NextGEN Manage gallery', 'nggallery-manage-gallery', array (&$this, 'show_menu'));
129
+ add_submenu_page( NGGFOLDER , __('Albums', 'nggallery'), __('Albums', 'nggallery'), 'NextGEN Edit album', 'nggallery-manage-album', array (&$this, 'show_menu'));
130
+ add_submenu_page( NGGFOLDER , __('Tags', 'nggallery'), __('Tags', 'nggallery'), 'NextGEN Manage tags', 'nggallery-tags', array (&$this, 'show_menu'));
131
+ add_submenu_page( NGGFOLDER , __('Settings', 'nggallery'), __('Settings', 'nggallery'), 'NextGEN Change options', 'nggallery-options', array (&$this, 'show_menu'));
132
+ if ( wpmu_enable_function('wpmuStyle') )
133
+ add_submenu_page( NGGFOLDER , __('Style', 'nggallery'), __('Style', 'nggallery'), 'NextGEN Change style', 'nggallery-style', array (&$this, 'show_menu'));
134
+ if ( wpmu_enable_function('wpmuRoles') || wpmu_site_admin() )
135
+ add_submenu_page( NGGFOLDER , __('Roles', 'nggallery'), __('Roles', 'nggallery'), 'activate_plugins', 'nggallery-roles', array (&$this, 'show_menu'));
136
+ add_submenu_page( NGGFOLDER , __('About this Gallery', 'nggallery'), __('About', 'nggallery'), 'NextGEN Gallery overview', 'nggallery-about', array (&$this, 'show_menu'));
137
+
138
+ if ( !is_multisite() || wpmu_site_admin() )
139
+ add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu'));
140
+
141
+ //register the column fields
142
+ $this->register_columns();
143
+ }
144
+
145
+ // integrate the network menu
146
+ function add_network_admin_menu() {
147
+
148
+ add_menu_page( __('Galleries', 'nggallery' ), __('Galleries', 'nggallery' ), 'nggallery-wpmu', NGGFOLDER, array (&$this, 'show_network_settings'), path_join(NGGALLERY_URLPATH, 'admin/images/nextgen_16_color.png') );
149
+ add_submenu_page( NGGFOLDER , __('Network settings', 'nggallery'), __('Network settings', 'nggallery'), 'nggallery-wpmu', NGGFOLDER, array (&$this, 'show_network_settings'));
150
+ add_submenu_page( NGGFOLDER , __('Reset / Uninstall', 'nggallery'), __('Reset / Uninstall', 'nggallery'), 'activate_plugins', 'nggallery-setup', array (&$this, 'show_menu'));
151
+ }
152
+
153
+ /**
154
+ * Adding NextGEN Gallery to the Admin bar
155
+ *
156
+ * @since 1.9.0
157
+ *
158
+ * @return void
159
+ */
160
+
161
+ function admin_bar_menu() {
162
+ // If the current user can't write posts, this is all of no use, so let's not output an admin menu
163
+ if ( !current_user_can('NextGEN Gallery overview') )
164
+ return;
165
+
166
+ global $wp_admin_bar;
167
+
168
+ $wp_admin_bar->add_menu( array( 'id' => 'ngg-menu', 'title' => __( 'Gallery' ), 'href' => admin_url('admin.php?page='. NGGFOLDER) ) );
169
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-overview', 'title' => __('Overview', 'nggallery'), 'href' => admin_url('admin.php?page='. NGGFOLDER) ) );
170
+ if ( current_user_can('NextGEN Upload images') )
171
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-add-gallery', 'title' => __('Add Gallery / Images', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-add-gallery') ) );
172
+ if ( current_user_can('NextGEN Manage gallery') )
173
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-manage-gallery', 'title' => __('Gallery', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-manage-gallery') ) );
174
+ if ( current_user_can('NextGEN Edit album') )
175
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-manage-album', 'title' => __( 'Albums', 'nggallery' ), 'href' => admin_url('admin.php?page=nggallery-manage-album') ) );
176
+ if ( current_user_can('NextGEN Manage tags') )
177
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-tags', 'title' => __('Tags', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-tags') ) );
178
+ if ( current_user_can('NextGEN Change options') )
179
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-options', 'title' => __('Settings', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-options') ) );
180
+ if ( wpmu_enable_function('wpmuStyle') && ( current_user_can('NextGEN Change style') ))
181
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-style', 'title' => __('Style', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-style') ) );
182
+ $wp_admin_bar->add_menu( array( 'parent' => 'ngg-menu', 'id' => 'ngg-menu-about', 'title' => __('About', 'nggallery'), 'href' => admin_url('admin.php?page=nggallery-about') ) );
183
+ }
184
+
185
+ // show the network page
186
+ function show_network_settings() {
187
+ include_once ( dirname (__FILE__) . '/style.php' );
188
+ include_once ( dirname (__FILE__) . '/wpmu.php' );
189
+ nggallery_wpmu_setup();
190
+ }
191
+
192
+ // load the script for the defined page and load only this code
193
+ function show_menu() {
194
+
195
+ global $ngg;
196
+
197
+ // Set installation date
198
+ if( empty($ngg->options['installDate']) ) {
199
+ $ngg->options['installDate'] = time();
200
+ update_option('ngg_options', $ngg->options);
201
+ }
202
+
203
+ // Show donation message only one time.
204
+ if (isset ( $_GET['hide_donation']) ) {
205
+ $ngg->options['hideDonation'] = true;
206
+ update_option('ngg_options', $ngg->options);
207
+ }
208
+
209
+ switch ($_GET['page']){
210
+ case "nggallery-add-gallery" :
211
+ include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
212
+ include_once ( dirname (__FILE__) . '/addgallery.php' ); // nggallery_admin_add_gallery
213
+ $ngg->addgallery_page = new nggAddGallery ();
214
+ $ngg->addgallery_page->controller();
215
+ break;
216
+ case "nggallery-manage-gallery" :
217
+ include_once ( dirname (__FILE__) . '/functions.php' ); // admin functions
218
+ include_once ( dirname (__FILE__) . '/manage.php' ); // nggallery_admin_manage_gallery
219
+ // Initate the Manage Gallery page
220
+ $ngg->manage_page = new nggManageGallery ();
221
+ // Render the output now, because you cannot access a object during the constructor is not finished
222
+ $ngg->manage_page->controller();
223
+ break;
224
+ case "nggallery-manage-album" :
225
+ include_once ( dirname (__FILE__) . '/album.php' ); // nggallery_admin_manage_album
226
+ $ngg->manage_album = new nggManageAlbum ();
227
+ $ngg->manage_album->controller();
228
+ break;
229
+ case "nggallery-options" :
230
+ include_once ( dirname (__FILE__) . '/settings.php' ); // nggallery_admin_options
231
+ $ngg->option_page = new nggOptions ();
232
+ $ngg->option_page->controller();
233
+ break;
234
+ case "nggallery-tags" :
235
+ include_once ( dirname (__FILE__) . '/tags.php' ); // nggallery_admin_tags
236
+ break;
237
+ case "nggallery-style" :
238
+ include_once ( dirname (__FILE__) . '/style.php' ); // nggallery_admin_style
239
+ nggallery_admin_style();
240
+ break;
241
+ case "nggallery-setup" :
242
+ include_once ( dirname (__FILE__) . '/setup.php' ); // nggallery_admin_setup
243
+ nggallery_admin_setup();
244
+ break;
245
+ case "nggallery-roles" :
246
+ include_once ( dirname (__FILE__) . '/roles.php' ); // nggallery_admin_roles
247
+ nggallery_admin_roles();
248
+ break;
249
+ case "nggallery-import" :
250
+ include_once ( dirname (__FILE__) . '/myimport.php' ); // nggallery_admin_import
251
+ nggallery_admin_import();
252
+ break;
253
+ case "nggallery-about" :
254
+ include_once ( dirname (__FILE__) . '/about.php' ); // nggallery_admin_about
255
+ nggallery_admin_about();
256
+ break;
257
+ case "nggallery" :
258
+ default :
259
+ include_once ( dirname (__FILE__) . '/overview.php' ); // nggallery_admin_overview
260
+ nggallery_admin_overview();
261
+ break;
262
+ }
263
+ }
264
+
265
+ function load_scripts() {
266
+ global $wp_version;
267
+
268
+ // no need to go on if it's not a plugin page
269
+ if( !isset($_GET['page']) )
270
+ return;
271
+
272
+ wp_register_script('ngg-ajax', NGGALLERY_URLPATH . 'admin/js/ngg.ajax.js', array('jquery'), '1.4.1');
273
+ wp_localize_script('ngg-ajax', 'nggAjaxSetup', array(
274
+ 'url' => admin_url('admin-ajax.php'),
275
+ 'action' => 'ngg_ajax_operation',
276
+ 'operation' => '',
277
+ 'nonce' => wp_create_nonce( 'ngg-ajax' ),
278
+ 'ids' => '',
279
+ 'permission' => __('You do not have the correct permission', 'nggallery'),
280
+ 'error' => __('Unexpected Error', 'nggallery'),
281
+ 'failure' => __('A failure occurred', 'nggallery')
282
+ ) );
283
+ wp_register_script( 'ngg-plupload-handler', NGGALLERY_URLPATH .'admin/js/plupload.handler.js', array('plupload-all'), '0.0.1' );
284
+ wp_localize_script( 'ngg-plupload-handler', 'pluploadL10n', array(
285
+ 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
286
+ 'file_exceeds_size_limit' => __('This file exceeds the maximum upload size for this site.'),
287
+ 'zero_byte_file' => __('This file is empty. Please try another.'),
288
+ 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
289
+ 'not_an_image' => __('This file is not an image. Please try another.'),
290
+ 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
291
+ 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
292
+ 'default_error' => __('An error occurred in the upload. Please try again later.'),
293
+ 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
294
+ 'upload_limit_exceeded' => __('You may only upload 1 file.'),
295
+ 'http_error' => __('HTTP error.'),
296
+ 'upload_failed' => __('Upload failed.'),
297
+ 'io_error' => __('IO error.'),
298
+ 'security_error' => __('Security error.'),
299
+ 'file_cancelled' => __('File canceled.'),
300
+ 'upload_stopped' => __('Upload stopped.'),
301
+ 'dismiss' => __('Dismiss'),
302
+ 'crunching' => __('Crunching&hellip;'),
303
+ 'deleted' => __('moved to the trash.'),
304
+ 'error_uploading' => __('&#8220;%s&#8221; has failed to upload due to an error')
305
+ ) );
306
+ wp_register_script('ngg-progressbar', NGGALLERY_URLPATH .'admin/js/ngg.progressbar.js', array('jquery'), '2.0.1');
307
+ wp_register_script('jquery-ui-autocomplete', NGGALLERY_URLPATH .'admin/js/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.15');
308
+
309
+ switch ($_GET['page']) {
310
+ case NGGFOLDER :
311
+ wp_enqueue_script( 'postbox' );
312
+ add_thickbox();
313
+ break;
314
+ case "nggallery-manage-gallery" :
315
+ wp_enqueue_script( 'postbox' );
316
+ wp_enqueue_script( 'ngg-ajax' );
317
+ wp_enqueue_script( 'ngg-progressbar' );
318
+ wp_enqueue_script( 'jquery-ui-dialog' );
319
+ wp_enqueue_script( 'jquery-ui-sortable' );
320
+ wp_enqueue_script( 'jquery-ui-datepicker' );
321
+ wp_register_script('shutter', NGGALLERY_URLPATH .'shutter/shutter-reloaded.js', false ,'1.3.2');
322
+ wp_localize_script('shutter', 'shutterSettings', array(
323
+ 'msgLoading' => __('L O A D I N G', 'nggallery'),
324
+ 'msgClose' => __('Click to Close', 'nggallery'),
325
+ 'imageCount' => '1'
326
+ ) );
327
+ wp_enqueue_script( 'shutter' );
328
+ break;
329
+ case "nggallery-manage-album" :
330
+ wp_enqueue_script( 'jquery-ui-autocomplete' );
331
+ wp_enqueue_script( 'jquery-ui-dialog' );
332
+ wp_enqueue_script( 'jquery-ui-sortable' );
333
+ wp_enqueue_script( 'ngg-autocomplete', NGGALLERY_URLPATH .'admin/js/ngg.autocomplete.js', array('jquery-ui-autocomplete'), '1.0.1');
334
+ break;
335
+ case "nggallery-options" :
336
+ wp_enqueue_script( 'jquery-ui-tabs' );
337
+ //wp_enqueue_script( 'ngg-colorpicker', NGGALLERY_URLPATH .'admin/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
338
+ break;
339
+ case "nggallery-add-gallery" :
340
+ wp_enqueue_script( 'jquery-ui-tabs' );
341
+ wp_enqueue_script( 'multifile', NGGALLERY_URLPATH .'admin/js/jquery.MultiFile.js', array('jquery'), '1.4.4' );
342
+ if ( defined('IS_WP_3_3') )
343
+ wp_enqueue_script( 'ngg-plupload-handler' );
344
+ else
345
+ wp_enqueue_script( 'ngg-swfupload-handler', NGGALLERY_URLPATH .'admin/js/swfupload.handler.js', array('jquery', 'swfupload'), '1.0.3' );
346
+ wp_enqueue_script( 'ngg-ajax' );
347
+ wp_enqueue_script( 'ngg-progressbar' );
348
+ wp_enqueue_script( 'jquery-ui-dialog' );
349
+ wp_enqueue_script( 'jqueryFileTree', NGGALLERY_URLPATH .'admin/js/jqueryFileTree/jqueryFileTree.js', array('jquery'), '1.0.1' );
350
+ break;
351
+ case "nggallery-style" :
352
+ wp_enqueue_script( 'codepress' );
353
+ wp_enqueue_script( 'ngg-colorpicker', NGGALLERY_URLPATH .'admin/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0');
354
+ break;
355
+
356
+ }
357
+ }
358
+
359
+ function load_styles() {
360
+ // load the icon for the navigation menu
361
+ wp_enqueue_style( 'nggmenu', NGGALLERY_URLPATH .'admin/css/menu.css', array() );
362
+ wp_register_style( 'nggadmin', NGGALLERY_URLPATH .'admin/css/nggadmin.css', false, '2.8.1', 'screen' );
363
+ wp_register_style( 'ngg-jqueryui', NGGALLERY_URLPATH .'admin/css/jquery.ui.css', false, '1.8.5', 'screen' );
364
+
365
+ // no need to go on if it's not a plugin page
366
+ if( !isset($_GET['page']) )
367
+ return;
368
+
369
+ switch ($_GET['page']) {
370
+ case NGGFOLDER :
371
+ wp_enqueue_style( 'thickbox' );
372
+ case "nggallery-about" :
373
+ wp_enqueue_style( 'nggadmin' );
374
+ //TODO:Remove after WP 3.3 release
375
+ if ( !defined('IS_WP_3_3') )
376
+ wp_admin_css( 'css/dashboard' );
377
+ break;
378
+ case "nggallery-add-gallery" :
379
+ wp_enqueue_style( 'ngg-jqueryui' );
380
+ wp_enqueue_style( 'jqueryFileTree', NGGALLERY_URLPATH .'admin/js/jqueryFileTree/jqueryFileTree.css', false, '1.0.1', 'screen' );
381
+ case "nggallery-options" :
382
+ wp_enqueue_style( 'nggtabs', NGGALLERY_URLPATH .'admin/css/jquery.ui.tabs.css', false, '2.5.0', 'screen' );
383
+ wp_enqueue_style( 'nggadmin' );
384
+ break;
385
+ case "nggallery-manage-gallery" :
386
+ wp_enqueue_style('shutter', NGGALLERY_URLPATH .'shutter/shutter-reloaded.css', false, '1.3.2', 'screen');
387
+ wp_enqueue_style( 'datepicker', NGGALLERY_URLPATH .'admin/css/jquery.ui.datepicker.css', false, '1.8.2', 'screen' );
388
+ case "nggallery-roles" :
389
+ case "nggallery-manage-album" :
390
+ wp_enqueue_style( 'ngg-jqueryui' );
391
+ wp_enqueue_style( 'nggadmin' );
392
+ break;
393
+ case "nggallery-tags" :
394
+ wp_enqueue_style( 'nggtags', NGGALLERY_URLPATH .'admin/css/tags-admin.css', false, '2.6.1', 'screen' );
395
+ break;
396
+ case "nggallery-style" :
397
+ wp_admin_css( 'css/theme-editor' );
398
+ wp_enqueue_style('nggcolorpicker', NGGALLERY_URLPATH.'admin/js/colorpicker/css/colorpicker.css', false, '1.0', 'screen');
399
+ wp_enqueue_style('nggadmincp', NGGALLERY_URLPATH.'admin/css/nggColorPicker.css', false, '1.0', 'screen');
400
+ break;
401
+ }
402
+ }
403
+
404
+ function show_help($help, $screen) {
405
+
406
+ // since WP3.0 it's an object
407
+ if ( is_object($screen) )
408
+ $screen = $screen->id;
409
+
410
+ $link = '';
411
+ // menu title is localized...
412
+ $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) );
413
+
414
+ switch ($screen) {
415
+ case 'toplevel_page_' . NGGFOLDER :
416
+ $link = __('<a href="http://www.wpgetready.com" target="_blank">Introduction</a>', 'nggallery');
417
+ break;
418
+ case "{$i18n}_page_nggallery-about" :
419
+ $link = __('<a href="http://www.nextgen-gallery.com/languages" target="_blank">Languages</a>', 'nggallery');
420
+ break;
421
+ }
422
+
423
+ if ( !empty($link) ) {
424
+ $help = '<h5>' . __('Get help with NextCellent Gallery', 'nggallery') . '</h5>';
425
+ $help .= '<div class="metabox-prefs">';
426
+ $help .= $link;
427
+ $help .= "</div>\n";
428
+ $help .= '<h5>' . __('More Help & Info', 'nggallery') . '</h5>';
429
+ $help .= '<div class="metabox-prefs">';
430
+ $help .= __('<a href="http://wordpress.org/tags/nextcellent-gallery-nextgen-legacy" target="_blank">Support Forums</a>', 'nggallery');
431
+ $help .= ' | <a href="http://wordpress.org/plugins/nextcellent-gallery-nextgen-legacy/" target="_blank">' . __('Download latest version', 'nggallery') . '</a>';
432
+ $help .= "</div>\n";
433
+ }
434
+
435
+ return $help;
436
+ }
437
+
438
+ /**
439
+ * New wrapper for WordPress 3.3, so contextual help will be added to the admin bar
440
+ * Rework this see http://wpdevel.wordpress.com/2011/12/06/help-and-screen-api-changes-in-3-3/
441
+ *
442
+ * @since 1.9.0
443
+ * @param object $screen
444
+ * @return void
445
+ */
446
+ function add_contextual_help($screen) {
447
+
448
+ $help = $this->show_help('', $screen);
449
+ //add_contextual_help( $screen, $help );
450
+ }
451
+
452
+ /**
453
+ * We need to manipulate the current_screen name so that we can show the correct column screen options
454
+ *
455
+ * @since 1.8.0
456
+ * @param object $screen
457
+ * @return object $screen
458
+ */
459
+ function edit_current_screen($screen) {
460
+
461
+ if ( is_string($screen) )
462
+ $screen = convert_to_screen($screen);
463
+
464
+ // menu title is localized, so we need to change the toplevel name
465
+ $i18n = strtolower ( _n( 'Gallery', 'Galleries', 1, 'nggallery' ) );
466
+
467
+ switch ($screen->id) {
468
+ case "{$i18n}_page_nggallery-manage-gallery" :
469
+ // we would like to have screen option only at the manage images / gallery page
470
+ if ( isset ($_POST['sortGallery']) )
471
+ $screen = $screen;
472
+ else if ( (isset($_GET['mode']) && $_GET['mode'] == 'edit') || isset ($_POST['backToGallery']) )
473
+ $screen->base = $screen->id = 'nggallery-manage-images';
474
+ else if ( (isset($_GET['mode']) && $_GET['mode'] == 'sort') )
475
+ $screen = $screen;
476
+ else
477
+ $screen->base = $screen->id = 'nggallery-manage-gallery';
478
+ break;
479
+ }
480
+
481
+ if ( defined('IS_WP_3_3') )
482
+ $this->add_contextual_help($screen);
483
+
484
+ return $screen;
485
+ }
486
+
487
+ /**
488
+ * We need to register the columns at a very early point
489
+ *
490
+ * @return void
491
+ */
492
+ function register_columns() {
493
+ include_once ( dirname (__FILE__) . '/manage-images.php' );
494
+
495
+ $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
496
+
497
+ include_once ( dirname (__FILE__) . '/manage-galleries.php' );
498
+
499
+ $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
500
+ }
501
+
502
+ /**
503
+ * Read an array from a remote url
504
+ *
505
+ * @param string $url
506
+ * @return array of the content
507
+ */
508
+ static function get_remote_array($url) {
509
+
510
+ if ( function_exists('wp_remote_request') ) {
511
+
512
+ if ( false === ( $content = get_transient( 'ngg_request_' . md5($url) ) ) ) {
513
+
514
+ $options = array();
515
+ $options['headers'] = array(
516
+ 'User-Agent' => 'NextGEN Gallery Information Reader V' . NGGVERSION . '; (' . get_bloginfo('url') .')'
517
+ );
518
+
519
+ $response = wp_remote_request($url, $options);
520
+
521
+ if ( is_wp_error( $response ) )
522
+ return false;
523
+
524
+ if ( 200 != $response['response']['code'] )
525
+ return false;
526
+
527
+ $content = $response['body'];
528
+ set_transient( 'ngg_request_' . md5($url), $content, 60*60*48 );
529
+ }
530
+
531
+ $content = unserialize($content);
532
+
533
+ if (is_array($content))
534
+ return $content;
535
+ }
536
+
537
+ return false;
538
+ }
539
+
540
+ }
541
+
542
+ function wpmu_site_admin() {
543
+ // Check for site admin
544
+ if ( function_exists('is_super_admin') )
545
+ if ( is_super_admin() )
546
+ return true;
547
+
548
+ return false;
549
+ }
550
+
551
+ function wpmu_enable_function($value) {
552
+ if (is_multisite()) {
553
+ $ngg_options = get_site_option('ngg_options');
554
+ return $ngg_options[$value];
555
+ }
556
+ // if this is not WPMU, enable it !
557
+ return true;
558
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/ajax.php CHANGED
@@ -1,433 +1,433 @@
1
- <?php
2
- add_action('wp_ajax_ngg_ajax_operation', 'ngg_ajax_operation' );
3
-
4
- /**
5
- * Image edit functions via AJAX
6
- *
7
- * @author Alex Rabe
8
- *
9
- *
10
- * @return void
11
- */
12
- function ngg_ajax_operation() {
13
-
14
- global $wpdb;
15
-
16
- // if nonce is not correct it returns -1
17
- check_ajax_referer( "ngg-ajax" );
18
-
19
- // check for correct capability
20
- if ( !is_user_logged_in() )
21
- die('-1');
22
-
23
- // check for correct NextGEN capability
24
- if ( !current_user_can('NextGEN Upload images') && !current_user_can('NextGEN Manage gallery') )
25
- die('-1');
26
-
27
- // include the ngg function
28
- include_once (dirname (__FILE__) . '/functions.php');
29
-
30
- // Get the image id
31
- if ( isset($_POST['image'])) {
32
- $id = (int) $_POST['image'];
33
- // let's get the image data
34
- $picture = nggdb::find_image( $id );
35
- // what do you want to do ?
36
- switch ( $_POST['operation'] ) {
37
- case 'create_thumbnail' :
38
- $result = nggAdmin::create_thumbnail($picture);
39
- break;
40
- case 'resize_image' :
41
- $result = nggAdmin::resize_image($picture);
42
- break;
43
- case 'rotate_cw' :
44
- $result = nggAdmin::rotate_image($picture, 'CW');
45
- nggAdmin::create_thumbnail($picture);
46
- break;
47
- case 'rotate_ccw' :
48
- $result = nggAdmin::rotate_image($picture, 'CCW');
49
- nggAdmin::create_thumbnail($picture);
50
- break;
51
- case 'set_watermark' :
52
- $result = nggAdmin::set_watermark($picture);
53
- break;
54
- case 'recover_image' :
55
- $result = nggAdmin::recover_image($picture);
56
- break;
57
- case 'import_metadata' :
58
- $result = nggAdmin::import_MetaData( $id );
59
- break;
60
- case 'get_image_ids' :
61
- $result = nggAdmin::get_image_ids( $id );
62
- break;
63
- default :
64
- do_action( 'ngg_ajax_' . $_POST['operation'] );
65
- die('-1');
66
- break;
67
- }
68
- // A success should return a '1'
69
- die ($result);
70
- }
71
-
72
- // The script should never stop here
73
- die('0');
74
- }
75
-
76
- add_action('wp_ajax_createNewThumb', 'createNewThumb');
77
-
78
- function createNewThumb() {
79
-
80
- global $ngg;
81
-
82
- // check for correct capability
83
- if ( !is_user_logged_in() )
84
- die('-1');
85
-
86
- // check for correct NextGEN capability
87
- if ( !current_user_can('NextGEN Manage gallery') )
88
- die('-1');
89
-
90
- include_once( nggGallery::graphic_library() );
91
-
92
- $id = (int) $_POST['id'];
93
- $picture = nggdb::find_image( $id );
94
-
95
- $x = round( $_POST['x'] * $_POST['rr'], 0);
96
- $y = round( $_POST['y'] * $_POST['rr'], 0);
97
- $w = round( $_POST['w'] * $_POST['rr'], 0);
98
- $h = round( $_POST['h'] * $_POST['rr'], 0);
99
-
100
- $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
101
-
102
- $thumb->crop($x, $y, $w, $h);
103
-
104
- // Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way
105
- if ($ngg->options['thumbfix']) {
106
- // check for portrait format
107
- if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
108
- // first resize to the wanted height, here changed to create_thumbnail()
109
- $thumb->resize(0, $ngg->options['thumbheight']);
110
- // get optimal y startpos
111
- $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
112
- $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
113
- } else {
114
- // first resize to the wanted width, here changed to create_thumbnail()
115
- $thumb->resize($ngg->options['thumbwidth'], 0);
116
- //
117
- // get optimal x startpos
118
- $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
119
- $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
120
- }
121
- //this create a thumbnail but keep ratio settings
122
- } else {
123
- $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
124
- }
125
-
126
- if ( $thumb->save($picture->thumbPath, 100)) {
127
-
128
- //read the new sizes
129
- $new_size = @getimagesize ( $picture->thumbPath );
130
- $size['width'] = $new_size[0];
131
- $size['height'] = $new_size[1];
132
-
133
- // add them to the database
134
- nggdb::update_image_meta($picture->pid, array( 'thumbnail' => $size) );
135
-
136
- echo "OK";
137
- } else {
138
- header('HTTP/1.1 500 Internal Server Error');
139
- echo "KO";
140
- }
141
-
142
- exit();
143
-
144
- }
145
-
146
- add_action('wp_ajax_rotateImage', 'ngg_rotateImage');
147
-
148
- function ngg_rotateImage() {
149
-
150
- // check for correct capability
151
- if ( !is_user_logged_in() )
152
- die('-1');
153
-
154
- // check for correct NextGEN capability
155
- if ( !current_user_can('NextGEN Manage gallery') )
156
- die('-1');
157
-
158
- require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
159
-
160
- // include the ngg function
161
- include_once (dirname (__FILE__). '/functions.php');
162
-
163
- $ngg_options = get_option('ngg_options');
164
-
165
- $id = (int) $_POST['id'];
166
- $result = '-1';
167
-
168
- switch ( $_POST['ra'] ) {
169
- case 'cw' :
170
- $result = nggAdmin::rotate_image($id, 'CW');
171
- break;
172
- case 'ccw' :
173
- $result = nggAdmin::rotate_image($id, 'CCW');
174
- break;
175
- case 'fv' :
176
- $result = nggAdmin::rotate_image($id, 0, 'V');
177
- break;
178
- case 'fh' :
179
- $result = nggAdmin::rotate_image($id, 0, 'H');
180
- break;
181
- }
182
-
183
- // recreate the thumbnail
184
- nggAdmin::create_thumbnail($id);
185
-
186
- if ( $result == 1 )
187
- die('1');
188
-
189
- header('HTTP/1.1 500 Internal Server Error');
190
- die( $result );
191
-
192
- }
193
-
194
- add_action('wp_ajax_ngg_dashboard', 'ngg_ajax_dashboard');
195
-
196
- function ngg_ajax_dashboard() {
197
-
198
- require_once( dirname( dirname(__FILE__) ) . '/admin/admin.php');
199
- require_once( dirname( dirname(__FILE__) ) . '/admin/overview.php');
200
-
201
- if ( !current_user_can('NextGEN Gallery overview') )
202
- die('-1');
203
-
204
- @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
205
- @header( 'X-Content-Type-Options: nosniff' );
206
-
207
- switch ( $_GET['jax'] ) {
208
-
209
- case 'ngg_lastdonators' :
210
- ngg_overview_donators();
211
- break;
212
-
213
- case 'dashboard_primary' :
214
- ngg_overview_news();
215
- break;
216
-
217
- case 'ngg_locale' :
218
- ngg_locale();
219
- break;
220
-
221
- case 'dashboard_plugins' :
222
- ngg_related_plugins();
223
- break;
224
-
225
- }
226
- die();
227
- }
228
-
229
- add_action('wp_ajax_ngg_file_browser', 'ngg_ajax_file_browser');
230
-
231
- /**
232
- * jQuery File Tree PHP Connector
233
- * @author Cory S.N. LaViska - A Beautiful Site (http://abeautifulsite.net/)
234
- * @version 1.0.1
235
- * 20131003: removed PHP4 compatibility code.
236
- * @return string folder content
237
- */
238
- function ngg_ajax_file_browser() {
239
-
240
- global $ngg;
241
-
242
- // check for correct NextGEN capability
243
- if ( !current_user_can('NextGEN Upload images') && !current_user_can('NextGEN Manage gallery') )
244
- die('No access');
245
-
246
- if ( !defined('ABSPATH') )
247
- die('No access');
248
-
249
- // if nonce is not correct it returns -1
250
- check_ajax_referer( 'ngg-ajax', 'nonce' );
251
-
252
- // start from the default path
253
- $root = trailingslashit ( WINABSPATH );
254
- // get the current directory
255
- $dir = trailingslashit ( urldecode($_POST['dir']) );
256
-
257
- if( file_exists($root . $dir) ) {
258
- $files = scandir($root . $dir);
259
- natcasesort($files);
260
-
261
- // The 2 counts for . and ..
262
- if( count($files) > 2 ) {
263
- echo "<ul class=\"jqueryDirTree\" style=\"display: none;\">";
264
-
265
- // return only directories
266
- foreach( $files as $file ) {
267
-
268
- //reserved name for the thumnbnails, don't use it as folder name
269
- if ( $file == 'thumbs')
270
- continue;
271
-
272
- if ( file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file) ) {
273
- echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . esc_html($dir . $file) . "/\">" . esc_html($file) . "</a></li>";
274
- }
275
- }
276
-
277
- echo "</ul>";
278
- }
279
- }
280
-
281
- die();
282
- }
283
-
284
- add_action('wp_ajax_ngg_tinymce', 'ngg_ajax_tinymce');
285
- /**
286
- * Call TinyMCE window content via admin-ajax
287
- *
288
- * @since 1.7.0
289
- * @return html content
290
- */
291
- function ngg_ajax_tinymce() {
292
-
293
- // check for rights
294
- if ( !current_user_can('edit_pages') && !current_user_can('edit_posts') )
295
- die(__("You are not allowed to be here"));
296
-
297
- include_once( dirname( dirname(__FILE__) ) . '/admin/tinymce/window.php');
298
-
299
- throw new E_Clean_Exit();
300
- }
301
-
302
- add_action( 'wp_ajax_ngg_rebuild_unique_slugs', 'ngg_ajax_rebuild_unique_slugs' );
303
- /**
304
- * This rebuild the slugs for albums, galleries and images as ajax routine, max 50 elements per request
305
- *
306
- * @since 1.7.0
307
- * @return string '1'
308
- */
309
- function ngg_ajax_rebuild_unique_slugs() {
310
- global $wpdb;
311
-
312
- // check for correct NextGEN capability
313
- if ( !current_user_can('NextGEN Change options') )
314
- die('No access');
315
-
316
- $action = $_POST['_action'];
317
- $offset = (int) $_POST['offset'];
318
-
319
- switch ($action) {
320
- case 'images':
321
- $images = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures ORDER BY pid ASC LIMIT $offset, 50", OBJECT_K);
322
- if ( is_array($images) ) {
323
- foreach ($images as $image) {
324
- //slug must be unique, we use the alttext for that
325
- $image->slug = nggdb::get_unique_slug( sanitize_title( $image->alttext ), 'image', $image->pid );
326
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggpictures SET image_slug= '%s' WHERE pid = '%d'" , $image->slug, $image->pid ) );
327
- }
328
- }
329
- break;
330
- case 'gallery':
331
- $galleries = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY gid ASC LIMIT $offset, 50", OBJECT_K);
332
- if ( is_array($galleries) ) {
333
- foreach ($galleries as $gallery) {
334
- //slug must be unique, we use the title for that
335
- $gallery->slug = nggdb::get_unique_slug( sanitize_title( $gallery->title ), 'gallery', $gallery->gid );
336
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggallery SET slug= '%s' WHERE gid = '%d'" , $gallery->slug, $gallery->gid ) );
337
- }
338
- }
339
- break;
340
- case 'album':
341
- $albumlist = $wpdb->get_results("SELECT * FROM $wpdb->nggalbum ORDER BY id ASC LIMIT $offset, 50", OBJECT_K);
342
- if ( is_array($albumlist) ) {
343
- foreach ($albumlist as $album) {
344
- //slug must be unique, we use the name for that
345
- $album->slug = nggdb::get_unique_slug( sanitize_title( $album->name ), 'album', $album->id );
346
- $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggalbum SET slug= '%s' WHERE id = '%d'" , $album->slug, $album->id ) );
347
- }
348
- }
349
- break;
350
- }
351
-
352
- die(1);
353
- }
354
- add_action('wp_ajax_ngg_image_check', 'ngg_ajax_image_check');
355
- /**
356
- * Test for various image resolution
357
- *
358
- * @since 1.7.3
359
- * @return result
360
- */
361
- function ngg_ajax_image_check() {
362
-
363
- // check for correct NextGEN capability
364
- if ( !current_user_can('NextGEN Upload images') )
365
- die('No access');
366
-
367
- if ( !defined('ABSPATH') )
368
- die('No access');
369
-
370
- $step = (int) $_POST['step'];
371
-
372
- // build the test sizes
373
- $sizes = array();
374
- $sizes[1] = array ( 'width' => 800, 'height' => 600);
375
- $sizes[2] = array ( 'width' => 1024, 'height' => 768);
376
- $sizes[3] = array ( 'width' => 1280, 'height' => 960); // 1MP
377
- $sizes[4] = array ( 'width' => 1600, 'height' => 1200); // 2MP
378
- $sizes[5] = array ( 'width' => 2016, 'height' => 1512); // 3MP
379
- $sizes[6] = array ( 'width' => 2272, 'height' => 1704); // 4MP
380
- $sizes[7] = array ( 'width' => 2560, 'height' => 1920); // 5MP
381
- $sizes[8] = array ( 'width' => 2848, 'height' => 2136); // 6MP
382
- $sizes[9] = array ( 'width' => 3072, 'height' => 2304); // 7MP
383
- $sizes[10] = array ( 'width' => 3264, 'height' => 2448); // 8MP
384
- $sizes[11] = array ( 'width' => 4048, 'height' => 3040); // 12MP
385
-
386
- if ( $step < 1 || $step > 11 )
387
- die('No vaild value');
388
-
389
- // let's test each image size
390
- $temp = imagecreatetruecolor ($sizes[$step]['width'], $sizes[$step]['height'] );
391
- imagedestroy ($temp);
392
-
393
- $result = array ('stat' => 'ok', 'message' => sprintf(__('Could create image with %s x %s pixel', 'nggallery'), $sizes[$step]['width'], $sizes[$step]['height'] ) );
394
-
395
- header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
396
- echo json_encode($result);
397
-
398
- die();
399
- }
400
-
401
- add_action('wp_ajax_ngg_test_head_footer', 'ngg_ajax_test_head_footer');
402
- /**
403
- * Check for the header / footer, parts taken from Matt Martz (http://sivel.net/)
404
- *
405
- * @see https://gist.github.com/378450
406
- * @since 1.7.3
407
- * @return result
408
- */
409
- function ngg_ajax_test_head_footer() {
410
-
411
- // Build the url to call, NOTE: uses home_url and thus requires WordPress 3.0
412
- $url = add_query_arg( array( 'test-head' => '', 'test-footer' => '' ), home_url() );
413
- // Perform the HTTP GET ignoring SSL errors
414
- $response = wp_remote_get( $url, array( 'sslverify' => false ) );
415
- // Grab the response code and make sure the request was sucessful
416
- $code = (int) wp_remote_retrieve_response_code( $response );
417
- if ( $code == 200 ) {
418
- global $head_footer_errors;
419
- $head_footer_errors = array();
420
-
421
- // Strip all tabs, line feeds, carriage returns and spaces
422
- $html = preg_replace( '/[\t\r\n\s]/', '', wp_remote_retrieve_body( $response ) );
423
-
424
- // Check to see if we found the existence of wp_head
425
- if ( ! strstr( $html, '<!--wp_head-->' ) )
426
- die('Missing the call to wp_head() in your theme, contact the theme author');
427
- // Check to see if we found the existence of wp_footer
428
- if ( ! strstr( $html, '<!--wp_footer-->' ) )
429
- die('Missing the call to wp_footer() in your theme, contact the theme author');
430
- }
431
- die('success');
432
- }
433
- ?>
1
+ <?php
2
+ add_action('wp_ajax_ngg_ajax_operation', 'ngg_ajax_operation' );
3
+
4
+ /**
5
+ * Image edit functions via AJAX
6
+ *
7
+ * @author Alex Rabe
8
+ *
9
+ *
10
+ * @return void
11
+ */
12
+ function ngg_ajax_operation() {
13
+
14
+ global $wpdb;
15
+
16
+ // if nonce is not correct it returns -1
17
+ check_ajax_referer( "ngg-ajax" );
18
+
19
+ // check for correct capability
20
+ if ( !is_user_logged_in() )
21
+ die('-1');
22
+
23
+ // check for correct NextGEN capability
24
+ if ( !current_user_can('NextGEN Upload images') && !current_user_can('NextGEN Manage gallery') )
25
+ die('-1');
26
+
27
+ // include the ngg function
28
+ include_once (dirname (__FILE__) . '/functions.php');
29
+
30
+ // Get the image id
31
+ if ( isset($_POST['image'])) {
32
+ $id = (int) $_POST['image'];
33
+ // let's get the image data
34
+ $picture = nggdb::find_image( $id );
35
+ // what do you want to do ?
36
+ switch ( $_POST['operation'] ) {
37
+ case 'create_thumbnail' :
38
+ $result = nggAdmin::create_thumbnail($picture);
39
+ break;
40
+ case 'resize_image' :
41
+ $result = nggAdmin::resize_image($picture);
42
+ break;
43
+ case 'rotate_cw' :
44
+ $result = nggAdmin::rotate_image($picture, 'CW');
45
+ nggAdmin::create_thumbnail($picture);
46
+ break;
47
+ case 'rotate_ccw' :
48
+ $result = nggAdmin::rotate_image($picture, 'CCW');
49
+ nggAdmin::create_thumbnail($picture);
50
+ break;
51
+ case 'set_watermark' :
52
+ $result = nggAdmin::set_watermark($picture);
53
+ break;
54
+ case 'recover_image' :
55
+ $result = nggAdmin::recover_image($picture);
56
+ break;
57
+ case 'import_metadata' :
58
+ $result = nggAdmin::import_MetaData( $id );
59
+ break;
60
+ case 'get_image_ids' :
61
+ $result = nggAdmin::get_image_ids( $id );
62
+ break;
63
+ default :
64
+ do_action( 'ngg_ajax_' . $_POST['operation'] );
65
+ die('-1');
66
+ break;
67
+ }
68
+ // A success should return a '1'
69
+ die ($result);
70
+ }
71
+
72
+ // The script should never stop here
73
+ die('0');
74
+ }
75
+
76
+ add_action('wp_ajax_createNewThumb', 'createNewThumb');
77
+
78
+ function createNewThumb() {
79
+
80
+ global $ngg;
81
+
82
+ // check for correct capability
83
+ if ( !is_user_logged_in() )
84
+ die('-1');
85
+
86
+ // check for correct NextGEN capability
87
+ if ( !current_user_can('NextGEN Manage gallery') )
88
+ die('-1');
89
+
90
+ include_once( nggGallery::graphic_library() );
91
+
92
+ $id = (int) $_POST['id'];
93
+ $picture = nggdb::find_image( $id );
94
+
95
+ $x = round( $_POST['x'] * $_POST['rr'], 0);
96
+ $y = round( $_POST['y'] * $_POST['rr'], 0);
97
+ $w = round( $_POST['w'] * $_POST['rr'], 0);
98
+ $h = round( $_POST['h'] * $_POST['rr'], 0);
99
+
100
+ $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
101
+
102
+ $thumb->crop($x, $y, $w, $h);
103
+
104
+ // Note : the routine is a bit different to create_thumbnail(), due to rounding it's resized in the other way
105
+ if ($ngg->options['thumbfix']) {
106
+ // check for portrait format
107
+ if ($thumb->currentDimensions['height'] > $thumb->currentDimensions['width']) {
108
+ // first resize to the wanted height, here changed to create_thumbnail()
109
+ $thumb->resize(0, $ngg->options['thumbheight']);
110
+ // get optimal y startpos
111
+ $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
112
+ $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
113
+ } else {
114
+ // first resize to the wanted width, here changed to create_thumbnail()
115
+ $thumb->resize($ngg->options['thumbwidth'], 0);
116
+ //
117
+ // get optimal x startpos
118
+ $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
119
+ $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
120
+ }
121
+ //this create a thumbnail but keep ratio settings
122
+ } else {
123
+ $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
124
+ }
125
+
126
+ if ( $thumb->save($picture->thumbPath, 100)) {
127
+
128
+ //read the new sizes
129
+ $new_size = @getimagesize ( $picture->thumbPath );
130
+ $size['width'] = $new_size[0];
131
+ $size['height'] = $new_size[1];
132
+
133
+ // add them to the database
134
+ nggdb::update_image_meta($picture->pid, array( 'thumbnail' => $size) );
135
+
136
+ echo "OK";
137
+ } else {
138
+ header('HTTP/1.1 500 Internal Server Error');
139
+ echo "KO";
140
+ }
141
+
142
+ exit();
143
+
144
+ }
145
+
146
+ add_action('wp_ajax_rotateImage', 'ngg_rotateImage');
147
+
148
+ function ngg_rotateImage() {
149
+
150
+ // check for correct capability
151
+ if ( !is_user_logged_in() )
152
+ die('-1');
153
+
154
+ // check for correct NextGEN capability
155
+ if ( !current_user_can('NextGEN Manage gallery') )
156
+ die('-1');
157
+
158
+ require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
159
+
160
+ // include the ngg function
161
+ include_once (dirname (__FILE__). '/functions.php');
162
+
163
+ $ngg_options = get_option('ngg_options');
164
+
165
+ $id = (int) $_POST['id'];
166
+ $result = '-1';
167
+
168
+ switch ( $_POST['ra'] ) {
169
+ case 'cw' :
170
+ $result = nggAdmin::rotate_image($id, 'CW');
171
+ break;
172
+ case 'ccw' :
173
+ $result = nggAdmin::rotate_image($id, 'CCW');
174
+ break;
175
+ case 'fv' :
176
+ $result = nggAdmin::rotate_image($id, 0, 'V');
177
+ break;
178
+ case 'fh' :
179
+ $result = nggAdmin::rotate_image($id, 0, 'H');
180
+ break;
181
+ }
182
+
183
+ // recreate the thumbnail
184
+ nggAdmin::create_thumbnail($id);
185
+
186
+ if ( $result == 1 )
187
+ die('1');
188
+
189
+ header('HTTP/1.1 500 Internal Server Error');
190
+ die( $result );
191
+
192
+ }
193
+
194
+ add_action('wp_ajax_ngg_dashboard', 'ngg_ajax_dashboard');
195
+
196
+ function ngg_ajax_dashboard() {
197
+
198
+ require_once( dirname( dirname(__FILE__) ) . '/admin/admin.php');
199
+ require_once( dirname( dirname(__FILE__) ) . '/admin/overview.php');
200
+
201
+ if ( !current_user_can('NextGEN Gallery overview') )
202
+ die('-1');
203
+
204
+ @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
205
+ @header( 'X-Content-Type-Options: nosniff' );
206
+
207
+ switch ( $_GET['jax'] ) {
208
+
209
+ case 'ngg_lastdonators' :
210
+ ngg_overview_donators();
211
+ break;
212
+
213
+ case 'dashboard_primary' :
214
+ ngg_overview_news();
215
+ break;
216
+
217
+ case 'ngg_locale' :
218
+ ngg_locale();
219
+ break;
220
+
221
+ case 'dashboard_plugins' :
222
+ ngg_related_plugins();
223
+ break;
224
+
225
+ }
226
+ die();
227
+ }
228
+
229
+ add_action('wp_ajax_ngg_file_browser', 'ngg_ajax_file_browser');
230
+
231
+ /**
232
+ * jQuery File Tree PHP Connector
233
+ * @author Cory S.N. LaViska - A Beautiful Site (http://abeautifulsite.net/)
234
+ * @version 1.0.1
235
+ * 20131003: removed PHP4 compatibility code.
236
+ * @return string folder content
237
+ */
238
+ function ngg_ajax_file_browser() {
239
+
240
+ global $ngg;
241
+
242
+ // check for correct NextGEN capability
243
+ if ( !current_user_can('NextGEN Upload images') && !current_user_can('NextGEN Manage gallery') )
244
+ die('No access');
245
+
246
+ if ( !defined('ABSPATH') )
247
+ die('No access');
248
+
249
+ // if nonce is not correct it returns -1
250
+ check_ajax_referer( 'ngg-ajax', 'nonce' );
251
+
252
+ // start from the default path
253
+ $root = trailingslashit ( WINABSPATH );
254
+ // get the current directory
255
+ $dir = trailingslashit ( urldecode($_POST['dir']) );
256
+
257
+ if( file_exists($root . $dir) ) {
258
+ $files = scandir($root . $dir);
259
+ natcasesort($files);
260
+
261
+ // The 2 counts for . and ..
262
+ if( count($files) > 2 ) {
263
+ echo "<ul class=\"jqueryDirTree\" style=\"display: none;\">";
264
+
265
+ // return only directories
266
+ foreach( $files as $file ) {
267
+
268
+ //reserved name for the thumnbnails, don't use it as folder name
269
+ if ( $file == 'thumbs')
270
+ continue;
271
+
272
+ if ( file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file) ) {
273
+ echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . esc_html($dir . $file) . "/\">" . esc_html($file) . "</a></li>";
274
+ }
275
+ }
276
+
277
+ echo "</ul>";
278
+ }
279
+ }
280
+
281
+ die();
282
+ }
283
+
284
+ add_action('wp_ajax_ngg_tinymce', 'ngg_ajax_tinymce');
285
+ /**
286
+ * Call TinyMCE window content via admin-ajax
287
+ *
288
+ * @since 1.7.0
289
+ * @return html content
290
+ */
291
+ function ngg_ajax_tinymce() {
292
+
293
+ // check for rights
294
+ if ( !current_user_can('edit_pages') && !current_user_can('edit_posts') )
295
+ die(__("You are not allowed to be here"));
296
+
297
+ include_once( dirname( dirname(__FILE__) ) . '/admin/tinymce/window.php');
298
+
299
+ throw new E_Clean_Exit();
300
+ }
301
+
302
+ add_action( 'wp_ajax_ngg_rebuild_unique_slugs', 'ngg_ajax_rebuild_unique_slugs' );
303
+ /**
304
+ * This rebuild the slugs for albums, galleries and images as ajax routine, max 50 elements per request
305
+ *
306
+ * @since 1.7.0
307
+ * @return string '1'
308
+ */
309
+ function ngg_ajax_rebuild_unique_slugs() {
310
+ global $wpdb;
311
+
312
+ // check for correct NextGEN capability
313
+ if ( !current_user_can('NextGEN Change options') )
314
+ die('No access');
315
+
316
+ $action = $_POST['_action'];
317
+ $offset = (int) $_POST['offset'];
318
+
319
+ switch ($action) {
320
+ case 'images':
321
+ $images = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures ORDER BY pid ASC LIMIT $offset, 50", OBJECT_K);
322
+ if ( is_array($images) ) {
323
+ foreach ($images as $image) {
324
+ //slug must be unique, we use the alttext for that
325
+ $image->slug = nggdb::get_unique_slug( sanitize_title( $image->alttext ), 'image', $image->pid );
326
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggpictures SET image_slug= '%s' WHERE pid = '%d'" , $image->slug, $image->pid ) );
327
+ }
328
+ }
329
+ break;
330
+ case 'gallery':
331
+ $galleries = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY gid ASC LIMIT $offset, 50", OBJECT_K);
332
+ if ( is_array($galleries) ) {
333
+ foreach ($galleries as $gallery) {
334
+ //slug must be unique, we use the title for that
335
+ $gallery->slug = nggdb::get_unique_slug( sanitize_title( $gallery->title ), 'gallery', $gallery->gid );
336
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggallery SET slug= '%s' WHERE gid = '%d'" , $gallery->slug, $gallery->gid ) );
337
+ }
338
+ }
339
+ break;
340
+ case 'album':
341
+ $albumlist = $wpdb->get_results("SELECT * FROM $wpdb->nggalbum ORDER BY id ASC LIMIT $offset, 50", OBJECT_K);
342
+ if ( is_array($albumlist) ) {
343
+ foreach ($albumlist as $album) {
344
+ //slug must be unique, we use the name for that
345
+ $album->slug = nggdb::get_unique_slug( sanitize_title( $album->name ), 'album', $album->id );
346
+ $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggalbum SET slug= '%s' WHERE id = '%d'" , $album->slug, $album->id ) );
347
+ }
348
+ }
349
+ break;
350
+ }
351
+
352
+ die(1);
353
+ }
354
+ add_action('wp_ajax_ngg_image_check', 'ngg_ajax_image_check');
355
+ /**
356
+ * Test for various image resolution
357
+ *
358
+ * @since 1.7.3
359
+ * @return result
360
+ */
361
+ function ngg_ajax_image_check() {
362
+
363
+ // check for correct NextGEN capability
364
+ if ( !current_user_can('NextGEN Upload images') )
365
+ die('No access');
366
+
367
+ if ( !defined('ABSPATH') )
368
+ die('No access');
369
+
370
+ $step = (int) $_POST['step'];
371
+
372
+ // build the test sizes
373
+ $sizes = array();
374
+ $sizes[1] = array ( 'width' => 800, 'height' => 600);
375
+ $sizes[2] = array ( 'width' => 1024, 'height' => 768);
376
+ $sizes[3] = array ( 'width' => 1280, 'height' => 960); // 1MP
377
+ $sizes[4] = array ( 'width' => 1600, 'height' => 1200); // 2MP
378
+ $sizes[5] = array ( 'width' => 2016, 'height' => 1512); // 3MP
379
+ $sizes[6] = array ( 'width' => 2272, 'height' => 1704); // 4MP
380
+ $sizes[7] = array ( 'width' => 2560, 'height' => 1920); // 5MP
381
+ $sizes[8] = array ( 'width' => 2848, 'height' => 2136); // 6MP
382
+ $sizes[9] = array ( 'width' => 3072, 'height' => 2304); // 7MP
383
+ $sizes[10] = array ( 'width' => 3264, 'height' => 2448); // 8MP
384
+ $sizes[11] = array ( 'width' => 4048, 'height' => 3040); // 12MP
385
+
386
+ if ( $step < 1 || $step > 11 )
387
+ die('No vaild value');
388
+
389
+ // let's test each image size
390
+ $temp = imagecreatetruecolor ($sizes[$step]['width'], $sizes[$step]['height'] );
391
+ imagedestroy ($temp);
392
+
393
+ $result = array ('stat' => 'ok', 'message' => sprintf(__('Could create image with %s x %s pixel', 'nggallery'), $sizes[$step]['width'], $sizes[$step]['height'] ) );
394
+
395
+ header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
396
+ echo json_encode($result);
397
+
398
+ die();
399
+ }
400
+
401
+ add_action('wp_ajax_ngg_test_head_footer', 'ngg_ajax_test_head_footer');
402
+ /**
403
+ * Check for the header / footer, parts taken from Matt Martz (http://sivel.net/)
404
+ *
405
+ * @see https://gist.github.com/378450
406
+ * @since 1.7.3
407
+ * @return result
408
+ */
409
+ function ngg_ajax_test_head_footer() {
410
+
411
+ // Build the url to call, NOTE: uses home_url and thus requires WordPress 3.0
412
+ $url = add_query_arg( array( 'test-head' => '', 'test-footer' => '' ), home_url() );
413
+ // Perform the HTTP GET ignoring SSL errors
414
+ $response = wp_remote_get( $url, array( 'sslverify' => false ) );
415
+ // Grab the response code and make sure the request was sucessful
416
+ $code = (int) wp_remote_retrieve_response_code( $response );
417
+ if ( $code == 200 ) {
418
+ global $head_footer_errors;
419
+ $head_footer_errors = array();
420
+
421
+ // Strip all tabs, line feeds, carriage returns and spaces
422
+ $html = preg_replace( '/[\t\r\n\s]/', '', wp_remote_retrieve_body( $response ) );
423
+
424
+ // Check to see if we found the existence of wp_head
425
+ if ( ! strstr( $html, '<!--wp_head-->' ) )
426
+ die('Missing the call to wp_head() in your theme, contact the theme author');
427
+ // Check to see if we found the existence of wp_footer
428
+ if ( ! strstr( $html, '<!--wp_footer-->' ) )
429
+ die('Missing the call to wp_footer() in your theme, contact the theme author');
430
+ }
431
+ die('success');
432
+ }
433
+ ?>
admin/album.php CHANGED
@@ -1,589 +1,586 @@
1
- <?php
2
-
3
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
-
5
- class nggManageAlbum {
6
-
7
- /**
8
- * The selected album ID
9
- *
10
- * @since 1.3.0
11
- * @access privat
12
- * @var int
13
- */
14
- var $currentID = 0;
15
-
16
- /**
17
- * The array for the galleries
18
- *
19
- * @since 1.3.0
20
- * @access privat
21
- * @var array
22
- */
23
- var $galleries = false;
24
-
25
- /**
26
- * The array for the albums
27
- *
28
- * @since 1.3.0
29
- * @access privat
30
- * @var array
31
- */
32
- var $albums = false;
33
-
34
- /**
35
- * The amount of all galleries
36
- *
37
- * @since 1.4.0
38
- * @access privat
39
- * @var int
40
- */
41
- var $num_galleries = false;
42
-
43
- /**
44
- * The amount of all albums
45
- *
46
- * @since 1.4.0
47
- * @access privat
48
- * @var int
49
- */
50
- var $num_albums = false;
51
-
52
- /**
53
- * Init the album output
54
- *
55
- */
56
- function __construct() {
57
- return true;
58
- }
59
-
60
- function controller() {
61
- global $nggdb;
62
-
63
- $this->currentID = isset($_REQUEST['act_album']) ? (int) $_REQUEST['act_album'] : 0 ;
64
-
65
- if (isset ($_POST['update']) || isset( $_POST['delete'] ) || isset( $_POST['add'] ) )
66
- $this->processor();
67
-
68
- if (isset ($_POST['update_album']) )
69
- $this->update_album();
70
-
71
- // get first all galleries & albums
72
- $this->albums = $nggdb->find_all_album();
73
- $this->galleries = $nggdb->find_all_galleries();
74
- $this->num_albums = count( $this->albums );
75
- $this->num_galleries = count( $this->galleries );
76
- $this->output();
77
-
78
- }
79
-
80
- function processor() {
81
- global $wpdb;
82
-
83
- check_admin_referer('ngg_album');
84
-
85
- if ( isset($_POST['add']) && isset ($_POST['newalbum']) ) {
86
-
87
- if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' ))
88
- wp_die(__('Cheatin&#8217; uh?'));
89
-
90
- $result = nggdb::add_album( $_POST['newalbum'] );
91
- $this->currentID = ($result) ? $result : 0 ;
92
-
93
- //hook for other plugins
94
- do_action('ngg_add_album', $this->currentID);
95
-
96
- if ($result)
97
- nggGallery::show_message(__('Update Successfully','nggallery'));
98
- }
99
-
100
- if ( isset($_POST['update']) && ($this->currentID > 0) ) {
101
-
102
- $gid = '';
103
-
104
- // get variable galleryContainer
105
- parse_str($_POST['sortorder']);
106
- if ( is_array($gid) ){
107
- $serial_sort = serialize($gid);
108
- $wpdb->query("UPDATE $wpdb->nggalbum SET sortorder = '$serial_sort' WHERE id = $this->currentID ");
109
- } else {
110
- $wpdb->query("UPDATE $wpdb->nggalbum SET sortorder = '0' WHERE id = $this->currentID ");
111
- }
112
-
113
- //hook for other plugins
114
- do_action('ngg_update_album_sortorder', $this->currentID);
115
-
116
- nggGallery::show_message(__('Update Successfully','nggallery'));
117
-
118
- }
119
-
120
- if ( isset($_POST['delete']) ) {
121
-
122
- if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' ))
123
- wp_die(__('Cheatin&#8217; uh?'));
124
-
125
- $result = nggdb::delete_album( $this->currentID );
126
-
127
- //hook for other plugins
128
- do_action('ngg_delete_album', $this->currentID);
129
-
130
- // jump back to main selection
131
- $this->currentID = 0;
132
-
133
- if ($result)
134
- nggGallery::show_message(__('Album deleted','nggallery'));
135
- }
136
-
137
- }
138
-
139
- function update_album() {
140
- global $wpdb, $nggdb;
141
-
142
- check_admin_referer('ngg_thickbox_form');
143
-
144
- if (!nggGallery::current_user_can( 'NextGEN Edit album settings' ))
145
- wp_die(__('Cheatin&#8217; uh?'));
146
-
147
- $name = $_POST['album_name'];
148
- $desc = $_POST['album_desc'];
149
- $prev = (int) $_POST['previewpic'];
150
- $link = (int) $_POST['pageid'];
151
-
152
- // slug must be unique, we use the title for that
153
- $slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album', $this->currentID );
154
-
155
- $result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggalbum SET slug= '%s', name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '%d'" , $slug, $name, $desc, $prev, $link, $this->currentID ) );
156
-
157
- //hook for other plugin to update the fields
158
- do_action('ngg_update_album', $this->currentID, $_POST);
159
-
160
- if ($result)
161
- nggGallery::show_message(__('Update Successfully','nggallery'));
162
- }
163
-
164
- function output() {
165
-
166
- global $wpdb, $nggdb;
167
-
168
- //TODO:Code MUST be optimized, how to flag a used gallery better ?
169
- $used_list = $this->get_used_galleries();
170
-
171
- ?>
172
-
173
- <script type="text/javascript">
174
-
175
- jQuery(document).ready(
176
- function()
177
- {
178
- jQuery("#previewpic").nggAutocomplete( {
179
- type: 'image',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>",width: "95%"
180
- });
181
-
182
- jQuery('#selectContainer').sortable( {
183
- items: '.groupItem',
184
- placeholder: 'sort_placeholder',
185
- opacity: 0.7,
186
- tolerance: 'intersect',
187
- distance: 2,
188
- forcePlaceholderSize: true ,
189
- connectWith: ['#galleryContainer']
190
- } );
191
-
192
- jQuery('#galleryContainer').sortable( {
193
- items: '.groupItem',
194
- placeholder: 'sort_placeholder',
195
- opacity: 0.7,
196
- tolerance: 'intersect',
197
- distance: 2,
198
- forcePlaceholderSize: true ,
199
- connectWith: ['#selectContainer', '#albumContainer']
200
- } );
201
-
202
- jQuery('#albumContainer').sortable( {
203
- items: '.groupItem',
204
- placeholder: 'sort_placeholder',
205
- opacity: 0.7,
206
- tolerance: 'intersect',
207
- distance: 2,
208
- forcePlaceholderSize: true ,
209
- connectWith: ['#galleryContainer']
210
- } );
211
-
212
- jQuery('a.min').bind('click', toggleContent);
213
-
214
- // Hide used galleries
215
- jQuery('a#toggle_used').click(function()
216
- {
217
- jQuery('#selectContainer div.inUse').toggle();
218
- return false;
219
- }
220
- );
221
-
222
- // Maximize All Portlets (whole site, no differentiation)
223
- jQuery('a#all_max').click(function()
224
- {
225
- jQuery('div.itemContent:hidden').show();
226
- return false;
227
- }
228
- );
229
-
230
- // Minimize All Portlets (whole site, no differentiation)
231
- jQuery('a#all_min').click(function()
232
- {
233
- jQuery('div.itemContent:visible').hide();
234
- return false;
235
- }
236
- );
237
- // Auto Minimize if more than 4 (whole site, no differentiation)
238
- if(jQuery('a.min').length > 4)
239
- {
240
- jQuery('a.min').html('[+]');
241
- jQuery('div.itemContent:visible').hide();
242
- jQuery('#selectContainer div.inUse').toggle();
243
- };
244
- }
245
- );
246
-
247
- var toggleContent = function(e)
248
- {
249
- var targetContent = jQuery('div.itemContent', this.parentNode.parentNode);
250
- if (targetContent.css('display') == 'none') {
251
- targetContent.slideDown(300);
252
- jQuery(this).html('[-]');
253
- } else {
254
- targetContent.slideUp(300);
255
- jQuery(this).html('[+]');
256
- }
257
- return false;
258
- }
259
-
260
- function ngg_serialize(s)
261
- {
262
- //serial = jQuery.SortSerialize(s);
263
- serial = jQuery('#galleryContainer').sortable('serialize');
264
- jQuery('input[name=sortorder]').val(serial);
265
- }
266
-
267
- function showDialog() {
268
- jQuery( "#editalbum").dialog({
269
- width: 640,
270
- resizable : false,
271
- modal: true,
272
- title: '<?php echo esc_js( __('Edit Album', 'nggallery') ); ?>'
273
- });
274
- jQuery('#editalbum .dialog-cancel').click(function() { jQuery( "#editalbum" ).dialog("close"); });
275
- }
276
-
277
- </script>
278
-
279
- <div class="wrap album" id="wrap" >
280
- <?php include('templates/social_media_buttons.php'); ?>
281
- <?php screen_icon( 'nextgen-gallery' ); ?>
282
- <h2><?php esc_html_e('Manage Albums', 'nggallery') ?></h2>
283
- <form id="selectalbum" method="POST" onsubmit="ngg_serialize()" accept-charset="utf-8">
284
- <?php wp_nonce_field('ngg_album') ?>
285
- <input name="sortorder" type="hidden" />
286
- <div class="albumnav tablenav">
287
- <div class="alignleft actions">
288
- <?php esc_html_e('Select album', 'nggallery') ?>
289
- <select id="act_album" name="act_album" onchange="this.form.submit();">
290
- <option value="0" ><?php esc_html_e('No album selected', 'nggallery') ?></option>
291
- <?php
292
- if( is_array($this->albums) ) {
293
- foreach($this->albums as $album) {
294
- $selected = ($this->currentID == $album->id) ? 'selected="selected" ' : '';
295
- echo '<option value="' . $album->id . '" ' . $selected . '>' . $album->id . ' - ' . esc_attr( $album->name ) . '</option>'."\n";
296
- }
297
- }
298
- ?>
299
- </select>
300
- <?php if ($this->currentID > 0){ ?>
301
- <input class="button-primary" type="submit" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>"/>
302
- <?php if(nggGallery::current_user_can( 'NextGEN Edit album settings' )) { ?>
303
- <input class="button-secondary" type="submit" name="showThickbox" value="<?php esc_attr_e( 'Edit album', 'nggallery'); ?>" onclick="showDialog(); return false;" />
304
- <?php } ?>
305
- <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
306
- <input class="button-secondary action "type="submit" name="delete" value="<?php esc_attr_e('Delete', 'nggallery'); ?>" onclick="javascript:check=confirm('<?php echo esc_js('Delete album ?','nggallery'); ?>');if(check==false) return false;"/>
307
- <?php } ?>
308
- <?php } else { ?>
309
- <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
310
- <span><?php esc_html_e('Add new album', 'nggallery'); ?>&nbsp;</span>
311
- <input class="search-input" id="newalbum" name="newalbum" type="text" value="" />
312
- <input class="button-secondary action" type="submit" name="add" value="<?php esc_attr_e('Add', 'nggallery'); ?>"/>
313
- <?php } ?>
314
- <?php } ?>
315
- </div>
316
- </div>
317
- </form>
318
-
319
- <br class="clear"/>
320
-
321
- <div>
322
- <div style="float:right;">
323
- <a href="#" title="<?php esc_attr_e('Show / hide used galleries','nggallery'); ?>" id="toggle_used"><?php esc_html_e('[Show all]', 'nggallery'); ?></a>
324
- | <a href="#" title="<?php esc_attr_e('Maximize the widget content','nggallery'); ?>" id="all_max"><?php esc_html_e('[Maximize]', 'nggallery'); ?></a>
325
- | <a href="#" title="<?php esc_attr_e('Minimize the widget content','nggallery'); ?>" id="all_min"><?php esc_html_e('[Minimize]', 'nggallery'); ?></a>
326
- </div>
327
- <?php esc_html_e('After you create and select a album, you can drag and drop a gallery or another album into your new album below','nggallery'); ?>
328
- </div>
329
-
330
- <br class="clear" />
331
-
332
- <div class="container">
333
-
334
- <!-- /#album container -->
335
- <div class="widget widget-right">
336
- <div class="widget-top">
337
- <h3><?php esc_html_e('Select album', 'nggallery'); ?></h3>
338
- </div>
339
- <div id="albumContainer" class="widget-holder">
340
- <?php
341
- if( is_array( $this->albums ) ) {
342
- foreach($this->albums as $album) {
343
- $this->get_container('a' . $album->id);
344
- }
345
- }
346
- ?>
347
- </div>
348
- </div>
349
-
350
- <!-- /#select container -->
351
- <div class="widget widget-right">
352
- <div class="widget-top">
353
- <h3><?php esc_html_e('Select gallery', 'nggallery'); ?></h3>
354
- </div>
355
- <div id="selectContainer" class="widget-holder">
356
- <?php
357
-
358
- if( is_array( $this->galleries ) ) {
359
- //get the array of galleries
360
- $sort_array = $this->currentID > 0 ? (array) $this->albums[$this->currentID]->galleries : array() ;
361
- foreach($this->galleries as $gallery) {
362
- if (!in_array($gallery->gid, $sort_array)) {
363
- if (in_array($gallery->gid,$used_list))
364
- $this->get_container($gallery->gid,true);
365
- else
366
- $this->get_container($gallery->gid,false);
367
- }
368
- }
369
- }
370
- ?>
371
- </div>
372
- </div>
373
-
374
- <!-- /#target-album -->
375
- <div class="widget target-album widget-left">
376
-
377
- <?php
378
- if ($this->currentID > 0){
379
- $album = $this->albums[$this->currentID];
380
- ?>
381
- <div class="widget-top">
382
- <h3><?php esc_html_e('Album ID', 'nggallery'); ?> <?php echo $album->id . ' : ' . esc_html( $album->name ); ?> </h3>
383
- </div>
384
- <div id="galleryContainer" class="widget-holder target">
385
- <?php
386
- $sort_array = (array) $this->albums[$this->currentID]->galleries;
387
- foreach($sort_array as $galleryid) {
388
- $this->get_container($galleryid, false);
389
- }
390
- }
391
- else
392
- {
393
- ?>
394
- <div class="widget-top">
395
- <h3><?php esc_html_e('No album selected!', 'nggallery'); ?></h3>
396
- </div>
397
- <div class="widget-holder target">
398
- <?php
399
- }
400
- ?>
401
- </div>
402
- </div><!-- /#target-album -->
403
-
404
- </div><!-- /#container -->
405
- </div><!-- /#wrap -->
406
-
407
- <?php if ($this->currentID > 0) : ?>
408
- <!-- #editalbum -->
409
- <div id="editalbum" style="display: none;" >
410
- <form id="form-edit-album" method="POST" accept-charset="utf-8">
411
- <?php wp_nonce_field('ngg_thickbox_form') ?>
412
- <input type="hidden" id="current_album" name="act_album" value="<?php echo $this->currentID; ?>" />
413
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
414
- <tr>
415
- <th>
416
- <?php esc_html_e('Album name:', 'nggallery'); ?><br />
417
- <input class="search-input" id="album_name" name="album_name" type="text" value="<?php echo esc_attr( $album->name ); ?>" style="width:95%" />
418
- </th>
419
- </tr>
420
- <tr>
421
- <th>
422
- <?php esc_html_e('Album description:', 'nggallery'); ?><br />
423
- <textarea class="search-input" id="album_desc" name="album_desc" cols="50" rows="2" style="width:95%" ><?php echo esc_attr( $album->albumdesc ); ?></textarea>
424
- </th>
425
- </tr>
426
- <tr>
427
- <th>
428
- <?php esc_html_e('Select a preview image:', 'nggallery'); ?><br />
429
- <select id="previewpic" name="previewpic" style="width:95%" >
430
- <?php if ($album->previewpic == 0) ?>
431
- <option value="0"><?php esc_html_e('No picture', 'nggallery'); ?></option>
432
- <?php
433
- if ($album->previewpic == 0)
434
- echo '<option value="0" selected="selected">' . __('No picture', 'nggallery') . '</option>';
435
- else {
436
- $picture = nggdb::find_image($album->previewpic);
437
- echo '<option value="' . $picture->pid . '" selected="selected" >'. $picture->pid . ' - ' . ( empty($picture->alltext) ? esc_attr( $picture->filename ) : esc_attr( $picture->alltext ) ) .' </option>'."\n";
438
- }
439
- ?>
440
- </select>
441
- </th>
442
- </tr>
443
- <tr>
444
- <th>
445
- <?php esc_html_e('Page Link to', 'nggallery')?><br />
446
- <select name="pageid" style="width:95%">
447
- <option value="0" ><?php esc_html_e('Not linked', 'nggallery') ?></option>
448
- <?php
449
- if (!isset($album->pageid))
450
- $album->pageid = 0;
451
- parent_dropdown($album->pageid); ?>
452
- </select>
453
- </th>
454
- </tr>
455
-
456
- <?php do_action('ngg_edit_album_settings', $this->currentID); ?>
457
-
458
- <tr align="right">
459
- <td class="submit">
460
- <input type="submit" class="button-primary" name="update_album" value="<?php esc_attr_e('OK', 'nggallery'); ?>" />
461
- &nbsp;
462
- <input class="button-secondary dialog-cancel" type="reset" value="<?php esc_attr_e('Cancel', 'nggallery'); ?>"/>
463
- </td>
464
- </tr>
465
- </table>
466
- </form>
467
- </div>
468
- <!-- /#editalbum -->
469
- <?php endif; ?>
470
-
471
- <?php
472
-
473
- }
474
-
475
- /**
476
- * Create the album or gallery container
477
- *
478
- * @param integer $id (the prefix 'a' indidcates that you look for a album
479
- * @param bool $used (object will be hidden)
480
- * @return $output
481
- */
482
- function get_container($id = 0, $used = false) {
483
- global $wpdb, $nggdb;
484
-
485
- $obj = array();
486
- $preview_image = '';
487
- $class = '';
488
-
489
- // if the id started with a 'a', then it's a sub album
490
- if (substr( $id, 0, 1) == 'a') {
491
-
492
- if ( !$album = $this->albums[ substr( $id, 1) ] )
493
- return;
494
-
495
- $obj['id'] = $album->id;
496
- $obj['name'] = $obj['title'] = $album->name;
497
- $obj['type'] = 'album';
498
- $class = 'album_obj';
499
-
500
- // get the post name
501
- $post = get_post($album->pageid);
502
- $obj['pagenname'] = ($post == null) ? '---' : $post->post_title;
503
-
504
- // for speed reason we limit it to 50
505
- if ( $this->num_albums < 50 ) {
506
- if ($album->previewpic != 0) {
507
- $image = $nggdb->find_image( $album->previewpic );
508
- $preview_image = ( !is_null($image->thumbURL) ) ? '<div class="inlinepicture"><img src="' . esc_url( $image->thumbURL ). '" /></div>' : '';
509
- }
510
- }
511
-
512
- // this indicates that we have a album container
513
- $prefix = 'a';
514
-
515
- } else {
516
- if ( !$gallery = $nggdb->find_gallery( $id ) )
517
- return;
518
-
519
- $obj['id'] = $gallery->gid;
520
- $obj['name'] = $gallery->name;
521
- $obj['title'] = $gallery->title;
522
- $obj['type'] = 'gallery';
523
-
524
- // get the post name
525
- $post = get_post($gallery->pageid);
526
- $obj['pagenname'] = ($post == null) ? '---' : $post->post_title;
527
-
528
- // for spped reason we limit it to 50
529
- if ( $this->num_galleries < 50 ) {
530
- // set image url
531
- $image = $nggdb->find_image( $gallery->previewpic );
532
- $preview_image = isset($image->thumbURL) ? '<div class="inlinepicture"><img src="' . esc_url( $image->thumbURL ) . '" /></div>' : '';
533
- }
534
-
535
- $prefix = '';
536
- }
537
-
538
- // add class if it's in use in other albums
539
- $used = $used ? ' inUse' : '';
540
-
541
- echo '<div id="gid-' . $prefix . $obj['id'] . '" class="groupItem' . $used . '">
542
- <div class="innerhandle">
543
- <div class="item_top ' . $class . '">
544
- <a href="#" class="min" title="close">[-]</a>
545
- ID: ' . $obj['id'] . ' | ' . wp_html_excerpt( esc_html ( nggGallery::i18n( $obj['title'] ) ) , 25) . '
546
- </div>
547
- <div class="itemContent">
548
- ' . $preview_image . '
549
- <p><strong>' . __('Name', 'nggallery') . ' : </strong>' . esc_html ( nggGallery::i18n( $obj['name'] ) ). '</p>
550
- <p><strong>' . __('Title', 'nggallery') . ' : </strong>' . esc_html ( nggGallery::i18n( $obj['title'] ) ) . '</p>
551
- <p><strong>' . __('Page', 'nggallery'). ' : </strong>' . esc_html ( nggGallery::i18n( $obj['pagenname'] ) ) . '</p>
552
- ' . apply_filters('ngg_display_album_item_content', '', $obj) . '
553
- </div>
554
- </div>
555
- </div>';
556
- }
557
-
558
- /**
559
- * get all used galleries from all albums
560
- *
561
- * @return array $used_galleries_ids
562
- */
563
- function get_used_galleries() {
564
-
565
- $used = array();
566
-
567
- if ($this->albums) {
568
- foreach($this->albums as $key => $value) {
569
- $sort_array = $this->albums[$key]->galleries;
570
- foreach($sort_array as $galleryid) {
571
- if (!in_array($galleryid, $used))
572
- $used[] = $galleryid;
573
- }
574
- }
575
- }
576
-
577
- return $used;
578
- }
579
-
580
- /**
581
- * PHP5 style destructor
582
- *
583
- * @return bool Always true
584
- */
585
- function __destruct() {
586
- return true;
587
- }
588
-
589
  }
1
+ <?php
2
+
3
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
+
5
+ class nggManageAlbum {
6
+
7
+ /**
8
+ * The selected album ID
9
+ *
10
+ * @since 1.3.0
11
+ * @access privat
12
+ * @var int
13
+ */
14
+ var $currentID = 0;
15
+
16
+ /**
17
+ * The array for the galleries
18
+ *
19
+ * @since 1.3.0
20
+ * @access privat
21
+ * @var array
22
+ */
23
+ var $galleries = false;
24
+
25
+ /**
26
+ * The array for the albums
27
+ *
28
+ * @since 1.3.0
29
+ * @access privat
30
+ * @var array
31
+ */
32
+ var $albums = false;
33
+
34
+ /**
35
+ * The amount of all galleries
36
+ *
37
+ * @since 1.4.0
38
+ * @access privat
39
+ * @var int
40
+ */
41
+ var $num_galleries = false;
42
+
43
+ /**
44
+ * The amount of all albums
45
+ *
46
+ * @since 1.4.0
47
+ * @access privat
48
+ * @var int
49
+ */
50
+ var $num_albums = false;
51
+
52
+ /**
53
+ * Init the album output
54
+ *
55
+ */
56
+ function __construct() {
57
+ return true;
58
+ }
59
+
60
+ function controller() {
61
+ global $nggdb;
62
+
63
+ $this->currentID = isset($_REQUEST['act_album']) ? (int) $_REQUEST['act_album'] : 0 ;
64
+
65
+ if (isset ($_POST['update']) || isset( $_POST['delete'] ) || isset( $_POST['add'] ) )
66
+ $this->processor();
67
+
68
+ if (isset ($_POST['update_album']) )
69
+ $this->update_album();
70
+
71
+ // get first all galleries & albums
72
+ $this->albums = $nggdb->find_all_album();
73
+ $this->galleries = $nggdb->find_all_galleries();
74
+ $this->num_albums = count( $this->albums );
75
+ $this->num_galleries = count( $this->galleries );
76
+ $this->output();
77
+
78
+ }
79
+
80
+ function processor() {
81
+ global $wpdb;
82
+
83
+ check_admin_referer('ngg_album');
84
+
85
+ if ( isset($_POST['add']) && isset ($_POST['newalbum']) ) {
86
+
87
+ if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' ))
88
+ wp_die(__('Cheatin&#8217; uh?'));
89
+
90
+ $result = nggdb::add_album( $_POST['newalbum'] );
91
+ $this->currentID = ($result) ? $result : 0 ;
92
+
93
+ //hook for other plugins
94
+ do_action('ngg_add_album', $this->currentID);
95
+
96
+ if ($result)
97
+ nggGallery::show_message(__('Update Successfully','nggallery'));
98
+ }
99
+
100
+ if ( isset($_POST['update']) && ($this->currentID > 0) ) {
101
+
102
+ $gid = '';
103
+
104
+ // get variable galleryContainer
105
+ parse_str($_POST['sortorder']);
106
+ if ( is_array($gid) ){
107
+ $serial_sort = serialize($gid);
108
+ $wpdb->query("UPDATE $wpdb->nggalbum SET sortorder = '$serial_sort' WHERE id = $this->currentID ");
109
+ } else {
110
+ $wpdb->query("UPDATE $wpdb->nggalbum SET sortorder = '0' WHERE id = $this->currentID ");
111
+ }
112
+
113
+ //hook for other plugins
114
+ do_action('ngg_update_album_sortorder', $this->currentID);
115
+
116
+ nggGallery::show_message(__('Update Successfully','nggallery'));
117
+
118
+ }
119
+
120
+ if ( isset($_POST['delete']) ) {
121
+
122
+ if (!nggGallery::current_user_can( 'NextGEN Add/Delete album' ))
123
+ wp_die(__('Cheatin&#8217; uh?'));
124
+
125
+ $result = nggdb::delete_album( $this->currentID );
126
+
127
+ //hook for other plugins
128
+ do_action('ngg_delete_album', $this->currentID);
129
+
130
+ // jump back to main selection
131
+ $this->currentID = 0;
132
+
133
+ if ($result)
134
+ nggGallery::show_message(__('Album deleted','nggallery'));
135
+ }
136
+
137
+ }
138
+
139
+ function update_album() {
140
+ global $wpdb, $nggdb;
141
+
142
+ check_admin_referer('ngg_thickbox_form');
143
+
144
+ if (!nggGallery::current_user_can( 'NextGEN Edit album settings' ))
145
+ wp_die(__('Cheatin&#8217; uh?'));
146
+
147
+ $name = $_POST['album_name'];
148
+ $desc = $_POST['album_desc'];
149
+ $prev = (int) $_POST['previewpic'];
150
+ $link = (int) $_POST['pageid'];
151
+
152
+ // slug must be unique, we use the title for that
153
+ $slug = nggdb::get_unique_slug( sanitize_title( $name ), 'album', $this->currentID );
154
+
155
+ $result = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->nggalbum SET slug= '%s', name= '%s', albumdesc= '%s', previewpic= %d, pageid= %d WHERE id = '%d'" , $slug, $name, $desc, $prev, $link, $this->currentID ) );
156
+
157
+ //hook for other plugin to update the fields
158
+ do_action('ngg_update_album', $this->currentID, $_POST);
159
+
160
+ if ($result)
161
+ nggGallery::show_message(__('Update Successfully','nggallery'));
162
+ }
163
+
164
+ function output() {
165
+
166
+ global $wpdb, $nggdb;
167
+
168
+ //TODO:Code MUST be optimized, how to flag a used gallery better ?
169
+ $used_list = $this->get_used_galleries();
170
+
171
+ ?>
172
+
173
+ <script type="text/javascript">
174
+
175
+ jQuery(document).ready(
176
+ function()
177
+ {
178
+ jQuery("#previewpic").nggAutocomplete( {
179
+ type: 'image',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>",width: "95%"
180
+ });
181
+
182
+ jQuery('#selectContainer').sortable( {
183
+ items: '.groupItem',
184
+ placeholder: 'sort_placeholder',
185
+ opacity: 0.7,
186
+ tolerance: 'intersect',
187
+ distance: 2,
188
+ forcePlaceholderSize: true ,
189
+ connectWith: ['#galleryContainer']
190
+ } );
191
+
192
+ jQuery('#galleryContainer').sortable( {
193
+ items: '.groupItem',
194
+ placeholder: 'sort_placeholder',
195
+ opacity: 0.7,
196
+ tolerance: 'intersect',
197
+ distance: 2,
198
+ forcePlaceholderSize: true ,
199
+ connectWith: ['#selectContainer', '#albumContainer']
200
+ } );
201
+
202
+ jQuery('#albumContainer').sortable( {
203
+ items: '.groupItem',
204
+ placeholder: 'sort_placeholder',
205
+ opacity: 0.7,
206
+ tolerance: 'intersect',
207
+ distance: 2,
208
+ forcePlaceholderSize: true ,
209
+ connectWith: ['#galleryContainer']
210
+ } );
211
+
212
+ jQuery('a.min').bind('click', toggleContent);
213
+
214
+ // Hide used galleries
215
+ jQuery('a#toggle_used').click(function()
216
+ {
217
+ jQuery('#selectContainer div.inUse').toggle();
218
+ return false;
219
+ }
220
+ );
221
+
222
+ // Maximize All Portlets (whole site, no differentiation)
223
+ jQuery('a#all_max').click(function()
224
+ {
225
+ jQuery('div.itemContent:hidden').show();
226
+ return false;
227
+ }
228
+ );
229
+
230
+ // Minimize All Portlets (whole site, no differentiation)
231
+ jQuery('a#all_min').click(function()
232
+ {
233
+ jQuery('div.itemContent:visible').hide();
234
+ return false;
235
+ }
236
+ );
237
+ // Auto Minimize if more than 4 (whole site, no differentiation)
238
+ if(jQuery('a.min').length > 4)
239
+ {
240
+ jQuery('a.min').html('&#9547;');
241
+ jQuery('div.itemContent:visible').hide();
242
+ jQuery('#selectContainer div.inUse').toggle();
243
+ };
244
+ }
245
+ );
246
+
247
+ var toggleContent = function(e)
248
+ {
249
+ var targetContent = jQuery('div.itemContent', this.parentNode.parentNode);
250
+ if (targetContent.css('display') == 'none') {
251
+ targetContent.slideDown(300);
252
+ jQuery(this).html('&#9473;');
253
+ } else {
254
+ targetContent.slideUp(300);
255
+ jQuery(this).html('&#9547;');
256
+ }
257
+ return false;
258
+ }
259
+
260
+ function ngg_serialize(s)
261
+ {
262
+ //serial = jQuery.SortSerialize(s);
263
+ serial = jQuery('#galleryContainer').sortable('serialize');
264
+ jQuery('input[name=sortorder]').val(serial);
265
+ }
266
+
267
+ function showDialog() {
268
+ jQuery( "#editalbum").dialog({
269
+ width: 640,
270
+ resizable : false,
271
+ modal: true,
272
+ title: '<?php echo esc_js( __('Edit Album', 'nggallery') ); ?>'
273
+ });
274
+ jQuery('#editalbum .dialog-cancel').click(function() { jQuery( "#editalbum" ).dialog("close"); });
275
+ }
276
+
277
+ </script>
278
+ <div class="wrap album" id="wrap" >
279
+ <?php screen_icon( 'nextgen-gallery' ); ?>
280
+ <h2><?php _e('Albums', 'nggallery') ?></h2>
281
+ <form id="selectalbum" method="POST" onsubmit="ngg_serialize()" accept-charset="utf-8">
282
+ <?php wp_nonce_field('ngg_album') ?>
283
+ <input name="sortorder" type="hidden" />
284
+ <div class="albumnav tablenav">
285
+ <div class="alignleft actions">
286
+ <?php esc_html_e('Select album', 'nggallery') ?>
287
+ <select id="act_album" name="act_album" onchange="this.form.submit();">
288
+ <option value="0" ><?php esc_html_e('No album selected', 'nggallery') ?></option>
289
+ <?php
290
+ if( is_array($this->albums) ) {
291
+ foreach($this->albums as $album) {
292
+ $selected = ($this->currentID == $album->id) ? 'selected="selected" ' : '';
293
+ echo '<option value="' . $album->id . '" ' . $selected . '>' . $album->id . ' - ' . esc_attr( $album->name ) . '</option>'."\n";
294
+ }
295
+ }
296
+ ?>
297
+ </select>
298
+ <?php if ($this->currentID > 0){ ?>
299
+ <input class="button-primary" type="submit" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>"/>
300
+ <?php if(nggGallery::current_user_can( 'NextGEN Edit album settings' )) { ?>
301
+ <input class="button-secondary" type="submit" name="showThickbox" value="<?php esc_attr_e( 'Edit album', 'nggallery'); ?>" onclick="showDialog(); return false;" />
302
+ <?php } ?>
303
+ <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
304
+ <input class="button-secondary action "type="submit" name="delete" value="<?php esc_attr_e('Delete', 'nggallery'); ?>" onclick="javascript:check=confirm('<?php echo esc_js('Delete album?','nggallery'); ?>');if(check==false) return false;"/>
305
+ <?php } ?>
306
+ <?php } else { ?>
307
+ <?php if(nggGallery::current_user_can( 'NextGEN Add/Delete album' )) { ?>
308
+ <span><?php esc_html_e('Add new album', 'nggallery'); ?>&nbsp;</span>
309
+ <input class="search-input" id="newalbum" name="newalbum" type="text" value="" />
310
+ <input class="button-secondary action" type="submit" name="add" value="<?php esc_attr_e('Add', 'nggallery'); ?>"/>
311
+ <?php } ?>
312
+ <?php } ?>
313
+ </div>
314
+ </div>
315
+ </form>
316
+
317
+ <br class="clear"/>
318
+
319
+ <div>
320
+ <div style="float:right;">
321
+ <a href="#" title="<?php esc_attr_e('Show / hide used galleries','nggallery'); ?>" id="toggle_used"><?php esc_html_e('[Show all]', 'nggallery'); ?></a>
322
+ | <a href="#" title="<?php esc_attr_e('Maximize the widget content','nggallery'); ?>" id="all_max"><?php esc_html_e('[Maximize]', 'nggallery'); ?></a>
323
+ | <a href="#" title="<?php esc_attr_e('Minimize the widget content','nggallery'); ?>" id="all_min"><?php esc_html_e('[Minimize]', 'nggallery'); ?></a>
324
+ </div>
325
+ <?php esc_html_e('After you create and select a album, you can drag and drop a gallery or another album into your new album below','nggallery'); ?>
326
+ </div>
327
+
328
+ <br class="clear" />
329
+
330
+ <div class="container">
331
+
332
+ <!-- /#album container -->
333
+ <div class="widget widget-right">
334
+ <div class="widget-top">
335
+ <h3><?php esc_html_e('Select album', 'nggallery'); ?></h3>
336
+ </div>
337
+ <div id="albumContainer" class="widget-holder">
338
+ <?php
339
+ if( is_array( $this->albums ) ) {
340
+ foreach($this->albums as $album) {
341
+ $this->get_container('a' . $album->id);
342
+ }
343
+ }
344
+ ?>
345
+ </div>
346
+ </div>
347
+
348
+ <!-- /#select container -->
349
+ <div class="widget widget-right">
350
+ <div class="widget-top">
351
+ <h3><?php esc_html_e('Select gallery', 'nggallery'); ?></h3>
352
+ </div>
353
+ <div id="selectContainer" class="widget-holder">
354
+ <?php
355
+
356
+ if( is_array( $this->galleries ) ) {
357
+ //get the array of galleries
358
+ $sort_array = $this->currentID > 0 ? (array) $this->albums[$this->currentID]->galleries : array() ;
359
+ foreach($this->galleries as $gallery) {
360
+ if (!in_array($gallery->gid, $sort_array)) {
361
+ if (in_array($gallery->gid,$used_list))
362
+ $this->get_container($gallery->gid,true);
363
+ else
364
+ $this->get_container($gallery->gid,false);
365
+ }
366
+ }
367
+ }
368
+ ?>
369
+ </div>
370
+ </div>
371
+
372
+ <!-- /#target-album -->
373
+ <div class="widget target-album widget-left">
374
+
375
+ <?php
376
+ if ($this->currentID > 0){
377
+ $album = $this->albums[$this->currentID];
378
+ ?>
379
+ <div class="widget-top">
380
+ <h3><?php esc_html_e('Album ID', 'nggallery'); ?> <?php echo $album->id . ' : ' . esc_html( $album->name ); ?> </h3>
381
+ </div>
382
+ <div id="galleryContainer" class="widget-holder target">
383
+ <?php
384
+ $sort_array = (array) $this->albums[$this->currentID]->galleries;
385
+ foreach($sort_array as $galleryid) {
386
+ $this->get_container($galleryid, false);
387
+ }
388
+ }
389
+ else
390
+ {
391
+ ?>
392
+ <div class="widget-top">
393
+ <h3><?php esc_html_e('No album selected!', 'nggallery'); ?></h3>
394
+ </div>
395
+ <div class="widget-holder target">
396
+ <?php
397
+ }
398
+ ?>
399
+ </div>
400
+ </div><!-- /#target-album -->
401
+
402
+ </div><!-- /#container -->
403
+ </div><!-- /#wrap -->
404
+
405
+ <?php if ($this->currentID > 0) : ?>
406
+ <!-- #editalbum -->
407
+ <div id="editalbum" style="display: none;" >
408
+ <form id="form-edit-album" method="POST" accept-charset="utf-8">
409
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
410
+ <input type="hidden" id="current_album" name="act_album" value="<?php echo $this->currentID; ?>" />
411
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
412
+ <tr>
413
+ <th>
414
+ <?php esc_html_e('Album name:', 'nggallery'); ?><br />
415
+ <input class="search-input" id="album_name" name="album_name" type="text" value="<?php echo esc_attr( $album->name ); ?>" style="width:95%" />
416
+ </th>
417
+ </tr>
418
+ <tr>
419
+ <th>
420
+ <?php esc_html_e('Album description:', 'nggallery'); ?><br />
421
+ <textarea class="search-input" id="album_desc" name="album_desc" cols="50" rows="2" style="width:95%" ><?php echo esc_attr( $album->albumdesc ); ?></textarea>
422
+ </th>
423
+ </tr>
424
+ <tr>
425
+ <th>
426
+ <?php esc_html_e('Select a preview image:', 'nggallery'); ?><br />
427
+ <select id="previewpic" name="previewpic" style="width:95%" >
428
+ <?php if ($album->previewpic == 0) ?>
429
+ <option value="0"><?php esc_html_e('No picture', 'nggallery'); ?></option>
430
+ <?php
431
+ if ($album->previewpic == 0)
432
+ echo '<option value="0" selected="selected">' . __('No picture', 'nggallery') . '</option>';
433
+ else {
434
+ $picture = nggdb::find_image($album->previewpic);
435
+ echo '<option value="' . $picture->pid . '" selected="selected" >'. $picture->pid . ' - ' . ( empty($picture->alltext) ? esc_attr( $picture->filename ) : esc_attr( $picture->alltext ) ) .' </option>'."\n";
436
+ }
437
+ ?>
438
+ </select>
439
+ </th>
440
+ </tr>
441
+ <tr>
442
+ <th>
443
+ <?php esc_html_e('Page Link to', 'nggallery')?><br />
444
+ <select name="pageid" style="width:95%">
445
+ <option value="0" ><?php esc_html_e('Not linked', 'nggallery') ?></option>
446
+ <?php
447
+ if (!isset($album->pageid))
448
+ $album->pageid = 0;
449
+ parent_dropdown($album->pageid); ?>
450
+ </select>
451
+ </th>
452
+ </tr>
453
+
454
+ <?php do_action('ngg_edit_album_settings', $this->currentID); ?>
455
+
456
+ <tr align="right">
457
+ <td class="submit">
458
+ <input type="submit" class="button-primary" name="update_album" value="<?php esc_attr_e('OK', 'nggallery'); ?>" />
459
+ &nbsp;
460
+ <input class="button-secondary dialog-cancel" type="reset" value="<?php esc_attr_e('Cancel', 'nggallery'); ?>"/>
461
+ </td>
462
+ </tr>
463
+ </table>
464
+ </form>
465
+ </div>
466
+ <!-- /#editalbum -->
467
+ <?php endif; ?>
468
+
469
+ <?php
470
+
471
+ }
472
+
473
+ /**
474
+ * Create the album or gallery container
475
+ *
476
+ * @param integer $id (the prefix 'a' indidcates that you look for a album
477
+ * @param bool $used (object will be hidden)
478
+ * @return $output
479
+ */
480
+ function get_container($id = 0, $used = false) {
481
+ global $wpdb, $nggdb;
482
+
483
+ $obj = array();
484
+ $preview_image = '';
485
+ $class = '';
486
+
487
+ // if the id started with a 'a', then it's a sub album
488
+ if (substr( $id, 0, 1) == 'a') {
489
+
490
+ if ( !$album = $this->albums[ substr( $id, 1) ] )
491
+ return;
492
+
493
+ $obj['id'] = $album->id;
494
+ $obj['name'] = $obj['title'] = $album->name;
495
+ $obj['type'] = 'album';
496
+ $class = 'album_obj';
497
+
498
+ // get the post name
499
+ $post = get_post($album->pageid);
500
+ $obj['pagenname'] = ($post == null) ? '---' : $post->post_title;
501
+
502
+ // for speed reason we limit it to 50
503
+ if ( $this->num_albums < 50 ) {
504
+ if ($album->previewpic != 0) {
505
+ $image = $nggdb->find_image( $album->previewpic );
506
+ $preview_image = ( !is_null($image->thumbURL) ) ? '<div class="inlinepicture"><img src="' . esc_url( $image->thumbURL ). '" /></div>' : '';
507
+ }
508
+ }
509
+
510
+ // this indicates that we have a album container
511
+ $prefix = 'a';
512
+
513
+ } else {
514
+ if ( !$gallery = $nggdb->find_gallery( $id ) )
515
+ return;
516
+
517
+ $obj['id'] = $gallery->gid;
518
+ $obj['name'] = $gallery->name;
519
+ $obj['title'] = $gallery->title;
520
+ $obj['type'] = 'gallery';
521
+
522
+ // get the post name
523
+ $post = get_post($gallery->pageid);
524
+ $obj['pagenname'] = ($post == null) ? '---' : $post->post_title;
525
+
526
+ // for spped reason we limit it to 50
527
+ if ( $this->num_galleries < 50 ) {
528
+ // set image url
529
+ $image = $nggdb->find_image( $gallery->previewpic );
530
+ $preview_image = isset($image->thumbURL) ? '<div class="inlinepicture"><img src="' . esc_url( $image->thumbURL ) . '" /></div>' : '';
531
+ }
532
+
533
+ $prefix = '';
534
+ }
535
+
536
+ // add class if it's in use in other albums
537
+ $used = $used ? ' inUse' : '';
538
+
539
+ echo '<div id="gid-' . $prefix . $obj['id'] . '" class="groupItem' . $used . '">
540
+ <div class="innerhandle">
541
+ <div class="item_top ' . $class . '">
542
+ <a href="#" class="min" title="close">[-]</a>
543
+ ID: ' . $obj['id'] . ' | ' . wp_html_excerpt( esc_html ( nggGallery::i18n( $obj['title'] ) ) , 25) . '
544
+ </div>
545
+ <div class="itemContent">
546
+ ' . $preview_image . '
547
+ <p><strong>' . __('Name', 'nggallery') . ' : </strong>' . esc_html ( nggGallery::i18n( $obj['name'] ) ). '</p>
548
+ <p><strong>' . __('Title', 'nggallery') . ' : </strong>' . esc_html ( nggGallery::i18n( $obj['title'] ) ) . '</p>
549
+ <p><strong>' . __('Page', 'nggallery'). ' : </strong>' . esc_html ( nggGallery::i18n( $obj['pagenname'] ) ) . '</p>
550
+ ' . apply_filters('ngg_display_album_item_content', '', $obj) . '
551
+ </div>
552
+ </div>
553
+ </div>';
554
+ }
555
+
556
+ /**
557
+ * get all used galleries from all albums
558
+ *
559
+ * @return array $used_galleries_ids
560
+ */
561
+ function get_used_galleries() {
562
+
563
+ $used = array();
564
+
565
+ if ($this->albums) {
566
+ foreach($this->albums as $key => $value) {
567
+ $sort_array = $this->albums[$key]->galleries;
568
+ foreach($sort_array as $galleryid) {
569
+ if (!in_array($galleryid, $used))
570
+ $used[] = $galleryid;
571
+ }
572
+ }
573
+ }
574
+
575
+ return $used;
576
+ }
577
+
578
+ /**
579
+ * PHP5 style destructor
580
+ *
581
+ * @return bool Always true
582
+ */
583
+ function __destruct() {
584
+ return true;
585
+ }
 
 
 
586
  }
admin/css/images/ui-bg_flat_0_aaaaaa_40x100.png ADDED
Binary file
admin/css/images/ui-bg_flat_75_ffffff_40x100.png ADDED
Binary file
admin/css/images/ui-bg_glass_55_fbf9ee_1x400.png ADDED
Binary file
admin/css/images/ui-bg_glass_65_ffffff_1x400.png ADDED
Binary file
admin/css/images/ui-bg_glass_75_dadada_1x400.png ADDED
Binary file
admin/css/images/ui-bg_glass_75_e6e6e6_1x400.png ADDED
Binary file
admin/css/images/ui-bg_glass_95_fef1ec_1x400.png ADDED
Binary file
admin/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png ADDED
Binary file
admin/css/images/ui-icons_2e83ff_256x240.png ADDED
Binary file
admin/css/images/ui-icons_454545_256x240.png ADDED
Binary file
admin/css/images/ui-icons_888888_256x240.png ADDED
Binary file
admin/css/images/ui-icons_cd0a0a_256x240.png ADDED
Binary file
admin/css/jquery.ui.css CHANGED
@@ -1,140 +1,141 @@
1
- /*
2
- * jQuery UI CSS Framework @VERSION
3
- *
4
- * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5
- * Dual licensed under the MIT or GPL Version 2 licenses.
6
- * http://jquery.org/license
7
- *
8
- * http://docs.jquery.com/UI/Theming/API
9
- */
10
-
11
- /* Layout helpers
12
- ----------------------------------*/
13
- .ui-helper-hidden { display: none; }
14
- .ui-helper-hidden-accessible { position: absolute; left: -99999999px; }
15
- .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
16
- .ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
17
- .ui-helper-clearfix { display: inline-block; }
18
- /* required comment for clearfix to work in Opera \*/
19
- * html .ui-helper-clearfix { height:1%; }
20
- .ui-helper-clearfix { display:block; }
21
- /* end clearfix */
22
- .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
23
-
24
- /* Interaction Cues
25
- ----------------------------------*/
26
- .ui-state-disabled { cursor: default !important; }
27
-
28
- /* Icons
29
- ----------------------------------*/
30
- .ui-icon-triangle-1-s { background-position: -64px -16px; }
31
-
32
- /* states and images */
33
- .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
34
-
35
- /* Misc visuals
36
- ----------------------------------*/
37
-
38
- /* Overlays */
39
- .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
40
-
41
- /* jQuery UI CSS Framework @VERSION */
42
-
43
- /* Component containers
44
- ----------------------------------*/
45
- .ui-widget-content { background: #fcfdfd 50% bottom repeat-x; color: #222222; }
46
- /* .ui-widget-content a { color: #222222; } */
47
- .ui-widget-header { background: #222222 50% 50% repeat-x; color: #CFCFCF; }
48
- .ui-widget-header a { color: #CFCFCF; }
49
-
50
- /* Interaction states
51
- ----------------------------------*/
52
- .ui-dialog-titlebar-close:hover { border: 1px solid #464646; background: #464646 50% 50% repeat-x; font-weight: normal; color: #ffffff; }
53
- .ui-widget :active { outline: none; }
54
-
55
- /* Icons
56
- ----------------------------------*/
57
-
58
- /* states and images */
59
- .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); }
60
- .ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); }
61
- .ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
62
- .ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); }
63
- .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
64
- .ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
65
-
66
- /* positioning */
67
- .ui-icon-close { background-position: -80px -128px; }
68
- .ui-icon-closethick { background-position: -96px -128px; }
69
- .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
70
- .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
71
-
72
- /* Misc visuals
73
- ----------------------------------*/
74
-
75
- /* Corner radius */
76
- .ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; }
77
- .ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; }
78
- .ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; }
79
- .ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; }
80
- .ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; }
81
- .ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; }
82
- .ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; }
83
- .ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; }
84
- .ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }
85
-
86
- /* Overlays */
87
- .ui-widget-overlay { background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); }
88
- .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
89
-
90
- /* jQuery UI Resizable */
91
- .ui-resizable { position: relative;}
92
- .ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
93
- .ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
94
- .ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
95
- .ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
96
- .ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
97
- .ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
98
- .ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
99
- .ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
100
- .ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
101
- .ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*
102
-
103
- /* jQuery UI Dialog */
104
- .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
105
- .ui-dialog { -moz-box-shadow: rgba(0,0,0,1) 0 4px 30px; -webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px; -khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px; box-shadow: rgba(0,0,0,1) 0 4px 30px; }
106
- .ui-dialog .ui-dialog-titlebar { padding: .5em 1em .3em; position: relative; }
107
- .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .2em 0; }
108
- .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
109
- .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
110
- .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
111
- .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
112
- .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
113
- .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
114
- .ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
115
- .ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
116
- .ui-draggable .ui-dialog-titlebar { cursor: move; }
117
-
118
- /* jQuery UI Progressbar */
119
- .ui-progressbar { height:2em; text-align: left; }
120
- .ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
121
-
122
- /* jQuery UI Dialog loading spinner */
123
- #spinner {display: none; width:100px; height: 100px; position: fixed; top: 50%; left: 50%; background:url(../../images/loader.gif) no-repeat center #fff; padding:10px; border:1px solid #666; margin-left: -50px; margin-top: -50px; z-index:2; overflow: auto; }
124
-
125
- /* jQuery Autocomplete */
126
- .ui-autocomplete { position: absolute; cursor: default; }
127
- .ui-autocomplete-start { background: white url('images/dropdown.png') right center no-repeat; }
128
- * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
129
- .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
130
- /* this limit the height of the result list*/
131
- .ui-autocomplete { max-height: 90px; overflow-y: auto; }
132
- * html .ui-autocomplete { height: 90px; }
133
- .ui-autocomplete .ui-state-hover, .ui-autocomplete .ui-widget-content .ui-state-hover { background: #1e90ff; color: #FFFFFF !important; }
134
- .ui-widget-content { border: 1px solid #dddddd; border-style:outset; background: #FFFFFF; }
135
- .ui-autocomplete, .ui-autocomplete .ui-corner-all { -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; }
136
- .ui-menu { list-style:none; padding: 1px; margin: 0; display:block; float: left; }
137
- .ui-menu .ui-menu { margin-top: -3px; }
138
- .ui-menu .ui-menu-item { margin:0; padding:0; zoom:1; float:left; clear:left; width:100%; }
139
- .ui-menu .ui-menu-item a { text-decoration:none; display:block; zoom:1; color: black;}
140
- .ui-helper-hidden-accessible {display: none}
 
1
+ /*
2
+ * jQuery UI CSS Framework @VERSION
3
+ *
4
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Theming/API
9
+ */
10
+
11
+ /* Layout helpers
12
+ ----------------------------------*/
13
+ .ui-helper-hidden { display: none; }
14
+ .ui-helper-hidden-accessible { position: absolute; left: -99999999px; }
15
+ .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
16
+ .ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
17
+ .ui-helper-clearfix { display: inline-block; }
18
+ /* required comment for clearfix to work in Opera \*/
19
+ * html .ui-helper-clearfix { height:1%; }
20
+ .ui-helper-clearfix { display:block; }
21
+ /* end clearfix */
22
+ .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
23
+
24
+ /* Component containers
25
+ ----------------------------------*/
26
+ .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
27
+ .ui-widget .ui-widget { font-size: 1em; }
28
+ .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
29
+ .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
30
+ .ui-widget-content a { color: #222222; }
31
+ .ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
32
+ .ui-widget-header a { color: #222222; }
33
+
34
+ /* Interaction Cues
35
+ ----------------------------------*/
36
+ .ui-state-disabled { cursor: default !important; }
37
+
38
+ /* Icons
39
+ ----------------------------------*/
40
+ .ui-icon-triangle-1-s { background-position: -64px -16px; }
41
+
42
+ /* states and images */
43
+ .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; margin-left: auto; margin-right: auto;}
44
+
45
+ /* Misc visuals
46
+ ----------------------------------*/
47
+
48
+ /* Overlays */
49
+ .ui-widget-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
50
+
51
+ /* jQuery UI CSS Framework @VERSION */
52
+
53
+ /* Interaction states
54
+ ----------------------------------*/
55
+ .ui-dialog-titlebar-close:hover { background: #464646 !important; font-weight: normal; color: #ffffff; }
56
+ .ui-widget :active { outline: none; }
57
+
58
+ /* Icons
59
+ ----------------------------------*/
60
+
61
+ /* states and images */
62
+ .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_cccccc_256x240.png); }
63
+ .ui-widget-content .ui-icon {background-image: url(images/ui-icons_cccccc_256x240.png); }
64
+ .ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
65
+ .ui-state-default .ui-icon { background-image: url(images/ui-icons_cccccc_256x240.png); }
66
+ .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png);}
67
+ .ui-state-active .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
68
+
69
+ /* positioning */
70
+ .ui-icon-close { background-position: -80px -128px; }
71
+ .ui-icon-closethick { background-position: -96px -128px; }
72
+ .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
73
+ .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
74
+
75
+ /* Misc visuals
76
+ ----------------------------------*/
77
+
78
+ /* Corner radius */
79
+ .ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; }
80
+ .ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; }
81
+ .ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; }
82
+ .ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; }
83
+ .ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; }
84
+ .ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; }
85
+ .ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; }
86
+ .ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; }
87
+
88
+ /* Overlays */
89
+ .ui-widget-overlay { background: #000000 50% 50% repeat-x; opacity: .50;filter:Alpha(Opacity=75); z-index:3; }
90
+ .ui-dialog {z-index: 5;}
91
+ .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #000000 50% 50% repeat-x; opacity: .75;filter:Alpha(Opacity=75); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/*
92
+
93
+ /* jQuery UI Resizable */
94
+ .ui-resizable { position: relative;}
95
+ .ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
96
+ .ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
97
+ .ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
98
+ .ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
99
+ .ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
100
+ .ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
101
+ .ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
102
+ .ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
103
+ .ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
104
+ .ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/*
105
+
106
+ /* jQuery UI Dialog */
107
+ .ui-dialog { position: absolute; width: 300px; overflow: hidden; background:white; }
108
+ .ui-dialog { -moz-box-shadow: rgba(0,0,0,1) 0 4px 30px; -webkit-box-shadow: rgba(0,0,0,1) 0 4px 30px; -khtml-box-shadow: rgba(0,0,0,1) 0 4px 30px; box-shadow: rgba(0,0,0,1) 0 4px 30px; }
109
+ .ui-dialog .ui-dialog-titlebar { position: relative; border-bottom: 1px solid #dfdfdf; }
110
+ .ui-dialog .ui-dialog-title { float: left; padding: 0 16px; font-size: 22px; font-weight: 200; line-height: 45px; margin: 0;}
111
+ .ui-dialog .ui-dialog-titlebar-close {position: absolute; right: .3em; top: .3em; bottom: .6em; width: 40px; margin: auto; padding: 1px; border: none; background: white;}
112
+ .ui-dialog-titlebar-close .ui-button-text {display:none;}
113
+ .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
114
+ .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
115
+ .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
116
+ .ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
117
+ .ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
118
+ .ui-draggable .ui-dialog-titlebar { cursor: move; }
119
+
120
+ /* jQuery UI Progressbar */
121
+ .ui-progressbar { height:2em; text-align: left; }
122
+ .ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
123
+
124
+ /* jQuery UI Dialog loading spinner */
125
+ #spinner {display: none; width:100px; height: 100px; position: fixed; top: 50%; left: 50%; background:url(../../images/loader.gif) no-repeat center #fff; padding:10px; border:1px solid #666; margin-left: -50px; margin-top: -50px; z-index:2; overflow: auto; }
126
+
127
+ /* jQuery Autocomplete */
128
+ .ui-autocomplete { position: absolute; cursor: default; }
129
+ .ui-autocomplete-start { background: white url('images/dropdown.png') right center no-repeat; }
130
+ * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
131
+ .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
132
+ /* this limit the height of the result list*/
133
+ .ui-autocomplete { max-height: 90px; overflow-y: auto; }
134
+ * html .ui-autocomplete { height: 90px; }
135
+ .ui-autocomplete .ui-state-hover, .ui-autocomplete .ui-widget-content .ui-state-hover { background: #1e90ff; color: #FFFFFF !important; }
136
+ .ui-autocomplete, .ui-autocomplete .ui-corner-all { -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; }
137
+ .ui-menu { list-style:none; padding: 1px; margin: 0; display:block; float: left; background: white;}
138
+ .ui-menu .ui-menu { margin-top: -3px; }
139
+ .ui-menu .ui-menu-item { margin:0; padding:0; zoom:1; float:left; clear:left; width:100%; }
140
+ .ui-menu .ui-menu-item a { text-decoration:none; display:block; zoom:1; color: black;}
141
+ .ui-helper-hidden-accessible {display: none}
admin/css/jquery.ui.datepicker.css ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery UI Datepicker 1.8.24
3
+ *
4
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Datepicker#theming
9
+ */
10
+ .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
11
+ .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
12
+ .ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
13
+ .ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
14
+ .ui-datepicker .ui-datepicker-prev { left:2px; }
15
+ .ui-datepicker .ui-datepicker-next { right:2px; }
16
+ .ui-datepicker .ui-datepicker-prev-hover { left:1px; }
17
+ .ui-datepicker .ui-datepicker-next-hover { right:1px; }
18
+ .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
19
+ .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
20
+ .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
21
+ .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
22
+ .ui-datepicker select.ui-datepicker-month,
23
+ .ui-datepicker select.ui-datepicker-year { width: 49%;}
24
+ .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
25
+ .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
26
+ .ui-datepicker td { border: 0; padding: 1px; }
27
+ .ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
28
+ .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
29
+ .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
30
+ .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
31
+
32
+ /* with multiple calendars */
33
+ .ui-datepicker.ui-datepicker-multi { width:auto; }
34
+ .ui-datepicker-multi .ui-datepicker-group { float:left; }
35
+ .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
36
+ .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
37
+ .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
38
+ .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
39
+ .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
40
+ .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
41
+ .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
42
+ .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
43
+
44
+ /* RTL support */
45
+ .ui-datepicker-rtl { direction: rtl; }
46
+ .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
47
+ .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
48
+ .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
49
+ .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
50
+ .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
51
+ .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
52
+ .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
53
+ .ui-datepicker-rtl .ui-datepicker-group { float:right; }
54
+ .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
55
+ .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
56
+
57
+ /* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
58
+ .ui-datepicker-cover {
59
+ position: absolute; /*must have*/
60
+ z-index: -1; /*must have*/
61
+ filter: mask(); /*must have*/
62
+ top: -4px; /*must have*/
63
+ left: -4px; /*must have*/
64
+ width: 200px; /*must have*/
65
+ height: 200px; /*must have*/
66
+ }
admin/css/jquery.ui.tabs.css CHANGED
@@ -1,158 +1,64 @@
1
- /* Caution! Ensure accessibility in print and other media types... */
2
- @media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */
3
- .ui-tabs-hide {
4
- display: none;
5
- }
6
- }
7
-
8
- /* Hide useless elements in print layouts... */
9
- @media print {
10
- .ui-tabs-nav {
11
- display: none;
12
- }
13
- }
14
-
15
- /* Skin */
16
- #slider {
17
- border-color:#EBEBEB rgb(204, 204, 204) rgb(204, 204, 204) rgb(235, 235, 235);
18
- border-style:solid;
19
- border-width:1px;
20
- margin:15px 15% 0pt 15px;
21
- padding:2px;
22
- }
23
- #tabs{
24
- display: block;
25
- background:#F1F1F1 none repeat scroll 0%;
26
- font-size:14px;
27
- overflow:hidden;
28
- }
29
-
30
- .ui-tabs-nav {
31
- list-style: none;
32
- margin: 0;
33
- padding: 0 0 0 10px;
34
- }
35
- .ui-tabs-nav:after { /* clearing without presentational markup, IE gets extra treatment */
36
- display: block;
37
- clear: both;
38
- content: " ";
39
- }
40
- .ui-tabs-nav li {
41
- float: left;
42
- padding: 6px 5px;
43
- min-width: 84px; /* be nice to Opera */
44
- margin: 2px 2px 0px 1px !important;
45
- text-decoration: none;
46
- list-style: none;
47
- }
48
- .ui-tabs-nav a, .ui-tabs-nav a span {
49
- display: block;
50
- padding: 0 1px;
51
- }
52
-
53
- .ui-tabs-nav a {
54
- margin: 1px 0 0; /* position: relative makes opacity fail for disabled tab in IE */
55
- padding-left: 0;
56
- color: #2583AD;
57
- line-height: 1.2;
58
- text-align: center;
59
- text-decoration: none;
60
- white-space: nowrap; /* required in IE 6 */
61
- outline: 0; /* prevent dotted border in Firefox */
62
- }
63
- .ui-tabs-nav .ui-tabs-selected{
64
- background: #6D6D6D url(../images/menu-bits.gif) repeat-x scroll left top;
65
- border-color: #6D6D6D;
66
- color: #FFFFFF;
67
- text-shadow:0 -1px 0 #666666;
68
-
69
- -moz-border-radius-topright: 6px;
70
- -khtml-border-top-right-radius: 6px;
71
- -webkit-border-top-right-radius: 6px;
72
- border-top-right-radius: 6px;
73
- -moz-border-radius-topleft: 6px;
74
- -khtml-border-top-left-radius: 6px;
75
- -webkit-border-top-left-radius: 6px;
76
- border-top-left-radius: 6px;
77
- }
78
-
79
- .ui-tabs-selected a,
80
- .ui-tabs-selected a:hover {
81
- color:#FFFFFF !important;
82
- }
83
-
84
- .ui-tabs-nav .ui-tabs-selected a,
85
- .ui-tabs-nav .ui-tabs-selected a:hover {
86
- position: relative;
87
- top: 1px;
88
- z-index: 2;
89
- margin-top: 0;
90
- }
91
-
92
- .ui-tabs-nav li a:hover {
93
- color:#D54E21;
94
- }
95
-
96
- .ui-tabs-nav a span {
97
- width: 64px; /* IE 6 treats width as min-width */
98
- min-width: 64px;
99
- height: 18px; /* IE 6 treats height as min-height */
100
- min-height: 18px;
101
- padding-top: 6px;
102
- padding-right: 0;
103
- }
104
- *>.ui-tabs-nav a span { /* hide from IE 6 */
105
- width: auto;
106
- height: auto;
107
- }
108
- .ui-tabs-nav .ui-tabs-selected a span {
109
- padding-bottom: 1px;
110
- }
111
- .ui-tabs-nav .ui-tabs-selected a, .ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active {
112
- background-position: 100% -150px;
113
- }
114
- .ui-tabs-nav a, .ui-tabs-nav .ui-tabs-disabled a:hover, .ui-tabs-nav .ui-tabs-disabled a:focus, .ui-tabs-nav .ui-tabs-disabled a:active {
115
- background-position: 100% -100px;
116
- }
117
- .ui-tabs-nav .ui-tabs-selected a span, .ui-tabs-nav a:hover span, .ui-tabs-nav a:focus span, .ui-tabs-nav a:active span {
118
- background-position: 0 -50px;
119
- }
120
- .ui-tabs-nav a span, .ui-tabs-nav .ui-tabs-disabled a:hover span, .ui-tabs-nav .ui-tabs-disabled a:focus span, .ui-tabs-nav .ui-tabs-disabled a:active span {
121
- background-position: 0 0;
122
- }
123
- .ui-tabs-nav .ui-tabs-selected a:link, .ui-tabs-nav .ui-tabs-selected a:visited, .ui-tabs-nav .ui-tabs-disabled a:link, .ui-tabs-nav .ui-tabs-disabled a:visited { /* @ Opera, use pseudo classes otherwise it confuses cursor... */
124
- cursor: text;
125
- }
126
- .ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active,
127
- .ui-tabs-nav .ui-tabs-unselect a:hover, .ui-tabs-nav .ui-tabs-unselect a:focus, .ui-tabs-nav .ui-tabs-unselect a:active { /* @ Opera, we need to be explicit again here now... */
128
- cursor: pointer;
129
- }
130
- .ui-tabs-disabled {
131
- opacity: .4;
132
- filter: alpha(opacity=40);
133
- }
134
- .ui-tabs-panel {
135
- border-top: 1px solid #97a5b0 !important;
136
- padding: 1em 8px;
137
- background: #fff; /* declare background color for container to avoid distorted fonts in IE while fading */
138
-
139
- /* overwrite wp-admin */
140
- border:none !important;
141
- height:100% !important;
142
- margin:0pt 0pt 0pt 0px !important;
143
- overflow:visible !important;
144
- }
145
-
146
- .ui-tabs-panel a {
147
- display:inline;
148
- }
149
-
150
-
151
- /* Additional IE specific bug fixes... */
152
- * html .ui-tabs-nav { /* auto clear, @ IE 6 & IE 7 Quirks Mode */
153
- display: inline-block;
154
- }
155
- *:first-child+html .ui-tabs-nav { /* @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
156
- display: inline-block;
157
- }
158
-
1
+ /* Caution! Ensure accessibility in print and other media types... */
2
+ @media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */
3
+ .ui-tabs-hide {
4
+ display: none;
5
+ }
6
+ }
7
+
8
+ /* Hide useless elements in print layouts... */
9
+ @media print {
10
+ .ui-tabs-nav {
11
+ display: none;
12
+ }
13
+ }
14
+
15
+ /* Skin */
16
+ #slider ul.ui-tabs-nav {
17
+ height: 33px;
18
+ border-bottom: 1px solid #CCCCCC;
19
+ padding: 9px 15px 0 10px;
20
+ }
21
+
22
+ #slider ul.ui-tabs-nav li {
23
+ float: left;
24
+ margin: 0 6px 0 0;
25
+ }
26
+
27
+ #slider ul.ui-tabs-nav li.ui-tabs-active a {
28
+ color: #000;
29
+ background: 0 0;
30
+ border-color: #ccc;
31
+ border-bottom-color: #f1f1f1;
32
+ border-bottom-width: 1px;
33
+ border-bottom-style: solid;
34
+ border-width: 1px;
35
+ }
36
+
37
+ #slider ul.ui-tabs-nav li.ui-tabs-active a:hover {
38
+ color: #000;
39
+ background: 0 0;
40
+ border-color: #ccc;
41
+ border-bottom-color: #f1f1f1;
42
+ }
43
+
44
+ #slider ul.ui-tabs-nav li a {
45
+ padding: 6px 10px;
46
+ font-weight: 700;
47
+ font-size: 15px;
48
+ line-height: 24px;
49
+ color: #555;
50
+ border-color: #ccc;
51
+ background: #e4e4e4;
52
+ }
53
+ #slider ul.ui-tabs-nav li a:hover{
54
+ background-color: #fff;
55
+ color: #464646;
56
+ }
57
+
58
+ /* Additional IE specific bug fixes... */
59
+ * html .ui-tabs-nav { /* auto clear, @ IE 6 & IE 7 Quirks Mode */
60
+ display: inline-block;
61
+ }
62
+ *:first-child+html .ui-tabs-nav { /* @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
63
+ display: inline-block;
64
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/css/ngg_social_media.css CHANGED
@@ -1,33 +1,34 @@
1
- #ngg_social_media {
2
- margin-top: -2px;
3
- width: 85%;
4
- position: relative;
5
- overflow: hidden;
6
- height: 20px;
7
- }
8
-
9
- .gallery_page_nggallery-manage-gallery #ngg_social_media,
10
- .gallery_page_nggallery-manage-album #ngg_social_media,
11
- .gallery_page_nggallery-tags #ngg_social_media,
12
- .gallery_page_nggallery-roles #ngg_social_media,
13
- .gallery_page_nggallery-about #ngg_social_media,
14
- .toplevel_page_nextgen-gallery #ngg_social_media {
15
- float: right;
16
- width: 55%;
17
- }
18
-
19
- #ngg_facebook_like {
20
- position: absolute;
21
- right: 0px;
22
- width: 81px;
23
- overflow: hidden;
24
- }
25
-
26
- #ngg_social_media .twitter-follow-button {
27
- position: absolute;
28
- right: 85px;
29
- }
30
-
31
- #slider {
32
- margin-top: 5px !important;
 
33
  }
1
+ /** Disabled for now
2
+ #ngg_social_media {
3
+ margin-top: -2px;
4
+ width: 85%;
5
+ position: relative;
6
+ overflow: hidden;
7
+ height: 20px;
8
+ }
9
+
10
+ .gallery_page_nggallery-manage-gallery #ngg_social_media,
11
+ .gallery_page_nggallery-manage-album #ngg_social_media,
12
+ .gallery_page_nggallery-tags #ngg_social_media,
13
+ .gallery_page_nggallery-roles #ngg_social_media,
14
+ .gallery_page_nggallery-about #ngg_social_media,
15
+ .toplevel_page_nextgen-gallery #ngg_social_media {
16
+ float: right;
17
+ width: 55%;
18
+ }
19
+
20
+ #ngg_facebook_like {
21
+ position: absolute;
22
+ right: 0px;
23
+ width: 81px;
24
+ overflow: hidden;
25
+ }
26
+
27
+ #ngg_social_media .twitter-follow-button {
28
+ position: absolute;
29
+ right: 85px;
30
+ }
31
+
32
+ #slider {
33
+ margin-top: 5px !important;
34
  }
admin/css/nggadmin.css CHANGED
@@ -1,7 +1,5 @@
1
- /*
2
- ** NextGEN Gallery Style for Wordpress 3.3
3
- */
4
-
5
  /* SETTINGS FOR Overview Gallery */
6
 
7
  #newversion {
@@ -88,20 +86,15 @@ a.switch-expert {
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 {
@@ -116,19 +109,14 @@ a.switch-expert {
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
 
@@ -143,10 +131,6 @@ p#ngg-inlinebutton {
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
  }
@@ -156,12 +140,12 @@ p#ngg-inlinebutton {
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 {
@@ -172,6 +156,74 @@ p#ngg-inlinebutton {
172
  width: 10%;
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  /* SETTINGS FOR PROGRESS BAR */
176
 
177
  div .progressborder {
@@ -285,7 +337,7 @@ div .innerhandle {
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 {
@@ -405,8 +457,11 @@ p#sortButton{
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
  }
 
 
 
 
1
+ /* NextGEN Gallery Style */
2
+
 
 
3
  /* SETTINGS FOR Overview Gallery */
4
 
5
  #newversion {
86
  float:right;
87
  font-size:90%;
88
  width:35%;
89
+ border:1px solid #CCCCCC;
90
+ padding: 1em;
 
91
  margin-bottom:10px;
92
  margin-left:10px;
93
  margin-right:8px;
94
+ background: white;
95
  }
96
  #wm-preview h3{
97
+ margin: 0;
 
 
 
 
98
  }
99
 
100
  #wm-position {
109
  clear:none;
110
  }
111
  .wm-table td {
 
112
  line-height:20px;
113
  margin-bottom:9px;
114
  padding:10px;
115
  }
116
  .wm-table th {
 
117
  padding:10px;
118
  text-align:left;
119
  }
 
 
 
120
 
121
  /* SETTINGS FOR MANAGE TABLE */
122
 
131
  top:-25pt;
132
  }
133
 
 
 
 
 
134
  .fixed .column-thumbnail{
135
  width:85px;
136
  }
140
  max-width:80px;
141
  }
142
 
143
+ .fixed .column-id, .fixed .column-quantity {
144
+ width: 3.5em;
145
  }
146
 
147
  .fixed .column-title {
148
+ width: 35%;
149
  }
150
 
151
  .fixed .column-description {
156
  width: 10%;
157
  }
158
 
159
+ .fixed .column-page_id{
160
+ width: 10%;
161
+ }
162
+
163
+ .images-grey-bubble{
164
+ height: 16px;
165
+ width: 16px;
166
+ }
167
+
168
+ .images-grey-bubble:before{
169
+ content: '\f233';
170
+ font: 400 20px/.5 dashicons;
171
+ speak: none;
172
+ display: inline-block;
173
+ padding: 0;
174
+ top: 4px;
175
+ left: -4px;
176
+ position: relative;
177
+ vertical-align: top;
178
+ -webkit-font-smoothing: antialiased;
179
+ -moz-osx-font-smoothing: grayscale;
180
+ text-decoration: none!important;
181
+ }
182
+
183
+ @media screen and (max-width: 782px) {
184
+ .fixed .column-page_id, .fixed .column-id , .fixed .column-description{
185
+ display: none;
186
+ }
187
+ .fixed .column-quantity{
188
+ width: 35px;
189
+ }
190
+ .fixed .column-title {
191
+ width: initial;
192
+ }
193
+ }
194
+
195
+ /* SETTINGS FOR GALLERY PROPERTIES */
196
+ #gallery-properties {
197
+ font-size: inherit;
198
+ }
199
+
200
+ #gallery-properties td {
201
+ margin-bottom: 0;
202
+ padding: 0;
203
+ vertical-align: top;
204
+ text-align: left;
205
+ }
206
+
207
+ /* SETTINGS FOR ADD NEW */
208
+ .add-new-form {
209
+ display: inline;
210
+ }
211
+ .add-new-form .add-new-h2{
212
+ display: inline;
213
+ color: #0074a2;
214
+ -webkit-transition-property: border,background,color;
215
+ -moz-transition-property: border,background,color;
216
+ transition-property: border,background,color;
217
+ -webkit-transition-duration: .05s;
218
+ -moz-transition-duration: .05s;
219
+ transition-duration: .05s;
220
+ -webkit-transition-timing-function: ease-in-out;
221
+ -moz-transition-timing-function: ease-in-out;
222
+ transition-timing-function: ease-in-out;
223
+ cursor: pointer;
224
+ line-height: initial;
225
+ }
226
+
227
  /* SETTINGS FOR PROGRESS BAR */
228
 
229
  div .progressborder {
337
  border-color:#DFDFDF;
338
  border-style:none solid solid;
339
  border-width:0 1px 1px;
340
+ padding: 10px;
341
  }
342
 
343
  .itemContent p {
457
 
458
  /* ABOUT PAGE */
459
  .ngg-list {
460
+ margin-left:30px;
461
+ list-style-position:outside;
 
462
  list-style-type:disc;
463
  }
464
+
465
+ /*Image Date Select*/
466
+ .datepicker { display: none; }
467
+ .change { font-size:9px; cursor: pointer; margin-left: 15px;}
admin/edit-thumbnail.php CHANGED
@@ -1,171 +1,166 @@
1
- <?php
2
-
3
- /**
4
-
5
- Custom thumbnail for NGG
6
- Author : Simone Fumagalli | simone@iliveinperego.com
7
- More info and update : http://www.iliveinperego.com/custom_thumbnail_for_ngg/
8
-
9
- Credits:
10
- NextGen Gallery : Alex Rabe | http://alexrabe.boelinger.com/wordpress-plugins/nextgen-gallery/
11
- jCrop : Kelly Hallman <khallman@wrack.org> | http://deepliquid.com/content/Jcrop.html
12
-
13
- **/
14
-
15
- require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
16
- require_once( NGGALLERY_ABSPATH . '/lib/image.php' );
17
-
18
- if ( !is_user_logged_in() )
19
- die(__('Cheatin&#8217; uh?'));
20
-
21
- if ( !current_user_can('NextGEN Manage gallery') )
22
- die(__('Cheatin&#8217; uh?'));
23
-
24
- global $wpdb;
25
-
26
- $id = (int) $_GET['id'];
27
-
28
- // let's get the image data
29
- $picture = nggdb::find_image($id);
30
-
31
- include_once( nggGallery::graphic_library() );
32
- $ngg_options=get_option('ngg_options');
33
-
34
- $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
35
- $thumb->resize(350,350);
36
- // we need the new dimension
37
- $resizedPreviewInfo = $thumb->newDimensions;
38
- $thumb->destruct();
39
-
40
- $preview_image = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
41
- $imageInfo = @getimagesize($picture->imagePath);
42
- $rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
43
-
44
- if ( ($ngg_options['thumbfix'] == 1) ) {
45
-
46
- $WidthHtmlPrev = $ngg_options['thumbwidth'];
47
- $HeightHtmlPrev = $ngg_options['thumbheight'];
48
-
49
- } else {
50
- // H > W
51
- if ($imageInfo[1] > $imageInfo[0]) {
52
-
53
- $HeightHtmlPrev = $ngg_options['thumbheight'];
54
- $WidthHtmlPrev = round($imageInfo[0] / ($imageInfo[1] / $ngg_options['thumbheight']),0);
55
-
56
- } else {
57
-
58
- $WidthHtmlPrev = $ngg_options['thumbwidth'];
59
- $HeightHtmlPrev = round($imageInfo[1] / ($imageInfo[0] / $ngg_options['thumbwidth']),0);
60
-
61
- }
62
- }
63
-
64
- ?>
65
- <script src="<?php echo NGGALLERY_URLPATH; ?>/admin/js/Jcrop/js/jquery.Jcrop.js"></script>
66
- <link rel="stylesheet" href="<?php echo NGGALLERY_URLPATH; ?>/admin/js/Jcrop/css/jquery.Jcrop.css" type="text/css" />
67
-
68
- <script type="text/javascript">
69
- //<![CDATA[
70
- var status = 'start';
71
- var xT, yT, wT, hT, selectedCoords;
72
- var selectedImage = "thumb<?php echo $id ?>";
73
-
74
- function showPreview(coords)
75
- {
76
-
77
- if (status != 'edit') {
78
- jQuery('#actualThumb').hide();
79
- jQuery('#previewNewThumb').show();
80
- status = 'edit';
81
- }
82
-
83
- var rx = <?php echo $WidthHtmlPrev; ?> / coords.w;
84
- var ry = <?php echo $HeightHtmlPrev; ?> / coords.h;
85
-
86
- jQuery('#imageToEditPreview').css({
87
- width: Math.round(rx * <?php echo $resizedPreviewInfo['newWidth']; ?>) + 'px',
88
- height: Math.round(ry * <?php echo $resizedPreviewInfo['newHeight']; ?>) + 'px',
89
- marginLeft: '-' + Math.round(rx * coords.x) + 'px',
90
- marginTop: '-' + Math.round(ry * coords.y) + 'px'
91
- });
92
-
93
- xT = coords.x;
94
- yT = coords.y;
95
- wT = coords.w;
96
- hT = coords.h;
97
-
98
- jQuery("#sizeThumb").html(xT+" "+yT+" "+wT+" "+hT);
99
-
100
- };
101
-
102
- function updateThumb() {
103
-
104
- if ( (wT == 0) || (hT == 0) || (wT == undefined) || (hT == undefined) ) {
105
- alert("<?php _e('Select with the mouse the area for the new thumbnail', 'nggallery'); ?>");
106
- return false;
107
- }
108
-
109
- jQuery.ajax({
110
- url: ajaxurl,
111
- type : "POST",
112
- data: {x: xT, y: yT, w: wT, h: hT, action: 'createNewThumb', id: <?php echo $id; ?>, rr: <?php echo str_replace(',','.',$rr); ?>},
113
- cache: false,
114
- success: function(data){
115
- var d = new Date();
116
- newUrl = jQuery("#"+selectedImage).attr("src") + "?" + d.getTime();
117
- jQuery("#"+selectedImage).attr("src" , newUrl);
118
-
119
- jQuery('#thumbMsg').html("<?php _e('Thumbnail updated', 'nggallery') ?>");
120
- jQuery('#thumbMsg').css({'display':'block'});
121
- setTimeout(function(){ jQuery('#thumbMsg').fadeOut('slow'); }, 1500);
122
- },
123
- error: function() {
124
- jQuery('#thumbMsg').html("<?php _e('Error updating thumbnail', 'nggallery') ?>");
125
- jQuery('#thumbMsg').css({'display':'block'});
126
- setTimeout(function(){ jQuery('#thumbMsg').fadeOut('slow'); }, 1500);
127
- }
128
- });
129
-
130
- };
131
- //]]>
132
- </script>
133
-
134
- <table width="98%" align="center" style="border:1px solid #DADADA">
135
- <tr>
136
- <td rowspan="3" valign="middle" align="center" width="350" style="background-color:#DADADA;">
137
- <img src="<?php echo esc_url( $preview_image ); ?>" alt="" id="imageToEdit" />
138
- </td>
139
- <td width="300" style="background-color : #DADADA;">
140
- <small style="margin-left:6px; display:block;"><?php esc_html_e('Select the area for the thumbnail from the picture on the left.', 'nggallery'); ?></small>
141
- </td>
142
- </tr>
143
- <tr>
144
- <td align="center" width="300" height="320">
145
- <div id="previewNewThumb" style="display:none;width:<?php echo $WidthHtmlPrev; ?>px;height:<?php echo $HeightHtmlPrev; ?>px;overflow:hidden; margin-left:5px;">
146
- <img src="<?php echo esc_url( $preview_image ); ?>" id="imageToEditPreview" />
147
- </div>
148
- <div id="actualThumb">
149
- <img src="<?php echo esc_url( $picture->thumbURL ); ?>?<?php echo time()?>" />
150
- </div>
151
- </td>
152
- </tr>
153
- <tr style="background-color:#DADADA;">
154
- <td>
155
- <input type="button" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>" onclick="updateThumb()" class="button-secondary" style="float:left; margin-left:4px;"/>
156
- <div id="thumbMsg" style="color:#FF0000; display : none;font-size:11px; float:right; width:60%; height:2em; line-height:2em;"></div>
157
- </td>
158
- </tr>
159
- </table>
160
-
161
- <script type="text/javascript">
162
- //<![CDATA[
163
- jQuery(document).ready(function(){
164
- jQuery('#imageToEdit').Jcrop({
165
- onChange: showPreview,
166
- onSelect: showPreview,
167
- aspectRatio: <?php echo str_replace(',', '.', round($WidthHtmlPrev/$HeightHtmlPrev, 3)); ?>
168
- });
169
- });
170
- //]]>
171
  </script>
1
+ <?php
2
+
3
+ /**
4
+
5
+ Custom thumbnail for NGG
6
+ Author : Simone Fumagalli | simone@iliveinperego.com
7
+ More info and update : http://www.iliveinperego.com/custom_thumbnail_for_ngg/
8
+
9
+ Credits:
10
+ NextGen Gallery : Alex Rabe | http://alexrabe.boelinger.com/wordpress-plugins/nextgen-gallery/
11
+ jCrop : Kelly Hallman <khallman@wrack.org> | http://deepliquid.com/content/Jcrop.html
12
+
13
+ **/
14
+
15
+ require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
16
+ require_once( NGGALLERY_ABSPATH . '/lib/image.php' );
17
+
18
+ if ( !is_user_logged_in() )
19
+ die(__('Cheatin&#8217; uh?'));
20
+
21
+ if ( !current_user_can('NextGEN Manage gallery') )
22
+ die(__('Cheatin&#8217; uh?'));
23
+
24
+ global $wpdb;
25
+
26
+ $id = (int) $_GET['id'];
27
+
28
+ // let's get the image data
29
+ $picture = nggdb::find_image($id);
30
+
31
+ include_once( nggGallery::graphic_library() );
32
+ $ngg_options=get_option('ngg_options');
33
+
34
+ $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
35
+ $thumb->resize(350,350);
36
+ // we need the new dimension
37
+ $resizedPreviewInfo = $thumb->newDimensions;
38
+ $thumb->destruct();
39
+
40
+ $preview_image = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $picture->pid . '&amp;width=350&amp;height=350';
41
+ $imageInfo = @getimagesize($picture->imagePath);
42
+ $rr = round($imageInfo[0] / $resizedPreviewInfo['newWidth'], 2);
43
+
44
+ if ( ($ngg_options['thumbfix'] == 1) ) {
45
+
46
+ $WidthHtmlPrev = $ngg_options['thumbwidth'];
47
+ $HeightHtmlPrev = $ngg_options['thumbheight'];
48
+
49
+ } else {
50
+ // H > W
51
+ if ($imageInfo[1] > $imageInfo[0]) {
52
+
53
+ $HeightHtmlPrev = $ngg_options['thumbheight'];
54
+ $WidthHtmlPrev = round($imageInfo[0] / ($imageInfo[1] / $ngg_options['thumbheight']),0);
55
+
56
+ } else {
57
+
58
+ $WidthHtmlPrev = $ngg_options['thumbwidth'];
59
+ $HeightHtmlPrev = round($imageInfo[1] / ($imageInfo[0] / $ngg_options['thumbwidth']),0);
60
+
61
+ }
62
+ }
63
+
64
+ ?>
65
+ <script src="<?php echo NGGALLERY_URLPATH; ?>/admin/js/Jcrop/js/jquery.Jcrop.js"></script>
66
+ <link rel="stylesheet" href="<?php echo NGGALLERY_URLPATH; ?>/admin/js/Jcrop/css/jquery.Jcrop.css" type="text/css" />
67
+
68
+ <script type="text/javascript">
69
+ //<![CDATA[
70
+ var status = 'start';
71
+ var xT, yT, wT, hT, selectedCoords;
72
+ var selectedImage = "thumb<?php echo $id ?>";
73
+
74
+ function showPreview(coords)
75
+ {
76
+
77
+ if (status != 'edit') {
78
+ jQuery('#actualThumb').hide();
79
+ jQuery('#previewNewThumb').show();
80
+ status = 'edit';
81
+ }
82
+
83
+ var rx = <?php echo $WidthHtmlPrev; ?> / coords.w;
84
+ var ry = <?php echo $HeightHtmlPrev; ?> / coords.h;
85
+
86
+ jQuery('#imageToEditPreview').css({
87
+ width: Math.round(rx * <?php echo $resizedPreviewInfo['newWidth']; ?>) + 'px',
88
+ height: Math.round(ry * <?php echo $resizedPreviewInfo['newHeight']; ?>) + 'px',
89
+ marginLeft: '-' + Math.round(rx * coords.x) + 'px',
90
+ marginTop: '-' + Math.round(ry * coords.y) + 'px'
91
+ });
92
+
93
+ xT = coords.x;
94
+ yT = coords.y;
95
+ wT = coords.w;
96
+ hT = coords.h;
97
+
98
+ jQuery("#sizeThumb").html(xT+" "+yT+" "+wT+" "+hT);
99
+
100
+ };
101
+
102
+ function updateThumb() {
103
+
104
+ if ( (wT == 0) || (hT == 0) || (wT == undefined) || (hT == undefined) ) {
105
+ alert("<?php _e('Select with the mouse the area for the new thumbnail', 'nggallery'); ?>");
106
+ return false;
107
+ }
108
+
109
+ jQuery.ajax({
110
+ url: ajaxurl,
111
+ type : "POST",
112
+ data: {x: xT, y: yT, w: wT, h: hT, action: 'createNewThumb', id: <?php echo $id; ?>, rr: <?php echo str_replace(',','.',$rr); ?>},
113
+ cache: false,
114
+ success: function(data){
115
+ var d = new Date();
116
+ newUrl = jQuery("#"+selectedImage).attr("src") + "?" + d.getTime();
117
+ jQuery("#"+selectedImage).attr("src" , newUrl);
118
+
119
+ jQuery('#thumbMsg').html("<?php _e('Thumbnail updated', 'nggallery') ?>");
120
+ jQuery('#thumbMsg').css({'display':'block'});
121
+ setTimeout(function(){ jQuery('#thumbMsg').fadeOut('slow'); }, 1500);
122
+ },
123
+ error: function() {
124
+ jQuery('#thumbMsg').html("<?php _e('Error updating thumbnail', 'nggallery') ?>");
125
+ jQuery('#thumbMsg').css({'display':'block'});
126
+ setTimeout(function(){ jQuery('#thumbMsg').fadeOut('slow'); }, 1500);
127
+ }
128
+ });
129
+
130
+ };
131
+ //]]>
132
+ </script>
133
+ <p><?php _e('Select the area for the thumbnail from the picture on the left.', 'nggallery'); ?></p>
134
+ <table width="98%" align="center">
135
+ <tr>
136
+ <td valign="middle" align="center" width="350">
137
+ <img src="<?php echo esc_url( $preview_image ); ?>" alt="" id="imageToEdit" />
138
+ </td>
139
+ <td align="center" width="300" height="319">
140
+ <div id="previewNewThumb" style="display:none;width:<?php echo $WidthHtmlPrev; ?>px;height:<?php echo $HeightHtmlPrev; ?>px;overflow:hidden; margin-left:5px;">
141
+ <img src="<?php echo esc_url( $preview_image ); ?>" id="imageToEditPreview" />
142
+ </div>
143
+ <div id="actualThumb">
144
+ <img src="<?php echo esc_url( $picture->thumbURL ); ?>?<?php echo time()?>" />
145
+ </div>
146
+ </td>
147
+ </tr>
148
+ <tr>
149
+ <td colspan="2">
150
+ <input type="button" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>" onclick="updateThumb()" class="button-primary" style="float:right; margin-top:0.5em;"/>
151
+ <div id="thumbMsg" style="display : none; float:right; width:60%; height:2em; line-height:2em;"></div>
152
+ </td>
153
+ </tr>
154
+ </table>
155
+
156
+ <script type="text/javascript">
157
+ //<![CDATA[
158
+ jQuery(document).ready(function(){
159
+ jQuery('#imageToEdit').Jcrop({
160
+ onChange: showPreview,
161
+ onSelect: showPreview,
162
+ aspectRatio: <?php echo str_replace(',', '.', round($WidthHtmlPrev/$HeightHtmlPrev, 3)); ?>
163
+ });
164
+ });
165
+ //]]>
 
 
 
 
 
166
  </script>
admin/functions.php CHANGED
@@ -1,1501 +1,1501 @@
1
- <?php
2
-
3
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
-
5
- /**
6
- * nggAdmin - Class for admin operation
7
- *
8
- * @package NextGEN Gallery
9
- * @author Alex Rabe
10
- *
11
- * @access public
12
- */
13
- class nggAdmin{
14
-
15
- /**
16
- * create a new gallery & folder
17
- *
18
- * @class nggAdmin
19
- * @param string $name of the gallery
20
- * @param string $defaultpath
21
- * @param bool $output if the function should show an error messsage or not
22
- * @return
23
- */
24
- function create_gallery($title, $defaultpath, $output = true) {
25
-
26
- global $user_ID;
27
-
28
- // get the current user ID
29
- get_currentuserinfo();
30
-
31
- //cleanup pathname
32
- $name = sanitize_file_name( sanitize_title($title) );
33
- $name = apply_filters('ngg_gallery_name', $name);
34
- $nggRoot = WINABSPATH . $defaultpath;
35
- $txt = '';
36
-
37
- // No gallery name ?
38
- if ( empty($name) ) {
39
- if ($output) nggGallery::show_error( __('No valid gallery name!', 'nggallery') );
40
- return false;
41
- }
42
-
43
- // check for main folder
44
- if ( !is_dir($nggRoot) ) {
45
- if ( !wp_mkdir_p( $nggRoot ) ) {
46
- $txt = __('Directory', 'nggallery').' <strong>' . esc_html( $defaultpath ) . '</strong> '.__('didn\'t exist. Please create first the main gallery folder ', 'nggallery').'!<br />';
47
- $txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery').' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> ';
48
- if ($output) nggGallery::show_error($txt);
49
- return false;
50
- }
51
- }
52
-
53
- // check for permission settings, Safe mode limitations are not taken into account.
54
- if ( !is_writeable( $nggRoot ) ) {
55
- $txt = __('Directory', 'nggallery').' <strong>' . esc_html( $defaultpath ) . '</strong> '.__('is not writeable !', 'nggallery').'<br />';
56
- $txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery').' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> ';
57
- if ($output) nggGallery::show_error($txt);
58
- return false;
59
- }
60
-
61
- // 1. Check for existing folder
62
- if ( is_dir(WINABSPATH . $defaultpath . $name ) && !(SAFE_MODE) ) {
63
- $suffix = 1;
64
- do {
65
- $alt_name = substr ($name, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "_$suffix";
66
- $dir_check = is_dir(WINABSPATH . $defaultpath . $alt_name );
67
- $suffix++;
68
- } while ( $dir_check );
69
- $name = $alt_name;
70
- }
71
- // define relative path to gallery inside wp root folder
72
- $nggpath = $defaultpath . $name;
73
-
74
- // 2. Create new gallery folder
75
- if ( !wp_mkdir_p (WINABSPATH . $nggpath) )
76
- $txt = __('Unable to create directory ', 'nggallery') . esc_html( $nggpath ) . '!<br />';
77
-
78
- // 3. Check folder permission
79
- if ( !is_writeable(WINABSPATH . $nggpath ) )
80
- $txt .= __('Directory', 'nggallery').' <strong>' . esc_html( $nggpath ) . '</strong> '.__('is not writeable !', 'nggallery').'<br />';
81
-
82
- // 4. Now create thumbnail folder inside
83
- if ( !is_dir(WINABSPATH . $nggpath . '/thumbs') ) {
84
- if ( !wp_mkdir_p ( WINABSPATH . $nggpath . '/thumbs') )
85
- $txt .= __('Unable to create directory ', 'nggallery').' <strong>' . esc_html( $nggpath ) . '/thumbs !</strong>';
86
- }
87
-
88
- if (SAFE_MODE) {
89
- $help = __('The server setting Safe-Mode is on !', 'nggallery');
90
- $help .= '<br />'.__('If you have problems, please create directory', 'nggallery').' <strong>' . esc_html( $nggpath ) . '</strong> ';
91
- $help .= __('and the thumbnails directory', 'nggallery').' <strong>' . esc_html( $nggpath ) . '/thumbs</strong> '.__('with permission 777 manually !', 'nggallery');
92
- if ($output) nggGallery::show_message($help);
93
- }
94
-
95
- // show a error message
96
- if ( !empty($txt) ) {
97
- if (SAFE_MODE) {
98
- // for safe_mode , better delete folder, both folder must be created manually
99
- @rmdir(WINABSPATH . $nggpath . '/thumbs');
100
- @rmdir(WINABSPATH . $nggpath);
101
- }
102
- if ($output) nggGallery::show_error($txt);
103
- return false;
104
- }
105
-
106
- // now add the gallery to the database
107
- $galleryID = nggdb::add_gallery($title, $nggpath, '', 0, 0, $user_ID );
108
- // here you can inject a custom function
109
- do_action('ngg_created_new_gallery', $galleryID);
110
-
111
- // return only the id if defined
112
- if ($output == false)
113
- return $galleryID;
114
-
115
- if ($galleryID != false) {
116
- $message = __('Gallery ID %1$s successfully created. You can show this gallery in your post or page with the shortcode %2$s.<br/>','nggallery');
117
- $message = sprintf($message, $galleryID, '<strong>[nggallery id=' . $galleryID . ']</strong>');
118
- $message .= '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $galleryID . '" >';
119
- $message .= __('Edit gallery','nggallery');
120
- $message .= '</a>';
121
-
122
- if ($output) nggGallery::show_message($message);
123
- }
124
- return true;
125
- }
126
-
127
- /**
128
- * nggAdmin::import_gallery()
129
- * TODO: Check permission of existing thumb folder & images
130
- *
131
- * @class nggAdmin
132
- * @param string $galleryfolder contains relative path to the gallery itself
133
- * @return void
134
- */
135
- function import_gallery($galleryfolder) {
136
-
137
- global $wpdb, $user_ID;
138
-
139
- // get the current user ID
140
- get_currentuserinfo();
141
-
142
- $created_msg = '';
143
-
144
- // remove trailing slash at the end, if somebody use it
145
- $galleryfolder = untrailingslashit($galleryfolder);
146
- $gallerypath = WINABSPATH . $galleryfolder;
147
-
148
- if (!is_dir($gallerypath)) {
149
- nggGallery::show_error(__('Directory', 'nggallery').' <strong>' . esc_html( $gallerypath ) .'</strong> '.__('doesn&#96;t exist!', 'nggallery'));
150
- return ;
151
- }
152
-
153
- // read list of images
154
- $new_imageslist = nggAdmin::scandir($gallerypath);
155
-
156
- if (empty($new_imageslist)) {
157
- nggGallery::show_message(__('Directory', 'nggallery').' <strong>' . esc_html( $gallerypath ) . '</strong> '.__('contains no pictures', 'nggallery'));
158
- return;
159
- }
160
-
161
- // check & create thumbnail folder
162
- if ( !nggGallery::get_thumbnail_folder($gallerypath) )
163
- return;
164
-
165
- // take folder name as gallery name
166
- $galleryname = basename($galleryfolder);
167
- $galleryname = apply_filters('ngg_gallery_name', $galleryname);
168
-
169
- // check for existing gallery folder
170
- $gallery_id = $wpdb->get_var("SELECT gid FROM $wpdb->nggallery WHERE path = '$galleryfolder' ");
171
-
172
- if (!$gallery_id) {
173
- // now add the gallery to the database
174
- $gallery_id = nggdb::add_gallery( $galleryname, $galleryfolder, '', 0, 0, $user_ID );
175
- if (!$gallery_id) {
176
- nggGallery::show_error(__('Database error. Could not add gallery!','nggallery'));
177
- return;
178
- }
179
- $created_msg = _n( 'Gallery', 'Galleries', 1, 'nggallery' ) . ' <strong>' . esc_html( $galleryname ) . '</strong> ' . __('successfully created!','nggallery') . '<br />';
180
- }
181
-
182
- // Look for existing image list
183
- $old_imageslist = $wpdb->get_col("SELECT filename FROM $wpdb->nggpictures WHERE galleryid = '$gallery_id' ");
184
-
185
- // if no images are there, create empty array
186
- if ($old_imageslist == NULL)
187
- $old_imageslist = array();
188
-
189
- // check difference
190
- $new_images = array_diff($new_imageslist, $old_imageslist);
191
-
192
- // all images must be valid files
193
- foreach($new_images as $key => $picture) {
194
-
195
- // filter function to rename/change/modify image before
196
- $picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id);
197
- $new_images[$key] = $picture;
198
-
199
- if (!@getimagesize($gallerypath . '/' . $picture) ) {
200
- unset($new_images[$key]);
201
- @unlink($gallerypath . '/' . $picture);
202
- }
203
- }
204
-
205
- // add images to database
206
- $image_ids = nggAdmin::add_Images($gallery_id, $new_images);
207
-
208
- //add the preview image if needed
209
- nggAdmin::set_gallery_preview ( $gallery_id );
210
-
211
- // now create thumbnails
212
- nggAdmin::do_ajax_operation( 'create_thumbnail' , $image_ids, __('Create new thumbnails','nggallery') );
213
-
214
- //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
215
- $message = $created_msg . count($image_ids) .__(' picture(s) successfully added','nggallery');
216
- $message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >';
217
- $message .= __('Edit gallery','nggallery');
218
- $message .= '</a>]';
219
-
220
- nggGallery::show_message($message);
221
-
222
- return;
223
-
224
- }
225
-
226
- /**
227
- * Scan folder for new images
228
- *
229
- * @class nggAdmin
230
- * @param string $dirname
231
- * @return array $files list of image filenames
232
- */
233
- function scandir( $dirname = '.' ) {
234
- $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif') );
235
-
236
- $files = array();
237
- if( $handle = opendir( $dirname ) ) {
238
- while( false !== ( $file = readdir( $handle ) ) ) {
239
- $info = pathinfo( $file );
240
- // just look for images with the correct extension
241
- if ( isset($info['extension']) )
242
- if ( in_array( strtolower($info['extension']), $ext) )
243
- $files[] = utf8_encode( $file );
244
- }
245
- closedir( $handle );
246
- }
247
- sort( $files );
248
- return ( $files );
249
- }
250
-
251
- /**
252
- * nggAdmin::createThumbnail() - function to create or recreate a thumbnail
253
- *
254
- * @class nggAdmin
255
- * @param object | int $image contain all information about the image or the id
256
- * @return string result code
257
- * @since v1.0.0
258
- */
259
- function create_thumbnail($image) {
260
-
261
- global $ngg;
262
-
263
- if(! class_exists('ngg_Thumbnail'))
264
- require_once( nggGallery::graphic_library() );
265
-
266
- if ( is_numeric($image) )
267
- $image = nggdb::find_image( $image );
268
-
269
- if ( !is_object($image) )
270
- return __('Object didn\'t contain correct data','nggallery');
271
-
272
- // before we start we import the meta data to database (required for uploads before V1.4.0)
273
- nggAdmin::maybe_import_meta( $image->pid );
274
-
275
- // check for existing thumbnail
276
- if (file_exists($image->thumbPath))
277
- if (!is_writable($image->thumbPath))
278
- return esc_html( $image->filename ) . __(' is not writeable ','nggallery');
279
-
280
- $thumb = new ngg_Thumbnail($image->imagePath, TRUE);
281
-
282
- // skip if file is not there
283
- if (!$thumb->error) {
284
- if ($ngg->options['thumbfix']) {
285
-
286
- // calculate correct ratio
287
- $wratio = $ngg->options['thumbwidth'] / $thumb->currentDimensions['width'];
288
- $hratio = $ngg->options['thumbheight'] / $thumb->currentDimensions['height'];
289
-
290
- if ($wratio > $hratio) {
291
- // first resize to the wanted width
292
- $thumb->resize($ngg->options['thumbwidth'], 0);
293
- // get optimal y startpos
294
- $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
295
- $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
296
- } else {
297
- // first resize to the wanted height
298
- $thumb->resize(0, $ngg->options['thumbheight']);
299
- // get optimal x startpos
300
- $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
301
- $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
302
- }
303
- //this create a thumbnail but keep ratio settings
304
- } else {
305
- $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
306
- }
307
-
308
- // save the new thumbnail
309
- $thumb->save($image->thumbPath, $ngg->options['thumbquality']);
310
- nggAdmin::chmod ($image->thumbPath);
311
-
312
- //read the new sizes
313
- $new_size = @getimagesize ( $image->thumbPath );
314
- $size['width'] = $new_size[0];
315
- $size['height'] = $new_size[1];
316
-
317
- // add them to the database
318
- nggdb::update_image_meta($image->pid, array( 'thumbnail' => $size) );
319
- }
320
-
321
- $thumb->destruct();
322
-
323
- if ( !empty($thumb->errmsg) )
324
- return ' <strong>' . esc_html( $image->filename ) . ' (Error : '.$thumb->errmsg .')</strong>';
325
-
326
- // success
327
- return '1';
328
- }
329
-
330
- /**
331
- * nggAdmin::resize_image() - create a new image, based on the height /width
332
- *
333
- * @class nggAdmin
334
- * @param object | int $image contain all information about the image or the id
335
- * @param integer $width optional
336
- * @param integer $height optional
337
- * @return string result code
338
- */
339
- function resize_image($image, $width = 0, $height = 0) {
340
-
341
- global $ngg;
342
-
343
- if(! class_exists('ngg_Thumbnail'))
344
- require_once( nggGallery::graphic_library() );
345
-
346
- if ( is_numeric($image) )
347
- $image = nggdb::find_image( $image );
348
-
349
- if ( !is_object($image) )
350
- return __('Object didn\'t contain correct data','nggallery');
351
-
352
- // before we start we import the meta data to database (required for uploads before V1.4.0)
353
- nggAdmin::maybe_import_meta( $image->pid );
354
-
355
- // if no parameter is set, take global settings
356
- $width = ($width == 0) ? $ngg->options['imgWidth'] : $width;
357
- $height = ($height == 0) ? $ngg->options['imgHeight'] : $height;
358
-
359
- if (!is_writable($image->imagePath))
360
- return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
361
-
362
- $file = new ngg_Thumbnail($image->imagePath, TRUE);
363
-
364
- // skip if file is not there
365
- if (!$file->error) {
366
-
367
- // If required save a backup copy of the file
368
- if ( ($ngg->options['imgBackup'] == 1) && (!file_exists($image->imagePath . '_backup')) )
369
- @copy ($image->imagePath, $image->imagePath . '_backup');
370
-
371
- $file->resize($width, $height);
372
- $file->save($image->imagePath, $ngg->options['imgQuality']);
373
- // read the new sizes
374
- $size = @getimagesize ( $image->imagePath );
375
- // add them to the database
376
- nggdb::update_image_meta($image->pid, array( 'width' => $size[0], 'height' => $size[1] ) );
377
- $file->destruct();
378
- } else {
379
- $file->destruct();
380
- return ' <strong>' . esc_html( $image->filename ) . ' (Error : ' . $file->errmsg . ')</strong>';
381
- }
382
-
383
- return '1';
384
- }
385
-
386
- /**
387
- * Rotated/Flip an image based on the orientation flag or a definded angle
388
- *
389
- * @param int|object $image
390
- * @param string (optional) $dir, CW (clockwise)or CCW (counter clockwise), if set to false, the exif flag will be used
391
- * @param string (optional) $flip, could be either false | V (flip vertical) | H (flip horizontal)
392
- * @return string result code
393
- */
394
- function rotate_image($image, $dir = false, $flip = false) {
395
-
396
- global $ngg;
397
-
398
- if(! class_exists('ngg_Thumbnail'))
399
- require_once( nggGallery::graphic_library() );
400
-
401
- if ( is_numeric($image) )
402
- $image = nggdb::find_image( $image );
403
-
404
- if ( !is_object($image) )
405
- return __('Object didn\'t contain correct data','nggallery');
406
-
407
- if (!is_writable($image->imagePath))
408
- return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
409
-
410
- // if you didn't define a rotation, we look for the orientation flag in EXIF
411
- if ( $dir === false ) {
412
- $meta = new nggMeta( $image->pid );
413
- $exif = $meta->get_EXIF();
414
-
415
- if (isset($exif['Orientation'])) {
416
-
417
- switch ($exif['Orientation']) {
418
- case 5 : // vertical flip + 90 rotate right
419
- $flip = 'V';
420
- case 6 : // 90 rotate right
421
- $dir = 'CW';
422
- break;
423
- case 7 : // horizontal flip + 90 rotate right
424
- $flip = 'H';
425
- case 8 : // 90 rotate left
426
- $dir = 'CCW';
427
- break;
428
- case 4 : // vertical flip
429
- $flip = 'V';
430
- break;
431
- case 3 : // 180 rotate left
432
- $dir = 180;
433
- break;
434
- case 2 : // horizontal flip
435
- $flip = 'H';
436
- break;
437
- case 1 : // no action in the case it doesn't need a rotation
438
- default:
439
- return '0';
440
- break;
441
- }
442
- } else
443
- return '0';
444
- }
445
- $file = new ngg_Thumbnail( $image->imagePath, TRUE );
446
-
447
- // skip if file is not there
448
- if (!$file->error) {
449
-
450
- // If required save a backup copy of the file
451
- if ( ($ngg->options['imgBackup'] == 1) && (!file_exists($image->imagePath . '_backup')) )
452
- @copy ($image->imagePath, $image->imagePath . '_backup');
453
-
454
- // before we start we import the meta data to database (required for uploads before V1.4.X)
455
- nggAdmin::maybe_import_meta( $image->pid );
456
-
457
- if ( $dir !== 0 )
458
- $file->rotateImage( $dir );
459
- if ( $dir === 180)
460
- $file->rotateImage( 'CCW' ); // very special case, we rotate the image two times
461
- if ( $flip == 'H')
462
- $file->flipImage(true, false);
463
- if ( $flip == 'V')
464
- $file->flipImage(false, true);
465
-
466
- $file->save($image->imagePath, $ngg->options['imgQuality']);
467
-
468
- // read the new sizes
469
- $size = @getimagesize ( $image->imagePath );
470
- // add them to the database
471
- nggdb::update_image_meta($image->pid, array( 'width' => $size[0], 'height' => $size[1] ) );
472
-
473
- }
474
-
475
- $file->destruct();
476
-
477
- if ( !empty($file->errmsg) )
478
- return ' <strong>' . esc_html( $image->filename ) . ' (Error : '.$file->errmsg .')</strong>';
479
-
480
- return '1';
481
-
482
- }
483
-
484
- /**
485
- * nggAdmin::set_watermark() - set the watermark for the image
486
- *
487
- * @class nggAdmin
488
- * @param object | int $image contain all information about the image or the id
489
- * @return string result code
490
- */
491
- function set_watermark($image) {
492
-
493
- global $ngg;
494
-
495
- if(! class_exists('ngg_Thumbnail'))
496
- require_once( nggGallery::graphic_library() );
497
-
498
- if ( is_numeric($image) )
499
- $image = nggdb::find_image( $image );
500
-
501
- if ( !is_object($image) )
502
- return __('Object didn\'t contain correct data','nggallery');
503
-
504
- // before we start we import the meta data to database (required for uploads before V1.4.0)
505
- nggAdmin::maybe_import_meta( $image->pid );
506
-
507
- if (!is_writable($image->imagePath))
508
- return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
509
-
510
- $file = new ngg_Thumbnail( $image->imagePath, TRUE );
511
-
512
- // skip if file is not there
513
- if (!$file->error) {
514
-
515
- // If required save a backup copy of the file
516
- if ( ($ngg->options['imgBackup'] == 1) && (!file_exists($image->imagePath . '_backup')) )
517
- @copy ($image->imagePath, $image->imagePath . '_backup');
518
-
519
- if ($ngg->options['wmType'] == 'image') {
520
- $file->watermarkImgPath = $ngg->options['wmPath'];
521
- $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
522
- }
523
- if ($ngg->options['wmType'] == 'text') {
524
- $file->watermarkText = $ngg->options['wmText'];
525
- $file->watermarkCreateText($ngg->options['wmColor'], $ngg->options['wmFont'], $ngg->options['wmSize'], $ngg->options['wmOpaque']);
526
- $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
527
- }
528
- $file->save($image->imagePath, $ngg->options['imgQuality']);
529
- }
530
-
531
- $file->destruct();
532
-
533
- if ( !empty($file->errmsg) )
534
- return ' <strong>' . esc_html( $image->filename ) . ' (Error : '.$file->errmsg .')</strong>';
535
-
536
- return '1';
537
- }
538
-
539
- /**
540
- * Recover image from backup copy and reprocess it
541
- *
542
- * @class nggAdmin
543
- * @since 1.5.0
544
- * @param object | int $image contain all information about the image or the id
545
- * @return string result code
546
- */
547
-
548
- function recover_image($image) {
549
-
550
- global $ngg;
551
-
552
- if ( is_numeric($image) )
553
- $image = nggdb::find_image( $image );
554
-
555
- if ( !is_object( $image ) )
556
- return __('Object didn\'t contain correct data','nggallery');
557
-
558
- if (!is_writable( $image->imagePath ))
559
- return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
560
-
561
- if (!file_exists( $image->imagePath . '_backup' )) {
562
- return ' <strong>'.__('File do not exists','nggallery').'</strong>';
563
- }
564
-
565
- if (!@copy( $image->imagePath . '_backup' , $image->imagePath) )
566
- return ' <strong>'.__('Couldn\'t restore original image','nggallery').'</strong>';
567
-
568
- require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
569
-
570
- $meta_obj = new nggMeta( $image->pid );
571
-
572
- $common = $meta_obj->get_common_meta();
573
- $common['saved'] = true;
574
- $result = nggdb::update_image_meta($image->pid, $common);
575
-
576
- return '1';
577
-
578
- }
579
-
580
- /**
581
- * Add images to database
582
- *
583
- * @class nggAdmin
584
- * @param int $galleryID
585
- * @param array $imageslist
586
- * @return array $image_ids Id's which are sucessful added
587
- */
588
- function add_Images($galleryID, $imageslist) {
589
-
590
- global $wpdb, $ngg;
591
-
592
- $image_ids = array();
593
-
594
- if ( is_array($imageslist) ) {
595
- foreach($imageslist as $picture) {
596
-
597
- // filter function to rename/change/modify image before
598
- $picture = apply_filters('ngg_pre_add_new_image', $picture, $galleryID);
599
-
600
- // strip off the extension of the filename
601
- $path_parts = pathinfo( $picture );
602
- $alttext = ( !isset($path_parts['filename']) ) ? substr($path_parts['basename'], 0,strpos($path_parts['basename'], '.')) : $path_parts['filename'];
603
- // save it to the database
604
- $pic_id = nggdb::add_image( $galleryID, $picture, '', $alttext );
605
-
606
- if ( !empty($pic_id) )
607
- $image_ids[] = $pic_id;
608
-
609
- // add the metadata
610
- nggAdmin::import_MetaData( $pic_id );
611
-
612
- // auto rotate
613
- nggAdmin::rotate_image( $pic_id );
614
-
615
- // Autoresize image if required
616
- if ($ngg->options['imgAutoResize']) {
617
- $imagetmp = nggdb::find_image( $pic_id );
618
- $sizetmp = @getimagesize ( $imagetmp->imagePath );
619
- $widthtmp = $ngg->options['imgWidth'];
620
- $heighttmp = $ngg->options['imgHeight'];
621
- if (($sizetmp[0] > $widthtmp && $widthtmp) || ($sizetmp[1] > $heighttmp && $heighttmp)) {
622
- nggAdmin::resize_image( $pic_id );
623
- }
624
- }
625
-
626
- // action hook for post process after the image is added to the database
627
- $image = array( 'id' => $pic_id, 'filename' => $picture, 'galleryID' => $galleryID);
628
- do_action('ngg_added_new_image', $image);
629
-
630
- }
631
- } // is_array
632
-
633
- // delete dirsize after adding new images
634
- delete_transient( 'dirsize_cache' );
635
-
636
- do_action('ngg_after_new_images_added', $galleryID, $image_ids );
637
-
638
- return $image_ids;
639
-
640
- }
641
-
642
- /**
643
- * Import some meta data into the database (if avialable)
644
- *
645
- * @class nggAdmin
646
- * @param array|int $imagesIds
647
- * @return string result code
648
- */
649
- function import_MetaData($imagesIds) {
650
-
651
- global $wpdb;
652
-
653
- require_once(NGGALLERY_ABSPATH . '/lib/image.php');
654
-
655
- if (!is_array($imagesIds))
656
- $imagesIds = array($imagesIds);
657
-
658
- foreach($imagesIds as $imageID) {
659
-
660
- $image = nggdb::find_image( $imageID );
661
- if (!$image->error) {
662
-
663
- $meta = nggAdmin::get_MetaData( $image->pid );
664
-
665
- // get the title
666
- $alttext = empty( $meta['title'] ) ? $image->alttext : $meta['title'];
667
-
668
- // get the caption / description field
669
- $description = empty( $meta['caption'] ) ? $image->description : $meta['caption'];
670
-
671
- // get the file date/time from exif
672
- $timestamp = $meta['timestamp'];
673
- // first update database
674
- $result = $wpdb->query(
675
- $wpdb->prepare("UPDATE $wpdb->nggpictures SET
676
- alttext = %s,
677
- description = %s,
678
- imagedate = %s
679
- WHERE pid = %d", $alttext, $description, $timestamp, $image->pid) );
680
-
681
- if ($result === false)
682
- return ' <strong>' . esc_html( $image->filename ) . ' ' . __('(Error : Couldn\'t not update data base)', 'nggallery') . '</strong>';
683
-
684
- //this flag will inform us that the import is already one time performed
685
- $meta['common']['saved'] = true;
686
- $result = nggdb::update_image_meta($image->pid, $meta['common']);
687
-
688
- if ($result === false)
689
- return ' <strong>' . esc_html( $image->filename ) . ' ' . __('(Error : Couldn\'t not update meta data)', 'nggallery') . '</strong>';
690
-
691
- // add the tags if we found some
692
- if ($meta['keywords']) {
693
- $taglist = explode(',', $meta['keywords']);
694
- wp_set_object_terms($image->pid, $taglist, 'ngg_tag');
695
- }
696
-
697
- } else
698
- return ' <strong>' . esc_html( $image->filename ) . ' ' . __('(Error : Couldn\'t not find image)', 'nggallery') . '</strong>';// error check
699
- }
700
-
701
- return '1';
702
- }
703
-
704
- /**
705
- * nggAdmin::get_MetaData()
706
- *
707
- * @class nggAdmin
708
- * @require NextGEN Meta class
709
- * @param int $id image ID
710
- * @return array metadata
711
- */
712
- function get_MetaData($id) {
713
-
714
- require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
715
-
716
- $meta = array();
717
-
718
- $pdata = new nggMeta( $id );
719
-
720
- $meta['title'] = trim ( $pdata->get_META('title') );
721
- $meta['caption'] = trim ( $pdata->get_META('caption') );
722
- $meta['keywords'] = trim ( $pdata->get_META('keywords') );
723
- $meta['timestamp'] = $pdata->get_date_time();
724
- // this contain other useful meta information
725
- $meta['common'] = $pdata->get_common_meta();
726
- // hook for addon plugin to add more meta fields
727
- $meta = apply_filters('ngg_get_image_metadata', $meta, $pdata);
728
-
729
- return $meta;
730
-
731
- }
732
-
733
- /**
734
- * Maybe import some meta data to the database. The functions checks the flag 'saved'
735
- * and if based on compat reason (pre V1.4.0) we save then some meta datas to the database
736
- *
737
- * @since V1.4.0
738
- * @param int $id
739
- * @return result
740
- */
741
- function maybe_import_meta( $id ) {
742
-
743
- require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
744
-
745
- $meta_obj = new nggMeta( $id );
746
-
747
- if ( $meta_obj->image->meta_data['saved'] != true ) {
748
- $common = $meta_obj->get_common_meta();
749
- //this flag will inform us that the import is already one time performed
750
- $common['saved'] = true;
751
- $result = nggdb::update_image_meta($id, $common);
752
- } else
753
- return false;
754
-
755
- return $result;
756
-
757
- }
758
-
759
- /**
760
- * Unzip a file via the PclZip class
761
- *
762
- * @class nggAdmin
763
- * @require PclZip class
764
- * @param string $dir
765
- * @param string $file
766
- * @return bool
767
- */
768
- function unzip($dir, $file) {
769
-
770
- if(! class_exists('PclZip'))
771
- require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
772
-
773
- $archive = new PclZip($file);
774
-
775
- // extract all files in one folder
776
- if ($archive->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH,
777
- PCLZIP_CB_PRE_EXTRACT, 'ngg_getOnlyImages',
778
- PCLZIP_CB_POST_EXTRACT, 'ngg_checkExtract') == 0) {
779
- nggGallery::show_error( 'Error : ' . $archive->errorInfo(true) );
780
- return false;
781
- }
782
-
783
- return true;
784
- }
785
-
786
- /**
787
- * nggAdmin::getOnlyImages()
788
- *
789
- * @class nggAdmin
790
- * @param mixed $p_event
791
- * @param mixed $p_header
792
- * @return bool
793
- */
794
- function getOnlyImages($p_event, &$p_header) {
795
- // avoid null byte hack (THX to Dominic Szablewski)
796
- if ( strpos($p_header['filename'], chr(0) ) !== false )
797
- $p_header['filename'] = substr ( $p_header['filename'], 0, strpos($p_header['filename'], chr(0) ));
798
- // check for extension
799
- $info = pathinfo($p_header['filename']);
800
- // check for extension
801
- $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif') );
802
- if ( in_array( strtolower($info['extension']), $ext) ) {
803
- // For MAC skip the ".image" files
804
- if ($info['basename']{0} == '.' )
805
- return 0;
806
- else {
807
- // sanitize the file name before we do further processing
808
- $info['basename'] = sanitize_file_name( $info['basename'] );
809
- $p_header['filename'] = $info['dirname'] . '/' . $info['basename'];
810
- return 1;
811
- }
812
-
813
- }
814
- // ----- all other files are skipped
815
- else {
816
- return 0;
817
- }
818
- }
819
-
820
- /**
821
- * Import a ZIP file via a upload form or a URL
822
- *
823
- * @class nggAdmin
824
- * @param int (optional) $galleryID
825
- * @return bool $result
826
- */
827
- function import_zipfile($galleryID) {
828
-
829
- global $ngg, $wpdb;
830
-
831
- if (nggWPMU::check_quota())
832
- return false;
833
-
834
- $defaultpath = $ngg->options['gallerypath'];
835
- $zipurl = $_POST['zipurl'];
836
-
837
- // if someone entered a URL try to upload it
838
- if (!empty($zipurl) && (function_exists('curl_init')) ) {
839
-
840
- if (!(preg_match('/^http(s)?:\/\//i', $zipurl) )) {
841
- nggGallery::show_error( __('No valid URL path ','nggallery') );
842
- return false;
843
- }
844
-
845
- $temp_zipfile = tempnam('/tmp', 'zipimport_');
846
- $filename = basename($zipurl);
847
-
848
- //Grab the zip via cURL
849
- $save = fopen ( $temp_zipfile, "w" );
850
- $ch = curl_init ();
851
- curl_setopt ( $ch, CURLOPT_FILE, $save );
852
- curl_setopt ( $ch, CURLOPT_HEADER, 0 );
853
- curl_setopt ( $ch, CURLOPT_BINARYTRANSFER, 1 );
854
- curl_setopt ( $ch, CURLOPT_URL, $zipurl );
855
- $success = curl_exec ( $ch );
856
- if (!$success)
857
- nggGallery::show_error( __('Import via cURL failed.','nggallery') . ' Error code ' . curl_errno( $ch ) . ' : ' . curl_error( $ch ) );
858
- curl_close ( $ch );
859
- fclose($save);
860
-
861
- if (!$success)
862
- return false;
863
-
864
- } else {
865
-
866
- $temp_zipfile = $_FILES['zipfile']['tmp_name'];
867
- $filename = $_FILES['zipfile']['name'];
868
-
869
- // Chrome return a empty content-type : http://code.google.com/p/chromium/issues/detail?id=6800
870
- if ( !preg_match('/chrome/i', $_SERVER['HTTP_USER_AGENT']) ) {
871
- // check if file is a zip file
872
- if ( !preg_match('/(zip|download|octet-stream)/i', $_FILES['zipfile']['type']) ) {
873
- @unlink($temp_zipfile); // del temp file
874
- nggGallery::show_error(__('Uploaded file was no or a faulty zip file ! The server recognized : ','nggallery') . $_FILES['zipfile']['type']);
875
- return false;
876
- }
877
- }
878
- }
879
-
880
- // should this unpacked into a new folder ?
881
- if ( $galleryID == '0' ) {
882
- //cleanup and take the zipfile name as folder name
883
- $foldername = sanitize_title(strtok ($filename, '.'));
884
- $foldername = $defaultpath . $foldername;
885
- } else {
886
- // get foldername if selected
887
- $foldername = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
888
- }
889
-
890
- if ( empty($foldername) ) {
891
- nggGallery::show_error( __('Could not get a valid foldername', 'nggallery') );
892
- return false;
893
- }
894
-
895
- // set complete folder path
896
- $newfolder = WINABSPATH . $foldername;
897
-
898
- // check first if the traget folder exist
899
- if (!is_dir($newfolder)) {
900
- // create new directories
901
- if (!wp_mkdir_p ($newfolder)) {
902
- $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?', 'nggallery'), esc_html( $newfolder ) );
903
- nggGallery::show_error($message);
904
- return false;
905
- }
906
- if (!wp_mkdir_p ($newfolder . '/thumbs')) {
907
- nggGallery::show_error(__('Unable to create directory ', 'nggallery') . esc_html( $newfolder ). '/thumbs !');
908
- return false;
909
- }
910
- }
911
-
912
- // unzip and del temp file
913
- $result = nggAdmin::unzip($newfolder, $temp_zipfile);
914
- @unlink($temp_zipfile);
915
-
916
- if ($result) {
917
- $message = __('Zip-File successfully unpacked','nggallery') . '<br />';
918
-
919
- // parse now the folder and add to database
920
- $message .= nggAdmin::import_gallery( $foldername );
921
- nggGallery::show_message($message);
922
- }
923
-
924
- return true;
925
- }
926
-
927
- /**
928
- * Function for uploading of images via the upload form
929
- *
930
- * @class nggAdmin
931
- * @return void
932
- */
933
- function upload_images() {
934
-
935
- global $nggdb;
936
-
937
- // WPMU action
938
- if (nggWPMU::check_quota())
939
- return;
940
-
941
- // Images must be an array
942
- $imageslist = array();
943
-
944
- // get selected gallery
945
- $galleryID = (int) $_POST['galleryselect'];
946
-
947
- if ($galleryID == 0) {
948
- nggGallery::show_error(__('No gallery selected !','nggallery'));
949
- return;
950
- }
951
-
952
- // get the path to the gallery
953
- $gallery = $nggdb->find_gallery($galleryID);
954
-
955
- if ( empty($gallery->path) ){
956
- nggGallery::show_error(__('Failure in database, no gallery path set !','nggallery'));
957
- return;
958
- }
959
-
960
- // read list of images
961
- $dirlist = nggAdmin::scandir($gallery->abspath);
962
-
963
- $imagefiles = $_FILES['imagefiles'];
964
-
965
- if (is_array($imagefiles)) {
966
- foreach ($imagefiles['name'] as $key => $value) {
967
-
968
- // look only for uploded files
969
- if ($imagefiles['error'][$key] == 0) {
970
-
971
- $temp_file = $imagefiles['tmp_name'][$key];
972
-
973
- //clean filename and extract extension
974
- $filepart = nggGallery::fileinfo( $imagefiles['name'][$key] );
975
- $filename = $filepart['basename'];
976
-
977
- // check for allowed extension and if it's an image file
978
- $ext = array('jpg', 'png', 'gif');
979
- if ( !in_array($filepart['extension'], $ext) || !@getimagesize($temp_file) ){
980
- nggGallery::show_error('<strong>' . esc_html( $imagefiles['name'][$key] ) . ' </strong>' . __('is no valid image file!','nggallery'));
981
- continue;
982
- }
983
-
984
- // check if this filename already exist in the folder
985
- $i = 0;
986
- while ( in_array( $filename, $dirlist ) ) {
987
- $filename = $filepart['filename'] . '_' . $i++ . '.' .$filepart['extension'];
988
- }
989
-
990
- $dest_file = $gallery->abspath . '/' . $filename;
991
-
992
- //check for folder permission
993
- if ( !is_writeable($gallery->abspath) ) {
994
- $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html($gallery->abspath) );
995
- nggGallery::show_error($message);
996
- return;
997
- }
998
-
999
- // save temp file to gallery
1000
- if ( !@move_uploaded_file($temp_file, $dest_file) ){
1001
- nggGallery::show_error(__('Error, the file could not be moved to : ','nggallery') . esc_html( $dest_file ) );
1002
- nggAdmin::check_safemode( $gallery->abspath );
1003
- continue;
1004
- }
1005
- if ( !nggAdmin::chmod($dest_file) ) {
1006
- nggGallery::show_error(__('Error, the file permissions could not be set','nggallery'));
1007
- continue;
1008
- }
1009
-
1010
- // add to imagelist & dirlist
1011
- $imageslist[] = $filename;
1012
- $dirlist[] = $filename;
1013
-
1014
- }
1015
- }
1016
- }
1017
-
1018
- if (count($imageslist) > 0) {
1019
-
1020
- // add images to database
1021
- $image_ids = nggAdmin::add_Images($galleryID, $imageslist);
1022
-
1023
- //create thumbnails
1024
- nggAdmin::do_ajax_operation( 'create_thumbnail' , $image_ids, __('Create new thumbnails','nggallery') );
1025
-
1026
- //add the preview image if needed
1027
- nggAdmin::set_gallery_preview ( $galleryID );
1028
-
1029
- nggGallery::show_message( count($image_ids) . __(' Image(s) successfully added','nggallery'));
1030
- }
1031
-
1032
- return;
1033
-
1034
- }
1035
-
1036
- /**
1037
- * Upload function will be called via the Flash uploader
1038
- *
1039
- * @class nggAdmin
1040
- * @param integer $galleryID
1041
- * @return string $result
1042
- */
1043
- static function swfupload_image($galleryID = 0) {
1044
-
1045
- global $nggdb;
1046
-
1047
- if ($galleryID == 0)
1048
- return __('No gallery selected !', 'nggallery');
1049
-
1050
- // WPMU action
1051
- if (nggWPMU::check_quota())
1052
- return '0';
1053
-
1054
- // Check the upload
1055
- if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0)
1056
- return __('Invalid upload. Error Code : ', 'nggallery') . $_FILES['Filedata']['error'];
1057
-
1058
- // get the filename and extension
1059
- $temp_file = $_FILES['Filedata']['tmp_name'];
1060
-
1061
- $filepart = nggGallery::fileinfo( $_FILES['Filedata']['name'] );
1062
- $filename = $filepart['basename'];
1063
-
1064
- // check for allowed extension
1065
- $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif') );
1066
- if (!in_array( strtolower( $filepart['extension'] ), $ext))
1067
- return esc_html( $_FILES[$key]['name'] ) . __('is no valid image file!', 'nggallery');
1068
-
1069
- // get the path to the gallery
1070
- $gallery = $nggdb->find_gallery( (int) $galleryID );
1071
- if ( empty($gallery->path) ){
1072
- @unlink($temp_file);
1073
- return __('Failure in database, no gallery path set !', 'nggallery');
1074
- }
1075
-
1076
- // read list of images
1077
- $imageslist = nggAdmin::scandir( WINABSPATH . $gallery->path );
1078
-
1079
- // check if this filename already exist
1080
- $i = 0;
1081
- while (in_array($filename, $imageslist)) {
1082
- $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension'];
1083
- }
1084
-
1085
- $dest_file = WINABSPATH . $gallery->path . '/' . $filename;
1086
-
1087
- // save temp file to gallery
1088
- if ( !@move_uploaded_file($_FILES["Filedata"]['tmp_name'], $dest_file) ){
1089
- nggAdmin::check_safemode(WINABSPATH . $gallery->path);
1090
- return __('Error, the file could not be moved to : ','nggallery'). esc_html( $dest_file );
1091
- }
1092
-
1093
- if ( !nggAdmin::chmod($dest_file) )
1094
- return __('Error, the file permissions could not be set','nggallery');
1095
-
1096
- return '0';
1097
- }
1098
-
1099
- /**
1100
- * Set correct file permissions (taken from wp core)
1101
- *
1102
- * @class nggAdmin
1103
- * @param string $filename
1104
- * @return bool $result
1105
- */
1106
- function chmod($filename = '') {
1107
-
1108
- $stat = @ stat( dirname($filename) );
1109
- $perms = $stat['mode'] & 0000666; // Remove execute bits for files
1110
- if ( @chmod($filename, $perms) )
1111
- return true;
1112
-
1113
- return false;
1114
- }
1115
-
1116
- /**
1117
- * Check UID in folder and Script
1118
- * Read http://www.php.net/manual/en/features.safe-mode.php to understand safe_mode
1119
- *
1120
- * @class nggAdmin
1121
- * @param string $foldername
1122
- * @return bool $result
1123
- */
1124
- function check_safemode($foldername) {
1125
-
1126
- if ( SAFE_MODE ) {
1127
-
1128
- $script_uid = ( ini_get('safe_mode_gid') ) ? getmygid() : getmyuid();
1129
- $folder_uid = fileowner($foldername);
1130
-
1131
- if ($script_uid != $folder_uid) {
1132
- $message = sprintf(__('SAFE MODE Restriction in effect! You need to create the folder <strong>%s</strong> manually','nggallery'), esc_html( $foldername ) );
1133
- $message .= '<br />' . sprintf(__('When safe_mode is on, PHP checks to see if the owner (%s) of the current script matches the owner (%s) of the file to be operated on by a file function or its directory','nggallery'), $script_uid, $folder_uid );
1134
- nggGallery::show_error($message);
1135
- return false;
1136
- }
1137
- }
1138
-
1139
- return true;
1140
- }
1141
-
1142
- /**
1143
- * Capability check. Check is the ID fit's to the user_ID
1144
- *
1145
- * @class nggAdmin
1146
- * @param int $check_ID is the user_id
1147
- * @return bool $result
1148
- */
1149
- function can_manage_this_gallery($check_ID) {
1150
-
1151
- global $user_ID, $wp_roles;
1152
-
1153
- if ( !current_user_can('NextGEN Manage others gallery') ) {
1154
- // get the current user ID
1155
- get_currentuserinfo();
1156
-
1157
- if ( $user_ID != $check_ID)
1158
- return false;
1159
- }
1160
-
1161
- return true;
1162
-
1163
- }
1164
-
1165
- /**
1166
- * Move images from one folder to another
1167
- *
1168
- * @class nggAdmin
1169
- * @param array|int $pic_ids ID's of the images
1170
- * @param int $dest_gid destination gallery
1171
- * @return void
1172
- */
1173
- function move_images($pic_ids, $dest_gid) {
1174
-
1175
- $errors = '';
1176
- $count = 0;
1177
-
1178
- if ( !is_array($pic_ids) )
1179
- $pic_ids = array($pic_ids);
1180
-
1181
- // Get destination gallery
1182
- $destination = nggdb::find_gallery( $dest_gid );
1183
- $dest_abspath = WINABSPATH . $destination->path;
1184
-
1185
- if ( $destination == null ) {
1186
- nggGallery::show_error(__('The destination gallery does not exist','nggallery'));
1187
- return;
1188
- }
1189
-
1190
- // Check for folder permission
1191
- if ( !is_writeable( $dest_abspath ) ) {
1192
- $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html( $dest_abspath ) );
1193
- nggGallery::show_error($message);
1194
- return;
1195
- }
1196
-
1197
- // Get pictures
1198
- $images = nggdb::find_images_in_list($pic_ids);
1199
-
1200
- foreach ($images as $image) {
1201
-
1202
- $i = 0;
1203
- $tmp_prefix = '';
1204
-
1205
- $destination_file_name = $image->filename;
1206
- // check if the filename already exist, then we add a copy_ prefix
1207
- while (file_exists( $dest_abspath . '/' . $destination_file_name)) {
1208
- $tmp_prefix = 'copy_' . ($i++) . '_';
1209
- $destination_file_name = $tmp_prefix . $image->filename;
1210
- }
1211
-
1212
- $destination_path = $dest_abspath . '/' . $destination_file_name;
1213
- $destination_thumbnail = $dest_abspath . '/thumbs/thumbs_' . $destination_file_name;
1214
-
1215
- // Move files
1216
- if ( !@rename($image->imagePath, $destination_path) ) {
1217
- $errors .= sprintf(__('Failed to move image %1$s to %2$s','nggallery'),
1218
- '<strong>' . esc_html( $image->filename ) . '</strong>', esc_html( $destination_path ) ) . '<br />';
1219
- continue;
1220
- }
1221
-
1222
- // Move backup file, if possible
1223
- @rename($image->imagePath . '_backup', $destination_path . '_backup');
1224
- // Move the thumbnail, if possible
1225
- @rename($image->thumbPath, $destination_thumbnail);
1226
-
1227
- // Change the gallery id in the database , maybe the filename
1228
- if ( nggdb::update_image($image->pid, $dest_gid, $destination_file_name) )
1229
- $count++;
1230
-
1231
- }
1232
-
1233
- if ( $errors != '' )
1234
- nggGallery::show_error($errors);
1235
-
1236
- $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . esc_html( $destination->title ) . '</a>';
1237
- $messages = sprintf(__('Moved %1$s picture(s) to gallery : %2$s .','nggallery'), $count, $link);
1238
- nggGallery::show_message($messages);
1239
-
1240
- return;
1241
- }
1242
-
1243
- /**
1244
- * Copy images to another gallery
1245
- *
1246
- * @class nggAdmin
1247
- * @param array|int $pic_ids ID's of the images
1248
- * @param int $dest_gid destination gallery
1249
- * @return void
1250
- */
1251
- function copy_images($pic_ids, $dest_gid) {
1252
-
1253
- require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
1254
-
1255
- $errors = $messages = '';
1256
-
1257
- if (!is_array($pic_ids))
1258
- $pic_ids = array($pic_ids);
1259
-
1260
- // Get destination gallery
1261
- $destination = nggdb::find_gallery( $dest_gid );
1262
- if ( $destination == null ) {
1263
- nggGallery::show_error(__('The destination gallery does not exist','nggallery'));
1264
- return;
1265
- }
1266
-
1267
- // Check for folder permission
1268
- if (!is_writeable(WINABSPATH.$destination->path)) {
1269
- $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html( WINABSPATH.$destination->path) );
1270
- nggGallery::show_error($message);
1271
- return;
1272
- }
1273
-
1274
- // Get pictures
1275
- $images = nggdb::find_images_in_list($pic_ids);
1276
- $destination_path = WINABSPATH . $destination->path;
1277
-
1278
- foreach ($images as $image) {
1279
- // WPMU action
1280
- if ( nggWPMU::check_quota() )
1281
- return;
1282
-
1283
- $i = 0;
1284
- $tmp_prefix = '';
1285
- $destination_file_name = $image->filename;
1286
- while (file_exists($destination_path . '/' . $destination_file_name)) {
1287
- $tmp_prefix = 'copy_' . ($i++) . '_';
1288
- $destination_file_name = $tmp_prefix . $image->filename;
1289
- }
1290
-
1291
- $destination_file_path = $destination_path . '/' . $destination_file_name;
1292
- $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
1293
-
1294
- // Copy files
1295
- if ( !@copy($image->imagePath, $destination_file_path) ) {
1296
- $errors .= sprintf(__('Failed to copy image %1$s to %2$s','nggallery'),
1297
- esc_html( $image->filename ), esc_html( $destination_file_path) ) . '<br />';
1298
- continue;
1299
- }
1300
-
1301
- // Copy backup file, if possible
1302
- @copy($image->imagePath . '_backup', $destination_file_path . '_backup');
1303
- // Copy the thumbnail if possible
1304
- @copy($image->thumbPath, $destination_thumb_file_path);
1305
-
1306
- // Create new database entry for the image
1307
- $new_pid = nggdb::insert_image( $destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
1308
-
1309
- if (!isset($new_pid)) {
1310
- $errors .= sprintf(__('Failed to copy database row for picture %s','nggallery'), $image->pid) . '<br />';
1311
- continue;
1312
- }
1313
-
1314
- // Copy tags
1315
- nggTags::copy_tags($image->pid, $new_pid);
1316
-
1317
- // Copy meta information
1318
- $meta = new nggMeta($image->pid);
1319
- nggdb::update_image_meta( $new_pid, $meta->image->meta_data);
1320
-
1321
- if ( $tmp_prefix != '' ) {
1322
- $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) &raquo; The file already existed in the destination gallery.','nggallery'),
1323
- $image->pid, esc_html($image->filename), $new_pid, esc_html($destination_file_name) ) . '<br />';
1324
- } else {
1325
- $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)','nggallery'),
1326
- $image->pid, esc_html($image->filename), $new_pid, esc_html($destination_file_name) ) . '<br />';
1327
- }
1328
-
1329
- }
1330
-
1331
- // Finish by showing errors or success
1332
- if ( $errors == '' ) {
1333
- $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . esc_html($destination->title) . '</a>';
1334
- $messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .','nggallery'), count($images), $link);
1335
- }
1336
-
1337
- if ( $messages != '' )
1338
- nggGallery::show_message($messages);
1339
-
1340
- if ( $errors != '' )
1341
- nggGallery::show_error($errors);
1342
-
1343
- return;
1344
- }
1345
-
1346
- /**
1347
- * Initate the Ajax operation
1348
- *
1349
- * @class nggAdmin
1350
- * @param string $operation name of the function which should be executed
1351
- * @param array $image_array
1352
- * @param string $title name of the operation
1353
- * @return string the javascript output
1354
- */
1355
- function do_ajax_operation( $operation, $image_array, $title = '' ) {
1356
-
1357
- if ( !is_array($image_array) || empty($image_array) )
1358
- return;
1359
-
1360
- $js_array = implode('","', $image_array);
1361
-
1362
- // send out some JavaScript, which initate the ajax operation
1363
- ?>
1364
- <script type="text/javascript">
1365
-
1366
- Images = new Array("<?php echo $js_array; ?>");
1367
-
1368
- nggAjaxOptions = {
1369
- operation: "<?php echo $operation; ?>",
1370
- ids: Images,
1371
- header: "<?php echo $title; ?>",
1372
- maxStep: Images.length
1373
- };
1374
-
1375
- jQuery(document).ready( function(){
1376
- nggProgressBar.init( nggAjaxOptions );
1377
- nggAjax.init( nggAjaxOptions );
1378
- } );
1379
- </script>
1380
-
1381
- <?php
1382
- }
1383
-
1384
- /**
1385
- * nggAdmin::set_gallery_preview() - define a preview pic after the first upload, can be changed in the gallery settings
1386
- *
1387
- * @class nggAdmin
1388
- * @param int $galleryID
1389
- * @return void
1390
- */
1391
- function set_gallery_preview( $galleryID ) {
1392
-
1393
- global $wpdb;
1394
-
1395
- $gallery = nggdb::find_gallery( $galleryID );
1396
-
1397
- // in the case no preview image is setup, we do this now
1398
- if ($gallery->previewpic == 0) {
1399
- $firstImage = $wpdb->get_var("SELECT pid FROM $wpdb->nggpictures WHERE exclude != 1 AND galleryid = '$galleryID' ORDER by pid DESC limit 0,1");
1400
- if ($firstImage) {
1401
- $wpdb->query("UPDATE $wpdb->nggallery SET previewpic = '$firstImage' WHERE gid = '$galleryID'");
1402
- wp_cache_delete($galleryID, 'ngg_gallery');
1403
- }
1404
- }
1405
-
1406
- return;
1407
- }
1408
-
1409
- /**
1410
- * Return a JSON coded array of Image ids for a requested gallery
1411
- *
1412
- * @class nggAdmin
1413
- * @param int $galleryID
1414
- * @return arry (JSON)
1415
- */
1416
- function get_image_ids( $galleryID ) {
1417
-
1418
- if ( !function_exists('json_encode') )
1419
- return(-2);
1420
-
1421
- $gallery = nggdb::get_ids_from_gallery($galleryID, 'pid', 'ASC', false);
1422
-
1423
- header('Content-Type: text/plain; charset=' . get_option('blog_charset'), true);
1424
- $output = json_encode($gallery);
1425
-
1426
- return $output;
1427
- }
1428
-
1429
- /**
1430
- * Decode upload error to normal message
1431
- *
1432
- * @class nggAdmin
1433
- * @access internal
1434
- * @param int $code php upload error code
1435
- * @return string message
1436
- */
1437
-
1438
- function decode_upload_error( $code ) {
1439
-
1440
- switch ($code) {
1441
- case UPLOAD_ERR_INI_SIZE:
1442
- $message = __ ( 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 'nggallery' );
1443
- break;
1444
- case UPLOAD_ERR_FORM_SIZE:
1445
- $message = __ ( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 'nggallery' );
1446
- break;
1447
- case UPLOAD_ERR_PARTIAL:
1448
- $message = __ ( 'The uploaded file was only partially uploaded', 'nggallery' );
1449
- break;
1450
- case UPLOAD_ERR_NO_FILE:
1451
- $message = __ ( 'No file was uploaded', 'nggallery' );
1452
- break;
1453
- case UPLOAD_ERR_NO_TMP_DIR:
1454
- $message = __ ( 'Missing a temporary folder', 'nggallery' );
1455
- break;
1456
- case UPLOAD_ERR_CANT_WRITE:
1457
- $message = __ ( 'Failed to write file to disk', 'nggallery' );
1458
- break;
1459
- case UPLOAD_ERR_EXTENSION:
1460
- $message = __ ( 'File upload stopped by extension', 'nggallery' );
1461
- break;
1462
- default:
1463
- $message = __ ( 'Unknown upload error', 'nggallery' );
1464
- break;
1465
- }
1466
-
1467
- return $message;
1468
- }
1469
-
1470
- } // END class nggAdmin
1471
-
1472
- /**
1473
- * TODO: Cannot be member of a class ? Check PCLZIP later...
1474
- *
1475
- * @param mixed $p_event
1476
- * @param mixed $p_header
1477
- * @return
1478
- */
1479
- function ngg_getOnlyImages($p_event, &$p_header) {
1480
- return nggAdmin::getOnlyImages($p_event, $p_header);
1481
- }
1482
-
1483
- /**
1484
- * Ensure after zip extraction that it could be only a image file
1485
- *
1486
- * @param mixed $p_event
1487
- * @param mixed $p_header
1488
- * @return 1
1489
- */
1490
- function ngg_checkExtract($p_event, &$p_header) {
1491
-
1492
- // look for valid extraction
1493
- if ($p_header['status'] == 'ok') {
1494
- // check if it's any image file, delete all other files
1495
- if ( !@getimagesize ( $p_header['filename'] ))
1496
- unlink($p_header['filename']);
1497
- }
1498
-
1499
- return 1;
1500
- }
1501
- ?>
1
+ <?php
2
+
3
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
+
5
+ /**
6
+ * nggAdmin - Class for admin operation
7
+ *
8
+ * @package NextGEN Gallery
9
+ * @author Alex Rabe
10
+ *
11
+ * @access public
12
+ */
13
+ class nggAdmin{
14
+
15
+ /**
16
+ * create a new gallery & folder
17
+ *
18
+ * @class nggAdmin
19
+ * @param string $name of the gallery
20
+ * @param string $defaultpath
21
+ * @param bool $output if the function should show an error messsage or not
22
+ * @return
23
+ */
24
+ static function create_gallery($title, $defaultpath, $output = true) {
25
+
26
+ global $user_ID;
27
+
28
+ // get the current user ID
29
+ get_currentuserinfo();
30
+
31
+ //cleanup pathname
32
+ $name = sanitize_file_name( sanitize_title($title) );
33
+ $name = apply_filters('ngg_gallery_name', $name);
34
+ $nggRoot = WINABSPATH . $defaultpath;
35
+ $txt = '';
36
+
37
+ // No gallery name ?
38
+ if ( empty($name) ) {
39
+ if ($output) nggGallery::show_error( __('No valid gallery name!', 'nggallery') );
40
+ return false;
41
+ }
42
+
43
+ // check for main folder
44
+ if ( !is_dir($nggRoot) ) {
45
+ if ( !wp_mkdir_p( $nggRoot ) ) {
46
+ $txt = __('Directory', 'nggallery').' <strong>' . esc_html( $defaultpath ) . '</strong> '.__('didn\'t exist. Please create first the main gallery folder ', 'nggallery').'!<br />';
47
+ $txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery').' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> ';
48
+ if ($output) nggGallery::show_error($txt);
49
+ return false;
50
+ }
51
+ }
52
+
53
+ // check for permission settings, Safe mode limitations are not taken into account.
54
+ if ( !is_writeable( $nggRoot ) ) {
55
+ $txt = __('Directory', 'nggallery').' <strong>' . esc_html( $defaultpath ) . '</strong> '.__('is not writeable !', 'nggallery').'<br />';
56
+ $txt .= __('Check this link, if you didn\'t know how to set the permission :', 'nggallery').' <a href="http://codex.wordpress.org/Changing_File_Permissions">http://codex.wordpress.org/Changing_File_Permissions</a> ';
57
+ if ($output) nggGallery::show_error($txt);
58
+ return false;
59
+ }
60
+
61
+ // 1. Check for existing folder
62
+ if ( is_dir(WINABSPATH . $defaultpath . $name ) && !(SAFE_MODE) ) {
63
+ $suffix = 1;
64
+ do {
65
+ $alt_name = substr ($name, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "_$suffix";
66
+ $dir_check = is_dir(WINABSPATH . $defaultpath . $alt_name );
67
+ $suffix++;
68
+ } while ( $dir_check );
69
+ $name = $alt_name;
70
+ }
71
+ // define relative path to gallery inside wp root folder
72
+ $nggpath = $defaultpath . $name;
73
+
74
+ // 2. Create new gallery folder
75
+ if ( !wp_mkdir_p (WINABSPATH . $nggpath) )
76
+ $txt = __('Unable to create directory ', 'nggallery') . esc_html( $nggpath ) . '!<br />';
77
+
78
+ // 3. Check folder permission
79
+ if ( !is_writeable(WINABSPATH . $nggpath ) )
80
+ $txt .= __('Directory', 'nggallery').' <strong>' . esc_html( $nggpath ) . '</strong> '.__('is not writeable !', 'nggallery').'<br />';
81
+
82
+ // 4. Now create thumbnail folder inside
83
+ if ( !is_dir(WINABSPATH . $nggpath . '/thumbs') ) {
84
+ if ( !wp_mkdir_p ( WINABSPATH . $nggpath . '/thumbs') )
85
+ $txt .= __('Unable to create directory ', 'nggallery').' <strong>' . esc_html( $nggpath ) . '/thumbs !</strong>';
86
+ }
87
+
88
+ if (SAFE_MODE) {
89
+ $help = __('The server setting Safe-Mode is on !', 'nggallery');
90
+ $help .= '<br />'.__('If you have problems, please create directory', 'nggallery').' <strong>' . esc_html( $nggpath ) . '</strong> ';
91
+ $help .= __('and the thumbnails directory', 'nggallery').' <strong>' . esc_html( $nggpath ) . '/thumbs</strong> '.__('with permission 777 manually !', 'nggallery');
92
+ if ($output) nggGallery::show_message($help);
93
+ }
94
+
95
+ // show a error message
96
+ if ( !empty($txt) ) {
97
+ if (SAFE_MODE) {
98
+ // for safe_mode , better delete folder, both folder must be created manually
99
+ @rmdir(WINABSPATH . $nggpath . '/thumbs');
100
+ @rmdir(WINABSPATH . $nggpath);
101
+ }
102
+ if ($output) nggGallery::show_error($txt);
103
+ return false;
104
+ }
105
+
106
+ // now add the gallery to the database
107
+ $galleryID = nggdb::add_gallery($title, $nggpath, '', 0, 0, $user_ID );
108
+ // here you can inject a custom function
109
+ do_action('ngg_created_new_gallery', $galleryID);
110
+
111
+ // return only the id if defined
112
+ if ($output == false)
113
+ return $galleryID;
114
+
115
+ if ($galleryID != false) {
116
+ $message = __('Gallery ID %1$s successfully created. You can show this gallery in your post or page with the shortcode %2$s.<br/>','nggallery');
117
+ $message = sprintf($message, $galleryID, '<strong>[nggallery id=' . $galleryID . ']</strong>');
118
+ $message .= '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $galleryID . '" >';
119
+ $message .= __('Edit gallery','nggallery');
120
+ $message .= '</a>';
121
+
122
+ if ($output) nggGallery::show_message($message);
123
+ }
124
+ return true;
125
+ }
126
+
127
+ /**
128
+ * nggAdmin::import_gallery()
129
+ * TODO: Check permission of existing thumb folder & images
130
+ *
131
+ * @class nggAdmin
132
+ * @param string $galleryfolder contains relative path to the gallery itself
133
+ * @return void
134
+ */
135
+ static function import_gallery($galleryfolder) {
136
+
137
+ global $wpdb, $user_ID;
138
+
139
+ // get the current user ID
140
+ get_currentuserinfo();
141
+
142
+ $created_msg = '';
143
+
144
+ // remove trailing slash at the end, if somebody use it
145
+ $galleryfolder = untrailingslashit($galleryfolder);
146
+ $gallerypath = WINABSPATH . $galleryfolder;
147
+
148
+ if (!is_dir($gallerypath)) {
149
+ nggGallery::show_error(__('Directory', 'nggallery').' <strong>' . esc_html( $gallerypath ) .'</strong> '.__('doesn&#96;t exist!', 'nggallery'));
150
+ return ;
151
+ }
152
+
153
+ // read list of images
154
+ $new_imageslist = nggAdmin::scandir($gallerypath);
155
+
156
+ if (empty($new_imageslist)) {
157
+ nggGallery::show_message(__('Directory', 'nggallery').' <strong>' . esc_html( $gallerypath ) . '</strong> '.__('contains no pictures', 'nggallery'));
158
+ return;
159
+ }
160
+
161
+ // check & create thumbnail folder
162
+ if ( !nggGallery::get_thumbnail_folder($gallerypath) )
163
+ return;
164
+
165
+ // take folder name as gallery name
166
+ $galleryname = basename($galleryfolder);
167
+ $galleryname = apply_filters('ngg_gallery_name', $galleryname);
168
+
169
+ // check for existing gallery folder
170
+ $gallery_id = $wpdb->get_var("SELECT gid FROM $wpdb->nggallery WHERE path = '$galleryfolder' ");
171
+
172
+ if (!$gallery_id) {
173
+ // now add the gallery to the database
174
+ $gallery_id = nggdb::add_gallery( $galleryname, $galleryfolder, '', 0, 0, $user_ID );
175
+ if (!$gallery_id) {
176
+ nggGallery::show_error(__('Database error. Could not add gallery!','nggallery'));
177
+ return;
178
+ }
179
+ $created_msg = _n( 'Gallery', 'Galleries', 1, 'nggallery' ) . ' <strong>' . esc_html( $galleryname ) . '</strong> ' . __('successfully created!','nggallery') . '<br />';
180
+ }
181
+
182
+ // Look for existing image list
183
+ $old_imageslist = $wpdb->get_col("SELECT filename FROM $wpdb->nggpictures WHERE galleryid = '$gallery_id' ");
184
+
185
+ // if no images are there, create empty array
186
+ if ($old_imageslist == NULL)
187
+ $old_imageslist = array();
188
+
189
+ // check difference
190
+ $new_images = array_diff($new_imageslist, $old_imageslist);
191
+
192
+ // all images must be valid files
193
+ foreach($new_images as $key => $picture) {
194
+
195
+ // filter function to rename/change/modify image before
196
+ $picture = apply_filters('ngg_pre_add_new_image', $picture, $gallery_id);
197
+ $new_images[$key] = $picture;
198
+
199
+ if (!@getimagesize($gallerypath . '/' . $picture) ) {
200
+ unset($new_images[$key]);
201
+ @unlink($gallerypath . '/' . $picture);
202
+ }
203
+ }
204
+
205
+ // add images to database
206
+ $image_ids = nggAdmin::add_Images($gallery_id, $new_images);
207
+
208
+ //add the preview image if needed
209
+ nggAdmin::set_gallery_preview ( $gallery_id );
210
+
211
+ // now create thumbnails
212
+ nggAdmin::do_ajax_operation( 'create_thumbnail' , $image_ids, __('Create new thumbnails','nggallery') );
213
+
214
+ //TODO:Message will not shown, because AJAX routine require more time, message should be passed to AJAX
215
+ $message = $created_msg . count($image_ids) .__(' picture(s) successfully added','nggallery');
216
+ $message .= ' [<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $gallery_id . '" >';
217
+ $message .= __('Edit gallery','nggallery');
218
+ $message .= '</a>]';
219
+
220
+ nggGallery::show_message($message);
221
+
222
+ return;
223
+
224
+ }
225
+
226
+ /**
227
+ * Scan folder for new images
228
+ *
229
+ * @class nggAdmin
230
+ * @param string $dirname
231
+ * @return array $files list of image filenames
232
+ */
233
+ static function scandir( $dirname = '.' ) {
234
+ $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif') );
235
+
236
+ $files = array();
237
+ if( $handle = opendir( $dirname ) ) {
238
+ while( false !== ( $file = readdir( $handle ) ) ) {
239
+ $info = pathinfo( $file );
240
+ // just look for images with the correct extension
241
+ if ( isset($info['extension']) )
242
+ if ( in_array( strtolower($info['extension']), $ext) )
243
+ $files[] = utf8_encode( $file );
244
+ }
245
+ closedir( $handle );
246
+ }
247
+ sort( $files );
248
+ return ( $files );
249
+ }
250
+
251
+ /**
252
+ * nggAdmin::createThumbnail() - function to create or recreate a thumbnail
253
+ *
254
+ * @class nggAdmin
255
+ * @param object | int $image contain all information about the image or the id
256
+ * @return string result code
257
+ * @since v1.0.0
258
+ */
259
+ static function create_thumbnail($image) {
260
+
261
+ global $ngg;
262
+
263
+ if(! class_exists('ngg_Thumbnail'))
264
+ require_once( nggGallery::graphic_library() );
265
+
266
+ if ( is_numeric($image) )
267
+ $image = nggdb::find_image( $image );
268
+
269
+ if ( !is_object($image) )
270
+ return __('Object didn\'t contain correct data','nggallery');
271
+
272
+ // before we start we import the meta data to database (required for uploads before V1.4.0)
273
+ nggAdmin::maybe_import_meta( $image->pid );
274
+
275
+ // check for existing thumbnail
276
+ if (file_exists($image->thumbPath))
277
+ if (!is_writable($image->thumbPath))
278
+ return esc_html( $image->filename ) . __(' is not writeable ','nggallery');
279
+
280
+ $thumb = new ngg_Thumbnail($image->imagePath, TRUE);
281
+
282
+ // skip if file is not there
283
+ if (!$thumb->error) {
284
+ if ($ngg->options['thumbfix']) {
285
+
286
+ // calculate correct ratio
287
+ $wratio = $ngg->options['thumbwidth'] / $thumb->currentDimensions['width'];
288
+ $hratio = $ngg->options['thumbheight'] / $thumb->currentDimensions['height'];
289
+
290
+ if ($wratio > $hratio) {
291
+ // first resize to the wanted width
292
+ $thumb->resize($ngg->options['thumbwidth'], 0);
293
+ // get optimal y startpos
294
+ $ypos = ($thumb->currentDimensions['height'] - $ngg->options['thumbheight']) / 2;
295
+ $thumb->crop(0, $ypos, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
296
+ } else {
297
+ // first resize to the wanted height
298
+ $thumb->resize(0, $ngg->options['thumbheight']);
299
+ // get optimal x startpos
300
+ $xpos = ($thumb->currentDimensions['width'] - $ngg->options['thumbwidth']) / 2;
301
+ $thumb->crop($xpos, 0, $ngg->options['thumbwidth'],$ngg->options['thumbheight']);
302
+ }
303
+ //this create a thumbnail but keep ratio settings
304
+ } else {
305
+ $thumb->resize($ngg->options['thumbwidth'],$ngg->options['thumbheight']);
306
+ }
307
+
308
+ // save the new thumbnail
309
+ $thumb->save($image->thumbPath, $ngg->options['thumbquality']);
310
+ nggAdmin::chmod ($image->thumbPath);
311
+
312
+ //read the new sizes
313
+ $new_size = @getimagesize ( $image->thumbPath );
314
+ $size['width'] = $new_size[0];
315
+ $size['height'] = $new_size[1];
316
+
317
+ // add them to the database
318
+ nggdb::update_image_meta($image->pid, array( 'thumbnail' => $size) );
319
+ }
320
+
321
+ $thumb->destruct();
322
+
323
+ if ( !empty($thumb->errmsg) )
324
+ return ' <strong>' . esc_html( $image->filename ) . ' (Error : '.$thumb->errmsg .')</strong>';
325
+
326
+ // success
327
+ return '1';
328
+ }
329
+
330
+ /**
331
+ * nggAdmin::resize_image() - create a new image, based on the height /width
332
+ *
333
+ * @class nggAdmin
334
+ * @param object | int $image contain all information about the image or the id
335
+ * @param integer $width optional
336
+ * @param integer $height optional
337
+ * @return string result code
338
+ */
339
+ static function resize_image($image, $width = 0, $height = 0) {
340
+
341
+ global $ngg;
342
+
343
+ if(! class_exists('ngg_Thumbnail'))
344
+ require_once( nggGallery::graphic_library() );
345
+
346
+ if ( is_numeric($image) )
347
+ $image = nggdb::find_image( $image );
348
+
349
+ if ( !is_object($image) )
350
+ return __('Object didn\'t contain correct data','nggallery');
351
+
352
+ // before we start we import the meta data to database (required for uploads before V1.4.0)
353
+ nggAdmin::maybe_import_meta( $image->pid );
354
+
355
+ // if no parameter is set, take global settings
356
+ $width = ($width == 0) ? $ngg->options['imgWidth'] : $width;
357
+ $height = ($height == 0) ? $ngg->options['imgHeight'] : $height;
358
+
359
+ if (!is_writable($image->imagePath))
360
+ return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
361
+
362
+ $file = new ngg_Thumbnail($image->imagePath, TRUE);
363
+
364
+ // skip if file is not there
365
+ if (!$file->error) {
366
+
367
+ // If required save a backup copy of the file
368
+ if ( ($ngg->options['imgBackup'] == 1) && (!file_exists($image->imagePath . '_backup')) )
369
+ @copy ($image->imagePath, $image->imagePath . '_backup');
370
+
371
+ $file->resize($width, $height);
372
+ $file->save($image->imagePath, $ngg->options['imgQuality']);
373
+ // read the new sizes
374
+ $size = @getimagesize ( $image->imagePath );
375
+ // add them to the database
376
+ nggdb::update_image_meta($image->pid, array( 'width' => $size[0], 'height' => $size[1] ) );
377
+ $file->destruct();
378
+ } else {
379
+ $file->destruct();
380
+ return ' <strong>' . esc_html( $image->filename ) . ' (Error : ' . $file->errmsg . ')</strong>';
381
+ }
382
+
383
+ return '1';
384
+ }
385
+
386
+ /**
387
+ * Rotated/Flip an image based on the orientation flag or a definded angle
388
+ *
389
+ * @param int|object $image
390
+ * @param string (optional) $dir, CW (clockwise)or CCW (counter clockwise), if set to false, the exif flag will be used
391
+ * @param string (optional) $flip, could be either false | V (flip vertical) | H (flip horizontal)
392
+ * @return string result code
393
+ */
394
+ static function rotate_image($image, $dir = false, $flip = false) {
395
+
396
+ global $ngg;
397
+
398
+ if(! class_exists('ngg_Thumbnail'))
399
+ require_once( nggGallery::graphic_library() );
400
+
401
+ if ( is_numeric($image) )
402
+ $image = nggdb::find_image( $image );
403
+
404
+ if ( !is_object($image) )
405
+ return __('Object didn\'t contain correct data','nggallery');
406
+
407
+ if (!is_writable($image->imagePath))
408
+ return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
409
+
410
+ // if you didn't define a rotation, we look for the orientation flag in EXIF
411
+ if ( $dir === false ) {
412
+ $meta = new nggMeta( $image->pid );
413
+ $exif = $meta->get_EXIF();
414
+
415
+ if (isset($exif['Orientation'])) {
416
+
417
+ switch ($exif['Orientation']) {
418
+ case 5 : // vertical flip + 90 rotate right
419
+ $flip = 'V';
420
+ case 6 : // 90 rotate right
421
+ $dir = 'CW';
422
+ break;
423
+ case 7 : // horizontal flip + 90 rotate right
424
+ $flip = 'H';
425
+ case 8 : // 90 rotate left
426
+ $dir = 'CCW';
427
+ break;
428
+ case 4 : // vertical flip
429
+ $flip = 'V';
430
+ break;
431
+ case 3 : // 180 rotate left
432
+ $dir = 180;
433
+ break;
434
+ case 2 : // horizontal flip
435
+ $flip = 'H';
436
+ break;
437
+ case 1 : // no action in the case it doesn't need a rotation
438
+ default:
439
+ return '0';
440
+ break;
441
+ }
442
+ } else
443
+ return '0';
444
+ }
445
+ $file = new ngg_Thumbnail( $image->imagePath, TRUE );
446
+
447
+ // skip if file is not there
448
+ if (!$file->error) {
449
+
450
+ // If required save a backup copy of the file
451
+ if ( ($ngg->options['imgBackup'] == 1) && (!file_exists($image->imagePath . '_backup')) )
452
+ @copy ($image->imagePath, $image->imagePath . '_backup');
453
+
454
+ // before we start we import the meta data to database (required for uploads before V1.4.X)
455
+ nggAdmin::maybe_import_meta( $image->pid );
456
+
457
+ if ( $dir !== 0 )
458
+ $file->rotateImage( $dir );
459
+ if ( $dir === 180)
460
+ $file->rotateImage( 'CCW' ); // very special case, we rotate the image two times
461
+ if ( $flip == 'H')
462
+ $file->flipImage(true, false);
463
+ if ( $flip == 'V')
464
+ $file->flipImage(false, true);
465
+
466
+ $file->save($image->imagePath, $ngg->options['imgQuality']);
467
+
468
+ // read the new sizes
469
+ $size = @getimagesize ( $image->imagePath );
470
+ // add them to the database
471
+ nggdb::update_image_meta($image->pid, array( 'width' => $size[0], 'height' => $size[1] ) );
472
+
473
+ }
474
+
475
+ $file->destruct();
476
+
477
+ if ( !empty($file->errmsg) )
478
+ return ' <strong>' . esc_html( $image->filename ) . ' (Error : '.$file->errmsg .')</strong>';
479
+
480
+ return '1';
481
+
482
+ }
483
+
484
+ /**
485
+ * nggAdmin::set_watermark() - set the watermark for the image
486
+ *
487
+ * @class nggAdmin
488
+ * @param object | int $image contain all information about the image or the id
489
+ * @return string result code
490
+ */
491
+ static function set_watermark($image) {
492
+
493
+ global $ngg;
494
+
495
+ if(! class_exists('ngg_Thumbnail'))
496
+ require_once( nggGallery::graphic_library() );
497
+
498
+ if ( is_numeric($image) )
499
+ $image = nggdb::find_image( $image );
500
+
501
+ if ( !is_object($image) )
502
+ return __('Object didn\'t contain correct data','nggallery');
503
+
504
+ // before we start we import the meta data to database (required for uploads before V1.4.0)
505
+ nggAdmin::maybe_import_meta( $image->pid );
506
+
507
+ if (!is_writable($image->imagePath))
508
+ return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
509
+
510
+ $file = new ngg_Thumbnail( $image->imagePath, TRUE );
511
+
512
+ // skip if file is not there
513
+ if (!$file->error) {
514
+
515
+ // If required save a backup copy of the file
516
+ if ( ($ngg->options['imgBackup'] == 1) && (!file_exists($image->imagePath . '_backup')) )
517
+ @copy ($image->imagePath, $image->imagePath . '_backup');
518
+
519
+ if ($ngg->options['wmType'] == 'image') {
520
+ $file->watermarkImgPath = $ngg->options['wmPath'];
521
+ $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
522
+ }
523
+ if ($ngg->options['wmType'] == 'text') {
524
+ $file->watermarkText = $ngg->options['wmText'];
525
+ $file->watermarkCreateText($ngg->options['wmColor'], $ngg->options['wmFont'], $ngg->options['wmSize'], $ngg->options['wmOpaque']);
526
+ $file->watermarkImage($ngg->options['wmPos'], $ngg->options['wmXpos'], $ngg->options['wmYpos']);
527
+ }
528
+ $file->save($image->imagePath, $ngg->options['imgQuality']);
529
+ }
530
+
531
+ $file->destruct();
532
+
533
+ if ( !empty($file->errmsg) )
534
+ return ' <strong>' . esc_html( $image->filename ) . ' (Error : '.$file->errmsg .')</strong>';
535
+
536
+ return '1';
537
+ }
538
+
539
+ /**
540
+ * Recover image from backup copy and reprocess it
541
+ *
542
+ * @class nggAdmin
543
+ * @since 1.5.0
544
+ * @param object | int $image contain all information about the image or the id
545
+ * @return string result code
546
+ */
547
+
548
+ static function recover_image($image) {
549
+
550
+ global $ngg;
551
+
552
+ if ( is_numeric($image) )
553
+ $image = nggdb::find_image( $image );
554
+
555
+ if ( !is_object( $image ) )
556
+ return __('Object didn\'t contain correct data','nggallery');
557
+
558
+ if (!is_writable( $image->imagePath ))
559
+ return ' <strong>' . esc_html( $image->filename ) . __(' is not writeable','nggallery') . '</strong>';
560
+
561
+ if (!file_exists( $image->imagePath . '_backup' )) {
562
+ return ' <strong>'.__('File do not exists','nggallery').'</strong>';
563
+ }
564
+
565
+ if (!@copy( $image->imagePath . '_backup' , $image->imagePath) )
566
+ return ' <strong>'.__('Couldn\'t restore original image','nggallery').'</strong>';
567
+
568
+ require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
569
+
570
+ $meta_obj = new nggMeta( $image->pid );
571
+
572
+ $common = $meta_obj->get_common_meta();
573
+ $common['saved'] = true;
574
+ $result = nggdb::update_image_meta($image->pid, $common);
575
+
576
+ return '1';
577
+
578
+ }
579
+
580
+ /**
581
+ * Add images to database
582
+ *
583
+ * @class nggAdmin
584
+ * @param int $galleryID
585
+ * @param array $imageslist
586
+ * @return array $image_ids Id's which are sucessful added
587
+ */
588
+ static function add_Images($galleryID, $imageslist) {
589
+
590
+ global $wpdb, $ngg;
591
+
592
+ $image_ids = array();
593
+
594
+ if ( is_array($imageslist) ) {
595
+ foreach($imageslist as $picture) {
596
+
597
+ // filter function to rename/change/modify image before
598
+ $picture = apply_filters('ngg_pre_add_new_image', $picture, $galleryID);
599
+
600
+ // strip off the extension of the filename
601
+ $path_parts = pathinfo( $picture );
602
+ $alttext = ( !isset($path_parts['filename']) ) ? substr($path_parts['basename'], 0,strpos($path_parts['basename'], '.')) : $path_parts['filename'];
603
+ // save it to the database
604
+ $pic_id = nggdb::add_image( $galleryID, $picture, '', $alttext );
605
+
606
+ if ( !empty($pic_id) )
607
+ $image_ids[] = $pic_id;
608
+
609
+ // add the metadata
610
+ nggAdmin::import_MetaData( $pic_id );
611
+
612
+ // auto rotate
613
+ nggAdmin::rotate_image( $pic_id );
614
+
615
+ // Autoresize image if required
616
+ if ($ngg->options['imgAutoResize']) {
617
+ $imagetmp = nggdb::find_image( $pic_id );
618
+ $sizetmp = @getimagesize ( $imagetmp->imagePath );
619
+ $widthtmp = $ngg->options['imgWidth'];
620
+ $heighttmp = $ngg->options['imgHeight'];
621
+ if (($sizetmp[0] > $widthtmp && $widthtmp) || ($sizetmp[1] > $heighttmp && $heighttmp)) {
622
+ nggAdmin::resize_image( $pic_id );
623
+ }
624
+ }
625
+
626
+ // action hook for post process after the image is added to the database
627
+ $image = array( 'id' => $pic_id, 'filename' => $picture, 'galleryID' => $galleryID);
628
+ do_action('ngg_added_new_image', $image);
629
+
630
+ }
631
+ } // is_array
632
+
633
+ // delete dirsize after adding new images
634
+ delete_transient( 'dirsize_cache' );
635
+
636
+ do_action('ngg_after_new_images_added', $galleryID, $image_ids );
637
+
638
+ return $image_ids;
639
+
640
+ }
641
+
642
+ /**
643
+ * Import some meta data into the database (if avialable)
644
+ *
645
+ * @class nggAdmin
646
+ * @param array|int $imagesIds
647
+ * @return string result code
648
+ */
649
+ static function import_MetaData($imagesIds) {
650
+
651
+ global $wpdb;
652
+
653
+ require_once(NGGALLERY_ABSPATH . '/lib/image.php');
654
+
655
+ if (!is_array($imagesIds))
656
+ $imagesIds = array($imagesIds);
657
+
658
+ foreach($imagesIds as $imageID) {
659
+
660
+ $image = nggdb::find_image( $imageID );
661
+ if (!$image->error) {
662
+
663
+ $meta = nggAdmin::get_MetaData( $image->pid );
664
+
665
+ // get the title
666
+ $alttext = empty( $meta['title'] ) ? $image->alttext : $meta['title'];
667
+
668
+ // get the caption / description field
669
+ $description = empty( $meta['caption'] ) ? $image->description : $meta['caption'];
670
+
671
+ // get the file date/time from exif
672
+ $timestamp = $meta['timestamp'];
673
+ // first update database
674
+ $result = $wpdb->query(
675
+ $wpdb->prepare("UPDATE $wpdb->nggpictures SET
676
+ alttext = %s,
677
+ description = %s,
678
+ imagedate = %s
679
+ WHERE pid = %d", $alttext, $description, $timestamp, $image->pid) );
680
+
681
+ if ($result === false)
682
+ return ' <strong>' . esc_html( $image->filename ) . ' ' . __('(Error : Couldn\'t not update data base)', 'nggallery') . '</strong>';
683
+
684
+ //this flag will inform us that the import is already one time performed
685
+ $meta['common']['saved'] = true;
686
+ $result = nggdb::update_image_meta($image->pid, $meta['common']);
687
+
688
+ if ($result === false)
689
+ return ' <strong>' . esc_html( $image->filename ) . ' ' . __('(Error : Couldn\'t not update meta data)', 'nggallery') . '</strong>';
690
+
691
+ // add the tags if we found some
692
+ if ($meta['keywords']) {
693
+ $taglist = explode(',', $meta['keywords']);
694
+ wp_set_object_terms($image->pid, $taglist, 'ngg_tag');
695
+ }
696
+
697
+ } else
698
+ return ' <strong>' . esc_html( $image->filename ) . ' ' . __('(Error : Couldn\'t not find image)', 'nggallery') . '</strong>';// error check
699
+ }
700
+
701
+ return '1';
702
+ }
703
+
704
+ /**
705
+ * nggAdmin::get_MetaData()
706
+ *
707
+ * @class nggAdmin
708
+ * @require NextGEN Meta class
709
+ * @param int $id image ID
710
+ * @return array metadata
711
+ */
712
+ static function get_MetaData($id) {
713
+
714
+ require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
715
+
716
+ $meta = array();
717
+
718
+ $pdata = new nggMeta( $id );
719
+
720
+ $meta['title'] = trim ( $pdata->get_META('title') );
721
+ $meta['caption'] = trim ( $pdata->get_META('caption') );
722
+ $meta['keywords'] = trim ( $pdata->get_META('keywords') );
723
+ $meta['timestamp'] = $pdata->get_date_time();
724
+ // this contain other useful meta information
725
+ $meta['common'] = $pdata->get_common_meta();
726
+ // hook for addon plugin to add more meta fields
727
+ $meta = apply_filters('ngg_get_image_metadata', $meta, $pdata);
728
+
729
+ return $meta;
730
+
731
+ }
732
+
733
+ /**
734
+ * Maybe import some meta data to the database. The functions checks the flag 'saved'
735
+ * and if based on compat reason (pre V1.4.0) we save then some meta datas to the database
736
+ *
737
+ * @since V1.4.0
738
+ * @param int $id
739
+ * @return result
740
+ */
741
+ static function maybe_import_meta( $id ) {
742
+
743
+ require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
744
+
745
+ $meta_obj = new nggMeta( $id );
746
+
747
+ if ( $meta_obj->image->meta_data['saved'] != true ) {
748
+ $common = $meta_obj->get_common_meta();
749
+ //this flag will inform us that the import is already one time performed
750
+ $common['saved'] = true;
751
+ $result = nggdb::update_image_meta($id, $common);
752
+ } else
753
+ return false;
754
+
755
+ return $result;
756
+
757
+ }
758
+
759
+ /**
760
+ * Unzip a file via the PclZip class
761
+ *
762
+ * @class nggAdmin
763
+ * @require PclZip class
764
+ * @param string $dir
765
+ * @param string $file
766
+ * @return bool
767
+ */
768
+ static function unzip($dir, $file) {
769
+
770
+ if(! class_exists('PclZip'))
771
+ require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
772
+
773
+ $archive = new PclZip($file);
774
+
775
+ // extract all files in one folder
776
+ if ($archive->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH,
777
+ PCLZIP_CB_PRE_EXTRACT, 'ngg_getOnlyImages',
778
+ PCLZIP_CB_POST_EXTRACT, 'ngg_checkExtract') == 0) {
779
+ nggGallery::show_error( 'Error : ' . $archive->errorInfo(true) );
780
+ return false;
781
+ }
782
+
783
+ return true;
784
+ }
785
+
786
+ /**
787
+ * nggAdmin::getOnlyImages()
788
+ *
789
+ * @class nggAdmin
790
+ * @param mixed $p_event
791
+ * @param mixed $p_header
792
+ * @return bool
793
+ */
794
+ static function getOnlyImages($p_event, &$p_header) {
795
+ // avoid null byte hack (THX to Dominic Szablewski)
796
+ if ( strpos($p_header['filename'], chr(0) ) !== false )
797
+ $p_header['filename'] = substr ( $p_header['filename'], 0, strpos($p_header['filename'], chr(0) ));
798
+ // check for extension
799
+ $info = pathinfo($p_header['filename']);
800
+ // check for extension
801
+ $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif') );
802
+ if ( in_array( strtolower($info['extension']), $ext) ) {
803
+ // For MAC skip the ".image" files
804
+ if ($info['basename']{0} == '.' )
805
+ return 0;
806
+ else {
807
+ // sanitize the file name before we do further processing
808
+ $info['basename'] = sanitize_file_name( $info['basename'] );
809
+ $p_header['filename'] = $info['dirname'] . '/' . $info['basename'];
810
+ return 1;
811
+ }
812
+
813
+ }
814
+ // ----- all other files are skipped
815
+ else {
816
+ return 0;
817
+ }
818
+ }
819
+
820
+ /**
821
+ * Import a ZIP file via a upload form or a URL
822
+ *
823
+ * @class nggAdmin
824
+ * @param int (optional) $galleryID
825
+ * @return bool $result
826
+ */
827
+ static function import_zipfile($galleryID) {
828
+
829
+ global $ngg, $wpdb;
830
+
831
+ if (nggWPMU::check_quota())
832
+ return false;
833
+
834
+ $defaultpath = $ngg->options['gallerypath'];
835
+ $zipurl = isset($_POST['zipurl'])?$_POST['zipurl']:"";
836
+
837
+ // if someone entered a URL try to upload it
838
+ if (!empty($zipurl) && (function_exists('curl_init')) ) {
839
+
840
+ if (!(preg_match('/^http(s)?:\/\//i', $zipurl) )) {
841
+ nggGallery::show_error( __('No valid URL path ','nggallery') );
842
+ return false;
843
+ }
844
+
845
+ $temp_zipfile = tempnam('/tmp', 'zipimport_');
846
+ $filename = basename($zipurl);
847
+
848
+ //Grab the zip via cURL
849
+ $save = fopen ( $temp_zipfile, "w" );
850
+ $ch = curl_init ();
851
+ curl_setopt ( $ch, CURLOPT_FILE, $save );
852
+ curl_setopt ( $ch, CURLOPT_HEADER, 0 );
853
+ curl_setopt ( $ch, CURLOPT_BINARYTRANSFER, 1 );
854
+ curl_setopt ( $ch, CURLOPT_URL, $zipurl );
855
+ $success = curl_exec ( $ch );
856
+ if (!$success)
857
+ nggGallery::show_error( __('Import via cURL failed.','nggallery') . ' Error code ' . curl_errno( $ch ) . ' : ' . curl_error( $ch ) );
858
+ curl_close ( $ch );
859
+ fclose($save);
860
+
861
+ if (!$success)
862
+ return false;
863
+
864
+ } else {
865
+
866
+ $temp_zipfile = $_FILES['zipfile']['tmp_name'];
867
+ $filename = $_FILES['zipfile']['name'];
868
+
869
+ // Chrome return a empty content-type : http://code.google.com/p/chromium/issues/detail?id=6800
870
+ if ( !preg_match('/chrome/i', $_SERVER['HTTP_USER_AGENT']) ) {
871
+ // check if file is a zip file
872
+ if ( !preg_match('/(zip|download|octet-stream)/i', $_FILES['zipfile']['type']) ) {
873
+ @unlink($temp_zipfile); // del temp file
874
+ nggGallery::show_error(__('Uploaded file was no or a faulty zip file ! The server recognized : ','nggallery') . $_FILES['zipfile']['type']);
875
+ return false;
876
+ }
877
+ }
878
+ }
879
+
880
+ // should this unpacked into a new folder ?
881
+ if ( $galleryID == '0' ) {
882
+ //cleanup and take the zipfile name as folder name
883
+ $foldername = sanitize_title(strtok ($filename, '.'));
884
+ $foldername = $defaultpath . $foldername;
885
+ } else {
886
+ // get foldername if selected
887
+ $foldername = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$galleryID' ");
888
+ }
889
+
890
+ if ( empty($foldername) ) {
891
+ nggGallery::show_error( __('Could not get a valid foldername', 'nggallery') );
892
+ return false;
893
+ }
894
+
895
+ // set complete folder path
896
+ $newfolder = WINABSPATH . $foldername;
897
+
898
+ // check first if the traget folder exist
899
+ if (!is_dir($newfolder)) {
900
+ // create new directories
901
+ if (!wp_mkdir_p ($newfolder)) {
902
+ $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?', 'nggallery'), esc_html( $newfolder ) );
903
+ nggGallery::show_error($message);
904
+ return false;
905
+ }
906
+ if (!wp_mkdir_p ($newfolder . '/thumbs')) {
907
+ nggGallery::show_error(__('Unable to create directory ', 'nggallery') . esc_html( $newfolder ). '/thumbs !');
908
+ return false;
909
+ }
910
+ }
911
+
912
+ // unzip and del temp file
913
+ $result = nggAdmin::unzip($newfolder, $temp_zipfile);
914
+ @unlink($temp_zipfile);
915
+
916
+ if ($result) {
917
+ $message = __('Zip-File successfully unpacked','nggallery') . '<br />';
918
+
919
+ // parse now the folder and add to database
920
+ nggAdmin::import_gallery( $foldername );
921
+ nggGallery::show_message($message);
922
+ }
923
+
924
+ return true;
925
+ }
926
+
927
+ /**
928
+ * Function for uploading of images via the upload form
929
+ *
930
+ * @class nggAdmin
931
+ * @return void
932
+ */
933
+ static function upload_images() {
934
+
935
+ global $nggdb;
936
+
937
+ // WPMU action
938
+ if (nggWPMU::check_quota())
939
+ return;
940
+
941
+ // Images must be an array
942
+ $imageslist = array();
943
+
944
+ // get selected gallery
945
+ $galleryID = (int) $_POST['galleryselect'];
946
+
947
+ if ($galleryID == 0) {
948
+ nggGallery::show_error(__('No gallery selected !','nggallery'));
949
+ return;
950
+ }
951
+
952
+ // get the path to the gallery
953
+ $gallery = $nggdb->find_gallery($galleryID);
954
+
955
+ if ( empty($gallery->path) ){
956
+ nggGallery::show_error(__('Failure in database, no gallery path set !','nggallery'));
957
+ return;
958
+ }
959
+
960
+ // read list of images
961
+ $dirlist = nggAdmin::scandir($gallery->abspath);
962
+
963
+ $imagefiles = $_FILES['imagefiles'];
964
+
965
+ if (is_array($imagefiles)) {
966
+ foreach ($imagefiles['name'] as $key => $value) {
967
+
968
+ // look only for uploded files
969
+ if ($imagefiles['error'][$key] == 0) {
970
+
971
+ $temp_file = $imagefiles['tmp_name'][$key];
972
+
973
+ //clean filename and extract extension
974
+ $filepart = nggGallery::fileinfo( $imagefiles['name'][$key] );
975
+ $filename = $filepart['basename'];
976
+
977
+ // check for allowed extension and if it's an image file
978
+ $ext = array('jpg', 'png', 'gif');
979
+ if ( !in_array($filepart['extension'], $ext) || !@getimagesize($temp_file) ){
980
+ nggGallery::show_error('<strong>' . esc_html( $imagefiles['name'][$key] ) . ' </strong>' . __('is no valid image file!','nggallery'));
981
+ continue;
982
+ }
983
+
984
+ // check if this filename already exist in the folder
985
+ $i = 0;
986
+ while ( in_array( $filename, $dirlist ) ) {
987
+ $filename = $filepart['filename'] . '_' . $i++ . '.' .$filepart['extension'];
988
+ }
989
+
990
+ $dest_file = $gallery->abspath . '/' . $filename;
991
+
992
+ //check for folder permission
993
+ if ( !is_writeable($gallery->abspath) ) {
994
+ $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html($gallery->abspath) );
995
+ nggGallery::show_error($message);
996
+ return;
997
+ }
998
+
999
+ // save temp file to gallery
1000
+ if ( !@move_uploaded_file($temp_file, $dest_file) ){
1001
+ nggGallery::show_error(__('Error, the file could not be moved to : ','nggallery') . esc_html( $dest_file ) );
1002
+ nggAdmin::check_safemode( $gallery->abspath );
1003
+ continue;
1004
+ }
1005
+ if ( !nggAdmin::chmod($dest_file) ) {
1006
+ nggGallery::show_error(__('Error, the file permissions could not be set','nggallery'));
1007
+ continue;
1008
+ }
1009
+
1010
+ // add to imagelist & dirlist
1011
+ $imageslist[] = $filename;
1012
+ $dirlist[] = $filename;
1013
+
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ if (count($imageslist) > 0) {
1019
+
1020
+ // add images to database
1021
+ $image_ids = nggAdmin::add_Images($galleryID, $imageslist);
1022
+
1023
+ //create thumbnails
1024
+ nggAdmin::do_ajax_operation( 'create_thumbnail' , $image_ids, __('Create new thumbnails','nggallery') );
1025
+
1026
+ //add the preview image if needed
1027
+ nggAdmin::set_gallery_preview ( $galleryID );
1028
+
1029
+ nggGallery::show_message( count($image_ids) . __(' Image(s) successfully added','nggallery'));
1030
+ }
1031
+
1032
+ return;
1033
+
1034
+ }
1035
+
1036
+ /**
1037
+ * Upload function will be called via the Flash uploader
1038
+ *
1039
+ * @class nggAdmin
1040
+ * @param integer $galleryID
1041
+ * @return string $result
1042
+ */
1043
+ static function swfupload_image($galleryID = 0) {
1044
+
1045
+ global $nggdb;
1046
+
1047
+ if ($galleryID == 0)
1048
+ return __('No gallery selected !', 'nggallery');
1049
+
1050
+ // WPMU action
1051
+ if (nggWPMU::check_quota())
1052
+ return '0';
1053
+
1054
+ // Check the upload
1055
+ if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name']) || $_FILES['Filedata']['error'] != 0)
1056
+ return __('Invalid upload. Error Code : ', 'nggallery') . $_FILES['Filedata']['error'];
1057
+
1058
+ // get the filename and extension
1059
+ $temp_file = $_FILES['Filedata']['tmp_name'];
1060
+
1061
+ $filepart = nggGallery::fileinfo( $_FILES['Filedata']['name'] );
1062
+ $filename = $filepart['basename'];
1063
+
1064
+ // check for allowed extension
1065
+ $ext = apply_filters('ngg_allowed_file_types', array('jpeg', 'jpg', 'png', 'gif') );
1066
+ if (!in_array( strtolower( $filepart['extension'] ), $ext))
1067
+ return esc_html( $_FILES[$key]['name'] ) . __('is no valid image file!', 'nggallery');
1068
+
1069
+ // get the path to the gallery
1070
+ $gallery = $nggdb->find_gallery( (int) $galleryID );
1071
+ if ( empty($gallery->path) ){
1072
+ @unlink($temp_file);
1073
+ return __('Failure in database, no gallery path set !', 'nggallery');
1074
+ }
1075
+
1076
+ // read list of images
1077
+ $imageslist = nggAdmin::scandir( WINABSPATH . $gallery->path );
1078
+
1079
+ // check if this filename already exist
1080
+ $i = 0;
1081
+ while (in_array($filename, $imageslist)) {
1082
+ $filename = $filepart['filename'] . '_' . $i++ . '.' . $filepart['extension'];
1083
+ }
1084
+
1085
+ $dest_file = WINABSPATH . $gallery->path . '/' . $filename;
1086
+
1087
+ // save temp file to gallery
1088
+ if ( !@move_uploaded_file($_FILES["Filedata"]['tmp_name'], $dest_file) ){
1089
+ nggAdmin::check_safemode(WINABSPATH . $gallery->path);
1090
+ return __('Error, the file could not be moved to : ','nggallery'). esc_html( $dest_file );
1091
+ }
1092
+
1093
+ if ( !nggAdmin::chmod($dest_file) )
1094
+ return __('Error, the file permissions could not be set','nggallery');
1095
+
1096
+ return '0';
1097
+ }
1098
+
1099
+ /**
1100
+ * Set correct file permissions (taken from wp core)
1101
+ *
1102
+ * @class nggAdmin
1103
+ * @param string $filename
1104
+ * @return bool $result
1105
+ */
1106
+ static function chmod($filename = '') {
1107
+
1108
+ $stat = @ stat( dirname($filename) );
1109
+ $perms = $stat['mode'] & 0000666; // Remove execute bits for files
1110
+ if ( @chmod($filename, $perms) )
1111
+ return true;
1112
+
1113
+ return false;
1114
+ }
1115
+
1116
+ /**
1117
+ * Check UID in folder and Script
1118
+ * Read http://www.php.net/manual/en/features.safe-mode.php to understand safe_mode
1119
+ *
1120
+ * @class nggAdmin
1121
+ * @param string $foldername
1122
+ * @return bool $result
1123
+ */
1124
+ static function check_safemode($foldername) {
1125
+
1126
+ if ( SAFE_MODE ) {
1127
+
1128
+ $script_uid = ( ini_get('safe_mode_gid') ) ? getmygid() : getmyuid();
1129
+ $folder_uid = fileowner($foldername);
1130
+
1131
+ if ($script_uid != $folder_uid) {
1132
+ $message = sprintf(__('SAFE MODE Restriction in effect! You need to create the folder <strong>%s</strong> manually','nggallery'), esc_html( $foldername ) );
1133
+ $message .= '<br />' . sprintf(__('When safe_mode is on, PHP checks to see if the owner (%s) of the current script matches the owner (%s) of the file to be operated on by a file function or its directory','nggallery'), $script_uid, $folder_uid );
1134
+ nggGallery::show_error($message);
1135
+ return false;
1136
+ }
1137
+ }
1138
+
1139
+ return true;
1140
+ }
1141
+
1142
+ /**
1143
+ * Capability check. Check is the ID fit's to the user_ID
1144
+ *
1145
+ * @class nggAdmin
1146
+ * @param int $check_ID is the user_id
1147
+ * @return bool $result
1148
+ */
1149
+ static function can_manage_this_gallery($check_ID) {
1150
+
1151
+ global $user_ID, $wp_roles;
1152
+
1153
+ if ( !current_user_can('NextGEN Manage others gallery') ) {
1154
+ // get the current user ID
1155
+ get_currentuserinfo();
1156
+
1157
+ if ( $user_ID != $check_ID)
1158
+ return false;
1159
+ }
1160
+
1161
+ return true;
1162
+
1163
+ }
1164
+
1165
+ /**
1166
+ * Move images from one folder to another
1167
+ *
1168
+ * @class nggAdmin
1169
+ * @param array|int $pic_ids ID's of the images
1170
+ * @param int $dest_gid destination gallery
1171
+ * @return void
1172
+ */
1173
+ static function move_images($pic_ids, $dest_gid) {
1174
+
1175
+ $errors = '';
1176
+ $count = 0;
1177
+
1178
+ if ( !is_array($pic_ids) )
1179
+ $pic_ids = array($pic_ids);
1180
+
1181
+ // Get destination gallery
1182
+ $destination = nggdb::find_gallery( $dest_gid );
1183
+ $dest_abspath = WINABSPATH . $destination->path;
1184
+
1185
+ if ( $destination == null ) {
1186
+ nggGallery::show_error(__('The destination gallery does not exist','nggallery'));
1187
+ return;
1188
+ }
1189
+
1190
+ // Check for folder permission
1191
+ if ( !is_writeable( $dest_abspath ) ) {
1192
+ $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html( $dest_abspath ) );
1193
+ nggGallery::show_error($message);
1194
+ return;
1195
+ }
1196
+
1197
+ // Get pictures
1198
+ $images = nggdb::find_images_in_list($pic_ids);
1199
+
1200
+ foreach ($images as $image) {
1201
+
1202
+ $i = 0;
1203
+ $tmp_prefix = '';
1204
+
1205
+ $destination_file_name = $image->filename;
1206
+ // check if the filename already exist, then we add a copy_ prefix
1207
+ while (file_exists( $dest_abspath . '/' . $destination_file_name)) {
1208
+ $tmp_prefix = 'copy_' . ($i++) . '_';
1209
+ $destination_file_name = $tmp_prefix . $image->filename;
1210
+ }
1211
+
1212
+ $destination_path = $dest_abspath . '/' . $destination_file_name;
1213
+ $destination_thumbnail = $dest_abspath . '/thumbs/thumbs_' . $destination_file_name;
1214
+
1215
+ // Move files
1216
+ if ( !@rename($image->imagePath, $destination_path) ) {
1217
+ $errors .= sprintf(__('Failed to move image %1$s to %2$s','nggallery'),
1218
+ '<strong>' . esc_html( $image->filename ) . '</strong>', esc_html( $destination_path ) ) . '<br />';
1219
+ continue;
1220
+ }
1221
+
1222
+ // Move backup file, if possible
1223
+ @rename($image->imagePath . '_backup', $destination_path . '_backup');
1224
+ // Move the thumbnail, if possible
1225
+ @rename($image->thumbPath, $destination_thumbnail);
1226
+
1227
+ // Change the gallery id in the database , maybe the filename
1228
+ if ( nggdb::update_image($image->pid, $dest_gid, $destination_file_name) )
1229
+ $count++;
1230
+
1231
+ }
1232
+
1233
+ if ( $errors != '' )
1234
+ nggGallery::show_error($errors);
1235
+
1236
+ $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . esc_html( $destination->title ) . '</a>';
1237
+ $messages = sprintf(__('Moved %1$s picture(s) to gallery : %2$s .','nggallery'), $count, $link);
1238
+ nggGallery::show_message($messages);
1239
+
1240
+ return;
1241
+ }
1242
+
1243
+ /**
1244
+ * Copy images to another gallery
1245
+ *
1246
+ * @class nggAdmin
1247
+ * @param array|int $pic_ids ID's of the images
1248
+ * @param int $dest_gid destination gallery
1249
+ * @return void
1250
+ */
1251
+ static function copy_images($pic_ids, $dest_gid) {
1252
+
1253
+ require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
1254
+
1255
+ $errors = $messages = '';
1256
+
1257
+ if (!is_array($pic_ids))
1258
+ $pic_ids = array($pic_ids);
1259
+
1260
+ // Get destination gallery
1261
+ $destination = nggdb::find_gallery( $dest_gid );
1262
+ if ( $destination == null ) {
1263
+ nggGallery::show_error(__('The destination gallery does not exist','nggallery'));
1264
+ return;
1265
+ }
1266
+
1267
+ // Check for folder permission
1268
+ if (!is_writeable(WINABSPATH.$destination->path)) {
1269
+ $message = sprintf(__('Unable to write to directory %s. Is this directory writable by the server?', 'nggallery'), esc_html( WINABSPATH.$destination->path) );
1270
+ nggGallery::show_error($message);
1271
+ return;
1272
+ }
1273
+
1274
+ // Get pictures
1275
+ $images = nggdb::find_images_in_list($pic_ids);
1276
+ $destination_path = WINABSPATH . $destination->path;
1277
+
1278
+ foreach ($images as $image) {
1279
+ // WPMU action
1280
+ if ( nggWPMU::check_quota() )
1281
+ return;
1282
+
1283
+ $i = 0;
1284
+ $tmp_prefix = '';
1285
+ $destination_file_name = $image->filename;
1286
+ while (file_exists($destination_path . '/' . $destination_file_name)) {
1287
+ $tmp_prefix = 'copy_' . ($i++) . '_';
1288
+ $destination_file_name = $tmp_prefix . $image->filename;
1289
+ }
1290
+
1291
+ $destination_file_path = $destination_path . '/' . $destination_file_name;
1292
+ $destination_thumb_file_path = $destination_path . '/' . $image->thumbFolder . $image->thumbPrefix . $destination_file_name;
1293
+
1294
+ // Copy files
1295
+ if ( !@copy($image->imagePath, $destination_file_path) ) {
1296
+ $errors .= sprintf(__('Failed to copy image %1$s to %2$s','nggallery'),
1297
+ esc_html( $image->filename ), esc_html( $destination_file_path) ) . '<br />';
1298
+ continue;
1299
+ }
1300
+
1301
+ // Copy backup file, if possible
1302
+ @copy($image->imagePath . '_backup', $destination_file_path . '_backup');
1303
+ // Copy the thumbnail if possible
1304
+ @copy($image->thumbPath, $destination_thumb_file_path);
1305
+
1306
+ // Create new database entry for the image
1307
+ $new_pid = nggdb::insert_image( $destination->gid, $destination_file_name, $image->alttext, $image->description, $image->exclude);
1308
+
1309
+ if (!isset($new_pid)) {
1310
+ $errors .= sprintf(__('Failed to copy database row for picture %s','nggallery'), $image->pid) . '<br />';
1311
+ continue;
1312
+ }
1313
+
1314
+ // Copy tags
1315
+ nggTags::copy_tags($image->pid, $new_pid);
1316
+
1317
+ // Copy meta information
1318
+ $meta = new nggMeta($image->pid);
1319
+ nggdb::update_image_meta( $new_pid, $meta->image->meta_data);
1320
+
1321
+ if ( $tmp_prefix != '' ) {
1322
+ $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s) &raquo; The file already existed in the destination gallery.','nggallery'),
1323
+ $image->pid, esc_html($image->filename), $new_pid, esc_html($destination_file_name) ) . '<br />';
1324
+ } else {
1325
+ $messages .= sprintf(__('Image %1$s (%2$s) copied as image %3$s (%4$s)','nggallery'),
1326
+ $image->pid, esc_html($image->filename), $new_pid, esc_html($destination_file_name) ) . '<br />';
1327
+ }
1328
+
1329
+ }
1330
+
1331
+ // Finish by showing errors or success
1332
+ if ( $errors == '' ) {
1333
+ $link = '<a href="' . admin_url() . 'admin.php?page=nggallery-manage-gallery&mode=edit&gid=' . $destination->gid . '" >' . esc_html($destination->title) . '</a>';
1334
+ $messages .= '<hr />' . sprintf(__('Copied %1$s picture(s) to gallery: %2$s .','nggallery'), count($images), $link);
1335
+ }
1336
+
1337
+ if ( $messages != '' )
1338
+ nggGallery::show_message($messages);
1339
+
1340
+ if ( $errors != '' )
1341
+ nggGallery::show_error($errors);
1342
+
1343
+ return;
1344
+ }
1345
+
1346
+ /**
1347
+ * Initate the Ajax operation
1348
+ *
1349
+ * @class nggAdmin
1350
+ * @param string $operation name of the function which should be executed
1351
+ * @param array $image_array
1352
+ * @param string $title name of the operation
1353
+ * @return string the javascript output
1354
+ */
1355
+ static function do_ajax_operation( $operation, $image_array, $title = '' ) {
1356
+
1357
+ if ( !is_array($image_array) || empty($image_array) )
1358
+ return;
1359
+
1360
+ $js_array = implode('","', $image_array);
1361
+
1362
+ // send out some JavaScript, which initate the ajax operation
1363
+ ?>
1364
+ <script type="text/javascript">
1365
+
1366
+ Images = new Array("<?php echo $js_array; ?>");
1367
+
1368
+ nggAjaxOptions = {
1369
+ operation: "<?php echo $operation; ?>",
1370
+ ids: Images,
1371
+ header: "<?php echo $title; ?>",
1372
+ maxStep: Images.length
1373
+ };
1374
+
1375
+ jQuery(document).ready( function(){
1376
+ nggProgressBar.init( nggAjaxOptions );
1377
+ nggAjax.init( nggAjaxOptions );
1378
+ } );
1379
+ </script>
1380
+
1381
+ <?php
1382
+ }
1383
+
1384
+ /**
1385
+ * nggAdmin::set_gallery_preview() - define a preview pic after the first upload, can be changed in the gallery settings
1386
+ *
1387
+ * @class nggAdmin
1388
+ * @param int $galleryID
1389
+ * @return void
1390
+ */
1391
+ static function set_gallery_preview( $galleryID ) {
1392
+
1393
+ global $wpdb;
1394
+
1395
+ $gallery = nggdb::find_gallery( $galleryID );
1396
+
1397
+ // in the case no preview image is setup, we do this now
1398
+ if ($gallery->previewpic == 0) {
1399
+ $firstImage = $wpdb->get_var("SELECT pid FROM $wpdb->nggpictures WHERE exclude != 1 AND galleryid = '$galleryID' ORDER by pid DESC limit 0,1");
1400
+ if ($firstImage) {
1401
+ $wpdb->query("UPDATE $wpdb->nggallery SET previewpic = '$firstImage' WHERE gid = '$galleryID'");
1402
+ wp_cache_delete($galleryID, 'ngg_gallery');
1403
+ }
1404
+ }
1405
+
1406
+ return;
1407
+ }
1408
+
1409
+ /**
1410
+ * Return a JSON coded array of Image ids for a requested gallery
1411
+ *
1412
+ * @class nggAdmin
1413
+ * @param int $galleryID
1414
+ * @return array (JSON)
1415
+ */
1416
+ static function get_image_ids( $galleryID ) {
1417
+
1418
+ if ( !function_exists('json_encode') )
1419
+ return(-2);
1420
+
1421
+ $gallery = nggdb::get_ids_from_gallery($galleryID, 'pid', 'ASC', false);
1422
+
1423
+ header('Content-Type: text/plain; charset=' . get_option('blog_charset'), true);
1424
+ $output = json_encode($gallery);
1425
+
1426
+ return $output;
1427
+ }
1428
+
1429
+ /**
1430
+ * Decode upload error to normal message
1431
+ *
1432
+ * @class nggAdmin
1433
+ * @access internal
1434
+ * @param int $code php upload error code
1435
+ * @return string message
1436
+ */
1437
+
1438
+ static function decode_upload_error( $code ) {
1439
+
1440
+ switch ($code) {
1441
+ case UPLOAD_ERR_INI_SIZE:
1442
+ $message = __ ( 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 'nggallery' );
1443
+ break;
1444
+ case UPLOAD_ERR_FORM_SIZE:
1445
+ $message = __ ( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 'nggallery' );
1446
+ break;
1447
+ case UPLOAD_ERR_PARTIAL:
1448
+ $message = __ ( 'The uploaded file was only partially uploaded', 'nggallery' );
1449
+ break;
1450
+ case UPLOAD_ERR_NO_FILE:
1451
+ $message = __ ( 'No file was uploaded', 'nggallery' );
1452
+ break;
1453
+ case UPLOAD_ERR_NO_TMP_DIR:
1454
+ $message = __ ( 'Missing a temporary folder', 'nggallery' );
1455
+ break;
1456
+ case UPLOAD_ERR_CANT_WRITE:
1457
+ $message = __ ( 'Failed to write file to disk', 'nggallery' );
1458
+ break;
1459
+ case UPLOAD_ERR_EXTENSION:
1460
+ $message = __ ( 'File upload stopped by extension', 'nggallery' );
1461
+ break;
1462
+ default:
1463
+ $message = __ ( 'Unknown upload error', 'nggallery' );
1464
+ break;
1465
+ }
1466
+
1467
+ return $message;
1468
+ }
1469
+
1470
+ } // END class nggAdmin
1471
+
1472
+ /**
1473
+ * TODO: Cannot be member of a class ? Check PCLZIP later...
1474
+ *
1475
+ * @param mixed $p_event
1476
+ * @param mixed $p_header
1477
+ * @return
1478
+ */
1479
+ function ngg_getOnlyImages($p_event, &$p_header) {
1480
+ return nggAdmin::getOnlyImages($p_event, $p_header);
1481
+ }
1482
+
1483
+ /**
1484
+ * Ensure after zip extraction that it could be only a image file
1485
+ *
1486
+ * @param mixed $p_event
1487
+ * @param mixed $p_header
1488
+ * @return 1
1489
+ */
1490
+ function ngg_checkExtract($p_event, &$p_header) {
1491
+
1492
+ // look for valid extraction
1493
+ if ($p_header['status'] == 'ok') {
1494
+ // check if it's any image file, delete all other files
1495
+ if ( !@getimagesize ( $p_header['filename'] ))
1496
+ unlink($p_header['filename']);
1497
+ }
1498
+
1499
+ return 1;
1500
+ }
1501
+ ?>
admin/install.php CHANGED
@@ -1,282 +1,282 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- /**
5
- * creates all tables for the gallery
6
- * called during register_activation hook
7
- *
8
- * @access internal
9
- * @return void
10
- */
11
- function nggallery_install () {
12
-
13
- global $wpdb , $wp_roles, $wp_version;
14
-
15
- // Check for capability
16
- if ( !current_user_can('activate_plugins') )
17
- return;
18
-
19
- // Set the capabilities for the administrator
20
- $role = get_role('administrator');
21
- // We need this role, no other chance
22
- if ( empty($role) ) {
23
- update_option( "ngg_init_check", __('Sorry, NextCellent Gallery works only with a role called administrator',"nggallery") );
24
- return;
25
- }
26
-
27
- $role->add_cap('NextGEN Gallery overview');
28
- $role->add_cap('NextGEN Use TinyMCE');
29
- $role->add_cap('NextGEN Upload images');
30
- $role->add_cap('NextGEN Manage gallery');
31
- $role->add_cap('NextGEN Manage tags');
32
- $role->add_cap('NextGEN Manage others gallery');
33
- $role->add_cap('NextGEN Edit album');
34
- $role->add_cap('NextGEN Change style');
35
- $role->add_cap('NextGEN Change options');
36
-
37
- // upgrade function changed in WordPress 2.3
38
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
39
-
40
- // add charset & collate like wp core
41
- $charset_collate = '';
42
-
43
- if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
44
- if ( ! empty($wpdb->charset) )
45
- $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
46
- if ( ! empty($wpdb->collate) )
47
- $charset_collate .= " COLLATE $wpdb->collate";
48
- }
49
-
50
- $nggpictures = $wpdb->prefix . 'ngg_pictures';
51
- $nggallery = $wpdb->prefix . 'ngg_gallery';
52
- $nggalbum = $wpdb->prefix . 'ngg_album';
53
-
54
- // 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'" ) ) {
102
- update_option( "ngg_init_check", __('NextCellent Gallery : Tables could not created, please check your database settings',"nggallery") );
103
- return;
104
- }
105
-
106
- $options = get_option('ngg_options');
107
- // set the default settings, if we didn't upgrade
108
- if ( empty( $options ) )
109
- ngg_default_options();
110
-
111
- // if all is passed , save the DBVERSION
112
- add_option("ngg_db_version", NGG_DBVERSION);
113
-
114
- }
115
-
116
- /**
117
- * Setup the default option array for the gallery
118
- *
119
- * @access internal
120
- * @since version 0.33
121
- * @return void
122
- */
123
- function ngg_default_options() {
124
-
125
- global $blog_id, $ngg;
126
-
127
- $ngg_options['gallerypath'] = 'wp-content/gallery/'; // set default path to the gallery
128
- $ngg_options['deleteImg'] = true; // delete Images
129
- $ngg_options['swfUpload'] = true; // activate the batch upload
130
- $ngg_options['usePermalinks'] = false; // use permalinks for parameters
131
- $ngg_options['permalinkSlug'] = 'nggallery'; // the default slug for permalinks
132
- $ngg_options['graphicLibrary'] = 'gd'; // default graphic library
133
- $ngg_options['imageMagickDir'] = '/usr/local/bin/'; // default path to ImageMagick
134
- $ngg_options['useMediaRSS'] = false; // activate the global Media RSS file
135
- $ngg_options['usePicLens'] = false; // activate the PicLens Link for galleries
136
-
137
- // Tags / categories
138
- $ngg_options['activateTags'] = false; // append related images
139
- $ngg_options['appendType'] = 'tags'; // look for category or tags
140
- $ngg_options['maxImages'] = 7; // number of images toshow
141
-
142
- // Thumbnail Settings
143
- $ngg_options['thumbwidth'] = 100; // Thumb Width
144
- $ngg_options['thumbheight'] = 75; // Thumb height
145
- $ngg_options['thumbfix'] = true; // Fix the dimension
146
- $ngg_options['thumbquality'] = 100; // Thumb Quality
147
-
148
- // Image Settings
149
- $ngg_options['imgWidth'] = 800; // Image Width
150
- $ngg_options['imgHeight'] = 600; // Image height
151
- $ngg_options['imgQuality'] = 85; // Image Quality
152
- $ngg_options['imgBackup'] = true; // Create a backup
153
- $ngg_options['imgAutoResize'] = false; // Resize after upload
154
-
155
- // Gallery Settings
156
- $ngg_options['galImages'] = '20'; // Number of images per page
157
- $ngg_options['galPagedGalleries'] = 0; // Number of galleries per page (in a album)
158
- $ngg_options['galColumns'] = 0; // Number of columns for the gallery
159
- $ngg_options['galShowSlide'] = true; // Show slideshow
160
- $ngg_options['galTextSlide'] = __('[Show as slideshow]','nggallery'); // Text for slideshow
161
- $ngg_options['galTextGallery'] = __('[Show picture list]','nggallery'); // Text for gallery
162
- $ngg_options['galShowOrder'] = 'gallery'; // Show order
163
- $ngg_options['galSort'] = 'sortorder'; // Sort order
164
- $ngg_options['galSortDir'] = 'ASC'; // Sort direction
165
- $ngg_options['galNoPages'] = true; // use no subpages for gallery
166
- $ngg_options['galImgBrowser'] = false; // Show ImageBrowser, instead effect
167
- $ngg_options['galHiddenImg'] = false; // For paged galleries we can hide image
168
- $ngg_options['galAjaxNav'] = false; // AJAX Navigation for Shutter effect
169
-
170
- // Thumbnail Effect
171
- $ngg_options['thumbEffect'] = 'shutter'; // select effect
172
- $ngg_options['thumbCode'] = 'class="shutterset_%GALLERY_NAME%"';
173
-
174
- // Watermark settings
175
- $ngg_options['wmPos'] = 'botRight'; // Postion
176
- $ngg_options['wmXpos'] = 5; // X Pos
177
- $ngg_options['wmYpos'] = 5; // Y Pos
178
- $ngg_options['wmType'] = 'text'; // Type : 'image' / 'text'
179
- $ngg_options['wmPath'] = ''; // Path to image
180
- $ngg_options['wmFont'] = 'arial.ttf'; // Font type
181
- $ngg_options['wmSize'] = 10; // Font Size
182
- $ngg_options['wmText'] = get_option('blogname'); // Text
183
- $ngg_options['wmColor'] = '000000'; // Font Color
184
- $ngg_options['wmOpaque'] = '100'; // Font Opaque
185
-
186
- // Image Rotator settings
187
- $ngg_options['enableIR'] = false;
188
- $ngg_options['slideFx'] = 'fade';
189
- $ngg_options['irURL'] = path_join(NGGALLERY_URLPATH, 'imagerotator.swf');
190
- $ngg_options['irXHTMLvalid'] = false;
191
- $ngg_options['irAudio'] = '';
192
- $ngg_options['irWidth'] = 320;
193
- $ngg_options['irHeight'] = 240;
194
- $ngg_options['irShuffle'] = true;
195
- $ngg_options['irLinkfromdisplay'] = true;
196
- $ngg_options['irShownavigation'] = false;
197
- $ngg_options['irShowicons'] = false;
198
- $ngg_options['irWatermark'] = false;
199
- $ngg_options['irOverstretch'] = 'true';
200
- $ngg_options['irRotatetime'] = 10;
201
- $ngg_options['irTransition'] = 'random';
202
- $ngg_options['irKenburns'] = false;
203
- $ngg_options['irBackcolor'] = '000000';
204
- $ngg_options['irFrontcolor'] = 'FFFFFF';
205
- $ngg_options['irLightcolor'] = 'CC0000';
206
- $ngg_options['irScreencolor'] = '000000';
207
-
208
- // CSS Style
209
- $ngg_options['activateCSS'] = true; // activate the CSS file
210
- $ngg_options['CSSfile'] = 'nggallery.css'; // set default css filename
211
-
212
- // special overrides for WPMU
213
- if (is_multisite()) {
214
- // get the site options
215
- $ngg_wpmu_options = get_site_option('ngg_options');
216
-
217
- // get the default value during first installation
218
- if (!is_array($ngg_wpmu_options)) {
219
- $ngg_wpmu_options['gallerypath'] = 'wp-content/blogs.dir/%BLOG_ID%/files/';
220
- $ngg_wpmu_options['wpmuCSSfile'] = 'nggallery.css';
221
- update_site_option('ngg_options', $ngg_wpmu_options);
222
- }
223
-
224
- $ngg_options['gallerypath'] = str_replace("%BLOG_ID%", $blog_id , $ngg_wpmu_options['gallerypath']);
225
- $ngg_options['CSSfile'] = $ngg_wpmu_options['wpmuCSSfile'];
226
- }
227
-
228
- update_option('ngg_options', $ngg_options);
229
-
230
- }
231
-
232
- /**
233
- * Deregister a capability from all classic roles
234
- *
235
- * @access internal
236
- * @param string $capability name of the capability which should be deregister
237
- * @return void
238
- */
239
- function ngg_remove_capability($capability){
240
- // this function remove the $capability only from the classic roles
241
- $check_order = array("subscriber", "contributor", "author", "editor", "administrator");
242
-
243
- foreach ($check_order as $role) {
244
-
245
- $role = get_role($role);
246
- $role->remove_cap($capability) ;
247
- }
248
-
249
- }
250
-
251
- /**
252
- * Uninstall all settings and tables
253
- * Called via Setup and register_unstall hook
254
- *
255
- * @access internal
256
- * @return void
257
- */
258
- function nggallery_uninstall() {
259
- global $wpdb;
260
-
261
- // first remove all tables
262
- $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_pictures");
263
- $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_gallery");
264
- $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_album");
265
-
266
- // then remove all options
267
- delete_option( 'ngg_options' );
268
- delete_option( 'ngg_db_version' );
269
- delete_option( 'ngg_update_exists' );
270
- delete_option( 'ngg_next_update' );
271
-
272
- // now remove the capability
273
- ngg_remove_capability("NextGEN Gallery overview");
274
- ngg_remove_capability("NextGEN Use TinyMCE");
275
- ngg_remove_capability("NextGEN Upload images");
276
- ngg_remove_capability("NextGEN Manage gallery");
277
- ngg_remove_capability("NextGEN Edit album");
278
- ngg_remove_capability("NextGEN Change style");
279
- ngg_remove_capability("NextGEN Change options");
280
- }
281
-
282
  ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ /**
5
+ * creates all tables for the gallery
6
+ * called during register_activation hook
7
+ *
8
+ * @access internal
9
+ * @return void
10
+ */
11
+ function nggallery_install () {
12
+
13
+ global $wpdb , $wp_roles, $wp_version;
14
+
15
+ // Check for capability
16
+ if ( !current_user_can('activate_plugins') )
17
+ return;
18
+
19
+ // Set the capabilities for the administrator
20
+ $role = get_role('administrator');
21
+ // We need this role, no other chance
22
+ if ( empty($role) ) {
23
+ update_option( "ngg_init_check", __('Sorry, NextCellent Gallery works only with a role called administrator',"nggallery") );
24
+ return;
25
+ }
26
+
27
+ $role->add_cap('NextGEN Gallery overview');
28
+ $role->add_cap('NextGEN Use TinyMCE');
29
+ $role->add_cap('NextGEN Upload images');
30
+ $role->add_cap('NextGEN Manage gallery');
31
+ $role->add_cap('NextGEN Manage tags');
32
+ $role->add_cap('NextGEN Manage others gallery');
33
+ $role->add_cap('NextGEN Edit album');
34
+ $role->add_cap('NextGEN Change style');
35
+ $role->add_cap('NextGEN Change options');
36
+
37
+ // upgrade function changed in WordPress 2.3
38
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
39
+
40
+ // add charset & collate like wp core
41
+ $charset_collate = '';
42
+
43
+ if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
44
+ if ( ! empty($wpdb->charset) )
45
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
46
+ if ( ! empty($wpdb->collate) )
47
+ $charset_collate .= " COLLATE $wpdb->collate";
48
+ }
49
+
50
+ $nggpictures = $wpdb->prefix . 'ngg_pictures';
51
+ $nggallery = $wpdb->prefix . 'ngg_gallery';
52
+ $nggalbum = $wpdb->prefix . 'ngg_album';
53
+
54
+ // 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'" ) ) {
102
+ update_option( "ngg_init_check", __('NextCellent Gallery : Tables could not created, please check your database settings',"nggallery") );
103
+ return;
104
+ }
105
+
106
+ $options = get_option('ngg_options');
107
+ // set the default settings, if we didn't upgrade
108
+ if ( empty( $options ) )
109
+ ngg_default_options();
110
+
111
+ // if all is passed , save the DBVERSION
112
+ add_option("ngg_db_version", NGG_DBVERSION);
113
+
114
+ }
115
+
116
+ /**
117
+ * Setup the default option array for the gallery
118
+ *
119
+ * @access internal
120
+ * @since version 0.33
121
+ * @return void
122
+ */
123
+ function ngg_default_options() {
124
+
125
+ global $blog_id, $ngg;
126
+
127
+ $ngg_options['gallerypath'] = 'wp-content/gallery/'; // set default path to the gallery
128
+ $ngg_options['deleteImg'] = true; // delete Images
129
+ $ngg_options['swfUpload'] = true; // activate the batch upload
130
+ $ngg_options['usePermalinks'] = false; // use permalinks for parameters
131
+ $ngg_options['permalinkSlug'] = 'nggallery'; // the default slug for permalinks
132
+ $ngg_options['graphicLibrary'] = 'gd'; // default graphic library
133
+ $ngg_options['imageMagickDir'] = '/usr/local/bin/'; // default path to ImageMagick
134
+ $ngg_options['useMediaRSS'] = false; // activate the global Media RSS file
135
+ $ngg_options['usePicLens'] = false; // activate the PicLens Link for galleries
136
+
137
+ // Tags / categories
138
+ $ngg_options['activateTags'] = false; // append related images
139
+ $ngg_options['appendType'] = 'tags'; // look for category or tags
140
+ $ngg_options['maxImages'] = 7; // number of images toshow
141
+
142
+ // Thumbnail Settings
143
+ $ngg_options['thumbwidth'] = 100; // Thumb Width
144
+ $ngg_options['thumbheight'] = 75; // Thumb height
145
+ $ngg_options['thumbfix'] = true; // Fix the dimension
146
+ $ngg_options['thumbquality'] = 100; // Thumb Quality
147
+
148
+ // Image Settings
149
+ $ngg_options['imgWidth'] = 800; // Image Width
150
+ $ngg_options['imgHeight'] = 600; // Image height
151
+ $ngg_options['imgQuality'] = 85; // Image Quality
152
+ $ngg_options['imgBackup'] = true; // Create a backup
153
+ $ngg_options['imgAutoResize'] = false; // Resize after upload
154
+
155
+ // Gallery Settings
156
+ $ngg_options['galImages'] = '20'; // Number of images per page
157
+ $ngg_options['galPagedGalleries'] = 0; // Number of galleries per page (in a album)
158
+ $ngg_options['galColumns'] = 0; // Number of columns for the gallery
159
+ $ngg_options['galShowSlide'] = true; // Show slideshow
160
+ $ngg_options['galTextSlide'] = __('[Show as slideshow]','nggallery'); // Text for slideshow
161
+ $ngg_options['galTextGallery'] = __('[Show picture list]','nggallery'); // Text for gallery
162
+ $ngg_options['galShowOrder'] = 'gallery'; // Show order
163
+ $ngg_options['galSort'] = 'sortorder'; // Sort order
164
+ $ngg_options['galSortDir'] = 'ASC'; // Sort direction
165
+ $ngg_options['galNoPages'] = true; // use no subpages for gallery
166
+ $ngg_options['galImgBrowser'] = false; // Show ImageBrowser, instead effect
167
+ $ngg_options['galHiddenImg'] = false; // For paged galleries we can hide image
168
+ $ngg_options['galAjaxNav'] = false; // AJAX Navigation for Shutter effect
169
+
170
+ // Thumbnail Effect
171
+ $ngg_options['thumbEffect'] = 'shutter'; // select effect
172
+ $ngg_options['thumbCode'] = 'class="shutterset_%GALLERY_NAME%"';
173
+
174
+ // Watermark settings
175
+ $ngg_options['wmPos'] = 'botRight'; // Postion
176
+ $ngg_options['wmXpos'] = 5; // X Pos
177
+ $ngg_options['wmYpos'] = 5; // Y Pos
178
+ $ngg_options['wmType'] = 'text'; // Type : 'image' / 'text'
179
+ $ngg_options['wmPath'] = ''; // Path to image
180
+ $ngg_options['wmFont'] = 'arial.ttf'; // Font type
181
+ $ngg_options['wmSize'] = 10; // Font Size
182
+ $ngg_options['wmText'] = get_option('blogname'); // Text
183
+ $ngg_options['wmColor'] = '000000'; // Font Color
184
+ $ngg_options['wmOpaque'] = '100'; // Font Opaque
185
+
186
+ // Image Rotator settings
187
+ $ngg_options['enableIR'] = false;
188
+ $ngg_options['slideFx'] = 'fade';
189
+ $ngg_options['irURL'] = path_join(NGGALLERY_URLPATH, 'imagerotator.swf');
190
+ $ngg_options['irXHTMLvalid'] = false;
191
+ $ngg_options['irAudio'] = '';
192
+ $ngg_options['irWidth'] = 320;
193
+ $ngg_options['irHeight'] = 240;
194
+ $ngg_options['irShuffle'] = true;
195
+ $ngg_options['irLinkfromdisplay'] = true;
196
+ $ngg_options['irShownavigation'] = false;
197
+ $ngg_options['irShowicons'] = false;
198
+ $ngg_options['irWatermark'] = false;
199
+ $ngg_options['irOverstretch'] = 'true';
200
+ $ngg_options['irRotatetime'] = 10;
201
+ $ngg_options['irTransition'] = 'random';
202
+ $ngg_options['irKenburns'] = false;
203
+ $ngg_options['irBackcolor'] = '000000';
204
+ $ngg_options['irFrontcolor'] = 'FFFFFF';
205
+ $ngg_options['irLightcolor'] = 'CC0000';
206
+ $ngg_options['irScreencolor'] = '000000';
207
+
208
+ // CSS Style
209
+ $ngg_options['activateCSS'] = true; // activate the CSS file
210
+ $ngg_options['CSSfile'] = 'nggallery.css'; // set default css filename
211
+
212
+ // special overrides for WPMU
213
+ if (is_multisite()) {
214
+ // get the site options
215
+ $ngg_wpmu_options = get_site_option('ngg_options');
216
+
217
+ // get the default value during first installation
218
+ if (!is_array($ngg_wpmu_options)) {
219
+ $ngg_wpmu_options['gallerypath'] = 'wp-content/blogs.dir/%BLOG_ID%/files/';
220
+ $ngg_wpmu_options['wpmuCSSfile'] = 'nggallery.css';
221
+ update_site_option('ngg_options', $ngg_wpmu_options);
222
+ }
223
+
224
+ $ngg_options['gallerypath'] = str_replace("%BLOG_ID%", $blog_id , $ngg_wpmu_options['gallerypath']);
225
+ $ngg_options['CSSfile'] = $ngg_wpmu_options['wpmuCSSfile'];
226
+ }
227
+
228
+ update_option('ngg_options', $ngg_options);
229
+
230
+ }
231
+
232
+ /**
233
+ * Deregister a capability from all classic roles
234
+ *
235
+ * @access internal
236
+ * @param string $capability name of the capability which should be deregister
237
+ * @return void
238
+ */
239
+ function ngg_remove_capability($capability){
240
+ // this function remove the $capability only from the classic roles
241
+ $check_order = array("subscriber", "contributor", "author", "editor", "administrator");
242
+
243
+ foreach ($check_order as $role) {
244
+
245
+ $role = get_role($role);
246
+ $role->remove_cap($capability) ;
247
+ }
248
+
249
+ }
250
+
251
+ /**
252
+ * Uninstall all settings and tables
253
+ * Called via Setup and register_unstall hook
254
+ *
255
+ * @access internal
256
+ * @return void
257
+ */
258
+ function nggallery_uninstall() {
259
+ global $wpdb;
260
+
261
+ // first remove all tables
262
+ $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_pictures");
263
+ $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_gallery");
264
+ $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}ngg_album");
265
+
266
+ // then remove all options
267
+ delete_option( 'ngg_options' );
268
+ delete_option( 'ngg_db_version' );
269
+ delete_option( 'ngg_update_exists' );
270
+ delete_option( 'ngg_next_update' );
271
+
272
+ // now remove the capability
273
+ ngg_remove_capability("NextGEN Gallery overview");
274
+ ngg_remove_capability("NextGEN Use TinyMCE");
275
+ ngg_remove_capability("NextGEN Upload images");
276
+ ngg_remove_capability("NextGEN Manage gallery");
277
+ ngg_remove_capability("NextGEN Edit album");
278
+ ngg_remove_capability("NextGEN Change style");
279
+ ngg_remove_capability("NextGEN Change options");
280
+ }
281
+
282
  ?>
admin/js/Jcrop/css/jquery.Jcrop.css CHANGED
@@ -1,35 +1,35 @@
1
- /* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */
2
- .jcrop-holder { text-align: left; }
3
-
4
- .jcrop-vline, .jcrop-hline
5
- {
6
- font-size: 0;
7
- position: absolute;
8
- background: white url('Jcrop.gif') top left repeat;
9
- }
10
- .jcrop-vline { height: 100%; width: 1px !important; }
11
- .jcrop-hline { width: 100%; height: 1px !important; }
12
- .jcrop-handle {
13
- font-size: 1px;
14
- width: 7px !important;
15
- height: 7px !important;
16
- border: 1px #eee solid;
17
- background-color: #333;
18
- *width: 9px;
19
- *height: 9px;
20
- }
21
-
22
- .jcrop-tracker { width: 100%; height: 100%; }
23
-
24
- .custom .jcrop-vline,
25
- .custom .jcrop-hline
26
- {
27
- background: yellow;
28
- }
29
- .custom .jcrop-handle
30
- {
31
- border-color: black;
32
- background-color: #C7BB00;
33
- -moz-border-radius: 3px;
34
- -webkit-border-radius: 3px;
35
- }
1
+ /* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */
2
+ .jcrop-holder { text-align: left; }
3
+
4
+ .jcrop-vline, .jcrop-hline
5
+ {
6
+ font-size: 0;
7
+ position: absolute;
8
+ background: white url('Jcrop.gif') top left repeat;
9
+ }
10
+ .jcrop-vline { height: 100%; width: 1px !important; }
11
+ .jcrop-hline { width: 100%; height: 1px !important; }
12
+ .jcrop-handle {
13
+ font-size: 1px;
14
+ width: 7px !important;
15
+ height: 7px !important;
16
+ border: 1px #eee solid;
17
+ background-color: #333;
18
+ *width: 9px;
19
+ *height: 9px;
20
+ }
21
+
22
+ .jcrop-tracker { width: 100%; height: 100%; }
23
+
24
+ .custom .jcrop-vline,
25
+ .custom .jcrop-hline
26
+ {
27
+ background: yellow;
28
+ }
29
+ .custom .jcrop-handle
30
+ {
31
+ border-color: black;
32
+ background-color: #C7BB00;
33
+ -moz-border-radius: 3px;
34
+ -webkit-border-radius: 3px;
35
+ }
admin/js/Jcrop/js/jquery.Jcrop.js CHANGED
@@ -1,1197 +1,1197 @@
1
- /**
2
- * jquery.Jcrop.js v0.9.8
3
- * jQuery Image Cropping Plugin
4
- * @author Kelly Hallman <khallman@gmail.com>
5
- * Copyright (c) 2008-2009 Kelly Hallman - released under MIT License {{{
6
- *
7
- * Permission is hereby granted, free of charge, to any person
8
- * obtaining a copy of this software and associated documentation
9
- * files (the "Software"), to deal in the Software without
10
- * restriction, including without limitation the rights to use,
11
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- * copies of the Software, and to permit persons to whom the
13
- * Software is furnished to do so, subject to the following
14
- * conditions:
15
-
16
- * The above copyright notice and this permission notice shall be
17
- * included in all copies or substantial portions of the Software.
18
-
19
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26
- * OTHER DEALINGS IN THE SOFTWARE.
27
-
28
- * }}}
29
- */
30
-
31
- (function($) {
32
-
33
- $.Jcrop = function(obj,opt)
34
- {
35
- // Initialization {{{
36
-
37
- // Sanitize some options {{{
38
- var obj = obj, opt = opt;
39
-
40
- if (typeof(obj) !== 'object') obj = $(obj)[0];
41
- if (typeof(opt) !== 'object') opt = { };
42
-
43
- // Some on-the-fly fixes for MSIE...sigh
44
- if (!('trackDocument' in opt))
45
- {
46
- opt.trackDocument = $.browser.msie ? false : true;
47
- if ($.browser.msie && $.browser.version.split('.')[0] == '8')
48
- opt.trackDocument = true;
49
- }
50
-
51
- if (!('keySupport' in opt))
52
- opt.keySupport = $.browser.msie ? false : true;
53
-
54
- // }}}
55
- // Extend the default options {{{
56
- var defaults = {
57
-
58
- // Basic Settings
59
- trackDocument: false,
60
- baseClass: 'jcrop',
61
- addClass: null,
62
-
63
- // Styling Options
64
- bgColor: 'black',
65
- bgOpacity: .6,
66
- borderOpacity: .4,
67
- handleOpacity: .5,
68
-
69
- handlePad: 5,
70
- handleSize: 9,
71
- handleOffset: 5,
72
- edgeMargin: 14,
73
-
74
- aspectRatio: 0,
75
- keySupport: true,
76
- cornerHandles: true,
77
- sideHandles: true,
78
- drawBorders: true,
79
- dragEdges: true,
80
-
81
- boxWidth: 0,
82
- boxHeight: 0,
83
-
84
- boundary: 8,
85
- animationDelay: 20,
86
- swingSpeed: 3,
87
-
88
- allowSelect: true,
89
- allowMove: true,
90
- allowResize: true,
91
-
92
- minSelect: [ 0, 0 ],
93
- maxSize: [ 0, 0 ],
94
- minSize: [ 0, 0 ],
95
-
96
- // Callbacks / Event Handlers
97
- onChange: function() { },
98
- onSelect: function() { }
99
-
100
- };
101
- var options = defaults;
102
- setOptions(opt);
103
-
104
- // }}}
105
- // Initialize some jQuery objects {{{
106
-
107
- var $origimg = $(obj);
108
- var $img = $origimg.clone().removeAttr('id').css({ position: 'absolute' });
109
-
110
- $img.width($origimg.width());
111
- $img.height($origimg.height());
112
- $origimg.after($img).hide();
113
-
114
- presize($img,options.boxWidth,options.boxHeight);
115
-
116
- var boundx = $img.width(),
117
- boundy = $img.height(),
118
-
119
- $div = $('<div />')
120
- .width(boundx).height(boundy)
121
- .addClass(cssClass('holder'))
122
- .css({
123
- position: 'relative',
124
- backgroundColor: options.bgColor
125
- }).insertAfter($origimg).append($img);
126
- ;
127
-
128
- if (options.addClass) $div.addClass(options.addClass);
129
- //$img.wrap($div);
130
-
131
- var $img2 = $('<img />')/*{{{*/
132
- .attr('src',$img.attr('src'))
133
- .css('position','absolute')
134
- .width(boundx).height(boundy)
135
- ;/*}}}*/
136
- var $img_holder = $('<div />')/*{{{*/
137
- .width(pct(100)).height(pct(100))
138
- .css({
139
- zIndex: 310,
140
- position: 'absolute',
141
- overflow: 'hidden'
142
- })
143
- .append($img2)
144
- ;/*}}}*/
145
- var $hdl_holder = $('<div />')/*{{{*/
146
- .width(pct(100)).height(pct(100))
147
- .css('zIndex',320);
148
- /*}}}*/
149
- var $sel = $('<div />')/*{{{*/
150
- .css({
151
- position: 'absolute',
152
- zIndex: 300
153
- })
154
- .insertBefore($img)
155
- .append($img_holder,$hdl_holder)
156
- ;/*}}}*/
157
-
158
- var bound = options.boundary;
159
- var $trk = newTracker().width(boundx+(bound*2)).height(boundy+(bound*2))
160
- .css({ position: 'absolute', top: px(-bound), left: px(-bound), zIndex: 290 })
161
- .mousedown(newSelection);
162
-
163
- /* }}} */
164
- // Set more variables {{{
165
-
166
- var xlimit, ylimit, xmin, ymin;
167
- var xscale, yscale, enabled = true;
168
- var docOffset = getPos($img),
169
- // Internal states
170
- btndown, lastcurs, dimmed, animating,
171
- shift_down;
172
-
173
- // }}}
174
-
175
-
176
- // }}}
177
- // Internal Modules {{{
178
-
179
- var Coords = function()/*{{{*/
180
- {
181
- var x1 = 0, y1 = 0, x2 = 0, y2 = 0, ox, oy;
182
-
183
- function setPressed(pos)/*{{{*/
184
- {
185
- var pos = rebound(pos);
186
- x2 = x1 = pos[0];
187
- y2 = y1 = pos[1];
188
- };
189
- /*}}}*/
190
- function setCurrent(pos)/*{{{*/
191
- {
192
- var pos = rebound(pos);
193
- ox = pos[0] - x2;
194
- oy = pos[1] - y2;
195
- x2 = pos[0];
196
- y2 = pos[1];
197
- };
198
- /*}}}*/
199
- function getOffset()/*{{{*/
200
- {
201
- return [ ox, oy ];
202
- };
203
- /*}}}*/
204
- function moveOffset(offset)/*{{{*/
205
- {
206
- var ox = offset[0], oy = offset[1];
207
-
208
- if (0 > x1 + ox) ox -= ox + x1;
209
- if (0 > y1 + oy) oy -= oy + y1;
210
-
211
- if (boundy < y2 + oy) oy += boundy - (y2 + oy);
212
- if (boundx < x2 + ox) ox += boundx - (x2 + ox);
213
-
214
- x1 += ox;
215
- x2 += ox;
216
- y1 += oy;
217
- y2 += oy;
218
- };
219
- /*}}}*/
220
- function getCorner(ord)/*{{{*/
221
- {
222
- var c = getFixed();
223
- switch(ord)
224
- {
225
- case 'ne': return [ c.x2, c.y ];
226
- case 'nw': return [ c.x, c.y ];
227
- case 'se': return [ c.x2, c.y2 ];
228
- case 'sw': return [ c.x, c.y2 ];
229
- }
230
- };
231
- /*}}}*/
232
- function getFixed()/*{{{*/
233
- {
234
- if (!options.aspectRatio) return getRect();
235
- // This function could use some optimization I think...
236
- var aspect = options.aspectRatio,
237
- min_x = options.minSize[0]/xscale,
238
- min_y = options.minSize[1]/yscale,
239
- max_x = options.maxSize[0]/xscale,
240
- max_y = options.maxSize[1]/yscale,
241
- rw = x2 - x1,
242
- rh = y2 - y1,
243
- rwa = Math.abs(rw),
244
- rha = Math.abs(rh),
245
- real_ratio = rwa / rha,
246
- xx, yy
247
- ;
248
- if (max_x == 0) { max_x = boundx * 10 }
249
- if (max_y == 0) { max_y = boundy * 10 }
250
- if (real_ratio < aspect)
251
- {
252
- yy = y2;
253
- w = rha * aspect;
254
- xx = rw < 0 ? x1 - w : w + x1;
255
-
256
- if (xx < 0)
257
- {
258
- xx = 0;
259
- h = Math.abs((xx - x1) / aspect);
260
- yy = rh < 0 ? y1 - h: h + y1;
261
- }
262
- else if (xx > boundx)
263
- {
264
- xx = boundx;
265
- h = Math.abs((xx - x1) / aspect);
266
- yy = rh < 0 ? y1 - h : h + y1;
267
- }
268
- }
269
- else
270
- {
271
- xx = x2;
272
- h = rwa / aspect;
273
- yy = rh < 0 ? y1 - h : y1 + h;
274
- if (yy < 0)
275
- {
276
- yy = 0;
277
- w = Math.abs((yy - y1) * aspect);
278
- xx = rw < 0 ? x1 - w : w + x1;
279
- }
280
- else if (yy > boundy)
281
- {
282
- yy = boundy;
283
- w = Math.abs(yy - y1) * aspect;
284
- xx = rw < 0 ? x1 - w : w + x1;
285
- }
286
- }
287
-
288
- // Magic %-)
289
- if(xx > x1) { // right side
290
- if(xx - x1 < min_x) {
291
- xx = x1 + min_x;
292
- } else if (xx - x1 > max_x) {
293
- xx = x1 + max_x;
294
- }
295
- if(yy > y1) {
296
- yy = y1 + (xx - x1)/aspect;
297
- } else {
298
- yy = y1 - (xx - x1)/aspect;
299
- }
300
- } else if (xx < x1) { // left side
301
- if(x1 - xx < min_x) {
302
- xx = x1 - min_x
303
- } else if (x1 - xx > max_x) {
304
- xx = x1 - max_x;
305
- }
306
- if(yy > y1) {
307
- yy = y1 + (x1 - xx)/aspect;
308
- } else {
309
- yy = y1 - (x1 - xx)/aspect;
310
- }
311
- }
312
-
313
- if(xx < 0) {
314
- x1 -= xx;
315
- xx = 0;
316
- } else if (xx > boundx) {
317
- x1 -= xx - boundx;
318
- xx = boundx;
319
- }
320
-
321
- if(yy < 0) {
322
- y1 -= yy;
323
- yy = 0;
324
- } else if (yy > boundy) {
325
- y1 -= yy - boundy;
326
- yy = boundy;
327
- }
328
-
329
- return last = makeObj(flipCoords(x1,y1,xx,yy));
330
- };
331
- /*}}}*/
332
- function rebound(p)/*{{{*/
333
- {
334
- if (p[0] < 0) p[0] = 0;
335
- if (p[1] < 0) p[1] = 0;
336
-
337
- if (p[0] > boundx) p[0] = boundx;
338
- if (p[1] > boundy) p[1] = boundy;
339
-
340
- return [ p[0], p[1] ];
341
- };
342
- /*}}}*/
343
- function flipCoords(x1,y1,x2,y2)/*{{{*/
344
- {
345
- var xa = x1, xb = x2, ya = y1, yb = y2;
346
- if (x2 < x1)
347
- {
348
- xa = x2;
349
- xb = x1;
350
- }
351
- if (y2 < y1)
352
- {
353
- ya = y2;
354
- yb = y1;
355
- }
356
- return [ Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb) ];
357
- };
358
- /*}}}*/
359
- function getRect()/*{{{*/
360
- {
361
- var xsize = x2 - x1;
362
- var ysize = y2 - y1;
363
-
364
- if (xlimit && (Math.abs(xsize) > xlimit))
365
- x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit);
366
- if (ylimit && (Math.abs(ysize) > ylimit))
367
- y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit);
368
-
369
- if (ymin && (Math.abs(ysize) < ymin))
370
- y2 = (ysize > 0) ? (y1 + ymin) : (y1 - ymin);
371
- if (xmin && (Math.abs(xsize) < xmin))
372
- x2 = (xsize > 0) ? (x1 + xmin) : (x1 - xmin);
373
-
374
- if (x1 < 0) { x2 -= x1; x1 -= x1; }
375
- if (y1 < 0) { y2 -= y1; y1 -= y1; }
376
- if (x2 < 0) { x1 -= x2; x2 -= x2; }
377
- if (y2 < 0) { y1 -= y2; y2 -= y2; }
378
- if (x2 > boundx) { var delta = x2 - boundx; x1 -= delta; x2 -= delta; }
379
- if (y2 > boundy) { var delta = y2 - boundy; y1 -= delta; y2 -= delta; }
380
- if (x1 > boundx) { var delta = x1 - boundy; y2 -= delta; y1 -= delta; }
381
- if (y1 > boundy) { var delta = y1 - boundy; y2 -= delta; y1 -= delta; }
382
-
383
- return makeObj(flipCoords(x1,y1,x2,y2));
384
- };
385
- /*}}}*/
386
- function makeObj(a)/*{{{*/
387
- {
388
- return { x: a[0], y: a[1], x2: a[2], y2: a[3],
389
- w: a[2] - a[0], h: a[3] - a[1] };
390
- };
391
- /*}}}*/
392
-
393
- return {
394
- flipCoords: flipCoords,
395
- setPressed: setPressed,
396
- setCurrent: setCurrent,
397
- getOffset: getOffset,
398
- moveOffset: moveOffset,
399
- getCorner: getCorner,
400
- getFixed: getFixed
401
- };
402
- }();
403
-
404
- /*}}}*/
405
- var Selection = function()/*{{{*/
406
- {
407
- var start, end, dragmode, awake, hdep = 370;
408
- var borders = { };
409
- var handle = { };
410
- var seehandles = false;
411
- var hhs = options.handleOffset;
412
-
413
- /* Insert draggable elements {{{*/
414
-
415
- // Insert border divs for outline
416
- if (options.drawBorders) {
417
- borders = {
418
- top: insertBorder('hline')
419
- .css('top',$.browser.msie?px(-1):px(0)),
420
- bottom: insertBorder('hline'),
421
- left: insertBorder('vline'),
422
- right: insertBorder('vline')
423
- };
424
- }
425
-
426
- // Insert handles on edges
427
- if (options.dragEdges) {
428
- handle.t = insertDragbar('n');
429
- handle.b = insertDragbar('s');
430
- handle.r = insertDragbar('e');
431
- handle.l = insertDragbar('w');
432
- }
433
-
434
- // Insert side handles
435
- options.sideHandles &&
436
- createHandles(['n','s','e','w']);
437
-
438
- // Insert corner handles
439
- options.cornerHandles &&
440
- createHandles(['sw','nw','ne','se']);
441
-
442
- /*}}}*/
443
- // Private Methods
444
- function insertBorder(type)/*{{{*/
445
- {
446
- var jq = $('<div />')
447
- .css({position: 'absolute', opacity: options.borderOpacity })
448
- .addClass(cssClass(type));
449
- $img_holder.append(jq);
450
- return jq;
451
- };
452
- /*}}}*/
453
- function dragDiv(ord,zi)/*{{{*/
454
- {
455
- var jq = $('<div />')
456
- .mousedown(createDragger(ord))
457
- .css({
458
- cursor: ord+'-resize',
459
- position: 'absolute',
460
- zIndex: zi
461
- })
462
- ;
463
- $hdl_holder.append(jq);
464
- return jq;
465
- };
466
- /*}}}*/
467
- function insertHandle(ord)/*{{{*/
468
- {
469
- return dragDiv(ord,hdep++)
470
- .css({ top: px(-hhs+1), left: px(-hhs+1), opacity: options.handleOpacity })
471
- .addClass(cssClass('handle'));
472
- };
473
- /*}}}*/
474
- function insertDragbar(ord)/*{{{*/
475
- {
476
- var s = options.handleSize,
477
- o = hhs,
478
- h = s, w = s,
479
- t = o, l = o;
480
-
481
- switch(ord)
482
- {
483
- case 'n': case 's': w = pct(100); break;
484
- case 'e': case 'w': h = pct(100); break;
485
- }
486
-
487
- return dragDiv(ord,hdep++).width(w).height(h)
488
- .css({ top: px(-t+1), left: px(-l+1)});
489
- };
490
- /*}}}*/
491
- function createHandles(li)/*{{{*/
492
- {
493
- for(i in li) handle[li[i]] = insertHandle(li[i]);
494
- };
495
- /*}}}*/
496
- function moveHandles(c)/*{{{*/
497
- {
498
- var midvert = Math.round((c.h / 2) - hhs),
499
- midhoriz = Math.round((c.w / 2) - hhs),
500
- north = west = -hhs+1,
501
- east = c.w - hhs,
502
- south = c.h - hhs,
503
- x, y;
504
-
505
- 'e' in handle &&
506
- handle.e.css({ top: px(midvert), left: px(east) }) &&
507
- handle.w.css({ top: px(midvert) }) &&
508
- handle.s.css({ top: px(south), left: px(midhoriz) }) &&
509
- handle.n.css({ left: px(midhoriz) });
510
-
511
- 'ne' in handle &&
512
- handle.ne.css({ left: px(east) }) &&
513
- handle.se.css({ top: px(south), left: px(east) }) &&
514
- handle.sw.css({ top: px(south) });
515
-
516
- 'b' in handle &&
517
- handle.b.css({ top: px(south) }) &&
518
- handle.r.css({ left: px(east) });
519
- };
520
- /*}}}*/
521
- function moveto(x,y)/*{{{*/
522
- {
523
- $img2.css({ top: px(-y), left: px(-x) });
524
- $sel.css({ top: px(y), left: px(x) });
525
- };
526
- /*}}}*/
527
- function resize(w,h)/*{{{*/
528
- {
529
- $sel.width(w).height(h);
530
- };
531
- /*}}}*/
532
- function refresh()/*{{{*/
533
- {
534
- var c = Coords.getFixed();
535
-
536
- Coords.setPressed([c.x,c.y]);
537
- Coords.setCurrent([c.x2,c.y2]);
538
-
539
- updateVisible();
540
- };
541
- /*}}}*/
542
-
543
- // Internal Methods
544
- function updateVisible()/*{{{*/
545
- { if (awake) return update(); };
546
- /*}}}*/
547
- function update()/*{{{*/
548
- {
549
- var c = Coords.getFixed();
550
-
551
- resize(c.w,c.h);
552
- moveto(c.x,c.y);
553
-
554
- options.drawBorders &&
555
- borders['right'].css({ left: px(c.w-1) }) &&
556
- borders['bottom'].css({ top: px(c.h-1) });
557
-
558
- seehandles && moveHandles(c);
559
- awake || show();
560
-
561
- options.onChange(unscale(c));
562
- };
563
- /*}}}*/
564
- function show()/*{{{*/
565
- {
566
- $sel.show();
567
- $img.css('opacity',options.bgOpacity);
568
- awake = true;
569
- };
570
- /*}}}*/
571
- function release()/*{{{*/
572
- {
573
- disableHandles();
574
- $sel.hide();
575
- $img.css('opacity',1);
576
- awake = false;
577
- };
578
- /*}}}*/
579
- function showHandles()//{{{
580
- {
581
- if (seehandles)
582
- {
583
- moveHandles(Coords.getFixed());
584
- $hdl_holder.show();
585
- }
586
- };
587
- //}}}
588
- function enableHandles()/*{{{*/
589
- {
590
- seehandles = true;
591
- if (options.allowResize)
592
- {
593
- moveHandles(Coords.getFixed());
594
- $hdl_holder.show();
595
- return true;
596
- }
597
- };
598
- /*}}}*/
599
- function disableHandles()/*{{{*/
600
- {
601
- seehandles = false;
602
- $hdl_holder.hide();
603
- };
604
- /*}}}*/
605
- function animMode(v)/*{{{*/
606
- {
607
- (animating = v) ? disableHandles(): enableHandles();
608
- };
609
- /*}}}*/
610
- function done()/*{{{*/
611
- {
612
- animMode(false);
613
- refresh();
614
- };
615
- /*}}}*/
616
-
617
- var $track = newTracker().mousedown(createDragger('move'))
618
- .css({ cursor: 'move', position: 'absolute', zIndex: 360 })
619
-
620
- $img_holder.append($track);
621
- disableHandles();
622
-
623
- return {
624
- updateVisible: updateVisible,
625
- update: update,
626
- release: release,
627
- refresh: refresh,
628
- setCursor: function (cursor) { $track.css('cursor',cursor); },
629
- enableHandles: enableHandles,
630
- enableOnly: function() { seehandles = true; },
631
- showHandles: showHandles,
632
- disableHandles: disableHandles,
633
- animMode: animMode,
634
- done: done
635
- };
636
- }();
637
- /*}}}*/
638
- var Tracker = function()/*{{{*/
639
- {
640
- var onMove = function() { },
641
- onDone = function() { },
642
- trackDoc = options.trackDocument;
643
-
644
- if (!trackDoc)
645
- {
646
- $trk
647
- .mousemove(trackMove)
648
- .mouseup(trackUp)
649
- .mouseout(trackUp)
650
- ;
651
- }
652
-
653
- function toFront()/*{{{*/
654
- {
655
- $trk.css({zIndex:450});
656
- if (trackDoc)
657
- {
658
- $(document)
659
- .mousemove(trackMove)
660
- .mouseup(trackUp)
661
- ;
662
- }
663
- }
664
- /*}}}*/
665
- function toBack()/*{{{*/
666
- {
667
- $trk.css({zIndex:290});
668
- if (trackDoc)
669
- {
670
- $(document)
671
- .unbind('mousemove',trackMove)
672
- .unbind('mouseup',trackUp)
673
- ;
674
- }
675
- }
676
- /*}}}*/
677
- function trackMove(e)/*{{{*/
678
- {
679
- onMove(mouseAbs(e));
680
- };
681
- /*}}}*/
682
- function trackUp(e)/*{{{*/
683
- {
684
- e.preventDefault();
685
- e.stopPropagation();
686
-
687
- if (btndown)
688
- {
689
- btndown = false;
690
-
691
- onDone(mouseAbs(e));
692
- options.onSelect(unscale(Coords.getFixed()));
693
- toBack();
694
- onMove = function() { };
695
- onDone = function() { };
696
- }
697
-
698
- return false;
699
- };
700
- /*}}}*/
701
-
702
- function activateHandlers(move,done)/* {{{ */
703
- {
704
- btndown = true;
705
- onMove = move;
706
- onDone = done;
707
- toFront();
708
- return false;
709
- };
710
- /* }}} */
711
-
712
- function setCursor(t) { $trk.css('cursor',t); };
713
-
714
- $img.before($trk);
715
- return {
716
- activateHandlers: activateHandlers,
717
- setCursor: setCursor
718
- };
719
- }();
720
- /*}}}*/
721
- var KeyManager = function()/*{{{*/
722
- {
723
- var $keymgr = $('<input type="radio" />')
724
- .css({ position: 'absolute', left: '-30px' })
725
- .keypress(parseKey)
726
- .blur(onBlur),
727
-
728
- $keywrap = $('<div />')
729
- .css({
730
- position: 'absolute',
731
- overflow: 'hidden'
732
- })
733
- .append($keymgr)
734
- ;
735
-
736
- function watchKeys()/*{{{*/
737
- {
738
- if (options.keySupport)
739
- {
740
- $keymgr.show();
741
- $keymgr.focus();
742
- }
743
- };
744
- /*}}}*/
745
- function onBlur(e)/*{{{*/
746
- {
747
- $keymgr.hide();
748
- };
749
- /*}}}*/
750
- function doNudge(e,x,y)/*{{{*/
751
- {
752
- if (options.allowMove) {
753
- Coords.moveOffset([x,y]);
754
- Selection.updateVisible();
755
- };
756
- e.preventDefault();
757
- e.stopPropagation();
758
- };
759
- /*}}}*/
760
- function parseKey(e)/*{{{*/
761
- {
762
- if (e.ctrlKey) return true;
763
- shift_down = e.shiftKey ? true : false;
764
- var nudge = shift_down ? 10 : 1;
765
- switch(e.keyCode)
766
- {
767
- case 37: doNudge(e,-nudge,0); break;
768
- case 39: doNudge(e,nudge,0); break;
769
- case 38: doNudge(e,0,-nudge); break;
770
- case 40: doNudge(e,0,nudge); break;
771
-
772
- case 27: Selection.release(); break;
773
-
774
- case 9: return true;
775
- }
776
-
777
- return nothing(e);
778
- };
779
- /*}}}*/
780
-
781
- if (options.keySupport) $keywrap.insertBefore($img);
782
- return {
783
- watchKeys: watchKeys
784
- };
785
- }();
786
- /*}}}*/
787
-
788
- // }}}
789
- // Internal Methods {{{
790
-
791
- function px(n) { return '' + parseInt(n) + 'px'; };
792
- function pct(n) { return '' + parseInt(n) + '%'; };
793
- function cssClass(cl) { return options.baseClass + '-' + cl; };
794
- function getPos(obj)/*{{{*/
795
- {
796
- // Updated in v0.9.4 to use built-in dimensions plugin
797
- var pos = $(obj).offset();
798
- return [ pos.left, pos.top ];
799
- };
800
- /*}}}*/
801
- function mouseAbs(e)/*{{{*/
802
- {
803
- return [ (e.pageX - docOffset[0]), (e.pageY - docOffset[1]) ];
804
- };
805
- /*}}}*/
806
- function myCursor(type)/*{{{*/
807
- {
808
- if (type != lastcurs)
809
- {
810
- Tracker.setCursor(type);
811
- //Handles.xsetCursor(type);
812
- lastcurs = type;
813
- }
814
- };
815
- /*}}}*/
816
- function startDragMode(mode,pos)/*{{{*/
817
- {
818
- docOffset = getPos($img);
819
- Tracker.setCursor(mode=='move'?mode:mode+'-resize');
820
-
821
- if (mode == 'move')
822
- return Tracker.activateHandlers(createMover(pos), doneSelect);
823
-
824
- var fc = Coords.getFixed();
825
- var opp = oppLockCorner(mode);
826
- var opc = Coords.getCorner(oppLockCorner(opp));
827
-
828
- Coords.setPressed(Coords.getCorner(opp));
829
- Coords.setCurrent(opc);
830
-
831
- Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect);
832
- };
833
- /*}}}*/
834
- function dragmodeHandler(mode,f)/*{{{*/
835
- {
836
- return function(pos) {
837
- if (!options.aspectRatio) switch(mode)
838
- {
839
- case 'e': pos[1] = f.y2; break;
840
- case 'w': pos[1] = f.y2; break;
841
- case 'n': pos[0] = f.x2; break;
842
- case 's': pos[0] = f.x2; break;
843
- }
844
- else switch(mode)
845
- {
846
- case 'e': pos[1] = f.y+1; break;
847
- case 'w': pos[1] = f.y+1; break;
848
- case 'n': pos[0] = f.x+1; break;
849
- case 's': pos[0] = f.x+1; break;
850
- }
851
- Coords.setCurrent(pos);
852
- Selection.update();
853
- };
854
- };
855
- /*}}}*/
856
- function createMover(pos)/*{{{*/
857
- {
858
- var lloc = pos;
859
- KeyManager.watchKeys();
860
-
861
- return function(pos)
862
- {
863
- Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]);
864
- lloc = pos;
865
-
866
- Selection.update();
867
- };
868
- };
869
- /*}}}*/
870
- function oppLockCorner(ord)/*{{{*/
871
- {
872
- switch(ord)
873
- {
874
- case 'n': return 'sw';
875
- case 's': return 'nw';
876
- case 'e': return 'nw';
877
- case 'w': return 'ne';
878
- case 'ne': return 'sw';
879
- case 'nw': return 'se';
880
- case 'se': return 'nw';
881
- case 'sw': return 'ne';
882
- };
883
- };
884
- /*}}}*/
885
- function createDragger(ord)/*{{{*/
886
- {
887
- return function(e) {
888
- if (options.disabled) return false;
889
- if ((ord == 'move') && !options.allowMove) return false;
890
- btndown = true;
891
- startDragMode(ord,mouseAbs(e));
892
- e.stopPropagation();
893
- e.preventDefault();
894
- return false;
895
- };
896
- };
897
- /*}}}*/
898
- function presize($obj,w,h)/*{{{*/
899
- {
900
- var nw = $obj.width(), nh = $obj.height();
901
- if ((nw > w) && w > 0)
902
- {
903
- nw = w;
904
- nh = (w/$obj.width()) * $obj.height();
905
- }
906
- if ((nh > h) && h > 0)
907
- {
908
- nh = h;
909
- nw = (h/$obj.height()) * $obj.width();
910
- }
911
- xscale = $obj.width() / nw;
912
- yscale = $obj.height() / nh;
913
- $obj.width(nw).height(nh);
914
- };
915
- /*}}}*/
916
- function unscale(c)/*{{{*/
917
- {
918
- return {
919
- x: parseInt(c.x * xscale), y: parseInt(c.y * yscale),
920
- x2: parseInt(c.x2 * xscale), y2: parseInt(c.y2 * yscale),
921
- w: parseInt(c.w * xscale), h: parseInt(c.h * yscale)
922
- };
923
- };
924
- /*}}}*/
925
- function doneSelect(pos)/*{{{*/
926
- {
927
- var c = Coords.getFixed();
928
- if (c.w > options.minSelect[0] && c.h > options.minSelect[1])
929
- {
930
- Selection.enableHandles();
931
- Selection.done();
932
- }
933
- else
934
- {
935
- Selection.release();
936
- }
937
- Tracker.setCursor( options.allowSelect?'crosshair':'default' );
938
- };
939
- /*}}}*/
940
- function newSelection(e)/*{{{*/
941
- {
942
- if (options.disabled) return false;
943
- if (!options.allowSelect) return false;
944
- btndown = true;
945
- docOffset = getPos($img);
946
- Selection.disableHandles();
947
- myCursor('crosshair');
948
- var pos = mouseAbs(e);
949
- Coords.setPressed(pos);
950
- Tracker.activateHandlers(selectDrag,doneSelect);
951
- KeyManager.watchKeys();
952
- Selection.update();
953
-
954
- e.stopPropagation();
955
- e.preventDefault();
956
- return false;
957
- };
958
- /*}}}*/
959
- function selectDrag(pos)/*{{{*/
960
- {
961
- Coords.setCurrent(pos);
962
- Selection.update();
963
- };
964
- /*}}}*/
965
- function newTracker()
966
- {
967
- var trk = $('<div></div>').addClass(cssClass('tracker'));
968
- $.browser.msie && trk.css({ opacity: 0, backgroundColor: 'white' });
969
- return trk;
970
- };
971
-
972
- // }}}
973
- // API methods {{{
974
-
975
- function animateTo(a)/*{{{*/
976
- {
977
- var x1 = a[0] / xscale,
978
- y1 = a[1] / yscale,
979
- x2 = a[2] / xscale,
980
- y2 = a[3] / yscale;
981
-
982
- if (animating) return;
983
-
984
- var animto = Coords.flipCoords(x1,y1,x2,y2);
985
- var c = Coords.getFixed();
986
- var animat = initcr = [ c.x, c.y, c.x2, c.y2 ];
987
- var interv = options.animationDelay;
988
-
989
- var x = animat[0];
990
- var y = animat[1];
991
- var x2 = animat[2];
992
- var y2 = animat[3];
993
- var ix1 = animto[0] - initcr[0];
994
- var iy1 = animto[1] - initcr[1];
995
- var ix2 = animto[2] - initcr[2];
996
- var iy2 = animto[3] - initcr[3];
997
- var pcent = 0;
998
- var velocity = options.swingSpeed;
999
-
1000
- Selection.animMode(true);
1001
-
1002
- var animator = function()
1003
- {
1004
- return function()
1005
- {
1006
- pcent += (100 - pcent) / velocity;
1007
-
1008
- animat[0] = x + ((pcent / 100) * ix1);
1009
- animat[1] = y + ((pcent / 100) * iy1);
1010
- animat[2] = x2 + ((pcent / 100) * ix2);
1011
- animat[3] = y2 + ((pcent / 100) * iy2);
1012
-
1013
- if (pcent < 100) animateStart();
1014
- else Selection.done();
1015
-
1016
- if (pcent >= 99.8) pcent = 100;
1017
-
1018
- setSelectRaw(animat);
1019
- };
1020
- }();
1021
-
1022
- function animateStart()
1023
- { window.setTimeout(animator,interv); };
1024
-
1025
- animateStart();
1026
- };
1027
- /*}}}*/
1028
- function setSelect(rect)//{{{
1029
- {
1030
- setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]);
1031
- };
1032
- //}}}
1033
- function setSelectRaw(l) /*{{{*/
1034
- {
1035
- Coords.setPressed([l[0],l[1]]);
1036
- Coords.setCurrent([l[2],l[3]]);
1037
- Selection.update();
1038
- };
1039
- /*}}}*/
1040
- function setOptions(opt)/*{{{*/
1041
- {
1042
- if (typeof(opt) != 'object') opt = { };
1043
- options = $.extend(options,opt);
1044
-
1045
- if (typeof(options.onChange)!=='function')
1046
- options.onChange = function() { };
1047
-
1048
- if (typeof(options.onSelect)!=='function')
1049
- options.onSelect = function() { };
1050
-
1051
- };
1052
- /*}}}*/
1053
- function tellSelect()/*{{{*/
1054
- {
1055
- return unscale(Coords.getFixed());
1056
- };
1057
- /*}}}*/
1058
- function tellScaled()/*{{{*/
1059
- {
1060
- return Coords.getFixed();
1061
- };
1062
- /*}}}*/
1063
- function setOptionsNew(opt)/*{{{*/
1064
- {
1065
- setOptions(opt);
1066
- interfaceUpdate();
1067
- };
1068
- /*}}}*/
1069
- function disableCrop()//{{{
1070
- {
1071
- options.disabled = true;
1072
- Selection.disableHandles();
1073
- Selection.setCursor('default');
1074
- Tracker.setCursor('default');
1075
- };
1076
- //}}}
1077
- function enableCrop()//{{{
1078
- {
1079
- options.disabled = false;
1080
- interfaceUpdate();
1081
- };
1082
- //}}}
1083
- function cancelCrop()//{{{
1084
- {
1085
- Selection.done();
1086
- Tracker.activateHandlers(null,null);
1087
- };
1088
- //}}}
1089
- function destroy()//{{{
1090
- {
1091
- $div.remove();
1092
- $origimg.show();
1093
- };
1094
- //}}}
1095
-
1096
- function interfaceUpdate(alt)//{{{
1097
- // This method tweaks the interface based on options object.
1098
- // Called when options are changed and at end of initialization.
1099
- {
1100
- options.allowResize ?
1101
- alt?Selection.enableOnly():Selection.enableHandles():
1102
- Selection.disableHandles();
1103
-
1104
- Tracker.setCursor( options.allowSelect? 'crosshair': 'default' );
1105
- Selection.setCursor( options.allowMove? 'move': 'default' );
1106
-
1107
- $div.css('backgroundColor',options.bgColor);
1108
-
1109
- if ('setSelect' in options) {
1110
- setSelect(opt.setSelect);
1111
- Selection.done();
1112
- delete(options.setSelect);
1113
- }
1114
-
1115
- if ('trueSize' in options) {
1116
- xscale = options.trueSize[0] / boundx;
1117
- yscale = options.trueSize[1] / boundy;
1118
- }
1119
-
1120
- xlimit = options.maxSize[0] || 0;
1121
- ylimit = options.maxSize[1] || 0;
1122
- xmin = options.minSize[0] || 0;
1123
- ymin = options.minSize[1] || 0;
1124
-
1125
- if ('outerImage' in options)
1126
- {
1127
- $img.attr('src',options.outerImage);
1128
- delete(options.outerImage);
1129
- }
1130
-
1131
- Selection.refresh();
1132
- };
1133
- //}}}
1134
-
1135
- // }}}
1136
-
1137
- $hdl_holder.hide();
1138
- interfaceUpdate(true);
1139
-
1140
- var api = {
1141
- animateTo: animateTo,
1142
- setSelect: setSelect,
1143
- setOptions: setOptionsNew,
1144
- tellSelect: tellSelect,
1145
- tellScaled: tellScaled,
1146
-
1147
- disable: disableCrop,
1148
- enable: enableCrop,
1149
- cancel: cancelCrop,
1150
-
1151
- focus: KeyManager.watchKeys,
1152
-
1153
- getBounds: function() { return [ boundx * xscale, boundy * yscale ]; },
1154
- getWidgetSize: function() { return [ boundx, boundy ]; },
1155
-
1156
- release: Selection.release,
1157
- destroy: destroy
1158
-
1159
- };
1160
-
1161
- $origimg.data('Jcrop',api);
1162
- return api;
1163
- };
1164
-
1165
- $.fn.Jcrop = function(options)/*{{{*/
1166
- {
1167
- function attachWhenDone(from)/*{{{*/
1168
- {
1169
- var loadsrc = options.useImg || from.src;
1170
- var img = new Image();
1171
- img.onload = function() { $.Jcrop(from,options); };
1172
- img.src = loadsrc;
1173
- };
1174
- /*}}}*/
1175
- if (typeof(options) !== 'object') options = { };
1176
-
1177
- // Iterate over each object, attach Jcrop
1178
- this.each(function()
1179
- {
1180
- // If we've already attached to this object
1181
- if ($(this).data('Jcrop'))
1182
- {
1183
- // The API can be requested this way (undocumented)
1184
- if (options == 'api') return $(this).data('Jcrop');
1185
- // Otherwise, we just reset the options...
1186
- else $(this).data('Jcrop').setOptions(options);
1187
- }
1188
- // If we haven't been attached, preload and attach
1189
- else attachWhenDone(this);
1190
- });
1191
-
1192
- // Return "this" so we're chainable a la jQuery plugin-style!
1193
- return this;
1194
- };
1195
- /*}}}*/
1196
-
1197
- })(jQuery);
1
+ /**
2
+ * jquery.Jcrop.js v0.9.8
3
+ * jQuery Image Cropping Plugin
4
+ * @author Kelly Hallman <khallman@gmail.com>
5
+ * Copyright (c) 2008-2009 Kelly Hallman - released under MIT License {{{
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person
8
+ * obtaining a copy of this software and associated documentation
9
+ * files (the "Software"), to deal in the Software without
10
+ * restriction, including without limitation the rights to use,
11
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the
13
+ * Software is furnished to do so, subject to the following
14
+ * conditions:
15
+
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26
+ * OTHER DEALINGS IN THE SOFTWARE.
27
+
28
+ * }}}
29
+ */
30
+
31
+ (function($) {
32
+
33
+ $.Jcrop = function(obj,opt)
34
+ {
35
+ // Initialization {{{
36
+
37
+ // Sanitize some options {{{
38
+ var obj = obj, opt = opt;
39
+
40
+ if (typeof(obj) !== 'object') obj = $(obj)[0];
41
+ if (typeof(opt) !== 'object') opt = { };
42
+
43
+ // Some on-the-fly fixes for MSIE...sigh
44
+ if (!('trackDocument' in opt))
45
+ {
46
+ opt.trackDocument = $.browser.msie ? false : true;
47
+ if ($.browser.msie && $.browser.version.split('.')[0] == '8')
48
+ opt.trackDocument = true;
49
+ }
50
+
51
+ if (!('keySupport' in opt))
52
+ opt.keySupport = $.browser.msie ? false : true;
53
+
54
+ // }}}
55
+ // Extend the default options {{{
56
+ var defaults = {
57
+
58
+ // Basic Settings
59
+ trackDocument: false,
60
+ baseClass: 'jcrop',
61
+ addClass: null,
62
+
63
+ // Styling Options
64
+ bgColor: 'black',
65
+ bgOpacity: .6,
66
+ borderOpacity: .4,
67
+ handleOpacity: .5,
68
+
69
+ handlePad: 5,
70
+ handleSize: 9,
71
+ handleOffset: 5,
72
+ edgeMargin: 14,
73
+
74
+ aspectRatio: 0,
75
+ keySupport: true,
76
+ cornerHandles: true,
77
+ sideHandles: true,
78
+ drawBorders: true,
79
+ dragEdges: true,
80
+
81
+ boxWidth: 0,
82
+ boxHeight: 0,
83
+
84
+ boundary: 8,
85
+ animationDelay: 20,
86
+ swingSpeed: 3,
87
+
88
+ allowSelect: true,
89
+ allowMove: true,
90
+ allowResize: true,
91
+
92
+ minSelect: [ 0, 0 ],
93
+ maxSize: [ 0, 0 ],
94
+ minSize: [ 0, 0 ],
95
+
96
+ // Callbacks / Event Handlers
97
+ onChange: function() { },
98
+ onSelect: function() { }
99
+
100
+ };
101
+ var options = defaults;
102
+ setOptions(opt);
103
+
104
+ // }}}
105
+ // Initialize some jQuery objects {{{
106
+
107
+ var $origimg = $(obj);
108
+ var $img = $origimg.clone().removeAttr('id').css({ position: 'absolute' });
109
+
110
+ $img.width($origimg.width());
111
+ $img.height($origimg.height());
112
+ $origimg.after($img).hide();
113
+
114
+ presize($img,options.boxWidth,options.boxHeight);
115
+
116
+ var boundx = $img.width(),
117
+ boundy = $img.height(),
118
+
119
+ $div = $('<div />')
120
+ .width(boundx).height(boundy)
121
+ .addClass(cssClass('holder'))
122
+ .css({
123
+ position: 'relative',
124
+ backgroundColor: options.bgColor
125
+ }).insertAfter($origimg).append($img);
126
+ ;
127
+
128
+ if (options.addClass) $div.addClass(options.addClass);
129
+ //$img.wrap($div);
130
+
131
+ var $img2 = $('<img />')/*{{{*/
132
+ .attr('src',$img.attr('src'))
133
+ .css('position','absolute')
134
+ .width(boundx).height(boundy)
135
+ ;/*}}}*/
136
+ var $img_holder = $('<div />')/*{{{*/
137
+ .width(pct(100)).height(pct(100))
138
+ .css({
139
+ zIndex: 310,
140
+ position: 'absolute',
141
+ overflow: 'hidden'
142
+ })
143
+ .append($img2)
144
+ ;/*}}}*/
145
+ var $hdl_holder = $('<div />')/*{{{*/
146
+ .width(pct(100)).height(pct(100))
147
+ .css('zIndex',320);
148
+ /*}}}*/
149
+ var $sel = $('<div />')/*{{{*/
150
+ .css({
151
+ position: 'absolute',
152
+ zIndex: 300
153
+ })
154
+ .insertBefore($img)
155
+ .append($img_holder,$hdl_holder)
156
+ ;/*}}}*/
157
+
158
+ var bound = options.boundary;
159
+ var $trk = newTracker().width(boundx+(bound*2)).height(boundy+(bound*2))
160
+ .css({ position: 'absolute', top: px(-bound), left: px(-bound), zIndex: 290 })
161
+ .mousedown(newSelection);
162
+
163
+ /* }}} */
164
+ // Set more variables {{{
165
+
166
+ var xlimit, ylimit, xmin, ymin;
167
+ var xscale, yscale, enabled = true;
168
+ var docOffset = getPos($img),
169
+ // Internal states
170
+ btndown, lastcurs, dimmed, animating,
171
+ shift_down;
172
+
173
+ // }}}
174
+
175
+
176
+ // }}}
177
+ // Internal Modules {{{
178
+
179
+ var Coords = function()/*{{{*/
180
+ {
181
+ var x1 = 0, y1 = 0, x2 = 0, y2 = 0, ox, oy;
182
+
183
+ function setPressed(pos)/*{{{*/
184
+ {
185
+ var pos = rebound(pos);
186
+ x2 = x1 = pos[0];
187
+ y2 = y1 = pos[1];
188
+ };
189
+ /*}}}*/
190
+ function setCurrent(pos)/*{{{*/
191
+ {
192
+ var pos = rebound(pos);
193
+ ox = pos[0] - x2;
194
+ oy = pos[1] - y2;
195
+ x2 = pos[0];
196
+ y2 = pos[1];
197
+ };
198
+ /*}}}*/
199
+ function getOffset()/*{{{*/
200
+ {
201
+ return [ ox, oy ];
202
+ };
203
+ /*}}}*/
204
+ function moveOffset(offset)/*{{{*/
205
+ {
206
+ var ox = offset[0], oy = offset[1];
207
+
208
+ if (0 > x1 + ox) ox -= ox + x1;
209
+ if (0 > y1 + oy) oy -= oy + y1;
210
+
211
+ if (boundy < y2 + oy) oy += boundy - (y2 + oy);
212
+ if (boundx < x2 + ox) ox += boundx - (x2 + ox);
213
+
214
+ x1 += ox;
215
+ x2 += ox;
216
+ y1 += oy;
217
+ y2 += oy;
218
+ };
219
+ /*}}}*/
220
+ function getCorner(ord)/*{{{*/
221
+ {
222
+ var c = getFixed();
223
+ switch(ord)
224
+ {
225
+ case 'ne': return [ c.x2, c.y ];
226
+ case 'nw': return [ c.x, c.y ];
227
+ case 'se': return [ c.x2, c.y2 ];
228
+ case 'sw': return [ c.x, c.y2 ];
229
+ }
230
+ };
231
+ /*}}}*/
232
+ function getFixed()/*{{{*/
233
+ {
234
+ if (!options.aspectRatio) return getRect();
235
+ // This function could use some optimization I think...
236
+ var aspect = options.aspectRatio,
237
+ min_x = options.minSize[0]/xscale,
238
+ min_y = options.minSize[1]/yscale,
239
+ max_x = options.maxSize[0]/xscale,
240
+ max_y = options.maxSize[1]/yscale,
241
+ rw = x2 - x1,
242
+ rh = y2 - y1,
243
+ rwa = Math.abs(rw),
244
+ rha = Math.abs(rh),
245
+ real_ratio = rwa / rha,
246
+ xx, yy
247
+ ;
248
+ if (max_x == 0) { max_x = boundx * 10 }
249
+ if (max_y == 0) { max_y = boundy * 10 }
250
+ if (real_ratio < aspect)
251
+ {
252
+ yy = y2;
253
+ w = rha * aspect;
254
+ xx = rw < 0 ? x1 - w : w + x1;
255
+
256
+ if (xx < 0)
257
+ {
258
+ xx = 0;
259
+ h = Math.abs((xx - x1) / aspect);
260
+ yy = rh < 0 ? y1 - h: h + y1;
261
+ }
262
+ else if (xx > boundx)
263
+ {
264
+ xx = boundx;
265
+ h = Math.abs((xx - x1) / aspect);
266
+ yy = rh < 0 ? y1 - h : h + y1;
267
+ }
268
+ }
269
+ else
270
+ {
271
+ xx = x2;
272
+ h = rwa / aspect;
273
+ yy = rh < 0 ? y1 - h : y1 + h;
274
+ if (yy < 0)
275
+ {
276
+ yy = 0;
277
+ w = Math.abs((yy - y1) * aspect);
278
+ xx = rw < 0 ? x1 - w : w + x1;
279
+ }
280
+ else if (yy > boundy)
281
+ {
282
+ yy = boundy;
283
+ w = Math.abs(yy - y1) * aspect;
284
+ xx = rw < 0 ? x1 - w : w + x1;
285
+ }
286
+ }
287
+
288
+ // Magic %-)
289
+ if(xx > x1) { // right side
290
+ if(xx - x1 < min_x) {
291
+ xx = x1 + min_x;
292
+ } else if (xx - x1 > max_x) {
293
+ xx = x1 + max_x;
294
+ }
295
+ if(yy > y1) {
296
+ yy = y1 + (xx - x1)/aspect;
297
+ } else {
298
+ yy = y1 - (xx - x1)/aspect;
299
+ }
300
+ } else if (xx < x1) { // left side
301
+ if(x1 - xx < min_x) {
302
+ xx = x1 - min_x
303
+ } else if (x1 - xx > max_x) {
304
+ xx = x1 - max_x;
305
+ }
306
+ if(yy > y1) {
307
+ yy = y1 + (x1 - xx)/aspect;
308
+ } else {
309
+ yy = y1 - (x1 - xx)/aspect;
310
+ }
311
+ }
312
+
313
+ if(xx < 0) {
314
+ x1 -= xx;
315
+ xx = 0;
316
+ } else if (xx > boundx) {
317
+ x1 -= xx - boundx;
318
+ xx = boundx;
319
+ }
320
+
321
+ if(yy < 0) {
322
+ y1 -= yy;
323
+ yy = 0;
324
+ } else if (yy > boundy) {
325
+ y1 -= yy - boundy;
326
+ yy = boundy;
327
+ }
328
+
329
+ return last = makeObj(flipCoords(x1,y1,xx,yy));
330
+ };
331
+ /*}}}*/
332
+ function rebound(p)/*{{{*/
333
+ {
334
+ if (p[0] < 0) p[0] = 0;
335
+ if (p[1] < 0) p[1] = 0;
336
+
337
+ if (p[0] > boundx) p[0] = boundx;
338
+ if (p[1] > boundy) p[1] = boundy;
339
+
340
+ return [ p[0], p[1] ];
341
+ };
342
+ /*}}}*/
343
+ function flipCoords(x1,y1,x2,y2)/*{{{*/
344
+ {
345
+ var xa = x1, xb = x2, ya = y1, yb = y2;
346
+ if (x2 < x1)
347
+ {
348
+ xa = x2;
349
+ xb = x1;
350
+ }
351
+ if (y2 < y1)
352
+ {
353
+ ya = y2;
354
+ yb = y1;
355
+ }
356
+ return [ Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb) ];
357
+ };
358
+ /*}}}*/
359
+ function getRect()/*{{{*/
360
+ {
361
+ var xsize = x2 - x1;
362
+ var ysize = y2 - y1;
363
+
364
+ if (xlimit && (Math.abs(xsize) > xlimit))
365
+ x2 = (xsize > 0) ? (x1 + xlimit) : (x1 - xlimit);
366
+ if (ylimit && (Math.abs(ysize) > ylimit))
367
+ y2 = (ysize > 0) ? (y1 + ylimit) : (y1 - ylimit);
368
+
369
+ if (ymin && (Math.abs(ysize) < ymin))
370
+ y2 = (ysize > 0) ? (y1 + ymin) : (y1 - ymin);
371
+ if (xmin && (Math.abs(xsize) < xmin))
372
+ x2 = (xsize > 0) ? (x1 + xmin) : (x1 - xmin);
373
+
374
+ if (x1 < 0) { x2 -= x1; x1 -= x1; }
375
+ if (y1 < 0) { y2 -= y1; y1 -= y1; }
376
+ if (x2 < 0) { x1 -= x2; x2 -= x2; }
377
+ if (y2 < 0) { y1 -= y2; y2 -= y2; }
378
+ if (x2 > boundx) { var delta = x2 - boundx; x1 -= delta; x2 -= delta; }
379
+ if (y2 > boundy) { var delta = y2 - boundy; y1 -= delta; y2 -= delta; }
380
+ if (x1 > boundx) { var delta = x1 - boundy; y2 -= delta; y1 -= delta; }
381
+ if (y1 > boundy) { var delta = y1 - boundy; y2 -= delta; y1 -= delta; }
382
+
383
+ return makeObj(flipCoords(x1,y1,x2,y2));
384
+ };
385
+ /*}}}*/
386
+ function makeObj(a)/*{{{*/
387
+ {
388
+ return { x: a[0], y: a[1], x2: a[2], y2: a[3],
389
+ w: a[2] - a[0], h: a[3] - a[1] };
390
+ };
391
+ /*}}}*/
392
+
393
+ return {
394
+ flipCoords: flipCoords,
395
+ setPressed: setPressed,
396
+ setCurrent: setCurrent,
397
+ getOffset: getOffset,
398
+ moveOffset: moveOffset,
399
+ getCorner: getCorner,
400
+ getFixed: getFixed
401
+ };
402
+ }();
403
+
404
+ /*}}}*/
405
+ var Selection = function()/*{{{*/
406
+ {
407
+ var start, end, dragmode, awake, hdep = 370;
408
+ var borders = { };
409
+ var handle = { };
410
+ var seehandles = false;
411
+ var hhs = options.handleOffset;
412
+
413
+ /* Insert draggable elements {{{*/
414
+
415
+ // Insert border divs for outline
416
+ if (options.drawBorders) {
417
+ borders = {
418
+ top: insertBorder('hline')
419
+ .css('top',$.browser.msie?px(-1):px(0)),
420
+ bottom: insertBorder('hline'),
421
+ left: insertBorder('vline'),
422
+ right: insertBorder('vline')
423
+ };
424
+ }
425
+
426
+ // Insert handles on edges
427
+ if (options.dragEdges) {
428
+ handle.t = insertDragbar('n');
429
+ handle.b = insertDragbar('s');
430
+ handle.r = insertDragbar('e');
431
+ handle.l = insertDragbar('w');
432
+ }
433
+
434
+ // Insert side handles
435
+ options.sideHandles &&
436
+ createHandles(['n','s','e','w']);
437
+
438
+ // Insert corner handles
439
+ options.cornerHandles &&
440
+ createHandles(['sw','nw','ne','se']);
441
+
442
+ /*}}}*/
443
+ // Private Methods
444
+ function insertBorder(type)/*{{{*/
445
+ {
446
+ var jq = $('<div />')
447
+ .css({position: 'absolute', opacity: options.borderOpacity })
448
+ .addClass(cssClass(type));
449
+ $img_holder.append(jq);
450
+ return jq;
451
+ };
452
+ /*}}}*/
453
+ function dragDiv(ord,zi)/*{{{*/
454
+ {
455
+ var jq = $('<div />')
456
+ .mousedown(createDragger(ord))
457
+ .css({
458
+ cursor: ord+'-resize',
459
+ position: 'absolute',
460
+ zIndex: zi
461
+ })
462
+ ;
463
+ $hdl_holder.append(jq);
464
+ return jq;
465
+ };
466
+ /*}}}*/
467
+ function insertHandle(ord)/*{{{*/
468
+ {
469
+ return dragDiv(ord,hdep++)
470
+ .css({ top: px(-hhs+1), left: px(-hhs+1), opacity: options.handleOpacity })
471
+ .addClass(cssClass('handle'));
472
+ };
473
+ /*}}}*/
474
+ function insertDragbar(ord)/*{{{*/
475
+ {
476
+ var s = options.handleSize,
477
+ o = hhs,
478
+ h = s, w = s,
479
+ t = o, l = o;
480
+
481
+ switch(ord)
482
+ {
483
+ case 'n': case 's': w = pct(100); break;
484
+ case 'e': case 'w': h = pct(100); break;
485
+ }
486
+
487
+ return dragDiv(ord,hdep++).width(w).height(h)
488
+ .css({ top: px(-t+1), left: px(-l+1)});
489
+ };
490
+ /*}}}*/
491
+ function createHandles(li)/*{{{*/
492
+ {
493
+ for(i in li) handle[li[i]] = insertHandle(li[i]);
494
+ };
495
+ /*}}}*/
496
+ function moveHandles(c)/*{{{*/
497
+ {
498
+ var midvert = Math.round((c.h / 2) - hhs),
499
+ midhoriz = Math.round((c.w / 2) - hhs),
500
+ north = west = -hhs+1,
501
+ east = c.w - hhs,
502
+ south = c.h - hhs,
503
+ x, y;
504
+
505
+ 'e' in handle &&
506
+ handle.e.css({ top: px(midvert), left: px(east) }) &&
507
+ handle.w.css({ top: px(midvert) }) &&
508
+ handle.s.css({ top: px(south), left: px(midhoriz) }) &&
509
+ handle.n.css({ left: px(midhoriz) });
510
+
511
+ 'ne' in handle &&
512
+ handle.ne.css({ left: px(east) }) &&
513
+ handle.se.css({ top: px(south), left: px(east) }) &&
514
+ handle.sw.css({ top: px(south) });
515
+
516
+ 'b' in handle &&
517
+ handle.b.css({ top: px(south) }) &&
518
+ handle.r.css({ left: px(east) });
519
+ };
520
+ /*}}}*/
521
+ function moveto(x,y)/*{{{*/
522
+ {
523
+ $img2.css({ top: px(-y), left: px(-x) });
524
+ $sel.css({ top: px(y), left: px(x) });
525
+ };
526
+ /*}}}*/
527
+ function resize(w,h)/*{{{*/
528
+ {
529
+ $sel.width(w).height(h);
530
+ };
531
+ /*}}}*/
532
+ function refresh()/*{{{*/
533
+ {
534
+ var c = Coords.getFixed();
535
+
536
+ Coords.setPressed([c.x,c.y]);
537
+ Coords.setCurrent([c.x2,c.y2]);
538
+
539
+ updateVisible();
540
+ };
541
+ /*}}}*/
542
+
543
+ // Internal Methods
544
+ function updateVisible()/*{{{*/
545
+ { if (awake) return update(); };
546
+ /*}}}*/
547
+ function update()/*{{{*/
548
+ {
549
+ var c = Coords.getFixed();
550
+
551
+ resize(c.w,c.h);
552
+ moveto(c.x,c.y);
553
+
554
+ options.drawBorders &&
555
+ borders['right'].css({ left: px(c.w-1) }) &&
556
+ borders['bottom'].css({ top: px(c.h-1) });
557
+
558
+ seehandles && moveHandles(c);
559
+ awake || show();
560
+
561
+ options.onChange(unscale(c));
562
+ };
563
+ /*}}}*/
564
+ function show()/*{{{*/
565
+ {
566
+ $sel.show();
567
+ $img.css('opacity',options.bgOpacity);
568
+ awake = true;
569
+ };
570
+ /*}}}*/
571
+ function release()/*{{{*/
572
+ {
573
+ disableHandles();
574
+ $sel.hide();
575
+ $img.css('opacity',1);
576
+ awake = false;
577
+ };
578
+ /*}}}*/
579
+ function showHandles()//{{{
580
+ {
581
+ if (seehandles)
582
+ {
583
+ moveHandles(Coords.getFixed());
584
+ $hdl_holder.show();
585
+ }
586
+ };
587
+ //}}}
588
+ function enableHandles()/*{{{*/
589
+ {
590
+ seehandles = true;
591
+ if (options.allowResize)
592
+ {
593
+ moveHandles(Coords.getFixed());
594
+ $hdl_holder.show();
595
+ return true;
596
+ }
597
+ };
598
+ /*}}}*/
599
+ function disableHandles()/*{{{*/
600
+ {
601
+ seehandles = false;
602
+ $hdl_holder.hide();
603
+ };
604
+ /*}}}*/
605
+ function animMode(v)/*{{{*/
606
+ {
607
+ (animating = v) ? disableHandles(): enableHandles();
608
+ };
609
+ /*}}}*/
610
+ function done()/*{{{*/
611
+ {
612
+ animMode(false);
613
+ refresh();
614
+ };
615
+ /*}}}*/
616
+
617
+ var $track = newTracker().mousedown(createDragger('move'))
618
+ .css({ cursor: 'move', position: 'absolute', zIndex: 360 })
619
+
620
+ $img_holder.append($track);
621
+ disableHandles();
622
+
623
+ return {
624
+ updateVisible: updateVisible,
625
+ update: update,
626
+ release: release,
627
+ refresh: refresh,
628
+ setCursor: function (cursor) { $track.css('cursor',cursor); },
629
+ enableHandles: enableHandles,
630
+ enableOnly: function() { seehandles = true; },
631
+ showHandles: showHandles,
632
+ disableHandles: disableHandles,
633
+ animMode: animMode,
634
+ done: done
635
+ };
636
+ }();
637
+ /*}}}*/
638
+ var Tracker = function()/*{{{*/
639
+ {
640
+ var onMove = function() { },
641
+ onDone = function() { },
642
+ trackDoc = options.trackDocument;
643
+
644
+ if (!trackDoc)
645
+ {
646
+ $trk
647
+ .mousemove(trackMove)
648
+ .mouseup(trackUp)
649
+ .mouseout(trackUp)
650
+ ;
651
+ }
652
+
653
+ function toFront()/*{{{*/
654
+ {
655
+ $trk.css({zIndex:450});
656
+ if (trackDoc)
657
+ {
658
+ $(document)
659
+ .mousemove(trackMove)
660
+ .mouseup(trackUp)
661
+ ;
662
+ }
663
+ }
664
+ /*}}}*/
665
+ function toBack()/*{{{*/
666
+ {
667
+ $trk.css({zIndex:290});
668
+ if (trackDoc)
669
+ {
670
+ $(document)
671
+ .unbind('mousemove',trackMove)
672
+ .unbind('mouseup',trackUp)
673
+ ;
674
+ }
675
+ }
676
+ /*}}}*/
677
+ function trackMove(e)/*{{{*/
678
+ {
679
+ onMove(mouseAbs(e));
680
+ };
681
+ /*}}}*/
682
+ function trackUp(e)/*{{{*/
683
+ {
684
+ e.preventDefault();
685
+ e.stopPropagation();
686
+
687
+ if (btndown)
688
+ {
689
+ btndown = false;
690
+
691
+ onDone(mouseAbs(e));
692
+ options.onSelect(unscale(Coords.getFixed()));
693
+ toBack();
694
+ onMove = function() { };
695
+ onDone = function() { };
696
+ }
697
+
698
+ return false;
699
+ };
700
+ /*}}}*/
701
+
702
+ function activateHandlers(move,done)/* {{{ */
703
+ {
704
+ btndown = true;
705
+ onMove = move;
706
+ onDone = done;
707
+ toFront();
708
+ return false;
709
+ };
710
+ /* }}} */
711
+
712
+ function setCursor(t) { $trk.css('cursor',t); };
713
+
714
+ $img.before($trk);
715
+ return {
716
+ activateHandlers: activateHandlers,
717
+ setCursor: setCursor
718
+ };
719
+ }();
720
+ /*}}}*/
721
+ var KeyManager = function()/*{{{*/
722
+ {
723
+ var $keymgr = $('<input type="radio" />')
724
+ .css({ position: 'absolute', left: '-30px' })
725
+ .keypress(parseKey)
726
+ .blur(onBlur),
727
+
728
+ $keywrap = $('<div />')
729
+ .css({
730
+ position: 'absolute',
731
+ overflow: 'hidden'
732
+ })
733
+ .append($keymgr)
734
+ ;
735
+
736
+ function watchKeys()/*{{{*/
737
+ {
738
+ if (options.keySupport)
739
+ {
740
+ $keymgr.show();
741
+ $keymgr.focus();
742
+ }
743
+ };
744
+ /*}}}*/
745
+ function onBlur(e)/*{{{*/
746
+ {
747
+ $keymgr.hide();
748
+ };
749
+ /*}}}*/
750
+ function doNudge(e,x,y)/*{{{*/
751
+ {
752
+ if (options.allowMove) {
753
+ Coords.moveOffset([x,y]);
754
+ Selection.updateVisible();
755
+ };
756
+ e.preventDefault();
757
+ e.stopPropagation();
758
+ };
759
+ /*}}}*/
760
+ function parseKey(e)/*{{{*/
761
+ {
762
+ if (e.ctrlKey) return true;
763
+ shift_down = e.shiftKey ? true : false;
764
+ var nudge = shift_down ? 10 : 1;
765
+ switch(e.keyCode)
766
+ {
767
+ case 37: doNudge(e,-nudge,0); break;
768
+ case 39: doNudge(e,nudge,0); break;
769
+ case 38: doNudge(e,0,-nudge); break;
770
+ case 40: doNudge(e,0,nudge); break;
771
+
772
+ case 27: Selection.release(); break;
773
+
774
+ case 9: return true;
775
+ }
776
+
777
+ return nothing(e);
778
+ };
779
+ /*}}}*/
780
+
781
+ if (options.keySupport) $keywrap.insertBefore($img);
782
+ return {
783
+ watchKeys: watchKeys
784
+ };
785
+ }();
786
+ /*}}}*/
787
+
788
+ // }}}
789
+ // Internal Methods {{{
790
+
791
+ function px(n) { return '' + parseInt(n) + 'px'; };
792
+ function pct(n) { return '' + parseInt(n) + '%'; };
793
+ function cssClass(cl) { return options.baseClass + '-' + cl; };
794
+ function getPos(obj)/*{{{*/
795
+ {
796
+ // Updated in v0.9.4 to use built-in dimensions plugin
797
+ var pos = $(obj).offset();
798
+ return [ pos.left, pos.top ];
799
+ };
800
+ /*}}}*/
801
+ function mouseAbs(e)/*{{{*/
802
+ {
803
+ return [ (e.pageX - docOffset[0]), (e.pageY - docOffset[1]) ];
804
+ };
805
+ /*}}}*/
806
+ function myCursor(type)/*{{{*/
807
+ {
808
+ if (type != lastcurs)
809
+ {
810
+ Tracker.setCursor(type);
811
+ //Handles.xsetCursor(type);
812
+ lastcurs = type;
813
+ }
814
+ };
815
+ /*}}}*/
816
+ function startDragMode(mode,pos)/*{{{*/
817
+ {
818
+ docOffset = getPos($img);
819
+ Tracker.setCursor(mode=='move'?mode:mode+'-resize');
820
+
821
+ if (mode == 'move')
822
+ return Tracker.activateHandlers(createMover(pos), doneSelect);
823
+
824
+ var fc = Coords.getFixed();
825
+ var opp = oppLockCorner(mode);
826
+ var opc = Coords.getCorner(oppLockCorner(opp));
827
+
828
+ Coords.setPressed(Coords.getCorner(opp));
829
+ Coords.setCurrent(opc);
830
+
831
+ Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect);
832
+ };
833
+ /*}}}*/
834
+ function dragmodeHandler(mode,f)/*{{{*/
835
+ {
836
+ return function(pos) {
837
+ if (!options.aspectRatio) switch(mode)
838
+ {
839
+ case 'e': pos[1] = f.y2; break;
840
+ case 'w': pos[1] = f.y2; break;
841
+ case 'n': pos[0] = f.x2; break;
842
+ case 's': pos[0] = f.x2; break;
843
+ }
844
+ else switch(mode)
845
+ {
846
+ case 'e': pos[1] = f.y+1; break;
847
+ case 'w': pos[1] = f.y+1; break;
848
+ case 'n': pos[0] = f.x+1; break;
849
+ case 's': pos[0] = f.x+1; break;
850
+ }
851
+ Coords.setCurrent(pos);
852
+ Selection.update();
853
+ };
854
+ };
855
+ /*}}}*/
856
+ function createMover(pos)/*{{{*/
857
+ {
858
+ var lloc = pos;
859
+ KeyManager.watchKeys();
860
+
861
+ return function(pos)
862
+ {
863
+ Coords.moveOffset([pos[0] - lloc[0], pos[1] - lloc[1]]);
864
+ lloc = pos;
865
+
866
+ Selection.update();
867
+ };
868
+ };
869
+ /*}}}*/
870
+ function oppLockCorner(ord)/*{{{*/
871
+ {
872
+ switch(ord)
873
+ {
874
+ case 'n': return 'sw';
875
+ case 's': return 'nw';
876
+ case 'e': return 'nw';
877
+ case 'w': return 'ne';
878
+ case 'ne': return 'sw';
879
+ case 'nw': return 'se';
880
+ case 'se': return 'nw';
881
+ case 'sw': return 'ne';
882
+ };
883
+ };
884
+ /*}}}*/
885
+ function createDragger(ord)/*{{{*/
886
+ {
887
+ return function(e) {
888
+ if (options.disabled) return false;
889
+ if ((ord == 'move') && !options.allowMove) return false;
890
+ btndown = true;
891
+ startDragMode(ord,mouseAbs(e));
892
+ e.stopPropagation();
893
+ e.preventDefault();
894
+ return false;
895
+ };
896
+ };
897
+ /*}}}*/
898
+ function presize($obj,w,h)/*{{{*/
899
+ {
900
+ var nw = $obj.width(), nh = $obj.height();
901
+ if ((nw > w) && w > 0)
902
+ {
903
+ nw = w;
904
+ nh = (w/$obj.width()) * $obj.height();
905
+ }
906
+ if ((nh > h) && h > 0)
907
+ {
908
+ nh = h;
909
+ nw = (h/$obj.height()) * $obj.width();
910
+ }
911
+ xscale = $obj.width() / nw;
912
+ yscale = $obj.height() / nh;
913
+ $obj.width(nw).height(nh);
914
+ };
915
+ /*}}}*/
916
+ function unscale(c)/*{{{*/
917
+ {
918
+ return {
919
+ x: parseInt(c.x * xscale), y: parseInt(c.y * yscale),
920
+ x2: parseInt(c.x2 * xscale), y2: parseInt(c.y2 * yscale),
921
+ w: parseInt(c.w * xscale), h: parseInt(c.h * yscale)
922
+ };
923
+ };
924
+ /*}}}*/
925
+ function doneSelect(pos)/*{{{*/
926
+ {
927
+ var c = Coords.getFixed();
928
+ if (c.w > options.minSelect[0] && c.h > options.minSelect[1])
929
+ {
930
+ Selection.enableHandles();
931
+ Selection.done();
932
+ }
933
+ else
934
+ {
935
+ Selection.release();
936
+ }
937
+ Tracker.setCursor( options.allowSelect?'crosshair':'default' );
938
+ };
939
+ /*}}}*/
940
+ function newSelection(e)/*{{{*/
941
+ {
942
+ if (options.disabled) return false;
943
+ if (!options.allowSelect) return false;
944
+ btndown = true;
945
+ docOffset = getPos($img);
946
+ Selection.disableHandles();
947
+ myCursor('crosshair');
948
+ var pos = mouseAbs(e);
949
+ Coords.setPressed(pos);
950
+ Tracker.activateHandlers(selectDrag,doneSelect);
951
+ KeyManager.watchKeys();
952
+ Selection.update();
953
+
954
+ e.stopPropagation();
955
+ e.preventDefault();
956
+ return false;
957
+ };
958
+ /*}}}*/
959
+ function selectDrag(pos)/*{{{*/
960
+ {
961
+ Coords.setCurrent(pos);
962
+ Selection.update();
963
+ };
964
+ /*}}}*/
965
+ function newTracker()
966
+ {
967
+ var trk = $('<div></div>').addClass(cssClass('tracker'));
968
+ $.browser.msie && trk.css({ opacity: 0, backgroundColor: 'white' });
969
+ return trk;
970
+ };
971
+
972
+ // }}}
973
+ // API methods {{{
974
+
975
+ function animateTo(a)/*{{{*/
976
+ {
977
+ var x1 = a[0] / xscale,
978
+ y1 = a[1] / yscale,
979
+ x2 = a[2] / xscale,
980
+ y2 = a[3] / yscale;
981
+
982
+ if (animating) return;
983
+
984
+ var animto = Coords.flipCoords(x1,y1,x2,y2);
985
+ var c = Coords.getFixed();
986
+ var animat = initcr = [ c.x, c.y, c.x2, c.y2 ];
987
+ var interv = options.animationDelay;
988
+
989
+ var x = animat[0];
990
+ var y = animat[1];
991
+ var x2 = animat[2];
992
+ var y2 = animat[3];
993
+ var ix1 = animto[0] - initcr[0];
994
+ var iy1 = animto[1] - initcr[1];
995
+ var ix2 = animto[2] - initcr[2];
996
+ var iy2 = animto[3] - initcr[3];
997
+ var pcent = 0;
998
+ var velocity = options.swingSpeed;
999
+
1000
+ Selection.animMode(true);
1001
+
1002
+ var animator = function()
1003
+ {
1004
+ return function()
1005
+ {
1006
+ pcent += (100 - pcent) / velocity;
1007
+
1008
+ animat[0] = x + ((pcent / 100) * ix1);
1009
+ animat[1] = y + ((pcent / 100) * iy1);
1010
+ animat[2] = x2 + ((pcent / 100) * ix2);
1011
+ animat[3] = y2 + ((pcent / 100) * iy2);
1012
+
1013
+ if (pcent < 100) animateStart();
1014
+ else Selection.done();
1015
+
1016
+ if (pcent >= 99.8) pcent = 100;
1017
+
1018
+ setSelectRaw(animat);
1019
+ };
1020
+ }();
1021
+
1022
+ function animateStart()
1023
+ { window.setTimeout(animator,interv); };
1024
+
1025
+ animateStart();
1026
+ };
1027
+ /*}}}*/
1028
+ function setSelect(rect)//{{{
1029
+ {
1030
+ setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]);
1031
+ };
1032
+ //}}}
1033
+ function setSelectRaw(l) /*{{{*/
1034
+ {
1035
+ Coords.setPressed([l[0],l[1]]);
1036
+ Coords.setCurrent([l[2],l[3]]);
1037
+ Selection.update();
1038
+ };
1039
+ /*}}}*/
1040
+ function setOptions(opt)/*{{{*/
1041
+ {
1042
+ if (typeof(opt) != 'object') opt = { };
1043
+ options = $.extend(options,opt);
1044
+
1045
+ if (typeof(options.onChange)!=='function')
1046
+ options.onChange = function() { };
1047
+
1048
+ if (typeof(options.onSelect)!=='function')
1049
+ options.onSelect = function() { };
1050
+
1051
+ };
1052
+ /*}}}*/
1053
+ function tellSelect()/*{{{*/
1054
+ {
1055
+ return unscale(Coords.getFixed());
1056
+ };
1057
+ /*}}}*/
1058
+ function tellScaled()/*{{{*/
1059
+ {
1060
+ return Coords.getFixed();
1061
+ };
1062
+ /*}}}*/
1063
+ function setOptionsNew(opt)/*{{{*/
1064
+ {
1065
+ setOptions(opt);
1066
+ interfaceUpdate();
1067
+ };
1068
+ /*}}}*/
1069
+ function disableCrop()//{{{
1070
+ {
1071
+ options.disabled = true;
1072
+ Selection.disableHandles();
1073
+ Selection.setCursor('default');
1074
+ Tracker.setCursor('default');
1075
+ };
1076
+ //}}}
1077
+ function enableCrop()//{{{
1078
+ {
1079
+ options.disabled = false;
1080
+ interfaceUpdate();
1081
+ };
1082
+ //}}}
1083
+ function cancelCrop()//{{{
1084
+ {
1085
+ Selection.done();
1086
+ Tracker.activateHandlers(null,null);
1087
+ };
1088
+ //}}}
1089
+ function destroy()//{{{
1090
+ {
1091
+ $div.remove();
1092
+ $origimg.show();
1093
+ };
1094
+ //}}}
1095
+
1096
+ function interfaceUpdate(alt)//{{{
1097
+ // This method tweaks the interface based on options object.
1098
+ // Called when options are changed and at end of initialization.
1099
+ {
1100
+ options.allowResize ?
1101
+ alt?Selection.enableOnly():Selection.enableHandles():
1102
+ Selection.disableHandles();
1103
+
1104
+ Tracker.setCursor( options.allowSelect? 'crosshair': 'default' );
1105
+ Selection.setCursor( options.allowMove? 'move': 'default' );
1106
+
1107
+ $div.css('backgroundColor',options.bgColor);
1108
+
1109
+ if ('setSelect' in options) {
1110
+ setSelect(opt.setSelect);
1111
+ Selection.done();
1112
+ delete(options.setSelect);
1113
+ }
1114
+
1115
+ if ('trueSize' in options) {
1116
+ xscale = options.trueSize[0] / boundx;
1117
+ yscale = options.trueSize[1] / boundy;
1118
+ }
1119
+
1120
+ xlimit = options.maxSize[0] || 0;
1121
+ ylimit = options.maxSize[1] || 0;
1122
+ xmin = options.minSize[0] || 0;
1123
+ ymin = options.minSize[1] || 0;
1124
+
1125
+ if ('outerImage' in options)
1126
+ {
1127
+ $img.attr('src',options.outerImage);
1128
+ delete(options.outerImage);
1129
+ }
1130
+
1131
+ Selection.refresh();
1132
+ };
1133
+ //}}}
1134
+
1135
+ // }}}
1136
+
1137
+ $hdl_holder.hide();
1138
+ interfaceUpdate(true);
1139
+
1140
+ var api = {
1141
+ animateTo: animateTo,
1142
+ setSelect: setSelect,
1143
+ setOptions: setOptionsNew,
1144
+ tellSelect: tellSelect,
1145
+ tellScaled: tellScaled,
1146
+
1147
+ disable: disableCrop,
1148
+ enable: enableCrop,
1149
+ cancel: cancelCrop,
1150
+
1151
+ focus: KeyManager.watchKeys,
1152
+
1153
+ getBounds: function() { return [ boundx * xscale, boundy * yscale ]; },
1154
+ getWidgetSize: function() { return [ boundx, boundy ]; },
1155
+
1156
+ release: Selection.release,
1157
+ destroy: destroy
1158
+
1159
+ };
1160
+
1161
+ $origimg.data('Jcrop',api);
1162
+ return api;
1163
+ };
1164
+
1165
+ $.fn.Jcrop = function(options)/*{{{*/
1166
+ {
1167
+ function attachWhenDone(from)/*{{{*/
1168
+ {
1169
+ var loadsrc = options.useImg || from.src;
1170
+ var img = new Image();
1171
+ img.onload = function() { $.Jcrop(from,options); };
1172
+ img.src = loadsrc;
1173
+ };
1174
+ /*}}}*/
1175
+ if (typeof(options) !== 'object') options = { };
1176
+
1177
+ // Iterate over each object, attach Jcrop
1178
+ this.each(function()
1179
+ {
1180
+ // If we've already attached to this object
1181
+ if ($(this).data('Jcrop'))
1182
+ {
1183
+ // The API can be requested this way (undocumented)
1184
+ if (options == 'api') return $(this).data('Jcrop');
1185
+ // Otherwise, we just reset the options...
1186
+ else $(this).data('Jcrop').setOptions(options);
1187
+ }
1188
+ // If we haven't been attached, preload and attach
1189
+ else attachWhenDone(this);
1190
+ });
1191
+
1192
+ // Return "this" so we're chainable a la jQuery plugin-style!
1193
+ return this;
1194
+ };
1195
+ /*}}}*/
1196
+
1197
+ })(jQuery);
admin/js/jquery.MultiFile.js CHANGED
@@ -1,535 +1,535 @@
1
- /*
2
- ### jQuery Multiple File Upload Plugin v1.46 - 2009-05-12 ###
3
- * Home: http://www.fyneworks.com/jquery/multiple-file-upload/
4
- * Code: http://code.google.com/p/jquery-multifile-plugin/
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- ###
10
- */
11
-
12
- /*# AVOID COLLISIONS #*/
13
- ;if(window.jQuery) (function($){
14
- /*# AVOID COLLISIONS #*/
15
-
16
- // plugin initialization
17
- $.fn.MultiFile = function(options){
18
- if(this.length==0) return this; // quick fail
19
-
20
- // Handle API methods
21
- if(typeof arguments[0]=='string'){
22
- // Perform API methods on individual elements
23
- if(this.length>1){
24
- var args = arguments;
25
- return this.each(function(){
26
- $.fn.MultiFile.apply($(this), args);
27
- });
28
- };
29
- // Invoke API method handler
30
- $.fn.MultiFile[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
31
- // Quick exit...
32
- return this;
33
- };
34
-
35
- // Initialize options for this call
36
- var options = $.extend(
37
- {}/* new object */,
38
- $.fn.MultiFile.options/* default options */,
39
- options || {} /* just-in-time options */
40
- );
41
-
42
- // Empty Element Fix!!!
43
- // this code will automatically intercept native form submissions
44
- // and disable empty file elements
45
- $('form')
46
- .not('MultiFile-intercepted')
47
- .addClass('MultiFile-intercepted')
48
- .submit($.fn.MultiFile.disableEmpty);
49
-
50
- //### http://plugins.jquery.com/node/1363
51
- // utility method to integrate this plugin with others...
52
- if($.fn.MultiFile.options.autoIntercept){
53
- $.fn.MultiFile.intercept( $.fn.MultiFile.options.autoIntercept /* array of methods to intercept */ );
54
- $.fn.MultiFile.options.autoIntercept = null; /* only run this once */
55
- };
56
-
57
- // loop through each matched element
58
- this
59
- .not('.MultiFile-applied')
60
- .addClass('MultiFile-applied')
61
- .each(function(){
62
- //#####################################################################
63
- // MAIN PLUGIN FUNCTIONALITY - START
64
- //#####################################################################
65
-
66
- // BUG 1251 FIX: http://plugins.jquery.com/project/comments/add/1251
67
- // variable group_count would repeat itself on multiple calls to the plugin.
68
- // this would cause a conflict with multiple elements
69
- // changes scope of variable to global so id will be unique over n calls
70
- window.MultiFile = (window.MultiFile || 0) + 1;
71
- var group_count = window.MultiFile;
72
-
73
- // Copy parent attributes - Thanks to Jonas Wagner
74
- // we will use this one to create new input elements
75
- var MultiFile = {e:this, E:$(this), clone:$(this).clone()};
76
-
77
- //===
78
-
79
- //# USE CONFIGURATION
80
- if(typeof options=='number') options = {max:options};
81
- var o = $.extend({},
82
- $.fn.MultiFile.options,
83
- options || {},
84
- ($.metadata? MultiFile.E.metadata(): ($.meta?MultiFile.E.data():null)) || {}, /* metadata options */
85
- {} /* internals */
86
- );
87
- // limit number of files that can be selected?
88
- if(!(o.max>0) /*IsNull(MultiFile.max)*/){
89
- o.max = MultiFile.E.attr('maxlength');
90
- if(!(o.max>0) /*IsNull(MultiFile.max)*/){
91
- o.max = (String(MultiFile.e.className.match(/\b(max|limit)\-([0-9]+)\b/gi) || ['']).match(/[0-9]+/gi) || [''])[0];
92
- if(!(o.max>0)) o.max = -1;
93
- else o.max = String(o.max).match(/[0-9]+/gi)[0];
94
- }
95
- };
96
- o.max = new Number(o.max);
97
- // limit extensions?
98
- o.accept = o.accept || MultiFile.E.attr('accept') || '';
99
- if(!o.accept){
100
- o.accept = (MultiFile.e.className.match(/\b(accept\-[\w\|]+)\b/gi)) || '';
101
- o.accept = new String(o.accept).replace(/^(accept|ext)\-/i,'');
102
- };
103
-
104
- //===
105
-
106
- // APPLY CONFIGURATION
107
- $.extend(MultiFile, o || {});
108
- MultiFile.STRING = $.extend({},$.fn.MultiFile.options.STRING,MultiFile.STRING);
109
-
110
- //===
111
-
112
- //#########################################
113
- // PRIVATE PROPERTIES/METHODS
114
- $.extend(MultiFile, {
115
- n: 0, // How many elements are currently selected?
116
- slaves: [], files: [],
117
- instanceKey: MultiFile.e.id || 'MultiFile'+String(group_count), // Instance Key?
118
- generateID: function(z){ return MultiFile.instanceKey + (z>0 ?'_F'+String(z):''); },
119
- trigger: function(event, element){
120
- var handler = MultiFile[event], value = $(element).attr('value');
121
- if(handler){
122
- var returnValue = handler(element, value, MultiFile);
123
- if( returnValue!=null ) return returnValue;
124
- }
125
- return true;
126
- }
127
- });
128
-
129
- //===
130
-
131
- // Setup dynamic regular expression for extension validation
132
- // - thanks to John-Paul Bader: http://smyck.de/2006/08/11/javascript-dynamic-regular-expresions/
133
- if(String(MultiFile.accept).length>1){
134
- MultiFile.accept = MultiFile.accept.replace(/\W+/g,'|').replace(/^\W|\W$/g,'');
135
- MultiFile.rxAccept = new RegExp('\\.('+(MultiFile.accept?MultiFile.accept:'')+')$','gi');
136
- };
137
-
138
- //===
139
-
140
- // Create wrapper to hold our file list
141
- MultiFile.wrapID = MultiFile.instanceKey+'_wrap'; // Wrapper ID?
142
- MultiFile.E.wrap('<div class="MultiFile-wrap" id="'+MultiFile.wrapID+'"></div>');
143
- MultiFile.wrapper = $('#'+MultiFile.wrapID+'');
144
-
145
- //===
146
-
147
- // MultiFile MUST have a name - default: file1[], file2[], file3[]
148
- MultiFile.e.name = MultiFile.e.name || 'file'+ group_count +'[]';
149
-
150
- //===
151
-
152
- if(!MultiFile.list){
153
- // Create a wrapper for the list
154
- // * OPERA BUG: NO_MODIFICATION_ALLOWED_ERR ('list' is a read-only property)
155
- // this change allows us to keep the files in the order they were selected
156
- MultiFile.wrapper.append( '<div class="MultiFile-list" id="'+MultiFile.wrapID+'_list"></div>' );
157
- MultiFile.list = $('#'+MultiFile.wrapID+'_list');
158
- };
159
- MultiFile.list = $(MultiFile.list);
160
-
161
- //===
162
-
163
- // Bind a new element
164
- MultiFile.addSlave = function( slave, slave_count ){
165
- //if(window.console) console.log('MultiFile.addSlave',slave_count);
166
-
167
- // Keep track of how many elements have been displayed
168
- MultiFile.n++;
169
- // Add reference to master element
170
- slave.MultiFile = MultiFile;
171
-
172
- // BUG FIX: http://plugins.jquery.com/node/1495
173
- // Clear identifying properties from clones
174
- if(slave_count>0) slave.id = slave.name = '';
175
-
176
- // Define element's ID and name (upload components need this!)
177
- //slave.id = slave.id || MultiFile.generateID(slave_count);
178
- if(slave_count>0) slave.id = MultiFile.generateID(slave_count);
179
- //FIX for: http://code.google.com/p/jquery-multifile-plugin/issues/detail?id=23
180
-
181
- // 2008-Apr-29: New customizable naming convention (see url below)
182
- // http://groups.google.com/group/jquery-dev/browse_frm/thread/765c73e41b34f924#
183
- slave.name = String(MultiFile.namePattern
184
- /*master name*/.replace(/\$name/gi,$(MultiFile.clone).attr('name'))
185
- /*master id */.replace(/\$id/gi, $(MultiFile.clone).attr('id'))
186
- /*group count*/.replace(/\$g/gi, group_count)//(group_count>0?group_count:''))
187
- /*slave count*/.replace(/\$i/gi, slave_count)//(slave_count>0?slave_count:''))
188
- );
189
-
190
- // If we've reached maximum number, disable input slave
191
- if( (MultiFile.max > 0) && ((MultiFile.n-1) > (MultiFile.max)) )//{ // MultiFile.n Starts at 1, so subtract 1 to find true count
192
- slave.disabled = true;
193
- //};
194
-
195
- // Remember most recent slave
196
- MultiFile.current = MultiFile.slaves[slave_count] = slave;
197
-
198
- // We'll use jQuery from now on
199
- slave = $(slave);
200
-
201
- // Clear value
202
- slave.val('').attr('value','')[0].value = '';
203
-
204
- // Stop plugin initializing on slaves
205
- slave.addClass('MultiFile-applied');
206
-
207
- // Triggered when a file is selected
208
- slave.change(function(){
209
- //if(window.console) console.log('MultiFile.slave.change',slave_count);
210
-
211
- // Lose focus to stop IE7 firing onchange again
212
- $(this).blur();
213
-
214
- //# Trigger Event! onFileSelect
215
- if(!MultiFile.trigger('onFileSelect', this, MultiFile)) return false;
216
- //# End Event!
217
-
218
- //# Retrive value of selected file from element
219
- var ERROR = '', v = String(this.value || ''/*.attr('value)*/);
220
-
221
- // check extension
222
- if(MultiFile.accept && v && !v.match(MultiFile.rxAccept))//{
223
- ERROR = MultiFile.STRING.denied.replace('$ext', String(v.match(/\.\w{1,4}$/gi)));
224
- //}
225
- //};
226
-
227
- // Disallow duplicates
228
- for(var f in MultiFile.slaves)//{
229
- if(MultiFile.slaves[f] && MultiFile.slaves[f]!=this)//{
230
- //console.log(MultiFile.slaves[f],MultiFile.slaves[f].value);
231
- if(MultiFile.slaves[f].value==v)//{
232
- ERROR = MultiFile.STRING.duplicate.replace('$file', v.match(/[^\/\\]+$/gi));
233
- //};
234
- //};
235
- //};
236
-
237
- // Create a new file input element
238
- var newEle = $(MultiFile.clone).clone();// Copy parent attributes - Thanks to Jonas Wagner
239
- //# Let's remember which input we've generated so
240
- // we can disable the empty ones before submission
241
- // See: http://plugins.jquery.com/node/1495
242
- newEle.addClass('MultiFile');
243
-
244
- // Handle error
245
- if(ERROR!=''){
246
- // Handle error
247
- MultiFile.error(ERROR);
248
-
249
- // 2007-06-24: BUG FIX - Thanks to Adrian Wr�bel <adrian [dot] wrobel [at] gmail.com>
250
- // Ditch the trouble maker and add a fresh new element
251
- MultiFile.n--;
252
- MultiFile.addSlave(newEle[0], slave_count);
253
- slave.parent().prepend(newEle);
254
- slave.remove();
255
- return false;
256
- };
257
-
258
- // Hide this element (NB: display:none is evil!)
259
- $(this).css({ position:'absolute', top: '-3000px' });
260
-
261
- // Add new element to the form
262
- slave.after(newEle);
263
-
264
- // Update list
265
- MultiFile.addToList( this, slave_count );
266
-
267
- // Bind functionality
268
- MultiFile.addSlave( newEle[0], slave_count+1 );
269
-
270
- //# Trigger Event! afterFileSelect
271
- if(!MultiFile.trigger('afterFileSelect', this, MultiFile)) return false;
272
- //# End Event!
273
-
274
- }); // slave.change()
275
-
276
- // Save control to element
277
- $(slave).data('MultiFile', MultiFile);
278
-
279
- };// MultiFile.addSlave
280
- // Bind a new element
281
-
282
-
283
-
284
- // Add a new file to the list
285
- MultiFile.addToList = function( slave, slave_count ){
286
- //if(window.console) console.log('MultiFile.addToList',slave_count);
287
-
288
- //# Trigger Event! onFileAppend
289
- if(!MultiFile.trigger('onFileAppend', slave, MultiFile)) return false;
290
- //# End Event!
291
-
292
- // Create label elements
293
- var
294
- r = $('<div class="MultiFile-label"></div>'),
295
- v = String(slave.value || ''/*.attr('value)*/),
296
- a = $('<span class="MultiFile-title" title="'+MultiFile.STRING.selected.replace('$file', v)+'">'+MultiFile.STRING.file.replace('$file', v.match(/[^\/\\]+$/gi)[0])+'</span>'),
297
- b = $('<a class="MultiFile-remove" href="#'+MultiFile.wrapID+'">'+MultiFile.STRING.remove+'</a>');
298
-
299
- // Insert label
300
- MultiFile.list.append(
301
- r.append(b, ' ', a)
302
- );
303
-
304
- b
305
- .click(function(){
306
-
307
- //# Trigger Event! onFileRemove
308
- if(!MultiFile.trigger('onFileRemove', slave, MultiFile)) return false;
309
- //# End Event!
310
-
311
- MultiFile.n--;
312
- MultiFile.current.disabled = false;
313
-
314
- // Remove element, remove label, point to current
315
- MultiFile.slaves[slave_count] = null;
316
- $(slave).remove();
317
- $(this).parent().remove();
318
-
319
- // Show most current element again (move into view) and clear selection
320
- $(MultiFile.current).css({ position:'', top: '' });
321
- $(MultiFile.current).reset().val('').attr('value', '')[0].value = '';
322
-
323
- //# Trigger Event! afterFileRemove
324
- if(!MultiFile.trigger('afterFileRemove', slave, MultiFile)) return false;
325
- //# End Event!
326
-
327
- return false;
328
- });
329
-
330
- //# Trigger Event! afterFileAppend
331
- if(!MultiFile.trigger('afterFileAppend', slave, MultiFile)) return false;
332
- //# End Event!
333
-
334
- }; // MultiFile.addToList
335
- // Add element to selected files list
336
-
337
-
338
-
339
- // Bind functionality to the first element
340
- if(!MultiFile.MultiFile) MultiFile.addSlave(MultiFile.e, 0);
341
-
342
- // Increment control count
343
- //MultiFile.I++; // using window.MultiFile
344
- MultiFile.n++;
345
-
346
- // Save control to element
347
- MultiFile.E.data('MultiFile', MultiFile);
348
-
349
-
350
- //#####################################################################
351
- // MAIN PLUGIN FUNCTIONALITY - END
352
- //#####################################################################
353
- }); // each element
354
- };
355
-
356
- /*--------------------------------------------------------*/
357
-
358
- /*
359
- ### Core functionality and API ###
360
- */
361
- $.extend($.fn.MultiFile, {
362
- /**
363
- * This method removes all selected files
364
- *
365
- * Returns a jQuery collection of all affected elements.
366
- *
367
- * @name reset
368
- * @type jQuery
369
- * @cat Plugins/MultiFile
370
- * @author Diego A. (http://www.fyneworks.com/)
371
- *
372
- * @example $.fn.MultiFile.reset();
373
- */
374
- reset: function(){
375
- var settings = $(this).data('MultiFile');
376
- //if(settings) settings.wrapper.find('a.MultiFile-remove').click();
377
- if(settings) settings.list.find('a.MultiFile-remove').click();
378
- return $(this);
379
- },
380
-
381
-
382
- /**
383
- * This utility makes it easy to disable all 'empty' file elements in the document before submitting a form.
384
- * It marks the affected elements so they can be easily re-enabled after the form submission or validation.
385
- *
386
- * Returns a jQuery collection of all affected elements.
387
- *
388
- * @name disableEmpty
389
- * @type jQuery
390
- * @cat Plugins/MultiFile
391
- * @author Diego A. (http://www.fyneworks.com/)
392
- *
393
- * @example $.fn.MultiFile.disableEmpty();
394
- * @param String class (optional) A string specifying a class to be applied to all affected elements - Default: 'mfD'.
395
- */
396
- disableEmpty: function(klass){ klass = (typeof(klass)=='string'?klass:'')||'mfD';
397
- var o = [];
398
- $('input:file.MultiFile').each(function(){ if($(this).val()=='') o[o.length] = this; });
399
- return $(o).each(function(){ this.disabled = true }).addClass(klass);
400
- },
401
-
402
-
403
- /**
404
- * This method re-enables 'empty' file elements that were disabled (and marked) with the $.fn.MultiFile.disableEmpty method.
405
- *
406
- * Returns a jQuery collection of all affected elements.
407
- *
408
- * @name reEnableEmpty
409
- * @type jQuery
410
- * @cat Plugins/MultiFile
411
- * @author Diego A. (http://www.fyneworks.com/)
412
- *
413
- * @example $.fn.MultiFile.reEnableEmpty();
414
- * @param String klass (optional) A string specifying the class that was used to mark affected elements - Default: 'mfD'.
415
- */
416
- reEnableEmpty: function(klass){ klass = (typeof(klass)=='string'?klass:'')||'mfD';
417
- return $('input:file.'+klass).removeClass(klass).each(function(){ this.disabled = false });
418
- },
419
-
420
-
421
- /**
422
- * This method will intercept other jQuery plugins and disable empty file input elements prior to form submission
423
- *
424
-
425
- * @name intercept
426
- * @cat Plugins/MultiFile
427
- * @author Diego A. (http://www.fyneworks.com/)
428
- *
429
- * @example $.fn.MultiFile.intercept();
430
- * @param Array methods (optional) Array of method names to be intercepted
431
- */
432
- intercepted: {},
433
- intercept: function(methods, context, args){
434
- var method, value; args = args || [];
435
- if(args.constructor.toString().indexOf("Array")<0) args = [ args ];
436
- if(typeof(methods)=='function'){
437
- $.fn.MultiFile.disableEmpty();
438
- value = methods.apply(context || window, args);
439
- //SEE-http://code.google.com/p/jquery-multifile-plugin/issues/detail?id=27
440
- setTimeout(function(){ $.fn.MultiFile.reEnableEmpty() },1000);
441
- return value;
442
- };
443
- if(methods.constructor.toString().indexOf("Array")<0) methods = [methods];
444
- for(var i=0;i<methods.length;i++){
445
- method = methods[i]+''; // make sure that we have a STRING
446
- if(method) (function(method){ // make sure that method is ISOLATED for the interception
447
- $.fn.MultiFile.intercepted[method] = $.fn[method] || function(){};
448
- $.fn[method] = function(){
449
- $.fn.MultiFile.disableEmpty();
450
- value = $.fn.MultiFile.intercepted[method].apply(this, arguments);
451
- //SEE-http://code.google.com/p/jquery-multifile-plugin/issues/detail?id=27
452
- setTimeout(function(){ $.fn.MultiFile.reEnableEmpty() },1000);
453
- return value;
454
- }; // interception
455
- })(method); // MAKE SURE THAT method IS ISOLATED for the interception
456
- };// for each method
457
- }
458
- });
459
-
460
- /*--------------------------------------------------------*/
461
-
462
- /*
463
- ### Default Settings ###
464
- eg.: You can override default control like this:
465
- $.fn.MultiFile.options.accept = 'gif|jpg';
466
- */
467
- $.fn.MultiFile.options = { //$.extend($.fn.MultiFile, { options: {
468
- accept: '', // accepted file extensions
469
- max: -1, // maximum number of selectable files
470
-
471
- // name to use for newly created elements
472
- namePattern: '$name', // same name by default (which creates an array)
473
-
474
- // STRING: collection lets you show messages in different languages
475
- STRING: {
476
- remove:'x',
477
- denied:'You cannot select a $ext file.\nTry again...',
478
- file:'$file',
479
- selected:'File selected: $file',
480
- duplicate:'This file has already been selected:\n$file'
481
- },
482
-
483
- // name of methods that should be automcatically intercepted so the plugin can disable
484
- // extra file elements that are empty before execution and automatically re-enable them afterwards
485
- autoIntercept: [ 'submit', 'ajaxSubmit', 'ajaxForm', 'validate' /* array of methods to intercept */ ],
486
-
487
- // error handling function
488
- error: function(s){
489
- /*
490
- ERROR! blockUI is not currently working in IE
491
- if($.blockUI){
492
- $.blockUI({
493
- message: s.replace(/\n/gi,'<br/>'),
494
- css: {
495
- border:'none', padding:'15px', size:'12.0pt',
496
- backgroundColor:'#900', color:'#fff',
497
- opacity:'.8','-webkit-border-radius': '10px','-moz-border-radius': '10px'
498
- }
499
- });
500
- window.setTimeout($.unblockUI, 2000);
501
- }
502
- else//{// save a byte!
503
- */
504
- alert(s);
505
- //}// save a byte!
506
- }
507
- }; //} });
508
-
509
- /*--------------------------------------------------------*/
510
-
511
- /*
512
- ### Additional Methods ###
513
- Required functionality outside the plugin's scope
514
- */
515
-
516
- // Native input reset method - because this alone doesn't always work: $(element).val('').attr('value', '')[0].value = '';
517
- $.fn.reset = function(){ return this.each(function(){ try{ this.reset(); }catch(e){} }); };
518
-
519
- /*--------------------------------------------------------*/
520
-
521
- /*
522
- ### Default implementation ###
523
- The plugin will attach itself to file inputs
524
- with the class 'multi' when the page loads
525
- */
526
- $(function(){
527
- //$("input:file.multi").MultiFile();
528
- $("input[type=file].multi").MultiFile();
529
- });
530
-
531
-
532
-
533
- /*# AVOID COLLISIONS #*/
534
- })(jQuery);
535
- /*# AVOID COLLISIONS #*/
1
+ /*
2
+ ### jQuery Multiple File Upload Plugin v1.46 - 2009-05-12 ###
3
+ * Home: http://www.fyneworks.com/jquery/multiple-file-upload/
4
+ * Code: http://code.google.com/p/jquery-multifile-plugin/
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ ###
10
+ */
11
+
12
+ /*# AVOID COLLISIONS #*/
13
+ ;if(window.jQuery) (function($){
14
+ /*# AVOID COLLISIONS #*/
15
+
16
+ // plugin initialization
17
+ $.fn.MultiFile = function(options){
18
+ if(this.length==0) return this; // quick fail
19
+
20
+ // Handle API methods
21
+ if(typeof arguments[0]=='string'){
22
+ // Perform API methods on individual elements
23
+ if(this.length>1){
24
+ var args = arguments;
25
+ return this.each(function(){
26
+ $.fn.MultiFile.apply($(this), args);
27
+ });
28
+ };
29
+ // Invoke API method handler
30
+ $.fn.MultiFile[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
31
+ // Quick exit...
32
+ return this;
33
+ };
34
+
35
+ // Initialize options for this call
36
+ var options = $.extend(
37
+ {}/* new object */,
38
+ $.fn.MultiFile.options/* default options */,
39
+ options || {} /* just-in-time options */
40
+ );
41
+
42
+ // Empty Element Fix!!!
43
+ // this code will automatically intercept native form submissions
44
+ // and disable empty file elements
45
+ $('form')
46
+ .not('MultiFile-intercepted')
47
+ .addClass('MultiFile-intercepted')
48
+ .submit($.fn.MultiFile.disableEmpty);
49
+
50
+ //### http://plugins.jquery.com/node/1363
51
+ // utility method to integrate this plugin with others...
52
+ if($.fn.MultiFile.options.autoIntercept){
53
+ $.fn.MultiFile.intercept( $.fn.MultiFile.options.autoIntercept /* array of methods to intercept */ );
54
+ $.fn.MultiFile.options.autoIntercept = null; /* only run this once */
55
+ };
56
+
57
+ // loop through each matched element
58
+ this
59
+ .not('.MultiFile-applied')
60
+ .addClass('MultiFile-applied')
61
+ .each(function(){
62
+ //#####################################################################
63
+ // MAIN PLUGIN FUNCTIONALITY - START
64
+ //#####################################################################
65
+
66
+ // BUG 1251 FIX: http://plugins.jquery.com/project/comments/add/1251
67
+ // variable group_count would repeat itself on multiple calls to the plugin.
68
+ // this would cause a conflict with multiple elements
69
+ // changes scope of variable to global so id will be unique over n calls
70
+ window.MultiFile = (window.MultiFile || 0) + 1;
71
+ var group_count = window.MultiFile;
72
+
73
+ // Copy parent attributes - Thanks to Jonas Wagner
74
+ // we will use this one to create new input elements
75
+ var MultiFile = {e:this, E:$(this), clone:$(this).clone()};
76
+
77
+ //===
78
+
79
+ //# USE CONFIGURATION
80
+ if(typeof options=='number') options = {max:options};
81
+ var o = $.extend({},
82
+ $.fn.MultiFile.options,
83
+ options || {},
84
+ ($.metadata? MultiFile.E.metadata(): ($.meta?MultiFile.E.data():null)) || {}, /* metadata options */
85
+ {} /* internals */
86
+ );
87
+ // limit number of files that can be selected?
88
+ if(!(o.max>0) /*IsNull(MultiFile.max)*/){
89
+ o.max = MultiFile.E.attr('maxlength');
90
+ if(!(o.max>0) /*IsNull(MultiFile.max)*/){
91
+ o.max = (String(MultiFile.e.className.match(/\b(max|limit)\-([0-9]+)\b/gi) || ['']).match(/[0-9]+/gi) || [''])[0];
92
+ if(!(o.max>0)) o.max = -1;
93
+ else o.max = String(o.max).match(/[0-9]+/gi)[0];
94
+ }
95
+ };
96
+ o.max = new Number(o.max);
97
+ // limit extensions?
98
+ o.accept = o.accept || MultiFile.E.attr('accept') || '';
99
+ if(!o.accept){
100
+ o.accept = (MultiFile.e.className.match(/\b(accept\-[\w\|]+)\b/gi)) || '';
101
+ o.accept = new String(o.accept).replace(/^(accept|ext)\-/i,'');
102
+ };
103
+
104
+ //===
105
+
106
+ // APPLY CONFIGURATION
107
+ $.extend(MultiFile, o || {});
108
+ MultiFile.STRING = $.extend({},$.fn.MultiFile.options.STRING,MultiFile.STRING);
109
+
110
+ //===
111
+
112
+ //#########################################
113
+ // PRIVATE PROPERTIES/METHODS
114
+ $.extend(MultiFile, {
115
+ n: 0, // How many elements are currently selected?
116
+ slaves: [], files: [],
117
+ instanceKey: MultiFile.e.id || 'MultiFile'+String(group_count), // Instance Key?
118
+ generateID: function(z){ return MultiFile.instanceKey + (z>0 ?'_F'+String(z):''); },
119
+ trigger: function(event, element){
120
+ var handler = MultiFile[event], value = $(element).attr('value');
121
+ if(handler){
122
+ var returnValue = handler(element, value, MultiFile);
123
+ if( returnValue!=null ) return returnValue;
124
+ }
125
+ return true;
126
+ }
127
+ });
128
+
129
+ //===
130
+
131
+ // Setup dynamic regular expression for extension validation
132
+ // - thanks to John-Paul Bader: http://smyck.de/2006/08/11/javascript-dynamic-regular-expresions/
133
+ if(String(MultiFile.accept).length>1){
134
+ MultiFile.accept = MultiFile.accept.replace(/\W+/g,'|').replace(/^\W|\W$/g,'');
135
+ MultiFile.rxAccept = new RegExp('\\.('+(MultiFile.accept?MultiFile.accept:'')+')$','gi');
136
+ };
137
+
138
+ //===
139
+
140
+ // Create wrapper to hold our file list
141
+ MultiFile.wrapID = MultiFile.instanceKey+'_wrap'; // Wrapper ID?
142
+ MultiFile.E.wrap('<div class="MultiFile-wrap" id="'+MultiFile.wrapID+'"></div>');
143
+ MultiFile.wrapper = $('#'+MultiFile.wrapID+'');
144
+
145
+ //===
146
+
147
+ // MultiFile MUST have a name - default: file1[], file2[], file3[]
148
+ MultiFile.e.name = MultiFile.e.name || 'file'+ group_count +'[]';
149
+
150
+ //===
151
+
152
+ if(!MultiFile.list){
153
+ // Create a wrapper for the list
154
+ // * OPERA BUG: NO_MODIFICATION_ALLOWED_ERR ('list' is a read-only property)
155
+ // this change allows us to keep the files in the order they were selected
156
+ MultiFile.wrapper.append( '<div class="MultiFile-list" id="'+MultiFile.wrapID+'_list"></div>' );
157
+ MultiFile.list = $('#'+MultiFile.wrapID+'_list');
158
+ };
159
+ MultiFile.list = $(MultiFile.list);
160
+
161
+ //===
162
+
163
+ // Bind a new element
164
+ MultiFile.addSlave = function( slave, slave_count ){
165
+ //if(window.console) console.log('MultiFile.addSlave',slave_count);
166
+
167
+ // Keep track of how many elements have been displayed
168
+ MultiFile.n++;
169
+ // Add reference to master element
170
+ slave.MultiFile = MultiFile;
171
+
172
+ // BUG FIX: http://plugins.jquery.com/node/1495
173
+ // Clear identifying properties from clones
174
+ if(slave_count>0) slave.id = slave.name = '';
175
+
176
+ // Define element's ID and name (upload components need this!)
177
+ //slave.id = slave.id || MultiFile.generateID(slave_count);
178
+ if(slave_count>0) slave.id = MultiFile.generateID(slave_count);
179
+ //FIX for: http://code.google.com/p/jquery-multifile-plugin/issues/detail?id=23
180
+
181
+ // 2008-Apr-29: New customizable naming convention (see url below)
182
+ // http://groups.google.com/group/jquery-dev/browse_frm/thread/765c73e41b34f924#
183
+ slave.name = String(MultiFile.namePattern
184
+ /*master name*/.replace(/\$name/gi,$(MultiFile.clone).attr('name'))
185
+ /*master id */.replace(/\$id/gi, $(MultiFile.clone).attr('id'))
186
+ /*group count*/.replace(/\$g/gi, group_count)//(group_count>0?group_count:''))
187
+ /*slave count*/.replace(/\$i/gi, slave_count)//(slave_count>0?slave_count:''))
188
+ );
189
+
190
+ // If we've reached maximum number, disable input slave
191
+ if( (MultiFile.max > 0) && ((MultiFile.n-1) > (MultiFile.max)) )//{ // MultiFile.n Starts at 1, so subtract 1 to find true count
192
+ slave.disabled = true;
193
+ //};
194
+
195
+ // Remember most recent slave
196
+ MultiFile.current = MultiFile.slaves[slave_count] = slave;
197
+
198
+ // We'll use jQuery from now on
199
+ slave = $(slave);
200
+
201
+ // Clear value
202
+ slave.val('').attr('value','')[0].value = '';
203
+
204
+ // Stop plugin initializing on slaves
205
+ slave.addClass('MultiFile-applied');
206
+
207
+ // Triggered when a file is selected
208
+ slave.change(function(){
209
+ //if(window.console) console.log('MultiFile.slave.change',slave_count);
210
+
211
+ // Lose focus to stop IE7 firing onchange again
212
+ $(this).blur();
213
+
214
+ //# Trigger Event! onFileSelect
215
+ if(!MultiFile.trigger('onFileSelect', this, MultiFile)) return false;
216
+ //# End Event!
217
+
218
+ //# Retrive value of selected file from element
219
+ var ERROR = '', v = String(this.value || ''/*.attr('value)*/);
220
+
221
+ // check extension
222
+ if(MultiFile.accept && v && !v.match(MultiFile.rxAccept))//{
223
+ ERROR = MultiFile.STRING.denied.replace('$ext', String(v.match(/\.\w{1,4}$/gi)));
224
+ //}
225
+ //};
226
+
227
+ // Disallow duplicates
228
+ for(var f in MultiFile.slaves)//{
229
+ if(MultiFile.slaves[f] && MultiFile.slaves[f]!=this)//{
230
+ //console.log(MultiFile.slaves[f],MultiFile.slaves[f].value);
231
+ if(MultiFile.slaves[f].value==v)//{
232
+ ERROR = MultiFile.STRING.duplicate.replace('$file', v.match(/[^\/\\]+$/gi));
233
+ //};
234
+ //};
235
+ //};
236
+
237
+ // Create a new file input element
238
+ var newEle = $(MultiFile.clone).clone();// Copy parent attributes - Thanks to Jonas Wagner
239
+ //# Let's remember which input we've generated so
240
+ // we can disable the empty ones before submission
241
+ // See: http://plugins.jquery.com/node/1495
242
+ newEle.addClass('MultiFile');
243
+
244
+ // Handle error
245
+ if(ERROR!=''){
246
+ // Handle error
247
+ MultiFile.error(ERROR);
248
+
249
+ // 2007-06-24: BUG FIX - Thanks to Adrian Wr�bel <adrian [dot] wrobel [at] gmail.com>
250
+ // Ditch the trouble maker and add a fresh new element
251
+ MultiFile.n--;
252
+ MultiFile.addSlave(newEle[0], slave_count);
253
+ slave.parent().prepend(newEle);
254
+ slave.remove();
255
+ return false;
256
+ };
257
+
258
+ // Hide this element (NB: display:none is evil!)
259
+ $(this).css({ position:'absolute', top: '-3000px' });
260
+
261
+ // Add new element to the form
262
+ slave.after(newEle);
263
+
264
+ // Update list
265
+ MultiFile.addToList( this, slave_count );
266
+
267
+ // Bind functionality
268
+ MultiFile.addSlave( newEle[0], slave_count+1 );
269
+
270
+ //# Trigger Event! afterFileSelect
271
+ if(!MultiFile.trigger('afterFileSelect', this, MultiFile)) return false;
272
+ //# End Event!
273
+
274
+ }); // slave.change()
275
+
276
+ // Save control to element
277
+ $(slave).data('MultiFile', MultiFile);
278
+
279
+ };// MultiFile.addSlave
280
+ // Bind a new element
281
+
282
+
283
+
284
+ // Add a new file to the list
285
+ MultiFile.addToList = function( slave, slave_count ){
286
+ //if(window.console) console.log('MultiFile.addToList',slave_count);
287
+
288
+ //# Trigger Event! onFileAppend
289
+ if(!MultiFile.trigger('onFileAppend', slave, MultiFile)) return false;
290
+ //# End Event!
291
+
292
+ // Create label elements
293
+ var
294
+ r = $('<div class="MultiFile-label"></div>'),
295
+ v = String(slave.value || ''/*.attr('value)*/),
296
+ a = $('<span class="MultiFile-title" title="'+MultiFile.STRING.selected.replace('$file', v)+'">'+MultiFile.STRING.file.replace('$file', v.match(/[^\/\\]+$/gi)[0])+'</span>'),
297
+ b = $('<a class="MultiFile-remove" href="#'+MultiFile.wrapID+'">'+MultiFile.STRING.remove+'</a>');
298
+
299
+ // Insert label
300
+ MultiFile.list.append(
301
+ r.append(b, ' ', a)
302
+ );
303
+
304
+ b
305
+ .click(function(){
306
+
307
+ //# Trigger Event! onFileRemove
308
+ if(!MultiFile.trigger('onFileRemove', slave, MultiFile)) return false;
309
+ //# End Event!
310
+
311
+ MultiFile.n--;
312
+ MultiFile.current.disabled = false;
313
+
314
+ // Remove element, remove label, point to current
315
+ MultiFile.slaves[slave_count] = null;
316
+ $(slave).remove();
317
+ $(this).parent().remove();
318
+
319
+ // Show most current element again (move into view) and clear selection
320
+ $(MultiFile.current).css({ position:'', top: '' });
321
+ $(MultiFile.current).reset().val('').attr('value', '')[0].value = '';
322
+
323
+ //# Trigger Event! afterFileRemove
324
+ if(!MultiFile.trigger('afterFileRemove', slave, MultiFile)) return false;
325
+ //# End Event!
326
+
327
+ return false;
328
+ });
329
+
330
+ //# Trigger Event! afterFileAppend
331
+ if(!MultiFile.trigger('afterFileAppend', slave, MultiFile)) return false;
332
+ //# End Event!
333
+
334
+ }; // MultiFile.addToList
335
+ // Add element to selected files list
336
+
337
+
338
+
339
+ // Bind functionality to the first element
340
+ if(!MultiFile.MultiFile) MultiFile.addSlave(MultiFile.e, 0);
341
+
342
+ // Increment control count
343
+ //MultiFile.I++; // using window.MultiFile
344
+ MultiFile.n++;
345
+
346
+ // Save control to element
347
+ MultiFile.E.data('MultiFile', MultiFile);
348
+
349
+
350
+ //#####################################################################
351
+ // MAIN PLUGIN FUNCTIONALITY - END
352
+ //#####################################################################
353
+ }); // each element
354
+ };
355
+
356
+ /*--------------------------------------------------------*/
357
+
358
+ /*
359
+ ### Core functionality and API ###
360
+ */
361
+ $.extend($.fn.MultiFile, {
362
+ /**
363
+ * This method removes all selected files
364
+ *
365
+ * Returns a jQuery collection of all affected elements.
366
+ *
367
+ * @name reset
368
+ * @type jQuery
369
+ * @cat Plugins/MultiFile
370
+ * @author Diego A. (http://www.fyneworks.com/)
371
+ *
372
+ * @example $.fn.MultiFile.reset();
373
+ */
374
+ reset: function(){
375
+ var settings = $(this).data('MultiFile');
376
+ //if(settings) settings.wrapper.find('a.MultiFile-remove').click();
377
+ if(settings) settings.list.find('a.MultiFile-remove').click();
378
+ return $(this);
379
+ },
380
+
381
+
382
+ /**
383
+ * This utility makes it easy to disable all 'empty' file elements in the document before submitting a form.
384
+ * It marks the affected elements so they can be easily re-enabled after the form submission or validation.
385
+ *
386
+ * Returns a jQuery collection of all affected elements.
387
+ *
388
+ * @name disableEmpty
389
+ * @type jQuery
390
+ * @cat Plugins/MultiFile
391
+ * @author Diego A. (http://www.fyneworks.com/)
392
+ *
393
+ * @example $.fn.MultiFile.disableEmpty();
394
+ * @param String class (optional) A string specifying a class to be applied to all affected elements - Default: 'mfD'.
395
+ */
396
+ disableEmpty: function(klass){ klass = (typeof(klass)=='string'?klass:'')||'mfD';
397
+ var o = [];
398
+ $('input:file.MultiFile').each(function(){ if($(this).val()=='') o[o.length] = this; });
399
+ return $(o).each(function(){ this.disabled = true }).addClass(klass);
400
+ },
401
+
402
+
403
+ /**
404
+ * This method re-enables 'empty' file elements that were disabled (and marked) with the $.fn.MultiFile.disableEmpty method.
405
+ *
406
+ * Returns a jQuery collection of all affected elements.
407
+ *
408
+ * @name reEnableEmpty
409
+ * @type jQuery
410
+ * @cat Plugins/MultiFile
411
+ * @author Diego A. (http://www.fyneworks.com/)
412
+ *
413
+ * @example $.fn.MultiFile.reEnableEmpty();
414
+ * @param String klass (optional) A string specifying the class that was used to mark affected elements - Default: 'mfD'.
415
+ */
416
+ reEnableEmpty: function(klass){ klass = (typeof(klass)=='string'?klass:'')||'mfD';
417
+ return $('input:file.'+klass).removeClass(klass).each(function(){ this.disabled = false });
418
+ },
419
+
420
+
421
+ /**
422
+ * This method will intercept other jQuery plugins and disable empty file input elements prior to form submission
423
+ *
424
+
425
+ * @name intercept
426
+ * @cat Plugins/MultiFile
427
+ * @author Diego A. (http://www.fyneworks.com/)
428
+ *
429
+ * @example $.fn.MultiFile.intercept();
430
+ * @param Array methods (optional) Array of method names to be intercepted
431
+ */
432
+ intercepted: {},
433
+ intercept: function(methods, context, args){
434
+ var method, value; args = args || [];
435
+ if(args.constructor.toString().indexOf("Array")<0) args = [ args ];
436
+ if(typeof(methods)=='function'){
437
+ $.fn.MultiFile.disableEmpty();
438
+ value = methods.apply(context || window, args);
439
+ //SEE-http://code.google.com/p/jquery-multifile-plugin/issues/detail?id=27
440
+ setTimeout(function(){ $.fn.MultiFile.reEnableEmpty() },1000);
441
+ return value;
442
+ };
443
+ if(methods.constructor.toString().indexOf("Array")<0) methods = [methods];
444
+ for(var i=0;i<methods.length;i++){
445
+ method = methods[i]+''; // make sure that we have a STRING
446
+ if(method) (function(method){ // make sure that method is ISOLATED for the interception
447
+ $.fn.MultiFile.intercepted[method] = $.fn[method] || function(){};
448
+ $.fn[method] = function(){
449
+ $.fn.MultiFile.disableEmpty();
450
+ value = $.fn.MultiFile.intercepted[method].apply(this, arguments);
451
+ //SEE-http://code.google.com/p/jquery-multifile-plugin/issues/detail?id=27
452
+ setTimeout(function(){ $.fn.MultiFile.reEnableEmpty() },1000);
453
+ return value;
454
+ }; // interception
455
+ })(method); // MAKE SURE THAT method IS ISOLATED for the interception
456
+ };// for each method
457
+ }
458
+ });
459
+
460
+ /*--------------------------------------------------------*/
461
+
462
+ /*
463
+ ### Default Settings ###
464
+ eg.: You can override default control like this:
465
+ $.fn.MultiFile.options.accept = 'gif|jpg';
466
+ */
467
+ $.fn.MultiFile.options = { //$.extend($.fn.MultiFile, { options: {
468
+ accept: '', // accepted file extensions
469
+ max: -1, // maximum number of selectable files
470
+
471
+ // name to use for newly created elements
472
+ namePattern: '$name', // same name by default (which creates an array)
473
+
474
+ // STRING: collection lets you show messages in different languages
475
+ STRING: {
476
+ remove:'x',
477
+ denied:'You cannot select a $ext file.\nTry again...',
478
+ file:'$file',
479
+ selected:'File selected: $file',
480
+ duplicate:'This file has already been selected:\n$file'
481
+ },
482
+
483
+ // name of methods that should be automcatically intercepted so the plugin can disable
484
+ // extra file elements that are empty before execution and automatically re-enable them afterwards
485
+ autoIntercept: [ 'submit', 'ajaxSubmit', 'ajaxForm', 'validate' /* array of methods to intercept */ ],
486
+
487
+ // error handling function
488
+ error: function(s){
489
+ /*
490
+ ERROR! blockUI is not currently working in IE
491
+ if($.blockUI){
492
+ $.blockUI({
493
+ message: s.replace(/\n/gi,'<br/>'),
494
+ css: {
495
+ border:'none', padding:'15px', size:'12.0pt',
496
+ backgroundColor:'#900', color:'#fff',
497
+ opacity:'.8','-webkit-border-radius': '10px','-moz-border-radius': '10px'
498
+ }
499
+ });
500
+ window.setTimeout($.unblockUI, 2000);
501
+ }
502
+ else//{// save a byte!
503
+ */
504
+ alert(s);
505
+ //}// save a byte!
506
+ }
507
+ }; //} });
508
+
509
+ /*--------------------------------------------------------*/
510
+
511
+ /*
512
+ ### Additional Methods ###
513
+ Required functionality outside the plugin's scope
514
+ */
515
+
516
+ // Native input reset method - because this alone doesn't always work: $(element).val('').attr('value', '')[0].value = '';
517
+ $.fn.reset = function(){ return this.each(function(){ try{ this.reset(); }catch(e){} }); };
518
+
519
+ /*--------------------------------------------------------*/
520
+
521
+ /*
522
+ ### Default implementation ###
523
+ The plugin will attach itself to file inputs
524
+ with the class 'multi' when the page loads
525
+ */
526
+ $(function(){
527
+ //$("input:file.multi").MultiFile();
528
+ $("input[type=file].multi").MultiFile();
529
+ });
530
+
531
+
532
+
533
+ /*# AVOID COLLISIONS #*/
534
+ })(jQuery);
535
+ /*# AVOID COLLISIONS #*/
admin/js/jquery.MultiFile.pack.js CHANGED
@@ -1,11 +1,11 @@
1
- /*
2
- ### jQuery Multiple File Upload Plugin v1.46 - 2009-05-12 ###
3
- * Home: http://www.fyneworks.com/jquery/multiple-file-upload/
4
- * Code: http://code.google.com/p/jquery-multifile-plugin/
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- ###
10
- */
11
  eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';3(U.1u)(6($){$.7.2=6(h){3(5.V==0)8 5;3(T S[0]==\'19\'){3(5.V>1){m i=S;8 5.M(6(){$.7.2.13($(5),i)})};$.7.2[S[0]].13(5,$.1N(S).27(1)||[]);8 5};m h=$.N({},$.7.2.F,h||{});$(\'2d\').1B(\'2-R\').Q(\'2-R\').1n($.7.2.Z);3($.7.2.F.15){$.7.2.1M($.7.2.F.15);$.7.2.F.15=10};5.1B(\'.2-1e\').Q(\'2-1e\').M(6(){U.2=(U.2||0)+1;m e=U.2;m g={e:5,E:$(5),L:$(5).L()};3(T h==\'21\')h={l:h};m o=$.N({},$.7.2.F,h||{},($.1m?g.E.1m():($.1S?g.E.17():10))||{},{});3(!(o.l>0)){o.l=g.E.D(\'28\');3(!(o.l>0)){o.l=(u(g.e.1D.B(/\\b(l|23)\\-([0-9]+)\\b/q)||[\'\']).B(/[0-9]+/q)||[\'\'])[0];3(!(o.l>0))o.l=-1;2b o.l=u(o.l).B(/[0-9]+/q)[0]}};o.l=18 2f(o.l);o.j=o.j||g.E.D(\'j\')||\'\';3(!o.j){o.j=(g.e.1D.B(/\\b(j\\-[\\w\\|]+)\\b/q))||\'\';o.j=18 u(o.j).t(/^(j|1d)\\-/i,\'\')};$.N(g,o||{});g.A=$.N({},$.7.2.F.A,g.A);$.N(g,{n:0,J:[],2c:[],1c:g.e.I||\'2\'+u(e),1i:6(z){8 g.1c+(z>0?\'1Z\'+u(z):\'\')},G:6(a,b){m c=g[a],k=$(b).D(\'k\');3(c){m d=c(b,k,g);3(d!=10)8 d}8 1a}});3(u(g.j).V>1){g.j=g.j.t(/\\W+/g,\'|\').t(/^\\W|\\W$/g,\'\');g.1k=18 2t(\'\\\\.(\'+(g.j?g.j:\'\')+\')$\',\'q\')};g.O=g.1c+\'1P\';g.E.1l(\'<P X="2-1l" I="\'+g.O+\'"></P>\');g.1q=$(\'#\'+g.O+\'\');g.e.H=g.e.H||\'p\'+e+\'[]\';3(!g.K){g.1q.1g(\'<P X="2-K" I="\'+g.O+\'1F"></P>\');g.K=$(\'#\'+g.O+\'1F\')};g.K=$(g.K);g.16=6(c,d){g.n++;c.2=g;3(d>0)c.I=c.H=\'\';3(d>0)c.I=g.1i(d);c.H=u(g.1j.t(/\\$H/q,$(g.L).D(\'H\')).t(/\\$I/q,$(g.L).D(\'I\')).t(/\\$g/q,e).t(/\\$i/q,d));3((g.l>0)&&((g.n-1)>(g.l)))c.14=1a;g.Y=g.J[d]=c;c=$(c);c.1b(\'\').D(\'k\',\'\')[0].k=\'\';c.Q(\'2-1e\');c.1V(6(){$(5).1X();3(!g.G(\'1Y\',5,g))8 y;m a=\'\',v=u(5.k||\'\');3(g.j&&v&&!v.B(g.1k))a=g.A.1o.t(\'$1d\',u(v.B(/\\.\\w{1,4}$/q)));1p(m f 2a g.J)3(g.J[f]&&g.J[f]!=5)3(g.J[f].k==v)a=g.A.1r.t(\'$p\',v.B(/[^\\/\\\\]+$/q));m b=$(g.L).L();b.Q(\'2\');3(a!=\'\'){g.1s(a);g.n--;g.16(b[0],d);c.1t().2e(b);c.C();8 y};$(5).1v({1w:\'1O\',1x:\'-1Q\'});c.1R(b);g.1y(5,d);g.16(b[0],d+1);3(!g.G(\'1T\',5,g))8 y});$(c).17(\'2\',g)};g.1y=6(c,d){3(!g.G(\'1U\',c,g))8 y;m r=$(\'<P X="2-1W"></P>\'),v=u(c.k||\'\'),a=$(\'<1z X="2-1A" 1A="\'+g.A.12.t(\'$p\',v)+\'">\'+g.A.p.t(\'$p\',v.B(/[^\\/\\\\]+$/q)[0])+\'</1z>\'),b=$(\'<a X="2-C" 2y="#\'+g.O+\'">\'+g.A.C+\'</a>\');g.K.1g(r.1g(b,\' \',a));b.1C(6(){3(!g.G(\'22\',c,g))8 y;g.n--;g.Y.14=y;g.J[d]=10;$(c).C();$(5).1t().C();$(g.Y).1v({1w:\'\',1x:\'\'});$(g.Y).11().1b(\'\').D(\'k\',\'\')[0].k=\'\';3(!g.G(\'24\',c,g))8 y;8 y});3(!g.G(\'25\',c,g))8 y};3(!g.2)g.16(g.e,0);g.n++;g.E.17(\'2\',g)})};$.N($.7.2,{11:6(){m a=$(5).17(\'2\');3(a)a.K.26(\'a.2-C\').1C();8 $(5)},Z:6(a){a=(T(a)==\'19\'?a:\'\')||\'1E\';m o=[];$(\'1h:p.2\').M(6(){3($(5).1b()==\'\')o[o.V]=5});8 $(o).M(6(){5.14=1a}).Q(a)},1f:6(a){a=(T(a)==\'19\'?a:\'\')||\'1E\';8 $(\'1h:p.\'+a).29(a).M(6(){5.14=y})},R:{},1M:6(b,c,d){m e,k;d=d||[];3(d.1G.1H().1I("1J")<0)d=[d];3(T(b)==\'6\'){$.7.2.Z();k=b.13(c||U,d);1K(6(){$.7.2.1f()},1L);8 k};3(b.1G.1H().1I("1J")<0)b=[b];1p(m i=0;i<b.V;i++){e=b[i]+\'\';3(e)(6(a){$.7.2.R[a]=$.7[a]||6(){};$.7[a]=6(){$.7.2.Z();k=$.7.2.R[a].13(5,S);1K(6(){$.7.2.1f()},1L);8 k}})(e)}}});$.7.2.F={j:\'\',l:-1,1j:\'$H\',A:{C:\'x\',1o:\'2g 2h 2i a $1d p.\\2j 2k...\',p:\'$p\',12:\'2l 12: $p\',1r:\'2m p 2n 2o 2p 12:\\n$p\'},15:[\'1n\',\'2q\',\'2r\',\'2s\'],1s:6(s){2u(s)}};$.7.11=6(){8 5.M(6(){2v{5.11()}2w(e){}})};$(6(){$("1h[2x=p].20").2()})})(1u);',62,159,'||MultiFile|if||this|function|fn|return|||||||||||accept|value|max|var|||file|gi|||replace|String||||false||STRING|match|remove|attr||options|trigger|name|id|slaves|list|clone|each|extend|wrapID|div|addClass|intercepted|arguments|typeof|window|length||class|current|disableEmpty|null|reset|selected|apply|disabled|autoIntercept|addSlave|data|new|string|true|val|instanceKey|ext|applied|reEnableEmpty|append|input|generateID|namePattern|rxAccept|wrap|metadata|submit|denied|for|wrapper|duplicate|error|parent|jQuery|css|position|top|addToList|span|title|not|click|className|mfD|_list|constructor|toString|indexOf|Array|setTimeout|1000|intercept|makeArray|absolute|_wrap|3000px|after|meta|afterFileSelect|onFileAppend|change|label|blur|onFileSelect|_F|multi|number|onFileRemove|limit|afterFileRemove|afterFileAppend|find|slice|maxlength|removeClass|in|else|files|form|prepend|Number|You|cannot|select|nTry|again|File|This|has|already|been|ajaxSubmit|ajaxForm|validate|RegExp|alert|try|catch|type|href'.split('|'),0,{}))
1
+ /*
2
+ ### jQuery Multiple File Upload Plugin v1.46 - 2009-05-12 ###
3
+ * Home: http://www.fyneworks.com/jquery/multiple-file-upload/
4
+ * Code: http://code.google.com/p/jquery-multifile-plugin/
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ ###
10
+ */
11
  eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';3(U.1u)(6($){$.7.2=6(h){3(5.V==0)8 5;3(T S[0]==\'19\'){3(5.V>1){m i=S;8 5.M(6(){$.7.2.13($(5),i)})};$.7.2[S[0]].13(5,$.1N(S).27(1)||[]);8 5};m h=$.N({},$.7.2.F,h||{});$(\'2d\').1B(\'2-R\').Q(\'2-R\').1n($.7.2.Z);3($.7.2.F.15){$.7.2.1M($.7.2.F.15);$.7.2.F.15=10};5.1B(\'.2-1e\').Q(\'2-1e\').M(6(){U.2=(U.2||0)+1;m e=U.2;m g={e:5,E:$(5),L:$(5).L()};3(T h==\'21\')h={l:h};m o=$.N({},$.7.2.F,h||{},($.1m?g.E.1m():($.1S?g.E.17():10))||{},{});3(!(o.l>0)){o.l=g.E.D(\'28\');3(!(o.l>0)){o.l=(u(g.e.1D.B(/\\b(l|23)\\-([0-9]+)\\b/q)||[\'\']).B(/[0-9]+/q)||[\'\'])[0];3(!(o.l>0))o.l=-1;2b o.l=u(o.l).B(/[0-9]+/q)[0]}};o.l=18 2f(o.l);o.j=o.j||g.E.D(\'j\')||\'\';3(!o.j){o.j=(g.e.1D.B(/\\b(j\\-[\\w\\|]+)\\b/q))||\'\';o.j=18 u(o.j).t(/^(j|1d)\\-/i,\'\')};$.N(g,o||{});g.A=$.N({},$.7.2.F.A,g.A);$.N(g,{n:0,J:[],2c:[],1c:g.e.I||\'2\'+u(e),1i:6(z){8 g.1c+(z>0?\'1Z\'+u(z):\'\')},G:6(a,b){m c=g[a],k=$(b).D(\'k\');3(c){m d=c(b,k,g);3(d!=10)8 d}8 1a}});3(u(g.j).V>1){g.j=g.j.t(/\\W+/g,\'|\').t(/^\\W|\\W$/g,\'\');g.1k=18 2t(\'\\\\.(\'+(g.j?g.j:\'\')+\')$\',\'q\')};g.O=g.1c+\'1P\';g.E.1l(\'<P X="2-1l" I="\'+g.O+\'"></P>\');g.1q=$(\'#\'+g.O+\'\');g.e.H=g.e.H||\'p\'+e+\'[]\';3(!g.K){g.1q.1g(\'<P X="2-K" I="\'+g.O+\'1F"></P>\');g.K=$(\'#\'+g.O+\'1F\')};g.K=$(g.K);g.16=6(c,d){g.n++;c.2=g;3(d>0)c.I=c.H=\'\';3(d>0)c.I=g.1i(d);c.H=u(g.1j.t(/\\$H/q,$(g.L).D(\'H\')).t(/\\$I/q,$(g.L).D(\'I\')).t(/\\$g/q,e).t(/\\$i/q,d));3((g.l>0)&&((g.n-1)>(g.l)))c.14=1a;g.Y=g.J[d]=c;c=$(c);c.1b(\'\').D(\'k\',\'\')[0].k=\'\';c.Q(\'2-1e\');c.1V(6(){$(5).1X();3(!g.G(\'1Y\',5,g))8 y;m a=\'\',v=u(5.k||\'\');3(g.j&&v&&!v.B(g.1k))a=g.A.1o.t(\'$1d\',u(v.B(/\\.\\w{1,4}$/q)));1p(m f 2a g.J)3(g.J[f]&&g.J[f]!=5)3(g.J[f].k==v)a=g.A.1r.t(\'$p\',v.B(/[^\\/\\\\]+$/q));m b=$(g.L).L();b.Q(\'2\');3(a!=\'\'){g.1s(a);g.n--;g.16(b[0],d);c.1t().2e(b);c.C();8 y};$(5).1v({1w:\'1O\',1x:\'-1Q\'});c.1R(b);g.1y(5,d);g.16(b[0],d+1);3(!g.G(\'1T\',5,g))8 y});$(c).17(\'2\',g)};g.1y=6(c,d){3(!g.G(\'1U\',c,g))8 y;m r=$(\'<P X="2-1W"></P>\'),v=u(c.k||\'\'),a=$(\'<1z X="2-1A" 1A="\'+g.A.12.t(\'$p\',v)+\'">\'+g.A.p.t(\'$p\',v.B(/[^\\/\\\\]+$/q)[0])+\'</1z>\'),b=$(\'<a X="2-C" 2y="#\'+g.O+\'">\'+g.A.C+\'</a>\');g.K.1g(r.1g(b,\' \',a));b.1C(6(){3(!g.G(\'22\',c,g))8 y;g.n--;g.Y.14=y;g.J[d]=10;$(c).C();$(5).1t().C();$(g.Y).1v({1w:\'\',1x:\'\'});$(g.Y).11().1b(\'\').D(\'k\',\'\')[0].k=\'\';3(!g.G(\'24\',c,g))8 y;8 y});3(!g.G(\'25\',c,g))8 y};3(!g.2)g.16(g.e,0);g.n++;g.E.17(\'2\',g)})};$.N($.7.2,{11:6(){m a=$(5).17(\'2\');3(a)a.K.26(\'a.2-C\').1C();8 $(5)},Z:6(a){a=(T(a)==\'19\'?a:\'\')||\'1E\';m o=[];$(\'1h:p.2\').M(6(){3($(5).1b()==\'\')o[o.V]=5});8 $(o).M(6(){5.14=1a}).Q(a)},1f:6(a){a=(T(a)==\'19\'?a:\'\')||\'1E\';8 $(\'1h:p.\'+a).29(a).M(6(){5.14=y})},R:{},1M:6(b,c,d){m e,k;d=d||[];3(d.1G.1H().1I("1J")<0)d=[d];3(T(b)==\'6\'){$.7.2.Z();k=b.13(c||U,d);1K(6(){$.7.2.1f()},1L);8 k};3(b.1G.1H().1I("1J")<0)b=[b];1p(m i=0;i<b.V;i++){e=b[i]+\'\';3(e)(6(a){$.7.2.R[a]=$.7[a]||6(){};$.7[a]=6(){$.7.2.Z();k=$.7.2.R[a].13(5,S);1K(6(){$.7.2.1f()},1L);8 k}})(e)}}});$.7.2.F={j:\'\',l:-1,1j:\'$H\',A:{C:\'x\',1o:\'2g 2h 2i a $1d p.\\2j 2k...\',p:\'$p\',12:\'2l 12: $p\',1r:\'2m p 2n 2o 2p 12:\\n$p\'},15:[\'1n\',\'2q\',\'2r\',\'2s\'],1s:6(s){2u(s)}};$.7.11=6(){8 5.M(6(){2v{5.11()}2w(e){}})};$(6(){$("1h[2x=p].20").2()})})(1u);',62,159,'||MultiFile|if||this|function|fn|return|||||||||||accept|value|max|var|||file|gi|||replace|String||||false||STRING|match|remove|attr||options|trigger|name|id|slaves|list|clone|each|extend|wrapID|div|addClass|intercepted|arguments|typeof|window|length||class|current|disableEmpty|null|reset|selected|apply|disabled|autoIntercept|addSlave|data|new|string|true|val|instanceKey|ext|applied|reEnableEmpty|append|input|generateID|namePattern|rxAccept|wrap|metadata|submit|denied|for|wrapper|duplicate|error|parent|jQuery|css|position|top|addToList|span|title|not|click|className|mfD|_list|constructor|toString|indexOf|Array|setTimeout|1000|intercept|makeArray|absolute|_wrap|3000px|after|meta|afterFileSelect|onFileAppend|change|label|blur|onFileSelect|_F|multi|number|onFileRemove|limit|afterFileRemove|afterFileAppend|find|slice|maxlength|removeClass|in|else|files|form|prepend|Number|You|cannot|select|nTry|again|File|This|has|already|been|ajaxSubmit|ajaxForm|validate|RegExp|alert|try|catch|type|href'.split('|'),0,{}))
admin/js/jquery.ui.autocomplete.js CHANGED
@@ -1,612 +1,612 @@
1
- /*
2
- * jQuery UI Autocomplete 1.8.15
3
- *
4
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
- * Dual licensed under the MIT or GPL Version 2 licenses.
6
- * http://jquery.org/license
7
- *
8
- * http://docs.jquery.com/UI/Autocomplete
9
- *
10
- * Depends:
11
- * jquery.ui.core.js
12
- * jquery.ui.widget.js
13
- * jquery.ui.position.js
14
- */
15
- (function( $, undefined ) {
16
-
17
- // used to prevent race conditions with remote data sources
18
- var requestIndex = 0;
19
-
20
- $.widget( "ui.autocomplete", {
21
- options: {
22
- appendTo: "body",
23
- autoFocus: false,
24
- delay: 300,
25
- minLength: 1,
26
- position: {
27
- my: "left top",
28
- at: "left bottom",
29
- collision: "none"
30
- },
31
- source: null
32
- },
33
-
34
- pending: 0,
35
-
36
- _create: function() {
37
- var self = this,
38
- doc = this.element[ 0 ].ownerDocument,
39
- suppressKeyPress;
40
-
41
- this.element
42
- .addClass( "ui-autocomplete-input" )
43
- .attr( "autocomplete", "off" )
44
- // TODO verify these actually work as intended
45
- .attr({
46
- role: "textbox",
47
- "aria-autocomplete": "list",
48
- "aria-haspopup": "true"
49
- })
50
- .bind( "keydown.autocomplete", function( event ) {
51
- if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
52
- return;
53
- }
54
-
55
- suppressKeyPress = false;
56
- var keyCode = $.ui.keyCode;
57
- switch( event.keyCode ) {
58
- case keyCode.PAGE_UP:
59
- self._move( "previousPage", event );
60
- break;
61
- case keyCode.PAGE_DOWN:
62
- self._move( "nextPage", event );
63
- break;
64
- case keyCode.UP:
65
- self._move( "previous", event );
66
- // prevent moving cursor to beginning of text field in some browsers
67
- event.preventDefault();
68
- break;
69
- case keyCode.DOWN:
70
- self._move( "next", event );
71
- // prevent moving cursor to end of text field in some browsers
72
- event.preventDefault();
73
- break;
74
- case keyCode.ENTER:
75
- case keyCode.NUMPAD_ENTER:
76
- // when menu is open and has focus
77
- if ( self.menu.active ) {
78
- // #6055 - Opera still allows the keypress to occur
79
- // which causes forms to submit
80
- suppressKeyPress = true;
81
- event.preventDefault();
82
- }
83
- //passthrough - ENTER and TAB both select the current element
84
- case keyCode.TAB:
85
- if ( !self.menu.active ) {
86
- return;
87
- }
88
- self.menu.select( event );
89
- break;
90
- case keyCode.ESCAPE:
91
- self.element.val( self.term );
92
- self.close( event );
93
- break;
94
- default:
95
- // keypress is triggered before the input value is changed
96
- clearTimeout( self.searching );
97
- self.searching = setTimeout(function() {
98
- // only search if the value has changed
99
- if ( self.term != self.element.val() ) {
100
- self.selectedItem = null;
101
- self.search( null, event );
102
- }
103
- }, self.options.delay );
104
- break;
105
- }
106
- })
107
- .bind( "keypress.autocomplete", function( event ) {
108
- if ( suppressKeyPress ) {
109
- suppressKeyPress = false;
110
- event.preventDefault();
111
- }
112
- })
113
- .bind( "focus.autocomplete", function() {
114
- if ( self.options.disabled ) {
115
- return;
116
- }
117
-
118
- self.selectedItem = null;
119
- self.previous = self.element.val();
120
- })
121
- .bind( "blur.autocomplete", function( event ) {
122
- if ( self.options.disabled ) {
123
- return;
124
- }
125
-
126
- clearTimeout( self.searching );
127
- // clicks on the menu (or a button to trigger a search) will cause a blur event
128
- self.closing = setTimeout(function() {
129
- self.close( event );
130
- self._change( event );
131
- }, 150 );
132
- });
133
- this._initSource();
134
- this.response = function() {
135
- return self._response.apply( self, arguments );
136
- };
137
- this.menu = $( "<ul></ul>" )
138
- .addClass( "ui-autocomplete" )
139
- .appendTo( $( this.options.appendTo || "body", doc )[0] )
140
- // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
141
- .mousedown(function( event ) {
142
- // clicking on the scrollbar causes focus to shift to the body
143
- // but we can't detect a mouseup or a click immediately afterward
144
- // so we have to track the next mousedown and close the menu if
145
- // the user clicks somewhere outside of the autocomplete
146
- var menuElement = self.menu.element[ 0 ];
147
- if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
148
- setTimeout(function() {
149
- $( document ).one( 'mousedown', function( event ) {
150
- if ( event.target !== self.element[ 0 ] &&
151
- event.target !== menuElement &&
152
- !$.ui.contains( menuElement, event.target ) ) {
153
- self.close();
154
- }
155
- });
156
- }, 1 );
157
- }
158
-
159
- // use another timeout to make sure the blur-event-handler on the input was already triggered
160
- setTimeout(function() {
161
- clearTimeout( self.closing );
162
- }, 13);
163
- })
164
- .menu({
165
- focus: function( event, ui ) {
166
- var item = ui.item.data( "item.autocomplete" );
167
- if ( false !== self._trigger( "focus", event, { item: item } ) ) {
168
- // use value to match what will end up in the input, if it was a key event
169
- if ( /^key/.test(event.originalEvent.type) ) {
170
- self.element.val( item.value );
171
- }
172
- }
173
- },
174
- selected: function( event, ui ) {
175
- var item = ui.item.data( "item.autocomplete" ),
176
- previous = self.previous;
177
-
178
- // only trigger when focus was lost (click on menu)
179
- if ( self.element[0] !== doc.activeElement ) {
180
- self.element.focus();
181
- self.previous = previous;
182
- // #6109 - IE triggers two focus events and the second
183
- // is asynchronous, so we need to reset the previous
184
- // term synchronously and asynchronously :-(
185
- setTimeout(function() {
186
- self.previous = previous;
187
- self.selectedItem = item;
188
- }, 1);
189
- }
190
-
191
- if ( false !== self._trigger( "select", event, { item: item } ) ) {
192
- self.element.val( item.value );
193
- }
194
- // reset the term after the select event
195
- // this allows custom select handling to work properly
196
- self.term = self.element.val();
197
-
198
- self.close( event );
199
- self.selectedItem = item;
200
- },
201
- blur: function( event, ui ) {
202
- // don't set the value of the text field if it's already correct
203
- // this prevents moving the cursor unnecessarily
204
- if ( self.menu.element.is(":visible") &&
205
- ( self.element.val() !== self.term ) ) {
206
- self.element.val( self.term );
207
- }
208
- }
209
- })
210
- .zIndex( this.element.zIndex() + 1 )
211
- // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
212
- .css({ top: 0, left: 0 })
213
- .hide()
214
- .data( "menu" );
215
- if ( $.fn.bgiframe ) {
216
- this.menu.element.bgiframe();
217
- }
218
- },
219
-
220
- destroy: function() {
221
- this.element
222
- .removeClass( "ui-autocomplete-input" )
223
- .removeAttr( "autocomplete" )
224
- .removeAttr( "role" )
225
- .removeAttr( "aria-autocomplete" )
226
- .removeAttr( "aria-haspopup" );
227
- this.menu.element.remove();
228
- $.Widget.prototype.destroy.call( this );
229
- },
230
-
231
- _setOption: function( key, value ) {
232
- $.Widget.prototype._setOption.apply( this, arguments );
233
- if ( key === "source" ) {
234
- this._initSource();
235
- }
236
- if ( key === "appendTo" ) {
237
- this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
238
- }
239
- if ( key === "disabled" && value && this.xhr ) {
240
- this.xhr.abort();
241
- }
242
- },
243
-
244
- _initSource: function() {
245
- var self = this,
246
- array,
247
- url;
248
- if ( $.isArray(this.options.source) ) {
249
- array = this.options.source;
250
- this.source = function( request, response ) {
251
- response( $.ui.autocomplete.filter(array, request.term) );
252
- };
253
- } else if ( typeof this.options.source === "string" ) {
254
- url = this.options.source;
255
- this.source = function( request, response ) {
256
- if ( self.xhr ) {
257
- self.xhr.abort();
258
- }
259
- self.xhr = $.ajax({
260
- url: url,
261
- data: request,
262
- dataType: "json",
263
- autocompleteRequest: ++requestIndex,
264
- success: function( data, status ) {
265
- if ( this.autocompleteRequest === requestIndex ) {
266
- response( data );
267
- }
268
- },
269
- error: function() {
270
- if ( this.autocompleteRequest === requestIndex ) {
271
- response( [] );
272
- }
273
- }
274
- });
275
- };
276
- } else {
277
- this.source = this.options.source;
278
- }
279
- },
280
-
281
- search: function( value, event ) {
282
- value = value != null ? value : this.element.val();
283
-
284
- // always save the actual value, not the one passed as an argument
285
- this.term = this.element.val();
286
-
287
- if ( value.length < this.options.minLength ) {
288
- return this.close( event );
289
- }
290
-
291
- clearTimeout( this.closing );
292
- if ( this._trigger( "search", event ) === false ) {
293
- return;
294
- }
295
-
296
- return this._search( value );
297
- },
298
-
299
- _search: function( value ) {
300
- this.pending++;
301
- this.element.addClass( "ui-autocomplete-loading" );
302
-
303
- this.source( { term: value }, this.response );
304
- },
305
-
306
- _response: function( content ) {
307
- if ( !this.options.disabled && content && content.length ) {
308
- content = this._normalize( content );
309
- this._suggest( content );
310
- this._trigger( "open" );
311
- } else {
312
- this.close();
313
- }
314
- this.pending--;
315
- if ( !this.pending ) {
316
- this.element.removeClass( "ui-autocomplete-loading" );
317
- }
318
- },
319
-
320
- close: function( event ) {
321
- clearTimeout( this.closing );
322
- if ( this.menu.element.is(":visible") ) {
323
- this.menu.element.hide();
324
- this.menu.deactivate();
325
- this._trigger( "close", event );
326
- }
327
- },
328
-
329
- _change: function( event ) {
330
- if ( this.previous !== this.element.val() ) {
331
- this._trigger( "change", event, { item: this.selectedItem } );
332
- }
333
- },
334
-
335
- _normalize: function( items ) {
336
- // assume all items have the right format when the first item is complete
337
- if ( items.length && items[0].label && items[0].value ) {
338
- return items;
339
- }
340
- return $.map( items, function(item) {
341
- if ( typeof item === "string" ) {
342
- return {
343
- label: item,
344
- value: item
345
- };
346
- }
347
- return $.extend({
348
- label: item.label || item.value,
349
- value: item.value || item.label
350
- }, item );
351
- });
352
- },
353
-
354
- _suggest: function( items ) {
355
- var ul = this.menu.element
356
- .empty()
357
- .zIndex( this.element.zIndex() + 1 );
358
- this._renderMenu( ul, items );
359
- // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
360
- this.menu.deactivate();
361
- this.menu.refresh();
362
-
363
- // size and position menu
364
- ul.show();
365
- this._resizeMenu();
366
- ul.position( $.extend({
367
- of: this.element
368
- }, this.options.position ));
369
-
370
- if ( this.options.autoFocus ) {
371
- this.menu.next( new $.Event("mouseover") );
372
- }
373
- },
374
-
375
- _resizeMenu: function() {
376
- var ul = this.menu.element;
377
- ul.outerWidth( Math.max(
378
- ul.width( "" ).outerWidth(),
379
- this.element.outerWidth()
380
- ) );
381
- },
382
-
383
- _renderMenu: function( ul, items ) {
384
- var self = this;
385
- $.each( items, function( index, item ) {
386
- self._renderItem( ul, item );
387
- });
388
- },
389
-
390
- _renderItem: function( ul, item) {
391
- return $( "<li></li>" )
392
- .data( "item.autocomplete", item )
393
- .append( $( "<a></a>" ).text( item.label ) )
394
- .appendTo( ul );
395
- },
396
-
397
- _move: function( direction, event ) {
398
- if ( !this.menu.element.is(":visible") ) {
399
- this.search( null, event );
400
- return;
401
- }
402
- if ( this.menu.first() && /^previous/.test(direction) ||
403
- this.menu.last() && /^next/.test(direction) ) {
404
- this.element.val( this.term );
405
- this.menu.deactivate();
406
- return;
407
- }
408
- this.menu[ direction ]( event );
409
- },
410
-
411
- widget: function() {
412
- return this.menu.element;
413
- }
414
- });
415
-
416
- $.extend( $.ui.autocomplete, {
417
- escapeRegex: function( value ) {
418
- return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
419
- },
420
- filter: function(array, term) {
421
- var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
422
- return $.grep( array, function(value) {
423
- return matcher.test( value.label || value.value || value );
424
- });
425
- }
426
- });
427
-
428
- }( jQuery ));
429
-
430
- /*
431
- * jQuery UI Menu (not officially released)
432
- *
433
- * This widget isn't yet finished and the API is subject to change. We plan to finish
434
- * it for the next release. You're welcome to give it a try anyway and give us feedback,
435
- * as long as you're okay with migrating your code later on. We can help with that, too.
436
- *
437
- * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
438
- * Dual licensed under the MIT or GPL Version 2 licenses.
439
- * http://jquery.org/license
440
- *
441
- * http://docs.jquery.com/UI/Menu
442
- *
443
- * Depends:
444
- * jquery.ui.core.js
445
- * jquery.ui.widget.js
446
- */
447
- (function($) {
448
-
449
- $.widget("ui.menu", {
450
- _create: function() {
451
- var self = this;
452
- this.element
453
- .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
454
- .attr({
455
- role: "listbox",
456
- "aria-activedescendant": "ui-active-menuitem"
457
- })
458
- .click(function( event ) {
459
- if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
460
- return;
461
- }
462
- // temporary
463
- event.preventDefault();
464
- self.select( event );
465
- });
466
- this.refresh();
467
- },
468
-
469
- refresh: function() {
470
- var self = this;
471
-
472
- // don't refresh list items that are already adapted
473
- var items = this.element.children("li:not(.ui-menu-item):has(a)")
474
- .addClass("ui-menu-item")
475
- .attr("role", "menuitem");
476
-
477
- items.children("a")
478
- .addClass("ui-corner-all")
479
- .attr("tabindex", -1)
480
- // mouseenter doesn't work with event delegation
481
- .mouseenter(function( event ) {
482
- self.activate( event, $(this).parent() );
483
- })
484
- .mouseleave(function() {
485
- self.deactivate();
486
- });
487
- },
488
-
489
- activate: function( event, item ) {
490
- this.deactivate();
491
- if (this.hasScroll()) {
492
- var offset = item.offset().top - this.element.offset().top,
493
- scroll = this.element.scrollTop(),
494
- elementHeight = this.element.height();
495
- if (offset < 0) {
496
- this.element.scrollTop( scroll + offset);
497
- } else if (offset >= elementHeight) {
498
- this.element.scrollTop( scroll + offset - elementHeight + item.height());
499
- }
500
- }
501
- this.active = item.eq(0)
502
- .children("a")
503
- .addClass("ui-state-hover")
504
- .attr("id", "ui-active-menuitem")
505
- .end();
506
- this._trigger("focus", event, { item: item });
507
- },
508
-
509
- deactivate: function() {
510
- if (!this.active) { return; }
511
-
512
- this.active.children("a")
513
- .removeClass("ui-state-hover")
514
- .removeAttr("id");
515
- this._trigger("blur");
516
- this.active = null;
517
- },
518
-
519
- next: function(event) {
520
- this.move("next", ".ui-menu-item:first", event);
521
- },
522
-
523
- previous: function(event) {
524
- this.move("prev", ".ui-menu-item:last", event);
525
- },
526
-
527
- first: function() {
528
- return this.active && !this.active.prevAll(".ui-menu-item").length;
529
- },
530
-
531
- last: function() {
532
- return this.active && !this.active.nextAll(".ui-menu-item").length;
533
- },
534
-
535
- move: function(direction, edge, event) {
536
- if (!this.active) {
537
- this.activate(event, this.element.children(edge));
538
- return;
539
- }
540
- var next = this.active[direction + "All"](".ui-menu-item").eq(0);
541
- if (next.length) {
542
- this.activate(event, next);
543
- } else {
544
- this.activate(event, this.element.children(edge));
545
- }
546
- },
547
-
548
- // TODO merge with previousPage
549
- nextPage: function(event) {
550
- if (this.hasScroll()) {
551
- // TODO merge with no-scroll-else
552
- if (!this.active || this.last()) {
553
- this.activate(event, this.element.children(".ui-menu-item:first"));
554
- return;
555
- }
556
- var base = this.active.offset().top,
557
- height = this.element.height(),
558
- result = this.element.children(".ui-menu-item").filter(function() {
559
- var close = $(this).offset().top - base - height + $(this).height();
560
- // TODO improve approximation
561
- return close < 10 && close > -10;
562
- });
563
-
564
- // TODO try to catch this earlier when scrollTop indicates the last page anyway
565
- if (!result.length) {
566
- result = this.element.children(".ui-menu-item:last");
567
- }
568
- this.activate(event, result);
569
- } else {
570
- this.activate(event, this.element.children(".ui-menu-item")
571
- .filter(!this.active || this.last() ? ":first" : ":last"));
572
- }
573
- },
574
-
575
- // TODO merge with nextPage
576
- previousPage: function(event) {
577
- if (this.hasScroll()) {
578
- // TODO merge with no-scroll-else
579
- if (!this.active || this.first()) {
580
- this.activate(event, this.element.children(".ui-menu-item:last"));
581
- return;
582
- }
583
-
584
- var base = this.active.offset().top,
585
- height = this.element.height();
586
- result = this.element.children(".ui-menu-item").filter(function() {
587
- var close = $(this).offset().top - base + height - $(this).height();
588
- // TODO improve approximation
589
- return close < 10 && close > -10;
590
- });
591
-
592
- // TODO try to catch this earlier when scrollTop indicates the last page anyway
593
- if (!result.length) {
594
- result = this.element.children(".ui-menu-item:first");
595
- }
596
- this.activate(event, result);
597
- } else {
598
- this.activate(event, this.element.children(".ui-menu-item")
599
- .filter(!this.active || this.first() ? ":last" : ":first"));
600
- }
601
- },
602
-
603
- hasScroll: function() {
604
- return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
605
- },
606
-
607
- select: function( event ) {
608
- this._trigger("selected", event, { item: this.active });
609
- }
610
- });
611
-
612
- }(jQuery));
1
+ /*
2
+ * jQuery UI Autocomplete 1.8.15
3
+ *
4
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Autocomplete
9
+ *
10
+ * Depends:
11
+ * jquery.ui.core.js
12
+ * jquery.ui.widget.js
13
+ * jquery.ui.position.js
14
+ */
15
+ (function( $, undefined ) {
16
+
17
+ // used to prevent race conditions with remote data sources
18
+ var requestIndex = 0;
19
+
20
+ $.widget( "ui.autocomplete", {
21
+ options: {
22
+ appendTo: "body",
23
+ autoFocus: false,
24
+ delay: 300,
25
+ minLength: 1,
26
+ position: {
27
+ my: "left top",
28
+ at: "left bottom",
29
+ collision: "none"
30
+ },
31
+ source: null
32
+ },
33
+
34
+ pending: 0,
35
+
36
+ _create: function() {
37
+ var self = this,
38
+ doc = this.element[ 0 ].ownerDocument,
39
+ suppressKeyPress;
40
+
41
+ this.element
42
+ .addClass( "ui-autocomplete-input" )
43
+ .attr( "autocomplete", "off" )
44
+ // TODO verify these actually work as intended
45
+ .attr({
46
+ role: "textbox",
47
+ "aria-autocomplete": "list",
48
+ "aria-haspopup": "true"
49
+ })
50
+ .bind( "keydown.autocomplete", function( event ) {
51
+ if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
52
+ return;
53
+ }
54
+
55
+ suppressKeyPress = false;
56
+ var keyCode = $.ui.keyCode;
57
+ switch( event.keyCode ) {
58
+ case keyCode.PAGE_UP:
59
+ self._move( "previousPage", event );
60
+ break;
61
+ case keyCode.PAGE_DOWN:
62
+ self._move( "nextPage", event );
63
+ break;
64
+ case keyCode.UP:
65
+ self._move( "previous", event );
66
+ // prevent moving cursor to beginning of text field in some browsers
67
+ event.preventDefault();
68
+ break;
69
+ case keyCode.DOWN:
70
+ self._move( "next", event );
71
+ // prevent moving cursor to end of text field in some browsers
72
+ event.preventDefault();
73
+ break;
74
+ case keyCode.ENTER:
75
+ case keyCode.NUMPAD_ENTER:
76
+ // when menu is open and has focus
77
+ if ( self.menu.active ) {
78
+ // #6055 - Opera still allows the keypress to occur
79
+ // which causes forms to submit
80
+ suppressKeyPress = true;
81
+ event.preventDefault();
82
+ }
83
+ //passthrough - ENTER and TAB both select the current element
84
+ case keyCode.TAB:
85
+ if ( !self.menu.active ) {
86
+ return;
87
+ }
88
+ self.menu.select( event );
89
+ break;
90
+ case keyCode.ESCAPE:
91
+ self.element.val( self.term );
92
+ self.close( event );
93
+ break;
94
+ default:
95
+ // keypress is triggered before the input value is changed
96
+ clearTimeout( self.searching );
97
+ self.searching = setTimeout(function() {
98
+ // only search if the value has changed
99
+ if ( self.term != self.element.val() ) {
100
+ self.selectedItem = null;
101
+ self.search( null, event );
102
+ }
103
+ }, self.options.delay );
104
+ break;
105
+ }
106
+ })
107
+ .bind( "keypress.autocomplete", function( event ) {
108
+ if ( suppressKeyPress ) {
109
+ suppressKeyPress = false;
110
+ event.preventDefault();
111
+ }
112
+ })
113
+ .bind( "focus.autocomplete", function() {
114
+ if ( self.options.disabled ) {
115
+ return;
116
+ }
117
+
118
+ self.selectedItem = null;
119
+ self.previous = self.element.val();
120
+ })
121
+ .bind( "blur.autocomplete", function( event ) {
122
+ if ( self.options.disabled ) {
123
+ return;
124
+ }
125
+
126
+ clearTimeout( self.searching );
127
+ // clicks on the menu (or a button to trigger a search) will cause a blur event
128
+ self.closing = setTimeout(function() {
129
+ self.close( event );
130
+ self._change( event );
131
+ }, 150 );
132
+ });
133
+ this._initSource();
134
+ this.response = function() {
135
+ return self._response.apply( self, arguments );
136
+ };
137
+ this.menu = $( "<ul></ul>" )
138
+ .addClass( "ui-autocomplete" )
139
+ .appendTo( $( this.options.appendTo || "body", doc )[0] )
140
+ // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
141
+ .mousedown(function( event ) {
142
+ // clicking on the scrollbar causes focus to shift to the body
143
+ // but we can't detect a mouseup or a click immediately afterward
144
+ // so we have to track the next mousedown and close the menu if
145
+ // the user clicks somewhere outside of the autocomplete
146
+ var menuElement = self.menu.element[ 0 ];
147
+ if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
148
+ setTimeout(function() {
149
+ $( document ).one( 'mousedown', function( event ) {
150
+ if ( event.target !== self.element[ 0 ] &&
151
+ event.target !== menuElement &&
152
+ !$.ui.contains( menuElement, event.target ) ) {
153
+ self.close();
154
+ }
155
+ });
156
+ }, 1 );
157
+ }
158
+
159
+ // use another timeout to make sure the blur-event-handler on the input was already triggered
160
+ setTimeout(function() {
161
+ clearTimeout( self.closing );
162
+ }, 13);
163
+ })
164
+ .menu({
165
+ focus: function( event, ui ) {
166
+ var item = ui.item.data( "item.autocomplete" );
167
+ if ( false !== self._trigger( "focus", event, { item: item } ) ) {
168
+ // use value to match what will end up in the input, if it was a key event
169
+ if ( /^key/.test(event.originalEvent.type) ) {
170
+ self.element.val( item.value );
171
+ }
172
+ }
173
+ },
174
+ selected: function( event, ui ) {
175
+ var item = ui.item.data( "item.autocomplete" ),
176
+ previous = self.previous;
177
+
178
+ // only trigger when focus was lost (click on menu)
179
+ if ( self.element[0] !== doc.activeElement ) {
180
+ self.element.focus();
181
+ self.previous = previous;
182
+ // #6109 - IE triggers two focus events and the second
183
+ // is asynchronous, so we need to reset the previous
184
+ // term synchronously and asynchronously :-(
185
+ setTimeout(function() {
186
+ self.previous = previous;
187
+ self.selectedItem = item;
188
+ }, 1);
189
+ }
190
+
191
+ if ( false !== self._trigger( "select", event, { item: item } ) ) {
192
+ self.element.val( item.value );
193
+ }
194
+ // reset the term after the select event
195
+ // this allows custom select handling to work properly
196
+ self.term = self.element.val();
197
+
198
+ self.close( event );
199
+ self.selectedItem = item;
200
+ },
201
+ blur: function( event, ui ) {
202
+ // don't set the value of the text field if it's already correct
203
+ // this prevents moving the cursor unnecessarily
204
+ if ( self.menu.element.is(":visible") &&
205
+ ( self.element.val() !== self.term ) ) {
206
+ self.element.val( self.term );
207
+ }
208
+ }
209
+ })
210
+ .zIndex( this.element.zIndex() + 1 )
211
+ // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
212
+ .css({ top: 0, left: 0 })
213
+ .hide()
214
+ .data( "menu" );
215
+ if ( $.fn.bgiframe ) {
216
+ this.menu.element.bgiframe();
217
+ }
218
+ },
219
+
220
+ destroy: function() {
221
+ this.element
222
+ .removeClass( "ui-autocomplete-input" )
223
+ .removeAttr( "autocomplete" )
224
+ .removeAttr( "role" )
225
+ .removeAttr( "aria-autocomplete" )
226
+ .removeAttr( "aria-haspopup" );
227
+ this.menu.element.remove();
228
+ $.Widget.prototype.destroy.call( this );
229
+ },
230
+
231
+ _setOption: function( key, value ) {
232
+ $.Widget.prototype._setOption.apply( this, arguments );
233
+ if ( key === "source" ) {
234
+ this._initSource();
235
+ }
236
+ if ( key === "appendTo" ) {
237
+ this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
238
+ }
239
+ if ( key === "disabled" && value && this.xhr ) {
240
+ this.xhr.abort();
241
+ }
242
+ },
243
+
244
+ _initSource: function() {
245
+ var self = this,
246
+ array,
247
+ url;
248
+ if ( $.isArray(this.options.source) ) {
249
+ array = this.options.source;
250
+ this.source = function( request, response ) {
251
+ response( $.ui.autocomplete.filter(array, request.term) );
252
+ };
253
+ } else if ( typeof this.options.source === "string" ) {
254
+ url = this.options.source;
255
+ this.source = function( request, response ) {
256
+ if ( self.xhr ) {
257
+ self.xhr.abort();
258
+ }
259
+ self.xhr = $.ajax({
260
+ url: url,
261
+ data: request,
262
+ dataType: "json",
263
+ autocompleteRequest: ++requestIndex,
264
+ success: function( data, status ) {
265
+ if ( this.autocompleteRequest === requestIndex ) {
266
+ response( data );
267
+ }
268
+ },
269
+ error: function() {
270
+ if ( this.autocompleteRequest === requestIndex ) {
271
+ response( [] );
272
+ }
273
+ }
274
+ });
275
+ };
276
+ } else {
277
+ this.source = this.options.source;
278
+ }
279
+ },
280
+
281
+ search: function( value, event ) {
282
+ value = value != null ? value : this.element.val();
283
+
284
+ // always save the actual value, not the one passed as an argument
285
+ this.term = this.element.val();
286
+
287
+ if ( value.length < this.options.minLength ) {
288
+ return this.close( event );
289
+ }
290
+
291
+ clearTimeout( this.closing );
292
+ if ( this._trigger( "search", event ) === false ) {
293
+ return;
294
+ }
295
+
296
+ return this._search( value );
297
+ },
298
+
299
+ _search: function( value ) {
300
+ this.pending++;
301
+ this.element.addClass( "ui-autocomplete-loading" );
302
+
303
+ this.source( { term: value }, this.response );
304
+ },
305
+
306
+ _response: function( content ) {
307
+ if ( !this.options.disabled && content && content.length ) {
308
+ content = this._normalize( content );
309
+ this._suggest( content );
310
+ this._trigger( "open" );
311
+ } else {
312
+ this.close();
313
+ }
314
+ this.pending--;
315
+ if ( !this.pending ) {
316
+ this.element.removeClass( "ui-autocomplete-loading" );
317
+ }
318
+ },
319
+
320
+ close: function( event ) {
321
+ clearTimeout( this.closing );
322
+ if ( this.menu.element.is(":visible") ) {
323
+ this.menu.element.hide();
324
+ this.menu.deactivate();
325
+ this._trigger( "close", event );
326
+ }
327
+ },
328
+
329
+ _change: function( event ) {
330
+ if ( this.previous !== this.element.val() ) {
331
+ this._trigger( "change", event, { item: this.selectedItem } );
332
+ }
333
+ },
334
+
335
+ _normalize: function( items ) {
336
+ // assume all items have the right format when the first item is complete
337
+ if ( items.length && items[0].label && items[0].value ) {
338
+ return items;
339
+ }
340
+ return $.map( items, function(item) {
341
+ if ( typeof item === "string" ) {
342
+ return {
343
+ label: item,
344
+ value: item
345
+ };
346
+ }
347
+ return $.extend({
348
+ label: item.label || item.value,
349
+ value: item.value || item.label
350
+ }, item );
351
+ });
352
+ },
353
+
354
+ _suggest: function( items ) {
355
+ var ul = this.menu.element
356
+ .empty()
357
+ .zIndex( this.element.zIndex() + 1 );
358
+ this._renderMenu( ul, items );
359
+ // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
360
+ this.menu.deactivate();
361
+ this.menu.refresh();
362
+
363
+ // size and position menu
364
+ ul.show();
365
+ this._resizeMenu();
366
+ ul.position( $.extend({
367
+ of: this.element
368
+ }, this.options.position ));
369
+
370
+ if ( this.options.autoFocus ) {
371
+ this.menu.next( new $.Event("mouseover") );
372
+ }
373
+ },
374
+
375
+ _resizeMenu: function() {
376
+ var ul = this.menu.element;
377
+ ul.outerWidth( Math.max(
378
+ ul.width( "" ).outerWidth(),
379
+ this.element.outerWidth()
380
+ ) );
381
+ },
382
+
383
+ _renderMenu: function( ul, items ) {
384
+ var self = this;
385
+ $.each( items, function( index, item ) {
386
+ self._renderItem( ul, item );
387
+ });
388
+ },
389
+
390
+ _renderItem: function( ul, item) {
391
+ return $( "<li></li>" )
392
+ .data( "item.autocomplete", item )
393
+ .append( $( "<a></a>" ).text( item.label ) )
394
+ .appendTo( ul );
395
+ },
396
+
397
+ _move: function( direction, event ) {
398
+ if ( !this.menu.element.is(":visible") ) {
399
+ this.search( null, event );
400
+ return;
401
+ }
402
+ if ( this.menu.first() && /^previous/.test(direction) ||
403
+ this.menu.last() && /^next/.test(direction) ) {
404
+ this.element.val( this.term );
405
+ this.menu.deactivate();
406
+ return;
407
+ }
408
+ this.menu[ direction ]( event );
409
+ },
410
+
411
+ widget: function() {
412
+ return this.menu.element;
413
+ }
414
+ });
415
+
416
+ $.extend( $.ui.autocomplete, {
417
+ escapeRegex: function( value ) {
418
+ return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
419
+ },
420
+ filter: function(array, term) {
421
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
422
+ return $.grep( array, function(value) {
423
+ return matcher.test( value.label || value.value || value );
424
+ });
425
+ }
426
+ });
427
+
428
+ }( jQuery ));
429
+
430
+ /*
431
+ * jQuery UI Menu (not officially released)
432
+ *
433
+ * This widget isn't yet finished and the API is subject to change. We plan to finish
434
+ * it for the next release. You're welcome to give it a try anyway and give us feedback,
435
+ * as long as you're okay with migrating your code later on. We can help with that, too.
436
+ *
437
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
438
+ * Dual licensed under the MIT or GPL Version 2 licenses.
439
+ * http://jquery.org/license
440
+ *
441
+ * http://docs.jquery.com/UI/Menu
442
+ *
443
+ * Depends:
444
+ * jquery.ui.core.js
445
+ * jquery.ui.widget.js
446
+ */
447
+ (function($) {
448
+
449
+ $.widget("ui.menu", {
450
+ _create: function() {
451
+ var self = this;
452
+ this.element
453
+ .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
454
+ .attr({
455
+ role: "listbox",
456
+ "aria-activedescendant": "ui-active-menuitem"
457
+ })
458
+ .click(function( event ) {
459
+ if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
460
+ return;
461
+ }
462
+ // temporary
463
+ event.preventDefault();
464
+ self.select( event );
465
+ });
466
+ this.refresh();
467
+ },
468
+
469
+ refresh: function() {
470
+ var self = this;
471
+
472
+ // don't refresh list items that are already adapted
473
+ var items = this.element.children("li:not(.ui-menu-item):has(a)")
474
+ .addClass("ui-menu-item")
475
+ .attr("role", "menuitem");
476
+
477
+ items.children("a")
478
+ .addClass("ui-corner-all")
479
+ .attr("tabindex", -1)
480
+ // mouseenter doesn't work with event delegation
481
+ .mouseenter(function( event ) {
482
+ self.activate( event, $(this).parent() );
483
+ })
484
+ .mouseleave(function() {
485
+ self.deactivate();
486
+ });
487
+ },
488
+
489
+ activate: function( event, item ) {
490
+ this.deactivate();
491
+ if (this.hasScroll()) {
492
+ var offset = item.offset().top - this.element.offset().top,
493
+ scroll = this.element.scrollTop(),
494
+ elementHeight = this.element.height();
495
+ if (offset < 0) {
496
+ this.element.scrollTop( scroll + offset);
497
+ } else if (offset >= elementHeight) {
498
+ this.element.scrollTop( scroll + offset - elementHeight + item.height());
499
+ }
500
+ }
501
+ this.active = item.eq(0)
502
+ .children("a")
503
+ .addClass("ui-state-hover")
504
+ .attr("id", "ui-active-menuitem")
505
+ .end();
506
+ this._trigger("focus", event, { item: item });
507
+ },
508
+
509
+ deactivate: function() {
510
+ if (!this.active) { return; }
511
+
512
+ this.active.children("a")
513
+ .removeClass("ui-state-hover")
514
+ .removeAttr("id");
515
+ this._trigger("blur");
516
+ this.active = null;
517
+ },
518
+
519
+ next: function(event) {
520
+ this.move("next", ".ui-menu-item:first", event);
521
+ },
522
+
523
+ previous: function(event) {
524
+ this.move("prev", ".ui-menu-item:last", event);
525
+ },
526
+
527
+ first: function() {
528
+ return this.active && !this.active.prevAll(".ui-menu-item").length;
529
+ },
530
+
531
+ last: function() {
532
+ return this.active && !this.active.nextAll(".ui-menu-item").length;
533
+ },
534
+
535
+ move: function(direction, edge, event) {
536
+ if (!this.active) {
537
+ this.activate(event, this.element.children(edge));
538
+ return;
539
+ }
540
+ var next = this.active[direction + "All"](".ui-menu-item").eq(0);
541
+ if (next.length) {
542
+ this.activate(event, next);
543
+ } else {
544
+ this.activate(event, this.element.children(edge));
545
+ }
546
+ },
547
+
548
+ // TODO merge with previousPage
549
+ nextPage: function(event) {
550
+ if (this.hasScroll()) {
551
+ // TODO merge with no-scroll-else
552
+ if (!this.active || this.last()) {
553
+ this.activate(event, this.element.children(".ui-menu-item:first"));
554
+ return;
555
+ }
556
+ var base = this.active.offset().top,
557
+ height = this.element.height(),
558
+ result = this.element.children(".ui-menu-item").filter(function() {
559
+ var close = $(this).offset().top - base - height + $(this).height();
560
+ // TODO improve approximation
561
+ return close < 10 && close > -10;
562
+ });
563
+
564
+ // TODO try to catch this earlier when scrollTop indicates the last page anyway
565
+ if (!result.length) {
566
+ result = this.element.children(".ui-menu-item:last");
567
+ }
568
+ this.activate(event, result);
569
+ } else {
570
+ this.activate(event, this.element.children(".ui-menu-item")
571
+ .filter(!this.active || this.last() ? ":first" : ":last"));
572
+ }
573
+ },
574
+
575
+ // TODO merge with nextPage
576
+ previousPage: function(event) {
577
+ if (this.hasScroll()) {
578
+ // TODO merge with no-scroll-else
579
+ if (!this.active || this.first()) {
580
+ this.activate(event, this.element.children(".ui-menu-item:last"));
581
+ return;
582
+ }
583
+
584
+ var base = this.active.offset().top,
585
+ height = this.element.height();
586
+ result = this.element.children(".ui-menu-item").filter(function() {
587
+ var close = $(this).offset().top - base + height - $(this).height();
588
+ // TODO improve approximation
589
+ return close < 10 && close > -10;
590
+ });
591
+
592
+ // TODO try to catch this earlier when scrollTop indicates the last page anyway
593
+ if (!result.length) {
594
+ result = this.element.children(".ui-menu-item:first");
595
+ }
596
+ this.activate(event, result);
597
+ } else {
598
+ this.activate(event, this.element.children(".ui-menu-item")
599
+ .filter(!this.active || this.first() ? ":last" : ":first"));
600
+ }
601
+ },
602
+
603
+ hasScroll: function() {
604
+ return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
605
+ },
606
+
607
+ select: function( event ) {
608
+ this._trigger("selected", event, { item: this.active });
609
+ }
610
+ });
611
+
612
+ }(jQuery));
admin/js/jquery.ui.autocomplete.min.js CHANGED
@@ -1,32 +1,32 @@
1
- /*
2
- * jQuery UI Autocomplete 1.8.15
3
- *
4
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
- * Dual licensed under the MIT or GPL Version 2 licenses.
6
- * http://jquery.org/license
7
- *
8
- * http://docs.jquery.com/UI/Autocomplete
9
- *
10
- * Depends:
11
- * jquery.ui.core.js
12
- * jquery.ui.widget.js
13
- * jquery.ui.position.js
14
- */
15
- (function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g=
16
- false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!=
17
- a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)};
18
- this.menu=d("<ul></ul>").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&&
19
- a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");
20
- d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&
21
- b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source=
22
- this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)!==false)return this._search(a)},_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)},_response:function(a){if(!this.options.disabled&&a&&a.length){a=this._normalize(a);this._suggest(a);this._trigger("open")}else this.close();
23
- this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this.menu.element.hide();this.menu.deactivate();this._trigger("close",a)}},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){if(a.length&&a[0].label&&a[0].value)return a;return d.map(a,function(b){if(typeof b==="string")return{label:b,value:b};return d.extend({label:b.label||
24
- b.value,value:b.value||b.label},b)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();b.show();this._resizeMenu();b.position(d.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next(new d.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(a,b){var g=this;
25
- d.each(b,function(c,f){g._renderItem(a,f)})},_renderItem:function(a,b){return d("<li></li>").data("item.autocomplete",b).append(d("<a></a>").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
26
- "\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery);
27
- (function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
28
- -1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");
29
- this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b,
30
- this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
31
- this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
32
  this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[d.fn.prop?"prop":"attr"]("scrollHeight")},select:function(e){this._trigger("selected",e,{item:this.active})}})})(jQuery);
1
+ /*
2
+ * jQuery UI Autocomplete 1.8.15
3
+ *
4
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Autocomplete
9
+ *
10
+ * Depends:
11
+ * jquery.ui.core.js
12
+ * jquery.ui.widget.js
13
+ * jquery.ui.position.js
14
+ */
15
+ (function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g=
16
+ false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!=
17
+ a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)};
18
+ this.menu=d("<ul></ul>").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&&
19
+ a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");
20
+ d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&
21
+ b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source=
22
+ this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)!==false)return this._search(a)},_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)},_response:function(a){if(!this.options.disabled&&a&&a.length){a=this._normalize(a);this._suggest(a);this._trigger("open")}else this.close();
23
+ this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this.menu.element.hide();this.menu.deactivate();this._trigger("close",a)}},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){if(a.length&&a[0].label&&a[0].value)return a;return d.map(a,function(b){if(typeof b==="string")return{label:b,value:b};return d.extend({label:b.label||
24
+ b.value,value:b.value||b.label},b)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();b.show();this._resizeMenu();b.position(d.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next(new d.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(a,b){var g=this;
25
+ d.each(b,function(c,f){g._renderItem(a,f)})},_renderItem:function(a,b){return d("<li></li>").data("item.autocomplete",b).append(d("<a></a>").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
26
+ "\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery);
27
+ (function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
28
+ -1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");
29
+ this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b,
30
+ this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
31
+ this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
32
  this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[d.fn.prop?"prop":"attr"]("scrollHeight")},select:function(e){this._trigger("selected",e,{item:this.active})}})})(jQuery);
admin/js/jqueryFileTree/jqueryFileTree.css CHANGED
@@ -5,7 +5,7 @@
5
  padding: 4px 8px;
6
  background: #fff;
7
  margin: 4px 0px;
8
- width: 350px;
9
  position:relative;
10
  display:none;
11
  }
5
  padding: 4px 8px;
6
  background: #fff;
7
  margin: 4px 0px;
8
+ max-width: 350px;
9
  position:relative;
10
  display:none;
11
  }
admin/js/jqueryFileTree/jqueryFileTree.js CHANGED
@@ -1,98 +1,98 @@
1
- // jQuery File Tree Plugin
2
- //
3
- // Version 1.01
4
- //
5
- // Cory S.N. LaViska
6
- // A Beautiful Site (http://abeautifulsite.net/)
7
- // 24 March 2008
8
- //
9
- // Visit http://abeautifulsite.net/notebook.php?article=58 for more information
10
- //
11
- // Usage: $('.fileTreeDemo').fileTree( options, callback )
12
- //
13
- // Options: root - root folder to display; default = /
14
- // script - location of the serverside AJAX file to use; default = jqueryFileTree.php
15
- // folderEvent - event to trigger expand/collapse; default = click
16
- // expandSpeed - default = 500 (ms); use -1 for no animation
17
- // collapseSpeed - default = 500 (ms); use -1 for no animation
18
- // expandEasing - easing function to use on expand (optional)
19
- // collapseEasing - easing function to use on collapse (optional)
20
- // multiFolder - whether or not to limit the browser to one subfolder at a time
21
- // loadMessage - Message to display while initial tree loads (can be HTML)
22
- //
23
- // History:
24
- //
25
- // 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
26
- // 1.00 - released (24 March 2008)
27
- //
28
- // TERMS OF USE
29
- //
30
- // This plugin is dual-licensed under the GNU General Public License and the MIT License and
31
- // is copyright 2008 A Beautiful Site, LLC.
32
- //
33
- if(jQuery) (function($){
34
-
35
- $.extend($.fn, {
36
- fileTree: function(o, h) {
37
- // Defaults
38
- if( !o ) var o = {};
39
- if( o.root == undefined ) o.root = '/';
40
- if( o.script == undefined ) o.script = 'jqueryFileTree.php';
41
- if( o.folderEvent == undefined ) o.folderEvent = 'dblclick';
42
- if( o.expandSpeed == undefined ) o.expandSpeed= 200;
43
- if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;
44
- if( o.expandEasing == undefined ) o.expandEasing = null;
45
- if( o.collapseEasing == undefined ) o.collapseEasing = null;
46
- if( o.multiFolder == undefined ) o.multiFolder = true;
47
- if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
48
-
49
- $(this).each( function() {
50
-
51
- function showTree(c, t) {
52
- $(c).addClass('wait');
53
- $(".jqueryFileTree.start").remove();
54
- $.post(o.script, { dir: t }, function(data) {
55
- $(c).find('.start').html('');
56
- $(c).removeClass('wait').append(data);
57
- if( o.root == t )
58
- $(c).find('UL:hidden').show();
59
- else
60
- $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
61
- bindTree(c);
62
- });
63
- }
64
-
65
- function bindTree(t) {
66
- $(t).find('li a').bind(o.folderEvent, function() {
67
- if( $(this).parent().hasClass('collapsed') ) {
68
- // Expand
69
- if( !o.multiFolder ) {
70
- $(this).parent().parent().find('ul').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
71
- $(this).parent().parent().find('li.directory').removeClass('expanded').addClass('collapsed');
72
- }
73
- $(this).parent().find('ul').remove(); // cleanup
74
- showTree( $(this).parent(), escape($(this).attr('rel').match( /.*\// )) );
75
- $(this).parent().removeClass('collapsed').addClass('expanded');
76
- } else {
77
- // Collapse
78
- $(this).parent().find('ul').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
79
- $(this).parent().removeClass('expanded').addClass('collapsed');
80
- }
81
- return false;
82
- });
83
- $(t).find('li a').bind('click', function() {
84
- h($(this).attr('rel'));
85
- $(this).parents('#file_browser').find('.active').removeClass('active');
86
- $(this).parent().addClass('active');
87
- return false;
88
- });
89
- }
90
- // Loading message
91
- $(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
92
- // Get the initial file list
93
- showTree( $(this), escape(o.root) );
94
- });
95
- }
96
- });
97
-
98
  })(jQuery);
1
+ // jQuery File Tree Plugin
2
+ //
3
+ // Version 1.01
4
+ //
5
+ // Cory S.N. LaViska
6
+ // A Beautiful Site (http://abeautifulsite.net/)
7
+ // 24 March 2008
8
+ //
9
+ // Visit http://abeautifulsite.net/notebook.php?article=58 for more information
10
+ //
11
+ // Usage: $('.fileTreeDemo').fileTree( options, callback )
12
+ //
13
+ // Options: root - root folder to display; default = /
14
+ // script - location of the serverside AJAX file to use; default = jqueryFileTree.php
15
+ // folderEvent - event to trigger expand/collapse; default = click
16
+ // expandSpeed - default = 500 (ms); use -1 for no animation
17
+ // collapseSpeed - default = 500 (ms); use -1 for no animation
18
+ // expandEasing - easing function to use on expand (optional)
19
+ // collapseEasing - easing function to use on collapse (optional)
20
+ // multiFolder - whether or not to limit the browser to one subfolder at a time
21
+ // loadMessage - Message to display while initial tree loads (can be HTML)
22
+ //
23
+ // History:
24
+ //
25
+ // 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
26
+ // 1.00 - released (24 March 2008)
27
+ //
28
+ // TERMS OF USE
29
+ //
30
+ // This plugin is dual-licensed under the GNU General Public License and the MIT License and
31
+ // is copyright 2008 A Beautiful Site, LLC.
32
+ //
33
+ if(jQuery) (function($){
34
+
35
+ $.extend($.fn, {
36
+ fileTree: function(o, h) {
37
+ // Defaults
38
+ if( !o ) var o = {};
39
+ if( o.root == undefined ) o.root = '/';
40
+ if( o.script == undefined ) o.script = 'jqueryFileTree.php';
41
+ if( o.folderEvent == undefined ) o.folderEvent = 'dblclick';
42
+ if( o.expandSpeed == undefined ) o.expandSpeed= 200;
43
+ if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;
44
+ if( o.expandEasing == undefined ) o.expandEasing = null;
45
+ if( o.collapseEasing == undefined ) o.collapseEasing = null;
46
+ if( o.multiFolder == undefined ) o.multiFolder = true;
47
+ if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
48
+
49
+ $(this).each( function() {
50
+
51
+ function showTree(c, t) {
52
+ $(c).addClass('wait');
53
+ $(".jqueryFileTree.start").remove();
54
+ $.post(o.script, { dir: t }, function(data) {
55
+ $(c).find('.start').html('');
56
+ $(c).removeClass('wait').append(data);
57
+ if( o.root == t )
58
+ $(c).find('UL:hidden').show();
59
+ else
60
+ $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
61
+ bindTree(c);
62
+ });
63
+ }
64
+
65
+ function bindTree(t) {
66
+ $(t).find('li a').bind(o.folderEvent, function() {
67
+ if( $(this).parent().hasClass('collapsed') ) {
68
+ // Expand
69
+ if( !o.multiFolder ) {
70
+ $(this).parent().parent().find('ul').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
71
+ $(this).parent().parent().find('li.directory').removeClass('expanded').addClass('collapsed');
72
+ }
73
+ $(this).parent().find('ul').remove(); // cleanup
74
+ showTree( $(this).parent(), escape($(this).attr('rel').match( /.*\// )) );
75
+ $(this).parent().removeClass('collapsed').addClass('expanded');
76
+ } else {
77
+ // Collapse
78
+ $(this).parent().find('ul').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
79
+ $(this).parent().removeClass('expanded').addClass('collapsed');
80
+ }
81
+ return false;
82
+ });
83
+ $(t).find('li a').bind('click', function() {
84
+ h($(this).attr('rel'));
85
+ $(this).parents('#file_browser').find('.active').removeClass('active');
86
+ $(this).parent().addClass('active');
87
+ return false;
88
+ });
89
+ }
90
+ // Loading message
91
+ $(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
92
+ // Get the initial file list
93
+ showTree( $(this), escape(o.root) );
94
+ });
95
+ }
96
+ });
97
+
98
  })(jQuery);
admin/js/ngg.ajax.js CHANGED
@@ -1,118 +1,118 @@
1
- /*
2
- * Ajax Plugin for NextGEN gallery
3
- * Version: 1.4.1
4
- * Author : Alex Rabe
5
- *
6
- */
7
- (function($) {
8
- nggAjax = {
9
- settings: {
10
- url: nggAjaxSetup.url,
11
- type: "POST",
12
- action: nggAjaxSetup.action,
13
- operation : nggAjaxSetup.operation,
14
- nonce: nggAjaxSetup.nonce,
15
- ids: nggAjaxSetup.ids,
16
- permission: nggAjaxSetup.permission,
17
- error: nggAjaxSetup.error,
18
- failure: nggAjaxSetup.failure,
19
- timeout: 10000
20
- },
21
-
22
- run: function( index ) {
23
- s = this.settings;
24
- var req = $.ajax({
25
- type: "POST",
26
- url: s.url,
27
- data:"action=" + s.action + "&operation=" + s.operation + "&_wpnonce=" + s.nonce + "&image=" + s.ids[index],
28
- cache: false,
29
- timeout: 10000,
30
- success: function(msg){
31
- switch ( parseInt(msg) ) {
32
- case -1:
33
- nggProgressBar.addNote( nggAjax.settings.permission );
34
- break;
35
- case 0:
36
- nggProgressBar.addNote( nggAjax.settings.error );
37
- break;
38
- case 1:
39
- // show nothing, its better
40
- break;
41
- default:
42
- // Return the message
43
- nggProgressBar.addNote( "<strong>ID " + nggAjax.settings.ids[index] + ":</strong> " + nggAjax.settings.failure, msg );
44
- break;
45
- }
46
-
47
- },
48
- error: function (msg) {
49
- nggProgressBar.addNote( "<strong>ID " + nggAjax.settings.ids[index] + ":</strong> " + nggAjax.settings.failure, msg.responseText );
50
- },
51
- complete: function () {
52
- index++;
53
- nggProgressBar.increase( index );
54
- // parse the whole array
55
- if (index < nggAjax.settings.ids.length)
56
- nggAjax.run( index );
57
- else
58
- nggProgressBar.finished();
59
- }
60
- });
61
- },
62
-
63
- readIDs: function( index ) {
64
- s = this.settings;
65
- var req = $.ajax({
66
- type: "POST",
67
- url: s.url,
68
- data:"action=" + s.action + "&operation=" + s.operation + "&_wpnonce=" + s.nonce + "&image=" + s.ids[index],
69
- dataType: "json",
70
- cache: false,
71
- timeout: 10000,
72
- success: function(msg){
73
- // join the array
74
- imageIDS = imageIDS.concat(msg);
75
- },
76
- error: function (msg) {
77
- nggProgressBar.addNote( "<strong>ID " + nggAjax.settings.ids[index] + ":</strong> " + nggAjax.settings.failure, msg.responseText );
78
- },
79
- complete: function () {
80
- index++;
81
- nggProgressBar.increase( index );
82
- // parse the whole array
83
- if (index < nggAjax.settings.ids.length)
84
- nggAjax.readIDs( index );
85
- else {
86
- // and now run the image operation
87
- index = 0;
88
- nggAjax.settings.ids = imageIDS;
89
- nggAjax.settings.operation = nextOperation;
90
- nggAjax.settings.maxStep = imageIDS.length;
91
- nggProgressBar.init( nggAjax.settings );
92
- nggAjax.run( index );
93
- }
94
- }
95
- });
96
- },
97
-
98
- init: function( s ) {
99
-
100
- var index = 0;
101
-
102
- // get the settings
103
- this.settings = $.extend( {}, this.settings, {}, s || {} );
104
-
105
- // a gallery operation need first all image ids via ajax
106
- if ( this.settings.operation.substring(0, 8) == 'gallery_' ) {
107
- nextOperation = this.settings.operation.substring(8);
108
- //first run, get all the ids
109
- this.settings.operation = 'get_image_ids';
110
- imageIDS = new Array();
111
- this.readIDs( index );
112
- } else {
113
- // start the ajax process
114
- this.run( index );
115
- }
116
- }
117
- }
118
- }(jQuery));
1
+ /*
2
+ * Ajax Plugin for NextGEN gallery
3
+ * Version: 1.4.1
4
+ * Author : Alex Rabe
5
+ *
6
+ */
7
+ (function($) {
8
+ nggAjax = {
9
+ settings: {
10
+ url: nggAjaxSetup.url,
11
+ type: "POST",
12
+ action: nggAjaxSetup.action,
13
+ operation : nggAjaxSetup.operation,
14
+ nonce: nggAjaxSetup.nonce,
15
+ ids: nggAjaxSetup.ids,
16
+ permission: nggAjaxSetup.permission,
17
+ error: nggAjaxSetup.error,
18
+ failure: nggAjaxSetup.failure,
19
+ timeout: 10000
20
+ },
21
+
22
+ run: function( index ) {
23
+ s = this.settings;
24
+ var req = $.ajax({
25
+ type: "POST",
26
+ url: s.url,
27
+ data:"action=" + s.action + "&operation=" + s.operation + "&_wpnonce=" + s.nonce + "&image=" + s.ids[index],
28
+ cache: false,
29
+ timeout: 10000,
30
+ success: function(msg){
31
+ switch ( parseInt(msg) ) {
32
+ case -1:
33
+ nggProgressBar.addNote( nggAjax.settings.permission );
34
+ break;
35
+ case 0:
36
+ nggProgressBar.addNote( nggAjax.settings.error );
37
+ break;
38
+ case 1:
39
+ // show nothing, its better
40
+ break;
41
+ default:
42
+ // Return the message
43
+ nggProgressBar.addNote( "<strong>ID " + nggAjax.settings.ids[index] + ":</strong> " + nggAjax.settings.failure, msg );
44
+ break;
45
+ }
46
+
47
+ },
48
+ error: function (msg) {
49
+ nggProgressBar.addNote( "<strong>ID " + nggAjax.settings.ids[index] + ":</strong> " + nggAjax.settings.failure, msg.responseText );
50
+ },
51
+ complete: function () {
52
+ index++;
53
+ nggProgressBar.increase( index );
54
+ // parse the whole array
55
+ if (index < nggAjax.settings.ids.length)
56
+ nggAjax.run( index );
57
+ else
58
+ nggProgressBar.finished();
59
+ }
60
+ });
61
+ },
62
+
63
+ readIDs: function( index ) {
64
+ s = this.settings;
65
+ var req = $.ajax({
66
+ type: "POST",
67
+ url: s.url,
68
+ data:"action=" + s.action + "&operation=" + s.operation + "&_wpnonce=" + s.nonce + "&image=" + s.ids[index],
69
+ dataType: "json",
70
+ cache: false,
71
+ timeout: 10000,
72
+ success: function(msg){
73
+ // join the array
74
+ imageIDS = imageIDS.concat(msg);
75
+ },
76
+ error: function (msg) {
77
+ nggProgressBar.addNote( "<strong>ID " + nggAjax.settings.ids[index] + ":</strong> " + nggAjax.settings.failure, msg.responseText );
78
+ },
79
+ complete: function () {
80
+ index++;
81
+ nggProgressBar.increase( index );
82
+ // parse the whole array
83
+ if (index < nggAjax.settings.ids.length)
84
+ nggAjax.readIDs( index );
85
+ else {
86
+ // and now run the image operation
87
+ index = 0;
88
+ nggAjax.settings.ids = imageIDS;
89
+ nggAjax.settings.operation = nextOperation;
90
+ nggAjax.settings.maxStep = imageIDS.length;
91
+ nggProgressBar.init( nggAjax.settings );
92
+ nggAjax.run( index );
93
+ }
94
+ }
95
+ });
96
+ },
97
+
98
+ init: function( s ) {
99
+
100
+ var index = 0;
101
+
102
+ // get the settings
103
+ this.settings = $.extend( {}, this.settings, {}, s || {} );
104
+
105
+ // a gallery operation need first all image ids via ajax
106
+ if ( this.settings.operation.substring(0, 8) == 'gallery_' ) {
107
+ nextOperation = this.settings.operation.substring(8);
108
+ //first run, get all the ids
109
+ this.settings.operation = 'get_image_ids';
110
+ imageIDS = new Array();
111
+ this.readIDs( index );
112
+ } else {
113
+ // start the ajax process
114
+ this.run( index );
115
+ }
116
+ }
117
+ }
118
+ }(jQuery));
admin/js/ngg.progressbar.js CHANGED
@@ -1,96 +1,96 @@
1
- /*
2
- * Progress bar Plugin for NextGEN gallery
3
- * Version: 2.0.3
4
- * Author : Alex Rabe
5
- *
6
- */
7
- (function($) {
8
- nggProgressBar = {
9
-
10
- settings: {
11
- id: 'progressbar',
12
- maxStep: 100,
13
- wait: false,
14
- header: '',
15
- init:false
16
- },
17
-
18
- init: function( s ) {
19
-
20
- s = this.settings = $.extend( {}, this.settings, {}, s || {} );
21
- width = Math.round( ( 100 / s.maxStep ) * 100 ) /100;
22
- // add the initial progressbar
23
- if ( $( "#" + s.id + "_dialog" ).length == 0) {
24
- s.header = (s.header.length > 0) ? s.header : '' ;
25
- $("body").append('<div id="' + s.id + '_dialog"><div id="' + s.id + '" class="progressborder"><div class="' + s.id + '"><span>0%</span></div></div></div>');
26
- $('html,body').scrollTop(0); // works only in IE, FF
27
- // we open the dialog
28
- $( "#" + s.id + "_dialog" ).dialog({
29
- width: 640,
30
- resizable : true,
31
- modal: true,
32
- title: s.header
33
- });
34
- }
35
- // get the pointer to the dialog
36
- div = $('#' + s.id + '_dialog');
37
- s.init = true;
38
- },
39
-
40
- addMessage: function( message ) {
41
- s = this.settings;
42
- if ( div.find("#" + s.id + "_message").length == 0)
43
- div.append('<div class="' + s.id + '_message"><span style="display:block" id="' + s.id + '_message">' + message + '</span></div>');
44
- else
45
- $("#" + s.id + "_message").html( message );
46
- },
47
-
48
- addNote: function( note, detail ) {
49
- s = this.settings;
50
- s.wait = true;
51
- if ( div.find("#" + s.id + "_note").length == 0)
52
- div.append('<ul id="' + s.id + '_note">&nbsp;</ul>');
53
-
54
- if (detail)
55
- $("#" + s.id + "_note").append("<li>" + note + "<div class='show_details'><span>[more]</span><br />" + detail + "</div></li>");
56
- else
57
- $("#" + s.id + "_note").append("<li>" + note + "</li>");
58
- // increase the height to show the note
59
- div.dialog("option", "height", 220);
60
- },
61
-
62
- increase: function( step ) {
63
- s = this.settings;
64
- var value = step * width + "%";
65
- var rvalue = Math.round (step * width) + "%" ;
66
- $("#" + s.id + " div").width( value );
67
- $("#" + s.id + " span").html( rvalue );
68
- },
69
-
70
- finished: function() {
71
- s = this.settings;
72
- $("#" + s.id + " div").width( '100%' );
73
- $("#" + s.id + " span").html( '100%' );
74
- // in the case we add a note , we should wait for a click
75
- if (s.wait) {
76
- $("#" + s.id).delay(1000).hide("slow");
77
- div.click(function () {
78
- $("#" + s.id + "_dialog").dialog("destroy");
79
- $("#" + s.id + "_dialog").remove();
80
- // In the casee it's the manage page, force a submit
81
- $('.nggform').prepend("<input type=\"hidden\" name=\"ajax_callback\" value=\"0\">");
82
- $('.nggform').submit();
83
- });
84
- } else {
85
-
86
- window.setTimeout(function() {
87
- $("#" + s.id + "_dialog" ).delay(4000).dialog("destroy");
88
- $("#" + s.id + "_dialog").remove();
89
- // In the casee it's the manage page, force a submit
90
- $('.nggform').prepend("<input type=\"hidden\" name=\"ajax_callback\" value=\"1\">");
91
- $('.nggform').delay(4000).submit();
92
- }, 1000);
93
- }
94
- }
95
- };
96
- })(jQuery);
1
+ /*
2
+ * Progress bar Plugin for NextGEN gallery
3
+ * Version: 2.0.3
4
+ * Author : Alex Rabe
5
+ *
6
+ */
7
+ (function($) {
8
+ nggProgressBar = {
9
+
10
+ settings: {
11
+ id: 'progressbar',
12
+ maxStep: 100,
13
+ wait: false,
14
+ header: '',
15
+ init:false
16
+ },
17
+
18
+ init: function( s ) {
19
+
20
+ s = this.settings = $.extend( {}, this.settings, {}, s || {} );
21
+ width = Math.round( ( 100 / s.maxStep ) * 100 ) /100;
22
+ // add the initial progressbar
23
+ if ( $( "#" + s.id + "_dialog" ).length == 0) {
24
+ s.header = (s.header.length > 0) ? s.header : '' ;
25
+ $("body").append('<div id="' + s.id + '_dialog"><div id="' + s.id + '" class="progressborder"><div class="' + s.id + '"><span>0%</span></div></div></div>');
26
+ $('html,body').scrollTop(0); // works only in IE, FF
27
+ // we open the dialog
28
+ $( "#" + s.id + "_dialog" ).dialog({
29
+ width: 640,
30
+ resizable : true,
31
+ modal: true,
32
+ title: s.header
33
+ });
34
+ }
35
+ // get the pointer to the dialog
36
+ div = $('#' + s.id + '_dialog');
37
+ s.init = true;
38
+ },
39
+
40
+ addMessage: function( message ) {
41
+ s = this.settings;
42
+ if ( div.find("#" + s.id + "_message").length == 0)
43
+ div.append('<div class="' + s.id + '_message"><span style="display:block" id="' + s.id + '_message">' + message + '</span></div>');
44
+ else
45
+ $("#" + s.id + "_message").html( message );
46
+ },
47
+
48
+ addNote: function( note, detail ) {
49
+ s = this.settings;
50
+ s.wait = true;
51
+ if ( div.find("#" + s.id + "_note").length == 0)
52
+ div.append('<ul id="' + s.id + '_note">&nbsp;</ul>');
53
+
54
+ if (detail)
55
+ $("#" + s.id + "_note").append("<li>" + note + "<div class='show_details'><span>[more]</span><br />" + detail + "</div></li>");
56
+ else
57
+ $("#" + s.id + "_note").append("<li>" + note + "</li>");
58
+ // increase the height to show the note
59
+ div.dialog("option", "height", 220);
60
+ },
61
+
62
+ increase: function( step ) {
63
+ s = this.settings;
64
+ var value = step * width + "%";
65
+ var rvalue = Math.round (step * width) + "%" ;
66
+ $("#" + s.id + " div").width( value );
67
+ $("#" + s.id + " span").html( rvalue );
68
+ },
69
+
70
+ finished: function() {
71
+ s = this.settings;
72
+ $("#" + s.id + " div").width( '100%' );
73
+ $("#" + s.id + " span").html( '100%' );
74
+ // in the case we add a note , we should wait for a click
75
+ if (s.wait) {
76
+ $("#" + s.id).delay(1000).hide("slow");
77
+ div.click(function () {
78
+ $("#" + s.id + "_dialog").dialog("destroy");
79
+ $("#" + s.id + "_dialog").remove();
80
+ // In the casee it's the manage page, force a submit
81
+ $('.nggform').prepend("<input type=\"hidden\" name=\"ajax_callback\" value=\"0\">");
82
+ $('.nggform').submit();
83
+ });
84
+ } else {
85
+
86
+ window.setTimeout(function() {
87
+ $("#" + s.id + "_dialog" ).delay(4000).dialog("destroy");
88
+ $("#" + s.id + "_dialog").remove();
89
+ // In the casee it's the manage page, force a submit
90
+ $('.nggform').prepend("<input type=\"hidden\" name=\"ajax_callback\" value=\"1\">");
91
+ $('.nggform').delay(4000).submit();
92
+ }, 1000);
93
+ }
94
+ }
95
+ };
96
+ })(jQuery);
admin/js/ngg_social_media.js CHANGED
@@ -1,8 +1,8 @@
1
- !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
2
- (function(d, s, id) {
3
- var js, fjs = d.getElementsByTagName(s)[0];
4
- if (d.getElementById(id)) return;
5
- js = d.createElement(s); js.id = id;
6
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
7
- fjs.parentNode.insertBefore(js, fjs);
8
  }(document, 'script', 'facebook-jssdk'));
1
+ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
2
+ (function(d, s, id) {
3
+ var js, fjs = d.getElementsByTagName(s)[0];
4
+ if (d.getElementById(id)) return;
5
+ js = d.createElement(s); js.id = id;
6
+ js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
7
+ fjs.parentNode.insertBefore(js, fjs);
8
  }(document, 'script', 'facebook-jssdk'));
admin/js/swfupload.handler.js CHANGED
@@ -1,153 +1,153 @@
1
- /**
2
- * NextGEN Gallery - SWFUpload Handler
3
- * http://www.nextgen-gallery.com/
4
- *
5
- * Built on top of the swfupload library
6
- * http://swfupload.org version 2.2.0
7
- *
8
- * version 1.0.3
9
- */
10
-
11
- // on load change the upload to swfupload
12
- function initSWFUpload() {
13
- jQuery(function() {
14
- jQuery("#uploadimage_btn").after("<input class='button-primary' type='button' name='uploadimage' id='swfupload_btn' value='" + ngg_swf_upload.customSettings.upload + "' />")
15
- .remove();
16
- jQuery("#swfupload_btn").click( function() { submitFiles(); } );
17
- jQuery("#imagefiles")
18
- .after("<div id='uploadQueue'></div>")
19
- .after("<input id='imagefiles' type='button' class='button-secondary uploadform' value='" + ngg_swf_upload.customSettings.browse + "' />")
20
- .after("<input type='text' id='txtFileName' readonly='readonly' />")
21
- .remove();
22
- jQuery("#imagefiles").click( function() { fileBrowse(); } );
23
- });
24
- }
25
-
26
- // call the upload dialog
27
- function fileBrowse() {
28
- jQuery("#txtFileName").val("");
29
- ngg_swf_upload.cancelUpload();
30
- ngg_swf_upload.selectFiles();
31
- }
32
-
33
- // called when a file is added
34
- function fileQueued(fileObj) {
35
- filesize = " (" + Math.round(fileObj.size/1024) + " kB) ";
36
- jQuery("#txtFileName").val(fileObj.name);
37
- jQuery("#uploadQueue")
38
- .append("<div id='" + fileObj.id + "' class='nggUploadItem'> [<a href='javascript:removeFile(\"" + fileObj.id + "\");'>" + ngg_swf_upload.customSettings.remove + "</a>] " + fileObj.name + filesize + "</div>")
39
- .children("div:last").slideDown("slow")
40
- .end();
41
- }
42
-
43
- // start the upload
44
- function submitFiles() {
45
- // check if a gallery is selected
46
- if (jQuery('#galleryselect').val() > "0") {
47
- nggProgressBar.init(nggAjaxOptions);
48
- // get old post_params
49
- post_params = ngg_swf_upload.getSetting("post_params");
50
- // update the selected gallery in the post_params
51
- post_params['galleryselect'] = jQuery('#galleryselect').val();
52
- ngg_swf_upload.setPostParams(post_params);
53
- ngg_swf_upload.startUpload();
54
- } else {
55
- jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"-1\">");
56
- jQuery("#uploadimage_form").submit();
57
- }
58
- }
59
-
60
- // called when a file will be removed
61
- function removeFile(fileID) {
62
- ngg_swf_upload.cancelUpload(fileID);
63
- jQuery("#" + fileID).hide("slow");
64
- jQuery("#" + fileID).remove();
65
- }
66
-
67
- // called before the uploads start
68
- function uploadStart(fileObj) {
69
- nggProgressBar.init(nggAjaxOptions);
70
- return true;
71
- }
72
-
73
- // called during the upload progress
74
- function uploadProgress(fileObj, bytesLoaded) {
75
- var percent = Math.ceil((bytesLoaded / fileObj.size) * 100);
76
- nggProgressBar.increase( percent );
77
- jQuery("#progressbar span").text(percent + "% - " + fileObj.name);
78
- }
79
-
80
- // called when the file is uploaded
81
- function uploadComplete(fileObj) {
82
- jQuery("#" + fileObj.id).hide("slow");
83
- jQuery("#" + fileObj.id).remove();
84
- if ( ngg_swf_upload.getStats().files_queued == 0) {
85
- nggProgressBar.finished();
86
- jQuery("#uploadimage_form").submit();
87
- }
88
- }
89
-
90
- // called when all files are uploaded
91
- function uploadSuccess(fileObj, server_data) {
92
- // Show any error message
93
- if (server_data != 0){
94
- nggProgressBar.addNote("<strong>ERROR</strong>: " + fileObj.name + " : " + server_data);
95
- }
96
- // Upload the next file until queue is empty
97
- if ( ngg_swf_upload.getStats().files_queued > 0) {
98
- ngg_swf_upload.startUpload();
99
- } else {
100
- // server_data could be add as hidden field
101
- jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"" + server_data + "\">");
102
- }
103
- }
104
-
105
- // called on error
106
- function uploadError(fileObj, error_code, message) {
107
- var error_name = "";
108
- switch(error_code) {
109
- case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
110
- error_name = "HTTP ERROR";
111
- break;
112
- case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
113
- error_name = "MISSING UPLOAD URL";
114
- break;
115
- case SWFUpload.UPLOAD_ERROR.IO_ERROR:
116
- error_name = "IO FAILURE";
117
- break;
118
- case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
119
- error_name = "SECURITY ERROR";
120
- break;
121
- case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
122
- error_name = "UPLOAD LIMIT EXCEEDED";
123
- break;
124
- case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
125
- error_name = "UPLOAD FAILED";
126
- break;
127
- case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
128
- error_name = "SPECIFIED FILE ID NOT FOUND";
129
- break;
130
- case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
131
- error_name = "FILE VALIDATION FAILED";
132
- break;
133
- case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
134
- error_name = "FILE CANCELLED";
135
- return;
136
- break;
137
- case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
138
- error_name = "FILE STOPPED";
139
- break;
140
- default:
141
- error_name = "UNKNOWN";
142
- break;
143
- }
144
- nggProgressBar.addNote("<strong>ERROR " + error_name + " </strong>: " + fileObj.name + " : " + message);
145
- jQuery("#" + fileObj.id).hide("slow");
146
- jQuery("#" + fileObj.id).remove();
147
- if ( ngg_swf_upload.getStats().files_queued > 0) {
148
- ngg_swf_upload.startUpload();
149
- } else {
150
- jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"" + error_name + "\">");
151
- jQuery("#uploadimage_form").submit();
152
- }
153
- }
1
+ /**
2
+ * NextGEN Gallery - SWFUpload Handler
3
+ * http://www.nextgen-gallery.com/
4
+ *
5
+ * Built on top of the swfupload library
6
+ * http://swfupload.org version 2.2.0
7
+ *
8
+ * version 1.0.3
9
+ */
10
+
11
+ // on load change the upload to swfupload
12
+ function initSWFUpload() {
13
+ jQuery(function() {
14
+ jQuery("#uploadimage_btn").after("<input class='button-primary' type='button' name='uploadimage' id='swfupload_btn' value='" + ngg_swf_upload.customSettings.upload + "' />")
15
+ .remove();
16
+ jQuery("#swfupload_btn").click( function() { submitFiles(); } );
17
+ jQuery("#imagefiles")
18
+ .after("<div id='uploadQueue'></div>")
19
+ .after("<input id='imagefiles' type='button' class='button-secondary uploadform' value='" + ngg_swf_upload.customSettings.browse + "' />")
20
+ .after("<input type='text' id='txtFileName' readonly='readonly' />")
21
+ .remove();
22
+ jQuery("#imagefiles").click( function() { fileBrowse(); } );
23
+ });
24
+ }
25
+
26
+ // call the upload dialog
27
+ function fileBrowse() {
28
+ jQuery("#txtFileName").val("");
29
+ ngg_swf_upload.cancelUpload();
30
+ ngg_swf_upload.selectFiles();
31
+ }
32
+
33
+ // called when a file is added
34
+ function fileQueued(fileObj) {
35
+ filesize = " (" + Math.round(fileObj.size/1024) + " kB) ";
36
+ jQuery("#txtFileName").val(fileObj.name);
37
+ jQuery("#uploadQueue")
38
+ .append("<div id='" + fileObj.id + "' class='nggUploadItem'> [<a href='javascript:removeFile(\"" + fileObj.id + "\");'>" + ngg_swf_upload.customSettings.remove + "</a>] " + fileObj.name + filesize + "</div>")
39
+ .children("div:last").slideDown("slow")
40
+ .end();
41
+ }
42
+
43
+ // start the upload
44
+ function submitFiles() {
45
+ // check if a gallery is selected
46
+ if (jQuery('#galleryselect').val() > "0") {
47
+ nggProgressBar.init(nggAjaxOptions);
48
+ // get old post_params
49
+ post_params = ngg_swf_upload.getSetting("post_params");
50
+ // update the selected gallery in the post_params
51
+ post_params['galleryselect'] = jQuery('#galleryselect').val();
52
+ ngg_swf_upload.setPostParams(post_params);
53
+ ngg_swf_upload.startUpload();
54
+ } else {
55
+ jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"-1\">");
56
+ jQuery("#uploadimage_form").submit();
57
+ }
58
+ }
59
+
60
+ // called when a file will be removed
61
+ function removeFile(fileID) {
62
+ ngg_swf_upload.cancelUpload(fileID);
63
+ jQuery("#" + fileID).hide("slow");
64
+ jQuery("#" + fileID).remove();
65
+ }
66
+
67
+ // called before the uploads start
68
+ function uploadStart(fileObj) {
69
+ nggProgressBar.init(nggAjaxOptions);
70
+ return true;
71
+ }
72
+
73
+ // called during the upload progress
74
+ function uploadProgress(fileObj, bytesLoaded) {
75
+ var percent = Math.ceil((bytesLoaded / fileObj.size) * 100);
76
+ nggProgressBar.increase( percent );
77
+ jQuery("#progressbar span").text(percent + "% - " + fileObj.name);
78
+ }
79
+
80
+ // called when the file is uploaded
81
+ function uploadComplete(fileObj) {
82
+ jQuery("#" + fileObj.id).hide("slow");
83
+ jQuery("#" + fileObj.id).remove();
84
+ if ( ngg_swf_upload.getStats().files_queued == 0) {
85
+ nggProgressBar.finished();
86
+ jQuery("#uploadimage_form").submit();
87
+ }
88
+ }
89
+
90
+ // called when all files are uploaded
91
+ function uploadSuccess(fileObj, server_data) {
92
+ // Show any error message
93
+ if (server_data != 0){
94
+ nggProgressBar.addNote("<strong>ERROR</strong>: " + fileObj.name + " : " + server_data);
95
+ }
96
+ // Upload the next file until queue is empty
97
+ if ( ngg_swf_upload.getStats().files_queued > 0) {
98
+ ngg_swf_upload.startUpload();
99
+ } else {
100
+ // server_data could be add as hidden field
101
+ jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"" + server_data + "\">");
102
+ }
103
+ }
104
+
105
+ // called on error
106
+ function uploadError(fileObj, error_code, message) {
107
+ var error_name = "";
108
+ switch(error_code) {
109
+ case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
110
+ error_name = "HTTP ERROR";
111
+ break;
112
+ case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
113
+ error_name = "MISSING UPLOAD URL";
114
+ break;
115
+ case SWFUpload.UPLOAD_ERROR.IO_ERROR:
116
+ error_name = "IO FAILURE";
117
+ break;
118
+ case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
119
+ error_name = "SECURITY ERROR";
120
+ break;
121
+ case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
122
+ error_name = "UPLOAD LIMIT EXCEEDED";
123
+ break;
124
+ case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
125
+ error_name = "UPLOAD FAILED";
126
+ break;
127
+ case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
128
+ error_name = "SPECIFIED FILE ID NOT FOUND";
129
+ break;
130
+ case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
131
+ error_name = "FILE VALIDATION FAILED";
132
+ break;
133
+ case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
134
+ error_name = "FILE CANCELLED";
135
+ return;
136
+ break;
137
+ case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
138
+ error_name = "FILE STOPPED";
139
+ break;
140
+ default:
141
+ error_name = "UNKNOWN";
142
+ break;
143
+ }
144
+ nggProgressBar.addNote("<strong>ERROR " + error_name + " </strong>: " + fileObj.name + " : " + message);
145
+ jQuery("#" + fileObj.id).hide("slow");
146
+ jQuery("#" + fileObj.id).remove();
147
+ if ( ngg_swf_upload.getStats().files_queued > 0) {
148
+ ngg_swf_upload.startUpload();
149
+ } else {
150
+ jQuery('#uploadimage_form').prepend("<input type=\"hidden\" name=\"swf_callback\" value=\"" + error_name + "\">");
151
+ jQuery("#uploadimage_form").submit();
152
+ }
153
+ }
admin/manage-galleries.php CHANGED
@@ -1,427 +1,429 @@
1
- <?php
2
-
3
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
-
5
- // *** show main gallery list
6
- function nggallery_manage_gallery_main() {
7
-
8
- global $ngg, $nggdb, $wp_query;
9
-
10
- //Build the pagination for more than 25 galleries
11
- $_GET['paged'] = isset($_GET['paged']) && ($_GET['paged'] > 0) ? absint($_GET['paged']) : 1;
12
-
13
- $items_per_page = 25;
14
-
15
- $start = ( $_GET['paged'] - 1 ) * $items_per_page;
16
-
17
- $order = ( isset ( $_GET['order'] ) && $_GET['order'] == 'desc' ) ? 'DESC' : 'ASC';
18
- $orderby = ( isset ( $_GET['orderby'] ) && ( in_array( $_GET['orderby'], array('gid', 'title', 'author') )) ) ? $_GET['orderby'] : 'gid';
19
-
20
- $gallerylist = $nggdb->find_all_galleries( $orderby, $order , TRUE, $items_per_page, $start, false);
21
- $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
22
-
23
- ?>
24
- <script type="text/javascript">
25
- <!--
26
- function checkAll(form)
27
- {
28
- for (i = 0, n = form.elements.length; i < n; i++) {
29
- if(form.elements[i].type == "checkbox") {
30
- if(form.elements[i].name == "doaction[]") {
31
- if(form.elements[i].checked == true)
32
- form.elements[i].checked = false;
33
- else
34
- form.elements[i].checked = true;
35
- }
36
- }
37
- }
38
- }
39
-
40
- function getNumChecked(form)
41
- {
42
- var num = 0;
43
- for (i = 0, n = form.elements.length; i < n; i++) {
44
- if(form.elements[i].type == "checkbox") {
45
- if(form.elements[i].name == "doaction[]")
46
- if(form.elements[i].checked == true)
47
- num++;
48
- }
49
- }
50
- return num;
51
- }
52
-
53
- // this function check for a the number of selected images, sumbmit false when no one selected
54
- function checkSelected() {
55
-
56
- if (typeof document.activeElement == "undefined" && document.addEventListener) {
57
- document.addEventListener("focus", function (e) {
58
- document.activeElement = e.target;
59
- }, true);
60
- }
61
-
62
- if ( document.activeElement.name == 'post_paged' )
63
- return true;
64
-
65
- var numchecked = getNumChecked(document.getElementById('editgalleries'));
66
-
67
- if(numchecked < 1) {
68
- alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?>');
69
- return false;
70
- }
71
-
72
- actionId = jQuery('#bulkaction').val();
73
-
74
- switch (actionId) {
75
- case "resize_images":
76
- showDialog('resize_images', '<?php echo esc_js(__('Resize images','nggallery')); ?>');
77
- return false;
78
- break;
79
- case "new_thumbnail":
80
- showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails','nggallery')); ?>');
81
- return false;
82
- break;
83
- }
84
-
85
- return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s galleries \n \n 'Cancel' to stop, 'OK' to proceed.",'nggallery')), "' + numchecked + '") ; ?>');
86
- }
87
-
88
- function showDialog( windowId, title ) {
89
- var form = document.getElementById('editgalleries');
90
- var elementlist = "";
91
- for (i = 0, n = form.elements.length; i < n; i++) {
92
- if(form.elements[i].type == "checkbox") {
93
- if(form.elements[i].name == "doaction[]")
94
- if(form.elements[i].checked == true)
95
- if (elementlist == "")
96
- elementlist = form.elements[i].value
97
- else
98
- elementlist += "," + form.elements[i].value ;
99
- }
100
- }
101
- jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
102
- jQuery("#" + windowId + "_imagelist").val(elementlist);
103
- // now show the dialog
104
- jQuery( "#" + windowId ).dialog({
105
- width: 640,
106
- resizable : false,
107
- modal: true,
108
- title: title
109
- });
110
- jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
111
- }
112
-
113
- function showAddGallery() {
114
- jQuery( "#addGallery").dialog({
115
- width: 640,
116
- resizable : false,
117
- modal: true,
118
- title: '<?php echo esc_js(__('Add new gallery','nggallery')); ?>'
119
- });
120
- jQuery("#addGallery .dialog-cancel").click(function() { jQuery( "#addGallery" ).dialog("close"); });
121
- }
122
- //-->
123
- </script>
124
- <div class="wrap">
125
- <?php include('templates/social_media_buttons.php'); ?>
126
- <?php screen_icon( 'nextgen-gallery' ); ?>
127
- <h2><?php echo _n( 'Gallery', 'Galleries', 2, 'nggallery'); ?></h2>
128
- <form class="search-form" action="" method="get">
129
- <p class="search-box">
130
- <label class="hidden" for="media-search-input"><?php _e( 'Search Images', 'nggallery' ); ?>:</label>
131
- <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
132
- <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
133
- <input type="submit" value="<?php _e( 'Search Images', 'nggallery' ); ?>" class="button" />
134
- </p>
135
- </form>
136
- <form id="editgalleries" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;paged=' . $_GET['paged']; ?>" accept-charset="utf-8">
137
- <?php wp_nonce_field('ngg_bulkgallery') ?>
138
- <input type="hidden" name="page" value="manage-galleries" />
139
-
140
- <div class="tablenav top">
141
-
142
- <div class="alignleft actions">
143
- <?php if ( function_exists('json_encode') ) : ?>
144
- <select name="bulkaction" id="bulkaction">
145
- <option value="no_action" ><?php _e("Bulk actions",'nggallery'); ?></option>
146
- <option value="delete_gallery" ><?php _e("Delete",'nggallery'); ?></option>
147
- <option value="set_watermark" ><?php _e("Set watermark",'nggallery'); ?></option>
148
- <option value="new_thumbnail" ><?php _e("Create new thumbnails",'nggallery'); ?></option>
149
- <option value="resize_images" ><?php _e("Resize images",'nggallery'); ?></option>
150
- <option value="import_meta" ><?php _e("Import metadata",'nggallery'); ?></option>
151
- <option value="recover_images" ><?php _e("Recover from backup",'nggallery'); ?></option>
152
- </select>
153
- <input name="showThickbox" class="button-secondary" type="submit" value="<?php _e('Apply','nggallery'); ?>" onclick="if ( !checkSelected() ) return false;" />
154
- <?php endif; ?>
155
- <?php if ( current_user_can('NextGEN Upload images') && nggGallery::current_user_can( 'NextGEN Add new gallery' ) ) : ?>
156
- <input name="doaction" class="button-secondary action" type="submit" onclick="showAddGallery(); return false;" value="<?php _e('Add new gallery', 'nggallery') ?>"/>
157
- <?php endif; ?>
158
- </div>
159
-
160
-
161
- <?php $ngg->manage_page->pagination( 'top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
162
-
163
- </div>
164
- <table class="wp-list-table widefat fixed" cellspacing="0">
165
- <thead>
166
- <tr>
167
- <?php $wp_list_table->print_column_headers(true); ?>
168
- </tr>
169
- </thead>
170
- <tfoot>
171
- <tr>
172
- <?php $wp_list_table->print_column_headers(false); ?>
173
- </tr>
174
- </tfoot>
175
- <tbody id="the-list">
176
- <?php
177
-
178
- if($gallerylist) {
179
- //get the columns
180
- $gallery_columns = $wp_list_table->get_columns();
181
- $hidden_columns = get_hidden_columns('nggallery-manage-gallery');
182
- $num_columns = count($gallery_columns) - count($hidden_columns);
183
-
184
- foreach($gallerylist as $gallery) {
185
- $alternate = ( !isset($alternate) || $alternate == 'class="alternate"' ) ? '' : 'class="alternate"';
186
- $gid = $gallery->gid;
187
- $name = (empty($gallery->title) ) ? $gallery->name : $gallery->title;
188
- $author_user = get_userdata( (int) $gallery->author );
189
- ?>
190
- <tr id="gallery-<?php echo $gid ?>" <?php echo $alternate; ?> >
191
- <?php
192
- foreach($gallery_columns as $gallery_column_key => $column_display_name) {
193
- $class = "class=\"$gallery_column_key column-$gallery_column_key\"";
194
-
195
- $style = '';
196
- if ( in_array($gallery_column_key, $hidden_columns) )
197
- $style = ' style="display:none;"';
198
-
199
- $attributes = "$class$style";
200
-
201
- switch ($gallery_column_key) {
202
- case 'cb' :
203
- ?>
204
- <th scope="row" class="column-cb check-column">
205
- <?php if (nggAdmin::can_manage_this_gallery($gallery->author)) { ?>
206
- <input name="doaction[]" type="checkbox" value="<?php echo $gid ?>" />
207
- <?php } ?>
208
- </th>
209
- <?php
210
- break;
211
- case 'id' :
212
- ?>
213
- <td <?php echo $attributes ?>><?php echo $gid; ?></td>
214
- <?php
215
- break;
216
- case 'title' :
217
- ?>
218
- <td class="title column-title">
219
- <?php if (nggAdmin::can_manage_this_gallery($gallery->author)) { ?>
220
- <a href="<?php echo wp_nonce_url( $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $gid, 'ngg_editgallery')?>" class='edit' title="<?php _e('Edit'); ?>" >
221
- <?php echo esc_html( nggGallery::i18n($name) ); ?>
222
- </a>
223
- <?php } else { ?>
224
- <?php echo esc_html( nggGallery::i18n($gallery->title) ); ?>
225
- <?php } ?>
226
- <div class="row-actions"></div>
227
- </td>
228
- <?php
229
- break;
230
- case 'description' :
231
- ?>
232
- <td <?php echo $attributes ?>><?php echo esc_html( nggGallery::i18n($gallery->galdesc) ); ?>&nbsp;</td>
233
- <?php
234
- break;
235
- case 'author' :
236
- ?>
237
- <td <?php echo $attributes ?>><?php echo esc_html( $author_user->display_name ); ?></td>
238
- <?php
239
- break;
240
- case 'page_id' :
241
- ?>
242
- <td <?php echo $attributes ?>><?php echo $gallery->pageid; ?></td>
243
- <?php
244
- break;
245
- case 'quantity' :
246
- ?>
247
- <td <?php echo $attributes ?>><?php echo $gallery->counter; ?></td>
248
- <?php
249
- break;
250
- default :
251
- ?>
252
- <td <?php echo $attributes ?>><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid); ?></td>
253
- <?php
254
- break;
255
- }
256
- } ?>
257
- </tr>
258
- <?php
259
- }
260
- } else {
261
- echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
262
- }
263
- ?>
264
- </tbody>
265
- </table>
266
- <div class="tablenav bottom">
267
- <?php $ngg->manage_page->pagination( 'bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
268
- </div>
269
- </form>
270
- </div>
271
- <!-- #addGallery -->
272
- <div id="addGallery" style="display: none;" >
273
- <form id="form-tags" method="POST" accept-charset="utf-8">
274
- <?php wp_nonce_field('ngg_addgallery'); ?>
275
- <input type="hidden" name="page" value="manage-galleries" />
276
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
277
- <tr>
278
- <td>
279
- <strong><?php _e('New Gallery', 'nggallery') ;?>:</strong> <input type="text" size="35" name="galleryname" value="" /><br />
280
- <?php if(!is_multisite()) { ?>
281
- <?php _e('Create a new , empty gallery below the folder', 'nggallery') ;?> <strong><?php echo $ngg->options['gallerypath']; ?></strong><br />
282
- <?php } ?>
283
- <i>( <?php _e('Allowed characters for file and folder names are', 'nggallery') ;?>: a-z, A-Z, 0-9, -, _ )</i>
284
- </td>
285
- </tr>
286
- <?php do_action('ngg_add_new_gallery_form'); ?>
287
- <tr align="right">
288
- <td class="submit">
289
- <input class="button-primary" type="submit" name="addgallery" value="<?php _e('OK','nggallery'); ?>" />
290
- &nbsp;
291
- <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
292
- </td>
293
- </tr>
294
- </table>
295
- </form>
296
- </div>
297
- <!-- /#addGallery -->
298
-
299
- <!-- #resize_images -->
300
- <div id="resize_images" style="display: none;" >
301
- <form id="form-resize-images" method="POST" accept-charset="utf-8">
302
- <?php wp_nonce_field('ngg_thickbox_form') ?>
303
- <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
304
- <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
305
- <input type="hidden" name="page" value="manage-galleries" />
306
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
307
- <tr valign="top">
308
- <td>
309
- <strong><?php _e('Resize Images to', 'nggallery'); ?>:</strong>
310
- </td>
311
- <td>
312
- <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?>" /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?>" />
313
- <br /><small><?php _e('Width x height (in pixel). NextCellent Gallery will keep ratio size','nggallery') ?></small>
314
- </td>
315
- </tr>
316
- <tr align="right">
317
- <td colspan="2" class="submit">
318
- <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?>" />
319
- &nbsp;
320
- <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
321
- </td>
322
- </tr>
323
- </table>
324
- </form>
325
- </div>
326
- <!-- /#resize_images -->
327
-
328
- <!-- #new_thumbnail -->
329
- <div id="new_thumbnail" style="display: none;" >
330
- <form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
331
- <?php wp_nonce_field('ngg_thickbox_form') ?>
332
- <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
333
- <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
334
- <input type="hidden" name="page" value="manage-galleries" />
335
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
336
- <tr valign="top">
337
- <th align="left"><?php _e('Width x height (in pixel)','nggallery') ?></th>
338
- <td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?>" /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?>" />
339
- <br /><small><?php _e('These values are maximum values ','nggallery') ?></small></td>
340
- </tr>
341
- <tr valign="top">
342
- <th align="left"><?php _e('Set fix dimension','nggallery') ?></th>
343
- <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
344
- <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails','nggallery') ?></small></td>
345
- </tr>
346
- <tr align="right">
347
- <td colspan="2" class="submit">
348
- <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery');?>" />
349
- &nbsp;
350
- <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
351
- </td>
352
- </tr>
353
- </table>
354
- </form>
355
- </div>
356
- <!-- /#new_thumbnail -->
357
-
358
- <?php
359
- }
360
-
361
- /**
362
- * Construtor class to create the table layout
363
- *
364
- * @package WordPress
365
- * @subpackage List_Table
366
- * @since 1.8.0
367
- * @access private
368
- */
369
- class _NGG_Galleries_List_Table extends WP_List_Table {
370
- var $_screen;
371
- var $_columns;
372
-
373
- function _NGG_Galleries_List_Table( $screen ) {
374
- if ( is_string( $screen ) )
375
- $screen = convert_to_screen( $screen );
376
-
377
- $this->_screen = $screen;
378
- $this->_columns = array() ;
379
-
380
- add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
381
- }
382
-
383
- function get_column_info() {
384
- $columns = get_column_headers( $this->_screen );
385
- $hidden = get_hidden_columns( $this->_screen );
386
- $_sortable = $this->get_sortable_columns();
387
-
388
- foreach ( $_sortable as $id => $data ) {
389
- if ( empty( $data ) )
390
- continue;
391
-
392
- $data = (array) $data;
393
- if ( !isset( $data[1] ) )
394
- $data[1] = false;
395
-
396
- $sortable[$id] = $data;
397
- }
398
-
399
- return array( $columns, $hidden, $sortable );
400
- }
401
-
402
- // define the columns to display, the syntax is 'internal name' => 'display name'
403
- function get_columns() {
404
- $columns = array();
405
-
406
- $columns['cb'] = '<input name="checkall" type="checkbox" onclick="checkAll(document.getElementById(\'editgalleries\'));" />';
407
- $columns['id'] = __('ID');
408
- $columns['title'] = _n( 'Gallery', 'Galleries', 1, 'nggallery');
409
- $columns['description'] = __('Description', 'nggallery');
410
- $columns['author'] = __('Author', 'nggallery');
411
- $columns['page_id'] = __('Page ID', 'nggallery');
412
- $columns['quantity'] = _n( 'Image', 'Images', 2, 'nggallery' );
413
-
414
- $columns = apply_filters('ngg_manage_gallery_columns', $columns);
415
-
416
- return $columns;
417
- }
418
-
419
- function get_sortable_columns() {
420
- return array(
421
- 'id' => array( 'gid', true ),
422
- 'title' => 'title',
423
- 'author' => 'author'
424
- );
425
- }
426
- }
 
 
427
  ?>
1
+ <?php
2
+
3
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
+
5
+ // *** show main gallery list
6
+ function nggallery_manage_gallery_main() {
7
+
8
+ global $ngg, $nggdb, $wp_query;
9
+
10
+ //Build the pagination for more than 25 galleries
11
+ $_GET['paged'] = isset($_GET['paged']) && ($_GET['paged'] > 0) ? absint($_GET['paged']) : 1;
12
+
13
+ $items_per_page = 25;
14
+
15
+ $start = ( $_GET['paged'] - 1 ) * $items_per_page;
16
+
17
+ $order = ( isset ( $_GET['order'] ) && $_GET['order'] == 'desc' ) ? 'DESC' : 'ASC';
18
+ $orderby = ( isset ( $_GET['orderby'] ) && ( in_array( $_GET['orderby'], array('gid', 'title', 'author') )) ) ? $_GET['orderby'] : 'gid';
19
+
20
+ $gallerylist = $nggdb->find_all_galleries( $orderby, $order , TRUE, $items_per_page, $start, false);
21
+ $wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
22
+
23
+ ?>
24
+ <script type="text/javascript">
25
+ <!--
26
+ function checkAll(form)
27
+ {
28
+ for (i = 0, n = form.elements.length; i < n; i++) {
29
+ if(form.elements[i].type == "checkbox") {
30
+ if(form.elements[i].name == "doaction[]") {
31
+ if(form.elements[i].checked == true)
32
+ form.elements[i].checked = false;
33
+ else
34
+ form.elements[i].checked = true;
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ function getNumChecked(form)
41
+ {
42
+ var num = 0;
43
+ for (i = 0, n = form.elements.length; i < n; i++) {
44
+ if(form.elements[i].type == "checkbox") {
45
+ if(form.elements[i].name == "doaction[]")
46
+ if(form.elements[i].checked == true)
47
+ num++;
48
+ }
49
+ }
50
+ return num;
51
+ }
52
+
53
+ // this function check for a the number of selected images, sumbmit false when no one selected
54
+ function checkSelected() {
55
+
56
+ if (typeof document.activeElement == "undefined" && document.addEventListener) {
57
+ document.addEventListener("focus", function (e) {
58
+ document.activeElement = e.target;
59
+ }, true);
60
+ }
61
+
62
+ if ( document.activeElement.name == 'post_paged' )
63
+ return true;
64
+
65
+ var numchecked = getNumChecked(document.getElementById('editgalleries'));
66
+
67
+ if(numchecked < 1) {
68
+ alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?>');
69
+ return false;
70
+ }
71
+
72
+ actionId = jQuery('#bulkaction').val();
73
+
74
+ switch (actionId) {
75
+ case "resize_images":
76
+ showDialog('resize_images', '<?php echo esc_js(__('Resize images','nggallery')); ?>');
77
+ return false;
78
+ break;
79
+ case "new_thumbnail":
80
+ showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails','nggallery')); ?>');
81
+ return false;
82
+ break;
83
+ }
84
+
85
+ return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s galleries \n \n 'Cancel' to stop, 'OK' to proceed.",'nggallery')), "' + numchecked + '") ; ?>');
86
+ }
87
+
88
+ function showDialog( windowId, title ) {
89
+ var form = document.getElementById('editgalleries');
90
+ var elementlist = "";
91
+ for (i = 0, n = form.elements.length; i < n; i++) {
92
+ if(form.elements[i].type == "checkbox") {
93
+ if(form.elements[i].name == "doaction[]")
94
+ if(form.elements[i].checked == true)
95
+ if (elementlist == "")
96
+ elementlist = form.elements[i].value
97
+ else
98
+ elementlist += "," + form.elements[i].value ;
99
+ }
100
+ }
101
+ jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
102
+ jQuery("#" + windowId + "_imagelist").val(elementlist);
103
+ // now show the dialog
104
+ jQuery( "#" + windowId ).dialog({
105
+ width: 640,
106
+ resizable : false,
107
+ modal: true,
108
+ title: title
109
+ });
110
+ jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
111
+ }
112
+
113
+ function showAddGallery() {
114
+ jQuery( "#addGallery").dialog({
115
+ width: '70%',
116
+ resizable : false,
117
+ modal: true,
118
+ title: '<?php echo esc_js(__('Add new gallery','nggallery')); ?>'
119
+ });
120
+ jQuery("#addGallery .dialog-cancel").click(function() { jQuery( "#addGallery" ).dialog("close"); });
121
+ }
122
+ //-->
123
+ </script>
124
+ <div class="wrap">
125
+ <?php screen_icon( 'nextgen-gallery' ); ?>
126
+ <h2><?php echo _e( 'Galleries', 'nggallery');?>
127
+ <form id="addgalleries" class="nggform add-new-form" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;paged=' . $_GET['paged']; ?>" accept-charset="utf-8"><?php if ( current_user_can('NextGEN Upload images') && nggGallery::current_user_can( 'NextGEN Add new gallery' ) ) : ?>
128
+ <input name="doaction" class="add-new-h2" type="submit" onclick="showAddGallery(); return false;" value="<?php _e('Add new gallery', 'nggallery') ?>"/>
129
+ <?php endif; ?></form></h2>
130
+ <form class="search-form" action="" method="get">
131
+ <p class="search-box">
132
+ <label class="hidden" for="media-search-input"><?php _e( 'Search Images', 'nggallery' ); ?>:</label>
133
+ <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
134
+ <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
135
+ <input type="submit" value="<?php _e( 'Search Images', 'nggallery' ); ?>" class="button" />
136
+ </p>
137
+ </form>
138
+ <form id="editgalleries" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;paged=' . $_GET['paged']; ?>" accept-charset="utf-8">
139
+ <?php wp_nonce_field('ngg_bulkgallery') ?>
140
+ <input type="hidden" name="page" value="manage-galleries" />
141
+
142
+ <div class="tablenav top">
143
+
144
+ <div class="alignleft actions">
145
+ <?php if ( function_exists('json_encode') ) : ?>
146
+ <select name="bulkaction" id="bulkaction">
147
+ <option value="no_action" ><?php _e("Actions",'nggallery'); ?></option>
148
+ <option value="delete_gallery" ><?php _e("Delete",'nggallery'); ?></option>
149
+ <option value="set_watermark" ><?php _e("Set watermark",'nggallery'); ?></option>
150
+ <option value="new_thumbnail" ><?php _e("Create new thumbnails",'nggallery'); ?></option>
151
+ <option value="resize_images" ><?php _e("Resize images",'nggallery'); ?></option>
152
+ <option value="import_meta" ><?php _e("Import metadata",'nggallery'); ?></option>
153
+ <option value="recover_images" ><?php _e("Recover from backup",'nggallery'); ?></option>
154
+ </select>
155
+ <input name="showThickbox" class="button-secondary" type="submit" value="<?php _e('Apply','nggallery'); ?>" onclick="if ( !checkSelected() ) return false;" />
156
+ <?php endif; ?>
157
+ </div>
158
+
159
+
160
+ <?php $ngg->manage_page->pagination( 'top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
161
+
162
+ </div>
163
+ <table class="wp-list-table widefat fixed" cellspacing="0">
164
+ <thead>
165
+ <tr>
166
+ <?php $wp_list_table->print_column_headers(true); ?>
167
+ </tr>
168
+ </thead>
169
+ <tfoot>
170
+ <tr>
171
+ <?php $wp_list_table->print_column_headers(false); ?>
172
+ </tr>
173
+ </tfoot>
174
+ <tbody id="the-list">
175
+ <?php
176
+
177
+ if($gallerylist) {
178
+ //get the columns
179
+ $gallery_columns = $wp_list_table->get_columns();
180
+ $hidden_columns = get_hidden_columns('nggallery-manage-gallery');
181
+ $num_columns = count($gallery_columns) - count($hidden_columns);
182
+
183
+ foreach($gallerylist as $gallery) {
184
+ $alternate = ( !isset($alternate) || $alternate == 'class="alternate"' ) ? '' : 'class="alternate"';
185
+ $gid = $gallery->gid;
186
+ $name = (empty($gallery->title) ) ? $gallery->name : $gallery->title;
187
+ $author_user = get_userdata( (int) $gallery->author );
188
+ ?>
189
+ <tr id="gallery-<?php echo $gid ?>" <?php echo $alternate; ?> >
190
+ <?php
191
+ foreach($gallery_columns as $gallery_column_key => $column_display_name) {
192
+ $class = "class=\"$gallery_column_key column-$gallery_column_key\"";
193
+
194
+ $style = '';
195
+ if ( in_array($gallery_column_key, $hidden_columns) )
196
+ $style = ' style="display:none;"';
197
+
198
+ $attributes = "$class$style";
199
+
200
+ switch ($gallery_column_key) {
201
+ case 'cb' :
202
+ ?>
203
+ <th scope="row" class="column-cb check-column">
204
+ <?php if (nggAdmin::can_manage_this_gallery($gallery->author)) { ?>
205
+ <input name="doaction[]" type="checkbox" value="<?php echo $gid ?>" />
206
+ <?php } ?>
207
+ </th>
208
+ <?php
209
+ break;
210
+ case 'id' :
211
+ ?>
212
+ <td <?php echo $attributes ?>><?php echo $gid; ?></td>
213
+ <?php
214
+ break;
215
+ case 'title' :
216
+ ?>
217
+ <td class="title column-title">
218
+ <?php if (nggAdmin::can_manage_this_gallery($gallery->author)) { ?>
219
+ <a href="<?php echo wp_nonce_url( $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $gid, 'ngg_editgallery')?>" class='edit' title="<?php _e('Edit'); ?>" >
220
+ <?php echo esc_html( nggGallery::i18n($name) ); ?>
221
+ </a>
222
+ <?php } else { ?>
223
+ <?php echo esc_html( nggGallery::i18n($gallery->title) ); ?>
224
+ <?php } ?>
225
+ <div class="row-actions"></div>
226
+ </td>
227
+ <?php
228
+ break;
229
+ case 'description' :
230
+ ?>
231
+ <td <?php echo $attributes ?>><?php echo esc_html( nggGallery::i18n($gallery->galdesc) ); ?>&nbsp;</td>
232
+ <?php
233
+ break;
234
+ case 'author' :
235
+ ?>
236
+ <td <?php echo $attributes ?>><?php echo esc_html( $author_user->display_name ); ?></td>
237
+ <?php
238
+ break;
239
+ case 'page_id' :
240
+ ?>
241
+ <td <?php echo $attributes ?>><?php echo $gallery->pageid; ?></td>
242
+ <?php
243
+ break;
244
+ case 'quantity' :
245
+ ?>
246
+ <td <?php echo $attributes ?>><?php echo $gallery->counter; ?></td>
247
+ <?php
248
+ break;
249
+ default :
250
+ ?>
251
+ <td <?php echo $attributes ?>><?php do_action('ngg_manage_gallery_custom_column', $gallery_column_key, $gid); ?></td>
252
+ <?php
253
+ break;
254
+ }
255
+ } ?>
256
+ </tr>
257
+ <?php
258
+ }
259
+ } else {
260
+ echo '<tr><td colspan="7" align="center"><strong>' . __('No entries found', 'nggallery') . '</strong></td></tr>';
261
+ }
262
+ ?>
263
+ </tbody>
264
+ </table>
265
+ <div class="tablenav bottom">
266
+ <?php $ngg->manage_page->pagination( 'bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
267
+ </div>
268
+ </form>
269
+ </div>
270
+ <!-- #addGallery -->
271
+ <div id="addGallery" style="display: none; background: white;" >
272
+ <form id="form-tags" method="POST" accept-charset="utf-8">
273
+ <?php wp_nonce_field('ngg_addgallery'); ?>
274
+ <input type="hidden" name="page" value="manage-galleries" />
275
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
276
+ <tr>
277
+ <td>
278
+ <strong><?php _e('New Gallery', 'nggallery') ;?>:</strong> <input type="text" size="35" name="galleryname" value="" /><br />
279
+ <?php if(!is_multisite()) { ?>
280
+ <?php _e('Create a new , empty gallery below the folder', 'nggallery') ;?> <strong><?php echo $ngg->options['gallerypath']; ?></strong><br />
281
+ <?php } ?>
282
+ <i>(<?php _e('Allowed characters for file and folder names are', 'nggallery') ;?>: a-z, A-Z, 0-9, -, _)</i>
283
+ </td>
284
+ </tr>
285
+ <?php do_action('ngg_add_new_gallery_form'); ?>
286
+ <tr align="right">
287
+ <td class="submit">
288
+ <input class="button-primary" type="submit" name="addgallery" value="<?php _e('OK','nggallery'); ?>" />
289
+ &nbsp;
290
+ <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
291
+ </td>
292
+ </tr>
293
+ </table>
294
+ </form>
295
+ </div>
296
+ <!-- /#addGallery -->
297
+
298
+ <!-- #resize_images -->
299
+ <div id="resize_images" style="display: none;" >
300
+ <form id="form-resize-images" method="POST" accept-charset="utf-8">
301
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
302
+ <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
303
+ <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
304
+ <input type="hidden" name="page" value="manage-galleries" />
305
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
306
+ <tr valign="top">
307
+ <td>
308
+ <strong><?php _e('Resize Images to', 'nggallery'); ?>:</strong>
309
+ </td>
310
+ <td>
311
+ <label for="imgWidth"><?php _e('Width','nggallery') ?></label>
312
+ <input type="number" step="1" min="0" class="small-text" name="imgWidth" class="small-text" value="<?php echo $ngg->options['imgWidth']; ?>" />
313
+ <label for="imgHeight"><?php _e('Height','nggallery') ?></label>
314
+ <input type="number" step="1" min="0" type="text" size="5" name="imgHeight" class="small-text" value="<?php echo $ngg->options['imgHeight']; ?>">
315
+ <p class="description"><?php _e('Width and height (in pixels). NextCellent Gallery will keep the ratio size.','nggallery') ?></p>
316
+ </td>
317
+ </tr>
318
+ <tr align="right">
319
+ <td colspan="2" class="submit">
320
+ <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?>" />
321
+ &nbsp;
322
+ <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
323
+ </td>
324
+ </tr>
325
+ </table>
326
+ </form>
327
+ </div>
328
+ <!-- /#resize_images -->
329
+
330
+ <!-- #new_thumbnail -->
331
+ <div id="new_thumbnail" style="display: none;" >
332
+ <form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
333
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
334
+ <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
335
+ <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
336
+ <input type="hidden" name="page" value="manage-galleries" />
337
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
338
+ <tr valign="top">
339
+ <th align="left"><?php _e('Size','nggallery') ?></th>
340
+ <td><label for="thumbwidth"><?php _e('Width','nggallery') ?> </label><input class="small-text" type="number" step="1" min="0" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?>" /> <label for="thumbheight"><?php _e('Height','nggallery') ?> </label><input class="small-text" type="number" step="1" min="0" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?>" />
341
+ <p class="description"><?php _e('These values are maximum values ','nggallery') ?></p></td>
342
+ </tr>
343
+ <tr valign="top">
344
+ <th align="left"><?php _e('Fixed size','nggallery'); ?></th>
345
+ <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
346
+ <?php _e('This will ignore the aspect ratio, so no portrait thumbnails','nggallery') ?></td>
347
+ </tr>
348
+ <tr align="right">
349
+ <td colspan="2" class="submit">
350
+ <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery');?>" />
351
+ &nbsp;
352
+ <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
353
+ </td>
354
+ </tr>
355
+ </table>
356
+ </form>
357
+ </div>
358
+ <!-- /#new_thumbnail -->
359
+
360
+ <?php
361
+ }
362
+
363
+ /**
364
+ * Construtor class to create the table layout
365
+ *
366
+ * @package WordPress
367
+ * @subpackage List_Table
368
+ * @since 1.8.0
369
+ * @access private
370
+ */
371
+ class _NGG_Galleries_List_Table extends WP_List_Table {
372
+ var $_screen;
373
+ var $_columns;
374
+
375
+ function _NGG_Galleries_List_Table( $screen ) {
376
+ if ( is_string( $screen ) )
377
+ $screen = convert_to_screen( $screen );
378
+
379
+ $this->_screen = $screen;
380
+ $this->_columns = array() ;
381
+
382
+ add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
383
+ }
384
+
385
+ function get_column_info() {
386
+ $columns = get_column_headers( $this->_screen );
387
+ $hidden = get_hidden_columns( $this->_screen );
388
+ $_sortable = $this->get_sortable_columns();
389
+
390
+ foreach ( $_sortable as $id => $data ) {
391
+ if ( empty( $data ) )
392
+ continue;
393
+
394
+ $data = (array) $data;
395
+ if ( !isset( $data[1] ) )
396
+ $data[1] = false;
397
+
398
+ $sortable[$id] = $data;
399
+ }
400
+
401
+ return array( $columns, $hidden, $sortable );
402
+ }
403
+
404
+ // define the columns to display, the syntax is 'internal name' => 'display name'
405
+ function get_columns() {
406
+ $columns = array();
407
+
408
+ $columns['cb'] = '<input name="checkall" type="checkbox" onclick="checkAll(document.getElementById(\'editgalleries\'));" />';
409
+ $columns['id'] = __('ID');
410
+ $columns['title'] = __( 'Title', 'nggallery');
411
+ $columns['description'] = __('Description', 'nggallery');
412
+ $columns['author'] = __('Author', 'nggallery');
413
+ $columns['page_id'] = __('Page ID', 'nggallery');
414
+ $columns['quantity'] = '<div class="images-grey-bubble" title="' . __( 'Images', 'nggallery' ) . '"></div>';
415
+
416
+ $columns = apply_filters('ngg_manage_gallery_columns', $columns);
417
+
418
+ return $columns;
419
+ }
420
+
421
+ function get_sortable_columns() {
422
+ return array(
423
+ 'id' => array( 'gid', true ),
424
+ 'title' => 'title',
425
+ 'author' => 'author'
426
+ );
427
+ }
428
+ }
429
  ?>
admin/manage-images.php CHANGED
@@ -1,715 +1,744 @@
1
- <?php
2
-
3
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.');}
4
-
5
- function nggallery_picturelist() {
6
- // *** show picture list
7
- global $wpdb, $nggdb, $user_ID, $ngg;
8
-
9
- // Look if its a search result
10
- $is_search = isset ($_GET['s']) ? true : false;
11
- $counter = 0;
12
-
13
- $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
14
-
15
- if ($is_search) {
16
-
17
- // fetch the imagelist
18
- $picturelist = $ngg->manage_page->search_result;
19
-
20
- // we didn't set a gallery or a pagination
21
- $act_gid = 0;
22
- $_GET['paged'] = 1;
23
- $page_links = false;
24
-
25
- } else {
26
-
27
- // GET variables
28
- $act_gid = $ngg->manage_page->gid;
29
-
30
- // Load the gallery metadata
31
- $gallery = $nggdb->find_gallery($act_gid);
32
-
33
- if (!$gallery) {
34
- nggGallery::show_error(__('Gallery not found.', 'nggallery'));
35
- return;
36
- }
37
-
38
- // Check if you have the correct capability
39
- if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
40
- nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
41
- return;
42
- }
43
-
44
- // look for pagination
45
- $_GET['paged'] = isset($_GET['paged']) && ($_GET['paged'] > 0) ? absint($_GET['paged']) : 1;
46
-
47
- $start = ( $_GET['paged'] - 1 ) * 50;
48
-
49
- // get picture values
50
- $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start );
51
-
52
- // get the current author
53
- $act_author_user = get_userdata( (int) $gallery->author );
54
-
55
- }
56
-
57
- // list all galleries
58
- $gallerylist = $nggdb->find_all_galleries();
59
-
60
- //get the columns
61
- $image_columns = $wp_list_table->get_columns();
62
- $hidden_columns = get_hidden_columns('nggallery-manage-images');
63
- $num_columns = count($image_columns) - count($hidden_columns);
64
-
65
- $attr = (nggGallery::current_user_can( 'NextGEN Edit gallery options' )) ? '' : 'disabled="disabled"';
66
-
67
- ?>
68
- <script type="text/javascript">
69
- <!--
70
- function showDialog( windowId, title ) {
71
- var form = document.getElementById('updategallery');
72
- var elementlist = "";
73
- for (i = 0, n = form.elements.length; i < n; i++) {
74
- if(form.elements[i].type == "checkbox") {
75
- if(form.elements[i].name == "doaction[]")
76
- if(form.elements[i].checked == true)
77
- if (elementlist == "")
78
- elementlist = form.elements[i].value
79
- else
80
- elementlist += "," + form.elements[i].value ;
81
- }
82
- }
83
- jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
84
- jQuery("#" + windowId + "_imagelist").val(elementlist);
85
- // now show the dialog
86
- jQuery( "#" + windowId ).dialog({
87
- width: 640,
88
- resizable : false,
89
- modal: true,
90
- title: title
91
- });
92
- jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
93
- }
94
-
95
- jQuery(function (){
96
- // load a content via ajax
97
- jQuery('a.ngg-dialog').click(function() {
98
- if ( jQuery( "#spinner" ).length == 0)
99
- jQuery("body").append('<div id="spinner"></div>');
100
- var $this = jQuery(this);
101
- var results = new RegExp('[\\?&]w=([^&#]*)').exec(this.href);
102
- var width = ( results ) ? results[1] : 600;
103
- var results = new RegExp('[\\?&]h=([^&#]*)').exec(this.href);
104
- var height = ( results ) ? results[1] : 440;
105
- jQuery('#spinner').fadeIn();
106
- var dialog = jQuery('<div style="display:hidden"></div>').appendTo('body');
107
- // load the remote content
108
- dialog.load(
109
- this.href,
110
- {},
111
- function () {
112
- jQuery('#spinner').hide();
113
- dialog.dialog({
114
- title: ($this.attr('title')) ? $this.attr('title') : '',
115
- width: width,
116
- height: height,
117
- modal: true,
118
- resizable: false,
119
- close: function() { dialog.remove(); }
120
- }).width(width - 30).height(height - 30);
121
- }
122
- );
123
- //prevent the browser to follow the link
124
- return false;
125
- });
126
- });
127
-
128
- function checkAll(form)
129
- {
130
- for (i = 0, n = form.elements.length; i < n; i++) {
131
- if(form.elements[i].type == "checkbox") {
132
- if(form.elements[i].name == "doaction[]") {
133
- if(form.elements[i].checked == true)
134
- form.elements[i].checked = false;
135
- else
136
- form.elements[i].checked = true;
137
- }
138
- }
139
- }
140
- }
141
-
142
- function getNumChecked(form)
143
- {
144
- var num = 0;
145
- for (i = 0, n = form.elements.length; i < n; i++) {
146
- if(form.elements[i].type == "checkbox") {
147
- if(form.elements[i].name == "doaction[]")
148
- if(form.elements[i].checked == true)
149
- num++;
150
- }
151
- }
152
- return num;
153
- }
154
-
155
- // this function check for a the number of selected images, sumbmit false when no one selected
156
- function checkSelected() {
157
-
158
- var numchecked = getNumChecked(document.getElementById('updategallery'));
159
-
160
- if (typeof document.activeElement == "undefined" && document.addEventListener) {
161
- document.addEventListener("focus", function (e) {
162
- document.activeElement = e.target;
163
- }, true);
164
- }
165
-
166
- if ( document.activeElement.name == 'post_paged' )
167
- return true;
168
-
169
- if(numchecked < 1) {
170
- alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?>');
171
- return false;
172
- }
173
-
174
- actionId = jQuery('#bulkaction').val();
175
-
176
- switch (actionId) {
177
- case "copy_to":
178
- showDialog('selectgallery', '<?php echo esc_js(__('Copy image to...','nggallery')); ?>');
179
- return false;
180
- break;
181
- case "move_to":
182
- showDialog('selectgallery', '<?php echo esc_js(__('Move image to...','nggallery')); ?>');
183
- return false;
184
- break;
185
- case "add_tags":
186
- showDialog('entertags', '<?php echo esc_js(__('Add new tags','nggallery')); ?>');
187
- return false;
188
- break;
189
- case "delete_tags":
190
- showDialog('entertags', '<?php echo esc_js(__('Delete tags','nggallery')); ?>');
191
- return false;
192
- break;
193
- case "overwrite_tags":
194
- showDialog('entertags', '<?php echo esc_js(__('Overwrite','nggallery')); ?>');
195
- return false;
196
- break;
197
- case "resize_images":
198
- showDialog('resize_images', '<?php echo esc_js(__('Resize images','nggallery')); ?>');
199
- return false;
200
- break;
201
- case "new_thumbnail":
202
- showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails','nggallery')); ?>');
203
- return false;
204
- break;
205
- }
206
-
207
- return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.",'nggallery')), "' + numchecked + '") ; ?>');
208
- }
209
-
210
- jQuery(document).ready( function() {
211
- // close postboxes that should be closed
212
- jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
213
- postboxes.add_postbox_toggles('ngg-manage-gallery');
214
- });
215
-
216
- //-->
217
- </script>
218
- <div class="wrap">
219
- <?php include('templates/social_media_buttons.php'); ?>
220
- <?php screen_icon( 'nextgen-gallery' ); ?>
221
- <?php if ($is_search) :?>
222
- <h2><?php printf( __('Search results for &#8220;%s&#8221;', 'nggallery'), esc_html( get_search_query() ) ); ?></h2>
223
- <form class="search-form" action="" method="get">
224
- <p class="search-box">
225
- <label class="hidden" for="media-search-input"><?php _e( 'Search Images', 'nggallery' ); ?>:</label>
226
- <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
227
- <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
228
- <input type="submit" value="<?php _e( 'Search Images', 'nggallery' ); ?>" class="button" />
229
- </p>
230
- </form>
231
-
232
- <br style="clear: both;" />
233
-
234
- <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . get_search_query(); ?>" accept-charset="utf-8">
235
- <?php wp_nonce_field('ngg_updategallery') ?>
236
- <input type="hidden" name="page" value="manage-images" />
237
-
238
- <?php else :?>
239
- <h2><?php echo _n( 'Gallery', 'Galleries', 1, 'nggallery' ); ?> : <?php echo esc_html ( nggGallery::i18n($gallery->title) ); ?></h2>
240
-
241
- <br style="clear: both;" />
242
-
243
- <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . $_GET['paged']; ?>" accept-charset="utf-8">
244
- <?php wp_nonce_field('ngg_updategallery') ?>
245
- <input type="hidden" name="page" value="manage-images" />
246
-
247
- <?php if ( nggGallery::current_user_can( 'NextGEN Edit gallery options' )) : ?>
248
- <div id="poststuff">
249
- <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
250
- <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?>" >
251
- <h3><?php _e('Gallery settings', 'nggallery') ?><small> (<?php _e('Click here for more settings', 'nggallery') ?>)</small></h3>
252
- <div class="inside">
253
- <table class="form-table" >
254
- <tr>
255
- <th align="left"><?php _e('Title') ?>:</th>
256
- <th align="left"><input <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery title' ); ?> type="text" size="50" name="title" value="<?php echo $gallery->title; ?>" /></th>
257
- <th align="right"><?php _e('Page Link to', 'nggallery') ?>:</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>
267
- <tr>
268
- <th align="left"><?php _e('Description') ?>:</th>
269
- <th align="left"><textarea <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery description' ); ?> name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php echo $gallery->galdesc; ?></textarea></th>
270
- <th align="right"><?php _e('Preview image', 'nggallery') ?>:</th>
271
- <th align="left">
272
- <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery preview pic' ); ?> name="previewpic" style="width:95%" >
273
- <option value="0" ><?php _e('No Picture', 'nggallery') ?></option>
274
- <?php
275
- // ensure that a preview pic from a other page is still shown here
276
- if ( intval($gallery->previewpic) != 0) {
277
- if ( !array_key_exists ($gallery->previewpic, $picturelist )){
278
- $previewpic = $nggdb->find_image($gallery->previewpic);
279
- if ($previewpic)
280
- echo '<option value="'.$previewpic->pid.'" selected="selected" >'.$previewpic->pid.' - ' . esc_attr( $previewpic->filename ) . '</option>'."\n";
281
- }
282
- }
283
- if(is_array($picturelist)) {
284
- foreach($picturelist as $picture) {
285
- if ($picture->exclude) continue;
286
- $selected = ($picture->pid == $gallery->previewpic) ? 'selected="selected" ' : '';
287
- echo '<option value="'.$picture->pid.'" '.$selected.'>'.$picture->pid.' - ' . esc_attr( $picture->filename ) . '</option>'."\n";
288
- }
289
- }
290
- ?>
291
- </select>
292
- </th>
293
- </tr>
294
- <tr>
295
- <th align="left"><?php _e('Path', 'nggallery') ?>:</th>
296
- <th align="left"><input <?php if ( is_multisite() ) echo 'readonly = "readonly"'; ?> <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery path' ); ?> type="text" size="50" name="path" value="<?php echo $gallery->path; ?>" /></th>
297
- <th align="right"><?php _e('Author', 'nggallery'); ?>:</th>
298
- <th align="left">
299
- <?php
300
- $editable_ids = $ngg->manage_page->get_editable_user_ids( $user_ID );
301
- if ( $editable_ids && count( $editable_ids ) > 1 && nggGallery::current_user_can( 'NextGEN Edit gallery author') )
302
- wp_dropdown_users( array('include' => $editable_ids, 'name' => 'author', 'selected' => empty( $gallery->author ) ? 0 : $gallery->author ) );
303
- else
304
- echo $act_author_user->display_name;
305
- ?>
306
- </th>
307
- </tr>
308
- <?php if(current_user_can( 'publish_pages' )) : ?>
309
- <tr>
310
- <th align="left">&nbsp;</th>
311
- <th align="left">&nbsp;</th>
312
- <th align="right"><?php _e('Create new page', 'nggallery') ?>:</th>
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>
322
- </tr>
323
- <?php endif; ?>
324
- <?php do_action('ngg_manage_gallery_settings', $act_gid); ?>
325
-
326
- </table>
327
-
328
- <div class="submit">
329
- <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images",'nggallery'); ?> " />
330
- <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes",'nggallery'); ?>" />
331
- </div>
332
-
333
- </div>
334
- </div>
335
- </div> <!-- poststuff -->
336
- <?php endif; ?>
337
-
338
- <?php endif; ?>
339
-
340
- <div class="tablenav top ngg-tablenav">
341
- <?php $ngg->manage_page->pagination( 'top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
342
- <div class="alignleft actions">
343
- <select id="bulkaction" name="bulkaction">
344
- <option value="no_action" ><?php _e("Bulk actions",'nggallery'); ?></option>
345
- <option value="set_watermark" ><?php _e("Set watermark",'nggallery'); ?></option>
346
- <option value="new_thumbnail" ><?php _e("Create new thumbnails",'nggallery'); ?></option>
347
- <option value="resize_images" ><?php _e("Resize images",'nggallery'); ?></option>
348
- <option value="recover_images" ><?php _e("Recover from backup",'nggallery'); ?></option>
349
- <option value="delete_images" ><?php _e("Delete images",'nggallery'); ?></option>
350
- <option value="import_meta" ><?php _e("Import metadata",'nggallery'); ?></option>
351
- <option value="rotate_cw" ><?php _e("Rotate images clockwise",'nggallery'); ?></option>
352
- <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise",'nggallery'); ?></option>
353
- <option value="copy_to" ><?php _e("Copy to...",'nggallery'); ?></option>
354
- <option value="move_to"><?php _e("Move to...",'nggallery'); ?></option>
355
- <option value="add_tags" ><?php _e("Add tags",'nggallery'); ?></option>
356
- <option value="delete_tags" ><?php _e("Delete tags",'nggallery'); ?></option>
357
- <option value="overwrite_tags" ><?php _e("Overwrite tags",'nggallery'); ?></option>
358
- </select>
359
- <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?>" onclick="if ( !checkSelected() ) return false;" />
360
-
361
- <?php if (($ngg->options['galSort'] == "sortorder") && (!$is_search) ) { ?>
362
- <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery');?>" />
363
- <?php } ?>
364
-
365
- <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery');?>" />
366
- </div>
367
- </div>
368
-
369
- <table id="ngg-listimages" class="widefat fixed" cellspacing="0" >
370
-
371
- <thead>
372
- <tr>
373
- <?php $wp_list_table->print_column_headers(true); ?>
374
- </tr>
375
- </thead>
376
- <tfoot>
377
- <tr>
378
- <?php $wp_list_table->print_column_headers(false); ?>
379
- </tr>
380
- </tfoot>
381
- <tbody id="the-list">
382
- <?php
383
- if($picturelist) {
384
-
385
- $thumbsize = '';
386
-
387
- if ($ngg->options['thumbfix'])
388
- $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
389
-
390
- foreach($picturelist as $picture) {
391
-
392
- //for search result we need to check the capatibiliy
393
- if ( !nggAdmin::can_manage_this_gallery($picture->author) && $is_search )
394
- continue;
395
-
396
- $counter++;
397
- $pid = (int) $picture->pid;
398
- $alternate = ( !isset($alternate) || $alternate == 'alternate' ) ? '' : 'alternate';
399
- $exclude = ( $picture->exclude ) ? 'checked="checked"' : '';
400
- $date = mysql2date(get_option('date_format'), $picture->imagedate);
401
- $time = mysql2date(get_option('time_format'), $picture->imagedate);
402
-
403
- ?>
404
- <tr id="picture-<?php echo $pid ?>" class="<?php echo $alternate ?> iedit" valign="top">
405
- <?php
406
- foreach($image_columns as $image_column_key => $column_display_name) {
407
- $class = "class='$image_column_key column-$image_column_key'";
408
-
409
- $style = '';
410
- if ( in_array($image_column_key, $hidden_columns) )
411
- $style = ' style="display:none;"';
412
-
413
- $attributes = $class . $style;
414
-
415
- switch ($image_column_key) {
416
- case 'cb' :
417
- $attributes = 'class="column-cb check-column"' . $style;
418
- ?>
419
- <th <?php echo $attributes ?> scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid ?>" /></th>
420
- <?php
421
- break;
422
- case 'id' :
423
- ?>
424
- <td <?php echo $attributes ?> style=""><?php echo $pid; ?>
425
- <input type="hidden" name="pid[]" value="<?php echo $pid ?>" />
426
- </td>
427
- <?php
428
- break;
429
- case 'filename' :
430
- $attributes = 'class="title column-filename column-title"' . $style;
431
- ?>
432
- <td <?php echo $attributes ?>>
433
- <strong><a href="<?php echo esc_url( $picture->imageURL ); ?>" class="thickbox" title="<?php echo esc_attr ($picture->filename); ?>">
434
- <?php echo ( empty($picture->alttext) ) ? esc_html( $picture->filename ) : esc_html( stripslashes(nggGallery::i18n($picture->alttext)) ); ?>
435
- </a></strong>
436
- <br /><?php echo $date; ?>
437
- <?php if ( !empty($picture->meta_data) ): ?>
438
- <br /><?php echo $picture->meta_data['width']; ?> x <?php echo $picture->meta_data['height']; ?> <?php _e('pixel', 'nggallery'); ?>
439
-
440
- <?php endif; ?>
441
- <p>
442
- <?php
443
- $actions = array();
444
- $actions['view'] = '<a class="shutter" href="' . esc_url( $picture->imageURL ) . '" title="' . esc_attr( sprintf(__('View "%s"'), sanitize_title ($picture->filename) )) . '">' . __('View', 'nggallery') . '</a>';
445
- $actions['meta'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data','nggallery') . '">' . __('Meta', 'nggallery') . '</a>';
446
- $actions['custom_thumb'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail','nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>';
447
- $actions['rotate'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate','nggallery') . '">' . __('Rotate', 'nggallery') . '</a>';
448
- if ( current_user_can( 'publish_posts' ) )
449
- $actions['publish'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/publish.php?id=' . $pid . '&h=230" title="' . __('Publish this image','nggallery') . '">' . __('Publish', 'nggallery') . '</a>';
450
- if ( file_exists( $picture->imagePath . '_backup' ) )
451
- $actions['recover'] = '<a class="confirmrecover" href="' .wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=recoverpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_recoverpicture'). '" title="' . __('Recover','nggallery') . '" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Recover "%s" ?' , 'nggallery'), $picture->filename)). '\');if(check==false) return false;">' . __('Recover', 'nggallery') . '</a>';
452
- $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=delpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_delpicture'). '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s" ?' , 'nggallery'), $picture->filename)). '\');if(check==false) return false;">' . __('Delete') . '</a>';
453
- $action_count = count($actions);
454
- $i = 0;
455
- echo '<div class="row-actions">';
456
- foreach ( $actions as $action => $link ) {
457
- ++$i;
458
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
459
- echo "<span class='$action'>$link$sep</span>";
460
- }
461
- echo '</div>';
462
- ?></p>
463
- </td>
464
- <?php
465
- break;
466
- case 'thumbnail' :
467
- $attributes = 'class="id column-thumbnail media-icon"' . $style;
468
- ?>
469
- <td <?php echo $attributes ?>><a href="<?php echo esc_url ( add_query_arg('i', mt_rand(), $picture->imageURL) ); ?>" class="shutter" title="<?php echo $picture->filename ?>">
470
- <img class="thumb" src="<?php echo esc_url ( add_query_arg('i', mt_rand(), $picture->thumbURL) ); ?>" id="thumb<?php echo $pid ?>" />
471
- </a>
472
- </td>
473
- <?php
474
- break;
475
- case 'alt_title_desc' :
476
- ?>
477
- <td <?php echo $attributes ?>>
478
- <input name="alttext[<?php echo $pid ?>]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo stripslashes($picture->alttext) ?>" /><br/>
479
- <textarea name="description[<?php echo $pid ?>]" style="width:95%; margin-top: 2px;" rows="2" ><?php echo stripslashes($picture->description) ?></textarea>
480
- </td>
481
- <?php
482
- break;
483
- case 'exclude' :
484
- ?>
485
- <td <?php echo $attributes ?>><input name="exclude[<?php echo $pid ?>]" type="checkbox" value="1" <?php echo $exclude ?> /></td>
486
- <?php
487
- break;
488
- case 'tags' :
489
- $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names');
490
- if (is_array ($picture->tags) ) $picture->tags = implode(', ', $picture->tags);
491
- ?>
492
- <td <?php echo $attributes ?>><textarea name="tags[<?php echo $pid ?>]" style="width:95%;" rows="2"><?php echo $picture->tags ?></textarea></td>
493
- <?php
494
- break;
495
- default :
496
- ?>
497
- <td <?php echo $attributes ?>><?php do_action('ngg_manage_image_custom_column', $image_column_key, $pid); ?></td>
498
- <?php
499
- break;
500
- }
501
- ?>
502
- <?php } ?>
503
- </tr>
504
- <?php
505
- }
506
- }
507
-
508
- // In the case you have no capaptibility to see the search result
509
- if ( $counter == 0 )
510
- echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>'.__('No entries found','nggallery').'</strong></td></tr>';
511
-
512
- ?>
513
-
514
- </tbody>
515
- </table>
516
- <div class="tablenav bottom">
517
- <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?>" />
518
- <?php $ngg->manage_page->pagination( 'bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
519
- </div>
520
- </form>
521
- <br class="clear"/>
522
- </div><!-- /#wrap -->
523
-
524
- <!-- #entertags -->
525
- <div id="entertags" style="display: none;" >
526
- <form id="form-tags" method="POST" accept-charset="utf-8">
527
- <?php wp_nonce_field('ngg_thickbox_form') ?>
528
- <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
529
- <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
530
- <input type="hidden" name="page" value="manage-images" />
531
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
532
- <tr>
533
- <th><?php _e("Enter the tags",'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th>
534
- </tr>
535
- <tr align="right">
536
- <td class="submit">
537
- <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK",'nggallery'); ?>" />
538
- &nbsp;
539
- <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e("Cancel",'nggallery'); ?>&nbsp;" />
540
- </td>
541
- </tr>
542
- </table>
543
- </form>
544
- </div>
545
- <!-- /#entertags -->
546
-
547
- <!-- #selectgallery -->
548
- <div id="selectgallery" style="display: none;" >
549
- <form id="form-select-gallery" method="POST" accept-charset="utf-8">
550
- <?php wp_nonce_field('ngg_thickbox_form') ?>
551
- <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
552
- <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
553
- <input type="hidden" name="page" value="manage-images" />
554
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
555
- <tr>
556
- <th>
557
- <?php _e('Select the destination gallery:', 'nggallery'); ?>&nbsp;
558
- <select name="dest_gid" style="width:90%" >
559
- <?php
560
- foreach ($gallerylist as $gallery) {
561
- if ($gallery->gid != $act_gid) {
562
- ?>
563
- <option value="<?php echo $gallery->gid; ?>" ><?php echo $gallery->gid; ?> - <?php echo esc_attr( stripslashes($gallery->title) ); ?></option>
564
- <?php
565
- }
566
- }
567
- ?>
568
- </select>
569
- </th>
570
- </tr>
571
- <tr align="right">
572
- <td class="submit">
573
- <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK",'nggallery'); ?>" />
574
- &nbsp;
575
- <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel",'nggallery'); ?>" />
576
- </td>
577
- </tr>
578
- </table>
579
- </form>
580
- </div>
581
- <!-- /#selectgallery -->
582
-
583
- <!-- #resize_images -->
584
- <div id="resize_images" style="display: none;" >
585
- <form id="form-resize-images" method="POST" accept-charset="utf-8">
586
- <?php wp_nonce_field('ngg_thickbox_form') ?>
587
- <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
588
- <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
589
- <input type="hidden" name="page" value="manage-images" />
590
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
591
- <tr valign="top">
592
- <td>
593
- <strong><?php _e('Resize Images to', 'nggallery'); ?>:</strong>
594
- </td>
595
- <td>
596
- <input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?>" /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?>" />
597
- <br /><small><?php _e('Width x height (in pixel). NextGEN Gallery will keep ratio size','nggallery') ?></small>
598
- </td>
599
- </tr>
600
- <tr align="right">
601
- <td colspan="2" class="submit">
602
- <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?>" />
603
- &nbsp;
604
- <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
605
- </td>
606
- </tr>
607
- </table>
608
- </form>
609
- </div>
610
- <!-- /#resize_images -->
611
-
612
- <!-- #new_thumbnail -->
613
- <div id="new_thumbnail" style="display: none;" >
614
- <form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
615
- <?php wp_nonce_field('ngg_thickbox_form') ?>
616
- <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
617
- <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
618
- <input type="hidden" name="page" value="manage-images" />
619
- <table width="100%" border="0" cellspacing="3" cellpadding="3" >
620
- <tr valign="top">
621
- <th align="left"><?php _e('Width x height (in pixel)','nggallery') ?></th>
622
- <td><input type="text" size="5" maxlength="5" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?>" /> x <input type="text" size="5" maxlength="5" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?>" />
623
- <br /><small><?php _e('These values are maximum values ','nggallery') ?></small></td>
624
- </tr>
625
- <tr valign="top">
626
- <th align="left"><?php _e('Set fix dimension','nggallery') ?></th>
627
- <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
628
- <br /><small><?php _e('Ignore the aspect ratio, no portrait thumbnails','nggallery') ?></small></td>
629
- </tr>
630
- <tr align="right">
631
- <td colspan="2" class="submit">
632
- <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery');?>" />
633
- &nbsp;
634
- <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
635
- </td>
636
- </tr>
637
- </table>
638
- </form>
639
- </div>
640
- <!-- /#new_thumbnail -->
641
-
642
- <script type="text/javascript">
643
- /* <![CDATA[ */
644
- jQuery(document).ready(function(){columns.init('nggallery-manage-images');});
645
- /* ]]> */
646
- </script>
647
- <?php
648
- }
649
-
650
- /**
651
- * Construtor class to create the table layout
652
- *
653
- * @package WordPress
654
- * @subpackage List_Table
655
- * @since 1.8.0
656
- * @access private
657
- */
658
- class _NGG_Images_List_Table extends WP_List_Table {
659
- var $_screen;
660
- var $_columns;
661
-
662
- function _NGG_Images_List_Table( $screen ) {
663
- if ( is_string( $screen ) )
664
- $screen = convert_to_screen( $screen );
665
-
666
- $this->_screen = $screen;
667
- $this->_columns = array() ;
668
-
669
- add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
670
- }
671
-
672
- function get_column_info() {
673
-
674
- $columns = get_column_headers( $this->_screen );
675
- $hidden = get_hidden_columns( $this->_screen );
676
- $_sortable = $this->get_sortable_columns();
677
- $sortable = array();
678
-
679
- foreach ( $_sortable as $id => $data ) {
680
- if ( empty( $data ) )
681
- continue;
682
-
683
- $data = (array) $data;
684
- if ( !isset( $data[1] ) )
685
- $data[1] = false;
686
-
687
- $sortable[$id] = $data;
688
- }
689
-
690
- return array( $columns, $hidden, $sortable );
691
- }
692
-
693
- // define the columns to display, the syntax is 'internal name' => 'display name'
694
- function get_columns() {
695
- $columns = array();
696
-
697
- $columns['cb'] = '<input name="checkall" type="checkbox" onclick="checkAll(document.getElementById(\'updategallery\'));" />';
698
- $columns['id'] = __('ID');
699
- $columns['thumbnail'] = __('Thumbnail', 'nggallery');
700
- $columns['filename'] = __('Filename', 'nggallery');
701
- $columns['alt_title_desc'] = __('Alt &amp; Title Text', 'nggallery') . ' / ' . __('Description', 'nggallery');
702
- $columns['tags'] = __('Tags (comma separated list)', 'nggallery');
703
- $columns['exclude'] = __('exclude', 'nggallery');
704
-
705
- $columns = apply_filters('ngg_manage_images_columns', $columns);
706
-
707
- return $columns;
708
- }
709
-
710
- function get_sortable_columns() {
711
- return array();
712
- }
713
- }
714
-
715
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.');}
4
+
5
+ function nggallery_picturelist() {
6
+ // *** show picture list
7
+ global $wpdb, $nggdb, $user_ID, $ngg;
8
+
9
+ // Look if its a search result
10
+ $is_search = isset ($_GET['s']) ? true : false;
11
+ $counter = 0;
12
+
13
+ $wp_list_table = new _NGG_Images_List_Table('nggallery-manage-images');
14
+
15
+ if ($is_search) {
16
+
17
+ // fetch the imagelist
18
+ $picturelist = $ngg->manage_page->search_result;
19
+
20
+ // we didn't set a gallery or a pagination
21
+ $act_gid = 0;
22
+ $_GET['paged'] = 1;
23
+ $page_links = false;
24
+
25
+ } else {
26
+
27
+ // GET variables
28
+ $act_gid = $ngg->manage_page->gid;
29
+
30
+ // Load the gallery metadata
31
+ $gallery = $nggdb->find_gallery($act_gid);
32
+
33
+ if (!$gallery) {
34
+ nggGallery::show_error(__('Gallery not found.', 'nggallery'));
35
+ return;
36
+ }
37
+
38
+ // Check if you have the correct capability
39
+ if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
40
+ nggGallery::show_error(__('Sorry, you have no access here', 'nggallery'));
41
+ return;
42
+ }
43
+
44
+ // look for pagination
45
+ $_GET['paged'] = isset($_GET['paged']) && ($_GET['paged'] > 0) ? absint($_GET['paged']) : 1;
46
+
47
+ $start = ( $_GET['paged'] - 1 ) * 50;
48
+
49
+ // get picture values
50
+ $picturelist = $nggdb->get_gallery($act_gid, $ngg->options['galSort'], $ngg->options['galSortDir'], false, 50, $start );
51
+
52
+ // get the current author
53
+ $act_author_user = get_userdata( (int) $gallery->author );
54
+
55
+ }
56
+
57
+ // list all galleries
58
+ $gallerylist = $nggdb->find_all_galleries();
59
+
60
+ //get the columns
61
+ $image_columns = $wp_list_table->get_columns();
62
+ $hidden_columns = get_hidden_columns('nggallery-manage-images');
63
+ $num_columns = count($image_columns) - count($hidden_columns);
64
+
65
+ $attr = (nggGallery::current_user_can( 'NextGEN Edit gallery options' )) ? '' : 'disabled="disabled"';
66
+
67
+ ?>
68
+ <script type="text/javascript">
69
+ <!--
70
+ function showDialog( windowId, title ) {
71
+ var form = document.getElementById('updategallery');
72
+ var elementlist = "";
73
+ for (i = 0, n = form.elements.length; i < n; i++) {
74
+ if(form.elements[i].type == "checkbox") {
75
+ if(form.elements[i].name == "doaction[]")
76
+ if(form.elements[i].checked == true)
77
+ if (elementlist == "")
78
+ elementlist = form.elements[i].value
79
+ else
80
+ elementlist += "," + form.elements[i].value ;
81
+ }
82
+ }
83
+ jQuery("#" + windowId + "_bulkaction").val(jQuery("#bulkaction").val());
84
+ jQuery("#" + windowId + "_imagelist").val(elementlist);
85
+ // now show the dialog
86
+ jQuery( "#" + windowId ).dialog({
87
+ width: 640,
88
+ resizable : false,
89
+ modal: true,
90
+ title: title
91
+ });
92
+ jQuery("#" + windowId + ' .dialog-cancel').click(function() { jQuery( "#" + windowId ).dialog("close"); });
93
+ }
94
+
95
+ jQuery(function (){
96
+
97
+ //Format for mysql: yy-mm-dd 00:00:00
98
+ //Load up the datepicker
99
+ jQuery(".datepicker").datepicker({
100
+ dateFormat:"MM dd, yy",
101
+ showOn:"focus",
102
+ onSelect: function(date) {
103
+ //Turn date into mysql and move things around
104
+ var mydate = jQuery.datepicker.formatDate("yy-mm-dd 00:00:00", new Date(date));
105
+ jQuery(this).siblings('.rawdate').attr('value',mydate);
106
+ jQuery(this).siblings(".date").html(date);
107
+ jQuery(this).siblings(".date").toggle();
108
+ jQuery(this).toggle();
109
+ jQuery(".change").toggle();
110
+ }
111
+ });
112
+
113
+ //When the user clicks change
114
+ jQuery(".change").click(function() { //Show the input and hide the span
115
+ jQuery(this).siblings(".date").toggle();
116
+ jQuery(this).siblings(".datepicker").toggle();
117
+ //jQuery(this).toggle();
118
+ jQuery(".change").toggle(); //All buttons disabled
119
+ });
120
+
121
+ // load a content via ajax
122
+ jQuery('a.ngg-dialog').click(function() {
123
+ if ( jQuery( "#spinner" ).length == 0)
124
+ jQuery("body").append('<div id="spinner"></div>');
125
+ var $this = jQuery(this);
126
+ jQuery('#spinner').fadeIn();
127
+ var dialog = jQuery('<div style="display:hidden"></div>').appendTo('body');
128
+ // load the remote content
129
+ dialog.load(
130
+ this.href,
131
+ {},
132
+ function () {
133
+ jQuery('#spinner').hide();
134
+ dialog.dialog({
135
+ title: ($this.attr('title')) ? $this.attr('title') : '',
136
+ width: 'auto',
137
+ height: 'auto',
138
+ modal: true,
139
+ resizable: true,
140
+ position: { my: "center", at: "center", of: window },
141
+ close: function() { dialog.remove(); }
142
+ });
143
+ }
144
+ );
145
+ //prevent the browser to follow the link
146
+ return false;
147
+ });
148
+
149
+
150
+ });
151
+
152
+ function checkAll(form)
153
+ {
154
+ for (i = 0, n = form.elements.length; i < n; i++) {
155
+ if(form.elements[i].type == "checkbox") {
156
+ if(form.elements[i].name == "doaction[]") {
157
+ if(form.elements[i].checked == true)
158
+ form.elements[i].checked = false;
159
+ else
160
+ form.elements[i].checked = true;
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ function getNumChecked(form)
167
+ {
168
+ var num = 0;
169
+ for (i = 0, n = form.elements.length; i < n; i++) {
170
+ if(form.elements[i].type == "checkbox") {
171
+ if(form.elements[i].name == "doaction[]")
172
+ if(form.elements[i].checked == true)
173
+ num++;
174
+ }
175
+ }
176
+ return num;
177
+ }
178
+
179
+ // this function check for a the number of selected images, sumbmit false when no one selected
180
+ function checkSelected() {
181
+
182
+ var numchecked = getNumChecked(document.getElementById('updategallery'));
183
+
184
+ if (typeof document.activeElement == "undefined" && document.addEventListener) {
185
+ document.addEventListener("focus", function (e) {
186
+ document.activeElement = e.target;
187
+ }, true);
188
+ }
189
+
190
+ if ( document.activeElement.name == 'post_paged' )
191
+ return true;
192
+
193
+ if(numchecked < 1) {
194
+ alert('<?php echo esc_js(__('No images selected', 'nggallery')); ?>');
195
+ return false;
196
+ }
197
+
198
+ actionId = jQuery('#bulkaction').val();
199
+
200
+ switch (actionId) {
201
+ case "copy_to":
202
+ showDialog('selectgallery', '<?php echo esc_js(__('Copy image to...','nggallery')); ?>');
203
+ return false;
204
+ break;
205
+ case "move_to":
206
+ showDialog('selectgallery', '<?php echo esc_js(__('Move image to...','nggallery')); ?>');
207
+ return false;
208
+ break;
209
+ case "add_tags":
210
+ showDialog('entertags', '<?php echo esc_js(__('Add new tags','nggallery')); ?>');
211
+ return false;
212
+ break;
213
+ case "delete_tags":
214
+ showDialog('entertags', '<?php echo esc_js(__('Delete tags','nggallery')); ?>');
215
+ return false;
216
+ break;
217
+ case "overwrite_tags":
218
+ showDialog('entertags', '<?php echo esc_js(__('Overwrite','nggallery')); ?>');
219
+ return false;
220
+ break;
221
+ case "resize_images":
222
+ showDialog('resize_images', '<?php echo esc_js(__('Resize images','nggallery')); ?>');
223
+ return false;
224
+ break;
225
+ case "new_thumbnail":
226
+ showDialog('new_thumbnail', '<?php echo esc_js(__('Create new thumbnails','nggallery')); ?>');
227
+ return false;
228
+ break;
229
+ }
230
+
231
+ return confirm('<?php echo sprintf(esc_js(__("You are about to start the bulk edit for %s images \n \n 'Cancel' to stop, 'OK' to proceed.",'nggallery')), "' + numchecked + '") ; ?>');
232
+ }
233
+
234
+ jQuery(document).ready( function() {
235
+ // close postboxes that should be closed
236
+ jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
237
+ postboxes.add_postbox_toggles('ngg-manage-gallery');
238
+ });
239
+
240
+ //-->
241
+ </script>
242
+ <div class="wrap">
243
+ <?php screen_icon( 'nextgen-gallery' ); ?>
244
+ <?php if ($is_search) :?>
245
+ <h2><?php printf( __('Search results for &#8220;%s&#8221;', 'nggallery'), esc_html( get_search_query() ) ); ?></h2>
246
+ <form class="search-form" action="" method="get">
247
+ <p class="search-box">
248
+ <label class="hidden" for="media-search-input"><?php _e( 'Search Images', 'nggallery' ); ?>:</label>
249
+ <input type="hidden" id="page-name" name="page" value="nggallery-manage-gallery" />
250
+ <input type="text" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
251
+ <input type="submit" value="<?php _e( 'Search Images', 'nggallery' ); ?>" class="button" />
252
+ </p>
253
+ </form>
254
+
255
+ <br style="clear: both;" />
256
+
257
+ <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;s=' . get_search_query(); ?>" accept-charset="utf-8">
258
+ <?php wp_nonce_field('ngg_updategallery') ?>
259
+ <input type="hidden" name="page" value="manage-images" />
260
+
261
+ <?php else :?>
262
+ <h2><?php echo _e( 'Gallery', 'nggallery' ); ?> <?php echo esc_html ( nggGallery::i18n($gallery->title) ); ?></h2>
263
+
264
+ <br style="clear: both;" />
265
+
266
+ <form id="updategallery" class="nggform" method="POST" action="<?php echo $ngg->manage_page->base_page . '&amp;mode=edit&amp;gid=' . $act_gid . '&amp;paged=' . $_GET['paged']; ?>" accept-charset="utf-8">
267
+ <?php wp_nonce_field('ngg_updategallery') ?>
268
+ <input type="hidden" name="page" value="manage-images" />
269
+
270
+ <?php if ( nggGallery::current_user_can( 'NextGEN Edit gallery options' )) : ?>
271
+ <div id="poststuff">
272
+ <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
273
+ <div id="gallerydiv" class="postbox <?php echo postbox_classes('gallerydiv', 'ngg-manage-gallery'); ?>" >
274
+ <h3><?php _e('Gallery settings', 'nggallery') ?><small> (<?php _e('Click here for more settings', 'nggallery') ?>)</small></h3>
275
+ <div class="inside">
276
+ <table class="form-table" id="gallery-properties">
277
+ <tr>
278
+ <td align="left"><?php _e('Title') ?>:</th>
279
+ <td align="left"><input <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery title' ); ?> type="text" size="50" name="title" value="<?php echo $gallery->title; ?>" /></th>
280
+ <td align="right"><?php _e('Page Link to', 'nggallery') ?>:</th>
281
+ <td align="left">
282
+ <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery page id' ); ?> name="pageid" style="width:95%">
283
+ <option value="0" ><?php _e('Not linked', 'nggallery') ?></option>
284
+ <?php $err = error_reporting(0); ?>
285
+ <?php parent_dropdown(intval($gallery->pageid)); ?>
286
+ <?php error_reporting($err); ?>
287
+ </select>
288
+ </th>
289
+ </tr>
290
+ <tr>
291
+ <td align="left"><?php _e('Description') ?>:</th>
292
+ <td align="left"><textarea <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery description' ); ?> name="gallerydesc" cols="30" rows="3" style="width: 95%" ><?php echo $gallery->galdesc; ?></textarea></th>
293
+ <td align="right"><?php _e('Preview image', 'nggallery') ?>:</th>
294
+ <td align="left">
295
+ <select <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery preview pic' ); ?> name="previewpic" style="width:95%" >
296
+ <option value="0" ><?php _e('No Picture', 'nggallery') ?></option>
297
+ <?php
298
+ // ensure that a preview pic from a other page is still shown here
299
+ if ( intval($gallery->previewpic) != 0) {
300
+ if ( !array_key_exists ($gallery->previewpic, $picturelist )){
301
+ $previewpic = $nggdb->find_image($gallery->previewpic);
302
+ if ($previewpic)
303
+ echo '<option value="'.$previewpic->pid.'" selected="selected" >'.$previewpic->pid.' - ' . esc_attr( $previewpic->filename ) . '</option>'."\n";
304
+ }
305
+ }
306
+ if(is_array($picturelist)) {
307
+ foreach($picturelist as $picture) {
308
+ if ($picture->exclude) continue;
309
+ $selected = ($picture->pid == $gallery->previewpic) ? 'selected="selected" ' : '';
310
+ echo '<option value="'.$picture->pid.'" '.$selected.'>'.$picture->pid.' - ' . esc_attr( $picture->filename ) . '</option>'."\n";
311
+ }
312
+ }
313
+ ?>
314
+ </select>
315
+ </th>
316
+ </tr>
317
+ <tr>
318
+ <td align="left"><?php _e('Path', 'nggallery') ?>:</th>
319
+ <td align="left"><input <?php if ( is_multisite() ) echo 'readonly = "readonly"'; ?> <?php nggGallery::current_user_can_form( 'NextGEN Edit gallery path' ); ?> type="text" size="50" name="path" value="<?php echo $gallery->path; ?>" /></th>
320
+ <td align="right"><?php _e('Author', 'nggallery'); ?>:</th>
321
+ <td align="left">
322
+ <?php
323
+ $editable_ids = $ngg->manage_page->get_editable_user_ids( $user_ID );
324
+ if ( $editable_ids && count( $editable_ids ) > 1 && nggGallery::current_user_can( 'NextGEN Edit gallery author') )
325
+ wp_dropdown_users( array('include' => $editable_ids, 'name' => 'author', 'selected' => empty( $gallery->author ) ? 0 : $gallery->author ) );
326
+ else
327
+ echo $act_author_user->display_name;
328
+ ?>
329
+ </th>
330
+ </tr>
331
+ <?php if(current_user_can( 'publish_pages' )) : ?>
332
+ <tr>
333
+ <td align="left">&nbsp;</th>
334
+ <td align="left">&nbsp;</th>
335
+ <td align="right"><?php _e('Create new page', 'nggallery') ?>:</th>
336
+ <td align="left">
337
+ <select name="parent_id" style="width:95%">
338
+ <option value="0"><?php _e ('Main page (No parent)', 'nggallery'); ?></option>
339
+ <?php if (get_post()): ?>
340
+ <?php parent_dropdown (); ?>
341
+ <?php endif ?>
342
+ </select>
343
+ <input class="button-secondary action" type="submit" name="addnewpage" value="<?php _e ('Add page', 'nggallery'); ?>" id="group"/>
344
+ </th>
345
+ </tr>
346
+ <?php endif; ?>
347
+ <?php do_action('ngg_manage_gallery_settings', $act_gid); ?>
348
+
349
+ </table>
350
+
351
+ <div class="submit">
352
+ <input type="submit" class="button-secondary" name="scanfolder" value="<?php _e("Scan Folder for new images",'nggallery'); ?> " />
353
+ <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e("Save Changes",'nggallery'); ?>" />
354
+ </div>
355
+
356
+ </div>
357
+ </div>
358
+ </div> <!-- poststuff -->
359
+ <?php endif; ?>
360
+
361
+ <?php endif; ?>
362
+
363
+ <div class="tablenav top ngg-tablenav">
364
+ <?php $ngg->manage_page->pagination( 'top', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
365
+ <div class="alignleft actions">
366
+ <select id="bulkaction" name="bulkaction">
367
+ <option value="no_action" ><?php _e("Actions",'nggallery'); ?></option>
368
+ <option value="set_watermark" ><?php _e("Set watermark",'nggallery'); ?></option>
369
+ <option value="new_thumbnail" ><?php _e("Create new thumbnails",'nggallery'); ?></option>
370
+ <option value="resize_images" ><?php _e("Resize images",'nggallery'); ?></option>
371
+ <option value="recover_images" ><?php _e("Recover from backup",'nggallery'); ?></option>
372
+ <option value="delete_images" ><?php _e("Delete images",'nggallery'); ?></option>
373
+ <option value="import_meta" ><?php _e("Import metadata",'nggallery'); ?></option>
374
+ <option value="rotate_cw" ><?php _e("Rotate images clockwise",'nggallery'); ?></option>
375
+ <option value="rotate_ccw" ><?php _e("Rotate images counter-clockwise",'nggallery'); ?></option>
376
+ <option value="copy_to" ><?php _e("Copy to...",'nggallery'); ?></option>
377
+ <option value="move_to"><?php _e("Move to...",'nggallery'); ?></option>
378
+ <option value="add_tags" ><?php _e("Add tags",'nggallery'); ?></option>
379
+ <option value="delete_tags" ><?php _e("Delete tags",'nggallery'); ?></option>
380
+ <option value="overwrite_tags" ><?php _e("Overwrite tags",'nggallery'); ?></option>
381
+ </select>
382
+ <input class="button-secondary" type="submit" name="showThickbox" value="<?php _e('Apply', 'nggallery'); ?>" onclick="if ( !checkSelected() ) return false;" />
383
+
384
+ <?php if (($ngg->options['galSort'] == "sortorder") && (!$is_search) ) { ?>
385
+ <input class="button-secondary" type="submit" name="sortGallery" value="<?php _e('Sort gallery', 'nggallery');?>" />
386
+ <?php } ?>
387
+
388
+ <input type="submit" name="updatepictures" class="button-primary action" value="<?php _e('Save Changes', 'nggallery');?>" />
389
+ </div>
390
+ </div>
391
+
392
+ <table id="ngg-listimages" class="widefat fixed" cellspacing="0" >
393
+
394
+ <thead>
395
+ <tr>
396
+ <?php $wp_list_table->print_column_headers(true); ?>
397
+ </tr>
398
+ </thead>
399
+ <tfoot>
400
+ <tr>
401
+ <?php $wp_list_table->print_column_headers(false); ?>
402
+ </tr>
403
+ </tfoot>
404
+ <tbody id="the-list">
405
+ <?php
406
+ if($picturelist) {
407
+
408
+ $thumbsize = '';
409
+
410
+ if ($ngg->options['thumbfix'])
411
+ $thumbsize = 'width="' . $ngg->options['thumbwidth'] . '" height="' . $ngg->options['thumbheight'] . '"';
412
+
413
+ foreach($picturelist as $picture) {
414
+
415
+ //for search result we need to check the capatibiliy
416
+ if ( !nggAdmin::can_manage_this_gallery($picture->author) && $is_search )
417
+ continue;
418
+
419
+ $counter++;
420
+ $pid = (int) $picture->pid;
421
+ $alternate = ( !isset($alternate) || $alternate == 'alternate' ) ? '' : 'alternate';
422
+ $exclude = ( $picture->exclude ) ? 'checked="checked"' : '';
423
+ $date = mysql2date(get_option('date_format'), $picture->imagedate);
424
+ $rawdate = $picture->imagedate;
425
+ $time = mysql2date(get_option('time_format'), $picture->imagedate);
426
+
427
+ ?>
428
+ <tr id="picture-<?php echo $pid ?>" class="<?php echo $alternate ?> iedit" valign="top">
429
+ <?php
430
+ foreach($image_columns as $image_column_key => $column_display_name) {
431
+ $class = "class='$image_column_key column-$image_column_key'";
432
+
433
+ $style = '';
434
+ if ( in_array($image_column_key, $hidden_columns) )
435
+ $style = ' style="display:none;"';
436
+
437
+ $attributes = $class . $style;
438
+
439
+ switch ($image_column_key) {
440
+ case 'cb' :
441
+ $attributes = 'class="column-cb check-column"' . $style;
442
+ ?>
443
+ <th <?php echo $attributes ?> scope="row"><input name="doaction[]" type="checkbox" value="<?php echo $pid ?>" /></th>
444
+ <?php
445
+ break;
446
+ case 'id' :
447
+ ?>
448
+ <td <?php echo $attributes ?> style=""><?php echo $pid; ?>
449
+ <input type="hidden" name="pid[]" value="<?php echo $pid ?>" />
450
+ </td>
451
+ <?php
452
+ break;
453
+ case 'filename' :
454
+ $attributes = 'class="title column-filename column-title"' . $style;
455
+ ?>
456
+ <td <?php echo $attributes ?>>
457
+ <strong><a href="<?php echo esc_url( $picture->imageURL ); ?>" class="thickbox" title="<?php echo esc_attr ($picture->filename); ?>">
458
+ <?php echo ( empty($picture->alttext) ) ? esc_html( $picture->filename ) : esc_html( stripslashes(nggGallery::i18n($picture->alttext)) ); ?>
459
+ </a></strong>
460
+ <br /><?php echo '<span class="date">'.$date.'</span>'; ?><input type="text" class="datepicker" value="<?php echo $date?>"/><span class="change"> <?php _e('Change Date', 'nggallery'); ?></span>
461
+ <input type="hidden" class="rawdate" name="date[<?php echo $pid ?>]" value="<?php echo $rawdate; ?>" />
462
+
463
+ <?php if ( !empty($picture->meta_data) ): ?>
464
+ <br /><?php echo $picture->meta_data['width']; ?> x <?php echo $picture->meta_data['height']; ?> <?php _e('pixel', 'nggallery'); ?>
465
+
466
+ <?php endif; ?>
467
+ <p>
468
+ <?php
469
+ $actions = array();
470
+ $actions['view'] = '<a class="shutter" href="' . esc_url( $picture->imageURL ) . '" title="' . esc_attr( sprintf(__('View "%s"'), sanitize_title ($picture->filename) )) . '">' . __('View', 'nggallery') . '</a>';
471
+ $actions['meta'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/showmeta.php?id=' . $pid . '" title="' . __('Show Meta data','nggallery') . '">' . __('Meta', 'nggallery') . '</a>';
472
+ $actions['custom_thumb'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/edit-thumbnail.php?id=' . $pid . '" title="' . __('Customize thumbnail','nggallery') . '">' . __('Edit thumb', 'nggallery') . '</a>';
473
+ $actions['rotate'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/rotate.php?id=' . $pid . '" title="' . __('Rotate','nggallery') . '">' . __('Rotate', 'nggallery') . '</a>';
474
+ if ( current_user_can( 'publish_posts' ) )
475
+ $actions['publish'] = '<a class="ngg-dialog" href="' . NGGALLERY_URLPATH . 'admin/publish.php?id=' . $pid . '&h=230" title="' . __('Publish this image','nggallery') . '">' . __('Publish', 'nggallery') . '</a>';
476
+ if ( file_exists( $picture->imagePath . '_backup' ) )
477
+ $actions['recover'] = '<a class="confirmrecover" href="' .wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=recoverpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_recoverpicture'). '" title="' . __('Recover','nggallery') . '" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Recover "%s" ?' , 'nggallery'), $picture->filename)). '\');if(check==false) return false;">' . __('Recover', 'nggallery') . '</a>';
478
+ $actions['delete'] = '<a class="submitdelete" href="' . wp_nonce_url("admin.php?page=nggallery-manage-gallery&amp;mode=delpic&amp;gid=" . $act_gid . "&amp;pid=" . $pid, 'ngg_delpicture'). '" class="delete column-delete" onclick="javascript:check=confirm( \'' . esc_attr(sprintf(__('Delete "%s" ?' , 'nggallery'), $picture->filename)). '\');if(check==false) return false;">' . __('Delete') . '</a>';
479
+ $action_count = count($actions);
480
+ $i = 0;
481
+ echo '<div class="row-actions">';
482
+ foreach ( $actions as $action => $link ) {
483
+ ++$i;
484
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
485
+ echo "<span class='$action'>$link$sep</span>";
486
+ }
487
+ echo '</div>';
488
+ ?></p>
489
+ </td>
490
+ <?php
491
+ break;
492
+ case 'thumbnail' :
493
+ $attributes = 'class="id column-thumbnail media-icon"' . $style;
494
+ ?>
495
+ <td <?php echo $attributes ?>><a href="<?php echo esc_url ( add_query_arg('i', mt_rand(), $picture->imageURL) ); ?>" class="shutter" title="<?php echo $picture->filename ?>">
496
+ <img class="thumb" src="<?php echo esc_url ( add_query_arg('i', mt_rand(), $picture->thumbURL) ); ?>" id="thumb<?php echo $pid ?>" />
497
+ </a>
498
+ </td>
499
+ <?php
500
+ break;
501
+ case 'alt_title_desc' :
502
+ ?>
503
+ <td <?php echo $attributes ?>>
504
+ <input placeholder="<?php _e("Alt & title text",'nggallery'); ?>" name="alttext[<?php echo $pid ?>]" type="text" style="width:95%; margin-bottom: 2px;" value="<?php echo stripslashes($picture->alttext) ?>" /><br/>
505
+ <textarea placeholder="<?php _e("Description",'nggallery'); ?>" name="description[<?php echo $pid ?>]" style="width:95%; margin: 1px;" rows="2" ><?php echo stripslashes($picture->description) ?></textarea>
506
+ </td>
507
+ <?php
508
+ break;
509
+ case 'exclude' :
510
+ ?>
511
+ <td <?php echo $attributes ?>><input name="exclude[<?php echo $pid ?>]" type="checkbox" value="1" <?php echo $exclude ?> /></td>
512
+ <?php
513
+ break;
514
+ case 'tags' :
515
+ $picture->tags = wp_get_object_terms($pid, 'ngg_tag', 'fields=names');
516
+ if (is_array ($picture->tags) ) $picture->tags = implode(', ', $picture->tags);
517
+ ?>
518
+ <td <?php echo $attributes ?>><textarea placeholder="<?php _e("Separated by commas",'nggallery'); ?>"name="tags[<?php echo $pid ?>]" style="width:95%;" rows="2"><?php echo $picture->tags ?></textarea></td>
519
+ <?php
520
+ break;
521
+ default :
522
+ ?>
523
+ <td <?php echo $attributes ?>><?php do_action('ngg_manage_image_custom_column', $image_column_key, $pid); ?></td>
524
+ <?php
525
+ break;
526
+ }
527
+ ?>
528
+ <?php } ?>
529
+ </tr>
530
+ <?php
531
+ }
532
+ }
533
+
534
+ // In the case you have no capaptibility to see the search result
535
+ if ( $counter == 0 )
536
+ echo '<tr><td colspan="' . $num_columns . '" align="center"><strong>'.__('No entries found','nggallery').'</strong></td></tr>';
537
+
538
+ ?>
539
+
540
+ </tbody>
541
+ </table>
542
+ <div class="tablenav bottom">
543
+ <input type="submit" class="button-primary action" name="updatepictures" value="<?php _e('Save Changes', 'nggallery'); ?>" />
544
+ <?php $ngg->manage_page->pagination( 'bottom', $_GET['paged'], $nggdb->paged['total_objects'], $nggdb->paged['objects_per_page'] ); ?>
545
+ </div>
546
+ </form>
547
+ <br class="clear"/>
548
+ </div><!-- /#wrap -->
549
+
550
+ <!-- #entertags -->
551
+ <div id="entertags" style="display: none;" >
552
+ <form id="form-tags" method="POST" accept-charset="utf-8">
553
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
554
+ <input type="hidden" id="entertags_imagelist" name="TB_imagelist" value="" />
555
+ <input type="hidden" id="entertags_bulkaction" name="TB_bulkaction" value="" />
556
+ <input type="hidden" name="page" value="manage-images" />
557
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
558
+ <tr>
559
+ <th><?php _e("Enter the tags",'nggallery'); ?> : <input name="taglist" type="text" style="width:90%" value="" /></th>
560
+ </tr>
561
+ <tr align="right">
562
+ <td class="submit">
563
+ <input class="button-primary" type="submit" name="TB_EditTags" value="<?php _e("OK",'nggallery'); ?>" />
564
+ &nbsp;
565
+ <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e("Cancel",'nggallery'); ?>&nbsp;" />
566
+ </td>
567
+ </tr>
568
+ </table>
569
+ </form>
570
+ </div>
571
+ <!-- /#entertags -->
572
+
573
+ <!-- #selectgallery -->
574
+ <div id="selectgallery" style="display: none;" >
575
+ <form id="form-select-gallery" method="POST" accept-charset="utf-8">
576
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
577
+ <input type="hidden" id="selectgallery_imagelist" name="TB_imagelist" value="" />
578
+ <input type="hidden" id="selectgallery_bulkaction" name="TB_bulkaction" value="" />
579
+ <input type="hidden" name="page" value="manage-images" />
580
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
581
+ <tr>
582
+ <th>
583
+ <?php _e('Select the destination gallery:', 'nggallery'); ?>&nbsp;
584
+ <select name="dest_gid" style="width:90%" >
585
+ <?php
586
+ foreach ($gallerylist as $gallery) {
587
+ if ($gallery->gid != $act_gid) {
588
+ ?>
589
+ <option value="<?php echo $gallery->gid; ?>" ><?php echo $gallery->gid; ?> - <?php echo esc_attr( stripslashes($gallery->title) ); ?></option>
590
+ <?php
591
+ }
592
+ }
593
+ ?>
594
+ </select>
595
+ </th>
596
+ </tr>
597
+ <tr align="right">
598
+ <td class="submit">
599
+ <input type="submit" class="button-primary" name="TB_SelectGallery" value="<?php _e("OK",'nggallery'); ?>" />
600
+ &nbsp;
601
+ <input class="button-secondary dialog-cancel" type="reset" value="<?php _e("Cancel",'nggallery'); ?>" />
602
+ </td>
603
+ </tr>
604
+ </table>
605
+ </form>
606
+ </div>
607
+ <!-- /#selectgallery -->
608
+
609
+ <!-- #resize_images -->
610
+ <div id="resize_images" style="display: none;" >
611
+ <form id="form-resize-images" method="POST" accept-charset="utf-8">
612
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
613
+ <input type="hidden" id="resize_images_imagelist" name="TB_imagelist" value="" />
614
+ <input type="hidden" id="resize_images_bulkaction" name="TB_bulkaction" value="" />
615
+ <input type="hidden" name="page" value="manage-images" />
616
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
617
+ <tr valign="top">
618
+ <td>
619
+ <strong><?php _e('Resize Images to', 'nggallery'); ?>:</strong>
620
+ </td>
621
+ <td>
622
+ <label for="imgWidth"><?php _e('Width','nggallery') ?></label>
623
+ <input type="number" step="1" min="0" class="small-text" name="imgWidth" class="small-text" value="<?php echo $ngg->options['imgWidth']; ?>" />
624
+ <label for="imgHeight"><?php _e('Height','nggallery') ?></label>
625
+ <input type="number" step="1" min="0" type="text" size="5" name="imgHeight" class="small-text" value="<?php echo $ngg->options['imgHeight']; ?>">
626
+ <p class="description"><?php _e('Width and height (in pixels). NextCellent Gallery will keep the ratio size.','nggallery') ?></p>
627
+ </td>
628
+ </tr>
629
+ <tr align="right">
630
+ <td colspan="2" class="submit">
631
+ <input class="button-primary" type="submit" name="TB_ResizeImages" value="<?php _e('OK', 'nggallery'); ?>" />
632
+ &nbsp;
633
+ <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
634
+ </td>
635
+ </tr>
636
+ </table>
637
+ </form>
638
+ </div>
639
+ <!-- /#resize_images -->
640
+
641
+ <!-- #new_thumbnail -->
642
+ <div id="new_thumbnail" style="display: none;" >
643
+ <form id="form-new-thumbnail" method="POST" accept-charset="utf-8">
644
+ <?php wp_nonce_field('ngg_thickbox_form') ?>
645
+ <input type="hidden" id="new_thumbnail_imagelist" name="TB_imagelist" value="" />
646
+ <input type="hidden" id="new_thumbnail_bulkaction" name="TB_bulkaction" value="" />
647
+ <input type="hidden" name="page" value="manage-images" />
648
+ <table width="100%" border="0" cellspacing="3" cellpadding="3" >
649
+ <tr valign="top">
650
+ <th align="left"><?php _e('Size','nggallery') ?></th>
651
+ <td><label for="thumbwidth"><?php _e('Width','nggallery') ?> </label><input class="small-text" type="number" step="1" min="0" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?>" /> <label for="thumbheight"><?php _e('Height','nggallery') ?> </label><input class="small-text" type="number" step="1" min="0" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?>" />
652
+ <p class="description"><?php _e('These values are maximum values ','nggallery') ?></p></td>
653
+ </tr>
654
+ <tr valign="top">
655
+ <th align="left"><?php _e('Fixed size','nggallery'); ?></th>
656
+ <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
657
+ <?php _e('This will ignore the aspect ratio, so no portrait thumbnails','nggallery') ?></td>
658
+ </tr>
659
+ <tr align="right">
660
+ <td colspan="2" class="submit">
661
+ <input class="button-primary" type="submit" name="TB_NewThumbnail" value="<?php _e('OK', 'nggallery');?>" />
662
+ &nbsp;
663
+ <input class="button-secondary dialog-cancel" type="reset" value="&nbsp;<?php _e('Cancel', 'nggallery'); ?>&nbsp;" />
664
+ </td>
665
+ </tr>
666
+ </table>
667
+ </form>
668
+ </div>
669
+ <!-- /#new_thumbnail -->
670
+
671
+ <script type="text/javascript">
672
+ /* <![CDATA[ */
673
+ jQuery(document).ready(function(){columns.init('nggallery-manage-images');});
674
+ /* ]]> */
675
+ </script>
676
+ <?php
677
+ }
678
+
679
+ /**
680
+ * Construtor class to create the table layout
681
+ *
682
+ * @package WordPress
683
+ * @subpackage List_Table
684
+ * @since 1.8.0
685
+ * @access private
686
+ */
687
+ class _NGG_Images_List_Table extends WP_List_Table {
688
+ var $_screen;
689
+ var $_columns;
690
+
691
+ function _NGG_Images_List_Table( $screen ) {
692
+ if ( is_string( $screen ) )
693
+ $screen = convert_to_screen( $screen );
694
+
695
+ $this->_screen = $screen;
696
+ $this->_columns = array() ;
697
+
698
+ add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
699
+ }
700
+
701
+ function get_column_info() {
702
+
703
+ $columns = get_column_headers( $this->_screen );
704
+ $hidden = get_hidden_columns( $this->_screen );
705
+ $_sortable = $this->get_sortable_columns();
706
+ $sortable = array();
707
+
708
+ foreach ( $_sortable as $id => $data ) {
709
+ if ( empty( $data ) )
710
+ continue;
711
+
712
+ $data = (array) $data;
713
+ if ( !isset( $data[1] ) )
714
+ $data[1] = false;
715
+
716
+ $sortable[$id] = $data;
717
+ }
718
+
719
+ return array( $columns, $hidden, $sortable );
720
+ }
721
+
722
+ // define the columns to display, the syntax is 'internal name' => 'display name'
723
+ function get_columns() {
724
+ $columns = array();
725
+
726
+ $columns['cb'] = '<input name="checkall" type="checkbox" onclick="checkAll(document.getElementById(\'updategallery\'));" />';
727
+ $columns['id'] = __('ID');
728
+ $columns['thumbnail'] = __('Thumbnail', 'nggallery');
729
+ $columns['filename'] = __('Filename', 'nggallery');
730
+ $columns['alt_title_desc'] = __('Alt &amp; Title Text', 'nggallery') . ' / ' . __('Description', 'nggallery');
731
+ $columns['tags'] = __('Tags', 'nggallery');
732
+ $columns['exclude'] = __('Exclude', 'nggallery');
733
+
734
+ $columns = apply_filters('ngg_manage_images_columns', $columns);
735
+
736
+ return $columns;
737
+ }
738
+
739
+ function get_sortable_columns() {
740
+ return array();
741
+ }
742
+ }
743
+
744
+ ?>
admin/manage-sort.php CHANGED
@@ -1,122 +1,122 @@
1
- <?php
2
-
3
- /**
4
- * @author Alex Rabe
5
- *
6
- */
7
-
8
- function nggallery_sortorder($galleryID = 0){
9
- global $wpdb, $ngg, $nggdb;
10
-
11
- if ($galleryID == 0) return;
12
-
13
- $galleryID = (int) $galleryID;
14
-
15
- if (isset ($_POST['updateSortorder'])) {
16
- check_admin_referer('ngg_updatesortorder');
17
- // get variable new sortorder
18
- parse_str($_POST['sortorder']);
19
- if (is_array($sortArray)){
20
- $neworder = array();
21
- foreach($sortArray as $pid) {
22
- $pid = substr($pid, 4); // get id from "pid-x"
23
- $neworder[] = (int) $pid;
24
- }
25
- $sortindex = 1;
26
- foreach($neworder as $pic_id) {
27
- $wpdb->query("UPDATE $wpdb->nggpictures SET sortorder = '$sortindex' WHERE pid = $pic_id");
28
- $sortindex++;
29
- }
30
-
31
- do_action('ngg_gallery_sort', $galleryID);
32
-
33
- nggGallery::show_message(__('Sort order changed','nggallery'));
34
- }
35
- }
36
-
37
- // look for presort args
38
- $presort = isset($_GET['presort']) ? $_GET['presort'] : false;
39
- $dir = ( isset($_GET['dir']) && $_GET['dir'] == 'DESC' ) ? 'DESC' : 'ASC';
40
- $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
41
- // ensure that nobody added some evil sorting :-)
42
- if (in_array( $presort, $sortitems) )
43
- $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
44
- else
45
- $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
46
-
47
- //this is the url without any presort variable
48
- $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
49
- //if we go back , then the mode should be edit
50
- $back_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
51
-
52
- // In the case somebody presort, then we take this url
53
- if ( isset($_GET['dir']) || isset($_GET['presort']) )
54
- $base_url = $_SERVER['REQUEST_URI'];
55
- else
56
- $base_url = $clean_url;
57
-
58
- ?>
59
- <script type="text/javascript">
60
- // seralize the ImageOrder
61
- function saveImageOrder()
62
- {
63
- var serial = "";
64
- var objects = document.getElementsByTagName('div');
65
- for(var no=0;no<objects.length;no++){
66
- if(objects[no].className=='imageBox' || objects[no].className=='imageBoxHighlighted'){
67
- if (serial.length > 0) serial = serial + '&'
68
- serial = serial + "sortArray[]=" + objects[no].id;
69
- }
70
- }
71
- jQuery('input[name=sortorder]').val(serial);
72
- // debug( 'This is the new order of the images(IDs) : <br>' + orderString );
73
-
74
- }
75
- jQuery(document).ready(function($) {
76
- $(".jqui-sortable").sortable({items: 'div.imageBox'});
77
- });
78
- </script>
79
- <div class="wrap">
80
- <form id="sortGallery" method="POST" action="<?php echo $clean_url ?>" onsubmit="saveImageOrder()" accept-charset="utf-8">
81
- <h2><?php _e('Sort Gallery', 'nggallery') ?></h2>
82
- <div class="tablenav">
83
- <div class="alignleft actions">
84
- <?php wp_nonce_field('ngg_updatesortorder') ?>
85
- <input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php _e('Update Sort Order', 'nggallery') ?>" />
86
- </div>
87
- <div class="alignright actions">
88
- <a href="<?php echo esc_url( $back_url ); ?>" class="button"><?php _e('Back to gallery', 'nggallery'); ?></a>
89
- </div>
90
- </div>
91
- <input name="sortorder" type="hidden" />
92
- <ul class="subsubsub">
93
- <li><?php _e('Presort', 'nggallery') ?> :</li>
94
- <li><a href="<?php echo esc_attr(remove_query_arg('presort', $base_url)); ?>" <?php if ($presort == '') echo 'class="current"'; ?>><?php _e('Unsorted', 'nggallery') ?></a> |</li>
95
- <li><a href="<?php echo esc_attr(add_query_arg('presort', 'pid', $base_url)); ?>" <?php if ($presort == 'pid') echo 'class="current"'; ?>><?php _e('Image ID', 'nggallery') ?></a> |</li>
96
- <li><a href="<?php echo esc_attr(add_query_arg('presort', 'filename', $base_url)); ?>" <?php if ($presort == 'filename') echo 'class="current"'; ?>><?php _e('Filename', 'nggallery') ?></a> |</li>
97
- <li><a href="<?php echo esc_attr(add_query_arg('presort', 'alttext', $base_url)); ?>" <?php if ($presort == 'alttext') echo 'class="current"'; ?>><?php _e('Alt/Title text', 'nggallery') ?></a> |</li>
98
- <li><a href="<?php echo esc_attr(add_query_arg('presort', 'imagedate', $base_url)); ?>" <?php if ($presort == 'imagedate') echo 'class="current"'; ?>><?php _e('Date/Time', 'nggallery') ?></a> |</li>
99
- <li><a href="<?php echo esc_attr(add_query_arg('dir', 'ASC', $base_url)); ?>" <?php if ($dir == 'ASC') echo 'class="current"'; ?>><?php _e('Ascending', 'nggallery') ?></a> |</li>
100
- <li><a href="<?php echo esc_attr(add_query_arg('dir', 'DESC', $base_url)); ?>" <?php if ($dir == 'DESC') echo 'class="current"'; ?>><?php _e('Descending', 'nggallery') ?></a></li>
101
- </ul>
102
- </form>
103
- <div id="debug" style="clear:both"></div>
104
- <div class='jqui-sortable'>
105
- <?php
106
- if($picturelist) {
107
- foreach($picturelist as $picture) {
108
- ?>
109
- <div class="imageBox" id="pid-<?php echo $picture->pid ?>">
110
- <div class="imageBox_theImage" style="background-image:url('<?php echo esc_url( $picture->thumbURL ); ?>')"></div>
111
- <div class="imageBox_label"><span><?php echo esc_html( stripslashes($picture->alttext) ); ?></span></div>
112
- </div>
113
- <?php
114
- }
115
- }
116
- ?>
117
- </div>
118
- </div>
119
-
120
- <?php
121
- }
122
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * @author Alex Rabe
5
+ *
6
+ */
7
+
8
+ function nggallery_sortorder($galleryID = 0){
9
+ global $wpdb, $ngg, $nggdb;
10
+
11
+ if ($galleryID == 0) return;
12
+
13
+ $galleryID = (int) $galleryID;
14
+
15
+ if (isset ($_POST['updateSortorder'])) {
16
+ check_admin_referer('ngg_updatesortorder');
17
+ // get variable new sortorder
18
+ parse_str($_POST['sortorder']);
19
+ if (is_array($sortArray)){
20
+ $neworder = array();
21
+ foreach($sortArray as $pid) {
22
+ $pid = substr($pid, 4); // get id from "pid-x"
23
+ $neworder[] = (int) $pid;
24
+ }
25
+ $sortindex = 1;
26
+ foreach($neworder as $pic_id) {
27
+ $wpdb->query("UPDATE $wpdb->nggpictures SET sortorder = '$sortindex' WHERE pid = $pic_id");
28
+ $sortindex++;
29
+ }
30
+
31
+ do_action('ngg_gallery_sort', $galleryID);
32
+
33
+ nggGallery::show_message(__('Sort order changed','nggallery'));
34
+ }
35
+ }
36
+
37
+ // look for presort args
38
+ $presort = isset($_GET['presort']) ? $_GET['presort'] : false;
39
+ $dir = ( isset($_GET['dir']) && $_GET['dir'] == 'DESC' ) ? 'DESC' : 'ASC';
40
+ $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
41
+ // ensure that nobody added some evil sorting :-)
42
+ if (in_array( $presort, $sortitems) )
43
+ $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
44
+ else
45
+ $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
46
+
47
+ //this is the url without any presort variable
48
+ $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
49
+ //if we go back , then the mode should be edit
50
+ $back_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
51
+
52
+ // In the case somebody presort, then we take this url
53
+ if ( isset($_GET['dir']) || isset($_GET['presort']) )
54
+ $base_url = $_SERVER['REQUEST_URI'];
55
+ else
56
+ $base_url = $clean_url;
57
+
58
+ ?>
59
+ <script type="text/javascript">
60
+ // seralize the ImageOrder
61
+ function saveImageOrder()
62
+ {
63
+ var serial = "";
64
+ var objects = document.getElementsByTagName('div');
65
+ for(var no=0;no<objects.length;no++){
66
+ if(objects[no].className=='imageBox' || objects[no].className=='imageBoxHighlighted'){
67
+ if (serial.length > 0) serial = serial + '&'
68
+ serial = serial + "sortArray[]=" + objects[no].id;
69
+ }
70
+ }
71
+ jQuery('input[name=sortorder]').val(serial);
72
+ // debug( 'This is the new order of the images(IDs) : <br>' + orderString );
73
+
74
+ }
75
+ jQuery(document).ready(function($) {
76
+ $(".jqui-sortable").sortable({items: 'div.imageBox'});
77
+ });
78
+ </script>
79
+ <div class="wrap">
80
+ <form id="sortGallery" method="POST" action="<?php echo $clean_url ?>" onsubmit="saveImageOrder()" accept-charset="utf-8">
81
+ <h2><?php _e('Sort Gallery', 'nggallery') ?></h2>
82
+ <div class="tablenav">
83
+ <div class="alignleft actions">
84
+ <?php wp_nonce_field('ngg_updatesortorder') ?>
85
+ <input class="button-primary action" type="submit" name="updateSortorder" onclick="saveImageOrder()" value="<?php _e('Update Sort Order', 'nggallery') ?>" />
86
+ </div>
87
+ <div class="alignright actions">
88
+ <a href="<?php echo esc_url( $back_url ); ?>" class="button"><?php _e('Back to gallery', 'nggallery'); ?></a>
89
+ </div>
90
+ </div>
91
+ <input name="sortorder" type="hidden" />
92
+ <ul class="subsubsub">
93
+ <li><?php _e('Presort', 'nggallery') ?> :</li>
94
+ <li><a href="<?php echo esc_attr(remove_query_arg('presort', $base_url)); ?>" <?php if ($presort == '') echo 'class="current"'; ?>><?php _e('Unsorted', 'nggallery') ?></a> |</li>
95
+ <li><a href="<?php echo esc_attr(add_query_arg('presort', 'pid', $base_url)); ?>" <?php if ($presort == 'pid') echo 'class="current"'; ?>><?php _e('Image ID', 'nggallery') ?></a> |</li>
96
+ <li><a href="<?php echo esc_attr(add_query_arg('presort', 'filename', $base_url)); ?>" <?php if ($presort == 'filename') echo 'class="current"'; ?>><?php _e('Filename', 'nggallery') ?></a> |</li>
97
+ <li><a href="<?php echo esc_attr(add_query_arg('presort', 'alttext', $base_url)); ?>" <?php if ($presort == 'alttext') echo 'class="current"'; ?>><?php _e('Alt/Title text', 'nggallery') ?></a> |</li>
98
+ <li><a href="<?php echo esc_attr(add_query_arg('presort', 'imagedate', $base_url)); ?>" <?php if ($presort == 'imagedate') echo 'class="current"'; ?>><?php _e('Date/Time', 'nggallery') ?></a> |</li>
99
+ <li><a href="<?php echo esc_attr(add_query_arg('dir', 'ASC', $base_url)); ?>" <?php if ($dir == 'ASC') echo 'class="current"'; ?>><?php _e('Ascending', 'nggallery') ?></a> |</li>
100
+ <li><a href="<?php echo esc_attr(add_query_arg('dir', 'DESC', $base_url)); ?>" <?php if ($dir == 'DESC') echo 'class="current"'; ?>><?php _e('Descending', 'nggallery') ?></a></li>
101
+ </ul>
102
+ </form>
103
+ <div id="debug" style="clear:both"></div>
104
+ <div class='jqui-sortable'>
105
+ <?php
106
+ if($picturelist) {
107
+ foreach($picturelist as $picture) {
108
+ ?>
109
+ <div class="imageBox" id="pid-<?php echo $picture->pid ?>">
110
+ <div class="imageBox_theImage" style="background-image:url('<?php echo esc_url( $picture->thumbURL ); ?>')"></div>
111
+ <div class="imageBox_label"><span><?php echo esc_html( stripslashes($picture->alttext) ); ?></span></div>
112
+ </div>
113
+ <?php
114
+ }
115
+ }
116
+ ?>
117
+ </div>
118
+ </div>
119
+
120
+ <?php
121
+ }
122
+ ?>
admin/manage.php CHANGED
@@ -1,657 +1,658 @@
1
- <?php
2
-
3
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
-
5
- class nggManageGallery {
6
-
7
- var $mode = 'main';
8
- var $gid = false;
9
- var $pid = false;
10
- var $base_page = 'admin.php?page=nggallery-manage-gallery';
11
- var $search_result = false;
12
-
13
- // initiate the manage page
14
- function nggManageGallery() {
15
-
16
- // GET variables
17
- if( isset($_GET['gid']) )
18
- $this->gid = (int) $_GET['gid'];
19
- if( isset($_GET['pid']) )
20
- $this->pid = (int) $_GET['pid'];
21
- if( isset($_GET['mode']) )
22
- $this->mode = trim ($_GET['mode']);
23
- // Check for pagination request, avoid post process of other submit button, exclude search results
24
- if ( isset($_POST['post_paged']) && !isset($_GET['s'] ) ) {
25
- if ( $_GET['paged'] != $_POST['post_paged'] ) {
26
- $_GET['paged'] = absint( $_POST['post_paged'] );
27
- return;
28
- }
29
- }
30
- // Should be only called via manage galleries overview
31
- if ( isset($_POST['page']) && $_POST['page'] == 'manage-galleries' )
32
- $this->post_processor_galleries();
33
- // Should be only called via a edit single gallery page
34
- if ( isset($_POST['page']) && $_POST['page'] == 'manage-images' )
35
- $this->post_processor_images();
36
- // Should be called via a publish dialog
37
- if ( isset($_POST['page']) && $_POST['page'] == 'publish-post' )
38
- $this->publish_post();
39
- //Look for other POST process
40
- if ( !empty($_POST) || !empty($_GET) )
41
- $this->processor();
42
-
43
- }
44
-
45
- function controller() {
46
-
47
- switch($this->mode) {
48
- case 'sort':
49
- include_once (dirname (__FILE__) . '/manage-sort.php');
50
- nggallery_sortorder($this->gid);
51
- break;
52
- case 'edit':
53
- include_once (dirname (__FILE__) . '/manage-images.php');
54
- nggallery_picturelist();
55
- break;
56
- case 'main':
57
- default:
58
- include_once (dirname (__FILE__) . '/manage-galleries.php');
59
- nggallery_manage_gallery_main();
60
- break;
61
- }
62
- }
63
-
64
- function processor() {
65
-
66
- global $wpdb, $ngg, $nggdb;
67
-
68
- // Delete a picture
69
- if ($this->mode == 'delpic') {
70
-
71
- //TODO:Remove also Tag reference
72
- check_admin_referer('ngg_delpicture');
73
- $image = $nggdb->find_image( $this->pid );
74
- if ($image) {
75
- if ($ngg->options['deleteImg']) {
76
- @unlink($image->imagePath);
77
- @unlink($image->thumbPath);
78
- @unlink($image->imagePath . '_backup' );
79
- }
80
- do_action('ngg_delete_picture', $this->pid);
81
- $result = nggdb::delete_image ( $this->pid );
82
- }
83
-
84
- if ($result)
85
- nggGallery::show_message( __('Picture','nggallery').' \''.$this->pid.'\' '.__('deleted successfully','nggallery') );
86
-
87
- $this->mode = 'edit'; // show pictures
88
-
89
- }
90
-
91
- // Recover picture from backup
92
- if ($this->mode == 'recoverpic') {
93
-
94
- check_admin_referer('ngg_recoverpicture');
95
- $image = $nggdb->find_image( $this->pid );
96
- // bring back the old image
97
- nggAdmin::recover_image($image);
98
- nggAdmin::create_thumbnail($image);
99
-
100
- nggGallery::show_message(__('Operation successful. Please clear your browser cache.',"nggallery"));
101
-
102
- $this->mode = 'edit'; // show pictures
103
-
104
- }
105
-
106
- // will be called after a ajax operation
107
- if (isset ($_POST['ajax_callback'])) {
108
- if ($_POST['ajax_callback'] == 1)
109
- nggGallery::show_message(__('Operation successful. Please clear your browser cache.',"nggallery"));
110
- }
111
-
112
- // show sort order
113
- if ( isset ($_POST['sortGallery']) )
114
- $this->mode = 'sort';
115
-
116
- if ( isset ($_GET['s']) )
117
- $this->search_images();
118
-
119
- }
120
-
121
- function post_processor_galleries() {
122
- global $wpdb, $ngg, $nggdb;
123
-
124
- // bulk update in a single gallery
125
- if (isset ($_POST['bulkaction']) && isset ($_POST['doaction'])) {
126
-
127
- check_admin_referer('ngg_bulkgallery');
128
-
129
- switch ($_POST['bulkaction']) {
130
- case 'no_action';
131
- // No action
132
- break;
133
- case 'recover_images':
134
- // Recover images from backup
135
- // A prefix 'gallery_' will first fetch all ids from the selected galleries
136
- nggAdmin::do_ajax_operation( 'gallery_recover_image' , $_POST['doaction'], __('Recover from backup','nggallery') );
137
- break;
138
- case 'set_watermark':
139
- // Set watermark
140
- // A prefix 'gallery_' will first fetch all ids from the selected galleries
141
- nggAdmin::do_ajax_operation( 'gallery_set_watermark' , $_POST['doaction'], __('Set watermark','nggallery') );
142
- break;
143
- case 'import_meta':
144
- // Import Metadata
145
- // A prefix 'gallery_' will first fetch all ids from the selected galleries
146
- nggAdmin::do_ajax_operation( 'gallery_import_metadata' , $_POST['doaction'], __('Import metadata','nggallery') );
147
- break;
148
- case 'delete_gallery':
149
- // Delete gallery
150
- if ( is_array($_POST['doaction']) ) {
151
- $deleted = false;
152
- foreach ( $_POST['doaction'] as $id ) {
153
- // get the path to the gallery
154
- $gallery = nggdb::find_gallery($id);
155
- if ($gallery){
156
- //TODO:Remove also Tag reference, look here for ids instead filename
157
- $imagelist = $wpdb->get_col("SELECT filename FROM $wpdb->nggpictures WHERE galleryid = '$gallery->gid' ");
158
- if ($ngg->options['deleteImg']) {
159
- if (is_array($imagelist)) {
160
- foreach ($imagelist as $filename) {
161
- @unlink(WINABSPATH . $gallery->path . '/thumbs/thumbs_' . $filename);
162
- @unlink(WINABSPATH . $gallery->path .'/'. $filename);
163
- @unlink(WINABSPATH . $gallery->path .'/'. $filename . '_backup');
164
- }
165
- }
166
- // delete folder
167
- @rmdir( WINABSPATH . $gallery->path . '/thumbs' );
168
- @rmdir( WINABSPATH . $gallery->path );
169
- }
170
- }
171
- do_action('ngg_delete_gallery', $id);
172
- $deleted = nggdb::delete_gallery( $id );
173
- }
174
-
175
- if($deleted)
176
- nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
177
-
178
- }
179
- break;
180
- }
181
- }
182
-
183
- if (isset ($_POST['addgallery']) && isset ($_POST['galleryname'])){
184
-
185
- check_admin_referer('ngg_addgallery');
186
-
187
- if ( !nggGallery::current_user_can( 'NextGEN Add new gallery' ))
188
- wp_die(__('Cheatin&#8217; uh?'));
189
-
190
- // get the default path for a new gallery
191
- $defaultpath = $ngg->options['gallerypath'];
192
- $newgallery = esc_attr( $_POST['galleryname']);
193
- if ( !empty($newgallery) )
194
- nggAdmin::create_gallery($newgallery, $defaultpath);
195
-
196
- do_action( 'ngg_update_addgallery_page' );
197
- }
198
-
199
- if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_ResizeImages'])) {
200
-
201
- check_admin_referer('ngg_thickbox_form');
202
-
203
- //save the new values for the next operation
204
- $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
205
- $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
206
- // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
207
- update_option('ngg_options', $ngg->options);
208
-
209
- $gallery_ids = explode(',', $_POST['TB_imagelist']);
210
- // A prefix 'gallery_' will first fetch all ids from the selected galleries
211
- nggAdmin::do_ajax_operation( 'gallery_resize_image' , $gallery_ids, __('Resize images','nggallery') );
212
- }
213
-
214
- if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_NewThumbnail'])) {
215
-
216
- check_admin_referer('ngg_thickbox_form');
217
-
218
- //save the new values for the next operation
219
- $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
220
- $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
221
- $ngg->options['thumbfix'] = isset ($_POST['thumbfix']) ? true : false;
222
- // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
223
- update_option('ngg_options', $ngg->options);
224
-
225
- $gallery_ids = explode(',', $_POST['TB_imagelist']);
226
- // A prefix 'gallery_' will first fetch all ids from the selected galleries
227
- nggAdmin::do_ajax_operation( 'gallery_create_thumbnail' , $gallery_ids, __('Create new thumbnails','nggallery') );
228
- }
229
-
230
- }
231
-
232
- function post_processor_images() {
233
- global $wpdb, $ngg, $nggdb;
234
-
235
- // bulk update in a single gallery
236
- if (isset ($_POST['bulkaction']) && isset ($_POST['doaction'])) {
237
-
238
- check_admin_referer('ngg_updategallery');
239
-
240
- switch ($_POST['bulkaction']) {
241
- case 'no_action';
242
- break;
243
- case 'rotate_cw':
244
- nggAdmin::do_ajax_operation( 'rotate_cw' , $_POST['doaction'], __('Rotate images', 'nggallery') );
245
- break;
246
- case 'rotate_ccw':
247
- nggAdmin::do_ajax_operation( 'rotate_ccw' , $_POST['doaction'], __('Rotate images', 'nggallery') );
248
- break;
249
- case 'recover_images':
250
- nggAdmin::do_ajax_operation( 'recover_image' , $_POST['doaction'], __('Recover from backup', 'nggallery') );
251
- break;
252
- case 'set_watermark':
253
- nggAdmin::do_ajax_operation( 'set_watermark' , $_POST['doaction'], __('Set watermark', 'nggallery') );
254
- break;
255
- case 'delete_images':
256
- if ( is_array($_POST['doaction']) ) {
257
- foreach ( $_POST['doaction'] as $imageID ) {
258
- $image = $nggdb->find_image( $imageID );
259
- if ($image) {
260
- if ($ngg->options['deleteImg']) {
261
- @unlink($image->imagePath);
262
- @unlink($image->thumbPath);
263
- @unlink($image->imagePath."_backup");
264
- }
265
- do_action('ngg_delete_picture', $image->pid);
266
- $delete_pic = nggdb::delete_image( $image->pid );
267
- }
268
- }
269
- if($delete_pic)
270
- nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery'));
271
- }
272
- break;
273
- case 'import_meta':
274
- nggAdmin::do_ajax_operation( 'import_metadata' , $_POST['doaction'], __('Import metadata', 'nggallery') );
275
- break;
276
- }
277
- }
278
-
279
- if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_ResizeImages'])) {
280
-
281
- check_admin_referer('ngg_thickbox_form');
282
-
283
- //save the new values for the next operation
284
- $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
285
- $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
286
-
287
- update_option('ngg_options', $ngg->options);
288
-
289
- $pic_ids = explode(',', $_POST['TB_imagelist']);
290
- nggAdmin::do_ajax_operation( 'resize_image' , $pic_ids, __('Resize images','nggallery') );
291
- }
292
-
293
- if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_NewThumbnail'])) {
294
-
295
- check_admin_referer('ngg_thickbox_form');
296
-
297
- //save the new values for the next operation
298
- $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
299
- $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
300
- $ngg->options['thumbfix'] = isset ( $_POST['thumbfix'] ) ? true : false;
301
- update_option('ngg_options', $ngg->options);
302
-
303
- $pic_ids = explode(',', $_POST['TB_imagelist']);
304
- nggAdmin::do_ajax_operation( 'create_thumbnail' , $pic_ids, __('Create new thumbnails','nggallery') );
305
- }
306
-
307
- if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_SelectGallery'])) {
308
-
309
- check_admin_referer('ngg_thickbox_form');
310
-
311
- $pic_ids = explode(',', $_POST['TB_imagelist']);
312
- $dest_gid = (int) $_POST['dest_gid'];
313
-
314
- switch ($_POST['TB_bulkaction']) {
315
- case 'copy_to':
316
- // Copy images
317
- nggAdmin::copy_images( $pic_ids, $dest_gid );
318
- break;
319
- case 'move_to':
320
- // Move images
321
- nggAdmin::move_images( $pic_ids, $dest_gid );
322
- break;
323
- }
324
- }
325
-
326
- if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_EditTags'])) {
327
- // do tags update
328
-
329
- check_admin_referer('ngg_thickbox_form');
330
-
331
- // get the images list
332
- $pic_ids = explode(',', $_POST['TB_imagelist']);
333
- $taglist = explode(',', $_POST['taglist']);
334
- $taglist = array_map('trim', $taglist);
335
-
336
- if (is_array($pic_ids)) {
337
-
338
- foreach($pic_ids as $pic_id) {
339
-
340
- // which action should be performed ?
341
- switch ($_POST['TB_bulkaction']) {
342
- case 'no_action';
343
- // No action
344
- break;
345
- case 'overwrite_tags':
346
- // Overwrite tags
347
- wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
348
- break;
349
- case 'add_tags':
350
- // Add / append tags
351
- wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
352
- break;
353
- case 'delete_tags':
354
- // Delete tags
355
- $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
356
- // get the slugs, to vaoid case sensitive problems
357
- $slugarray = array_map('sanitize_title', $taglist);
358
- $oldtags = array_map('sanitize_title', $oldtags);
359
- // compare them and return the diff
360
- $newtags = array_diff($oldtags, $slugarray);
361
- wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
362
- break;
363
- }
364
- }
365
-
366
- nggGallery::show_message( __('Tags changed', 'nggallery') );
367
- }
368
- }
369
-
370
- if (isset ($_POST['updatepictures']) ) {
371
- // Update pictures
372
-
373
- check_admin_referer('ngg_updategallery');
374
-
375
- if ( nggGallery::current_user_can( 'NextGEN Edit gallery options' ) && !isset ($_GET['s']) ) {
376
-
377
- if ( nggGallery::current_user_can( 'NextGEN Edit gallery title' )) {
378
- // don't forget to update the slug
379
- $slug = nggdb::get_unique_slug( sanitize_title( $_POST['title'] ), 'gallery', $this->gid );
380
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET title= '%s', slug= '%s' WHERE gid = %d", esc_attr($_POST['title']), $slug, $this->gid) );
381
- }
382
- if ( nggGallery::current_user_can( 'NextGEN Edit gallery path' ))
383
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET path= '%s' WHERE gid = %d", untrailingslashit ( str_replace('\\', '/', trim( stripslashes($_POST['path']) )) ), $this->gid ) );
384
- if ( nggGallery::current_user_can( 'NextGEN Edit gallery description' ))
385
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET galdesc= '%s' WHERE gid = %d", esc_attr( $_POST['gallerydesc'] ), $this->gid) );
386
- if ( nggGallery::current_user_can( 'NextGEN Edit gallery page id' ))
387
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET pageid= '%d' WHERE gid = %d", (int) $_POST['pageid'], $this->gid) );
388
- if ( nggGallery::current_user_can( 'NextGEN Edit gallery preview pic' ))
389
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET previewpic= '%d' WHERE gid = %d", (int) $_POST['previewpic'], $this->gid) );
390
- if ( isset ($_POST['author']) && nggGallery::current_user_can( 'NextGEN Edit gallery author' ) )
391
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET author= '%d' WHERE gid = %d", (int) $_POST['author'], $this->gid) );
392
-
393
- wp_cache_delete($this->gid, 'ngg_gallery');
394
-
395
- }
396
-
397
- $this->update_pictures();
398
-
399
- //hook for other plugin to update the fields
400
- do_action('ngg_update_gallery', $this->gid, $_POST);
401
-
402
- nggGallery::show_message(__('Update successful',"nggallery"));
403
- }
404
-
405
- if (isset ($_POST['scanfolder'])) {
406
- // Rescan folder
407
- check_admin_referer('ngg_updategallery');
408
-
409
- $gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$this->gid' ");
410
- nggAdmin::import_gallery($gallerypath);
411
- }
412
-
413
- if (isset ($_POST['addnewpage'])) {
414
- // Add a new page
415
-
416
- check_admin_referer('ngg_updategallery');
417
-
418
- $parent_id = esc_attr($_POST['parent_id']);
419
- $gallery_title = esc_attr($_POST['title']);
420
- $gallery_name = $wpdb->get_var("SELECT name FROM $wpdb->nggallery WHERE gid = '$this->gid' ");
421
-
422
- // Create a WP page
423
- global $user_ID;
424
-
425
- $page['post_type'] = 'page';
426
- $page['post_content'] = '[nggallery id=' . $this->gid . ']';
427
- $page['post_parent'] = $parent_id;
428
- $page['post_author'] = $user_ID;
429
- $page['post_status'] = 'publish';
430
- $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
431
- $page = apply_filters('ngg_add_new_page', $page, $this->gid);
432
-
433
- $gallery_pageid = wp_insert_post ($page);
434
- if ($gallery_pageid != 0) {
435
- $result = $wpdb->query("UPDATE $wpdb->nggallery SET title= '$gallery_title', pageid = '$gallery_pageid' WHERE gid = '$this->gid'");
436
- wp_cache_delete($this->gid, 'ngg_gallery');
437
- nggGallery::show_message( __('New gallery page ID','nggallery'). ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' .__('created','nggallery') );
438
- }
439
-
440
- do_action('ngg_gallery_addnewpage', $this->gid);
441
- }
442
- }
443
-
444
- /**
445
- * Publish a new post with the shortcode from the selected image
446
- *
447
- * @since 1.7.0
448
- * @return void
449
- */
450
- function publish_post() {
451
-
452
- check_admin_referer('publish-post');
453
-
454
- // Create a WP page
455
- global $user_ID, $ngg;
456
-
457
- $ngg->options['publish_width'] = (int) $_POST['width'];
458
- $ngg->options['publish_height'] = (int) $_POST['height'];
459
- $ngg->options['publish_align'] = $_POST['align'];
460
- $align = ( $ngg->options['publish_align'] == 'none') ? '' : 'float='.$ngg->options['publish_align'];
461
-
462
- //save the new values for the next operation
463
- update_option('ngg_options', $ngg->options);
464
-
465
- $post['post_type'] = 'post';
466
- $post['post_content'] = '[singlepic id=' . intval($_POST['pid']) . ' w=' . $ngg->options['publish_width'] . ' h=' . $ngg->options['publish_height'] . ' ' . $align . ']';
467
- $post['post_author'] = $user_ID;
468
- $post['post_status'] = isset ( $_POST['publish'] ) ? 'publish' : 'draft';
469
- $post['post_title'] = $_POST['post_title'];
470
- $post = apply_filters('ngg_add_new_post', $post, $_POST['pid']);
471
-
472
- $post_id = wp_insert_post ($post);
473
-
474
- if ($post_id != 0)
475
- nggGallery::show_message( __('Published a new post','nggallery') );
476
-
477
- }
478
-
479
- function update_pictures() {
480
- global $wpdb, $nggdb;
481
-
482
- //TODO:Error message when update failed
483
-
484
- $description = isset ( $_POST['description'] ) ? $_POST['description'] : array();
485
- $alttext = isset ( $_POST['alttext'] ) ? $_POST['alttext'] : array();
486
- $exclude = isset ( $_POST['exclude'] ) ? $_POST['exclude'] : false;
487
- $taglist = isset ( $_POST['tags'] ) ? $_POST['tags'] : false;
488
- $pictures = isset ( $_POST['pid'] ) ? $_POST['pid'] : false;
489
-
490
- if ( is_array($pictures) ){
491
- foreach( $pictures as $pid ){
492
- $image = $nggdb->find_image( $pid );
493
- if ($image) {
494
- // description field
495
- $image->description = $description[$image->pid];
496
-
497
- // only uptade this field if someone change the alttext
498
- if ( $image->alttext != $alttext[$image->pid] ) {
499
- $image->alttext = $alttext[$image->pid];
500
- $image->image_slug = nggdb::get_unique_slug( sanitize_title( $image->alttext ), 'image', $image->pid );
501
- }
502
-
503
- // set exclude flag
504
- if ( is_array($exclude) )
505
- $image->exclude = ( array_key_exists($image->pid, $exclude) )? 1 : 0;
506
- else
507
- $image->exclude = 0;
508
-
509
- // update the database
510
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggpictures SET image_slug = '%s', alttext = '%s', description = '%s', exclude = %d WHERE pid = %d",
511
- $image->image_slug, $image->alttext, $image->description, $image->exclude, $image->pid) );
512
- // remove from cache
513
- wp_cache_delete($image->pid, 'ngg_image');
514
-
515
- // hook for other plugins after image is updated
516
- do_action('ngg_image_updated', $image);
517
- }
518
-
519
- }
520
- }
521
-
522
- //TODO: This produce 300-400 queries !
523
- if ( is_array($taglist) ){
524
- foreach($taglist as $key=>$value) {
525
- $tags = explode(',', $value);
526
- wp_set_object_terms($key, $tags, 'ngg_tag');
527
- }
528
- }
529
-
530
- return;
531
- }
532
-
533
- // Check if user can select a author
534
- function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
535
- global $wpdb;
536
-
537
- $user = new WP_User( $user_id );
538
-
539
- if ( ! $user->has_cap('NextGEN Manage others gallery') ) {
540
- if ( $user->has_cap('NextGEN Manage gallery') || $exclude_zeros == false )
541
- return array($user->id);
542
- else
543
- return false;
544
- }
545
-
546
- $level_key = $wpdb->prefix . 'user_level';
547
- $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
548
- if ( $exclude_zeros )
549
- $query .= " AND meta_value != '0'";
550
-
551
- return $wpdb->get_col( $query );
552
- }
553
-
554
- function search_images() {
555
- global $nggdb;
556
-
557
- if ( empty($_GET['s']) )
558
- return;
559
- //on what ever reason I need to set again the query var
560
- set_query_var('s', $_GET['s']);
561
- $request = get_search_query();
562
-
563
- // look now for the images
564
- $search_for_images = (array) $nggdb->search_for_images( $request );
565
- $search_for_tags = (array) nggTags::find_images_for_tags( $request , 'ASC' );
566
-
567
- // finally merge the two results together
568
- $this->search_result = array_merge( $search_for_images , $search_for_tags );
569
-
570
- // TODO: Currently we didn't support a proper pagination
571
- $nggdb->paged['total_objects'] = $nggdb->paged['objects_per_page'] = count ($this->search_result) ;
572
- $nggdb->paged['max_objects_per_page'] = 1;
573
-
574
- // show pictures page
575
- $this->mode = 'edit';
576
- }
577
-
578
- /**
579
- * Display the pagination.
580
- *
581
- * @since 1.8.0
582
- * @author taken from WP core (see includes/class-wp-list-table.php)
583
- * @return string echo the html pagination bar
584
- */
585
- function pagination( $which, $current, $total_items, $per_page ) {
586
-
587
- $total_pages = ($per_page > 0) ? ceil( $total_items / $per_page ) : 1;
588
-
589
- $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
590
-
591
- $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
592
-
593
- $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
594
-
595
- $page_links = array();
596
-
597
- $disable_first = $disable_last = '';
598
- if ( $current == 1 )
599
- $disable_first = ' disabled';
600
- if ( $current == $total_pages )
601
- $disable_last = ' disabled';
602
-
603
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
604
- 'first-page' . $disable_first,
605
- esc_attr__( 'Go to the first page' ),
606
- esc_url( remove_query_arg( 'paged', $current_url ) ),
607
- '&laquo;'
608
- );
609
-
610
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
611
- 'prev-page' . $disable_first,
612
- esc_attr__( 'Go to the previous page' ),
613
- esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
614
- '&lsaquo;'
615
- );
616
-
617
- if ( 'bottom' == $which )
618
- $html_current_page = $current;
619
- else
620
- $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
621
- esc_attr__( 'Current page' ),
622
- esc_attr( 'post_paged' ),
623
- $current,
624
- strlen( $total_pages )
625
- );
626
-
627
- $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
628
- $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
629
-
630
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
631
- 'next-page' . $disable_last,
632
- esc_attr__( 'Go to the next page' ),
633
- esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
634
- '&rsaquo;'
635
- );
636
-
637
- $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
638
- 'last-page' . $disable_last,
639
- esc_attr__( 'Go to the last page' ),
640
- esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
641
- '&raquo;'
642
- );
643
-
644
- $output .= "\n<span class='pagination-links'>" . join( "\n", $page_links ) . '</span>';
645
-
646
- if ( $total_pages )
647
- $page_class = $total_pages < 2 ? ' one-page' : '';
648
- else
649
- $page_class = ' no-pages';
650
-
651
- $pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
652
-
653
- echo $pagination;
654
- }
655
-
656
- }
657
- ?>
 
1
+ <?php
2
+
3
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
+
5
+ class nggManageGallery {
6
+
7
+ var $mode = 'main';
8
+ var $gid = false;
9
+ var $pid = false;
10
+ var $base_page = 'admin.php?page=nggallery-manage-gallery';
11
+ var $search_result = false;
12
+
13
+ // initiate the manage page
14
+ function nggManageGallery() {
15
+
16
+ // GET variables
17
+ if( isset($_GET['gid']) )
18
+ $this->gid = (int) $_GET['gid'];
19
+ if( isset($_GET['pid']) )
20
+ $this->pid = (int) $_GET['pid'];
21
+ if( isset($_GET['mode']) )
22
+ $this->mode = trim ($_GET['mode']);
23
+ // Check for pagination request, avoid post process of other submit button, exclude search results
24
+ if ( isset($_POST['post_paged']) && !isset($_GET['s'] ) ) {
25
+ if ( $_GET['paged'] != $_POST['post_paged'] ) {
26
+ $_GET['paged'] = absint( $_POST['post_paged'] );
27
+ return;
28
+ }
29
+ }
30
+ // Should be only called via manage galleries overview
31
+ if ( isset($_POST['page']) && $_POST['page'] == 'manage-galleries' )
32
+ $this->post_processor_galleries();
33
+ // Should be only called via a edit single gallery page
34
+ if ( isset($_POST['page']) && $_POST['page'] == 'manage-images' )
35
+ $this->post_processor_images();
36
+ // Should be called via a publish dialog
37
+ if ( isset($_POST['page']) && $_POST['page'] == 'publish-post' )
38
+ $this->publish_post();
39
+ //Look for other POST process
40
+ if ( !empty($_POST) || !empty($_GET) )
41
+ $this->processor();
42
+
43
+ }
44
+
45
+ function controller() {
46
+
47
+ switch($this->mode) {
48
+ case 'sort':
49
+ include_once (dirname (__FILE__) . '/manage-sort.php');
50
+ nggallery_sortorder($this->gid);
51
+ break;
52
+ case 'edit':
53
+ include_once (dirname (__FILE__) . '/manage-images.php');
54
+ nggallery_picturelist();
55
+ break;
56
+ case 'main':
57
+ default:
58
+ include_once (dirname (__FILE__) . '/manage-galleries.php');
59
+ nggallery_manage_gallery_main();
60
+ break;
61
+ }
62
+ }
63
+
64
+ function processor() {
65
+
66
+ global $wpdb, $ngg, $nggdb;
67
+
68
+ // Delete a picture
69
+ if ($this->mode == 'delpic') {
70
+
71
+ //TODO:Remove also Tag reference
72
+ check_admin_referer('ngg_delpicture');
73
+ $image = $nggdb->find_image( $this->pid );
74
+ if ($image) {
75
+ if ($ngg->options['deleteImg']) {
76
+ @unlink($image->imagePath);
77
+ @unlink($image->thumbPath);
78
+ @unlink($image->imagePath . '_backup' );
79
+ }
80
+ do_action('ngg_delete_picture', $this->pid);
81
+ $result = nggdb::delete_image ( $this->pid );
82
+ }
83
+
84
+ if ($result)
85
+ nggGallery::show_message( __('Picture','nggallery').' \''.$this->pid.'\' '.__('deleted successfully','nggallery') );
86
+
87
+ $this->mode = 'edit'; // show pictures
88
+
89
+ }
90
+
91
+ // Recover picture from backup
92
+ if ($this->mode == 'recoverpic') {
93
+
94
+ check_admin_referer('ngg_recoverpicture');
95
+ $image = $nggdb->find_image( $this->pid );
96
+ // bring back the old image
97
+ nggAdmin::recover_image($image);
98
+ nggAdmin::create_thumbnail($image);
99
+
100
+ nggGallery::show_message(__('Operation successful. Please clear your browser cache.',"nggallery"));
101
+
102
+ $this->mode = 'edit'; // show pictures
103
+
104
+ }
105
+
106
+ // will be called after a ajax operation
107
+ if (isset ($_POST['ajax_callback'])) {
108
+ if ($_POST['ajax_callback'] == 1)
109
+ nggGallery::show_message(__('Operation successful. Please clear your browser cache.',"nggallery"));
110
+ }
111
+
112
+ // show sort order
113
+ if ( isset ($_POST['sortGallery']) )
114
+ $this->mode = 'sort';
115
+
116
+ if ( isset ($_GET['s']) )
117
+ $this->search_images();
118
+
119
+ }
120
+
121
+ function post_processor_galleries() {
122
+ global $wpdb, $ngg, $nggdb;
123
+
124
+ // bulk update in a single gallery
125
+ if (isset ($_POST['bulkaction']) && isset ($_POST['doaction'])) {
126
+
127
+ check_admin_referer('ngg_bulkgallery');
128
+
129
+ switch ($_POST['bulkaction']) {
130
+ case 'no_action';
131
+ // No action
132
+ break;
133
+ case 'recover_images':
134
+ // Recover images from backup
135
+ // A prefix 'gallery_' will first fetch all ids from the selected galleries
136
+ nggAdmin::do_ajax_operation( 'gallery_recover_image' , $_POST['doaction'], __('Recover from backup','nggallery') );
137
+ break;
138
+ case 'set_watermark':
139
+ // Set watermark
140
+ // A prefix 'gallery_' will first fetch all ids from the selected galleries
141
+ nggAdmin::do_ajax_operation( 'gallery_set_watermark' , $_POST['doaction'], __('Set watermark','nggallery') );
142
+ break;
143
+ case 'import_meta':
144
+ // Import Metadata
145
+ // A prefix 'gallery_' will first fetch all ids from the selected galleries
146
+ nggAdmin::do_ajax_operation( 'gallery_import_metadata' , $_POST['doaction'], __('Import metadata','nggallery') );
147
+ break;
148
+ case 'delete_gallery':
149
+ // Delete gallery
150
+ if ( is_array($_POST['doaction']) ) {
151
+ $deleted = false;
152
+ foreach ( $_POST['doaction'] as $id ) {
153
+ // get the path to the gallery
154
+ $gallery = nggdb::find_gallery($id);
155
+ if ($gallery){
156
+ //TODO:Remove also Tag reference, look here for ids instead filename
157
+ $imagelist = $wpdb->get_col("SELECT filename FROM $wpdb->nggpictures WHERE galleryid = '$gallery->gid' ");
158
+ if ($ngg->options['deleteImg']) {
159
+ if (is_array($imagelist)) {
160
+ foreach ($imagelist as $filename) {
161
+ @unlink(WINABSPATH . $gallery->path . '/thumbs/thumbs_' . $filename);
162
+ @unlink(WINABSPATH . $gallery->path .'/'. $filename);
163
+ @unlink(WINABSPATH . $gallery->path .'/'. $filename . '_backup');
164
+ }
165
+ }
166
+ // delete folder
167
+ @rmdir( WINABSPATH . $gallery->path . '/thumbs' );
168
+ @rmdir( WINABSPATH . $gallery->path );
169
+ }
170
+ }
171
+ do_action('ngg_delete_gallery', $id);
172
+ $deleted = nggdb::delete_gallery( $id );
173
+ }
174
+
175
+ if($deleted)
176
+ nggGallery::show_message(__('Gallery deleted successfully ', 'nggallery'));
177
+
178
+ }
179
+ break;
180
+ }
181
+ }
182
+
183
+ if (isset ($_POST['addgallery']) && isset ($_POST['galleryname'])){
184
+
185
+ check_admin_referer('ngg_addgallery');
186
+
187
+ if ( !nggGallery::current_user_can( 'NextGEN Add new gallery' ))
188
+ wp_die(__('Cheatin&#8217; uh?'));
189
+
190
+ // get the default path for a new gallery
191
+ $defaultpath = $ngg->options['gallerypath'];
192
+ $newgallery = esc_attr( $_POST['galleryname']);
193
+ if ( !empty($newgallery) )
194
+ nggAdmin::create_gallery($newgallery, $defaultpath);
195
+
196
+ do_action( 'ngg_update_addgallery_page' );
197
+ }
198
+
199
+ if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_ResizeImages'])) {
200
+
201
+ check_admin_referer('ngg_thickbox_form');
202
+
203
+ //save the new values for the next operation
204
+ $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
205
+ $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
206
+ // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
207
+ update_option('ngg_options', $ngg->options);
208
+
209
+ $gallery_ids = explode(',', $_POST['TB_imagelist']);
210
+ // A prefix 'gallery_' will first fetch all ids from the selected galleries
211
+ nggAdmin::do_ajax_operation( 'gallery_resize_image' , $gallery_ids, __('Resize images','nggallery') );
212
+ }
213
+
214
+ if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_NewThumbnail'])) {
215
+
216
+ check_admin_referer('ngg_thickbox_form');
217
+
218
+ //save the new values for the next operation
219
+ $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
220
+ $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
221
+ $ngg->options['thumbfix'] = isset ($_POST['thumbfix']) ? true : false;
222
+ // What is in the case the user has no if cap 'NextGEN Change options' ? Check feedback
223
+ update_option('ngg_options', $ngg->options);
224
+
225
+ $gallery_ids = explode(',', $_POST['TB_imagelist']);
226
+ // A prefix 'gallery_' will first fetch all ids from the selected galleries
227
+ nggAdmin::do_ajax_operation( 'gallery_create_thumbnail' , $gallery_ids, __('Create new thumbnails','nggallery') );
228
+ }
229
+
230
+ }
231
+
232
+ function post_processor_images() {
233
+ global $wpdb, $ngg, $nggdb;
234
+
235
+ // bulk update in a single gallery
236
+ if (isset ($_POST['bulkaction']) && isset ($_POST['doaction'])) {
237
+
238
+ check_admin_referer('ngg_updategallery');
239
+
240
+ switch ($_POST['bulkaction']) {
241
+ case 'no_action';
242
+ break;
243
+ case 'rotate_cw':
244
+ nggAdmin::do_ajax_operation( 'rotate_cw' , $_POST['doaction'], __('Rotate images', 'nggallery') );
245
+ break;
246
+ case 'rotate_ccw':
247
+ nggAdmin::do_ajax_operation( 'rotate_ccw' , $_POST['doaction'], __('Rotate images', 'nggallery') );
248
+ break;
249
+ case 'recover_images':
250
+ nggAdmin::do_ajax_operation( 'recover_image' , $_POST['doaction'], __('Recover from backup', 'nggallery') );
251
+ break;
252
+ case 'set_watermark':
253
+ nggAdmin::do_ajax_operation( 'set_watermark' , $_POST['doaction'], __('Set watermark', 'nggallery') );
254
+ break;
255
+ case 'delete_images':
256
+ if ( is_array($_POST['doaction']) ) {
257
+ foreach ( $_POST['doaction'] as $imageID ) {
258
+ $image = $nggdb->find_image( $imageID );
259
+ if ($image) {
260
+ if ($ngg->options['deleteImg']) {
261
+ @unlink($image->imagePath);
262
+ @unlink($image->thumbPath);
263
+ @unlink($image->imagePath."_backup");
264
+ }
265
+ do_action('ngg_delete_picture', $image->pid);
266
+ $delete_pic = nggdb::delete_image( $image->pid );
267
+ }
268
+ }
269
+ if($delete_pic)
270
+ nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery'));
271
+ }
272
+ break;
273
+ case 'import_meta':
274
+ nggAdmin::do_ajax_operation( 'import_metadata' , $_POST['doaction'], __('Import metadata', 'nggallery') );
275
+ break;
276
+ }
277
+ }
278
+
279
+ if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_ResizeImages'])) {
280
+
281
+ check_admin_referer('ngg_thickbox_form');
282
+
283
+ //save the new values for the next operation
284
+ $ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
285
+ $ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
286
+
287
+ update_option('ngg_options', $ngg->options);
288
+
289
+ $pic_ids = explode(',', $_POST['TB_imagelist']);
290
+ nggAdmin::do_ajax_operation( 'resize_image' , $pic_ids, __('Resize images','nggallery') );
291
+ }
292
+
293
+ if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_NewThumbnail'])) {
294
+
295
+ check_admin_referer('ngg_thickbox_form');
296
+
297
+ //save the new values for the next operation
298
+ $ngg->options['thumbwidth'] = (int) $_POST['thumbwidth'];
299
+ $ngg->options['thumbheight'] = (int) $_POST['thumbheight'];
300
+ $ngg->options['thumbfix'] = isset ( $_POST['thumbfix'] ) ? true : false;
301
+ update_option('ngg_options', $ngg->options);
302
+
303
+ $pic_ids = explode(',', $_POST['TB_imagelist']);
304
+ nggAdmin::do_ajax_operation( 'create_thumbnail' , $pic_ids, __('Create new thumbnails','nggallery') );
305
+ }
306
+
307
+ if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_SelectGallery'])) {
308
+
309
+ check_admin_referer('ngg_thickbox_form');
310
+
311
+ $pic_ids = explode(',', $_POST['TB_imagelist']);
312
+ $dest_gid = (int) $_POST['dest_gid'];
313
+
314
+ switch ($_POST['TB_bulkaction']) {
315
+ case 'copy_to':
316
+ // Copy images
317
+ nggAdmin::copy_images( $pic_ids, $dest_gid );
318
+ break;
319
+ case 'move_to':
320
+ // Move images
321
+ nggAdmin::move_images( $pic_ids, $dest_gid );
322
+ break;
323
+ }
324
+ }
325
+
326
+ if (isset ($_POST['TB_bulkaction']) && isset ($_POST['TB_EditTags'])) {
327
+ // do tags update
328
+
329
+ check_admin_referer('ngg_thickbox_form');
330
+
331
+ // get the images list
332
+ $pic_ids = explode(',', $_POST['TB_imagelist']);
333
+ $taglist = explode(',', $_POST['taglist']);
334
+ $taglist = array_map('trim', $taglist);
335
+
336
+ if (is_array($pic_ids)) {
337
+
338
+ foreach($pic_ids as $pic_id) {
339
+
340
+ // which action should be performed ?
341
+ switch ($_POST['TB_bulkaction']) {
342
+ case 'no_action';
343
+ // No action
344
+ break;
345
+ case 'overwrite_tags':
346
+ // Overwrite tags
347
+ wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
348
+ break;
349
+ case 'add_tags':
350
+ // Add / append tags
351
+ wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
352
+ break;
353
+ case 'delete_tags':
354
+ // Delete tags
355
+ $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
356
+ // get the slugs, to vaoid case sensitive problems
357
+ $slugarray = array_map('sanitize_title', $taglist);
358
+ $oldtags = array_map('sanitize_title', $oldtags);
359
+ // compare them and return the diff
360
+ $newtags = array_diff($oldtags, $slugarray);
361
+ wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
362
+ break;
363
+ }
364
+ }
365
+
366
+ nggGallery::show_message( __('Tags changed', 'nggallery') );
367
+ }
368
+ }
369
+
370
+ if (isset ($_POST['updatepictures']) ) {
371
+ // Update pictures
372
+
373
+ check_admin_referer('ngg_updategallery');
374
+
375
+ if ( nggGallery::current_user_can( 'NextGEN Edit gallery options' ) && !isset ($_GET['s']) ) {
376
+
377
+ if ( nggGallery::current_user_can( 'NextGEN Edit gallery title' )) {
378
+ // don't forget to update the slug
379
+ $slug = nggdb::get_unique_slug( sanitize_title( $_POST['title'] ), 'gallery', $this->gid );
380
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET title= '%s', slug= '%s' WHERE gid = %d", esc_attr($_POST['title']), $slug, $this->gid) );
381
+ }
382
+ if ( nggGallery::current_user_can( 'NextGEN Edit gallery path' ))
383
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET path= '%s' WHERE gid = %d", untrailingslashit ( str_replace('\\', '/', trim( stripslashes($_POST['path']) )) ), $this->gid ) );
384
+ if ( nggGallery::current_user_can( 'NextGEN Edit gallery description' ))
385
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET galdesc= '%s' WHERE gid = %d", esc_attr( $_POST['gallerydesc'] ), $this->gid) );
386
+ if ( nggGallery::current_user_can( 'NextGEN Edit gallery page id' ))
387
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET pageid= '%d' WHERE gid = %d", (int) $_POST['pageid'], $this->gid) );
388
+ if ( nggGallery::current_user_can( 'NextGEN Edit gallery preview pic' ))
389
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET previewpic= '%d' WHERE gid = %d", (int) $_POST['previewpic'], $this->gid) );
390
+ if ( isset ($_POST['author']) && nggGallery::current_user_can( 'NextGEN Edit gallery author' ) )
391
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggallery SET author= '%d' WHERE gid = %d", (int) $_POST['author'], $this->gid) );
392
+
393
+ wp_cache_delete($this->gid, 'ngg_gallery');
394
+
395
+ }
396
+
397
+ $this->update_pictures();
398
+
399
+ //hook for other plugin to update the fields
400
+ do_action('ngg_update_gallery', $this->gid, $_POST);
401
+
402
+ nggGallery::show_message(__('Update successful',"nggallery"));
403
+ }
404
+
405
+ if (isset ($_POST['scanfolder'])) {
406
+ // Rescan folder
407
+ check_admin_referer('ngg_updategallery');
408
+
409
+ $gallerypath = $wpdb->get_var("SELECT path FROM $wpdb->nggallery WHERE gid = '$this->gid' ");
410
+ nggAdmin::import_gallery($gallerypath);
411
+ }
412
+
413
+ if (isset ($_POST['addnewpage'])) {
414
+ // Add a new page
415
+
416
+ check_admin_referer('ngg_updategallery');
417
+
418
+ $parent_id = esc_attr($_POST['parent_id']);
419
+ $gallery_title = esc_attr($_POST['title']);
420
+ $gallery_name = $wpdb->get_var("SELECT name FROM $wpdb->nggallery WHERE gid = '$this->gid' ");
421
+
422
+ // Create a WP page
423
+ global $user_ID;
424
+
425
+ $page['post_type'] = 'page';
426
+ $page['post_content'] = '[nggallery id=' . $this->gid . ']';
427
+ $page['post_parent'] = $parent_id;
428
+ $page['post_author'] = $user_ID;
429
+ $page['post_status'] = 'publish';
430
+ $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
431
+ $page = apply_filters('ngg_add_new_page', $page, $this->gid);
432
+
433
+ $gallery_pageid = wp_insert_post ($page);
434
+ if ($gallery_pageid != 0) {
435
+ $result = $wpdb->query("UPDATE $wpdb->nggallery SET title= '$gallery_title', pageid = '$gallery_pageid' WHERE gid = '$this->gid'");
436
+ wp_cache_delete($this->gid, 'ngg_gallery');
437
+ nggGallery::show_message( __('New gallery page ID','nggallery'). ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' .__('created','nggallery') );
438
+ }
439
+
440
+ do_action('ngg_gallery_addnewpage', $this->gid);
441
+ }
442
+ }
443
+
444
+ /**
445
+ * Publish a new post with the shortcode from the selected image
446
+ *
447
+ * @since 1.7.0
448
+ * @return void
449
+ */
450
+ function publish_post() {
451
+
452
+ check_admin_referer('publish-post');
453
+
454
+ // Create a WP page
455
+ global $user_ID, $ngg;
456
+
457
+ $ngg->options['publish_width'] = (int) $_POST['width'];
458
+ $ngg->options['publish_height'] = (int) $_POST['height'];
459
+ $ngg->options['publish_align'] = $_POST['align'];
460
+ $align = ( $ngg->options['publish_align'] == 'none') ? '' : 'float='.$ngg->options['publish_align'];
461
+
462
+ //save the new values for the next operation
463
+ update_option('ngg_options', $ngg->options);
464
+
465
+ $post['post_type'] = 'post';
466
+ $post['post_content'] = '[singlepic id=' . intval($_POST['pid']) . ' w=' . $ngg->options['publish_width'] . ' h=' . $ngg->options['publish_height'] . ' ' . $align . ']';
467
+ $post['post_author'] = $user_ID;
468
+ $post['post_status'] = isset ( $_POST['publish'] ) ? 'publish' : 'draft';
469
+ $post['post_title'] = $_POST['post_title'];
470
+ $post = apply_filters('ngg_add_new_post', $post, $_POST['pid']);
471
+
472
+ $post_id = wp_insert_post ($post);
473
+
474
+ if ($post_id != 0)
475
+ nggGallery::show_message( __('Published a new post','nggallery') );
476
+
477
+ }
478
+
479
+ function update_pictures() {
480
+ global $wpdb, $nggdb;
481
+
482
+ //TODO:Error message when update failed
483
+
484
+ $description = isset ( $_POST['description'] ) ? $_POST['description'] : array();
485
+ $alttext = isset ( $_POST['alttext'] ) ? $_POST['alttext'] : array();
486
+ $exclude = isset ( $_POST['exclude'] ) ? $_POST['exclude'] : false;
487
+ $taglist = isset ( $_POST['tags'] ) ? $_POST['tags'] : false;
488
+ $pictures = isset ( $_POST['pid'] ) ? $_POST['pid'] : false;
489
+ $date = isset ( $_POST['date'] ) ? $_POST['date'] : "NOW()"; //Not sure if NOW() will work or not but in theory it should
490
+
491
+ if ( is_array($pictures) ){
492
+ foreach( $pictures as $pid ){
493
+ $image = $nggdb->find_image( $pid );
494
+ if ($image) {
495
+ // description field
496
+ $image->description = $description[$image->pid];
497
+ $image->date = $date[$image->pid];
498
+ // only uptade this field if someone change the alttext
499
+ if ( $image->alttext != $alttext[$image->pid] ) {
500
+ $image->alttext = $alttext[$image->pid];
501
+ $image->image_slug = nggdb::get_unique_slug( sanitize_title( $image->alttext ), 'image', $image->pid );
502
+ }
503
+
504
+ // set exclude flag
505
+ if ( is_array($exclude) )
506
+ $image->exclude = ( array_key_exists($image->pid, $exclude) )? 1 : 0;
507
+ else
508
+ $image->exclude = 0;
509
+
510
+ // update the database
511
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggpictures SET image_slug = '%s', alttext = '%s', description = '%s', exclude = %d, imagedate = %s WHERE pid = %d",
512
+ $image->image_slug, $image->alttext, $image->description, $image->exclude, $image->date, $image->pid) );
513
+ // remove from cache
514
+ wp_cache_delete($image->pid, 'ngg_image');
515
+
516
+ // hook for other plugins after image is updated
517
+ do_action('ngg_image_updated', $image);
518
+ }
519
+
520
+ }
521
+ }
522
+
523
+ //TODO: This produce 300-400 queries !
524
+ if ( is_array($taglist) ){
525
+ foreach($taglist as $key=>$value) {
526
+ $tags = explode(',', $value);
527
+ wp_set_object_terms($key, $tags, 'ngg_tag');
528
+ }
529
+ }
530
+
531
+ return;
532
+ }
533
+
534
+ // Check if user can select a author
535
+ function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
536
+ global $wpdb;
537
+
538
+ $user = new WP_User( $user_id );
539
+
540
+ if ( ! $user->has_cap('NextGEN Manage others gallery') ) {
541
+ if ( $user->has_cap('NextGEN Manage gallery') || $exclude_zeros == false )
542
+ return array($user->id);
543
+ else
544
+ return false;
545
+ }
546
+
547
+ $level_key = $wpdb->prefix . 'user_level';
548
+ $query = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$level_key'";
549
+ if ( $exclude_zeros )
550
+ $query .= " AND meta_value != '0'";
551
+
552
+ return $wpdb->get_col( $query );
553
+ }
554
+
555
+ function search_images() {
556
+ global $nggdb;
557
+
558
+ if ( empty($_GET['s']) )
559
+ return;
560
+ //on what ever reason I need to set again the query var
561
+ set_query_var('s', $_GET['s']);
562
+ $request = get_search_query();
563
+
564
+ // look now for the images
565
+ $search_for_images = (array) $nggdb->search_for_images( $request );
566
+ $search_for_tags = (array) nggTags::find_images_for_tags( $request , 'ASC' );
567
+
568
+ // finally merge the two results together
569
+ $this->search_result = array_merge( $search_for_images , $search_for_tags );
570
+
571
+ // TODO: Currently we didn't support a proper pagination
572
+ $nggdb->paged['total_objects'] = $nggdb->paged['objects_per_page'] = count ($this->search_result) ;
573
+ $nggdb->paged['max_objects_per_page'] = 1;
574
+
575
+ // show pictures page
576
+ $this->mode = 'edit';
577
+ }
578
+
579
+ /**
580
+ * Display the pagination.
581
+ *
582
+ * @since 1.8.0
583
+ * @author taken from WP core (see includes/class-wp-list-table.php)
584
+ * @return string echo the html pagination bar
585
+ */
586
+ function pagination( $which, $current, $total_items, $per_page ) {
587
+
588
+ $total_pages = ($per_page > 0) ? ceil( $total_items / $per_page ) : 1;
589
+
590
+ $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
591
+
592
+ $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
593
+
594
+ $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
595
+
596
+ $page_links = array();
597
+
598
+ $disable_first = $disable_last = '';
599
+ if ( $current == 1 )
600
+ $disable_first = ' disabled';
601
+ if ( $current == $total_pages )
602
+ $disable_last = ' disabled';
603
+
604
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
605
+ 'first-page' . $disable_first,
606
+ esc_attr__( 'Go to the first page' ),
607
+ esc_url( remove_query_arg( 'paged', $current_url ) ),
608
+ '&laquo;'
609
+ );
610
+
611
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
612
+ 'prev-page' . $disable_first,
613
+ esc_attr__( 'Go to the previous page' ),
614
+ esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
615
+ '&lsaquo;'
616
+ );
617
+
618
+ if ( 'bottom' == $which )
619
+ $html_current_page = $current;
620
+ else
621
+ $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
622
+ esc_attr__( 'Current page' ),
623
+ esc_attr( 'post_paged' ),
624
+ $current,
625
+ strlen( $total_pages )
626
+ );
627
+
628
+ $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
629
+ $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
630
+
631
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
632
+ 'next-page' . $disable_last,
633
+ esc_attr__( 'Go to the next page' ),
634
+ esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
635
+ '&rsaquo;'
636
+ );
637
+
638
+ $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
639
+ 'last-page' . $disable_last,
640
+ esc_attr__( 'Go to the last page' ),
641
+ esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
642
+ '&raquo;'
643
+ );
644
+
645
+ $output .= "\n<span class='pagination-links'>" . join( "\n", $page_links ) . '</span>';
646
+
647
+ if ( $total_pages )
648
+ $page_class = $total_pages < 2 ? ' one-page' : '';
649
+ else
650
+ $page_class = ' no-pages';
651
+
652
+ $pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
653
+
654
+ echo $pagination;
655
+ }
656
+
657
+ }
658
+ ?>
admin/media-upload.php CHANGED
@@ -1,282 +1,282 @@
1
- <?php
2
-
3
- /**
4
- * @title Add action/filter for the upload tab
5
- * @author Alex Rabe
6
- *
7
- */
8
-
9
- function ngg_wp_upload_tabs ($tabs) {
10
-
11
- $newtab = array('nextgen' => __('NextCellent Gallery','nggallery'));
12
-
13
- return array_merge($tabs,$newtab);
14
- }
15
-
16
- add_filter('media_upload_tabs', 'ngg_wp_upload_tabs');
17
-
18
- function media_upload_nextgen() {
19
-
20
- // Not in use
21
- $errors = false;
22
-
23
- // Generate TinyMCE HTML output
24
- if ( isset($_POST['send']) ) {
25
- $keys = array_keys($_POST['send']);
26
- $send_id = (int) array_shift($keys);
27
- $image = $_POST['image'][$send_id];
28
- $alttext = stripslashes( htmlspecialchars ($image['alttext'], ENT_QUOTES));
29
- $description = stripslashes (htmlspecialchars($image['description'], ENT_QUOTES));
30
-
31
- // here is no new line allowed
32
- $clean_description = preg_replace("/\n|\r\n|\r$/", " ", $description);
33
- $img = nggdb::find_image($send_id);
34
- $thumbcode = $img->get_thumbcode();
35
- $class="ngg-singlepic ngg-{$image['align']}";
36
-
37
- // Build output
38
- if ($image['size'] == "thumbnail")
39
- $html = "<img src='{$image['thumb']}' alt='$alttext' class='$class' />";
40
- // Wrap the link to the fullsize image around
41
- $html = "<a $thumbcode href='{$image['url']}' title='$clean_description'>$html</a>";
42
-
43
- if ($image['size'] == "full")
44
- $html = "<img src='{$image['url']}' alt='$alttext' class='$class' />";
45
-
46
- if ($image['size'] == "singlepic")
47
- $html = "[singlepic id=$send_id w=320 h=240 float={$image['align']}]";
48
-
49
- media_upload_nextgen_save_image();
50
-
51
- // Return it to TinyMCE
52
- return media_send_to_editor($html);
53
- }
54
-
55
- // Save button
56
- if ( isset($_POST['save']) ) {
57
- media_upload_nextgen_save_image();
58
- }
59
-
60
- return wp_iframe( 'media_upload_nextgen_form', $errors );
61
- }
62
-
63
- add_action('media_upload_nextgen', 'media_upload_nextgen');
64
-
65
- function media_upload_nextgen_save_image() {
66
-
67
- global $wpdb;
68
-
69
- check_admin_referer('ngg-media-form');
70
-
71
- if ( !empty($_POST['image']) ) foreach ( $_POST['image'] as $image_id => $image ) {
72
-
73
- // create a unique slug
74
- $image_slug = nggdb::get_unique_slug( sanitize_title( $image['alttext'] ), 'image' );
75
- $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggpictures SET image_slug= '%s', alttext= '%s', description = '%s' WHERE pid = %d", $image_slug, $image['alttext'], $image['description'], $image_id));
76
- wp_cache_delete($image_id, 'ngg_image');
77
- }
78
- }
79
-
80
- function media_upload_nextgen_form($errors) {
81
-
82
- global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $ngg, $nggdb;
83
-
84
- media_upload_header();
85
-
86
- $post_id = intval($_REQUEST['post_id']);
87
- $galleryID = 0;
88
- $total = 1;
89
- $picarray = array();
90
-
91
- $form_action_url = site_url( "wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=nextgen&post_id=$post_id", 'admin');
92
-
93
- // Get number of images in gallery
94
- if ( isset($_REQUEST['select_gal']) ){
95
- $galleryID = (int) $_REQUEST['select_gal'];
96
- $total = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = '$galleryID'");
97
- }
98
-
99
- // Build navigation
100
- $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
101
- if ( $_GET['paged'] < 1 )
102
- $_GET['paged'] = 1;
103
- $start = ( $_GET['paged'] - 1 ) * 10;
104
- if ( $start < 1 )
105
- $start = 0;
106
-
107
- // Get the images
108
- if ( $galleryID != 0 )
109
- $picarray = $wpdb->get_col("SELECT pid FROM $wpdb->nggpictures WHERE galleryid = '$galleryID' AND exclude != 1 ORDER BY {$ngg->options['galSort']} {$ngg->options['galSortDir']} LIMIT $start, 10 ");
110
-
111
- // WP-Core code for Post-thumbnail
112
- $calling_post_id = 0;
113
- if ( isset( $_GET['post_id'] ) )
114
- $calling_post_id = $_GET['post_id'];
115
-
116
- ?>
117
-
118
- <script type="text/javascript">
119
- <!--
120
- function NGGSetAsThumbnail(id){
121
- var $link = jQuery('a#ngg-post-thumbnail-' + id);
122
-
123
- $link.text( setPostThumbnailL10n.saving );
124
- jQuery.post(ajaxurl, {
125
- action:"ngg_set_post_thumbnail", post_id: post_id, thumbnail_id: id, cookie: encodeURIComponent(document.cookie)
126
- }, function(str){
127
- var win = window.dialogArguments || opener || parent || top;
128
- $link.text( setPostThumbnailL10n.setThumbnail );
129
- if ( str == '0' ) {
130
- alert( setPostThumbnailL10n.error );
131
- } else {
132
- jQuery('a.ngg-post-thumbnail').show();
133
- $link.text( setPostThumbnailL10n.done );
134
- $link.fadeOut( 2000 );
135
- // set some id as meta input filed
136
- win.WPSetThumbnailID('ngg-' + id);
137
- // replace the meta box with the image
138
- win.WPSetThumbnailHTML(str);
139
- }
140
- }
141
- );
142
- }
143
- //-->
144
- </script>
145
-
146
- <form id="filter" action="" method="get">
147
- <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
148
- <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
149
- <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
150
-
151
- <div class="tablenav">
152
- <?php
153
- $page_links = paginate_links( array(
154
- 'base' => add_query_arg( 'paged', '%#%' ),
155
- 'format' => '',
156
- 'total' => ceil($total / 10),
157
- 'current' => $_GET['paged']
158
- ));
159
-
160
- if ( $page_links )
161
- echo "<div class='tablenav-pages'>$page_links</div>";
162
- ?>
163
-
164
- <div class="alignleft actions">
165
- <select id="select_gal" name="select_gal" style="width:120px;">;
166
- <option value="0" <?php selected('0', $galleryID); ?> ><?php esc_attr( _e('No gallery',"nggallery") ); ?></option>
167
- <?php
168
- // Show gallery selection
169
- $gallerylist = $nggdb->find_all_galleries();
170
- if(is_array($gallerylist)) {
171
- foreach($gallerylist as $gallery) {
172
- $selected = ($gallery->gid == $galleryID )? ' selected="selected"' : "";
173
- echo '<option value="'.$gallery->gid.'"'.$selected.' >'.$gallery->title.'</option>'."\n";
174
- }
175
- }
176
- ?>
177
- </select>
178
- <input type="submit" id="show-gallery" value="<?php esc_attr( _e('Select &#187;','nggallery') ); ?>" class="button-secondary" />
179
- </div>
180
- <br style="clear:both;" />
181
- </div>
182
- </form>
183
-
184
- <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form" id="library-form">
185
-
186
- <?php wp_nonce_field('ngg-media-form'); ?>
187
-
188
- <script type="text/javascript">
189
- <!--
190
- jQuery(function($){
191
- var preloaded = $(".media-item.preloaded");
192
- if ( preloaded.length > 0 ) {
193
- preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
194
- updateMediaForm();
195
- }
196
- });
197
- -->
198
- </script>
199
-
200
- <div id="media-items">
201
- <?php
202
- if( is_array($picarray) ) {
203
- foreach ($picarray as $picid) {
204
- //TODO:Reduce SQL Queries
205
- $picture = nggdb::find_image($picid);
206
- ?>
207
- <div id='media-item-<?php echo $picid ?>' class='media-item preloaded'>
208
- <div class='filename'></div>
209
- <a class='toggle describe-toggle-on' href='#'><?php esc_attr( _e('Show', "nggallery") ); ?></a>
210
- <a class='toggle describe-toggle-off' href='#'><?php esc_attr( _e('Hide', "nggallery") );?></a>
211
- <div class='filename new'><?php echo ( empty($picture->alttext) ) ? wp_html_excerpt( esc_html( $picture->filename ),60) : stripslashes( wp_html_excerpt( esc_html( $picture->alttext ),60) ); ?></div>
212
- <table class='slidetoggle describe startclosed'><tbody>
213
- <tr>
214
- <td rowspan='4'><img class='thumbnail' alt='<?php echo esc_attr( $picture->alttext ); ?>' src='<?php echo esc_attr( $picture->thumbURL ); ?>'/></td>
215
- <td><?php esc_html( _e('Image ID:', "nggallery") ); ?><?php echo $picid ?></td>
216
- </tr>
217
- <tr><td><?php echo esc_html( $picture->filename ); ?></td></tr>
218
- <tr><td><?php echo esc_html( stripslashes($picture->alttext) ); ?></td></tr>
219
- <tr><td>&nbsp;</td></tr>
220
- <tr>
221
- <td class="label"><label for="image[<?php echo $picid ?>][alttext]"><?php esc_attr_e('Alt/Title text', "nggallery") ;?></label></td>
222
- <td class="field"><input id="image[<?php echo $picid ?>][alttext]" name="image[<?php echo $picid ?>][alttext]" value="<?php esc_attr_e( stripslashes($picture->alttext) ); ?>" type="text"/></td>
223
- </tr>
224
- <tr>
225
- <td class="label"><label for="image[<?php echo $picid ?>][description]"><?php esc_attr_e("Description","nggallery") ; ?></label></td>
226
- <td class="field"><textarea name="image[<?php echo $picid ?>][description]" id="image[<?php echo $picid ?>][description]"><?php esc_attr_e( stripslashes($picture->description) ); ?></textarea></td>
227
- </tr>
228
- <tr class="align">
229
- <td class="label"><label for="image[<?php echo $picid ?>][align]"><?php esc_attr_e("Alignment"); ?></label></td>
230
- <td class="field">
231
- <input name="image[<?php echo $picid ?>][align]" id="image-align-none-<?php echo $picid ?>" checked="checked" value="none" type="radio" />
232
- <label for="image-align-none-<?php echo $picid ?>" class="align image-align-none-label"><?php esc_attr_e("None") ;?></label>
233
- <input name="image[<?php echo $picid ?>][align]" id="image-align-left-<?php echo $picid ?>" value="left" type="radio" />
234
- <label for="image-align-left-<?php echo $picid ?>" class="align image-align-left-label"><?php esc_attr_e("Left") ;?></label>
235
- <input name="image[<?php echo $picid ?>][align]" id="image-align-center-<?php echo $picid ?>" value="center" type="radio" />
236
- <label for="image-align-center-<?php echo $picid ?>" class="align image-align-center-label"><?php esc_attr_e("Center") ;?></label>
237
- <input name="image[<?php echo $picid ?>][align]" id="image-align-right-<?php echo $picid ?>" value="right" type="radio" />
238
- <label for="image-align-right-<?php echo $picid ?>" class="align image-align-right-label"><?php esc_attr_e("Right") ;?></label>
239
- </td>
240
- </tr>
241
- <tr class="image-size">
242
- <th class="label"><label for="image[<?php echo $picid ?>][size]"><span class="alignleft"><?php esc_attr_e("Size") ; ?></span></label>
243
- </th>
244
- <td class="field">
245
- <input name="image[<?php echo $picid ?>][size]" id="image-size-thumb-<?php echo $picid ?>" type="radio" checked="checked" value="thumbnail" />
246
- <label for="image-size-thumb-<?php echo $picid ?>"><?php esc_attr_e("Thumbnail") ; ?></label>
247
- <input name="image[<?php echo $picid ?>][size]" id="image-size-full-<?php echo $picid ?>" type="radio" value="full" />
248
- <label for="image-size-full-<?php echo $picid ?>"><?php esc_attr_e("Full size") ; ?></label>
249
- <input name="image[<?php echo $picid ?>][size]" id="image-size-singlepic-<?php echo $picid ?>" type="radio" value="singlepic" />
250
- <label for="image-size-singlepic-<?php echo $picid ?>"><?php esc_attr_e("Singlepic", "nggallery") ; ?></label>
251
- </td>
252
- </tr>
253
- <tr class="submit">
254
- <td>
255
- <input type="hidden" name="image[<?php echo $picid ?>][thumb]" value="<?php echo esc_attr( $picture->thumbURL ); ?>" />
256
- <input type="hidden" name="image[<?php echo $picid ?>][url]" value="<?php echo esc_attr( $picture->imageURL ); ?>" />
257
- </td>
258
- <td class="savesend">
259
- <?php
260
- if ( $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) )
261
- echo "<a class='ngg-post-thumbnail' id='ngg-post-thumbnail-" . $picid . "' href='#' onclick='NGGSetAsThumbnail(\"$picid\");return false;'>" . esc_html__( 'Use as featured image' ) . "</a>";
262
- ?>
263
- <button type="submit" class="button" value="1" name="send[<?php echo $picid ?>]"><?php esc_html_e( 'Insert into Post' ); ?></button>
264
- </td>
265
- </tr>
266
- </tbody></table>
267
- </div>
268
- <?php
269
- }
270
- }
271
- ?>
272
- </div>
273
- <p class="ml-submit">
274
- <input type="submit" class="button savebutton" name="save" value="<?php esc_attr( _e('Save all changes','nggallery') ); ?>" />
275
- </p>
276
- <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
277
- <input type="hidden" name="select_gal" id="select_gal" value="<?php echo (int) $galleryID; ?>" />
278
- </form>
279
-
280
- <?php
281
- }
282
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * @title Add action/filter for the upload tab
5
+ * @author Alex Rabe
6
+ *
7
+ */
8
+
9
+ function ngg_wp_upload_tabs ($tabs) {
10
+
11
+ $newtab = array('nextgen' => __('NextCellent Gallery','nggallery'));
12
+
13
+ return array_merge($tabs,$newtab);
14
+ }
15
+
16
+ add_filter('media_upload_tabs', 'ngg_wp_upload_tabs');
17
+
18
+ function media_upload_nextgen() {
19
+
20
+ // Not in use
21
+ $errors = false;
22
+
23
+ // Generate TinyMCE HTML output
24
+ if ( isset($_POST['send']) ) {
25
+ $keys = array_keys($_POST['send']);
26
+ $send_id = (int) array_shift($keys);
27
+ $image = $_POST['image'][$send_id];
28
+ $alttext = stripslashes( htmlspecialchars ($image['alttext'], ENT_QUOTES));
29
+ $description = stripslashes (htmlspecialchars($image['description'], ENT_QUOTES));
30
+
31
+ // here is no new line allowed
32
+ $clean_description = preg_replace("/\n|\r\n|\r$/", " ", $description);
33
+ $img = nggdb::find_image($send_id);
34
+ $thumbcode = $img->get_thumbcode();
35
+ $class="ngg-singlepic ngg-{$image['align']}";
36
+
37
+ // Build output
38
+ if ($image['size'] == "thumbnail")
39
+ $html = "<img src='{$image['thumb']}' alt='$alttext' class='$class' />";
40
+ // Wrap the link to the fullsize image around
41
+ $html = "<a $thumbcode href='{$image['url']}' title='$clean_description'>$html</a>";
42
+
43
+ if ($image['size'] == "full")
44
+ $html = "<img src='{$image['url']}' alt='$alttext' class='$class' />";
45
+
46
+ if ($image['size'] == "singlepic")
47
+ $html = "[singlepic id=$send_id w=320 h=240 float={$image['align']}]";
48
+
49
+ media_upload_nextgen_save_image();
50
+
51
+ // Return it to TinyMCE
52
+ return media_send_to_editor($html);
53
+ }
54
+
55
+ // Save button
56
+ if ( isset($_POST['save']) ) {
57
+ media_upload_nextgen_save_image();
58
+ }
59
+
60
+ return wp_iframe( 'media_upload_nextgen_form', $errors );
61
+ }
62
+
63
+ add_action('media_upload_nextgen', 'media_upload_nextgen');
64
+
65
+ function media_upload_nextgen_save_image() {
66
+
67
+ global $wpdb;
68
+
69
+ check_admin_referer('ngg-media-form');
70
+
71
+ if ( !empty($_POST['image']) ) foreach ( $_POST['image'] as $image_id => $image ) {
72
+
73
+ // create a unique slug
74
+ $image_slug = nggdb::get_unique_slug( sanitize_title( $image['alttext'] ), 'image' );
75
+ $wpdb->query( $wpdb->prepare ("UPDATE $wpdb->nggpictures SET image_slug= '%s', alttext= '%s', description = '%s' WHERE pid = %d", $image_slug, $image['alttext'], $image['description'], $image_id));
76
+ wp_cache_delete($image_id, 'ngg_image');
77
+ }
78
+ }
79
+
80
+ function media_upload_nextgen_form($errors) {
81
+
82
+ global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types, $ngg, $nggdb;
83
+
84
+ media_upload_header();
85
+
86
+ $post_id = intval($_REQUEST['post_id']);
87
+ $galleryID = 0;
88
+ $total = 1;
89
+ $picarray = array();
90
+
91
+ $form_action_url = site_url( "wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=nextgen&post_id=$post_id", 'admin');
92
+
93
+ // Get number of images in gallery
94
+ if ( isset($_REQUEST['select_gal']) ){
95
+ $galleryID = (int) $_REQUEST['select_gal'];
96
+ $total = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = '$galleryID'");
97
+ }
98
+
99
+ // Build navigation
100
+ $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0;
101
+ if ( $_GET['paged'] < 1 )
102
+ $_GET['paged'] = 1;
103
+ $start = ( $_GET['paged'] - 1 ) * 10;
104
+ if ( $start < 1 )
105
+ $start = 0;
106
+
107
+ // Get the images
108
+ if ( $galleryID != 0 )
109
+ $picarray = $wpdb->get_col("SELECT pid FROM $wpdb->nggpictures WHERE galleryid = '$galleryID' AND exclude != 1 ORDER BY {$ngg->options['galSort']} {$ngg->options['galSortDir']} LIMIT $start, 10 ");
110
+
111
+ // WP-Core code for Post-thumbnail
112
+ $calling_post_id = 0;
113
+ if ( isset( $_GET['post_id'] ) )
114
+ $calling_post_id = $_GET['post_id'];
115
+
116
+ ?>
117
+
118
+ <script type="text/javascript">
119
+ <!--
120
+ function NGGSetAsThumbnail(id){
121
+ var $link = jQuery('a#ngg-post-thumbnail-' + id);
122
+
123
+ $link.text( setPostThumbnailL10n.saving );
124
+ jQuery.post(ajaxurl, {
125
+ action:"ngg_set_post_thumbnail", post_id: post_id, thumbnail_id: id, cookie: encodeURIComponent(document.cookie)
126
+ }, function(str){
127
+ var win = window.dialogArguments || opener || parent || top;
128
+ $link.text( setPostThumbnailL10n.setThumbnail );
129
+ if ( str == '0' ) {
130
+ alert( setPostThumbnailL10n.error );
131
+ } else {
132
+ jQuery('a.ngg-post-thumbnail').show();
133
+ $link.text( setPostThumbnailL10n.done );
134
+ $link.fadeOut( 2000 );
135
+ // set some id as meta input filed
136
+ win.WPSetThumbnailID('ngg-' + id);
137
+ // replace the meta box with the image
138
+ win.WPSetThumbnailHTML(str);
139
+ }
140
+ }
141
+ );
142
+ }
143
+ //-->
144
+ </script>
145
+
146
+ <form id="filter" action="" method="get">
147
+ <input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
148
+ <input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
149
+ <input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
150
+
151
+ <div class="tablenav">
152
+ <?php
153
+ $page_links = paginate_links( array(
154
+ 'base' => add_query_arg( 'paged', '%#%' ),
155
+ 'format' => '',
156
+ 'total' => ceil($total / 10),
157
+ 'current' => $_GET['paged']
158
+ ));
159
+
160
+ if ( $page_links )
161
+ echo "<div class='tablenav-pages'>$page_links</div>";
162
+ ?>
163
+
164
+ <div class="alignleft actions">
165
+ <select id="select_gal" name="select_gal" style="width:120px;">;
166
+ <option value="0" <?php selected('0', $galleryID); ?> ><?php esc_attr( _e('No gallery',"nggallery") ); ?></option>
167
+ <?php
168
+ // Show gallery selection
169
+ $gallerylist = $nggdb->find_all_galleries();
170
+ if(is_array($gallerylist)) {
171
+ foreach($gallerylist as $gallery) {
172
+ $selected = ($gallery->gid == $galleryID )? ' selected="selected"' : "";
173
+ echo '<option value="'.$gallery->gid.'"'.$selected.' >'.$gallery->title.'</option>'."\n";
174
+ }
175
+ }
176
+ ?>
177
+ </select>
178
+ <input type="submit" id="show-gallery" value="<?php esc_attr( _e('Select &#187;','nggallery') ); ?>" class="button-secondary" />
179
+ </div>
180
+ <br style="clear:both;" />
181
+ </div>
182
+ </form>
183
+
184
+ <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form" id="library-form">
185
+
186
+ <?php wp_nonce_field('ngg-media-form'); ?>
187
+
188
+ <script type="text/javascript">
189
+ <!--
190
+ jQuery(function($){
191
+ var preloaded = $(".media-item.preloaded");
192
+ if ( preloaded.length > 0 ) {
193
+ preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
194
+ updateMediaForm();
195
+ }
196
+ });
197
+ -->
198
+ </script>
199
+
200
+ <div id="media-items">
201
+ <?php
202
+ if( is_array($picarray) ) {
203
+ foreach ($picarray as $picid) {
204
+ //TODO:Reduce SQL Queries
205
+ $picture = nggdb::find_image($picid);
206
+ ?>
207
+ <div id='media-item-<?php echo $picid ?>' class='media-item preloaded'>
208
+ <div class='filename'></div>
209
+ <a class='toggle describe-toggle-on' href='#'><?php esc_attr( _e('Show', "nggallery") ); ?></a>
210
+ <a class='toggle describe-toggle-off' href='#'><?php esc_attr( _e('Hide', "nggallery") );?></a>
211
+ <div class='filename new'><?php echo ( empty($picture->alttext) ) ? wp_html_excerpt( esc_html( $picture->filename ),60) : stripslashes( wp_html_excerpt( esc_html( $picture->alttext ),60) ); ?></div>
212
+ <table class='slidetoggle describe startclosed'><tbody>
213
+ <tr>
214
+ <td rowspan='4'><img class='thumbnail' alt='<?php echo esc_attr( $picture->alttext ); ?>' src='<?php echo esc_attr( $picture->thumbURL ); ?>'/></td>
215
+ <td><?php esc_html( _e('Image ID:', "nggallery") ); ?><?php echo $picid ?></td>
216
+ </tr>
217
+ <tr><td><?php echo esc_html( $picture->filename ); ?></td></tr>
218
+ <tr><td><?php echo esc_html( stripslashes($picture->alttext) ); ?></td></tr>
219
+ <tr><td>&nbsp;</td></tr>
220
+ <tr>
221
+ <td class="label"><label for="image[<?php echo $picid ?>][alttext]"><?php esc_attr_e('Alt/Title text', "nggallery") ;?></label></td>
222
+ <td class="field"><input id="image[<?php echo $picid ?>][alttext]" name="image[<?php echo $picid ?>][alttext]" value="<?php esc_attr_e( stripslashes($picture->alttext) ); ?>" type="text"/></td>
223
+ </tr>
224
+ <tr>
225
+ <td class="label"><label for="image[<?php echo $picid ?>][description]"><?php esc_attr_e("Description","nggallery") ; ?></label></td>
226
+ <td class="field"><textarea name="image[<?php echo $picid ?>][description]" id="image[<?php echo $picid ?>][description]"><?php esc_attr_e( stripslashes($picture->description) ); ?></textarea></td>
227
+ </tr>
228
+ <tr class="align">
229
+ <td class="label"><label for="image[<?php echo $picid ?>][align]"><?php esc_attr_e("Alignment"); ?></label></td>
230
+ <td class="field">
231
+ <input name="image[<?php echo $picid ?>][align]" id="image-align-none-<?php echo $picid ?>" checked="checked" value="none" type="radio" />
232
+ <label for="image-align-none-<?php echo $picid ?>" class="align image-align-none-label"><?php esc_attr_e("None") ;?></label>
233
+ <input name="image[<?php echo $picid ?>][align]" id="image-align-left-<?php echo $picid ?>" value="left" type="radio" />
234
+ <label for="image-align-left-<?php echo $picid ?>" class="align image-align-left-label"><?php esc_attr_e("Left") ;?></label>
235
+ <input name="image[<?php echo $picid ?>][align]" id="image-align-center-<?php echo $picid ?>" value="center" type="radio" />
236
+ <label for="image-align-center-<?php echo $picid ?>" class="align image-align-center-label"><?php esc_attr_e("Center") ;?></label>
237
+ <input name="image[<?php echo $picid ?>][align]" id="image-align-right-<?php echo $picid ?>" value="right" type="radio" />
238
+ <label for="image-align-right-<?php echo $picid ?>" class="align image-align-right-label"><?php esc_attr_e("Right") ;?></label>
239
+ </td>
240
+ </tr>
241
+ <tr class="image-size">
242
+ <th class="label"><label for="image[<?php echo $picid ?>][size]"><span class="alignleft"><?php esc_attr_e("Size") ; ?></span></label>
243
+ </th>
244
+ <td class="field">
245
+ <input name="image[<?php echo $picid ?>][size]" id="image-size-thumb-<?php echo $picid ?>" type="radio" checked="checked" value="thumbnail" />
246
+ <label for="image-size-thumb-<?php echo $picid ?>"><?php esc_attr_e("Thumbnail") ; ?></label>
247
+ <input name="image[<?php echo $picid ?>][size]" id="image-size-full-<?php echo $picid ?>" type="radio" value="full" />
248
+ <label for="image-size-full-<?php echo $picid ?>"><?php esc_attr_e("Full size") ; ?></label>
249
+ <input name="image[<?php echo $picid ?>][size]" id="image-size-singlepic-<?php echo $picid ?>" type="radio" value="singlepic" />
250
+ <label for="image-size-singlepic-<?php echo $picid ?>"><?php esc_attr_e("Singlepic", "nggallery") ; ?></label>
251
+ </td>
252
+ </tr>
253
+ <tr class="submit">
254
+ <td>
255
+ <input type="hidden" name="image[<?php echo $picid ?>][thumb]" value="<?php echo esc_attr( $picture->thumbURL ); ?>" />
256
+ <input type="hidden" name="image[<?php echo $picid ?>][url]" value="<?php echo esc_attr( $picture->imageURL ); ?>" />
257
+ </td>
258
+ <td class="savesend">
259
+ <?php
260
+ if ( $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) )
261
+ echo "<a class='ngg-post-thumbnail' id='ngg-post-thumbnail-" . $picid . "' href='#' onclick='NGGSetAsThumbnail(\"$picid\");return false;'>" . esc_html__( 'Use as featured image' ) . "</a>";
262
+ ?>
263
+ <button type="submit" class="button" value="1" name="send[<?php echo $picid ?>]"><?php esc_html_e( 'Insert into Post' ); ?></button>
264
+ </td>
265
+ </tr>
266
+ </tbody></table>
267
+ </div>
268
+ <?php
269
+ }
270
+ }
271
+ ?>
272
+ </div>
273
+ <p class="ml-submit">
274
+ <input type="submit" class="button savebutton" name="save" value="<?php esc_attr( _e('Save all changes','nggallery') ); ?>" />
275
+ </p>
276
+ <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
277
+ <input type="hidden" name="select_gal" id="select_gal" value="<?php echo (int) $galleryID; ?>" />
278
+ </form>
279
+
280
+ <?php
281
+ }
282
+ ?>
admin/overview.php CHANGED
@@ -1,866 +1,849 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- /**
5
- * nggallery_admin_overview()
6
- * 20130410: FZSM: as part of initiative, avoid implementing spaghuetti code.
7
- * Introducing class to deal with code and functions to provide backward compatibility 100%
8
- * Add the admin overview the dashboard style
9
- * @return mixed content
10
- */
11
- function nggallery_admin_overview() {
12
- ?>
13
- <div class="wrap ngg-wrap">
14
- <?php include('templates/social_media_buttons.php'); ?>
15
- <?php screen_icon( 'nextgen-gallery' ); ?>
16
- <h2><?php _e('NextCellent Gallery Overview', 'nggallery') ?></h2>
17
- <?php if (version_compare(PHP_VERSION, '5.0.0', '<')) ngg_check_for_PHP5(); ?>
18
- <div id="dashboard-widgets-container" class="ngg-overview">
19
- <div id="dashboard-widgets" class="metabox-holder">
20
- <div id="post-body">
21
- <div id="dashboard-widgets-main-content">
22
- <div class="postbox-container" id="main-container" style="width:75%;">
23
- <?php do_meta_boxes('ngg_overview', 'left', ''); ?>
24
- </div>
25
- <div class="postbox-container" id="side-container" style="width:24%;">
26
- <?php do_meta_boxes('ngg_overview', 'right', ''); ?>
27
- </div>
28
- </div>
29
- </div>
30
- </div>
31
- </div>
32
- </div>
33
- <script type="text/javascript">
34
- //<![CDATA[
35
- var ajaxWidgets, ajaxPopulateWidgets;
36
-
37
- jQuery(document).ready( function($) {
38
- // These widgets are sometimes populated via ajax
39
- ajaxWidgets = [
40
- 'ngg_lastdonators',
41
- 'dashboard_primary',
42
- 'ngg_locale',
43
- 'dashboard_plugins'
44
- ];
45
-
46
- ajaxPopulateWidgets = function(el) {
47
- show = function(id, i) {
48
- var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
49
- if ( e.length ) {
50
- p = e.parent();
51
- setTimeout( function(){
52
- p.load('admin-ajax.php?action=ngg_dashboard&jax=' + id, '', function() {
53
- p.hide().slideDown('normal', function(){
54
- $(this).css('display', '');
55
- if ( 'dashboard_plugins' == id && $.isFunction(tb_init) )
56
- tb_init('#dashboard_plugins a.thickbox');
57
- });
58
- });
59
- }, i * 500 );
60
- }
61
- }
62
- if ( el ) {
63
- el = el.toString();
64
- if ( $.inArray(el, ajaxWidgets) != -1 )
65
- show(el, 0);
66
- } else {
67
- $.each( ajaxWidgets, function(i) {
68
- show(this, i);
69
- });
70
- }
71
- };
72
- ajaxPopulateWidgets();
73
- } );
74
-
75
- jQuery(document).ready( function($) {
76
- // postboxes setup
77
- postboxes.add_postbox_toggles('ngg-overview');
78
- });
79
- //]]>
80
- </script>
81
- <?php
82
- }
83
-
84
- /**
85
- * Load the meta boxes
86
- *
87
- */
88
- add_meta_box('dashboard_right_now', __('Welcome to NextCellent Gallery !', 'nggallery'), 'ngg_overview_right_now', 'ngg_overview', 'left', 'core');
89
- add_meta_box('ngg_meta_box', __('Help me help YOU!', 'nggallery'), 'nextcellent_overview::likeThisMetaBox', 'ngg_overview', 'right', 'core');
90
- if ( !(get_locale() == 'en_US') )
91
- add_meta_box('ngg_locale', __('Translation', 'nggallery'), 'ngg_widget_locale', 'ngg_overview', 'right', 'core');
92
- add_meta_box('dashboard_primary', __('Latest News', 'nggallery'), 'ngg_widget_overview_news', 'ngg_overview', 'left', 'core');
93
- //add_meta_box('ngg_lastdonators', __('Recent donators', 'nggallery'), 'ngg_widget_overview_donators', 'ngg_overview', 'right', 'core');
94
- if ( !is_multisite() || is_super_admin() ) {
95
- add_meta_box('ngg_plugin_check', __('Plugin Check', 'nggallery'), 'ngg_plugin_check', 'ngg_overview', 'right', 'core');
96
- add_meta_box('ngg_server', __('Server Settings', 'nggallery'), 'ngg_overview_server', 'ngg_overview', 'right', 'core');
97
- add_meta_box('dashboard_plugins', __('Related plugins', 'nggallery'), 'ngg_widget_related_plugins', 'ngg_overview', 'left', 'core');
98
- }
99
-
100
-
101
-
102
- /**
103
- * Ajax Check for conflict with other plugins/themes
104
- *
105
- * @return void
106
- */
107
- function ngg_plugin_check() {
108
-
109
- global $ngg;
110
- ?>
111
- <script type="text/javascript">
112
- (function($) {
113
- nggPluginCheck = {
114
-
115
- settings: {
116
- img_run: '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="icon" alt="started"/>',
117
- img_ok: '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" class="icon" alt="ok"/>',
118
- img_fail: '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" class="icon" alt="failed" />',
119
- domain: '<?php echo esc_url( home_url('index.php', is_ssl() ? 'https' : 'http') ); ?>'
120
- },
121
-
122
- run: function( index, state ) {
123
- ul = $('#plugin_check');
124
- s = this.settings;
125
- var step = 1;
126
- switch ( index ) {
127
- case 1:
128
- this.check1();
129
- break;
130
- case 2:
131
- this.check2( step );
132
- break;
133
- case 3:
134
- this.check3();
135
- break;
136
- }
137
- },
138
-
139
- // this function check if the json API will work with your theme & plugins
140
- check1 : function() {
141
- this.start(1);
142
- var req = $.ajax({
143
- dataType: 'json',
144
- url: s.domain,
145
- data:'callback=json&format=json&method=version',
146
- cache: false,
147
- timeout: 10000,
148
- success: function(msg){
149
- if (msg.version == '<?php echo $ngg->version; ?>')
150
- nggPluginCheck.success(1);
151
- else
152
- nggPluginCheck.failed(1);
153
- },
154
- error: function (msg) {
155
- nggPluginCheck.failed(1);
156
- },
157
- complete: function () {
158
- nggPluginCheck.run(2);
159
- }
160
- });
161
-
162
- },
163
-
164
- // this function check if GD lib can create images & thumbnails
165
- check2 : function( step ) {
166
- if (step == 1) this.start(2);
167
- var stop = false;
168
- var req = $.ajax({
169
- type: "POST",
170
- url: ajaxurl,
171
- data:"action=ngg_image_check&step=" + step,
172
- cache: false,
173
- timeout: 10000,
174
- success: function(msg){
175
- if (msg.stat == 'ok') {
176
- nggPluginCheck.success(2, msg.message);
177
- } else {
178
- if (step == 1)
179
- nggPluginCheck.failed(2);
180
- stop = true;
181
- }
182
-
183
- },
184
- error: function (msg) {
185
- if (step == 1)
186
- nggPluginCheck.failed(2);
187
- stop = true;
188
- },
189
- complete: function () {
190
- step++;
191
- if (step <= 11 && stop == false)
192
- nggPluginCheck.check2(step);
193
- else
194
- nggPluginCheck.run(3);
195
- }
196
- });
197
- },
198
-
199
- // this function check if wp_head / wp_footer is avaiable
200
- check3 : function() {
201
- this.start(3);
202
- var req = $.ajax({
203
- type: "POST",
204
- url: ajaxurl,
205
- data:"action=ngg_test_head_footer",
206
- cache: false,
207
- timeout: 10000,
208
- success: function(msg){
209
- if (msg == 'success')
210
- nggPluginCheck.success(3);
211
- else
212
- nggPluginCheck.failed(3, msg);
213
- },
214
- error: function (msg) {
215
- nggPluginCheck.failed(3);
216
- }
217
- });
218
- },
219
-
220
- start: function( id ) {
221
-
222
- s = this.settings;
223
- var field = "#check" + id;
224
-
225
- if ( ul.find(field + " img").length == 0)
226
- $(field).prepend( s.img_run );
227
- else
228
- $(field + " img").replaceWith( s.img_run );
229
-
230
- $(field + " .success").hide();
231
- $(field + " .failed").hide();
232
- $(field + " .default").replaceWith('<p class="default message"><?php echo esc_js( __('Running...', 'nggallery') ); ?></p> ');
233
- },
234
-
235
- success: function( id, msg ) {
236
-
237
- s = this.settings;
238
- var field = "#check" + id;
239
-
240
- if ( ul.find(field + " img").length == 0)
241
- $(field).prepend( s.img_ok );
242
- else
243
- $(field + " img").replaceWith( s.img_ok );
244
-
245
- $(field + " .default").hide();
246
- if (msg)
247
- $(field + " .success").replaceWith('<p class="success message">' + msg +' </p> ');
248
- else
249
- $(field + " .success").show();
250
-
251
- },
252
-
253
- failed: function( id, msg ) {
254
-
255
- s = this.settings;
256
- var field = "#check" + id;
257
-
258
- if ( ul.find(field + " img").length == 0)
259
- $(field).prepend( s.img_fail );
260
- else
261
- $(field + " img").replaceWith( s.img_fail );
262
-
263
- $(field + " .default").hide();
264
- if (msg)
265
- $(field + " .failed").replaceWith('<p class="failed message">' + msg +' </p> ');
266
- else
267
- $(field + " .failed").show();
268
-
269
- }
270
-
271
- };
272
- })(jQuery);
273
- </script>
274
- <div class="dashboard-widget-holder wp_dashboard_empty">
275
- <div class="ngg-dashboard-widget">
276
- <div class="dashboard-widget-content">
277
- <ul id="plugin_check" class="settings">
278
- <li id="check1">
279
- <strong><?php _e('Check plugin/theme conflict', 'nggallery'); ?></strong>
280
- <p class="default message"><?php _e('Not tested', 'nggallery'); ?></p>
281
- <p class="success message" style="display: none;"><?php _e('No conflict could be detected', 'nggallery'); ?></p>
282
- <p class="failed message" style="display: none;"><?php _e('Test failed, disable other plugins & switch to default theme', 'nggallery'); ?></p>
283
- </li>
284
- <li id="check2">
285
- <strong><?php _e('Test image function', 'nggallery'); ?></strong>
286
- <p class="default message"><?php _e('Not tested', 'nggallery'); ?></p>
287
- <p class="success message" style="display: none;"><?php _e('The plugin could create images', 'nggallery'); ?></p>
288
- <p class="failed message" style="display: none;"><?php _e('Couldn\'t create image, check your memory limit', 'nggallery'); ?></p>
289
- </li>
290
- <li id="check3">
291
- <strong><?php _e('Check theme compatibility', 'nggallery'); ?></strong>
292
- <p class="default message"><?php _e('Not tested', 'nggallery'); ?></p>
293
- <p class="success message" style="display: none;"><?php _e('Your theme should work fine with NextCellent Gallery', 'nggallery'); ?></p>
294
- <p class="failed message" style="display: none;"><?php _e('wp_head()/wp_footer() is missing, contact the theme author', 'nggallery'); ?></p>
295
- </li>
296
- </ul>
297
- <p class="textright">
298
- <input type="button" name="update" value="<?php _e('Check plugin', 'nggallery'); ?>" onclick="nggPluginCheck.run(1);" class="button-secondary" />
299
- </p>
300
- </div>
301
- </div>
302
- </div>
303
- <?php
304
- }
305
-
306
- /**
307
- * Show the server settings in a dashboard widget
308
- *
309
- * @return void
310
- */
311
- function ngg_overview_server() {
312
- ?>
313
- <div id="dashboard_server_settings" class="dashboard-widget-holder wp_dashboard_empty">
314
- <div class="ngg-dashboard-widget">
315
- <div class="dashboard-widget-content">
316
- <ul class="settings">
317
- <?php ngg_get_serverinfo(); ?>
318
- </ul>
319
- <p><strong><?php _e('Graphic Library', 'nggallery'); ?></strong></p>
320
- <ul class="settings">
321
- <?php ngg_gd_info(); ?>
322
- </ul>
323
- </div>
324
- </div>
325
- </div>
326
- <?php
327
- }
328
-
329
- /**
330
- * Show the most recent donators
331
- *
332
- * @return void
333
- */
334
- function ngg_widget_overview_donators() {
335
- echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
336
- }
337
-
338
- function ngg_overview_donators() {
339
- global $ngg;
340
-
341
- $i = 0;
342
- $list = '';
343
-
344
- $supporter = nggAdminPanel::get_remote_array($ngg->donators);
345
-
346
- // Ensure that this is a array
347
- if ( !is_array($supporter) )
348
- return _e('Thanks to all donators...', 'nggallery');
349
-
350
- $supporter = array_reverse($supporter);
351
-
352
- foreach ($supporter as $name => $url) {
353
- $i++;
354
- if ($url)
355
- $list .= "<li><a href=\"$url\">$name</a></li>\n";
356
- else
357
- $list .= "<li>$name</li>";
358
- if ($i > 4)
359
- break;
360
- }
361
-
362
- ?>
363
- <div id="dashboard_server_settings" class="dashboard-widget-holder">
364
- <div class="ngg-dashboard-widget">
365
- <div class="dashboard-widget-content">
366
- <ul class="settings">
367
- <?php echo $list; ?>
368
- </ul>
369
- <p class="textright">
370
- <a class="button" href="admin.php?page=nggallery-about#donators"><?php _e('View all', 'nggallery'); ?></a>
371
- </p>
372
- </div>
373
- </div>
374
- </div>
375
- <?php
376
- }
377
-
378
- /**
379
- * Show the latest NextGEN Gallery news
380
- *
381
- * @return void
382
- */
383
- function ngg_widget_overview_news() {
384
- echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
385
- }
386
- function ngg_overview_news(){
387
-
388
- ?>
389
- <div class="rss-widget">
390
- <?php
391
- $rss = @fetch_feed( 'http://wpgetready.com/feed/' );
392
-
393
- if ( is_object($rss) ) {
394
-
395
- if ( is_wp_error($rss) ) {
396
- echo '<p>' . sprintf(__('Newsfeed could not be loaded. Check the <a href="%s">front page</a> to check for updates.', 'nggallery'), 'http://www.nextgen-gallery.com/') . '</p>';
397
- return;
398
- }
399
-
400
- echo '<ul>';
401
- foreach ( $rss->get_items(0, 3) as $item ) {
402
- $link = $item->get_link();
403
- while ( stristr($link, 'http') != $link )
404
- $link = substr($link, 1);
405
- $link = esc_url(strip_tags($link));
406
- $title = esc_attr(strip_tags($item->get_title()));
407
- if ( empty($title) )
408
- $title = __('Untitled');
409
-
410
- $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) );
411
- $desc = wp_html_excerpt( $desc, 360 );
412
-
413
- // Append ellipsis. Change existing [...] to [&hellip;].
414
- if ( '[...]' == substr( $desc, -5 ) )
415
- $desc = substr( $desc, 0, -5 ) . '[&hellip;]';
416
- elseif ( '[&hellip;]' != substr( $desc, -10 ) )
417
- $desc .= ' [&hellip;]';
418
-
419
- $desc = esc_html( $desc );
420
-
421
- $date = $item->get_date();
422
- $diff = '';
423
-
424
- if ( $date ) {
425
-
426
- $diff = human_time_diff( strtotime($date, time()) );
427
-
428
- if ( $date_stamp = strtotime( $date ) )
429
- $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
430
- else
431
- $date = '';
432
- }
433
- ?>
434
- <li><a class="rsswidget" title="" target="_blank" href='<?php echo $link; ?>'><?php echo $title; ?></a>
435
- <span class="rss-date"><?php echo $date; ?></span>
436
- <div class="rssSummary"><strong><?php echo $diff; ?></strong> - <?php echo $desc; ?></div></li>
437
- <?php
438
- }
439
- echo '</ul>';
440
- }
441
- ?>
442
- </div>
443
- <?php
444
- }
445
-
446
- /**
447
- * Show a summary of the used images
448
- *
449
- * @return void
450
- */
451
- function ngg_overview_right_now() {
452
- global $wpdb;
453
- $images = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
454
- $galleries = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
455
- $albums = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
456
- ?>
457
- <div class="table table_content">
458
- <p class="sub"><?php _e('At a Glance', 'nggallery'); ?></p>
459
- <table>
460
- <tbody>
461
- <tr class="first">
462
- <td class="first b"><a href="admin.php?page=nggallery-add-gallery"><?php echo $images; ?></a></td>
463
- <td class="t"><a href="admin.php?page=nggallery-add-gallery"><?php echo _n( 'Image', 'Images', $images, 'nggallery' ); ?></a></td>
464
- <td class="b"></td>
465
- <td class="last"></td>
466
- </tr>
467
- <tr>
468
- <td class="first b"><a href="admin.php?page=nggallery-manage-gallery"><?php echo $galleries; ?></a></td>
469
- <td class="t"><a href="admin.php?page=nggallery-manage-gallery"><?php echo _n( 'Gallery', 'Galleries', $galleries, 'nggallery' ); ?></a></td>
470
- <td class="b"></td>
471
- <td class="last"></td>
472
- </tr>
473
- <tr>
474
- <td class="first b"><a href="admin.php?page=nggallery-manage-album"><?php echo $albums; ?></a></td>
475
- <td class="t"><a href="admin.php?page=nggallery-manage-album"><?php echo _n( 'Album', 'Albums', $albums, 'nggallery' ); ?></a></td>
476
- <td class="b"></td>
477
- <td class="last"></td>
478
- </tr>
479
- </tbody>
480
- </table>
481
- </div>
482
- <div class="versions" style="padding-top:14px">
483
- <p>
484
- <?php if(current_user_can('NextGEN Upload images')): ?><a class="button rbutton" href="admin.php?page=nggallery-add-gallery"><?php _e('Upload pictures', 'nggallery') ?></a><?php endif; ?>
485
- <?php _e('Here you can control your images, galleries and albums.', 'nggallery') ?>
486
- </p>
487
- <br class="clear" />
488
- </div>
489
- <?php
490
- if ( is_multisite() )
491
- ngg_dashboard_quota();
492
- }
493
-
494
- // Display File upload quota on dashboard
495
- function ngg_dashboard_quota() {
496
-
497
- if ( get_site_option( 'upload_space_check_disabled' ) )
498
- return;
499
-
500
- if ( !wpmu_enable_function('wpmuQuotaCheck') )
501
- return;
502
-
503
- $quota = get_space_allowed();
504
- $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
505
-
506
- if ( $used > $quota )
507
- $percentused = '100';
508
- else
509
- $percentused = ( $used / $quota ) * 100;
510
- $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
511
- $used = round( $used, 2 );
512
- $percentused = number_format( $percentused );
513
-
514
- ?>
515
- <p class="sub musub" style="position:static" ><?php _e( 'Storage Space' ); ?></p>
516
- <div class="table table_content musubtable">
517
- <table>
518
- <tr class="first">
519
- <td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'admin.php?page=nggallery-manage-gallery' ) ), $quota ); ?></td>
520
- <td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
521
- </tr>
522
- </table>
523
- </div>
524
- <div class="table table_discussion musubtable">
525
- <table>
526
- <tr class="first">
527
- <td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'admin.php?page=nggallery-manage-gallery' ) ), $used, $percentused ); ?></td>
528
- <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
529
- </tr>
530
- </table>
531
- </div>
532
- <br class="clear" />
533
- <?php
534
- }
535
-
536
- /**
537
- * Looks up for translation file
538
- *
539
- * @return void
540
- */
541
- function ngg_widget_locale() {
542
-
543
- require_once(NGGALLERY_ABSPATH . '/lib/locale.php');
544
-
545
- $locale = new ngg_locale();
546
-
547
- $overview_url = admin_url() . 'admin.php?page=' . NGGFOLDER;
548
-
549
- // Check if someone would like to update the translation file
550
- if ( isset($_GET['locale']) && $_GET['locale'] == 'update' ) {
551
- check_admin_referer('ngg_update_locale');
552
-
553
- $result = $locale->download_locale();
554
-
555
- if ($result == true) {
556
- ?>
557
- <p class="hint"><?php _e('Translation file successful updated. Please reload page.', 'nggallery'); ?></p>
558
- <p class="textright">
559
- <a class="button" href="<?php echo esc_url(strip_tags($overview_url)); ?>"><?php _e('Reload page', 'nggallery'); ?></a>
560
- </p>
561
- <?php
562
- } else {
563
- ?>
564
- <p class="hint"><?php _e('Translation file couldn\'t be updated', 'nggallery'); ?></p>
565
- <?php
566
- }
567
-
568
- return;
569
- }
570
-
571
- echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
572
- }
573
-
574
- function ngg_locale() {
575
- global $ngg;
576
-
577
- require_once(NGGALLERY_ABSPATH . '/lib/locale.php');
578
-
579
- $locale = new ngg_locale();
580
- $overview_url = admin_url() . 'admin.php?page=' . NGGFOLDER;
581
- $result = $locale->check();
582
- $update_url = wp_nonce_url ( $overview_url . '&amp;locale=update', 'ngg_update_locale');
583
-
584
- //Translators can change this text via gettext
585
- if ($result == 'installed') {
586
- echo $ngg->translator;
587
- if ( !is_wp_error($locale->response) && $locale->response['response']['code'] == '200') {
588
- ?>
589
- <p class="textright">
590
- <a class="button" href="<?php echo esc_url( strip_tags($update_url) ); ?>"><?php _e('Update', 'nggallery'); ?></a>
591
- </p>
592
- <?php
593
- }
594
- }
595
-
596
- //Translators can change this text via gettext
597
- if ($result == 'available') {
598
- ?>
599
- <p><strong>Download now your language file !</strong></p>
600
- <p class="textright">
601
- <a class="button" href="<?php echo esc_url( strip_tags($update_url) ); ?>"><?php _e('Download', 'nggallery'); ?></a>
602
- </p>
603
- <?php
604
- }
605
-
606
-
607
- if ($result == 'not_exist')
608
- echo '<p class="hint">'. sprintf( '<strong>Would you like to help translating this plugin?</strong> <a target="_blank" href="%s">Download</a> the current pot file and read <a href="http://www.nextgen-gallery.com/translating-nextgen-gallery/">here</a> how you can translate the plugin.', NGGALLERY_URLPATH . 'lang/nggallery.pot').'</p>';
609
-
610
- }
611
-
612
- /**
613
- * Show GD Library version information
614
- *
615
- * @return void
616
- */
617
- function ngg_gd_info() {
618
-
619
- if(function_exists("gd_info")){
620
- $info = gd_info();
621
- $keys = array_keys($info);
622
- for($i=0; $i<count($keys); $i++) {
623
- if(is_bool($info[$keys[$i]]))
624
- echo "<li> " . $keys[$i] ." : <span>" . ngg_gd_yesNo($info[$keys[$i]]) . "</span></li>\n";
625
- else
626
- echo "<li> " . $keys[$i] ." : <span>" . $info[$keys[$i]] . "</span></li>\n";
627
- }
628
- }
629
- else {
630
- echo '<h4>'.__('No GD support', 'nggallery').'!</h4>';
631
- }
632
- }
633
-
634
- /**
635
- * Return localized Yes or no
636
- *
637
- * @param bool $bool
638
- * @return return 'Yes' | 'No'
639
- */
640
- function ngg_gd_yesNo( $bool ){
641
- if($bool)
642
- return __('Yes', 'nggallery');
643
- else
644
- return __('No', 'nggallery');
645
- }
646
-
647
-
648
- /**
649
- * Show up some server infor's
650
- * @author GamerZ (http://www.lesterchan.net)
651
- *
652
- * @return void
653
- */
654
- function ngg_get_serverinfo() {
655
-
656
- global $wpdb, $ngg;
657
- // Get MYSQL Version
658
- $sqlversion = $wpdb->get_var("SELECT VERSION() AS version");
659
- // GET SQL Mode
660
- $mysqlinfo = $wpdb->get_results("SHOW VARIABLES LIKE 'sql_mode'");
661
- if (is_array($mysqlinfo)) $sql_mode = $mysqlinfo[0]->Value;
662
- if (empty($sql_mode)) $sql_mode = __('Not set', 'nggallery');
663
- // Get PHP Safe Mode
664
- if(ini_get('safe_mode')) $safe_mode = __('On', 'nggallery');
665
- else $safe_mode = __('Off', 'nggallery');
666
- // Get PHP allow_url_fopen
667
- if(ini_get('allow_url_fopen')) $allow_url_fopen = __('On', 'nggallery');
668
- else $allow_url_fopen = __('Off', 'nggallery');
669
- // Get PHP Max Upload Size
670
- if(ini_get('upload_max_filesize')) $upload_max = ini_get('upload_max_filesize');
671
- else $upload_max = __('N/A', 'nggallery');
672
- // Get PHP Output buffer Size
673
- if(ini_get('pcre.backtrack_limit')) $backtrack_limit = ini_get('pcre.backtrack_limit');
674
- else $backtrack_limit = __('N/A', 'nggallery');
675
- // Get PHP Max Post Size
676
- if(ini_get('post_max_size')) $post_max = ini_get('post_max_size');
677
- else $post_max = __('N/A', 'nggallery');
678
- // Get PHP Max execution time
679
- if(ini_get('max_execution_time')) $max_execute = ini_get('max_execution_time');
680
- else $max_execute = __('N/A', 'nggallery');
681
- // Get PHP Memory Limit
682
- if(ini_get('memory_limit')) $memory_limit = $ngg->memory_limit;
683
- else $memory_limit = __('N/A', 'nggallery');
684
- // Get actual memory_get_usage
685
- if (function_exists('memory_get_usage')) $memory_usage = round(memory_get_usage() / 1024 / 1024, 2) . __(' MByte', 'nggallery');
686
- else $memory_usage = __('N/A', 'nggallery');
687
- // required for EXIF read
688
- if (is_callable('exif_read_data')) $exif = __('Yes', 'nggallery'). " ( V" . substr(phpversion('exif'),0,4) . ")" ;
689
- else $exif = __('No', 'nggallery');
690
- // required for meta data
691
- if (is_callable('iptcparse')) $iptc = __('Yes', 'nggallery');
692
- else $iptc = __('No', 'nggallery');
693
- // required for meta data
694
- if (is_callable('xml_parser_create')) $xml = __('Yes', 'nggallery');
695
- else $xml = __('No', 'nggallery');
696
-
697
- ?>
698
- <li><?php _e('Operating System', 'nggallery'); ?> : <span><?php echo PHP_OS; ?>&nbsp;(<?php echo (PHP_INT_SIZE * 8) ?>&nbsp;Bit)</span></li>
699
- <li><?php _e('Server', 'nggallery'); ?> : <span><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></span></li>
700
- <li><?php _e('Memory usage', 'nggallery'); ?> : <span><?php echo $memory_usage; ?></span></li>
701
- <li><?php _e('MYSQL Version', 'nggallery'); ?> : <span><?php echo $sqlversion; ?></span></li>
702
- <li><?php _e('SQL Mode', 'nggallery'); ?> : <span><?php echo $sql_mode; ?></span></li>
703
- <li><?php _e('PHP Version', 'nggallery'); ?> : <span><?php echo PHP_VERSION; ?></span></li>
704
- <li><?php _e('PHP Safe Mode', 'nggallery'); ?> : <span><?php echo $safe_mode; ?></span></li>
705
- <li><?php _e('PHP Allow URL fopen', 'nggallery'); ?> : <span><?php echo $allow_url_fopen; ?></span></li>
706
- <li><?php _e('PHP Memory Limit', 'nggallery'); ?> : <span><?php echo $memory_limit; ?></span></li>
707
- <li><?php _e('PHP Max Upload Size', 'nggallery'); ?> : <span><?php echo $upload_max; ?></span></li>
708
- <li><?php _e('PHP Max Post Size', 'nggallery'); ?> : <span><?php echo $post_max; ?></span></li>
709
- <li><?php _e('PCRE Backtracking Limit', 'nggallery'); ?> : <span><?php echo $backtrack_limit; ?></span></li>
710
- <li><?php _e('PHP Max Script Execute Time', 'nggallery'); ?> : <span><?php echo $max_execute; ?>s</span></li>
711
- <li><?php _e('PHP Exif support', 'nggallery'); ?> : <span><?php echo $exif; ?></span></li>
712
- <li><?php _e('PHP IPTC support', 'nggallery'); ?> : <span><?php echo $iptc; ?></span></li>
713
- <li><?php _e('PHP XML support', 'nggallery'); ?> : <span><?php echo $xml; ?></span></li>
714
- <?php
715
- }
716
-
717
- /**
718
- * Inform about the end of PHP4
719
- *
720
- * @return void
721
- */
722
- function ngg_check_for_PHP5() {
723
- ?>
724
- <div class="updated">
725
- <p><?php _e('NextCellent Gallery contains some functions which are only available under PHP 5.2. You are using the old PHP 4 version, upgrade now! It\'s no longer supported by the PHP group. Many shared hosting providers offer both PHP 4 and PHP 5, running simultaneously. Ask your provider if they can do this.', 'nggallery'); ?></p>
726
- </div>
727
- <?php
728
- }
729
-
730
- /**
731
- * ngg_get_phpinfo() - Extract all of the data from phpinfo into a nested array
732
- *
733
- * @author jon@sitewizard.ca
734
- * @return array
735
- */
736
- function ngg_get_phpinfo() {
737
-
738
- ob_start();
739
- phpinfo();
740
- $phpinfo = array('phpinfo' => array());
741
-
742
- if ( preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER) )
743
- foreach($matches as $match) {
744
- if(strlen($match[1]))
745
- $phpinfo[$match[1]] = array();
746
- elseif(isset($match[3]))
747
- $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
748
- else
749
- $phpinfo[end(array_keys($phpinfo))][] = $match[2];
750
- }
751
-
752
- return $phpinfo;
753
- }
754
-
755
- /**
756
- * Show NextGEN Gallery related plugins. Fetch plugins from wp.org which have added 'nextgen-gallery' as tag in readme.txt
757
- *
758
- * @return postbox output
759
- */
760
- function ngg_widget_related_plugins() {
761
- echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
762
- }
763
-
764
- /**
765
- * Backward compatibility, scheduled to delete on future iteration.
766
- */
767
- function ngg_related_plugins() {
768
- nextcellent_overview::related_plugins() ;
769
- }
770
-
771
- /**
772
- * Provide utilities functions for creating metaboxes on overview
773
- * Class nextcellent_overview
774
- */
775
- class nextcellent_overview {
776
- const URL_WPGETREADY = 'http://www.wpgetready.com';
777
-
778
- /**
779
- * Display a list of related plugins, gathered from Wordpress Repository
780
- * Optional parameter to display more or less plugins.
781
- * To improve: filter obsolete plugins (last_updated less than two years from now)
782
- */
783
- static function related_plugins($how_many=4) {
784
- include(ABSPATH . 'wp-admin/includes/plugin-install.php');
785
- //If transient vaporized, refresh it
786
- if ( false === ( $api = get_transient( 'ngg_related_plugins' ) ) ) {
787
- // Adittional info http://dd32.id.au/projects/wordpressorg-plugin-information-api-docs/
788
- $api = plugins_api('query_plugins', array('search' => 'nextgen') );
789
- if ( is_wp_error($api) ) return;
790
- set_transient( 'ngg_related_plugins', $api, 60*60*24 ); //enable to check within a day.
791
- }
792
-
793
- echo '<div style="margin-bottom:10px;padding:8px;font-size:110%;background:#eebbaa;"><b>Note</b>: third parties plugins compatible with NGG. Be aware that NextCellent cannot provide 100% compatibility with it</div>';
794
- //List of suppressed plugin on the list.
795
- $blacklist = array('nextgen-gallery','nextcellent-gallery-nextgen-legacy');
796
-
797
- $i = 0;
798
- while ( $i < $how_many ) {
799
-
800
- // pick them randomly
801
- if ( 0 == count($api->plugins) ) return;
802
-
803
- $key = array_rand($api->plugins);
804
- $plugin = $api->plugins[$key];
805
-
806
- // don't forget to remove them
807
- unset($api->plugins[$key]);
808
-
809
- if ( !isset($plugin->name) ) continue;
810
-
811
- if ( in_array($plugin->slug , $blacklist ) ) continue;
812
-
813
- $link = esc_url( $plugin->homepage );
814
- $title = esc_html( $plugin->name );
815
-
816
- $description = esc_html( strip_tags(@html_entity_decode($plugin->short_description, ENT_QUOTES, get_option('blog_charset'))) );
817
-
818
- $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin->slug, 'install-plugin_' . $plugin->slug) .
819
- '&amp;TB_iframe=true&amp;width=600&amp;height=800';
820
-
821
- echo "<h5><a href='{$link}' target='_blank'>{$title}</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
822
- echo "<p>$description<strong> " . __( 'Author' ) . " : </strong>$plugin->author</p>\n";
823
-
824
- $i++;
825
- }
826
-
827
- }
828
-
829
-
830
- /**
831
- * Like Metabox over right
832
- */
833
- static function likeThisMetaBox() {
834
-
835
- echo '<p>';
836
- echo sprintf(__('This plugin is a branch from NGG stable version 1.9.13.<br> Developed & maintained by <a href="%s" target="_blank">WPGetReady.com</a>', 'nggallery'), self::URL_WPGETREADY);
837
-
838
- echo '</p><ul>';
839
-
840
- $url = 'wordpress.org/plugins/nextcellent-gallery-nextgen-legacy/' ;
841
- echo "<li style='padding-left: 38px; background:transparent url(" . NGGALLERY_URLPATH . "admin/images/icon-rating.png ) no-repeat scroll center left; background-position: 16px 50%; text-decoration: none;'><a href='{$url}' target='_blank'>";
842
- _e('Please contribute it giving this plugin a good rate! Thank you!!!', 'nggallery');
843
- echo "</a></li>";
844
-
845
- $url = self::URL_WPGETREADY;
846
- echo "<li style='padding-left: 38px; background:transparent url(" . NGGALLERY_URLPATH . "admin/images/nextgen.png ) no-repeat scroll center left; background-position: 16px 50%; text-decoration: none;'><a href='{$url}' target='_blank'>";
847
- _e("Visit the plugin homepage", 'nggallery');
848
- echo "</a></li>";
849
- /*
850
- $url = 'http://www.nextgen-gallery.com/languages/';
851
- echo "<li style='padding-left: 38px; background:transparent url(" . NGGALLERY_URLPATH . "admin/images/icon-translate.png ) no-repeat scroll center left; background-position: 16px 50%; text-decoration: none;'><a href='{$url}' target='_blank'>";
852
- _e("Help translating it", 'nggallery');
853
- echo "</a></li>";
854
- */
855
-
856
- echo '</ul>';
857
-
858
- /*
859
- echo '
860
- <div class="social" style="text-align:center;margin:15px 0 10px 0;"><span class="social" style="margin-right:5px;"><a target="_blank" href="http://twitter.com/NextGENGallery"><img title="Follow NextGEN on Twitter" alt="Twitter" src="' . NGGALLERY_URLPATH . 'admin/images/twitter.png"></a></span><span class="social" style="margin-right:5px;"><a target="_blank" href="http://www.facebook.com/NextGENGallery"><img title="Like NextGEN on Facebook" alt="Facebook" src="' . NGGALLERY_URLPATH . 'admin/images/facebook.png"></a></span><span class="social"><a target="_blank" href="http://plus.google.com/101643895780935290171"><img title="Add NextGEN to your circles" alt="GooglePlus" src="' . NGGALLERY_URLPATH . 'admin/images/googleplus.png"></a></span></div>';
861
- */
862
- }
863
- }
864
-
865
-
866
- ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ /**
5
+ * nggallery_admin_overview()
6
+ * 20130410: FZSM: as part of initiative, avoid implementing spaghuetti code.
7
+ * Introducing class to deal with code and functions to provide backward compatibility 100%
8
+ * Add the admin overview the dashboard style
9
+ * @return mixed content
10
+ */
11
+ function nggallery_admin_overview() {
12
+ ?>
13
+ <div class="wrap ngg-wrap">
14
+ <?php screen_icon( 'nextgen-gallery' ); ?>
15
+ <h2><?php _e('NextCellent Gallery Overview', 'nggallery') ?></h2>
16
+ <?php if (version_compare(PHP_VERSION, '5.0.0', '<')) ngg_check_for_PHP5(); ?>
17
+ <div id="dashboard-widgets-container" class="ngg-overview">
18
+ <div id="dashboard-widgets" class="metabox-holder">
19
+ <div id="post-body">
20
+ <div id="dashboard-widgets-main-content">
21
+ <div class="postbox-container" id="main-container" style="width:75%;">
22
+ <?php do_meta_boxes('ngg_overview', 'left', ''); ?>
23
+ </div>
24
+ <div class="postbox-container" id="side-container" style="width:24%;">
25
+ <?php do_meta_boxes('ngg_overview', 'right', ''); ?>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ <script type="text/javascript">
33
+ //<![CDATA[
34
+ var ajaxWidgets, ajaxPopulateWidgets;
35
+
36
+ jQuery(document).ready( function($) {
37
+ // These widgets are sometimes populated via ajax
38
+ ajaxWidgets = [
39
+ 'ngg_lastdonators',
40
+ 'dashboard_primary',
41
+ 'ngg_locale',
42
+ 'dashboard_plugins'
43
+ ];
44
+
45
+ ajaxPopulateWidgets = function(el) {
46
+ show = function(id, i) {
47
+ var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading');
48
+ if ( e.length ) {
49
+ p = e.parent();
50
+ setTimeout( function(){
51
+ p.load('admin-ajax.php?action=ngg_dashboard&jax=' + id, '', function() {
52
+ p.hide().slideDown('normal', function(){
53
+ $(this).css('display', '');
54
+ if ( 'dashboard_plugins' == id && $.isFunction(tb_init) )
55
+ tb_init('#dashboard_plugins a.thickbox');
56
+ });
57
+ });
58
+ }, i * 500 );
59
+ }
60
+ }
61
+ if ( el ) {
62
+ el = el.toString();
63
+ if ( $.inArray(el, ajaxWidgets) != -1 )
64
+ show(el, 0);
65
+ } else {
66
+ $.each( ajaxWidgets, function(i) {
67
+ show(this, i);
68
+ });
69
+ }
70
+ };
71
+ ajaxPopulateWidgets();
72
+ } );
73
+
74
+ jQuery(document).ready( function($) {
75
+ // postboxes setup
76
+ postboxes.add_postbox_toggles('ngg-overview');
77
+ });
78
+ //]]>
79
+ </script>
80
+ <?php
81
+ }
82
+
83
+ /**
84
+ * Load the meta boxes
85
+ *
86
+ */
87
+ add_meta_box('dashboard_overview', __('Welcome to NextCellent Gallery !', 'nggallery'), 'ngg_overview_right_now', 'ngg_overview', 'left', 'core');
88
+ add_meta_box('ngg_meta_box', __('Help me help YOU!', 'nggallery'), 'nextcellent_overview::likeThisMetaBox', 'ngg_overview', 'right', 'core');
89
+ if ( !(get_locale() == 'en_US') )
90
+ add_meta_box('ngg_locale', __('Translation', 'nggallery'), 'ngg_widget_locale', 'ngg_overview', 'right', 'core');
91
+ add_meta_box('dashboard_primary', __('Latest News', 'nggallery'), 'ngg_widget_overview_news', 'ngg_overview', 'left', 'core');
92
+ //add_meta_box('ngg_lastdonators', __('Recent donators', 'nggallery'), 'ngg_widget_overview_donators', 'ngg_overview', 'right', 'core');
93
+ if ( !is_multisite() || is_super_admin() ) {
94
+ add_meta_box('ngg_plugin_check', __('Plugin Check', 'nggallery'), 'ngg_plugin_check', 'ngg_overview', 'right', 'core');
95
+ add_meta_box('ngg_server', __('Server Settings', 'nggallery'), 'ngg_overview_server', 'ngg_overview', 'right', 'core');
96
+ add_meta_box('dashboard_plugins', __('Related plugins', 'nggallery'), 'ngg_widget_related_plugins', 'ngg_overview', 'left', 'core');
97
+ }
98
+
99
+
100
+
101
+ /**
102
+ * Ajax Check for conflict with other plugins/themes
103
+ *
104
+ * @return void
105
+ */
106
+ function ngg_plugin_check() {
107
+
108
+ global $ngg;
109
+ ?>
110
+ <script type="text/javascript">
111
+ (function($) {
112
+ nggPluginCheck = {
113
+
114
+ settings: {
115
+ img_run: '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="icon" alt="started"/>',
116
+ img_ok: '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" class="icon" alt="ok"/>',
117
+ img_fail: '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" class="icon" alt="failed" />',
118
+ domain: '<?php echo esc_url( home_url('index.php', is_ssl() ? 'https' : 'http') ); ?>'
119
+ },
120
+
121
+ run: function( index, state ) {
122
+ ul = $('#plugin_check');
123
+ s = this.settings;
124
+ var step = 1;
125
+ switch ( index ) {
126
+ case 1:
127
+ this.check1();
128
+ break;
129
+ case 2:
130
+ this.check2( step );
131
+ break;
132
+ case 3:
133
+ this.check3();
134
+ break;
135
+ }
136
+ },
137
+
138
+ // this function check if the json API will work with your theme & plugins
139
+ check1 : function() {
140
+ this.start(1);
141
+ var req = $.ajax({
142
+ dataType: 'json',
143
+ url: s.domain,
144
+ data:'callback=json&format=json&method=version',
145
+ cache: false,
146
+ timeout: 10000,
147
+ success: function(msg){
148
+ if (msg.version == '<?php echo $ngg->version; ?>')
149
+ nggPluginCheck.success(1);
150
+ else
151
+ nggPluginCheck.failed(1);
152
+ },
153
+ error: function (msg) {
154
+ nggPluginCheck.failed(1);
155
+ },
156
+ complete: function () {
157
+ nggPluginCheck.run(2);
158
+ }
159
+ });
160
+
161
+ },
162
+
163
+ // this function check if GD lib can create images & thumbnails
164
+ check2 : function( step ) {
165
+ if (step == 1) this.start(2);
166
+ var stop = false;
167
+ var req = $.ajax({
168
+ type: "POST",
169
+ url: ajaxurl,
170
+ data:"action=ngg_image_check&step=" + step,
171
+ cache: false,
172
+ timeout: 10000,
173
+ success: function(msg){
174
+ if (msg.stat == 'ok') {
175
+ nggPluginCheck.success(2, msg.message);
176
+ } else {
177
+ if (step == 1)
178
+ nggPluginCheck.failed(2);
179
+ stop = true;
180
+ }
181
+
182
+ },
183
+ error: function (msg) {
184
+ if (step == 1)
185
+ nggPluginCheck.failed(2);
186
+ stop = true;
187
+ },
188
+ complete: function () {
189
+ step++;
190
+ if (step <= 11 && stop == false)
191
+ nggPluginCheck.check2(step);
192
+ else
193
+ nggPluginCheck.run(3);
194
+ }
195
+ });
196
+ },
197
+
198
+ // this function check if wp_head / wp_footer is avaiable
199
+ check3 : function() {
200
+ this.start(3);
201
+ var req = $.ajax({
202
+ type: "POST",
203
+ url: ajaxurl,
204
+ data:"action=ngg_test_head_footer",
205
+ cache: false,
206
+ timeout: 10000,
207
+ success: function(msg){
208
+ if (msg == 'success')
209
+ nggPluginCheck.success(3);
210
+ else
211
+ nggPluginCheck.failed(3, msg);
212
+ },
213
+ error: function (msg) {
214
+ nggPluginCheck.failed(3);
215
+ }
216
+ });
217
+ },
218
+
219
+ start: function( id ) {
220
+
221
+ s = this.settings;
222
+ var field = "#check" + id;
223
+
224
+ if ( ul.find(field + " img").length == 0)
225
+ $(field).prepend( s.img_run );
226
+ else
227
+ $(field + " img").replaceWith( s.img_run );
228
+
229
+ $(field + " .success").hide();
230
+ $(field + " .failed").hide();
231
+ $(field + " .default").replaceWith('<p class="default message"><?php echo esc_js( __('Running...', 'nggallery') ); ?></p> ');
232
+ },
233
+
234
+ success: function( id, msg ) {
235
+
236
+ s = this.settings;
237
+ var field = "#check" + id;
238
+
239
+ if ( ul.find(field + " img").length == 0)
240
+ $(field).prepend( s.img_ok );
241
+ else
242
+ $(field + " img").replaceWith( s.img_ok );
243
+
244
+ $(field + " .default").hide();
245
+ if (msg)
246
+ $(field + " .success").replaceWith('<p class="success message">' + msg +' </p> ');
247
+ else
248
+ $(field + " .success").show();
249
+
250
+ },
251
+
252
+ failed: function( id, msg ) {
253
+
254
+ s = this.settings;
255
+ var field = "#check" + id;
256
+
257
+ if ( ul.find(field + " img").length == 0)
258
+ $(field).prepend( s.img_fail );
259
+ else
260
+ $(field + " img").replaceWith( s.img_fail );
261
+
262
+ $(field + " .default").hide();
263
+ if (msg)
264
+ $(field + " .failed").replaceWith('<p class="failed message">' + msg +' </p> ');
265
+ else
266
+ $(field + " .failed").show();
267
+
268
+ }
269
+
270
+ };
271
+ })(jQuery);
272
+ </script>
273
+ <div class="dashboard-widget-holder wp_dashboard_empty">
274
+ <div class="ngg-dashboard-widget">
275
+ <div class="dashboard-widget-content">
276
+ <ul id="plugin_check" class="settings">
277
+ <li id="check1">
278
+ <strong><?php _e('Check plugin/theme conflict', 'nggallery'); ?></strong>
279
+ <p class="default message"><?php _e('Not tested', 'nggallery'); ?></p>
280
+ <p class="success message" style="display: none;"><?php _e('No conflict could be detected', 'nggallery'); ?></p>
281
+ <p class="failed message" style="display: none;"><?php _e('Test failed, disable other plugins & switch to default theme', 'nggallery'); ?></p>
282
+ </li>
283
+ <li id="check2">
284
+ <strong><?php _e('Test image function', 'nggallery'); ?></strong>
285
+ <p class="default message"><?php _e('Not tested', 'nggallery'); ?></p>
286
+ <p class="success message" style="display: none;"><?php _e('The plugin could create images', 'nggallery'); ?></p>
287
+ <p class="failed message" style="display: none;"><?php _e('Couldn\'t create image, check your memory limit', 'nggallery'); ?></p>
288
+ </li>
289
+ <li id="check3">
290
+ <strong><?php _e('Check theme compatibility', 'nggallery'); ?></strong>
291
+ <p class="default message"><?php _e('Not tested', 'nggallery'); ?></p>
292
+ <p class="success message" style="display: none;"><?php _e('Your theme should work fine with NextCellent Gallery', 'nggallery'); ?></p>
293
+ <p class="failed message" style="display: none;"><?php _e('wp_head()/wp_footer() is missing, contact the theme author', 'nggallery'); ?></p>
294
+ </li>
295
+ </ul>
296
+ <p class="textright">
297
+ <input type="button" name="update" value="<?php _e('Check plugin', 'nggallery'); ?>" onclick="nggPluginCheck.run(1);" class="button-secondary" />
298
+ </p>
299
+ </div>
300
+ </div>
301
+ </div>
302
+ <?php
303
+ }
304
+
305
+ /**
306
+ * Show the server settings in a dashboard widget
307
+ *
308
+ * @return void
309
+ */
310
+ function ngg_overview_server() {
311
+ ?>
312
+ <div id="dashboard_server_settings" class="dashboard-widget-holder wp_dashboard_empty">
313
+ <div class="ngg-dashboard-widget">
314
+ <div class="dashboard-widget-content">
315
+ <ul class="settings">
316
+ <?php ngg_get_serverinfo(); ?>
317
+ </ul>
318
+ <p><strong><?php _e('Graphic Library', 'nggallery'); ?></strong></p>
319
+ <ul class="settings">
320
+ <?php ngg_gd_info(); ?>
321
+ </ul>
322
+ </div>
323
+ </div>
324
+ </div>
325
+ <?php
326
+ }
327
+
328
+ /**
329
+ * Show the most recent donators
330
+ *
331
+ * @return void
332
+ */
333
+ function ngg_widget_overview_donators() {
334
+ echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
335
+ }
336
+
337
+ function ngg_overview_donators() {
338
+ global $ngg;
339
+
340
+ $i = 0;
341
+ $list = '';
342
+
343
+ $supporter = nggAdminPanel::get_remote_array($ngg->donators);
344
+
345
+ // Ensure that this is a array
346
+ if ( !is_array($supporter) )
347
+ return _e('Thanks to all donators...', 'nggallery');
348
+
349
+ $supporter = array_reverse($supporter);
350
+
351
+ foreach ($supporter as $name => $url) {
352
+ $i++;
353
+ if ($url)
354
+ $list .= "<li><a href=\"$url\">$name</a></li>\n";
355
+ else
356
+ $list .= "<li>$name</li>";
357
+ if ($i > 4)
358
+ break;
359
+ }
360
+
361
+ ?>
362
+ <div id="dashboard_server_settings" class="dashboard-widget-holder">
363
+ <div class="ngg-dashboard-widget">
364
+ <div class="dashboard-widget-content">
365
+ <ul class="settings">
366
+ <?php echo $list; ?>
367
+ </ul>
368
+ <p class="textright">
369
+ <a class="button" href="admin.php?page=nggallery-about#donators"><?php _e('View all', 'nggallery'); ?></a>
370
+ </p>
371
+ </div>
372
+ </div>
373
+ </div>
374
+ <?php
375
+ }
376
+
377
+ /**
378
+ * Show the latest NextGEN Gallery news
379
+ *
380
+ * @return void
381
+ */
382
+ function ngg_widget_overview_news() {
383
+ echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
384
+ }
385
+ function ngg_overview_news(){
386
+
387
+ ?>
388
+ <div class="rss-widget">
389
+ <?php
390
+ $rss = @fetch_feed( 'http://wpgetready.com/feed/' );
391
+
392
+ if ( is_object($rss) ) {
393
+
394
+ if ( is_wp_error($rss) ) {
395
+ echo '<p>' . sprintf(__('Newsfeed could not be loaded. Check the <a href="%s">front page</a> to check for updates.', 'nggallery'), 'http://www.nextgen-gallery.com/') . '</p>';
396
+ return;
397
+ }
398
+
399
+ echo '<ul>';
400
+ foreach ( $rss->get_items(0, 3) as $item ) {
401
+ $link = $item->get_link();
402
+ while ( stristr($link, 'http') != $link )
403
+ $link = substr($link, 1);
404
+ $link = esc_url(strip_tags($link));
405
+ $title = esc_attr(strip_tags($item->get_title()));
406
+ if ( empty($title) )
407
+ $title = __('Untitled');
408
+
409
+ $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) );
410
+ $desc = wp_html_excerpt( $desc, 360 );
411
+
412
+ // Append ellipsis. Change existing [...] to [&hellip;].
413
+ if ( '[...]' == substr( $desc, -5 ) )
414
+ $desc = substr( $desc, 0, -5 ) . '[&hellip;]';
415
+ elseif ( '[&hellip;]' != substr( $desc, -10 ) )
416
+ $desc .= ' [&hellip;]';
417
+
418
+ $desc = esc_html( $desc );
419
+
420
+ $date = $item->get_date();
421
+ $diff = '';
422
+
423
+ if ( $date ) {
424
+
425
+ $diff = human_time_diff( strtotime($date, time()) );
426
+
427
+ if ( $date_stamp = strtotime( $date ) )
428
+ $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
429
+ else
430
+ $date = '';
431
+ }
432
+ ?>
433
+ <li><a class="rsswidget" title="" target="_blank" href='<?php echo $link; ?>'><?php echo $title; ?></a>
434
+ <span class="rss-date"><?php echo $date; ?></span>
435
+ <div class="rssSummary"><strong><?php echo $diff; ?></strong> - <?php echo $desc; ?></div></li>
436
+ <?php
437
+ }
438
+ echo '</ul>';
439
+ }
440
+ ?>
441
+ </div>
442
+ <?php
443
+ }
444
+
445
+ /**
446
+ * Show a summary of the used images
447
+ *
448
+ * @return void
449
+ */
450
+ function ngg_overview_right_now() {
451
+ global $wpdb;
452
+ $images = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
453
+ $galleries = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
454
+ $albums = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
455
+ ?>
456
+ <div class="table table_content">
457
+ <h4><?php _e('At a Glance', 'nggallery'); ?></h4>
458
+ <table>
459
+ <tbody>
460
+ <tr class="first">
461
+ <td class="first b"><a href="admin.php?page=nggallery-add-gallery"><?php echo $images; ?></a></td>
462
+ <td class="t"><a href="admin.php?page=nggallery-add-gallery"><?php echo _n( 'Image', 'Images', $images, 'nggallery' ); ?></a></td>
463
+ <td class="b"></td>
464
+ <td class="last"></td>
465
+ </tr>
466
+ <tr>
467
+ <td class="first b"><a href="admin.php?page=nggallery-manage-gallery"><?php echo $galleries; ?></a></td>
468
+ <td class="t"><a href="admin.php?page=nggallery-manage-gallery"><?php echo _n( 'Gallery', 'Galleries', $galleries, 'nggallery' ); ?></a></td>
469
+ <td class="b"></td>
470
+ <td class="last"></td>
471
+ </tr>
472
+ <tr>
473
+ <td class="first b"><a href="admin.php?page=nggallery-manage-album"><?php echo $albums; ?></a></td>
474
+ <td class="t"><a href="admin.php?page=nggallery-manage-album"><?php echo _n( 'Album', 'Albums', $albums, 'nggallery' ); ?></a></td>
475
+ <td class="b"></td>
476
+ <td class="last"></td>
477
+ </tr>
478
+ </tbody>
479
+ </table>
480
+ </div>
481
+ <div class="versions" style="padding-top:14px">
482
+ <p>
483
+ <?php if(current_user_can('NextGEN Upload images')): ?><a class="button rbutton" href="admin.php?page=nggallery-add-gallery"><?php _e('Upload pictures', 'nggallery') ?></a><?php endif; ?>
484
+ <?php _e('Here you can control your images, galleries and albums.', 'nggallery') ?>
485
+ </p>
486
+ <br class="clear" />
487
+ </div>
488
+ <?php
489
+ if ( is_multisite() )
490
+ ngg_dashboard_quota();
491
+ }
492
+
493
+ // Display File upload quota on dashboard
494
+ function ngg_dashboard_quota() {
495
+
496
+ if ( get_site_option( 'upload_space_check_disabled' ) )
497
+ return;
498
+
499
+ if ( !wpmu_enable_function('wpmuQuotaCheck') )
500
+ return;
501
+
502
+ $quota = get_space_allowed();
503
+ $used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
504
+
505
+ if ( $used > $quota )
506
+ $percentused = '100';
507
+ else
508
+ $percentused = ( $used / $quota ) * 100;
509
+ $used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
510
+ $used = round( $used, 2 );
511
+ $percentused = number_format( $percentused );
512
+
513
+ ?>
514
+ <p class="sub musub" style="position:static" ><?php _e( 'Storage Space' ); ?></p>
515
+ <div class="table table_content musubtable">
516
+ <table>
517
+ <tr class="first">
518
+ <td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'admin.php?page=nggallery-manage-gallery' ) ), $quota ); ?></td>
519
+ <td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
520
+ </tr>
521
+ </table>
522
+ </div>
523
+ <div class="table table_discussion musubtable">
524
+ <table>
525
+ <tr class="first">
526
+ <td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'admin.php?page=nggallery-manage-gallery' ) ), $used, $percentused ); ?></td>
527
+ <td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
528
+ </tr>
529
+ </table>
530
+ </div>
531
+ <br class="clear" />
532
+ <?php
533
+ }
534
+
535
+ /**
536
+ * Looks up for translation file
537
+ *
538
+ * @return void
539
+ */
540
+ function ngg_widget_locale() {
541
+
542
+ require_once(NGGALLERY_ABSPATH . '/lib/locale.php');
543
+
544
+ $locale = new ngg_locale();
545
+
546
+ $overview_url = admin_url() . 'admin.php?page=' . NGGFOLDER;
547
+
548
+ // Check if someone would like to update the translation file
549
+ if ( isset($_GET['locale']) && $_GET['locale'] == 'update' ) {
550
+ check_admin_referer('ngg_update_locale');
551
+
552
+ $result = $locale->download_locale();
553
+
554
+ if ($result == true) {
555
+ ?>
556
+ <p class="hint"><?php _e('Translation file successful updated. Please reload page.', 'nggallery'); ?></p>
557
+ <p class="textright">
558
+ <a class="button" href="<?php echo esc_url(strip_tags($overview_url)); ?>"><?php _e('Reload page', 'nggallery'); ?></a>
559
+ </p>
560
+ <?php
561
+ } else {
562
+ ?>
563
+ <p class="hint"><?php _e('Translation file couldn\'t be updated', 'nggallery'); ?></p>
564
+ <?php
565
+ }
566
+
567
+ return;
568
+ }
569
+
570
+ echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
571
+ }
572
+
573
+ function ngg_locale() {
574
+ global $ngg;
575
+
576
+ require_once(NGGALLERY_ABSPATH . '/lib/locale.php');
577
+
578
+ $locale = new ngg_locale();
579
+ $overview_url = admin_url() . 'admin.php?page=' . NGGFOLDER;
580
+ $result = $locale->check();
581
+ $update_url = wp_nonce_url ( $overview_url . '&amp;locale=update', 'ngg_update_locale');
582
+
583
+ //Translators can change this text via gettext
584
+ if ($result == 'installed') {
585
+ echo $ngg->translator;
586
+ if ( !is_wp_error($locale->response) && $locale->response['response']['code'] == '200') {
587
+ ?>
588
+ <p class="textright">
589
+ <a class="button" href="<?php echo esc_url( strip_tags($update_url) ); ?>"><?php _e('Update', 'nggallery'); ?></a>
590
+ </p>
591
+ <?php
592
+ }
593
+ }
594
+
595
+ //Translators can change this text via gettext
596
+ if ($result == 'available') {
597
+ ?>
598
+ <p><strong>Download now your language file !</strong></p>
599
+ <p class="textright">
600
+ <a class="button" href="<?php echo esc_url( strip_tags($update_url) ); ?>"><?php _e('Download', 'nggallery'); ?></a>
601
+ </p>
602
+ <?php
603
+ }
604
+
605
+
606
+ if ($result == 'not_exist')
607
+ echo '<p class="hint">'. sprintf( '<strong>Would you like to help translating this plugin?</strong> <a target="_blank" href="%s">Download</a> the current pot file and read <a href="http://www.nextgen-gallery.com/translating-nextgen-gallery/">here</a> how you can translate the plugin.', NGGALLERY_URLPATH . 'lang/nggallery.pot').'</p>';
608
+
609
+ }
610
+
611
+ /**
612
+ * Show GD Library version information
613
+ *
614
+ * @return void
615
+ */
616
+ function ngg_gd_info() {
617
+
618
+ if(function_exists("gd_info")){
619
+ $info = gd_info();
620
+ $keys = array_keys($info);
621
+ for($i=0; $i<count($keys); $i++) {
622
+ if(is_bool($info[$keys[$i]]))
623
+ echo "<li> " . $keys[$i] ." : <span>" . ngg_gd_yesNo($info[$keys[$i]]) . "</span></li>\n";
624
+ else
625
+ echo "<li> " . $keys[$i] ." : <span>" . $info[$keys[$i]] . "</span></li>\n";
626
+ }
627
+ }
628
+ else {
629
+ echo '<h4>'.__('No GD support', 'nggallery').'!</h4>';
630
+ }
631
+ }
632
+
633
+ /**
634
+ * Return localized Yes or no
635
+ *
636
+ * @param bool $bool
637
+ * @return return 'Yes' | 'No'
638
+ */
639
+ function ngg_gd_yesNo( $bool ){
640
+ if($bool)
641
+ return __('Yes', 'nggallery');
642
+ else
643
+ return __('No', 'nggallery');
644
+ }
645
+
646
+
647
+ /**
648
+ * Show up some server infor's
649
+ * @author GamerZ (http://www.lesterchan.net)
650
+ *
651
+ * @return void
652
+ */
653
+ function ngg_get_serverinfo() {
654
+
655
+ global $wpdb, $ngg;
656
+ // Get MYSQL Version
657
+ $sqlversion = $wpdb->get_var("SELECT VERSION() AS version");
658
+ // GET SQL Mode
659
+ $mysqlinfo = $wpdb->get_results("SHOW VARIABLES LIKE 'sql_mode'");
660
+ if (is_array($mysqlinfo)) $sql_mode = $mysqlinfo[0]->Value;
661
+ if (empty($sql_mode)) $sql_mode = __('Not set', 'nggallery');
662
+ // Get PHP Safe Mode
663
+ if(ini_get('safe_mode')) $safe_mode = __('On', 'nggallery');
664
+ else $safe_mode = __('Off', 'nggallery');
665
+ // Get PHP allow_url_fopen
666
+ if(ini_get('allow_url_fopen')) $allow_url_fopen = __('On', 'nggallery');
667
+ else $allow_url_fopen = __('Off', 'nggallery');
668
+ // Get PHP Max Upload Size
669
+ if(ini_get('upload_max_filesize')) $upload_max = ini_get('upload_max_filesize');
670
+ else $upload_max = __('N/A', 'nggallery');
671
+ // Get PHP Output buffer Size
672
+ if(ini_get('pcre.backtrack_limit')) $backtrack_limit = ini_get('pcre.backtrack_limit');
673
+ else $backtrack_limit = __('N/A', 'nggallery');
674
+ // Get PHP Max Post Size
675
+ if(ini_get('post_max_size')) $post_max = ini_get('post_max_size');
676
+ else $post_max = __('N/A', 'nggallery');
677
+ // Get PHP Max execution time
678
+ if(ini_get('max_execution_time')) $max_execute = ini_get('max_execution_time');
679
+ else $max_execute = __('N/A', 'nggallery');
680
+ // Get PHP Memory Limit
681
+ if(ini_get('memory_limit')) $memory_limit = $ngg->memory_limit;
682
+ else $memory_limit = __('N/A', 'nggallery');
683
+ // Get actual memory_get_usage
684
+ if (function_exists('memory_get_usage')) $memory_usage = round(memory_get_usage() / 1024 / 1024, 2) . __(' MByte', 'nggallery');
685
+ else $memory_usage = __('N/A', 'nggallery');
686
+ // required for EXIF read
687
+ if (is_callable('exif_read_data')) $exif = __('Yes', 'nggallery'). " ( V" . substr(phpversion('exif'),0,4) . ")" ;
688
+ else $exif = __('No', 'nggallery');
689
+ // required for meta data
690
+ if (is_callable('iptcparse')) $iptc = __('Yes', 'nggallery');
691
+ else $iptc = __('No', 'nggallery');
692
+ // required for meta data
693
+ if (is_callable('xml_parser_create')) $xml = __('Yes', 'nggallery');
694
+ else $xml = __('No', 'nggallery');
695
+
696
+ ?>
697
+ <li><?php _e('Operating System', 'nggallery'); ?> : <span><?php echo PHP_OS; ?>&nbsp;(<?php echo (PHP_INT_SIZE * 8) ?>&nbsp;Bit)</span></li>
698
+ <li><?php _e('Server', 'nggallery'); ?> : <span><?php echo $_SERVER["SERVER_SOFTWARE"]; ?></span></li>
699
+ <li><?php _e('Memory usage', 'nggallery'); ?> : <span><?php echo $memory_usage; ?></span></li>
700
+ <li><?php _e('MYSQL Version', 'nggallery'); ?> : <span><?php echo $sqlversion; ?></span></li>
701
+ <li><?php _e('SQL Mode', 'nggallery'); ?> : <span><?php echo $sql_mode; ?></span></li>
702
+ <li><?php _e('PHP Version', 'nggallery'); ?> : <span><?php echo PHP_VERSION; ?></span></li>
703
+ <li><?php _e('PHP Safe Mode', 'nggallery'); ?> : <span><?php echo $safe_mode; ?></span></li>
704
+ <li><?php _e('PHP Allow URL fopen', 'nggallery'); ?> : <span><?php echo $allow_url_fopen; ?></span></li>
705
+ <li><?php _e('PHP Memory Limit', 'nggallery'); ?> : <span><?php echo $memory_limit; ?></span></li>
706
+ <li><?php _e('PHP Max Upload Size', 'nggallery'); ?> : <span><?php echo $upload_max; ?></span></li>
707
+ <li><?php _e('PHP Max Post Size', 'nggallery'); ?> : <span><?php echo $post_max; ?></span></li>
708
+ <li><?php _e('PCRE Backtracking Limit', 'nggallery'); ?> : <span><?php echo $backtrack_limit; ?></span></li>
709
+ <li><?php _e('PHP Max Script Execute Time', 'nggallery'); ?> : <span><?php echo $max_execute; ?>s</span></li>
710
+ <li><?php _e('PHP Exif support', 'nggallery'); ?> : <span><?php echo $exif; ?></span></li>
711
+ <li><?php _e('PHP IPTC support', 'nggallery'); ?> : <span><?php echo $iptc; ?></span></li>
712
+ <li><?php _e('PHP XML support', 'nggallery'); ?> : <span><?php echo $xml; ?></span></li>
713
+ <?php
714
+ }
715
+
716
+ /**
717
+ * Inform about the end of PHP4
718
+ *
719
+ * @return void
720
+ */
721
+ function ngg_check_for_PHP5() {
722
+ ?>
723
+ <div class="updated">
724
+ <p><?php _e('NextCellent Gallery contains some functions which are only available under PHP 5.2. You are using the old PHP 4 version, upgrade now! It\'s no longer supported by the PHP group. Many shared hosting providers offer both PHP 4 and PHP 5, running simultaneously. Ask your provider if they can do this.', 'nggallery'); ?></p>
725
+ </div>
726
+ <?php
727
+ }
728
+
729
+ /**
730
+ * ngg_get_phpinfo() - Extract all of the data from phpinfo into a nested array
731
+ *
732
+ * @author jon@sitewizard.ca
733
+ * @return array
734
+ */
735
+ function ngg_get_phpinfo() {
736
+
737
+ ob_start();
738
+ phpinfo();
739
+ $phpinfo = array('phpinfo' => array());
740
+
741
+ if ( preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\s*</t[hd]>)?)?</tr>)#s', ob_get_clean(), $matches, PREG_SET_ORDER) )
742
+ foreach($matches as $match) {
743
+ if(strlen($match[1]))
744
+ $phpinfo[$match[1]] = array();
745
+ elseif(isset($match[3]))
746
+ $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
747
+ else
748
+ $phpinfo[end(array_keys($phpinfo))][] = $match[2];
749
+ }
750
+
751
+ return $phpinfo;
752
+ }
753
+
754
+ /**
755
+ * Show NextGEN Gallery related plugins. Fetch plugins from wp.org which have added 'nextgen-gallery' as tag in readme.txt
756
+ *
757
+ * @return postbox output
758
+ */
759
+ function ngg_widget_related_plugins() {
760
+ echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
761
+ }
762
+
763
+ /**
764
+ * Backward compatibility, scheduled to delete on future iteration.
765
+ */
766
+ function ngg_related_plugins() {
767
+ nextcellent_overview::related_plugins() ;
768
+ }
769
+
770
+ /**
771
+ * Provide utilities functions for creating metaboxes on overview
772
+ * Class nextcellent_overview
773
+ */
774
+ class nextcellent_overview {
775
+ const URL_WPGETREADY = 'http://www.wpgetready.com';
776
+
777
+ /**
778
+ * Display a list of related plugins, gathered from Wordpress Repository
779
+ * Optional parameter to display more or less plugins.
780
+ * To improve: filter obsolete plugins (last_updated less than two years from now)
781
+ */
782
+ static function related_plugins($how_many=4) {
783
+ include(ABSPATH . 'wp-admin/includes/plugin-install.php');
784
+ //If transient vaporized, refresh it
785
+ if ( false === ( $api = get_transient( 'ngg_related_plugins' ) ) ) {
786
+ // Adittional info http://dd32.id.au/projects/wordpressorg-plugin-information-api-docs/
787
+ $api = plugins_api('query_plugins', array('search' => 'nextgen') );
788
+ if ( is_wp_error($api) ) return;
789
+ set_transient( 'ngg_related_plugins', $api, 60*60*24 ); //enable to check within a day.
790
+ }
791
+
792
+ echo '<div style="margin-bottom:10px;padding:8px;font-size:110%;background:#eebbaa;"><b>'; _e('Pay attention','nggallery'); echo '</b>:'; _e('third parties plugins that are compatible with NGG may not be 100% compatible with NextCellent Gallery!','nggallery'); echo '</div>';
793
+ //List of suppressed plugin on the list.
794
+ $blacklist = array('nextgen-gallery','nextcellent-gallery-nextgen-legacy');
795
+
796
+ $i = 0;
797
+ while ( $i < $how_many ) {
798
+
799
+ // pick them randomly
800
+ if ( 0 == count($api->plugins) ) return;
801
+
802
+ $key = array_rand($api->plugins);
803
+ $plugin = $api->plugins[$key];
804
+
805
+ // don't forget to remove them
806
+ unset($api->plugins[$key]);
807
+
808
+ if ( !isset($plugin->name) ) continue;
809
+
810
+ if ( in_array($plugin->slug , $blacklist ) ) continue;
811
+
812
+ $link = esc_url( $plugin->homepage );
813
+ $title = esc_html( $plugin->name );
814
+
815
+ $description = esc_html( strip_tags(@html_entity_decode($plugin->short_description, ENT_QUOTES, get_option('blog_charset'))) );
816
+
817
+ $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin->slug, 'install-plugin_' . $plugin->slug) .
818
+ '&amp;TB_iframe=true&amp;width=600&amp;height=800';
819
+
820
+ echo "<h5><a href='{$link}' target='_blank'>{$title}</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
821
+ echo "<p>$description<strong> " . __( 'Author' ) . " : </strong>$plugin->author</p>\n";
822
+
823
+ $i++;
824
+ }
825
+
826
+ }
827
+
828
+ /**
829
+ * Like Metabox over right
830
+ */
831
+ static function likeThisMetaBox() {
832
+
833
+ echo '<p>';
834
+ echo sprintf(__('This plugin is a branch from NGG stable version 1.9.13.<br> Developed & maintained by <a href="%s" target="_blank">WPGetReady.com</a>', 'nggallery'), self::URL_WPGETREADY);
835
+
836
+ echo '</p><ul>';
837
+
838
+ $url = 'http://www.wordpress.org/plugins/nextcellent-gallery-nextgen-legacy/' ;
839
+ echo "<li style='padding-left: 38px; background:transparent url(" . NGGALLERY_URLPATH . "admin/images/icon-rating.png ) no-repeat scroll center left; background-position: 16px 50%; text-decoration: none;'><a href='{$url}' target='_blank'>";
840
+ _e('You can contribute by giving this plugin a good rating! Thanks a lot!', 'nggallery');
841
+ echo "</a></li>";
842
+
843
+ $url = self::URL_WPGETREADY;
844
+ echo "<li style='padding-left: 38px; background:transparent url(" . NGGALLERY_URLPATH . "admin/images/nextgen.png ) no-repeat scroll center left; background-position: 16px 50%; text-decoration: none;'><a href='{$url}' target='_blank'>";
845
+ _e("Visit the plugin homepage", 'nggallery');
846
+ echo '</a></li></ul>';
847
+ }
848
+ }
849
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/roles.php CHANGED
@@ -1,140 +1,139 @@
1
- <?php
2
-
3
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
-
5
- function nggallery_admin_roles() {
6
-
7
- if ( isset($_POST['update_cap']) ) {
8
-
9
- check_admin_referer('ngg_addroles');
10
-
11
- // now set or remove the capability
12
- ngg_set_capability($_POST['general'],"NextGEN Gallery overview");
13
- ngg_set_capability($_POST['tinymce'],"NextGEN Use TinyMCE");
14
- ngg_set_capability($_POST['add_gallery'],"NextGEN Upload images");
15
- ngg_set_capability($_POST['manage_gallery'],"NextGEN Manage gallery");
16
- ngg_set_capability($_POST['manage_others'],"NextGEN Manage others gallery");
17
- ngg_set_capability($_POST['manage_tags'],"NextGEN Manage tags");
18
- ngg_set_capability($_POST['edit_album'],"NextGEN Edit album");
19
- ngg_set_capability($_POST['change_style'],"NextGEN Change style");
20
- ngg_set_capability($_POST['change_options'],"NextGEN Change options");
21
-
22
- nggGallery::show_message(__('Updated capabilities',"nggallery"));
23
- }
24
-
25
- ?>
26
- <div class="wrap">
27
- <?php include('templates/social_media_buttons.php'); ?>
28
- <?php screen_icon( 'nextgen-gallery' ); ?>
29
- <h2><?php _e('Roles / capabilities', 'nggallery') ;?></h2>
30
- <p><?php _e('Select the lowest role which should be able to access the following capabilities. NextCellent Gallery supports the standard roles from WordPress.', 'nggallery') ?> <br />
31
- <?php _e('For a more flexible user management you can use the', 'nggallery') ?> <a href="http://wordpress.org/extend/plugins/capsman/" target="_blank">Capability Manager</a>.</p>
32
- <form name="addroles" id="addroles" method="POST" accept-charset="utf-8" >
33
- <?php wp_nonce_field('ngg_addroles') ?>
34
- <table class="form-table">
35
- <tr valign="top">
36
- <th scope="row"><?php _e('Main NextCellent Gallery overview', 'nggallery') ;?>:</th>
37
- <td><label for="general"><select name="general" id="general"><?php wp_dropdown_roles( ngg_get_role('NextGEN Gallery overview') ); ?></select></label></td>
38
- </tr>
39
- <tr valign="top">
40
- <th scope="row"><?php _e('Use TinyMCE Button / Upload tab', 'nggallery') ;?>:</th>
41
- <td><label for="tinymce"><select name="tinymce" id="tinymce"><?php wp_dropdown_roles( ngg_get_role('NextGEN Use TinyMCE') ); ?></select></label></td>
42
- </tr>
43
- <tr valign="top">
44
- <th scope="row"><?php _e('Add gallery / Upload images', 'nggallery') ;?>:</th>
45
- <td><label for="add_gallery"><select name="add_gallery" id="add_gallery"><?php wp_dropdown_roles( ngg_get_role('NextGEN Upload images') ); ?></select></label></td>
46
- </tr>
47
- <tr valign="top">
48
- <th scope="row"><?php _e('Manage gallery', 'nggallery') ;?>:</th>
49
- <td><label for="manage_gallery"><select name="manage_gallery" id="manage_gallery"><?php wp_dropdown_roles( ngg_get_role('NextGEN Manage gallery') ); ?></select></label></td>
50
- </tr>
51
- <tr valign="top">
52
- <th scope="row"><?php _e('Manage others gallery', 'nggallery') ;?>:</th>
53
- <td><label for="manage_others"><select name="manage_others" id="manage_others"><?php wp_dropdown_roles( ngg_get_role('NextGEN Manage others gallery') ); ?></select></label></td>
54
- </tr>
55
- <tr valign="top">
56
- <th scope="row"><?php _e('Manage tags', 'nggallery') ;?>:</th>
57
- <td><label for="manage_tags"><select name="manage_tags" id="manage_tags"><?php wp_dropdown_roles( ngg_get_role('NextGEN Manage tags') ); ?></select></label></td>
58
- </tr>
59
- <tr valign="top">
60
- <th scope="row"><?php _e('Edit Album', 'nggallery') ;?>:</th>
61
- <td><label for="edit_album"><select name="edit_album" id="edit_album"><?php wp_dropdown_roles( ngg_get_role('NextGEN Edit album') ); ?></select></label></td>
62
- </tr>
63
- <tr valign="top">
64
- <th scope="row"><?php _e('Change style', 'nggallery') ;?>:</th>
65
- <td><label for="change_style"><select name="change_style" id="change_style"><?php wp_dropdown_roles( ngg_get_role('NextGEN Change style') ); ?></select></label></td>
66
- </tr>
67
- <tr valign="top">
68
- <th scope="row"><?php _e('Change options', 'nggallery') ;?>:</th>
69
- <td><label for="change_options"><select name="change_options" id="change_options"><?php wp_dropdown_roles( ngg_get_role('NextGEN Change options') ); ?></select></label></td>
70
- </tr>
71
- </table>
72
- <div class="submit"><input type="submit" class="button-primary" name= "update_cap" value="<?php _e('Update capabilities', 'nggallery') ;?>"/></div>
73
- </form>
74
- </div>
75
- <?php
76
-
77
- }
78
-
79
- function ngg_get_sorted_roles() {
80
- // This function returns all roles, sorted by user level (lowest to highest)
81
- global $wp_roles;
82
- $roles = $wp_roles->role_objects;
83
- $sorted = array();
84
-
85
- if( class_exists('RoleManager') ) {
86
- foreach( $roles as $role_key => $role_name ) {
87
- $role = get_role($role_key);
88
- if( empty($role) ) continue;
89
- $role_user_level = array_reduce(array_keys($role->capabilities), array('WP_User', 'level_reduction'), 0);
90
- $sorted[$role_user_level] = $role;
91
- }
92
- $sorted = array_values($sorted);
93
- } else {
94
- $role_order = array("subscriber", "contributor", "author", "editor", "administrator");
95
- foreach($role_order as $role_key) {
96
- $sorted[$role_key] = get_role($role_key);
97
- }
98
- }
99
- return $sorted;
100
- }
101
-
102
- function ngg_get_role($capability){
103
- // This function return the lowest roles which has the capabilities
104
- $check_order = ngg_get_sorted_roles();
105
-
106
- $args = array_slice(func_get_args(), 1);
107
- $args = array_merge(array($capability), $args);
108
-
109
- foreach ($check_order as $check_role) {
110
- if ( empty($check_role) )
111
- return false;
112
-
113
- if (call_user_func_array(array(&$check_role, 'has_cap'), $args))
114
- return $check_role->name;
115
- }
116
- return false;
117
- }
118
-
119
- function ngg_set_capability($lowest_role, $capability){
120
- // This function set or remove the $capability
121
- $check_order = ngg_get_sorted_roles();
122
-
123
- $add_capability = false;
124
-
125
- foreach ($check_order as $the_role) {
126
- $role = $the_role->name;
127
-
128
- if ( $lowest_role == $role )
129
- $add_capability = true;
130
-
131
- // If you rename the roles, then please use a role manager plugin
132
-
133
- if ( empty($the_role) )
134
- continue;
135
-
136
- $add_capability ? $the_role->add_cap($capability) : $the_role->remove_cap($capability) ;
137
- }
138
- }
139
-
140
  ?>
1
+ <?php
2
+
3
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
4
+
5
+ function nggallery_admin_roles() {
6
+
7
+ if ( isset($_POST['update_cap']) ) {
8
+
9
+ check_admin_referer('ngg_addroles');
10
+
11
+ // now set or remove the capability
12
+ ngg_set_capability($_POST['general'],"NextGEN Gallery overview");
13
+ ngg_set_capability($_POST['tinymce'],"NextGEN Use TinyMCE");
14
+ ngg_set_capability($_POST['add_gallery'],"NextGEN Upload images");
15
+ ngg_set_capability($_POST['manage_gallery'],"NextGEN Manage gallery");
16
+ ngg_set_capability($_POST['manage_others'],"NextGEN Manage others gallery");
17
+ ngg_set_capability($_POST['manage_tags'],"NextGEN Manage tags");
18
+ ngg_set_capability($_POST['edit_album'],"NextGEN Edit album");
19
+ ngg_set_capability($_POST['change_style'],"NextGEN Change style");
20
+ ngg_set_capability($_POST['change_options'],"NextGEN Change options");
21
+
22
+ nggGallery::show_message(__('Updated capabilities',"nggallery"));
23
+ }
24
+
25
+ ?>
26
+ <div class="wrap">
27
+ <?php screen_icon( 'nextgen-gallery' ); ?>
28
+ <h2><?php _e('Roles / capabilities', 'nggallery') ;?></h2>
29
+ <p><?php _e('Select the lowest role which should be able to access the following capabilities. NextCellent Gallery supports the standard roles from WordPress.', 'nggallery') ?> <br />
30
+ <?php _e('For a more flexible user management you can use the', 'nggallery') ?> <a href="http://wordpress.org/extend/plugins/capsman/" target="_blank">Capability Manager</a>.</p>
31
+ <form name="addroles" id="addroles" method="POST" accept-charset="utf-8" >
32
+ <?php wp_nonce_field('ngg_addroles') ?>
33
+ <table class="form-table">
34
+ <tr valign="top">
35
+ <th scope="row"><?php _e('Main NextCellent Gallery overview', 'nggallery') ;?>:</th>
36
+ <td><label for="general"><select name="general" id="general"><?php wp_dropdown_roles( ngg_get_role('NextGEN Gallery overview') ); ?></select></label></td>
37
+ </tr>
38
+ <tr valign="top">
39
+ <th scope="row"><?php _e('Use TinyMCE Button / Upload tab', 'nggallery') ;?>:</th>
40
+ <td><label for="tinymce"><select name="tinymce" id="tinymce"><?php wp_dropdown_roles( ngg_get_role('NextGEN Use TinyMCE') ); ?></select></label></td>
41
+ </tr>
42
+ <tr valign="top">
43
+ <th scope="row"><?php _e('Add gallery / Upload images', 'nggallery') ;?>:</th>
44
+ <td><label for="add_gallery"><select name="add_gallery" id="add_gallery"><?php wp_dropdown_roles( ngg_get_role('NextGEN Upload images') ); ?></select></label></td>
45
+ </tr>
46
+ <tr valign="top">
47
+ <th scope="row"><?php _e('Manage gallery', 'nggallery') ;?>:</th>
48
+ <td><label for="manage_gallery"><select name="manage_gallery" id="manage_gallery"><?php wp_dropdown_roles( ngg_get_role('NextGEN Manage gallery') ); ?></select></label></td>
49
+ </tr>
50
+ <tr valign="top">
51
+ <th scope="row"><?php _e('Manage others gallery', 'nggallery') ;?>:</th>
52
+ <td><label for="manage_others"><select name="manage_others" id="manage_others"><?php wp_dropdown_roles( ngg_get_role('NextGEN Manage others gallery') ); ?></select></label></td>
53
+ </tr>
54
+ <tr valign="top">
55
+ <th scope="row"><?php _e('Manage tags', 'nggallery') ;?>:</th>
56
+ <td><label for="manage_tags"><select name="manage_tags" id="manage_tags"><?php wp_dropdown_roles( ngg_get_role('NextGEN Manage tags') ); ?></select></label></td>
57
+ </tr>
58
+ <tr valign="top">
59
+ <th scope="row"><?php _e('Edit Album', 'nggallery') ;?>:</th>
60
+ <td><label for="edit_album"><select name="edit_album" id="edit_album"><?php wp_dropdown_roles( ngg_get_role('NextGEN Edit album') ); ?></select></label></td>
61
+ </tr>
62
+ <tr valign="top">
63
+ <th scope="row"><?php _e('Change style', 'nggallery') ;?>:</th>
64
+ <td><label for="change_style"><select name="change_style" id="change_style"><?php wp_dropdown_roles( ngg_get_role('NextGEN Change style') ); ?></select></label></td>
65
+ </tr>
66
+ <tr valign="top">
67
+ <th scope="row"><?php _e('Change options', 'nggallery') ;?>:</th>
68
+ <td><label for="change_options"><select name="change_options" id="change_options"><?php wp_dropdown_roles( ngg_get_role('NextGEN Change options') ); ?></select></label></td>
69
+ </tr>
70
+ </table>
71
+ <div class="submit"><input type="submit" class="button-primary" name= "update_cap" value="<?php _e('Update capabilities', 'nggallery') ;?>"/></div>
72
+ </form>
73
+ </div>
74
+ <?php
75
+
76
+ }
77
+
78
+ function ngg_get_sorted_roles() {
79
+ // This function returns all roles, sorted by user level (lowest to highest)
80
+ global $wp_roles;
81
+ $roles = $wp_roles->role_objects;
82
+ $sorted = array();
83
+
84
+ if( class_exists('RoleManager') ) {
85
+ foreach( $roles as $role_key => $role_name ) {
86
+ $role = get_role($role_key);
87
+ if( empty($role) ) continue;
88
+ $role_user_level = array_reduce(array_keys($role->capabilities), array('WP_User', 'level_reduction'), 0);
89
+ $sorted[$role_user_level] = $role;
90
+ }
91
+ $sorted = array_values($sorted);
92
+ } else {
93
+ $role_order = array("subscriber", "contributor", "author", "editor", "administrator");
94
+ foreach($role_order as $role_key) {
95
+ $sorted[$role_key] = get_role($role_key);
96
+ }
97
+ }
98
+ return $sorted;
99
+ }
100
+
101
+ function ngg_get_role($capability){
102
+ // This function return the lowest roles which has the capabilities
103
+ $check_order = ngg_get_sorted_roles();
104
+
105
+ $args = array_slice(func_get_args(), 1);
106
+ $args = array_merge(array($capability), $args);
107
+
108
+ foreach ($check_order as $check_role) {
109
+ if ( empty($check_role) )
110
+ return false;
111
+
112
+ if (call_user_func_array(array(&$check_role, 'has_cap'), $args))
113
+ return $check_role->name;
114
+ }
115
+ return false;
116
+ }
117
+
118
+ function ngg_set_capability($lowest_role, $capability){
119
+ // This function set or remove the $capability
120
+ $check_order = ngg_get_sorted_roles();
121
+
122
+ $add_capability = false;
123
+
124
+ foreach ($check_order as $the_role) {
125
+ $role = $the_role->name;
126
+
127
+ if ( $lowest_role == $role )
128
+ $add_capability = true;
129
+
130
+ // If you rename the roles, then please use a role manager plugin
131
+
132
+ if ( empty($the_role) )
133
+ continue;
134
+
135
+ $add_capability ? $the_role->add_cap($capability) : $the_role->remove_cap($capability) ;
136
+ }
137
+ }
138
+
 
139
  ?>
admin/rotate.php CHANGED
@@ -1,94 +1,93 @@
1
- <?php
2
- /**
3
-
4
- Custom thumbnail for NGG
5
- Author : Simone Fumagalli | simone@iliveinperego.com
6
- More info and update : http://www.iliveinperego.com/rotate_for_ngg/
7
-
8
- Credits:
9
- NextGen Gallery : Alex Rabe | http://alexrabe.boelinger.com/wordpress-plugins/nextgen-gallery/
10
-
11
- **/
12
-
13
- require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
14
- require_once( NGGALLERY_ABSPATH . '/lib/image.php' );
15
-
16
- if ( !is_user_logged_in() )
17
- die(__('Cheatin&#8217; uh?'));
18
-
19
- if ( !current_user_can('NextGEN Manage gallery') )
20
- die(__('Cheatin&#8217; uh?'));
21
-
22
- global $wpdb;
23
-
24
- $id = (int) $_GET['id'];
25
-
26
- // let's get the image data
27
- $picture = nggdb::find_image($id);
28
-
29
- include_once( nggGallery::graphic_library() );
30
- $ngg_options = get_option('ngg_options');
31
-
32
- $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
33
- $thumb->resize(350,350);
34
-
35
- // we need the new dimension
36
- $resizedPreviewInfo = $thumb->newDimensions;
37
- $thumb->destruct();
38
-
39
- $preview_image = trailingslashit( home_url() ) . 'index.php?callback=image&amp;pid=' . $picture->pid . '&amp;width=350&amp;height=350';
40
-
41
- ?>
42
-
43
- <script language="JavaScript">
44
- <!--
45
-
46
- function rotateImage() {
47
-
48
- var rotate_angle = jQuery('input[name=ra]:checked').val();
49
-
50
- jQuery.ajax({
51
- url: ajaxurl,
52
- type : "POST",
53
- data: {action: 'rotateImage', id: <?php echo $id ?>, ra: rotate_angle},
54
- cache: false,
55
- success: function (msg) { showMessage('<?php _e('Image rotated', 'nggallery'); ?>') },
56
- error: function (msg, status, errorThrown) { showMessage('<?php _e('Error rotating thumbnail', 'nggallery'); ?>') }
57
- });
58
-
59
- }
60
-
61
- function showMessage(message) {
62
- jQuery('#thumbMsg').html(message);
63
- jQuery('#thumbMsg').css({'display':'block'});
64
- setTimeout(function(){ jQuery('#thumbMsg').fadeOut('slow'); }, 1500);
65
-
66
- var d = new Date();
67
- newUrl = jQuery("#imageToEdit").attr("src") + "?" + d.getTime();
68
- jQuery("#imageToEdit").attr("src" , newUrl);
69
-
70
- }
71
-
72
- -->
73
- </script>
74
-
75
- <table width="98%" align="center" style="border:1px solid #DADADA">
76
- <tr style="height : 360px;">
77
- <td valign="middle" align="center" style="background-color:#DADADA; width : 370px;">
78
- <img src="<?php echo esc_url( $preview_image ); ?>" alt="" id="imageToEdit" />
79
- </td>
80
- <td>
81
- <input type="radio" name="ra" value="cw" /><?php esc_html_e('90&deg; clockwise', 'nggallery'); ?><br />
82
- <input type="radio" name="ra" value="ccw" /><?php esc_html_e('90&deg; anticlockwise', 'nggallery'); ?><br />
83
- <input type="radio" name="ra" value="fv" /><?php esc_html_e('Flip vertically', 'nggallery'); ?><br />
84
- <input type="radio" name="ra" value="fh" /><?php esc_html_e('Flip horizontally', 'nggallery'); ?>
85
- </td>
86
- </tr>
87
- <tr style="background-color:#DADADA;">
88
-
89
- <td colspan="2">
90
- <input type="button" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>" onclick="rotateImage()" class="button-secondary" style="float:right; margin-left:4px;"/>
91
- <div id="thumbMsg" style="color:#FF0000; display : none;font-size:11px; float:right; width:60%; height:2em; line-height:2em;"></div>
92
- </td>
93
- </tr>
94
  </table>
1
+ <?php
2
+ /**
3
+
4
+ Custom thumbnail for NGG
5
+ Author : Simone Fumagalli | simone@iliveinperego.com
6
+ More info and update : http://www.iliveinperego.com/rotate_for_ngg/
7
+
8
+ Credits:
9
+ NextGen Gallery : Alex Rabe | http://alexrabe.boelinger.com/wordpress-plugins/nextgen-gallery/
10
+
11
+ **/
12
+
13
+ require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
14
+ require_once( NGGALLERY_ABSPATH . '/lib/image.php' );
15
+
16
+ if ( !is_user_logged_in() )
17
+ die(__('Cheatin&#8217; uh?'));
18
+
19
+ if ( !current_user_can('NextGEN Manage gallery') )
20
+ die(__('Cheatin&#8217; uh?'));
21
+
22
+ global $wpdb;
23
+
24
+ $id = (int) $_GET['id'];
25
+
26
+ // let's get the image data
27
+ $picture = nggdb::find_image($id);
28
+
29
+ include_once( nggGallery::graphic_library() );
30
+ $ngg_options = get_option('ngg_options');
31
+
32
+ $thumb = new ngg_Thumbnail($picture->imagePath, TRUE);
33
+ $thumb->resize(350,350);
34
+
35
+ // we need the new dimension
36
+ $resizedPreviewInfo = $thumb->newDimensions;
37
+ $thumb->destruct();
38
+
39
+ $preview_image = trailingslashit( home_url() ) . 'index.php?callback=image&amp;pid=' . $picture->pid . '&amp;width=350&amp;height=350';
40
+
41
+ ?>
42
+
43
+ <script language="JavaScript">
44
+ <!--
45
+
46
+ function rotateImage() {
47
+
48
+ var rotate_angle = jQuery('input[name=ra]:checked').val();
49
+
50
+ jQuery.ajax({
51
+ url: ajaxurl,
52
+ type : "POST",
53
+ data: {action: 'rotateImage', id: <?php echo $id ?>, ra: rotate_angle},
54
+ cache: false,
55
+ success: function (msg) { showMessage('<?php _e('Image rotated', 'nggallery'); ?>') },
56
+ error: function (msg, status, errorThrown) { showMessage('<?php _e('Error rotating thumbnail', 'nggallery'); ?>') }
57
+ });
58
+
59
+ }
60
+
61
+ function showMessage(message) {
62
+ jQuery('#thumbMsg').html(message);
63
+ jQuery('#thumbMsg').css({'display':'block'});
64
+ setTimeout(function(){ jQuery('#thumbMsg').fadeOut('slow'); }, 1500);
65
+
66
+ var d = new Date();
67
+ newUrl = jQuery("#imageToEdit").attr("src") + "?" + d.getTime();
68
+ jQuery("#imageToEdit").attr("src" , newUrl);
69
+
70
+ }
71
+
72
+ -->
73
+ </script>
74
+ <p><?php _e('Select how you would like to rotate the image on the left.', 'nggallery'); ?></p>
75
+ <table width="98%" align="center">
76
+ <tr style="min-height: 360px;">
77
+ <td valign="middle" align="center" style="width : 370px;">
78
+ <img src="<?php echo esc_url( $preview_image ); ?>" alt="" id="imageToEdit" />
79
+ </td>
80
+ <td style="min-width: 160px;">
81
+ <input type="radio" name="ra" value="cw" /><?php esc_html_e('90&deg; clockwise', 'nggallery'); ?><br />
82
+ <input type="radio" name="ra" value="ccw" /><?php esc_html_e('90&deg; anticlockwise', 'nggallery'); ?><br />
83
+ <input type="radio" name="ra" value="fv" /><?php esc_html_e('Flip vertically', 'nggallery'); ?><br />
84
+ <input type="radio" name="ra" value="fh" /><?php esc_html_e('Flip horizontally', 'nggallery'); ?>
85
+ </td>
86
+ </tr>
87
+ <tr>
88
+ <td colspan="2">
89
+ <input type="button" name="update" value="<?php esc_attr_e('Update', 'nggallery'); ?>" onclick="rotateImage()" class="button-primary" style="float:right; margin-top:0.5em;"/>
90
+ <div id="thumbMsg" style="display : none; float:right; width:60%; height:2em; line-height:2em;"></div>
91
+ </td>
92
+ </tr>
 
93
  </table>
admin/settings.php CHANGED
@@ -1,930 +1,915 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- /**
5
- * Rebuild slugs for albums, galleries and images via AJAX request
6
- *
7
- * @sine 1.7.0
8
- * @access internal
9
- */
10
- class ngg_rebuild_unique_slugs {
11
-
12
- function start_rebuild() {
13
- global $wpdb;
14
-
15
- $total = array();
16
- // get the total number of images
17
- $total['images'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
18
- $total['gallery'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
19
- $total['album'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
20
-
21
- $messages = array(
22
- 'images' => __( 'Rebuild image structure : %s / %s images', 'nggallery' ),
23
- 'gallery' => __( 'Rebuild gallery structure : %s / %s galleries', 'nggallery' ),
24
- 'album' => __( 'Rebuild album structure : %s / %s albums', 'nggallery' ),
25
- );
26
-
27
- ?>
28
- <?php
29
-
30
- foreach ( array_keys( $messages ) as $key ) {
31
-
32
- $message = sprintf( $messages[ $key ] ,
33
- "<span class='ngg-count-current'>0</span>",
34
- "<span class='ngg-count-total'>" . $total[ $key ] . "</span>"
35
- );
36
-
37
- echo "<div class='$key updated'><p class='ngg'>$message</p></div>";
38
- }
39
-
40
- $ajax_url = add_query_arg( 'action', 'ngg_rebuild_unique_slugs', admin_url( 'admin-ajax.php' ) );
41
- ?>
42
- <script type="text/javascript">
43
- jQuery(document).ready(function($) {
44
- var ajax_url = '<?php echo $ajax_url; ?>',
45
- _action = 'images',
46
- images = <?php echo $total['images']; ?>,
47
- gallery = <?php echo $total['gallery']; ?>,
48
- album = <?php echo $total['album']; ?>,
49
- total = 0,
50
- offset = 0,
51
- count = 50;
52
-
53
- var $display = $('.ngg-count-current');
54
- $('.finished, .gallery, .album').hide();
55
- total = images;
56
-
57
- function call_again() {
58
- if ( offset > total ) {
59
- offset = 0;
60
- // 1st run finished
61
- if (_action == 'images') {
62
- _action = 'gallery';
63
- total = gallery;
64
- $('.images, .gallery').toggle();
65
- $display.html(offset);
66
- call_again();
67
- return;
68
- }
69
- // 2nd run finished
70
- if (_action == 'gallery') {
71
- _action = 'album';
72
- total = album;
73
- $('.gallery, .album').toggle();
74
- $display.html(offset);
75
- call_again();
76
- return;
77
- }
78
- // 3rd run finished, exit now
79
- if (_action == 'album') {
80
- $('.ngg')
81
- .html('<?php _e( 'Done.', 'nggallery' ); ?>')
82
- .parent('div').hide();
83
- $('.finished').show();
84
- return;
85
- }
86
- }
87
-
88
- $.post(ajax_url, {'_action': _action, 'offset': offset}, function(response) {
89
- $display.html(offset);
90
-
91
- offset += count;
92
- call_again();
93
- });
94
- }
95
-
96
- call_again();
97
- });
98
- </script>
99
- <?php
100
- }
101
- }
102
-
103
- class nggOptions {
104
-
105
- /**
106
- * nggOptions::__construct()
107
- *
108
- * @return void
109
- */
110
- function __construct() {
111
-
112
- // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
113
- $this->filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
114
-
115
- //Look for POST updates
116
- if ( !empty($_POST) )
117
- $this->processor();
118
- }
119
-
120
- /**
121
- * Save/Load options and add a new hook for plugins
122
- *
123
- * @return void
124
- */
125
- function processor() {
126
-
127
- global $ngg, $nggRewrite;
128
-
129
- $old_state = $ngg->options['usePermalinks'];
130
- $old_slug = $ngg->options['permalinkSlug'];
131
-
132
- if ( isset($_POST['irDetect']) ) {
133
- check_admin_referer('ngg_settings');
134
- $ngg->options['irURL'] = ngg_search_imagerotator();
135
- update_option('ngg_options', $ngg->options);
136
- }
137
-
138
- if ( isset($_POST['updateoption']) ) {
139
- check_admin_referer('ngg_settings');
140
- // get the hidden option fields, taken from WP core
141
- if ( $_POST['page_options'] )
142
- $options = explode(',', stripslashes($_POST['page_options']));
143
-
144
- if ($options) {
145
- foreach ($options as $option) {
146
- $option = trim($option);
147
- $value = isset($_POST[$option]) ? trim($_POST[$option]) : false;
148
- // $value = sanitize_option($option, $value); // This does stripslashes on those that need it
149
- $ngg->options[$option] = $value;
150
- }
151
-
152
- // do not allow a empty string
153
- if ( empty ( $ngg->options['permalinkSlug'] ) )
154
- $ngg->options['permalinkSlug'] = 'nggallery';
155
-
156
- // the path should always end with a slash
157
- $ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
158
- $ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
159
-
160
- // the custom sortorder must be ascending
161
- $ngg->options['galSortDir'] = ($ngg->options['galSort'] == 'sortorder') ? 'ASC' : $ngg->options['galSortDir'];
162
- }
163
- // Save options
164
- update_option('ngg_options', $ngg->options);
165
-
166
- // Flush Rewrite rules
167
- if ( $old_state != $ngg->options['usePermalinks'] || $old_slug != $ngg->options['permalinkSlug'] )
168
- $nggRewrite->flush();
169
-
170
- nggGallery::show_message(__('Update Successfully','nggallery'));
171
- }
172
-
173
- if ( isset($_POST['clearcache']) ) {
174
- check_admin_referer('ngg_settings');
175
-
176
- $path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
177
-
178
- if (is_dir($path))
179
- if ($handle = opendir($path)) {
180
- while (false !== ($file = readdir($handle))) {
181
- if ($file != '.' && $file != '..') {
182
- @unlink($path . '/' . $file);
183
- }
184
- }
185
- closedir($handle);
186
- }
187
-
188
- nggGallery::show_message(__('Cache cleared','nggallery'));
189
- }
190
-
191
- if ( isset($_POST['createslugs']) ) {
192
- check_admin_referer('ngg_settings');
193
- ngg_rebuild_unique_slugs::start_rebuild();
194
- }
195
-
196
- do_action( 'ngg_update_options_page' );
197
-
198
- }
199
-
200
- /**
201
- * Render the page content
202
- *
203
- * @return void
204
- */
205
- function controller() {
206
-
207
- // get list of tabs
208
- $tabs = $this->tabs_order();
209
-
210
- ?>
211
- <script type="text/javascript">
212
- jQuery(document).ready(function(){
213
- jQuery('html,body').scrollTop(0);
214
- jQuery("a.switch-expert").hide();
215
- /*
216
- jQuery(".expert").hide();
217
- jQuery("a.switch-expert").click(function(e) {
218
- jQuery(".expert").toggle();
219
- return false;
220
- });
221
- */
222
- jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' });
223
- jQuery('#slider').css('display', 'block');
224
- /*
225
- jQuery('.picker').ColorPicker({
226
- onSubmit: function(hsb, hex, rgb, el) {
227
- jQuery(el).val(hex);
228
- jQuery(el).ColorPickerHide();
229
- },
230
- onBeforeShow: function () {
231
- jQuery(this).ColorPickerSetColor(this.value);
232
- }
233
- })
234
- .bind('keyup', function(){
235
- jQuery(this).ColorPickerSetColor(this.value);
236
- });
237
- */
238
- });
239
-
240
- function insertcode(value) {
241
- var effectcode;
242
- switch (value) {
243
- case "none":
244
- effectcode = "";
245
- jQuery('#tbImage').hide("slow");
246
- break;
247
- case "thickbox":
248
- effectcode = 'class="thickbox" rel="%GALLERY_NAME%"';
249
- jQuery('#tbImage').show("slow");
250
- break;
251
- case "lightbox":
252
- effectcode = 'rel="lightbox[%GALLERY_NAME%]"';
253
- jQuery('#tbImage').hide("slow");
254
- break;
255
- case "highslide":
256
- effectcode = 'class="highslide" onclick="return hs.expand(this, { slideshowGroup: %GALLERY_NAME% })"';
257
- jQuery('#tbImage').hide("slow");
258
- break;
259
- case "shutter":
260
- effectcode = 'class="shutterset_%GALLERY_NAME%"';
261
- jQuery('#tbImage').hide("slow");
262
- break;
263
- default:
264
- break;
265
- }
266
- jQuery("#thumbCode").val(effectcode);
267
- };
268
-
269
- function setcolor(fileid, color) {
270
- jQuery(fileid).css("background-color", '#' + color );
271
- };
272
- </script>
273
- <?php include('templates/social_media_buttons.php'); ?>
274
- <div id="slider" class="wrap" style="display: none;">
275
- <ul id="tabs">
276
- <?php
277
- foreach($tabs as $tab_key => $tab_name) {
278
- echo "\n\t\t<li><a href='#$tab_key'>$tab_name</a></li>";
279
- }
280
- ?>
281
- </ul>
282
- <?php
283
- foreach($tabs as $tab_key => $tab_name) {
284
- echo "\n\t<div id='$tab_key'>\n";
285
- // Looks for the internal class function, otherwise enable a hook for plugins
286
- if ( method_exists( $this, "tab_$tab_key" ))
287
- call_user_func( array( &$this , "tab_$tab_key") );
288
- else
289
- do_action( 'ngg_tab_content_' . $tab_key );
290
- echo "\n\t</div>";
291
- }
292
- ?>
293
- </div>
294
- <?php
295
-
296
- }
297
-
298
- /**
299
- * Create array for tabs and add a filter for other plugins to inject more tabs
300
- *
301
- * @return array $tabs
302
- */
303
- function tabs_order() {
304
-
305
- $tabs = array();
306
-
307
- $tabs['generaloptions'] = __('General Options', 'nggallery');
308
- $tabs['thumbnails'] = __('Thumbnails', 'nggallery');
309
- $tabs['images'] = __('Images', 'nggallery');
310
- $tabs['gallery'] = _n( 'Gallery', 'Galleries', 1, 'nggallery' );
311
- $tabs['effects'] = __('Effects', 'nggallery');
312
- $tabs['watermark'] = __('Watermark', 'nggallery');
313
- $tabs['slideshow'] = __('Slideshow', 'nggallery');
314
-
315
- $tabs = apply_filters('ngg_settings_tabs', $tabs);
316
-
317
- return $tabs;
318
-
319
- }
320
-
321
- function tab_generaloptions() {
322
- global $ngg;
323
-
324
- ?>
325
- <!-- General Options -->
326
- <h2><?php _e('General Options','nggallery'); ?></h2>
327
- <form name="generaloptions" method="post" action="<?php echo $this->filepath; ?>">
328
- <?php wp_nonce_field('ngg_settings') ?>
329
- <input type="hidden" name="page_options" value="gallerypath,deleteImg,useMediaRSS,usePicLens,usePermalinks,permalinkSlug,graphicLibrary,imageMagickDir,activateTags,appendType,maxImages" />
330
- <table class="form-table ngg-options">
331
- <tr valign="top">
332
- <th align="left"><?php _e('Gallery path','nggallery'); ?></th>
333
- <td><input <?php if (is_multisite()) echo 'readonly = "readonly"'; ?> type="text" size="35" name="gallerypath" value="<?php echo $ngg->options['gallerypath']; ?>" />
334
- <span class="setting-description"><?php _e('This is the default path for all galleries','nggallery') ?></span></td>
335
- </tr>
336
- <tr class="expert" valign="top">
337
- <th align="left"><?php _e('Delete image files','nggallery'); ?></th>
338
- <td><input <?php if (is_multisite()) echo 'readonly = "readonly"'; ?> type="checkbox" name="deleteImg" value="1" <?php checked('1', $ngg->options['deleteImg']); ?> />
339
- <?php _e('Delete files, when removing a gallery in the database','nggallery'); ?></td>
340
- </tr>
341
- <tr valign="top">
342
- <th align="left"><?php _e('Activate permalinks','nggallery') ?></th>
343
- <td><input type="checkbox" name="usePermalinks" value="1" <?php checked('1', $ngg->options['usePermalinks']); ?> />
344
- <?php _e('When you activate this option, you need to update your permalink structure one time.','nggallery'); ?>
345
- <?php _e('Gallery slug name :','nggallery'); ?>
346
- <input type="text" size="15" name="permalinkSlug" value="<?php echo $ngg->options['permalinkSlug']; ?>" /></td>
347
- </tr>
348
- <tr class="expert">
349
- <th valign="top"><?php _e('Create new URL friendly image slugs','nggallery'); ?></th>
350
- <td><input type="submit" name="createslugs" class="button-secondary" value="<?php _e('Proceed now','nggallery') ;?> &raquo;"/></td>
351
- </tr>
352
- <tr class="expert">
353
- <th valign="top"><?php _e('Select graphic library','nggallery'); ?></th>
354
- <td><label><input name="graphicLibrary" type="radio" value="gd" <?php checked('gd', $ngg->options['graphicLibrary']); ?> /> <?php _e('GD Library', 'nggallery') ;?></label><br />
355
- <label><input name="graphicLibrary" type="radio" value="im" <?php checked('im', $ngg->options['graphicLibrary']); ?> /> <?php _e('ImageMagick (Experimental). Path to the library :', 'nggallery') ;?>&nbsp;
356
- <input <?php if (is_multisite()) echo 'readonly = "readonly"'; ?> type="text" size="35" name="imageMagickDir" value="<?php echo $ngg->options['imageMagickDir']; ?>" /></label>
357
- </td>
358
- </tr>
359
- <tr>
360
- <th align="left"><?php _e('Activate Media RSS feed','nggallery'); ?></th>
361
- <td><input type="checkbox" name="useMediaRSS" value="1" <?php checked('1', $ngg->options['useMediaRSS']); ?> />
362
- <span class="setting-description"><?php _e('A RSS feed will be added to you blog header. Useful for CoolIris/PicLens','nggallery') ?></span></td>
363
- </tr>
364
- <tr>
365
- <th align="left"><?php _e('Activate PicLens/CoolIris support','nggallery'); ?> (<a href="http://www.cooliris.com">CoolIris</a>)</th>
366
- <td><input type="checkbox" name="usePicLens" value="1" <?php checked('1', $ngg->options['usePicLens']); ?> />
367
- <span class="setting-description"><?php _e('When you activate this option, some javascript is added to your site footer. Make sure that wp_footer is called in your theme.','nggallery') ?></span></td>
368
- </tr>
369
- </table>
370
- <h3 class="expert"><?php _e('Tags / Categories','nggallery'); ?></h3>
371
- <table class="expert form-table ngg-options">
372
- <tr>
373
- <th valign="top"><?php _e('Activate related images','nggallery'); ?></th>
374
- <td><input name="activateTags" type="checkbox" value="1" <?php checked('1', $ngg->options['activateTags']); ?> />
375
- <?php _e('This option will append related images to every post','nggallery'); ?>
376
- </td>
377
- </tr>
378
- <tr>
379
- <th valign="top"><?php _e('Match with','nggallery'); ?></th>
380
- <td><label><input name="appendType" type="radio" value="category" <?php checked('category', $ngg->options['appendType']); ?> /> <?php _e('Categories', 'nggallery') ;?></label><br />
381
- <label><input name="appendType" type="radio" value="tags" <?php checked('tags', $ngg->options['appendType']); ?> /> <?php _e('Tags', 'nggallery') ;?></label>
382
- </td>
383
- </tr>
384
- <tr>
385
- <th valign="top"><?php _e('Max. number of images','nggallery'); ?></th>
386
- <td><input type="text" name="maxImages" value="<?php echo $ngg->options['maxImages']; ?>" size="3" maxlength="3" />
387
- <span class="setting-description"><?php _e('0 will show all images','nggallery'); ?></span>
388
- </td>
389
- </tr>
390
- </table>
391
- <div class="alignright"><a href="" class="switch-expert" >[<?php _e('More settings','nggallery'); ?>]</a></div>
392
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes'); ?>"/></div>
393
- </form>
394
- <?php
395
- }
396
-
397
- function tab_thumbnails() {
398
- global $ngg;
399
- ?>
400
- <!-- Thumbnail settings -->
401
- <h2><?php _e('Thumbnail settings','nggallery'); ?></h2>
402
- <form name="thumbnailsettings" method="POST" action="<?php echo $this->filepath.'#thumbnails'; ?>" >
403
- <?php wp_nonce_field('ngg_settings') ?>
404
- <input type="hidden" name="page_options" value="thumbwidth,thumbheight,thumbfix,thumbquality" />
405
- <p><?php _e('Please note : If you change the settings, you need to recreate the thumbnails under -> Manage Gallery .', 'nggallery') ?></p>
406
- <table class="form-table ngg-options">
407
- <tr valign="top">
408
- <th align="left"><?php _e('Width x height (in pixel)','nggallery'); ?></th>
409
- <td><input type="text" size="4" maxlength="4" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?>" /> x <input type="text" size="4" maxlength="4" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?>" />
410
- <span class="setting-description"><?php _e('These values are maximum values ','nggallery'); ?></span></td>
411
- </tr>
412
- <tr valign="top">
413
- <th align="left"><?php _e('Set fix dimension','nggallery'); ?></th>
414
- <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
415
- <?php _e('Ignore the aspect ratio, no portrait thumbnails','nggallery') ?></td>
416
- </tr>
417
- <tr class="expert" valign="top">
418
- <th align="left"><?php _e('Thumbnail quality','nggallery'); ?></th>
419
- <td><input type="text" size="3" maxlength="3" name="thumbquality" value="<?php echo $ngg->options['thumbquality']; ?>" /> %</td>
420
- </tr>
421
- </table>
422
- <div class="alignright"><a href="" class="switch-expert" >[<?php _e('More settings','nggallery'); ?>]</a></div>
423
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
424
- </form>
425
- <?php
426
- }
427
-
428
- function tab_images() {
429
- global $ngg;
430
- ?>
431
- <!-- Image settings -->
432
- <h2><?php _e('Image settings','nggallery'); ?></h2>
433
- <form name="imagesettings" method="POST" action="<?php echo $this->filepath.'#images'; ?>" >
434
- <?php wp_nonce_field('ngg_settings') ?>
435
- <input type="hidden" name="page_options" value="imgResize,imgWidth,imgHeight,imgQuality,imgBackup,imgAutoResize" />
436
- <table class="form-table ngg-options">
437
- <tr valign="top">
438
- <th valign="top"><label for="fixratio"><?php _e('Resize Images','nggallery') ?></label></th>
439
- <td><input type="text" size="5" name="imgWidth" value="<?php echo $ngg->options['imgWidth']; ?>" /> x <input type="text" size="5" name="imgHeight" value="<?php echo $ngg->options['imgHeight']; ?>" />
440
- <span class="setting-description"><?php _e('Width x height (in pixel). NextCellent Gallery will keep ratio size','nggallery') ?></span></td>
441
- </tr>
442
- <tr valign="top">
443
- <th valign="top"><?php _e('Image quality','nggallery'); ?></th>
444
- <td><input type="text" size="3" maxlength="3" name="imgQuality" value="<?php echo $ngg->options['imgQuality']; ?>" /> %</td>
445
- </tr>
446
- <tr>
447
- <th valign="top"><?php _e('Backup original images','nggallery'); ?></th>
448
- <td><input type="checkbox" name="imgBackup" value="1"<?php echo ($ngg->options['imgBackup'] == 1) ? ' checked ="chechked"' : ''; ?>/>
449
- <span class="setting-description"><?php _e('Creates a backup for inserted images','nggallery'); ?></span></td>
450
- </tr>
451
- <tr>
452
- <th valign="top"><?php _e('Automatically resize','nggallery'); ?></th>
453
- <td><input type="checkbox" name="imgAutoResize" value="1"<?php echo ($ngg->options['imgAutoResize'] == 1) ? ' checked ="chechked"' : ''; ?>/>
454
- <span class="setting-description"><?php _e('Automatically resize images on upload.','nggallery') ?></span></td>
455
- </tr>
456
- </table>
457
- <h3 class="expert"><?php _e('Single picture','nggallery') ?></h3>
458
- <table class="expert form-table ngg-options">
459
- <tr>
460
- <th valign="top"><?php _e('Clear cache folder','nggallery'); ?></th>
461
- <td><input type="submit" name="clearcache" class="button-secondary" value="<?php _e('Proceed now','nggallery') ;?> &raquo;"/></td>
462
- </tr>
463
- </table>
464
- <div class="alignright"><a href="" class="switch-expert" >[<?php _e('More settings','nggallery'); ?>]</a></div>
465
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
466
- </form>
467
-
468
- <?php
469
- }
470
-
471
- function tab_gallery() {
472
- global $ngg;
473
- ?>
474
- <!-- Gallery settings -->
475
- <h2><?php _e('Gallery settings','nggallery'); ?></h2>
476
- <form name="galleryform" method="POST" action="<?php echo $this->filepath.'#gallery'; ?>" >
477
- <?php wp_nonce_field('ngg_settings') ?>
478
- <input type="hidden" name="page_options" value="galNoPages,galImages,galColumns,galShowSlide,galTextSlide,galTextGallery,galShowOrder,galImgBrowser,galSort,galSortDir,galHiddenImg,galAjaxNav" />
479
- <table class="form-table ngg-options">
480
- <tr class="expert" >
481
- <th valign="top"><?php _e('Deactivate gallery page link','nggallery') ?></th>
482
- <td><input name="galNoPages" type="checkbox" value="1" <?php checked('1', $ngg->options['galNoPages']); ?> />
483
- <?php _e('The album will not link to a gallery subpage. The gallery is shown on the same page.','nggallery') ?>
484
- </td>
485
- </tr>
486
- <tr>
487
- <th valign="top"><?php _e('Number of images per page','nggallery') ?></th>
488
- <td><input type="text" name="galImages" value="<?php echo $ngg->options['galImages']; ?>" size="3" maxlength="3" />
489
- <span class="setting-description"><?php _e('0 will disable pagination, all images on one page','nggallery') ?></span>
490
- </td>
491
- </tr>
492
- <tr>
493
- <th valign="top"><?php _e('Number of columns','nggallery'); ?></th>
494
- <td><input type="text" name="galColumns" value="<?php echo $ngg->options['galColumns']; ?>" size="3" maxlength="3" />
495
- <span class="setting-description"><?php _e('0 will display as much as possible based on the width of your theme. Setting normally only required for captions below the images','nggallery') ?></span>
496
- </td>
497
- </tr>
498
- <tr>
499
- <th valign="top"><?php _e('Integrate slideshow','nggallery'); ?></th>
500
- <td><input name="galShowSlide" type="checkbox" value="1" <?php checked('1', $ngg->options['galShowSlide']); ?> />
501
- <input type="text" name="galTextSlide" value="<?php echo $ngg->options['galTextSlide'] ?>" size="20" />
502
- <input type="text" name="galTextGallery" value="<?php echo $ngg->options['galTextGallery'] ?>" size="20" />
503
- </td>
504
- </tr>
505
- <tr class="expert" >
506
- <th valign="top"><?php _e('Show first','nggallery'); ?></th>
507
- <td><label><input name="galShowOrder" type="radio" value="gallery" <?php checked('gallery', $ngg->options['galShowOrder']); ?> /> <?php _e('Thumbnails', 'nggallery') ;?></label><br />
508
- <label><input name="galShowOrder" type="radio" value="slide" <?php checked('slide', $ngg->options['galShowOrder']); ?> /> <?php _e('Slideshow', 'nggallery') ;?></label>
509
- </td>
510
- </tr>
511
- <tr class="expert" >
512
- <th valign="top"><?php _e('Show ImageBrowser','nggallery'); ?></th>
513
- <td><input name="galImgBrowser" type="checkbox" value="1" <?php checked('1', $ngg->options['galImgBrowser']); ?> />
514
- <?php _e('The gallery will open the ImageBrowser instead the effect.', 'nggallery'); ?>
515
- </td>
516
- </tr>
517
- <tr class="expert" >
518
- <th valign="top"><?php _e('Add hidden images','nggallery'); ?></th>
519
- <td><input name="galHiddenImg" type="checkbox" value="1" <?php checked('1', $ngg->options['galHiddenImg']); ?> />
520
- <?php _e('If pagination is used, this option will still show all images in the modal window (Thickbox, Lightbox etc.). Note : This increases the page load','nggallery'); ?>
521
- </td>
522
- </tr>
523
- <tr class="expert" >
524
- <th valign="top"><?php _e('Enable AJAX pagination','nggallery'); ?></th>
525
- <td><input name="galAjaxNav" type="checkbox" value="1" <?php checked('1', $ngg->options['galAjaxNav']); ?> />
526
- <?php _e('Browse images without reload the page. Note : Works only in combination with Shutter effect','nggallery'); ?>
527
- </td>
528
- </tr>
529
- </table>
530
- <h3 class="expert" ><?php _e('Sort options','nggallery') ?></h3>
531
- <table class="expert form-table ngg-options">
532
- <tr>
533
- <th valign="top"><?php _e('Sort thumbnails','nggallery') ?></th>
534
- <td>
535
- <label><input name="galSort" type="radio" value="sortorder" <?php checked('sortorder', $ngg->options['galSort']); ?> /> <?php _e('Custom order', 'nggallery') ;?></label><br />
536
- <label><input name="galSort" type="radio" value="pid" <?php checked('pid', $ngg->options['galSort']); ?> /> <?php _e('Image ID', 'nggallery') ;?></label><br />
537
- <label><input name="galSort" type="radio" value="filename" <?php checked('filename', $ngg->options['galSort']); ?> /> <?php _e('File name', 'nggallery') ;?></label><br />
538
- <label><input name="galSort" type="radio" value="alttext" <?php checked('alttext', $ngg->options['galSort']); ?> /> <?php _e('Alt / Title text', 'nggallery') ;?></label><br />
539
- <label><input name="galSort" type="radio" value="imagedate" <?php checked('imagedate', $ngg->options['galSort']); ?> /> <?php _e('Date / Time', 'nggallery') ;?></label>
540
- </td>
541
- </tr>
542
- <tr>
543
- <th valign="top"><?php _e('Sort direction','nggallery') ?></th>
544
- <td><label><input name="galSortDir" type="radio" value="ASC" <?php checked('ASC', $ngg->options['galSortDir']); ?> /> <?php _e('Ascending', 'nggallery') ;?></label><br />
545
- <label><input name="galSortDir" type="radio" value="DESC" <?php checked('DESC', $ngg->options['galSortDir']); ?> /> <?php _e('Descending', 'nggallery') ;?></label>
546
- </td>
547
- </tr>
548
- </table>
549
- <div class="alignright"><a href="" class="switch-expert" >[<?php _e('More settings','nggallery'); ?>]</a></div>
550
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
551
- </form>
552
- <?php
553
- }
554
-
555
- function tab_effects() {
556
- global $ngg;
557
- ?>
558
- <!-- Effects settings -->
559
- <h2><?php _e('Effects','nggallery'); ?></h2>
560
- <form name="effectsform" method="POST" action="<?php echo $this->filepath.'#effects'; ?>" >
561
- <?php wp_nonce_field('ngg_settings') ?>
562
- <input type="hidden" name="page_options" value="thumbEffect,thumbCode" />
563
- <p><?php _e('Here you can select the thumbnail effect, NextCellent Gallery will integrate the required HTML code in the images. Please note that only the Shutter and Thickbox effect will automatic added to your theme.','nggallery'); ?>
564
- <?php _e('With the placeholder','nggallery'); ?><strong> %GALLERY_NAME% </strong> <?php _e('you can activate a navigation through the images (depend on the effect). Change the code line only , when you use a different thumbnail effect or you know what you do.','nggallery'); ?></p>
565
- <table class="form-table ngg-options">
566
- <tr valign="top">
567
- <th><?php _e('JavaScript Thumbnail effect','nggallery') ?></th>
568
- <td>
569
- <select size="1" id="thumbEffect" name="thumbEffect" onchange="insertcode(this.value)">
570
- <option value="none" <?php selected('none', $ngg->options['thumbEffect']); ?> ><?php _e('None', 'nggallery') ;?></option>
571
- <option value="thickbox" <?php selected('thickbox', $ngg->options['thumbEffect']); ?> ><?php _e('Thickbox', 'nggallery') ;?></option>
572
- <option value="lightbox" <?php selected('lightbox', $ngg->options['thumbEffect']); ?> ><?php _e('Lightbox', 'nggallery') ;?></option>
573
- <option value="highslide" <?php selected('highslide', $ngg->options['thumbEffect']); ?> ><?php _e('Highslide', 'nggallery') ;?></option>
574
- <option value="shutter" <?php selected('shutter', $ngg->options['thumbEffect']); ?> ><?php _e('Shutter', 'nggallery') ;?></option>
575
- <option value="custom" <?php selected('custom', $ngg->options['thumbEffect']); ?> ><?php _e('Custom', 'nggallery') ;?></option>
576
- </select>
577
- </td>
578
- </tr>
579
- <tr class="expert" valign="top">
580
- <th><?php _e('Link Code line','nggallery') ?></th>
581
- <td><textarea id="thumbCode" name="thumbCode" cols="50" rows="5"><?php echo htmlspecialchars(stripslashes($ngg->options['thumbCode'])); ?></textarea></td>
582
- </tr>
583
- </table>
584
- <div class="alignright"><a href="" class="switch-expert" >[<?php _e('More settings','nggallery'); ?>]</a></div>
585
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
586
- </form>
587
-
588
- <?php
589
- }
590
-
591
- function tab_watermark() {
592
-
593
- global $wpdb, $ngg;
594
-
595
- // take the first image as sample
596
- $imageID = $wpdb->get_var("SELECT MIN(pid) FROM $wpdb->nggpictures");
597
- $imageURL = ($imageID) ? $imageURL = '<img src="'. home_url('index.php') . '?callback=image&amp;pid=' . intval ($imageID) . '&amp;mode=watermark&amp;width=300&amp;height=250" />' : '';
598
-
599
- ?>
600
- <!-- Watermark settings -->
601
- <h2><?php _e('Watermark','nggallery'); ?></h2>
602
- <p><?php _e('Please note : You can only activate the watermark under -> Manage Gallery . This action cannot be undone.', 'nggallery') ?></p>
603
- <form name="watermarkform" method="POST" action="<?php echo $this->filepath.'#watermark'; ?>" >
604
- <?php wp_nonce_field('ngg_settings') ?>
605
- <input type="hidden" name="page_options" value="wmPos,wmXpos,wmYpos,wmType,wmPath,wmFont,wmSize,wmColor,wmText,wmOpaque" />
606
- <div id="wm-preview">
607
- <h3><?php _e('Preview','nggallery') ?></h3>
608
- <p style="text-align:center;"><?php echo $imageURL; ?></p>
609
- <h3><?php _e('Position','nggallery') ?></h3>
610
- <div>
611
- <table id="wm-position">
612
- <tr>
613
- <td valign="top">
614
- <strong><?php _e('Position','nggallery') ?></strong>
615
- <table border="1">
616
- <tr>
617
- <td><input type="radio" name="wmPos" value="topLeft" <?php checked('topLeft', $ngg->options['wmPos']); ?> /></td>
618
- <td><input type="radio" name="wmPos" value="topCenter" <?php checked('topCenter', $ngg->options['wmPos']); ?> /></td>
619
- <td><input type="radio" name="wmPos" value="topRight" <?php checked('topRight', $ngg->options['wmPos']); ?> /></td>
620
- </tr>
621
- <tr>
622
- <td><input type="radio" name="wmPos" value="midLeft" <?php checked('midLeft', $ngg->options['wmPos']); ?> /></td>
623
- <td><input type="radio" name="wmPos" value="midCenter" <?php checked('midCenter', $ngg->options['wmPos']); ?> /></td>
624
- <td><input type="radio" name="wmPos" value="midRight" <?php checked('midRight', $ngg->options['wmPos']); ?> /></td>
625
- </tr>
626
- <tr>
627
- <td><input type="radio" name="wmPos" value="botLeft" <?php checked('botLeft', $ngg->options['wmPos']); ?> /></td>
628
- <td><input type="radio" name="wmPos" value="botCenter" <?php checked('botCenter', $ngg->options['wmPos']); ?> /></td>
629
- <td><input type="radio" name="wmPos" value="botRight" <?php checked('botRight', $ngg->options['wmPos']); ?> /></td>
630
- </tr>
631
- </table>
632
- </td>
633
- <td valign="top">
634
- <strong><?php _e('Offset','nggallery') ?></strong>
635
- <table border="0">
636
- <tr>
637
- <td>x</td>
638
- <td><input type="text" name="wmXpos" value="<?php echo $ngg->options['wmXpos'] ?>" size="4" /> px</td>
639
- </tr>
640
- <tr>
641
- <td>y</td>
642
- <td><input type="text" name="wmYpos" value="<?php echo $ngg->options['wmYpos'] ?>" size="4" /> px</td>
643
- </tr>
644
- </table>
645
- </td>
646
- </tr>
647
- </table>
648
- </div>
649
- </div>
650
- <h3><label><input type="radio" name="wmType" value="image" <?php checked('image', $ngg->options['wmType']); ?> /> <?php _e('Use image as watermark','nggallery') ?></label></h3>
651
- <table class="wm-table form-table">
652
- <tr>
653
- <th><?php _e('URL to file','nggallery') ?></th>
654
- <td><input type="text" size="40" name="wmPath" value="<?php echo $ngg->options['wmPath']; ?>" /><br />
655
- <?php if(!ini_get('allow_url_fopen')) _e('The accessing of URL files is disabled at your server (allow_url_fopen)','nggallery') ?> </td>
656
- </tr>
657
- </table>
658
- <h3><label><input type="radio" name="wmType" value="text" <?php checked('text', $ngg->options['wmType']); ?> /> <?php _e('Use text as watermark','nggallery') ?></label></h3>
659
- <table class="wm-table form-table">
660
- <tr>
661
- <th><?php _e('Font','nggallery') ?></th>
662
- <td><select name="wmFont" size="1"> <?php
663
- $fontlist = ngg_get_TTFfont();
664
- foreach ( $fontlist as $fontfile ) {
665
- echo "\n".'<option value="'.$fontfile.'" '.ngg_input_selected($fontfile, $ngg->options['wmFont']).' >'.$fontfile.'</option>';
666
- }
667
- ?>
668
- </select><br /><span class="setting-description">
669
- <?php if ( !function_exists('ImageTTFBBox') )
670
- _e('This function will not work, cause you need the FreeType library','nggallery');
671
- else
672
- _e('You can upload more fonts in the folder <strong>nggallery/fonts</strong>','nggallery'); ?>
673
- </span>
674
- </td>
675
- </tr>
676
- <tr>
677
- <th><?php _e('Size','nggallery') ?></th>
678
- <td><input type="text" name="wmSize" value="<?php echo $ngg->options['wmSize']; ?>" size="4" maxlength="2" /> px</td>
679
- </tr>
680
- <tr>
681
- <th><?php _e('Color','nggallery') ?></th>
682
- <td><input class="picker" type="text" size="6" maxlength="6" id="wmColor" name="wmColor" onchange="setcolor('#previewText', this.value)" value="<?php echo $ngg->options['wmColor'] ?>" />
683
- <input type="text" size="1" readonly="readonly" id="previewText" style="background-color: #<?php echo $ngg->options['wmColor']; ?>" /> <?php _e('(hex w/o #)','nggallery') ?></td>
684
- </tr>
685
- <tr>
686
- <th valign="top"><?php _e('Text','nggallery') ?></th>
687
- <td><textarea name="wmText" cols="40" rows="4"><?php echo $ngg->options['wmText'] ?></textarea></td>
688
- </tr>
689
- <tr>
690
- <th><?php _e('Opaque','nggallery') ?></th>
691
- <td><input type="text" name="wmOpaque" value="<?php echo $ngg->options['wmOpaque'] ?>" size="3" maxlength="3" /> % </td>
692
- </tr>
693
- </table>
694
- <div class="clear"> &nbsp; </div>
695
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
696
- </form>
697
- <?php
698
- }
699
-
700
- function tab_slideshow() {
701
-
702
- global $ngg;
703
- ?>
704
- <!-- Slideshow settings -->
705
- <form name="player_options" method="POST" action="<?php echo $this->filepath.'#slideshow'; ?>" >
706
- <?php wp_nonce_field('ngg_settings'); ?>
707
- <input type="hidden" name="page_options" value="slideFx,enableIR,irURL,irWidth,irHeight,irShuffle,irLinkfromdisplay,irShownavigation,irShowicons,irWatermark,irOverstretch,irRotatetime,irTransition,irKenburns,irBackcolor,irFrontcolor,irLightcolor,irScreencolor,irAudio,irXHTMLvalid" />
708
- <h2><?php _e('Slideshow','nggallery'); ?></h2>
709
- <table class="form-table ngg-options">
710
- <tr>
711
- <th><?php _e('Default size (W x H)','nggallery') ?></th>
712
- <td><input type="text" size="3" maxlength="4" name="irWidth" value="<?php echo $ngg->options['irWidth']; ?>" /> x
713
- <input type="text" size="3" maxlength="4" name="irHeight" value="<?php echo $ngg->options['irHeight']; ?>" /></td>
714
- </tr>
715
- <tr>
716
- <th><?php _e('Duration time','nggallery') ?></th>
717
- <td><input type="text" size="3" maxlength="3" name="irRotatetime" value="<?php echo $ngg->options['irRotatetime'] ?>" /> <?php _e('sec.', 'nggallery') ;?></td>
718
- </tr>
719
- <tr>
720
- <th><?php _e('Transition / Fade effect','nggallery') ?></th>
721
- <td>
722
- <select size="1" name="slideFx">
723
- <option value="fade" <?php selected('fade', $ngg->options['slideFx']); ?> ><?php _e('fade', 'nggallery') ;?></option>
724
- <option value="blindX" <?php selected('blindX', $ngg->options['slideFx']); ?> ><?php _e('blindX', 'nggallery') ;?></option>
725
- <option value="cover" <?php selected('cover', $ngg->options['slideFx']); ?> ><?php _e('cover', 'nggallery') ;?></option>
726
- <option value="scrollUp" <?php selected('scrollUp', $ngg->options['slideFx']); ?> ><?php _e('scrollUp', 'nggallery') ;?></option>
727
- <option value="scrollDown" <?php selected('scrollDown', $ngg->options['slideFx']); ?> ><?php _e('scrollDown', 'nggallery') ;?></option>
728
- <option value="shuffle" <?php selected('shuffle', $ngg->options['slideFx']); ?> ><?php _e('shuffle', 'nggallery') ;?></option>
729
- <option value="toss" <?php selected('toss', $ngg->options['slideFx']); ?> ><?php _e('toss', 'nggallery') ;?></option>
730
- <option value="wipe" <?php selected('wipe', $ngg->options['slideFx']); ?> ><?php _e('wipe', 'nggallery') ;?></option>
731
- </select>
732
- <span class="description"><?php _e('See here for more information about the effects :', 'nggallery') ?> <a href="http://jquery.malsup.com/cycle/browser.html" target="_blank" >jQuery Cycle</a></span>
733
- </td>
734
- </tr>
735
- </table>
736
- <h3 class="expert" ><?php _e('Settings for the JW Image Rotator','nggallery') ?></h3>
737
- <p>
738
- NextCellent Gallery flash slideshows use the JW Image Rotator Version 3.17 by <a target='_blank' href='http://www.longtailvideo.com/players/jw-image-rotator/'>Long Tail Video</a>.
739
- Press the button below to search for it automatically. For earlier versions of NextCellent Gallery, you'll need to
740
- upload the file manually to the <a href='http://codex.wordpress.org/Uploading_Files' target='_blank'>WordPress Uploads directory</a>.
741
- </p>
742
- <?php if (empty($ngg->options['irURL']) && ($ngg->options['enableIR'] == '1')) { ?>
743
- <div id="message" class="error inline">
744
- <p>
745
- <?php _e('The path to JW Image Rotator is not defined, the slideshow will not work.','nggallery'); ?><br />
746
- Press the button below to search for the file.
747
- </p>
748
- </div>
749
- <?php }?>
750
- <table class="expert form-table ngg-options">
751
- <tr>
752
- <th><?php _e('Enable flash slideshow','nggallery') ?></th>
753
- <td><input name="enableIR" type="checkbox" value="1" <?php checked('1', $ngg->options['enableIR']); ?> />
754
- <span class="setting-description"><?php _e('Integrate the flash based slideshow for all flash supported devices','nggallery') ?></span></td>
755
- </tr>
756
- <tr>
757
- <th><?php _e('Path to the JW Image Rotator (URL)','nggallery') ?></th>
758
- <td>
759
- <input type="text" size="50" id="irURL" name="irURL" value="<?php echo $ngg->options['irURL']; ?>" />
760
- <input type="submit" name="irDetect" class="button-secondary" value="<?php _e('Search now','nggallery') ;?> &raquo;"/>
761
- <br /><span class="setting-description"><?php _e('Press the button below to search for the JW Image Rotator','nggallery') ?></span>
762
- </td>
763
- </tr>
764
- <tr>
765
- <th><?php _e('Shuffle mode','nggallery') ?></th>
766
- <td><input name="irShuffle" type="checkbox" value="1" <?php checked('1', $ngg->options['irShuffle']); ?> /></td>
767
- </tr>
768
- <tr class="expert">
769
- <th><?php _e('Show next image on click','nggallery') ?></th>
770
- <td><input name="irLinkfromdisplay" type="checkbox" value="1" <?php checked('1', $ngg->options['irLinkfromdisplay']); ?> /></td>
771
- </tr>
772
- <tr class="expert">
773
- <th><?php _e('Show navigation bar','nggallery') ?></th>
774
- <td><input name="irShownavigation" type="checkbox" value="1" <?php checked('1', $ngg->options['irShownavigation']); ?> /></td>
775
- </tr>
776
- <tr class="expert">
777
- <th><?php _e('Show loading icon','nggallery') ?></th>
778
- <td><input name="irShowicons" type="checkbox" value="1" <?php checked('1', $ngg->options['irShowicons']); ?> /></td>
779
- </tr>
780
- <tr class="expert">
781
- <th><?php _e('Use watermark logo','nggallery') ?></th>
782
- <td><input name="irWatermark" type="checkbox" value="1" <?php checked('1', $ngg->options['irWatermark']); ?> />
783
- <span class="setting-description"><?php _e('You can change the logo at the watermark settings','nggallery') ?></span></td>
784
- </tr>
785
- <tr class="expert">
786
- <th><?php _e('Stretch image','nggallery') ?></th>
787
- <td>
788
- <select size="1" name="irOverstretch">
789
- <option value="true" <?php selected('true', $ngg->options['irOverstretch']); ?> ><?php _e('true', 'nggallery') ;?></option>
790
- <option value="false" <?php selected('false', $ngg->options['irOverstretch']); ?> ><?php _e('false', 'nggallery') ;?></option>
791
- <option value="fit" <?php selected('fit', $ngg->options['irOverstretch']); ?> ><?php _e('fit', 'nggallery') ;?></option>
792
- <option value="none" <?php selected('none', $ngg->options['irOverstretch']); ?> ><?php _e('none', 'nggallery') ;?></option>
793
- </select>
794
- </td>
795
- </tr>
796
- <tr>
797
- <th><?php _e('Transition / Fade effect','nggallery') ?></th>
798
- <td>
799
- <select size="1" name="irTransition">
800
- <option value="fade" <?php selected('fade', $ngg->options['irTransition']); ?> ><?php _e('fade', 'nggallery') ;?></option>
801
- <option value="bgfade" <?php selected('bgfade', $ngg->options['irTransition']); ?> ><?php _e('bgfade', 'nggallery') ;?></option>
802
- <option value="slowfade" <?php selected('slowfade', $ngg->options['irTransition']); ?> ><?php _e('slowfade', 'nggallery') ;?></option>
803
- <option value="circles" <?php selected('circles', $ngg->options['irTransition']); ?> ><?php _e('circles', 'nggallery') ;?></option>
804
- <option value="bubbles" <?php selected('bubbles', $ngg->options['irTransition']); ?> ><?php _e('bubbles', 'nggallery') ;?></option>
805
- <option value="blocks" <?php selected('blocks', $ngg->options['irTransition']); ?> ><?php _e('blocks', 'nggallery') ;?></option>
806
- <option value="fluids" <?php selected('fluids', $ngg->options['irTransition']); ?> ><?php _e('fluids', 'nggallery') ;?></option>
807
- <option value="flash" <?php selected('flash', $ngg->options['irTransition']); ?> ><?php _e('flash', 'nggallery') ;?></option>
808
- <option value="lines" <?php selected('lines', $ngg->options['irTransition']); ?> ><?php _e('lines', 'nggallery') ;?></option>
809
- <option value="random" <?php selected('random', $ngg->options['irTransition']); ?> ><?php _e('random', 'nggallery') ;?></option>
810
- </select>
811
- </td>
812
- </tr>
813
- <tr class="expert">
814
- <th><?php _e('Use slow zooming effect','nggallery') ?></th>
815
- <td><input name="irKenburns" type="checkbox" value="1" <?php checked('1', $ngg->options['irKenburns']); ?> /></td>
816
- </tr>
817
- <tr>
818
- <th><?php _e('Background Color','nggallery') ?></th>
819
- <td><input class="picker" type="text" size="6" maxlength="6" id="irBackcolor" name="irBackcolor" onchange="setcolor('#previewBack', this.value)" value="<?php echo $ngg->options['irBackcolor'] ?>" />
820
- <input type="text" size="1" readonly="readonly" id="previewBack" style="background-color: #<?php echo $ngg->options['irBackcolor'] ?>" /></td>
821
- </tr>
822
- <tr>
823
- <th><?php _e('Texts / Buttons Color','nggallery') ?></th>
824
- <td><input class="picker" type="text" size="6" maxlength="6" id="irFrontcolor" name="irFrontcolor" onchange="setcolor('#previewFront', this.value)" value="<?php echo $ngg->options['irFrontcolor'] ?>" />
825
- <input type="text" size="1" readonly="readonly" id="previewFront" style="background-color: #<?php echo $ngg->options['irFrontcolor'] ?>" /></td>
826
- </tr>
827
- <tr class="expert">
828
- <th><?php _e('Rollover / Active Color','nggallery') ?></th>
829
- <td><input class="picker" type="text" size="6" maxlength="6" id="irLightcolor" name="irLightcolor" onchange="setcolor('#previewLight', this.value)" value="<?php echo $ngg->options['irLightcolor'] ?>" />
830
- <input type="text" size="1" readonly="readonly" id="previewLight" style="background-color: #<?php echo $ngg->options['irLightcolor'] ?>" /></td>
831
- </tr>
832
- <tr class="expert">
833
- <th><?php _e('Screen Color','nggallery') ?></th>
834
- <td><input class="picker" type="text" size="6" maxlength="6" id="irScreencolor" name="irScreencolor" onchange="setcolor('#previewScreen', this.value)" value="<?php echo $ngg->options['irScreencolor'] ?>" />
835
- <input type="text" size="1" readonly="readonly" id="previewScreen" style="background-color: #<?php echo $ngg->options['irScreencolor'] ?>" /></td>
836
- </tr>
837
- <tr class="expert">
838
- <th><?php _e('Background music (URL)','nggallery') ?></th>
839
- <td><input type="text" size="50" id="irAudio" name="irAudio" value="<?php echo $ngg->options['irAudio'] ?>" /></td>
840
- </tr>
841
- <tr class="expert">
842
- <th ><?php _e('Try XHTML validation (with CDATA)','nggallery') ?></th>
843
- <td><input name="irXHTMLvalid" type="checkbox" value="1" <?php checked('1', $ngg->options['irXHTMLvalid']); ?> />
844
- <span class="setting-description"><?php _e('Important : Could causes problem at some browser. Please recheck your page.','nggallery') ?></span></td>
845
- </tr>
846
- </table>
847
- <div class="alignright"><a href="" class="switch-expert" >[<?php _e('More settings','nggallery'); ?>]</a></div>
848
- <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
849
- </form>
850
- <?php
851
- }
852
- }
853
-
854
- function ngg_get_TTFfont() {
855
-
856
- $ttf_fonts = array ();
857
-
858
- // Files in wp-content/plugins/nggallery/fonts directory
859
- $plugin_root = NGGALLERY_ABSPATH . 'fonts';
860
-
861
- $plugins_dir = @ dir($plugin_root);
862
- if ($plugins_dir) {
863
- while (($file = $plugins_dir->read()) !== false) {
864
- if (preg_match('|^\.+$|', $file))
865
- continue;
866
- if (is_dir($plugin_root.'/'.$file)) {
867
- $plugins_subdir = @ dir($plugin_root.'/'.$file);
868
- if ($plugins_subdir) {
869
- while (($subfile = $plugins_subdir->read()) !== false) {
870
- if (preg_match('|^\.+$|', $subfile))
871
- continue;
872
- if (preg_match('|\.ttf$|', $subfile))
873
- $ttf_fonts[] = "$file/$subfile";
874
- }
875
- }
876
- } else {
877
- if (preg_match('|\.ttf$|', $file))
878
- $ttf_fonts[] = $file;
879
- }
880
- }
881
- }
882
-
883
- return $ttf_fonts;
884
- }
885
-
886
- function ngg_search_imagerotator() {
887
- global $wpdb;
888
-
889
- $upload = wp_upload_dir();
890
-
891
- // look first at the old place and move it to wp-content/uploads
892
- if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
893
- @rename(NGGALLERY_ABSPATH . 'imagerotator.swf', $upload['basedir'] . '/imagerotator.swf');
894
-
895
- // This should be the new place
896
- if ( file_exists( $upload['basedir'] . '/imagerotator.swf' ) )
897
- return $upload['baseurl'] . '/imagerotator.swf';
898
-
899
- // Find the path to the imagerotator via the media library
900
- if ( $path = $wpdb->get_var( "SELECT guid FROM {$wpdb->posts} WHERE guid LIKE '%imagerotator.swf%'" ) )
901
- return $path;
902
-
903
- // maybe it's located at wp-content
904
- if ( file_exists( WP_CONTENT_DIR . '/imagerotator.swf' ) )
905
- return WP_CONTENT_URL . '/imagerotator.swf';
906
-
907
- // or in the plugin folder
908
- if ( file_exists( WP_PLUGIN_DIR . '/imagerotator.swf' ) )
909
- return WP_PLUGIN_URL . '/imagerotator.swf';
910
-
911
- // this is deprecated and will be ereased during a automatic upgrade
912
- if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
913
- return NGGALLERY_URLPATH . 'imagerotator.swf';
914
-
915
- return '';
916
- }
917
-
918
- /**********************************************************/
919
- // taken from WP Core
920
-
921
- function ngg_input_selected( $selected, $current) {
922
- if ( $selected == $current)
923
- return ' selected="selected"';
924
- }
925
-
926
- function ngg_input_checked( $checked, $current) {
927
- if ( $checked == $current)
928
- return ' checked="checked"';
929
- }
930
  ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ /**
5
+ * Rebuild slugs for albums, galleries and images via AJAX request
6
+ *
7
+ * @sine 1.7.0
8
+ * @access internal
9
+ */
10
+ class ngg_rebuild_unique_slugs {
11
+
12
+ function start_rebuild() {
13
+ global $wpdb;
14
+
15
+ $total = array();
16
+ // get the total number of images
17
+ $total['images'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures") );
18
+ $total['gallery'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggallery") );
19
+ $total['album'] = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggalbum") );
20
+
21
+ $messages = array(
22
+ 'images' => __( 'Rebuild image structure : %s / %s images', 'nggallery' ),
23
+ 'gallery' => __( 'Rebuild gallery structure : %s / %s galleries', 'nggallery' ),
24
+ 'album' => __( 'Rebuild album structure : %s / %s albums', 'nggallery' ),
25
+ );
26
+
27
+ foreach ( array_keys( $messages ) as $key ) {
28
+
29
+ $message = sprintf( $messages[ $key ] ,
30
+ "<span class='ngg-count-current'>0</span>",
31
+ "<span class='ngg-count-total'>" . $total[ $key ] . "</span>"
32
+ );
33
+
34
+ echo "<div class='$key updated'><p class='ngg'>$message</p></div>";
35
+ }
36
+
37
+ $ajax_url = add_query_arg( 'action', 'ngg_rebuild_unique_slugs', admin_url( 'admin-ajax.php' ) );
38
+ ?>
39
+ <script type="text/javascript">
40
+ jQuery(document).ready(function($) {
41
+ var ajax_url = '<?php echo $ajax_url; ?>',
42
+ _action = 'images',
43
+ images = <?php echo $total['images']; ?>,
44
+ gallery = <?php echo $total['gallery']; ?>,
45
+ album = <?php echo $total['album']; ?>,
46
+ total = 0,
47
+ offset = 0,
48
+ count = 50;
49
+
50
+ var $display = $('.ngg-count-current');
51
+ $('.finished, .gallery, .album').hide();
52
+ total = images;
53
+
54
+ function call_again() {
55
+ if ( offset > total ) {
56
+ offset = 0;
57
+ // 1st run finished
58
+ if (_action == 'images') {
59
+ _action = 'gallery';
60
+ total = gallery;
61
+ $('.images, .gallery').toggle();
62
+ $display.html(offset);
63
+ call_again();
64
+ return;
65
+ }
66
+ // 2nd run finished
67
+ if (_action == 'gallery') {
68
+ _action = 'album';
69
+ total = album;
70
+ $('.gallery, .album').toggle();
71
+ $display.html(offset);
72
+ call_again();
73
+ return;
74
+ }
75
+ // 3rd run finished, exit now
76
+ if (_action == 'album') {
77
+ $('.ngg')
78
+ .html('<?php _e( 'Done.', 'nggallery' ); ?>')
79
+ .parent('div').hide();
80
+ $('.finished').show();
81
+ return;
82
+ }
83
+ }
84
+
85
+ $.post(ajax_url, {'_action': _action, 'offset': offset}, function(response) {
86
+ $display.html(offset);
87
+
88
+ offset += count;
89
+ call_again();
90
+ });
91
+ }
92
+
93
+ call_again();
94
+ });
95
+ </script>
96
+ <?php
97
+ }
98
+ }
99
+
100
+ class nggOptions {
101
+
102
+ /**
103
+ * nggOptions::__construct()
104
+ *
105
+ * @return void
106
+ */
107
+ function __construct() {
108
+
109
+ // same as $_SERVER['REQUEST_URI'], but should work under IIS 6.0
110
+ $this->filepath = admin_url() . 'admin.php?page=' . $_GET['page'];
111
+
112
+ //Look for POST updates
113
+ if ( !empty($_POST) )
114
+ $this->processor();
115
+ }
116
+
117
+ /**
118
+ * Save/Load options and add a new hook for plugins
119
+ *
120
+ * @return void
121
+ */
122
+ function processor() {
123
+
124
+ global $ngg, $nggRewrite;
125
+
126
+ $old_state = $ngg->options['usePermalinks'];
127
+ $old_slug = $ngg->options['permalinkSlug'];
128
+
129
+ if ( isset($_POST['irDetect']) ) {
130
+ check_admin_referer('ngg_settings');
131
+ $ngg->options['irURL'] = ngg_search_imagerotator();
132
+ update_option('ngg_options', $ngg->options);
133
+ }
134
+
135
+ if ( isset($_POST['updateoption']) ) {
136
+ check_admin_referer('ngg_settings');
137
+ // get the hidden option fields, taken from WP core
138
+ if ( $_POST['page_options'] )
139
+ $options = explode(',', stripslashes($_POST['page_options']));
140
+
141
+ if ($options) {
142
+ foreach ($options as $option) {
143
+ $option = trim($option);
144
+ $value = isset($_POST[$option]) ? trim($_POST[$option]) : false;
145
+ // $value = sanitize_option($option, $value); // This does stripslashes on those that need it
146
+ $ngg->options[$option] = $value;
147
+ }
148
+
149
+ // do not allow a empty string
150
+ if ( empty ( $ngg->options['permalinkSlug'] ) )
151
+ $ngg->options['permalinkSlug'] = 'nggallery';
152
+
153
+ // the path should always end with a slash
154
+ $ngg->options['gallerypath'] = trailingslashit($ngg->options['gallerypath']);
155
+ $ngg->options['imageMagickDir'] = trailingslashit($ngg->options['imageMagickDir']);
156
+
157
+ // the custom sortorder must be ascending
158
+ $ngg->options['galSortDir'] = ($ngg->options['galSort'] == 'sortorder') ? 'ASC' : $ngg->options['galSortDir'];
159
+ }
160
+ // Save options
161
+ update_option('ngg_options', $ngg->options);
162
+
163
+ // Flush Rewrite rules
164
+ if ( $old_state != $ngg->options['usePermalinks'] || $old_slug != $ngg->options['permalinkSlug'] )
165
+ $nggRewrite->flush();
166
+
167
+ nggGallery::show_message(__('Update Successfully','nggallery'));
168
+ }
169
+
170
+ if ( isset($_POST['clearcache']) ) {
171
+ check_admin_referer('ngg_settings');
172
+
173
+ $path = WINABSPATH . $ngg->options['gallerypath'] . 'cache/';
174
+
175
+ if (is_dir($path))
176
+ if ($handle = opendir($path)) {
177
+ while (false !== ($file = readdir($handle))) {
178
+ if ($file != '.' && $file != '..') {
179
+ @unlink($path . '/' . $file);
180
+ }
181
+ }
182
+ closedir($handle);
183
+ }
184
+
185
+ nggGallery::show_message(__('Cache cleared','nggallery'));
186
+ }
187
+
188
+ if ( isset($_POST['createslugs']) ) {
189
+ check_admin_referer('ngg_settings');
190
+ ngg_rebuild_unique_slugs::start_rebuild();
191
+ }
192
+
193
+ do_action( 'ngg_update_options_page' );
194
+
195
+ }
196
+
197
+ /**
198
+ * Render the page content
199
+ *
200
+ * @return void
201
+ */
202
+ function controller() {
203
+
204
+ // get list of tabs
205
+ $tabs = $this->tabs_order();
206
+
207
+ ?>
208
+ <script type="text/javascript">
209
+ jQuery(document).ready(function(){
210
+ jQuery('html,body').scrollTop(0);
211
+ jQuery('#slider').tabs({ fxFade: true, fxSpeed: 'fast' });
212
+ jQuery('#slider').css('display', 'block');
213
+ });
214
+
215
+ function insertcode(value) {
216
+ var effectcode;
217
+ switch (value) {
218
+ case "none":
219
+ effectcode = "";
220
+ jQuery('#tbImage').hide("slow");
221
+ break;
222
+ case "thickbox":
223
+ effectcode = 'class="thickbox" rel="%GALLERY_NAME%"';
224
+ jQuery('#tbImage').show("slow");
225
+ break;
226
+ case "lightbox":
227
+ effectcode = 'rel="lightbox[%GALLERY_NAME%]"';
228
+ jQuery('#tbImage').hide("slow");
229
+ break;
230
+ case "highslide":
231
+ effectcode = 'class="highslide" onclick="return hs.expand(this, { slideshowGroup: %GALLERY_NAME% })"';
232
+ jQuery('#tbImage').hide("slow");
233
+ break;
234
+ case "shutter":
235
+ effectcode = 'class="shutterset_%GALLERY_NAME%"';
236
+ jQuery('#tbImage').hide("slow");
237
+ break;
238
+ default:
239
+ break;
240
+ }
241
+ jQuery("#thumbCode").val(effectcode);
242
+ };
243
+
244
+ function setcolor(fileid, color) {
245
+ jQuery(fileid).css("background-color", '#' + color );
246
+ };
247
+ </script>
248
+ <div class="wrap ngg-wrap">
249
+ <?php screen_icon( 'nextgen-gallery' ); ?>
250
+ <h2><?php _e('Settings', 'nggallery') ?></h2>
251
+ </div>
252
+ <div id="slider" class="wrap" style="display: none;">
253
+ <ul id="tabs">
254
+ <?php
255
+ foreach($tabs as $tab_key => $tab_name) {
256
+ echo "\n\t\t<li><a class='nav-tab' href='#$tab_key'>$tab_name</a></li>";
257
+ }
258
+ ?>
259
+ </ul>
260
+ <?php
261
+ foreach($tabs as $tab_key => $tab_name) {
262
+ echo "\n\t<div id='$tab_key'>\n";
263
+ // Looks for the internal class function, otherwise enable a hook for plugins
264
+ if ( method_exists( $this, "tab_$tab_key" ))
265
+ call_user_func( array( &$this , "tab_$tab_key") );
266
+ else
267
+ do_action( 'ngg_tab_content_' . $tab_key );
268
+ echo "\n\t</div>";
269
+ }
270
+ ?>
271
+ </div>
272
+ <?php
273
+
274
+ }
275
+
276
+ /**
277
+ * Create array for tabs and add a filter for other plugins to inject more tabs
278
+ *
279
+ * @return array $tabs
280
+ */
281
+ function tabs_order() {
282
+
283
+ $tabs = array();
284
+
285
+ $tabs['generaloptions'] = __('General', 'nggallery');
286
+ $tabs['images'] = __('Images', 'nggallery');
287
+ $tabs['gallery'] = __( 'Gallery', 'nggallery' );
288
+ $tabs['effects'] = __('Effects', 'nggallery');
289
+ $tabs['watermark'] = __('Watermark', 'nggallery');
290
+ $tabs['slideshow'] = __('Slideshow', 'nggallery');
291
+
292
+ $tabs = apply_filters('ngg_settings_tabs', $tabs);
293
+
294
+ return $tabs;
295
+
296
+ }
297
+
298
+ function tab_generaloptions() {
299
+ global $ngg;
300
+
301
+ ?>
302
+ <!-- General Options -->
303
+ <h3><?php _e('General settings','nggallery'); ?></h3>
304
+ <form name="generaloptions" method="post" action="<?php echo $this->filepath; ?>">
305
+ <?php wp_nonce_field('ngg_settings') ?>
306
+ <input type="hidden" name="page_options" value="gallerypath,deleteImg,useMediaRSS,usePicLens,usePermalinks,permalinkSlug,graphicLibrary,imageMagickDir,activateTags,appendType,maxImages" />
307
+ <table class="form-table ngg-options">
308
+ <tr valign="top">
309
+ <th align="left"><?php _e('Gallery path','nggallery'); ?></th>
310
+ <td><input <?php if (is_multisite()) echo 'readonly = "readonly"'; ?> type="text" class="regular-text code" name="gallerypath" value="<?php echo $ngg->options['gallerypath']; ?>" />
311
+ <p class="description"><?php _e('This is the default path for all galleries','nggallery') ?></p></td>
312
+ </tr>
313
+ <tr valign="top">
314
+ <th align="left"><?php _e('Image files','nggallery'); ?></th>
315
+ <td><input <?php if (is_multisite()) echo 'readonly = "readonly"'; ?> type="checkbox" name="deleteImg" value="1" <?php checked('1', $ngg->options['deleteImg']); ?> />
316
+ <?php _e('Delete files when removing a gallery from the database','nggallery'); ?></td>
317
+ </tr>
318
+ <tr>
319
+ <th valign="top"><?php _e('Select graphic library','nggallery'); ?></th>
320
+ <td><label><input name="graphicLibrary" type="radio" value="gd" <?php checked('gd', $ngg->options['graphicLibrary']); ?> /> <?php _e('GD Library', 'nggallery') ;?></label><br />
321
+ <label><input name="graphicLibrary" type="radio" value="im" <?php checked('im', $ngg->options['graphicLibrary']); ?> /> <?php _e('ImageMagick (Experimental)', 'nggallery') ;?></label><br/>
322
+ <?php _e('Path to the library:', 'nggallery') ;?>&nbsp;
323
+ <input <?php if (is_multisite()) echo 'readonly = "readonly"'; ?> type="text" class="regular-text code" name="imageMagickDir" value="<?php echo $ngg->options['imageMagickDir']; ?>" />
324
+ </td>
325
+ </tr>
326
+ <tr>
327
+ <th align="left"><?php _e('Media RSS feed','nggallery'); ?></th>
328
+ <td><input type="checkbox" name="useMediaRSS" value="1" <?php checked('1', $ngg->options['useMediaRSS']); ?> />
329
+ <span><?php _e('Add a RSS feed to you blog header. Useful for CoolIris/PicLens','nggallery') ?></span></td>
330
+ </tr>
331
+ <tr>
332
+ <th align="left"><?php _e('PicLens/CoolIris','nggallery'); ?> (<a href="http://www.cooliris.com">CoolIris</a>)</th>
333
+ <td><input type="checkbox" name="usePicLens" value="1" <?php checked('1', $ngg->options['usePicLens']); ?> />
334
+ <?php _e('Include support for PicLens and CoolIris','nggallery') ?>
335
+ <p class="description"><?php _e('When activated, JavaScript is added to your site footer. Make sure that wp_footer is called in your theme.','nggallery') ?></p></td>
336
+ </td>
337
+ </tr>
338
+ </table>
339
+ <h3><?php _e('Permalinks','nggallery') ?></h3>
340
+ <table class="form-table ngg-options">
341
+ <tr valign="top">
342
+ <th align="left"><?php _e('Use permalinks','nggallery'); ?></th>
343
+ <td><input type="checkbox" name="usePermalinks" value="1" <?php checked('1', $ngg->options['usePermalinks']); ?> />
344
+ <?php _e('Adds a static link to all images','nggallery'); ?>
345
+ <p class="description"><?php _e('When activating this option, you need to update your permalink structure once','nggallery'); ?></p></td>
346
+ </tr>
347
+ <tr>
348
+ <td>
349
+ <p><?php _e('Gallery slug:','nggallery'); ?></p></td>
350
+ <td><input type="text" class="regular-text code" name="permalinkSlug" value="<?php echo $ngg->options['permalinkSlug']; ?>" /></td>
351
+ </tr>
352
+ <tr>
353
+ <th valign="top"><?php _e('Recreate URLs','nggallery'); ?></th>
354
+ <td><input type="submit" name="createslugs" class="button-secondary" value="<?php _e('Start now','nggallery') ;?> &raquo;"/>
355
+ <p class="description"><?php _e('If you\'ve changed these settings, you\'ll have to recreate the URLs.','nggallery'); ?></p></td>
356
+ </tr>
357
+ </table>
358
+ <h3><?php _e('Related images','nggallery'); ?></h3>
359
+ <table class="form-table ngg-options">
360
+ <tr>
361
+ <th valign="top"><?php _e('Add related images','nggallery'); ?></th>
362
+ <td><input name="activateTags" type="checkbox" value="1" <?php checked('1', $ngg->options['activateTags']); ?> />
363
+ <?php _e('This will add related images to every post','nggallery'); ?>
364
+ </td>
365
+ </tr>
366
+ <tr>
367
+ <th valign="top"><?php _e('Match with','nggallery'); ?></th>
368
+ <td><label><input name="appendType" type="radio" value="category" <?php checked('category', $ngg->options['appendType']); ?> /> <?php _e('Categories', 'nggallery') ;?></label><br />
369
+ <label><input name="appendType" type="radio" value="tags" <?php checked('tags', $ngg->options['appendType']); ?> /> <?php _e('Tags', 'nggallery') ;?></label>
370
+ </td>
371
+ </tr>
372
+ <tr>
373
+ <th valign="top"><?php _e('Max. number of images','nggallery'); ?></th>
374
+ <td><input name="maxImages" type="number" step="1" min="1" value="<?php echo $ngg->options['maxImages']; ?>" class="small-text" />
375
+ <p class="description"><?php _e('0 will show all images','nggallery'); ?></p>
376
+ </td>
377
+ </tr>
378
+ </table>
379
+ <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes'); ?>"/></div>
380
+ </form>
381
+ <?php
382
+ }
383
+
384
+ function tab_images() {
385
+ global $ngg;
386
+ ?>
387
+ <!-- Image settings -->
388
+ <h3><?php _e('Image settings','nggallery'); ?></h3>
389
+ <form name="imagesettings" method="POST" action="<?php echo $this->filepath.'#images'; ?>" >
390
+ <?php wp_nonce_field('ngg_settings') ?>
391
+ <input type="hidden" name="page_options" value="imgResize,imgWidth,imgHeight,imgQuality,imgBackup,imgAutoResize,thumbwidth,thumbheight,thumbfix,thumbquality" />
392
+ <table class="form-table ngg-options">
393
+ <tr valign="top">
394
+ <th valign="top"><?php _e('Resize images','nggallery') ?></th>
395
+ <td><label for="imgWidth"><?php _e('Width','nggallery') ?></label>
396
+ <input type="number" step="1" min="0" class="small-text" name="imgWidth" class="small-text" value="<?php echo $ngg->options['imgWidth']; ?>" />
397
+ <label for="imgHeight"><?php _e('Height','nggallery') ?></label>
398
+ <input type="number" step="1" min="0" type="text" size="5" name="imgHeight" class="small-text" value="<?php echo $ngg->options['imgHeight']; ?>">
399
+ <p class="description"><?php _e('Width and height (in pixels). NextCellent Gallery will keep the ratio size.','nggallery') ?></p></td>
400
+ </tr>
401
+ <tr valign="top">
402
+ <th valign="top"><?php _e('Image quality','nggallery'); ?></th>
403
+ <td><input type="number" step="1" min="0" max="100" class="small-text" name="imgQuality" value="<?php echo $ngg->options['imgQuality']; ?>" />
404
+ <label for="imgQuality">%</label></td>
405
+ </tr>
406
+ <tr>
407
+ <th valign="top"><?php _e('Backup original','nggallery'); ?></th>
408
+ <td><input type="checkbox" name="imgBackup" value="1"<?php echo ($ngg->options['imgBackup'] == 1) ? ' checked ="chechked"' : ''; ?>/>
409
+ <span><?php _e('Create a backup for the resized images','nggallery'); ?></span></td>
410
+ </tr>
411
+ <tr>
412
+ <th valign="top"><?php _e('Automatically resize','nggallery'); ?></th>
413
+ <td><input type="checkbox" name="imgAutoResize" value="1"<?php echo ($ngg->options['imgAutoResize'] == 1) ? ' checked ="chechked"' : ''; ?>/>
414
+ <span><?php _e('Automatically resize images on upload.','nggallery') ?></span></td>
415
+ </tr>
416
+ </table>
417
+ <!-- Thumbnail settings -->
418
+ <h3><?php _e('Thumbnail settings','nggallery'); ?></h3>
419
+ <p class="description"><?php _e('Please note: if you change these settings, you need to recreate the thumbnails under -> Manage Gallery .', 'nggallery') ?></p>
420
+ <table class="form-table ngg-options">
421
+ <tr valign="top">
422
+ <th align="left"><?php _e('Thumbnail size','nggallery'); ?></th>
423
+ <td>
424
+ <label for="thumbwidth"><?php _e('Width','nggallery') ?></label>
425
+ <input type="number" step="1" min="0" class="small-text" name="thumbwidth" value="<?php echo $ngg->options['thumbwidth']; ?>" />
426
+ <label for="thumbheight"><?php _e('Height','nggallery') ?></label>
427
+ <input type="number" step="1" min="0" class="small-text" name="thumbheight" value="<?php echo $ngg->options['thumbheight']; ?>" />
428
+ <p class="description"><?php _e('These values are maximum values ','nggallery'); ?></p></td>
429
+ </tr>
430
+ <tr valign="top">
431
+ <th align="left"><?php _e('Fixed size','nggallery'); ?></th>
432
+ <td><input type="checkbox" name="thumbfix" value="1" <?php checked('1', $ngg->options['thumbfix']); ?> />
433
+ <?php _e('This will ignore the aspect ratio, so no portrait thumbnails','nggallery') ?></td>
434
+ </tr>
435
+ <tr valign="top">
436
+ <th align="left"><?php _e('Thumbnail quality','nggallery'); ?></th>
437
+ <td><input type="number" step="1" min="0" max="100" class="small-text" name="thumbquality" value="<?php echo $ngg->options['thumbquality']; ?>" /><label for="thumbquality">%</label></td>
438
+ </tr>
439
+ </table>
440
+ <h3><?php _e('Single picture','nggallery') ?></h3>
441
+ <table class="form-table ngg-options">
442
+ <tr>
443
+ <th valign="top"><?php _e('Clear cache folder','nggallery'); ?></th>
444
+ <td><input type="submit" name="clearcache" class="button-secondary" value="<?php _e('Proceed now','nggallery') ;?> &raquo;"/></td>
445
+ </tr>
446
+ </table>
447
+ <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
448
+ </form>
449
+
450
+ <?php
451
+ }
452
+
453
+ function tab_gallery() {
454
+ global $ngg;
455
+ ?>
456
+ <!-- Gallery settings -->
457
+ <h3><?php _e('Gallery settings','nggallery'); ?></h3>
458
+ <form name="galleryform" method="POST" action="<?php echo $this->filepath.'#gallery'; ?>" >
459
+ <?php wp_nonce_field('ngg_settings') ?>
460
+ <input type="hidden" name="page_options" value="galNoPages,galImages,galColumns,galShowSlide,galTextSlide,galTextGallery,galShowOrder,galImgBrowser,galSort,galSortDir,galHiddenImg,galAjaxNav" />
461
+ <table class="form-table ngg-options">
462
+ <tr>
463
+ <th valign="top"><?php _e('Inline gallery','nggallery') ?></th>
464
+ <td><input name="galNoPages" type="checkbox" value="1" <?php checked('1', $ngg->options['galNoPages']); ?> />
465
+ <?php _e('Galleries will not be shown on a subpage, but on the same page.','nggallery') ?>
466
+ </td>
467
+ </tr>
468
+ <tr>
469
+ <th valign="top"><?php _e('Images per page','nggallery') ?></th>
470
+ <td><input type="number" step="1" min="0" class="small-text" name="galImages" value="<?php echo $ngg->options['galImages']; ?>" />
471
+ <label for="galImages">images</label>
472
+ <p class="description"><?php _e('0 will disable pagination, all images on one page','nggallery') ?></p>
473
+ </td>
474
+ </tr>
475
+ <tr>
476
+ <th valign="top"><?php _e('Columns','nggallery'); ?></th>
477
+ <td><input type="number" step="1" min="0" class="small-text" name="galColumns" value="<?php echo $ngg->options['galColumns']; ?>" />
478
+ <label for="galColumns">columns per page</label>
479
+ <p class="description"><?php _e('0 will display as much columns as possible. This is normally only required for captions below the images.','nggallery') ?></p>
480
+ </td>
481
+ </tr>
482
+ <tr>
483
+ <th valign="top"><?php _e('Slideshow','nggallery'); ?></th>
484
+ <td><input name="galShowSlide" type="checkbox" value="1" <?php checked('1', $ngg->options['galShowSlide']); ?> /> <?php _e('Enable slideshow','nggallery'); ?><br/><?php _e('Text to show:','nggallery'); ?>
485
+ <input type="text" class="regular-text" name="galTextSlide" value="<?php echo $ngg->options['galTextSlide'] ?>" />
486
+ <input type="text" name="galTextGallery" value="<?php echo $ngg->options['galTextGallery'] ?>" class="regular-text"/>
487
+ <p class="description"> <?php _e('This is the text the visitors will have to click to switch between display modes.','nggallery'); ?></p>
488
+ </td>
489
+ </tr>
490
+ <tr>
491
+ <th valign="top"><?php _e('Show first','nggallery'); ?></th>
492
+ <td><label><input name="galShowOrder" type="radio" value="gallery" <?php checked('gallery', $ngg->options['galShowOrder']); ?> /> <?php _e('Thumbnails', 'nggallery') ;?></label><br />
493
+ <label><input name="galShowOrder" type="radio" value="slide" <?php checked('slide', $ngg->options['galShowOrder']); ?> /> <?php _e('Slideshow', 'nggallery') ;?></label>
494
+ <p class="description">Choose what the visitors will see first.</p>
495
+ </td>
496
+ </tr>
497
+ <tr>
498
+ <th valign="top"><?php _e('ImageBrowser','nggallery'); ?></th>
499
+ <td><input name="galImgBrowser" type="checkbox" value="1" <?php checked('1', $ngg->options['galImgBrowser']); ?> />
500
+ <?php _e('Use ImageBrowser instead of another effect.', 'nggallery'); ?>
501
+ </td>
502
+ </tr>
503
+ <tr>
504
+ <th valign="top"><?php _e('Hidden images','nggallery'); ?></th>
505
+ <td><input name="galHiddenImg" type="checkbox" value="1" <?php checked('1', $ngg->options['galHiddenImg']); ?> />
506
+ <?php _e('Loads all images for the modal window, when pagination is used (like Thickbox, Lightbox etc.).','nggallery'); ?>
507
+ <p class="description"> <?php _e('Note: this increases the page load (possibly a lot)', 'nggallery'); ?>
508
+ </td>
509
+ </tr>
510
+ <tr>
511
+ <th valign="top"><?php _e('AJAX pagination','nggallery'); ?></th>
512
+ <td><input name="galAjaxNav" type="checkbox" value="1" <?php checked('1', $ngg->options['galAjaxNav']); ?> />
513
+ <?php _e('Use AJAX pagination to browse images without reloading the page.','nggallery'); ?>
514
+ <p class="description"><?php _e('Note: works only in combination with the Shutter effect.', 'nggallery'); ?> </p>
515
+ </td>
516
+ </tr>
517
+ </table>
518
+ <h3><?php _e('Sort options','nggallery') ?></h3>
519
+ <table class="form-table ngg-options">
520
+ <tr>
521
+ <th valign="top"><?php _e('Sort thumbnails','nggallery') ?></th>
522
+ <td>
523
+ <label><input name="galSort" type="radio" value="sortorder" <?php checked('sortorder', $ngg->options['galSort']); ?> /> <?php _e('Custom order', 'nggallery') ;?></label><br />
524
+ <label><input name="galSort" type="radio" value="pid" <?php checked('pid', $ngg->options['galSort']); ?> /> <?php _e('Image ID', 'nggallery') ;?></label><br />
525
+ <label><input name="galSort" type="radio" value="filename" <?php checked('filename', $ngg->options['galSort']); ?> /> <?php _e('File name', 'nggallery') ;?></label><br />
526
+ <label><input name="galSort" type="radio" value="alttext" <?php checked('alttext', $ngg->options['galSort']); ?> /> <?php _e('Alt / Title text', 'nggallery') ;?></label><br />
527
+ <label><input name="galSort" type="radio" value="imagedate" <?php checked('imagedate', $ngg->options['galSort']); ?> /> <?php _e('Date / Time', 'nggallery') ;?></label>
528
+ </td>
529
+ </tr>
530
+ <tr>
531
+ <th valign="top"><?php _e('Sort direction','nggallery') ?></th>
532
+ <td><label><input name="galSortDir" type="radio" value="ASC" <?php checked('ASC', $ngg->options['galSortDir']); ?> /> <?php _e('Ascending', 'nggallery') ;?></label><br />
533
+ <label><input name="galSortDir" type="radio" value="DESC" <?php checked('DESC', $ngg->options['galSortDir']); ?> /> <?php _e('Descending', 'nggallery') ;?></label>
534
+ </td>
535
+ </tr>
536
+ </table>
537
+ <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
538
+ </form>
539
+ <?php
540
+ }
541
+
542
+ function tab_effects() {
543
+ global $ngg;
544
+ ?>
545
+ <!-- Effects settings -->
546
+ <h3><?php _e('Effects','nggallery'); ?></h3>
547
+ <form name="effectsform" method="POST" action="<?php echo $this->filepath.'#effects'; ?>" >
548
+ <?php wp_nonce_field('ngg_settings') ?>
549
+ <input type="hidden" name="page_options" value="thumbEffect,thumbCode" />
550
+ <p><?php _e('Here you can select the thumbnail effect, NextCellent Gallery will integrate the required HTML code in the images. Please note that only the Shutter and Thickbox effect will automatic added to your theme.','nggallery'); ?>
551
+ <?php _e('With the placeholder','nggallery'); ?><strong> %GALLERY_NAME% </strong> <?php _e('you can activate a navigation through the images (depend on the effect). Change the code line only , when you use a different thumbnail effect or you know what you do.','nggallery'); ?></p>
552
+ <table class="form-table ngg-options">
553
+ <tr valign="top">
554
+ <th><?php _e('JavaScript Thumbnail effect','nggallery') ?></th>
555
+ <td>
556
+ <select size="1" id="thumbEffect" name="thumbEffect" onchange="insertcode(this.value)">
557
+ <option value="none" <?php selected('none', $ngg->options['thumbEffect']); ?> ><?php _e('None', 'nggallery') ;?></option>
558
+ <option value="thickbox" <?php selected('thickbox', $ngg->options['thumbEffect']); ?> ><?php _e('Thickbox', 'nggallery') ;?></option>
559
+ <option value="lightbox" <?php selected('lightbox', $ngg->options['thumbEffect']); ?> ><?php _e('Lightbox', 'nggallery') ;?></option>
560
+ <option value="highslide" <?php selected('highslide', $ngg->options['thumbEffect']); ?> ><?php _e('Highslide', 'nggallery') ;?></option>
561
+ <option value="shutter" <?php selected('shutter', $ngg->options['thumbEffect']); ?> ><?php _e('Shutter', 'nggallery') ;?></option>
562
+ <option value="custom" <?php selected('custom', $ngg->options['thumbEffect']); ?> ><?php _e('Custom', 'nggallery') ;?></option>
563
+ </select>
564
+ </td>
565
+ </tr>
566
+ <tr valign="top">
567
+ <th><?php _e('Link Code line','nggallery') ?></th>
568
+ <td><textarea id="thumbCode" name="thumbCode" cols="50" rows="5"><?php echo htmlspecialchars(stripslashes($ngg->options['thumbCode'])); ?></textarea></td>
569
+ </tr>
570
+ </table>
571
+ <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
572
+ </form>
573
+
574
+ <?php
575
+ }
576
+
577
+ function tab_watermark() {
578
+
579
+ global $wpdb, $ngg;
580
+
581
+ // take the first image as sample
582
+ $imageID = $wpdb->get_var("SELECT MIN(pid) FROM $wpdb->nggpictures");
583
+ $imageURL = ($imageID) ? $imageURL = '<img src="'. home_url('index.php') . '?callback=image&amp;pid=' . intval ($imageID) . '&amp;mode=watermark&amp;width=300&amp;height=250" />' : '';
584
+
585
+ ?>
586
+ <!-- Watermark settings -->
587
+ <h3><?php _e('Watermark','nggallery'); ?></h3>
588
+ <p><?php _e('Please note : you can only activate the watermark under -> Manage Galleries . This action cannot be undone.', 'nggallery') ?></p>
589
+ <form name="watermarkform" method="POST" action="<?php echo $this->filepath.'#watermark'; ?>" >
590
+ <?php wp_nonce_field('ngg_settings') ?>
591
+ <input type="hidden" name="page_options" value="wmPos,wmXpos,wmYpos,wmType,wmPath,wmFont,wmSize,wmColor,wmText,wmOpaque" />
592
+ <div id="wm-preview">
593
+ <h3><?php _e('Preview','nggallery') ?></h3>
594
+ <p style="text-align:center;"><?php echo $imageURL; ?></p>
595
+ <h3><?php _e('Position','nggallery') ?></h3>
596
+ <div>
597
+ <table id="wm-position">
598
+ <tr>
599
+ <td valign="top">
600
+ <strong><?php _e('Position','nggallery') ?></strong>
601
+ <table border="1">
602
+ <tr>
603
+ <td><input type="radio" name="wmPos" value="topLeft" <?php checked('topLeft', $ngg->options['wmPos']); ?> /></td>
604
+ <td><input type="radio" name="wmPos" value="topCenter" <?php checked('topCenter', $ngg->options['wmPos']); ?> /></td>
605
+ <td><input type="radio" name="wmPos" value="topRight" <?php checked('topRight', $ngg->options['wmPos']); ?> /></td>
606
+ </tr>
607
+ <tr>
608
+ <td><input type="radio" name="wmPos" value="midLeft" <?php checked('midLeft', $ngg->options['wmPos']); ?> /></td>
609
+ <td><input type="radio" name="wmPos" value="midCenter" <?php checked('midCenter', $ngg->options['wmPos']); ?> /></td>
610
+ <td><input type="radio" name="wmPos" value="midRight" <?php checked('midRight', $ngg->options['wmPos']); ?> /></td>
611
+ </tr>
612
+ <tr>
613
+ <td><input type="radio" name="wmPos" value="botLeft" <?php checked('botLeft', $ngg->options['wmPos']); ?> /></td>
614
+ <td><input type="radio" name="wmPos" value="botCenter" <?php checked('botCenter', $ngg->options['wmPos']); ?> /></td>
615
+ <td><input type="radio" name="wmPos" value="botRight" <?php checked('botRight', $ngg->options['wmPos']); ?> /></td>
616
+ </tr>
617
+ </table>
618
+ </td>
619
+ <td valign="top">
620
+ <strong><?php _e('Offset','nggallery') ?></strong>
621
+ <table border="0">
622
+ <tr>
623
+ <td>x:</td>
624
+ <td><input type="number" step="1" min="0" class="small-text" name="wmXpos" value="<?php echo $ngg->options['wmXpos'] ?>" /><label for="wmXpos">px</label></td>
625
+ </tr>
626
+ <tr>
627
+ <td>y:</td>
628
+ <td><input type="number" step="1" min="0" class="small-text" name="wmYpos" value="<?php echo $ngg->options['wmYpos'] ?>" /><label for="wmYpos">px</label></td>
629
+ </tr>
630
+ </table>
631
+ </td>
632
+ </tr>
633
+ </table>
634
+ </div>
635
+ </div>
636
+ <h3><label><input type="radio" name="wmType" value="image" <?php checked('image', $ngg->options['wmType']); ?> /> <?php _e('Use image as watermark','nggallery') ?></label></h3>
637
+ <table class="wm-table form-table">
638
+ <tr>
639
+ <th><?php _e('URL to file','nggallery') ?></th>
640
+ <td><input type="text" size="40" name="wmPath" value="<?php echo $ngg->options['wmPath']; ?>" /><br />
641
+ <?php if(!ini_get('allow_url_fopen')) _e('The accessing of URL files is disabled at your server (allow_url_fopen)','nggallery') ?> </td>
642
+ </tr>
643
+ </table>
644
+ <h3><label><input type="radio" name="wmType" value="text" <?php checked('text', $ngg->options['wmType']); ?> /> <?php _e('Use text as watermark','nggallery') ?></label></h3>
645
+ <table class="wm-table form-table">
646
+ <tr>
647
+ <th><?php _e('Font','nggallery') ?></th>
648
+ <td><select name="wmFont" size="1"> <?php
649
+ $fontlist = ngg_get_TTFfont();
650
+ foreach ( $fontlist as $fontfile ) {
651
+ echo "\n".'<option value="'.$fontfile.'" '.ngg_input_selected($fontfile, $ngg->options['wmFont']).' >'.$fontfile.'</option>';
652
+ }
653
+ ?>
654
+ </select><br /><span>
655
+ <?php if ( !function_exists('ImageTTFBBox') )
656
+ _e('This function will not work, cause you need the FreeType library','nggallery');
657
+ else
658
+ _e('You can upload more fonts in the folder <strong>nggallery/fonts</strong>','nggallery'); ?>
659
+ </span>
660
+ </td>
661
+ </tr>
662
+ <tr>
663
+ <th><?php _e('Size','nggallery') ?></th>
664
+ <td><input type="number" step="1" min="0" class="small-text" name="wmSize" value="<?php echo $ngg->options['wmSize']; ?>"/><label for="wmSize">px</label></td>
665
+ </tr>
666
+ <tr>
667
+ <th><?php _e('Color','nggallery') ?></th>
668
+ <td><input class="picker" type="text" size="6" maxlength="6" id="wmColor" name="wmColor" onchange="setcolor('#previewText', this.value)" value="<?php echo $ngg->options['wmColor'] ?>" />
669
+ <input type="text" size="1" readonly="readonly" id="previewText" style="background-color: #<?php echo $ngg->options['wmColor']; ?>" /> <?php _e('(hex w/o #)','nggallery') ?></td>
670
+ </tr>
671
+ <tr>
672
+ <th valign="top"><?php _e('Text','nggallery') ?></th>
673
+ <td><textarea name="wmText" cols="40" rows="4"><?php echo $ngg->options['wmText'] ?></textarea></td>
674
+ </tr>
675
+ <tr>
676
+ <th><?php _e('Opaque','nggallery') ?></th>
677
+ <td><input type="number" step="1" min="0" max="100" class="small-text" name="wmOpaque" value="<?php echo $ngg->options['wmOpaque'] ?>"/><label for="wmOpaque">%</label></td>
678
+ </tr>
679
+ </table>
680
+ <div class="clear"> &nbsp; </div>
681
+ <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
682
+ </form>
683
+ <?php
684
+ }
685
+
686
+ function tab_slideshow() {
687
+
688
+ global $ngg;
689
+ ?>
690
+ <!-- Slideshow settings -->
691
+ <form name="player_options" method="POST" action="<?php echo $this->filepath.'#slideshow'; ?>" >
692
+ <?php wp_nonce_field('ngg_settings'); ?>
693
+ <input type="hidden" name="page_options" value="slideFx,enableIR,irURL,irWidth,irHeight,irShuffle,irLinkfromdisplay,irShownavigation,irShowicons,irWatermark,irOverstretch,irRotatetime,irTransition,irKenburns,irBackcolor,irFrontcolor,irLightcolor,irScreencolor,irAudio,irXHTMLvalid" />
694
+ <h3><?php _e('Slideshow','nggallery'); ?></h3>
695
+ <table class="form-table ngg-options">
696
+ <tr>
697
+ <th><?php _e('Default size','nggallery') ?></th>
698
+ <td><label for="irWidth"><?php _e('Width','nggallery') ?></label>
699
+ <input type="number" step="1" min="0" class="small-text" name="irWidth" value="<?php echo $ngg->options['irWidth']; ?> " />
700
+ <label for="irHeight"><?php _e('Height','nggallery') ?></label>
701
+ <input type="number" step="1" min="0" class="small-text" name="irHeight" value="<?php echo $ngg->options['irHeight']; ?>" />
702
+ </td>
703
+ </tr>
704
+ <tr>
705
+ <th><?php _e('Duration','nggallery') ?></th>
706
+ <td><input type="number" type="number" step="1" min="0" class="small-text" name="irRotatetime" value="<?php echo $ngg->options['irRotatetime'] ?>" /> <label for="irRotatetime"><?php _e('sec.', 'nggallery') ;?></label></td>
707
+ </tr>
708
+ <tr>
709
+ <th><?php _e('Transition / Fade effect','nggallery') ?></th>
710
+ <td>
711
+ <select size="1" name="slideFx">
712
+ <option value="fade" <?php selected('fade', $ngg->options['slideFx']); ?> ><?php _e('fade', 'nggallery') ;?></option>
713
+ <option value="blindX" <?php selected('blindX', $ngg->options['slideFx']); ?> ><?php _e('blindX', 'nggallery') ;?></option>
714
+ <option value="cover" <?php selected('cover', $ngg->options['slideFx']); ?> ><?php _e('cover', 'nggallery') ;?></option>
715
+ <option value="scrollUp" <?php selected('scrollUp', $ngg->options['slideFx']); ?> ><?php _e('scrollUp', 'nggallery') ;?></option>
716
+ <option value="scrollDown" <?php selected('scrollDown', $ngg->options['slideFx']); ?> ><?php _e('scrollDown', 'nggallery') ;?></option>
717
+ <option value="shuffle" <?php selected('shuffle', $ngg->options['slideFx']); ?> ><?php _e('shuffle', 'nggallery') ;?></option>
718
+ <option value="toss" <?php selected('toss', $ngg->options['slideFx']); ?> ><?php _e('toss', 'nggallery') ;?></option>
719
+ <option value="wipe" <?php selected('wipe', $ngg->options['slideFx']); ?> ><?php _e('wipe', 'nggallery') ;?></option>
720
+ </select>
721
+ <p class="description"><?php _e('See here for more information about the effects :', 'nggallery') ?> <a href="http://jquery.malsup.com/cycle/browser.html" target="_blank" >jQuery Cycle</a></p>
722
+ </td>
723
+ </tr>
724
+ </table>
725
+ <h3><?php _e('Settings for the JW Image Rotator','nggallery') ?></h3>
726
+ <p><?php _e('NextCellent Gallery flash slideshows use the JW Image Rotator Version 3.17 by', 'nggallery') ;?> <a target='_blank' href='http://www.longtailvideo.com/players/jw-image-rotator/'>Long Tail Video</a>.
727
+ <?php _e('Press the button below to search for it automatically. For earlier versions of NextCellent Gallery, you\'ll need to
728
+ upload the file manually to the', 'nggallery') ;?> <a href='http://codex.wordpress.org/Uploading_Files' target='_blank'>WordPress Uploads directory</a>.</p>
729
+ <?php if (empty($ngg->options['irURL']) && ($ngg->options['enableIR'] == '1')) { ?>
730
+ <div id="message" class="error inline">
731
+ <p>
732
+ <?php _e('The path to JW Image Rotator is not defined, the slideshow will not work.','nggallery'); ?><br />
733
+ <?php _e('Press the button below to search for the file.','nggallery'); ?></p>
734
+ </div>
735
+ <?php }?>
736
+ <table class="form-table ngg-options">
737
+ <tr>
738
+ <th><?php _e('Enable flash slideshow','nggallery') ?></th>
739
+ <td><input name="enableIR" type="checkbox" value="1" <?php checked('1', $ngg->options['enableIR']); ?> />
740
+ <span><?php _e('Integrate the flash based slideshow for all flash supported devices','nggallery') ?></span></td>
741
+ </tr>
742
+ <tr>
743
+ <th><?php _e('Path to the JW Image Rotator (URL)','nggallery') ?></th>
744
+ <td>
745
+ <input type="text" class="regular-text code" id="irURL" name="irURL" value="<?php echo $ngg->options['irURL']; ?>" />
746
+ <input type="submit" name="irDetect" class="button-secondary" value="<?php _e('Search now','nggallery') ;?> &raquo;"/>
747
+ <br /><span><?php _e('Press the button below to search for the JW Image Rotator','nggallery') ?></span>
748
+ </td>
749
+ </tr>
750
+ <tr>
751
+ <th><?php _e('Shuffle mode','nggallery') ?></th>
752
+ <td><input name="irShuffle" type="checkbox" value="1" <?php checked('1', $ngg->options['irShuffle']); ?> /></td>
753
+ </tr>
754
+ <tr>
755
+ <th><?php _e('Show next image on click','nggallery') ?></th>
756
+ <td><input name="irLinkfromdisplay" type="checkbox" value="1" <?php checked('1', $ngg->options['irLinkfromdisplay']); ?> /></td>
757
+ </tr>
758
+ <tr>
759
+ <th><?php _e('Show navigation bar','nggallery') ?></th>
760
+ <td><input name="irShownavigation" type="checkbox" value="1" <?php checked('1', $ngg->options['irShownavigation']); ?> /></td>
761
+ </tr>
762
+ <tr>
763
+ <th><?php _e('Show loading icon','nggallery') ?></th>
764
+ <td><input name="irShowicons" type="checkbox" value="1" <?php checked('1', $ngg->options['irShowicons']); ?> /></td>
765
+ </tr>
766
+ <tr>
767
+ <th><?php _e('Use watermark logo','nggallery') ?></th>
768
+ <td><input name="irWatermark" type="checkbox" value="1" <?php checked('1', $ngg->options['irWatermark']); ?> />
769
+ <span><?php _e('You can change the logo at the watermark settings','nggallery') ?></span></td>
770
+ </tr>
771
+ <tr>
772
+ <th><?php _e('Stretch image','nggallery') ?></th>
773
+ <td>
774
+ <select size="1" name="irOverstretch">
775
+ <option value="true" <?php selected('true', $ngg->options['irOverstretch']); ?> ><?php _e('true', 'nggallery') ;?></option>
776
+ <option value="false" <?php selected('false', $ngg->options['irOverstretch']); ?> ><?php _e('false', 'nggallery') ;?></option>
777
+ <option value="fit" <?php selected('fit', $ngg->options['irOverstretch']); ?> ><?php _e('fit', 'nggallery') ;?></option>
778
+ <option value="none" <?php selected('none', $ngg->options['irOverstretch']); ?> ><?php _e('none', 'nggallery') ;?></option>
779
+ </select>
780
+ </td>
781
+ </tr>
782
+ <tr>
783
+ <th><?php _e('Transition / Fade effect','nggallery') ?></th>
784
+ <td>
785
+ <select size="1" name="irTransition">
786
+ <option value="fade" <?php selected('fade', $ngg->options['irTransition']); ?> ><?php _e('fade', 'nggallery') ;?></option>
787
+ <option value="bgfade" <?php selected('bgfade', $ngg->options['irTransition']); ?> ><?php _e('bgfade', 'nggallery') ;?></option>
788
+ <option value="slowfade" <?php selected('slowfade', $ngg->options['irTransition']); ?> ><?php _e('slowfade', 'nggallery') ;?></option>
789
+ <option value="circles" <?php selected('circles', $ngg->options['irTransition']); ?> ><?php _e('circles', 'nggallery') ;?></option>
790
+ <option value="bubbles" <?php selected('bubbles', $ngg->options['irTransition']); ?> ><?php _e('bubbles', 'nggallery') ;?></option>
791
+ <option value="blocks" <?php selected('blocks', $ngg->options['irTransition']); ?> ><?php _e('blocks', 'nggallery') ;?></option>
792
+ <option value="fluids" <?php selected('fluids', $ngg->options['irTransition']); ?> ><?php _e('fluids', 'nggallery') ;?></option>
793
+ <option value="flash" <?php selected('flash', $ngg->options['irTransition']); ?> ><?php _e('flash', 'nggallery') ;?></option>
794
+ <option value="lines" <?php selected('lines', $ngg->options['irTransition']); ?> ><?php _e('lines', 'nggallery') ;?></option>
795
+ <option value="random" <?php selected('random', $ngg->options['irTransition']); ?> ><?php _e('random', 'nggallery') ;?></option>
796
+ </select>
797
+ </td>
798
+ </tr>
799
+ <tr>
800
+ <th><?php _e('Use slow zooming effect','nggallery') ?></th>
801
+ <td><input name="irKenburns" type="checkbox" value="1" <?php checked('1', $ngg->options['irKenburns']); ?> /></td>
802
+ </tr>
803
+ <tr>
804
+ <th><?php _e('Background Color','nggallery') ?></th>
805
+ <td><input class="picker" type="text" size="6" maxlength="6" id="irBackcolor" name="irBackcolor" onchange="setcolor('#previewBack', this.value)" value="<?php echo $ngg->options['irBackcolor'] ?>" />
806
+ <input type="text" size="1" readonly="readonly" id="previewBack" style="background-color: #<?php echo $ngg->options['irBackcolor'] ?>" /></td>
807
+ </tr>
808
+ <tr>
809
+ <th><?php _e('Texts / Buttons Color','nggallery') ?></th>
810
+ <td><input class="picker" type="text" size="6" maxlength="6" id="irFrontcolor" name="irFrontcolor" onchange="setcolor('#previewFront', this.value)" value="<?php echo $ngg->options['irFrontcolor'] ?>" />
811
+ <input type="text" size="1" readonly="readonly" id="previewFront" style="background-color: #<?php echo $ngg->options['irFrontcolor'] ?>" /></td>
812
+ </tr>
813
+ <tr>
814
+ <th><?php _e('Rollover / Active Color','nggallery') ?></th>
815
+ <td><input class="picker" type="text" size="6" maxlength="6" id="irLightcolor" name="irLightcolor" onchange="setcolor('#previewLight', this.value)" value="<?php echo $ngg->options['irLightcolor'] ?>" />
816
+ <input type="text" size="1" readonly="readonly" id="previewLight" style="background-color: #<?php echo $ngg->options['irLightcolor'] ?>" /></td>
817
+ </tr>
818
+ <tr>
819
+ <th><?php _e('Screen Color','nggallery') ?></th>
820
+ <td><input class="picker" type="text" size="6" maxlength="6" id="irScreencolor" name="irScreencolor" onchange="setcolor('#previewScreen', this.value)" value="<?php echo $ngg->options['irScreencolor'] ?>" />
821
+ <input type="text" size="1" readonly="readonly" id="previewScreen" style="background-color: #<?php echo $ngg->options['irScreencolor'] ?>" /></td>
822
+ </tr>
823
+ <tr>
824
+ <th><?php _e('Background music (URL)','nggallery') ?></th>
825
+ <td><input type="text" class="regular-text code" id="irAudio" name="irAudio" value="<?php echo $ngg->options['irAudio'] ?>" /></td>
826
+ </tr>
827
+ <tr>
828
+ <th ><?php _e('Try XHTML validation (with CDATA)','nggallery') ?></th>
829
+ <td><input name="irXHTMLvalid" type="checkbox" value="1" <?php checked('1', $ngg->options['irXHTMLvalid']); ?> />
830
+ <span><?php _e('Important : Could causes problem with some browser. Please recheck your page.','nggallery') ?></span></td>
831
+ </tr>
832
+ </table>
833
+ <div class="submit"><input class="button-primary" type="submit" name="updateoption" value="<?php _e('Save Changes') ;?>"/></div>
834
+ </form>
835
+ <?php
836
+ }
837
+ }
838
+
839
+ function ngg_get_TTFfont() {
840
+
841
+ $ttf_fonts = array ();
842
+
843
+ // Files in wp-content/plugins/nggallery/fonts directory
844
+ $plugin_root = NGGALLERY_ABSPATH . 'fonts';
845
+
846
+ $plugins_dir = @ dir($plugin_root);
847
+ if ($plugins_dir) {
848
+ while (($file = $plugins_dir->read()) !== false) {
849
+ if (preg_match('|^\.+$|', $file))
850
+ continue;
851
+ if (is_dir($plugin_root.'/'.$file)) {
852
+ $plugins_subdir = @ dir($plugin_root.'/'.$file);
853
+ if ($plugins_subdir) {
854
+ while (($subfile = $plugins_subdir->read()) !== false) {
855
+ if (preg_match('|^\.+$|', $subfile))
856
+ continue;
857
+ if (preg_match('|\.ttf$|', $subfile))
858
+ $ttf_fonts[] = "$file/$subfile";
859
+ }
860
+ }
861
+ } else {
862
+ if (preg_match('|\.ttf$|', $file))
863
+ $ttf_fonts[] = $file;
864
+ }
865
+ }
866
+ }
867
+
868
+ return $ttf_fonts;
869
+ }
870
+
871
+ function ngg_search_imagerotator() {
872
+ global $wpdb;
873
+
874
+ $upload = wp_upload_dir();
875
+
876
+ // look first at the old place and move it to wp-content/uploads
877
+ if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
878
+ @rename(NGGALLERY_ABSPATH . 'imagerotator.swf', $upload['basedir'] . '/imagerotator.swf');
879
+
880
+ // This should be the new place
881
+ if ( file_exists( $upload['basedir'] . '/imagerotator.swf' ) )
882
+ return $upload['baseurl'] . '/imagerotator.swf';
883
+
884
+ // Find the path to the imagerotator via the media library
885
+ if ( $path = $wpdb->get_var( "SELECT guid FROM {$wpdb->posts} WHERE guid LIKE '%imagerotator.swf%'" ) )
886
+ return $path;
887
+
888
+ // maybe it's located at wp-content
889
+ if ( file_exists( WP_CONTENT_DIR . '/imagerotator.swf' ) )
890
+ return WP_CONTENT_URL . '/imagerotator.swf';
891
+
892
+ // or in the plugin folder
893
+ if ( file_exists( WP_PLUGIN_DIR . '/imagerotator.swf' ) )
894
+ return WP_PLUGIN_URL . '/imagerotator.swf';
895
+
896
+ // this is deprecated and will be ereased during a automatic upgrade
897
+ if ( file_exists( NGGALLERY_ABSPATH . 'imagerotator.swf' ) )
898
+ return NGGALLERY_URLPATH . 'imagerotator.swf';
899
+
900
+ return '';
901
+ }
902
+
903
+ /**********************************************************/
904
+ // taken from WP Core
905
+
906
+ function ngg_input_selected( $selected, $current) {
907
+ if ( $selected == $current)
908
+ return ' selected="selected"';
909
+ }
910
+
911
+ function ngg_input_checked( $checked, $current) {
912
+ if ( $checked == $current)
913
+ return ' checked="checked"';
914
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
915
  ?>
admin/setup.php CHANGED
@@ -1,58 +1,58 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- function nggallery_admin_setup() {
5
- global $wpdb, $ngg;
6
-
7
- if (isset($_POST['resetdefault'])) {
8
- check_admin_referer('ngg_uninstall');
9
-
10
- include_once ( dirname (__FILE__). '/install.php');
11
-
12
- ngg_default_options();
13
- $ngg->load_options();
14
-
15
- nggGallery::show_message(__('Reset all settings to default parameter','nggallery'));
16
- }
17
-
18
- if (isset($_POST['uninstall'])) {
19
-
20
- check_admin_referer('ngg_uninstall');
21
-
22
- include_once ( dirname (__FILE__). '/install.php');
23
-
24
- nggallery_uninstall();
25
-
26
- nggGallery::show_message(__('Uninstall sucessful ! Now delete the plugin and enjoy your life ! Good luck !','nggallery'));
27
- }
28
- ?>
29
- <div class="wrap">
30
- <h2><?php _e('Reset options', 'nggallery') ;?></h2>
31
- <form name="resetsettings" method="post">
32
- <?php wp_nonce_field('ngg_uninstall') ?>
33
- <p><?php _e('Reset all options/settings to the default installation.', 'nggallery') ;?></p>
34
- <div align="center"><input type="submit" class="button" name="resetdefault" value="<?php _e('Reset settings', 'nggallery') ;?>" onclick="javascript:check=confirm('<?php _e('Reset all options to default settings ?\n\nChoose [Cancel] to Stop, [OK] to proceed.\n','nggallery'); ?>');if(check==false) return false;" /></div>
35
- </form>
36
- </div>
37
- <?php if ( !is_multisite() || wpmu_site_admin() ) : ?>
38
- <div class="wrap">
39
- <h2><?php _e('Uninstall plugin tables', 'nggallery') ;?></h2>
40
-
41
- <form name="resetsettings" method="post">
42
- <div>
43
- <?php wp_nonce_field('ngg_uninstall') ?>
44
- <p><?php _e('You don\'t like NextCellent Gallery ?', 'nggallery') ;?></p>
45
- <p><?php _e('No problem, before you deactivate this plugin press the Uninstall Button, because deactivating NextCellent Gallery does not remove any data that may have been created. ', 'nggallery') ;?>
46
- </div>
47
- <p><font color="red"><strong><?php _e('WARNING:', 'nggallery') ;?></strong><br />
48
- <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to backup all the tables first. NextCellent gallery is stored in the tables', 'nggallery') ;?> <strong><?php echo $wpdb->nggpictures; ?></strong>, <strong><?php echo $wpdb->nggalbum; ?></strong> <?php _e('and', 'nggallery') ;?> <strong><?php echo $wpdb->nggalbum; ?></strong>.</font></p>
49
- <div align="center">
50
- <input type="submit" name="uninstall" class="button delete" value="<?php _e('Uninstall plugin', 'nggallery') ?>" onclick="javascript:check=confirm('<?php _e('You are about to Uninstall this plugin from WordPress.\nThis action is not reversible.\n\nChoose [Cancel] to Stop, [OK] to Uninstall.\n','nggallery'); ?>');if(check==false) return false;"/>
51
- </div>
52
- </form>
53
- </div>
54
- <?php endif; ?>
55
-
56
- <?php
57
- }
58
- ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ function nggallery_admin_setup() {
5
+ global $wpdb, $ngg;
6
+
7
+ if (isset($_POST['resetdefault'])) {
8
+ check_admin_referer('ngg_uninstall');
9
+
10
+ include_once ( dirname (__FILE__). '/install.php');
11
+
12
+ ngg_default_options();
13
+ $ngg->load_options();
14
+
15
+ nggGallery::show_message(__('Reset all settings to default parameter','nggallery'));
16
+ }
17
+
18
+ if (isset($_POST['uninstall'])) {
19
+
20
+ check_admin_referer('ngg_uninstall');
21
+
22
+ include_once ( dirname (__FILE__). '/install.php');
23
+
24
+ nggallery_uninstall();
25
+
26
+ nggGallery::show_message(__('Uninstall sucessful ! Now delete the plugin and enjoy your life ! Good luck !','nggallery'));
27
+ }
28
+ ?>
29
+ <div class="wrap">
30
+ <h2><?php _e('Reset options', 'nggallery') ;?></h2>
31
+ <form name="resetsettings" method="post">
32
+ <?php wp_nonce_field('ngg_uninstall') ?>
33
+ <p><?php _e('Reset all options/settings to the default installation.', 'nggallery') ;?></p>
34
+ <div align="center"><input type="submit" class="button" name="resetdefault" value="<?php _e('Reset settings', 'nggallery') ;?>" onclick="javascript:check=confirm('<?php _e('Reset all options to default settings ?\n\nChoose [Cancel] to Stop, [OK] to proceed.\n','nggallery'); ?>');if(check==false) return false;" /></div>
35
+ </form>
36
+ </div>
37
+ <?php if ( !is_multisite() || wpmu_site_admin() ) : ?>
38
+ <div class="wrap">
39
+ <h2><?php _e('Uninstall plugin tables', 'nggallery') ;?></h2>
40
+
41
+ <form name="resetsettings" method="post">
42
+ <div>
43
+ <?php wp_nonce_field('ngg_uninstall') ?>
44
+ <p><?php _e('You don\'t like NextCellent Gallery ?', 'nggallery') ;?></p>
45
+ <p><?php _e('No problem, before you deactivate this plugin press the Uninstall Button, because deactivating NextCellent Gallery does not remove any data that may have been created. ', 'nggallery') ;?>
46
+ </div>
47
+ <p><font color="red"><strong><?php _e('WARNING:', 'nggallery') ;?></strong><br />
48
+ <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to backup all the tables first. NextCellent gallery is stored in the tables', 'nggallery') ;?> <strong><?php echo $wpdb->nggpictures; ?></strong>, <strong><?php echo $wpdb->nggalbum; ?></strong> <?php _e('and', 'nggallery') ;?> <strong><?php echo $wpdb->nggalbum; ?></strong>.</font></p>
49
+ <div align="center">
50
+ <input type="submit" name="uninstall" class="button delete" value="<?php _e('Uninstall plugin', 'nggallery') ?>" onclick="javascript:check=confirm('<?php _e('You are about to Uninstall this plugin from WordPress.\nThis action is not reversible.\n\nChoose [Cancel] to Stop, [OK] to Uninstall.\n','nggallery'); ?>');if(check==false) return false;"/>
51
+ </div>
52
+ </form>
53
+ </div>
54
+ <?php endif; ?>
55
+
56
+ <?php
57
+ }
58
+ ?>
admin/showmeta.php CHANGED
@@ -1,124 +1,123 @@
1
- <?php
2
-
3
- // look up for the path
4
- require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
5
-
6
- require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
7
- require_once(NGGALLERY_ABSPATH . '/lib/image.php');
8
-
9
- if ( !is_user_logged_in() )
10
- die(__('Cheatin&#8217; uh?'));
11
-
12
- if ( !current_user_can('NextGEN Manage gallery') )
13
- die(__('Cheatin&#8217; uh?'));
14
-
15
- global $wpdb;
16
-
17
- $id = (int) $_GET['id'];
18
- // let's get the meta data'
19
- $meta = new nggMeta($id);
20
- $dbdata = $meta->get_saved_meta();
21
- $exifdata = $meta->get_EXIF();
22
- $iptcdata = $meta->get_IPTC();
23
- $xmpdata = $meta->get_XMP();
24
- $class = '';
25
-
26
- ?>
27
- <!-- META DATA -->
28
- <fieldset class="options nggallery">
29
- <h3><?php _e('Meta Data','nggallery'); ?></h3>
30
- <?php if ($dbdata) { ?>
31
- <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
32
- <thead>
33
- <tr>
34
- <th scope="col"><?php _e('Tag','nggallery'); ?></th>
35
- <th scope="col"><?php _e('Value','nggallery'); ?></th>
36
- </tr>
37
- </thead>
38
- <?php
39
- foreach ($dbdata as $key => $value){
40
- if ( is_array($value) ) continue;
41
- $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
42
- echo '<tr '.$class.'>
43
- <td style="width:230px">'. esc_html( $meta->i8n_name($key) ).'</td>
44
- <td>' . esc_html( $value ) . '</td>
45
- </tr>';
46
- }
47
- ?>
48
- </table>
49
- <?php } else echo "<strong>" . __('No meta data saved','nggallery') . "</strong>"; ?>
50
- </fieldset>
51
-
52
- <!-- EXIF DATA -->
53
- <?php if ($exifdata) { ?>
54
- <fieldset class="options nggallery">
55
- <h3><?php _e('EXIF Data','nggallery'); ?></h3>
56
- <?php if ($exifdata) { ?>
57
- <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
58
- <thead>
59
- <tr>
60
- <th scope="col"><?php _e('Tag','nggallery'); ?></th>
61
- <th scope="col"><?php _e('Value','nggallery'); ?></th>
62
- </tr>
63
- </thead>
64
- <?php
65
- foreach ($exifdata as $key => $value){
66
- $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
67
- echo '<tr '.$class.'>
68
- <td style="width:230px">' . esc_html ( $meta->i8n_name($key) ) . '</td>
69
- <td>' . esc_html( $value ) .'</td>
70
- </tr>';
71
- }
72
- ?>
73
- </table>
74
- <?php } else echo "<strong>". __('No exif data','nggallery'). "</strong>"; ?>
75
- </fieldset>
76
- <?php } ?>
77
-
78
- <!-- IPTC DATA -->
79
- <?php if ($iptcdata) { ?>
80
- <fieldset class="options nggallery">
81
- <h3><?php _e('IPTC Data','nggallery'); ?></h3>
82
- <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
83
- <thead>
84
- <tr>
85
- <th scope="col"><?php _e('Tag','nggallery'); ?></th>
86
- <th scope="col"><?php _e('Value','nggallery'); ?></th>
87
- </tr>
88
- </thead>
89
- <?php
90
- foreach ($iptcdata as $key => $value){
91
- $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
92
- echo '<tr '.$class.'>
93
- <td style="width:230px">' . esc_html( $meta->i8n_name($key) ) . '</td>
94
- <td>' . esc_html( $value ) . '</td>
95
- </tr>';
96
- }
97
- ?>
98
- </table>
99
- </fieldset>
100
- <?php } ?>
101
-
102
- <!-- XMP DATA -->
103
- <?php if ($xmpdata) { ?>
104
- <fieldset class="options nggallery">
105
- <h3><?php _e('XMP Data','nggallery'); ?></h3>
106
- <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
107
- <thead>
108
- <tr>
109
- <th scope="col"><?php _e('Tag','nggallery'); ?></th>
110
- <th scope="col"><?php _e('Value','nggallery'); ?></th>
111
- </tr>
112
- </thead>
113
- <?php
114
- foreach ($xmpdata as $key => $value){
115
- $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
116
- echo '<tr '.$class.'>
117
- <td style="width:230px">' . esc_html( $meta->i8n_name($key) ) . '</td>
118
- <td>' . esc_html( $value ) . '</td>
119
- </tr>';
120
- }
121
- ?>
122
- </table>
123
- </fieldset>
124
  <?php } ?>
1
+ <?php
2
+
3
+ // look up for the path
4
+ require_once( dirname( dirname(__FILE__) ) . '/ngg-config.php');
5
+
6
+ require_once(NGGALLERY_ABSPATH . '/lib/meta.php');
7
+ require_once(NGGALLERY_ABSPATH . '/lib/image.php');
8
+
9
+ if ( !is_user_logged_in() )
10
+ die(__('Cheatin&#8217; uh?'));
11
+
12
+ if ( !current_user_can('NextGEN Manage gallery') )
13
+ die(__('Cheatin&#8217; uh?'));
14
+
15
+ global $wpdb;
16
+
17
+ $id = (int) $_GET['id'];
18
+ // let's get the meta data'
19
+ $meta = new nggMeta($id);
20
+ $dbdata = $meta->get_saved_meta();
21
+ $exifdata = $meta->get_EXIF();
22
+ $iptcdata = $meta->get_IPTC();
23
+ $xmpdata = $meta->get_XMP();
24
+ $class = '';
25
+
26
+ ?>
27
+ <!-- META DATA -->
28
+ <fieldset class="options nggallery">
29
+ <?php if ($dbdata) { ?>
30
+ <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
31
+ <thead style="text-align: left;">
32
+ <tr>
33
+ <th scope="col"><?php _e('Name','nggallery'); ?></th>
34
+ <th scope="col"><?php _e('Value','nggallery'); ?></th>
35
+ </tr>
36
+ </thead>
37
+ <?php
38
+ foreach ($dbdata as $key => $value){
39
+ if ( is_array($value) ) continue;
40
+ $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
41
+ echo '<tr '.$class.'>
42
+ <td style="width:230px">'. esc_html( $meta->i8n_name($key) ).'</td>
43
+ <td>' . esc_html( $value ) . '</td>
44
+ </tr>';
45
+ }
46
+ ?>
47
+ </table>
48
+ <?php } else echo "<strong>" . __('No meta data saved','nggallery') . "</strong>"; ?>
49
+ </fieldset>
50
+
51
+ <!-- EXIF DATA -->
52
+ <?php if ($exifdata) { ?>
53
+ <fieldset class="options nggallery">
54
+ <h3><?php _e('EXIF Data','nggallery'); ?></h3>
55
+ <?php if ($exifdata) { ?>
56
+ <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
57
+ <thead style="text-align: left;">
58
+ <tr>
59
+ <th scope="col"><?php _e('Name','nggallery'); ?></th>
60
+ <th scope="col"><?php _e('Value','nggallery'); ?></th>
61
+ </tr>
62
+ </thead>
63
+ <?php
64
+ foreach ($exifdata as $key => $value){
65
+ $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
66
+ echo '<tr '.$class.'>
67
+ <td style="width:230px">' . esc_html ( $meta->i8n_name($key) ) . '</td>
68
+ <td>' . esc_html( $value ) .'</td>
69
+ </tr>';
70
+ }
71
+ ?>
72
+ </table>
73
+ <?php } else echo "<strong>". __('No exif data','nggallery'). "</strong>"; ?>
74
+ </fieldset>
75
+ <?php } ?>
76
+
77
+ <!-- IPTC DATA -->
78
+ <?php if ($iptcdata) { ?>
79
+ <fieldset class="options nggallery">
80
+ <h3><?php _e('IPTC Data','nggallery'); ?></h3>
81
+ <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
82
+ <thead style="text-align: left;">
83
+ <tr>
84
+ <th scope="col"><?php _e('Name','nggallery'); ?></th>
85
+ <th scope="col"><?php _e('Value','nggallery'); ?></th>
86
+ </tr>
87
+ </thead>
88
+ <?php
89
+ foreach ($iptcdata as $key => $value){
90
+ $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
91
+ echo '<tr '.$class.'>
92
+ <td style="width:230px">' . esc_html( $meta->i8n_name($key) ) . '</td>
93
+ <td>' . esc_html( $value ) . '</td>
94
+ </tr>';
95
+ }
96
+ ?>
97
+ </table>
98
+ </fieldset>
99
+ <?php } ?>
100
+
101
+ <!-- XMP DATA -->
102
+ <?php if ($xmpdata) { ?>
103
+ <fieldset class="options nggallery">
104
+ <h3><?php _e('XMP Data','nggallery'); ?></h3>
105
+ <table id="the-list-x" width="100%" cellspacing="3" cellpadding="3">
106
+ <thead>
107
+ <tr>
108
+ <th scope="col"><?php _e('Name','nggallery'); ?></th>
109
+ <th scope="col"><?php _e('Value','nggallery'); ?></th>
110
+ </tr>
111
+ </thead>
112
+ <?php
113
+ foreach ($xmpdata as $key => $value){
114
+ $class = ( $class == 'class="alternate"' ) ? '' : 'class="alternate"';
115
+ echo '<tr '.$class.'>
116
+ <td style="width:230px">' . esc_html( $meta->i8n_name($key) ) . '</td>
117
+ <td>' . esc_html( $value ) . '</td>
118
+ </tr>';
119
+ }
120
+ ?>
121
+ </table>
122
+ </fieldset>
 
123
  <?php } ?>
admin/style.php CHANGED
@@ -1,252 +1,251 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- function nggallery_admin_style() {
5
-
6
- global $ngg;
7
-
8
- if ( $theme_css_exists = file_exists (TEMPLATEPATH . "/nggallery.css") ) {
9
-
10
- $real_file = TEMPLATEPATH . "/nggallery.css";
11
- $file_show = 'nggallery.css ' . __('(From the theme folder)','nggallery');
12
-
13
- } else {
14
-
15
- if (isset($_POST['css'])) {
16
- check_admin_referer('ngg_style');
17
- $act_cssfile = $_POST['css'];
18
-
19
- if ( isset( $_POST['activate'] ) ) {
20
- // save option now
21
- $ngg->options['activateCSS'] = $_POST['activateCSS'];
22
- $ngg->options['CSSfile'] = $act_cssfile;
23
- update_option('ngg_options', $ngg->options);
24
- nggGallery::show_message(__('Update Successfully','nggallery'));
25
- }
26
- } else {
27
- // get the options
28
- if (isset($_POST['file']))
29
- $act_cssfile = $_POST['file'];
30
- else
31
- $act_cssfile = $ngg->options['CSSfile'];
32
- }
33
-
34
- // set the path
35
- $real_file = NGGALLERY_ABSPATH . "css/" . $act_cssfile;
36
- }
37
-
38
- if (isset($_POST['updatecss'])) {
39
-
40
- check_admin_referer('ngg_style');
41
-
42
- if ( !current_user_can('edit_themes') )
43
- wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
44
-
45
- $newcontent = stripslashes($_POST['newcontent']);
46
-
47
- if (is_writeable($real_file)) {
48
- $f = fopen($real_file, 'w+');
49
- fwrite($f, $newcontent);
50
-
51
- fclose($f);
52
- nggGallery::show_message(__('CSS file successfully updated','nggallery'));
53
- }
54
- }
55
-
56
- // get the content of the file
57
- //TODO: BUG : Read failed after write a file, maybe a Cache problem
58
- $error = ( !is_file($real_file) );
59
-
60
- if (!$error && filesize($real_file) > 0) {
61
- $f = fopen($real_file, 'r');
62
- $content = fread($f, filesize($real_file));
63
- $content = htmlspecialchars($content);
64
- }
65
-
66
- ?>
67
- <script type="text/javascript">
68
- jQuery(document).ready(function(){
69
- jQuery('#colorSelector').ColorPicker({
70
- color: '#0000ff',
71
- onShow: function (colpkr) {
72
- jQuery(colpkr).fadeIn(500);
73
- return false;
74
- },
75
- onHide: function (colpkr) {
76
- jQuery(colpkr).fadeOut(500);
77
- return false;
78
- },
79
- onChange: function (hsb, hex, rgb) {
80
- jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
81
- }
82
- });
83
- });
84
- </script>
85
- <div class="wrap">
86
-
87
- <div class="bordertitle">
88
- <?php screen_icon( 'nextgen-gallery' ); ?>
89
- <h2><?php _e('Style Editor','nggallery') ?></h2>
90
- <?php if (!$theme_css_exists) : ?>
91
- <form id="themeselector" name="cssfiles" method="post">
92
- <?php wp_nonce_field('ngg_style') ?>
93
- <strong><?php _e('Activate and use style sheet:','nggallery') ?></strong>
94
- <input type="checkbox" name="activateCSS" value="1" <?php checked('1', $ngg->options['activateCSS']); ?> />
95
- <select name="css" id="theme" style="margin: 0pt; padding: 0pt;" onchange="this.form.submit();">
96
- <?php
97
- $csslist = ngg_get_cssfiles();
98
- foreach ($csslist as $key =>$a_cssfile) {
99
- $css_name = $a_cssfile['Name'];
100
- if ($key == $act_cssfile) {
101
- $file_show = $key;
102
- $selected = " selected='selected'";
103
- $act_css_description = $a_cssfile['Description'];
104
- $act_css_author = $a_cssfile['Author'];
105
- $act_css_version = $a_cssfile['Version'];
106
- }
107
- else $selected = '';
108
- $css_name = esc_attr($css_name);
109
- echo "\n\t<option value=\"$key\" $selected>$css_name</option>";
110
- }
111
- ?>
112
- </select>
113
- <input class="button" type="submit" name="activate" value="<?php _e('Activate','nggallery') ?> &raquo;" class="button" />
114
- </form>
115
- <?php endif; ?>
116
- </div>
117
- <br style="clear: both;"/>
118
-
119
- <?php if (!is_multisite() || wpmu_site_admin() ) { ?>
120
- <div class="tablenav">
121
- <?php
122
- if ( is_writeable($real_file) ) {
123
- echo '<big>' . sprintf(__('Editing <strong>%s</strong>','nggallery'), $file_show) . '</big>';
124
- } else {
125
- echo '<big>' . sprintf(__('Browsing <strong>%s</strong>','nggallery'), $file_show) . '</big>';
126
- }
127
- ?>
128
- </div>
129
- <br style="clear: both;"/>
130
-
131
- <div id="templateside">
132
- <?php if (!$theme_css_exists) : ?>
133
- <ul>
134
- <li><strong><?php _e('Author','nggallery') ?> :</strong> <?php echo $act_css_author ?></li>
135
- <li><strong><?php _e('Version','nggallery') ?> :</strong> <?php echo $act_css_version ?></li>
136
- <li><strong><?php _e('Description','nggallery') ?> :<br /></strong> <?php echo $act_css_description ?></li>
137
- </ul>
138
- <p><?php _e('Tip : Copy your stylesheet (nggallery.css) to your theme folder, so it will be not lost during a upgrade','nggallery') ?></p>
139
- <?php else: ?>
140
- <p><?php _e('Your theme contain a NextCellent Gallery stylesheet (nggallery.css), this file will be used','nggallery') ?></p>
141
- <?php endif; ?>
142
- <p><?php _e('Tip No. 2: Use the color picker below to help you find the right color scheme for your gallery!','nggallery') ?></p>
143
- <div id="colorSelector">
144
- <div></div>
145
- </div>
146
- </div>
147
- <?php
148
- if (!$error) {
149
- ?>
150
- <form name="template" id="template" method="post">
151
- <?php wp_nonce_field('ngg_style') ?>
152
- <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress css"><?php echo $content ?></textarea>
153
- <input type="hidden" name="updatecss" value="updatecss" />
154
- <input type="hidden" name="file" value="<?php echo $file_show ?>" />
155
- </div>
156
- <?php if ( is_writeable($real_file) ) : ?>
157
- <p class="submit">
158
- <input class="button-primary action" type="submit" name="submit" value="<?php _e('Update File','nggallery') ?>" tabindex="2" />
159
- </p>
160
- <?php else : ?>
161
- <p><em><?php _e('If this file were writable you could edit it.','nggallery'); ?></em></p>
162
- <?php endif; ?>
163
- </form>
164
- <?php
165
- } else {
166
- echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.','nggallery') . '</p></div>';
167
- }
168
- ?>
169
- <div class="clear"> &nbsp; </div>
170
- </div> <!-- wrap-->
171
-
172
- <?php
173
- }
174
-
175
- } // END nggallery_admin_style()
176
-
177
- /**********************************************************/
178
- // ### Code from wordpress plugin import
179
- // read in the css files
180
- function ngg_get_cssfiles() {
181
- global $cssfiles;
182
-
183
- if (isset ($cssfiles)) {
184
- return $cssfiles;
185
- }
186
-
187
- $cssfiles = array ();
188
-
189
- // Files in wp-content/plugins/nggallery/css directory
190
- $plugin_root = NGGALLERY_ABSPATH . "css";
191
-
192
- $plugins_dir = @ dir($plugin_root);
193
- if ($plugins_dir) {
194
- while (($file = $plugins_dir->read()) !== false) {
195
- if (preg_match('|^\.+$|', $file))
196
- continue;
197
- if (is_dir($plugin_root.'/'.$file)) {
198
- $plugins_subdir = @ dir($plugin_root.'/'.$file);
199
- if ($plugins_subdir) {
200
- while (($subfile = $plugins_subdir->read()) !== false) {
201
- if (preg_match('|^\.+$|', $subfile))
202
- continue;
203
- if (preg_match('|\.css$|', $subfile))
204
- $plugin_files[] = "$file/$subfile";
205
- }
206
- }
207
- } else {
208
- if (preg_match('|\.css$|', $file))
209
- $plugin_files[] = $file;
210
- }
211
- }
212
- }
213
-
214
- if ( !$plugins_dir || !$plugin_files )
215
- return $cssfiles;
216
-
217
- foreach ( $plugin_files as $plugin_file ) {
218
- if ( !is_readable("$plugin_root/$plugin_file"))
219
- continue;
220
-
221
- $plugin_data = ngg_get_cssfiles_data("$plugin_root/$plugin_file");
222
-
223
- if ( empty ($plugin_data['Name']) )
224
- continue;
225
-
226
- $cssfiles[plugin_basename($plugin_file)] = $plugin_data;
227
- }
228
-
229
- uasort($cssfiles, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
230
-
231
- return $cssfiles;
232
- }
233
-
234
- // parse the Header information
235
- function ngg_get_cssfiles_data($plugin_file) {
236
- $plugin_data = implode('', file($plugin_file));
237
- preg_match("|CSS Name:(.*)|i", $plugin_data, $plugin_name);
238
- preg_match("|Description:(.*)|i", $plugin_data, $description);
239
- preg_match("|Author:(.*)|i", $plugin_data, $author_name);
240
- if (preg_match("|Version:(.*)|i", $plugin_data, $version))
241
- $version = trim($version[1]);
242
- else
243
- $version = '';
244
-
245
- $description = wptexturize(trim($description[1]));
246
-
247
- $name = trim($plugin_name[1]);
248
- $author = trim($author_name[1]);
249
-
250
- return array ('Name' => $name, 'Description' => $description, 'Author' => $author, 'Version' => $version );
251
- }
252
  ?>
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ function nggallery_admin_style() {
5
+
6
+ global $ngg;
7
+
8
+ if ( $theme_css_exists = file_exists (TEMPLATEPATH . "/nggallery.css") ) {
9
+
10
+ $real_file = TEMPLATEPATH . "/nggallery.css";
11
+ $file_show = 'nggallery.css ' . __('(From the theme folder)','nggallery');
12
+
13
+ } else {
14
+
15
+ if (isset($_POST['css'])) {
16
+ check_admin_referer('ngg_style');
17
+ $act_cssfile = $_POST['css'];
18
+
19
+ if ( isset( $_POST['activate'] ) ) {
20
+ // save option now
21
+ $ngg->options['activateCSS'] = $_POST['activateCSS'];
22
+ $ngg->options['CSSfile'] = $act_cssfile;
23
+ update_option('ngg_options', $ngg->options);
24
+ nggGallery::show_message(__('Update Successfully','nggallery'));
25
+ }
26
+ } else {
27
+ // get the options
28
+ if (isset($_POST['file']))
29
+ $act_cssfile = $_POST['file'];
30
+ else
31
+ $act_cssfile = $ngg->options['CSSfile'];
32
+ }
33
+
34
+ // set the path
35
+ $real_file = NGGALLERY_ABSPATH . "css/" . $act_cssfile;
36
+ }
37
+
38
+ if (isset($_POST['updatecss'])) {
39
+
40
+ check_admin_referer('ngg_style');
41
+
42
+ if ( !current_user_can('edit_themes') )
43
+ wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
44
+
45
+ $newcontent = stripslashes($_POST['newcontent']);
46
+
47
+ if (is_writeable($real_file)) {
48
+ $f = fopen($real_file, 'w+');
49
+ fwrite($f, $newcontent);
50
+
51
+ fclose($f);
52
+ nggGallery::show_message(__('CSS file successfully updated','nggallery'));
53
+ }
54
+ }
55
+
56
+ // get the content of the file
57
+ //TODO: BUG : Read failed after write a file, maybe a Cache problem
58
+ $error = ( !is_file($real_file) );
59
+
60
+ if (!$error && filesize($real_file) > 0) {
61
+ $f = fopen($real_file, 'r');
62
+ $content = fread($f, filesize($real_file));
63
+ $content = htmlspecialchars($content);
64
+ }
65
+
66
+ ?>
67
+ <script type="text/javascript">
68
+ jQuery(document).ready(function(){
69
+ jQuery('#colorSelector').ColorPicker({
70
+ color: '#0000ff',
71
+ onShow: function (colpkr) {
72
+ jQuery(colpkr).fadeIn(500);
73
+ return false;
74
+ },
75
+ onHide: function (colpkr) {
76
+ jQuery(colpkr).fadeOut(500);
77
+ return false;
78
+ },
79
+ onChange: function (hsb, hex, rgb) {
80
+ jQuery('#colorSelector div').css('backgroundColor', '#' + hex);
81
+ }
82
+ });
83
+ });
84
+ </script>
85
+ <div class="wrap">
86
+ <div class="bordertitle">
87
+ <?php screen_icon( 'nextgen-gallery' ); ?>
88
+ <h2><?php _e('Style Editor','nggallery') ?></h2>
89
+ <?php if (!$theme_css_exists) : ?>
90
+ <form id="themeselector" name="cssfiles" method="post">
91
+ <?php wp_nonce_field('ngg_style') ?>
92
+ <strong><?php _e('Activate and use style sheet:','nggallery') ?></strong>
93
+ <input type="checkbox" name="activateCSS" value="1" <?php checked('1', $ngg->options['activateCSS']); ?> />
94
+ <select name="css" id="theme" style="margin: 0pt; padding: 0pt;" onchange="this.form.submit();">
95
+ <?php
96
+ $csslist = ngg_get_cssfiles();
97
+ foreach ($csslist as $key =>$a_cssfile) {
98
+ $css_name = $a_cssfile['Name'];
99
+ if ($key == $act_cssfile) {
100
+ $file_show = $key;
101
+ $selected = " selected='selected'";
102
+ $act_css_description = $a_cssfile['Description'];
103
+ $act_css_author = $a_cssfile['Author'];
104
+ $act_css_version = $a_cssfile['Version'];
105
+ }
106
+ else $selected = '';
107
+ $css_name = esc_attr($css_name);
108
+ echo "\n\t<option value=\"$key\" $selected>$css_name</option>";
109
+ }
110
+ ?>
111
+ </select>
112
+ <input class="button" type="submit" name="activate" value="<?php _e('Activate','nggallery') ?> &raquo;" class="button" />
113
+ </form>
114
+ <?php endif; ?>
115
+ </div>
116
+ <br style="clear: both;"/>
117
+
118
+ <?php if (!is_multisite() || wpmu_site_admin() ) { ?>
119
+ <div class="tablenav">
120
+ <?php
121
+ if ( is_writeable($real_file) ) {
122
+ echo '<big>' . sprintf(__('Editing <strong>%s</strong>','nggallery'), $file_show) . '</big>';
123
+ } else {
124
+ echo '<big>' . sprintf(__('Browsing <strong>%s</strong>','nggallery'), $file_show) . '</big>';
125
+ }
126
+ ?>
127
+ </div>
128
+ <br style="clear: both;"/>
129
+
130
+ <div id="templateside">
131
+ <?php if (!$theme_css_exists) : ?>
132
+ <ul>
133
+ <li><strong><?php _e('Author','nggallery') ?> :</strong> <?php echo $act_css_author ?></li>
134
+ <li><strong><?php _e('Version','nggallery') ?> :</strong> <?php echo $act_css_version ?></li>
135
+ <li><strong><?php _e('Description','nggallery') ?> :<br /></strong> <?php echo $act_css_description ?></li>
136
+ </ul>
137
+ <p><?php _e('Tip: Copy your stylesheet (nggallery.css) to your theme folder, so it will be not lost during a upgrade','nggallery') ?></p>
138
+ <?php else: ?>
139
+ <p><?php _e('Your theme contain a NextCellent Gallery stylesheet (nggallery.css), this file will be used','nggallery') ?></p>
140
+ <?php endif; ?>
141
+ <p><?php _e('Tip No. 2: Use the color picker below to help you find the right color scheme for your gallery!','nggallery') ?></p>
142
+ <div id="colorSelector">
143
+ <div></div>
144
+ </div>
145
+ </div>
146
+ <?php
147
+ if (!$error) {
148
+ ?>
149
+ <form name="template" id="template" method="post">
150
+ <?php wp_nonce_field('ngg_style') ?>
151
+ <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1" class="codepress css"><?php echo $content ?></textarea>
152
+ <input type="hidden" name="updatecss" value="updatecss" />
153
+ <input type="hidden" name="file" value="<?php echo $file_show ?>" />
154
+ </div>
155
+ <?php if ( is_writeable($real_file) ) : ?>
156
+ <p class="submit">
157
+ <input class="button-primary action" type="submit" name="submit" value="<?php _e('Update File','nggallery') ?>" tabindex="2" />
158
+ </p>
159
+ <?php else : ?>
160
+ <p><em><?php _e('If this file were writable you could edit it.','nggallery'); ?></em></p>
161
+ <?php endif; ?>
162
+ </form>
163
+ <?php
164
+ } else {
165
+ echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again.','nggallery') . '</p></div>';
166
+ }
167
+ ?>
168
+ <div class="clear"> &nbsp; </div>
169
+ </div> <!-- wrap-->
170
+
171
+ <?php
172
+ }
173
+
174
+ } // END nggallery_admin_style()
175
+
176
+ /**********************************************************/
177
+ // ### Code from wordpress plugin import
178
+ // read in the css files
179
+ function ngg_get_cssfiles() {
180
+ global $cssfiles;
181
+
182
+ if (isset ($cssfiles)) {
183
+ return $cssfiles;
184
+ }
185
+
186
+ $cssfiles = array ();
187
+
188
+ // Files in wp-content/plugins/nggallery/css directory
189
+ $plugin_root = NGGALLERY_ABSPATH . "css";
190
+
191
+ $plugins_dir = @ dir($plugin_root);
192
+ if ($plugins_dir) {
193
+ while (($file = $plugins_dir->read()) !== false) {
194
+ if (preg_match('|^\.+$|', $file))
195
+ continue;
196
+ if (is_dir($plugin_root.'/'.$file)) {
197
+ $plugins_subdir = @ dir($plugin_root.'/'.$file);
198
+ if ($plugins_subdir) {
199
+ while (($subfile = $plugins_subdir->read()) !== false) {
200
+ if (preg_match('|^\.+$|', $subfile))
201
+ continue;
202
+ if (preg_match('|\.css$|', $subfile))
203
+ $plugin_files[] = "$file/$subfile";
204
+ }
205
+ }
206
+ } else {
207
+ if (preg_match('|\.css$|', $file))
208
+ $plugin_files[] = $file;
209
+ }
210
+ }
211
+ }
212
+
213
+ if ( !$plugins_dir || !$plugin_files )
214
+ return $cssfiles;
215
+
216
+ foreach ( $plugin_files as $plugin_file ) {
217
+ if ( !is_readable("$plugin_root/$plugin_file"))
218
+ continue;
219
+
220
+ $plugin_data = ngg_get_cssfiles_data("$plugin_root/$plugin_file");
221
+
222
+ if ( empty ($plugin_data['Name']) )
223
+ continue;
224
+
225
+ $cssfiles[plugin_basename($plugin_file)] = $plugin_data;
226
+ }
227
+
228
+ uasort($cssfiles, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
229
+
230
+ return $cssfiles;
231
+ }
232
+
233
+ // parse the Header information
234
+ function ngg_get_cssfiles_data($plugin_file) {
235
+ $plugin_data = implode('', file($plugin_file));
236
+ preg_match("|CSS Name:(.*)|i", $plugin_data, $plugin_name);
237
+ preg_match("|Description:(.*)|i", $plugin_data, $description);
238
+ preg_match("|Author:(.*)|i", $plugin_data, $author_name);
239
+ if (preg_match("|Version:(.*)|i", $plugin_data, $version))
240
+ $version = trim($version[1]);
241
+ else
242
+ $version = '';
243
+
244
+ $description = wptexturize(trim($description[1]));
245
+
246
+ $name = trim($plugin_name[1]);
247
+ $author = trim($author_name[1]);
248
+
249
+ return array ('Name' => $name, 'Description' => $description, 'Author' => $author, 'Version' => $version );
250
+ }
 
251
  ?>
admin/tags.php CHANGED
@@ -1,292 +1,290 @@
1
- <?php
2
- /**
3
- * Tag management page. Inspired from the Simple Tags plugin by Amaury Balmer.
4
- * http://code.google.com/p/simple-tags/
5
- */
6
-
7
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
8
-
9
- $action_status = array('message' => '', 'status' => 'ok');
10
-
11
- if ( isset($_POST['tag_action']) ) {
12
-
13
- check_admin_referer('nggallery_admin_tags');
14
-
15
- if ( $_POST['tag_action'] == 'renametag' ) {
16
- $oldtag = (isset($_POST['renametag_old'])) ? $_POST['renametag_old'] : '';
17
- $newtag = (isset($_POST['renametag_new'])) ? $_POST['renametag_new'] : '';
18
- $action_status = nggTags::rename_tags( $oldtag, $newtag );
19
- } elseif ( $_POST['tag_action'] == 'deletetag' ) {
20
- $todelete = (isset($_POST['deletetag_name'])) ? $_POST['deletetag_name'] : '';
21
- $action_status = nggTags::delete_tags( $todelete );
22
- } elseif ( $_POST['tag_action'] == 'editslug' ) {
23
- $matchtag = (isset($_POST['tagname_match'])) ? $_POST['tagname_match'] : '';
24
- $newslug = (isset($_POST['tagslug_new'])) ? $_POST['tagslug_new'] : '';
25
- $action_status = nggTags::edit_tag_slug( $matchtag, $newslug );
26
- }
27
- }
28
-
29
- // Som useful variables
30
- $admin_base_url = admin_url() . 'admin.php?page=nggallery-tags';
31
- $nb_tags = 50; // Number of tags to show on a single page
32
-
33
- // Manage URL
34
-
35
- $sort_order = ( isset($_GET['tag_sortorder']) ) ? esc_attr( stripslashes($_GET['tag_sortorder']) ) : 'desc';
36
- $search_url = ( isset($_GET['search']) ) ? '&amp;search=' . esc_attr ( stripslashes($_GET['search']) ) : '';
37
- $action_url = $admin_base_url . '&amp;tag_sortorder=' . $sort_order. $search_url;
38
-
39
- // Tags Filters
40
- $order_array = array(
41
- 'desc' => __('Most popular', 'nggallery'),
42
- 'asc' => __('Least used', 'nggallery'),
43
- 'natural' => __('Alphabetical', 'nggallery'));
44
-
45
- // Build Tags Param
46
- $param = 'hide_empty=false';
47
- switch ($sort_order) {
48
- case 'natural' :
49
- $param .= '&number='.$nb_tags.'&orderby=name&order=asc';
50
- break;
51
- case 'asc' :
52
- $param .= '&number='.$nb_tags.'&orderby=count&order=asc';
53
- break;
54
- default :
55
- $param .= '&number='.$nb_tags.'&orderby=count&order=desc';
56
- break;
57
- }
58
-
59
-
60
- // Search
61
- if ( !empty($_GET['search']) ) {
62
- $search = stripslashes($_GET['search']);
63
- $param .= '&name__like=' . $search;
64
- }
65
-
66
- // Offset
67
- if ( !empty($_GET['offset']) ) {
68
- $param .= '&offset=' . intval( $_GET['offset'] );
69
- }
70
-
71
- // Navigation urls
72
- if ( empty($_GET['offset']) ) {
73
- $offset = 0;
74
- } else {
75
- $offset = intval( $_GET['offset'] );
76
- }
77
-
78
- $tag_count = (int)wp_count_terms('ngg_tag', 'ignore_empty=true');
79
-
80
- if ($offset + $nb_tags < $tag_count) {
81
- $next_offset = '' . min($offset + $nb_tags, $tag_count - $nb_tags);
82
- } else {
83
- $next_offset = '';
84
- }
85
-
86
- if ($nb_tags < $tag_count && $offset>0) {
87
- $prev_offset = '' . max($offset - $nb_tags, 0);
88
- } else {
89
- $prev_offset = '';
90
- }
91
-
92
- ?>
93
- <style>
94
- .disabled, .disabled:hover { border-color: #E5E5E5; color: #999999; cursor: default; }
95
- </style>
96
-
97
- <div class="wrap ngg_wrap">
98
- <?php include('templates/social_media_buttons.php'); ?>
99
- <?php screen_icon( 'nextgen-gallery' ); ?>
100
- <h2><?php _e('Manage image tags', 'nggallery'); ?></h2>
101
-
102
- <?php if ($action_status['message']!='') : ?>
103
- <div id="message" class="<?php echo ($action_status['status']=='ok' ? 'updated' : $action_status['status']); ?> fade">
104
- <p><strong><?php echo $action_status['message']; ?></strong></p>
105
- </div>
106
- <?php endif; ?>
107
-
108
- <table>
109
- <tr>
110
- <td class="list_tags">
111
- <fieldset class="options" id="taglist">
112
- <h3><?php _e('Existing Tags', 'nggallery'); ?></h3>
113
-
114
- <form method="get">
115
- <p>
116
- <label for="search"><?php _e('Search tags', 'nggallery'); ?></label><br />
117
- <input type="hidden" name="page" value="<?php echo esc_attr( stripslashes($_GET['page']) ); ?>" />
118
- <input type="hidden" name="tag_sortorder" value="<?php echo $sort_order; ?>" />
119
- <input type="text" name="search" id="search" size="10" value="<?php if (isset($_GET['search'])) echo esc_attr( stripslashes($_GET['search']) ); ?>" />
120
- <input class="button" type="submit" value="<?php _e('Go', 'nggallery'); ?>" />
121
- </p>
122
- </form>
123
-
124
- <div class="sort_order">
125
- <h3><?php _e('Sort Order:', 'nggallery'); ?></h3>
126
- <?php
127
- $output = array();
128
- foreach( $order_array as $sort => $title ) {
129
- $output[] = ($sort == $sort_order) ? '<span style="color: red;">'.$title.'</span>' : '<a href="'. $admin_base_url . '&amp;tag_sortorder=' . $sort . $search_url .'">'.$title.'</a>';
130
- }
131
- echo implode('<br />', $output);
132
- $output = array();
133
- unset($output);
134
- ?>
135
- </div>
136
-
137
- <div id="ajax_area_tagslist">
138
- <ul>
139
- <?php
140
- $tags = (array) nggTags::find_tags($param, true);
141
- foreach( $tags as $tag ) {
142
- //TODO:Tag link should be call a list of images in manage gallery
143
- //echo '<li><span>' . $tag->name . '</span>&nbsp;<a href="'.(ngg_get_tag_link( $tag->term_id )).'" title="'.sprintf(__('View all images tagged with %s', 'nggallery'), $tag->name).'">('.$tag->count.')</a></li>'."\n";
144
- echo '<li><span>' . esc_html( $tag->name ). '</span>&nbsp;'.'('. esc_html( $tag->count ).')</li>'."\n";
145
-
146
- }
147
- unset($tags);
148
- ?>
149
- </ul>
150
-
151
- <?php if ( $prev_offset!='' || $next_offset!='' ) : ?>
152
- <div class="navigation">
153
-
154
- <?php if ($prev_offset!='') { ?>
155
- <form method="get" style="display: inline;">
156
- <span>
157
- <input type="hidden" name="page" value="<?php echo esc_attr( stripslashes($_GET['page']) ); ?>" />
158
- <input type="hidden" name="tag_sortorder" value="<?php echo $sort_order; ?>" />
159
- <input type="hidden" name="offset" value="<?php echo $prev_offset; ?>" />
160
- <input class="button" type="submit" value="&laquo; <?php _e('Previous tags', 'nggallery'); ?>" />
161
- </span>
162
- </form>
163
- <?php } else { ?>
164
- <span><span class="button disabled">&laquo; <?php _e('Previous tags', 'nggallery'); ?></span></span>
165
- <?php } ?>
166
-
167
- <?php if ($next_offset!='') { ?>
168
- <form method="get" style="display: inline;">
169
- <span>
170
- <input type="hidden" name="page" value="<?php echo esc_attr( stripslashes($_GET['page']) ); ?>" />
171
- <input type="hidden" name="tag_sortorder" value="<?php echo $sort_order; ?>" />
172
- <input type="hidden" name="offset" value="<?php echo $next_offset; ?>" />
173
- <input class="button" type="submit" value="<?php _e('Next tags', 'nggallery'); ?> &raquo;" />
174
- </span>
175
- </form>
176
- <?php } else { ?>
177
- <span><span class="button disabled"><?php _e('Previous tags', 'nggallery'); ?> &raquo;</span></span>
178
- <?php } ?>
179
- </div>
180
- <?php endif; ?>
181
- </div>
182
- </fieldset>
183
- </td>
184
- <td class="forms_manage">
185
- <h3><?php _e('Rename Tag', 'nggallery'); ?></h3>
186
- <form action="<?php echo $action_url; ?>" method="post">
187
- <input type="hidden" name="tag_action" value="renametag" />
188
- <?php wp_nonce_field('nggallery_admin_tags'); ?>
189
-
190
- <table class="form-table">
191
- <tr valign="top">
192
- <td colspan="2">
193
- <p><?php _e('Enter the tag to rename and its new value. You can use this feature to merge tags too. Click "Rename" and all posts which use this tag will be updated.', 'nggallery'); ?></p>
194
- <p><?php _e('You can specify multiple tags to rename by separating them with commas.', 'nggallery'); ?></p>
195
- </td>
196
- </tr>
197
- <tr valign="top">
198
- <th scope="row"><label for="renametag_old"><?php _e('Tag(s) to rename:', 'nggallery'); ?></label></th>
199
- <td><input type="text" id="renametag_old" name="renametag_old" value="" size="40" /></td>
200
- </tr>
201
- <tr valign="top">
202
- <th scope="row"><label for="renametag_new"><?php _e('New tag name(s):', 'nggallery'); ?></label></th>
203
- <td>
204
- <input type="text" id="renametag_new" name="renametag_new" value="" size="40" />
205
- <input class="button" type="submit" name="rename" value="<?php _e('Rename', 'nggallery'); ?>" />
206
- </td>
207
- </tr>
208
- </table>
209
- </form>
210
-
211
- <h3><?php _e('Delete Tag', 'nggallery'); ?></h3>
212
- <form action="<?php echo $action_url; ?>" method="post">
213
- <input type="hidden" name="tag_action" value="deletetag" />
214
- <?php wp_nonce_field('nggallery_admin_tags'); ?>
215
-
216
- <table class="form-table">
217
- <tr valign="top">
218
- <td colspan="2">
219
- <p><?php _e('Enter the name of the tag to delete. This tag will be removed from all posts.', 'nggallery'); ?></p>
220
- <p><?php _e('You can specify multiple tags to delete by separating them with commas', 'nggallery'); ?>.</p>
221
- </td>
222
- </tr>
223
- <tr valign="top">
224
- <th scope="row"><label for="deletetag_name"><?php _e('Tag(s) to delete:', 'nggallery'); ?></label></th>
225
- <td>
226
- <input type="text" id="deletetag_name" name="deletetag_name" value="" size="40" />
227
- <input class="button" type="submit" name="delete" value="<?php _e('Delete', 'nggallery'); ?>" />
228
- </td>
229
- </tr>
230
- </table>
231
- </form>
232
-
233
- <h3><?php _e('Edit Tag Slug', 'nggallery'); ?></h3>
234
- <form action="<?php echo $action_url; ?>" method="post">
235
- <input type="hidden" name="tag_action" value="editslug" />
236
- <?php wp_nonce_field('nggallery_admin_tags'); ?>
237
-
238
- <table class="form-table">
239
- <tr valign="top">
240
- <td colspan="2">
241
- <p><?php _e('Enter the tag name to edit and its new slug. <a href="http://codex.wordpress.org/Glossary#Slug">Slug definition</a>', 'nggallery'); ?></p>
242
- <p><?php _e('You can specify multiple tags to rename by separating them with commas.', 'nggallery'); ?></p>
243
- </td>
244
- </tr>
245
- <tr valign="top">
246
- <th scope="row"><label for="tagname_match"><?php _e('Tag(s) to match:', 'nggallery'); ?></label></th>
247
- <td><input type="text" id="tagname_match" name="tagname_match" value="" size="40" /></td>
248
- </tr>
249
- <tr valign="top">
250
- <th scope="row"><label for="tagslug_new"><?php _e('Slug(s) to set:', 'nggallery'); ?></label></th>
251
- <td>
252
- <input type="text" id="tagslug_new" name="tagslug_new" value="" size="40" />
253
- <input class="button" type="submit" name="edit" value="<?php _e('Edit', 'nggallery'); ?>" />
254
- </td>
255
- </tr>
256
- </table>
257
- </form>
258
- </td>
259
- </tr>
260
- </table>
261
- <script type="text/javascript">
262
- // <![CDATA[
263
- // Register onclick event
264
- function registerClick() {
265
- jQuery('#taglist ul li span').bind("click", function(){
266
- addTag(this.innerHTML, "renametag_old");
267
- addTag(this.innerHTML, "deletetag_name");
268
- addTag(this.innerHTML, "tagname_match");
269
- });
270
- }
271
-
272
- // Register initial event
273
- jQuery(document).ready(function() {
274
- registerClick();
275
- });
276
-
277
- // Add tag into input
278
- function addTag( tag, name_element ) {
279
- var input_element = document.getElementById( name_element );
280
-
281
- if ( input_element.value.length > 0 && !input_element.value.match(/,\s*$/) )
282
- input_element.value += ", ";
283
-
284
- var re = new RegExp(tag + ",");
285
- if ( !input_element.value.match(re) )
286
- input_element.value += tag + ", ";
287
-
288
- return true;
289
- }
290
- // ]]>
291
- </script>
292
  </div>
1
+ <?php
2
+ /**
3
+ * Tag management page. Inspired from the Simple Tags plugin by Amaury Balmer.
4
+ * http://code.google.com/p/simple-tags/
5
+ */
6
+
7
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
8
+
9
+ $action_status = array('message' => '', 'status' => 'ok');
10
+
11
+ if ( isset($_POST['tag_action']) ) {
12
+
13
+ check_admin_referer('nggallery_admin_tags');
14
+
15
+ if ( $_POST['tag_action'] == 'renametag' ) {
16
+ $oldtag = (isset($_POST['renametag_old'])) ? $_POST['renametag_old'] : '';
17
+ $newtag = (isset($_POST['renametag_new'])) ? $_POST['renametag_new'] : '';
18
+ $action_status = nggTags::rename_tags( $oldtag, $newtag );
19
+ } elseif ( $_POST['tag_action'] == 'deletetag' ) {
20
+ $todelete = (isset($_POST['deletetag_name'])) ? $_POST['deletetag_name'] : '';
21
+ $action_status = nggTags::delete_tags( $todelete );
22
+ } elseif ( $_POST['tag_action'] == 'editslug' ) {
23
+ $matchtag = (isset($_POST['tagname_match'])) ? $_POST['tagname_match'] : '';
24
+ $newslug = (isset($_POST['tagslug_new'])) ? $_POST['tagslug_new'] : '';
25
+ $action_status = nggTags::edit_tag_slug( $matchtag, $newslug );
26
+ }
27
+ }
28
+
29
+ // Som useful variables
30
+ $admin_base_url = admin_url() . 'admin.php?page=nggallery-tags';
31
+ $nb_tags = 50; // Number of tags to show on a single page
32
+
33
+ // Manage URL
34
+ $sort_order = ( isset($_GET['tag_sortorder']) ) ? esc_attr( stripslashes($_GET['tag_sortorder']) ) : 'desc';
35
+ $search_url = ( isset($_GET['search']) ) ? '&amp;search=' . esc_attr ( stripslashes($_GET['search']) ) : '';
36
+ $action_url = $admin_base_url . '&amp;tag_sortorder=' . $sort_order. $search_url;
37
+
38
+ // Tags Filters
39
+ $order_array = array(
40
+ 'desc' => __('Most popular', 'nggallery'),
41
+ 'asc' => __('Least used', 'nggallery'),
42
+ 'natural' => __('Alphabetical', 'nggallery'));
43
+
44
+ // Build Tags Param
45
+ $param = 'hide_empty=false';
46
+ switch ($sort_order) {
47
+ case 'natural' :
48
+ $param .= '&number='.$nb_tags.'&orderby=name&order=asc';
49
+ break;
50
+ case 'asc' :
51
+ $param .= '&number='.$nb_tags.'&orderby=count&order=asc';
52
+ break;
53
+ default :
54
+ $param .= '&number='.$nb_tags.'&orderby=count&order=desc';
55
+ break;
56
+ }
57
+
58
+
59
+ // Search
60
+ if ( !empty($_GET['search']) ) {
61
+ $search = stripslashes($_GET['search']);
62
+ $param .= '&name__like=' . $search;
63
+ }
64
+
65
+ // Offset
66
+ if ( !empty($_GET['offset']) ) {
67
+ $param .= '&offset=' . intval( $_GET['offset'] );
68
+ }
69
+
70
+ // Navigation urls
71
+ if ( empty($_GET['offset']) ) {
72
+ $offset = 0;
73
+ } else {
74
+ $offset = intval( $_GET['offset'] );
75
+ }
76
+
77
+ $tag_count = (int)wp_count_terms('ngg_tag', 'ignore_empty=true');
78
+
79
+ if ($offset + $nb_tags < $tag_count) {
80
+ $next_offset = '' . min($offset + $nb_tags, $tag_count - $nb_tags);
81
+ } else {
82
+ $next_offset = '';
83
+ }
84
+
85
+ if ($nb_tags < $tag_count && $offset>0) {
86
+ $prev_offset = '' . max($offset - $nb_tags, 0);
87
+ } else {
88
+ $prev_offset = '';
89
+ }
90
+
91
+ ?>
92
+ <style>
93
+ .disabled, .disabled:hover { border-color: #E5E5E5; color: #999999; cursor: default; }
94
+ </style>
95
+
96
+ <div class="wrap ngg_wrap">
97
+ <?php screen_icon( 'nextgen-gallery' ); ?>
98
+ <h2><?php _e('Tags', 'nggallery'); ?></h2>
99
+
100
+ <?php if ($action_status['message']!='') : ?>
101
+ <div id="message" class="<?php echo ($action_status['status']=='ok' ? 'updated' : $action_status['status']); ?> fade">
102
+ <p><strong><?php echo $action_status['message']; ?></strong></p>
103
+ </div>
104
+ <?php endif; ?>
105
+
106
+ <table>
107
+ <tr>
108
+ <td class="list_tags">
109
+ <fieldset class="options" id="taglist">
110
+ <h3><?php _e('Existing Tags', 'nggallery'); ?></h3>
111
+
112
+ <form method="get">
113
+ <p>
114
+ <label for="search"><?php _e('Search tags', 'nggallery'); ?></label><br />
115
+ <input type="hidden" name="page" value="<?php echo esc_attr( stripslashes($_GET['page']) ); ?>" />
116
+ <input type="hidden" name="tag_sortorder" value="<?php echo $sort_order; ?>" />
117
+ <input type="text" name="search" id="search" size="10" value="<?php if (isset($_GET['search'])) echo esc_attr( stripslashes($_GET['search']) ); ?>" />
118
+ <input class="button" type="submit" value="<?php _e('Go', 'nggallery'); ?>" />
119
+ </p>
120
+ </form>
121
+
122
+ <div class="sort_order">
123
+ <h3><?php _e('Sort Order:', 'nggallery'); ?></h3>
124
+ <?php
125
+ $output = array();
126
+ foreach( $order_array as $sort => $title ) {
127
+ $output[] = ($sort == $sort_order) ? '<span style="color: red;">'.$title.'</span>' : '<a href="'. $admin_base_url . '&amp;tag_sortorder=' . $sort . $search_url .'">'.$title.'</a>';
128
+ }
129
+ echo implode('<br />', $output);
130
+ $output = array();
131
+ unset($output);
132
+ ?>
133
+ </div>
134
+
135
+ <div id="ajax_area_tagslist">
136
+ <ul>
137
+ <?php
138
+ $tags = (array) nggTags::find_tags($param, true);
139
+ foreach( $tags as $tag ) {
140
+ //TODO:Tag link should be call a list of images in manage gallery
141
+ //echo '<li><span>' . $tag->name . '</span>&nbsp;<a href="'.(ngg_get_tag_link( $tag->term_id )).'" title="'.sprintf(__('View all images tagged with %s', 'nggallery'), $tag->name).'">('.$tag->count.')</a></li>'."\n";
142
+ echo '<li><span>' . esc_html( $tag->name ). '</span>&nbsp;'.'('. esc_html( $tag->count ).')</li>'."\n";
143
+
144
+ }
145
+ unset($tags);
146
+ ?>
147
+ </ul>
148
+
149
+ <?php if ( $prev_offset!='' || $next_offset!='' ) : ?>
150
+ <div class="navigation">
151
+
152
+ <?php if ($prev_offset!='') { ?>
153
+ <form method="get" style="display: inline;">
154
+ <span>
155
+ <input type="hidden" name="page" value="<?php echo esc_attr( stripslashes($_GET['page']) ); ?>" />
156
+ <input type="hidden" name="tag_sortorder" value="<?php echo $sort_order; ?>" />
157
+ <input type="hidden" name="offset" value="<?php echo $prev_offset; ?>" />
158
+ <input class="button" type="submit" value="&laquo; <?php _e('Previous tags', 'nggallery'); ?>" />
159
+ </span>
160
+ </form>
161
+ <?php } else { ?>
162
+ <span><span class="button disabled">&laquo; <?php _e('Previous tags', 'nggallery'); ?></span></span>
163
+ <?php } ?>
164
+
165
+ <?php if ($next_offset!='') { ?>
166
+ <form method="get" style="display: inline;">
167
+ <span>
168
+ <input type="hidden" name="page" value="<?php echo esc_attr( stripslashes($_GET['page']) ); ?>" />
169
+ <input type="hidden" name="tag_sortorder" value="<?php echo $sort_order; ?>" />
170
+ <input type="hidden" name="offset" value="<?php echo $next_offset; ?>" />
171
+ <input class="button" type="submit" value="<?php _e('Next tags', 'nggallery'); ?> &raquo;" />
172
+ </span>
173
+ </form>
174
+ <?php } else { ?>
175
+ <span><span class="button disabled"><?php _e('Previous tags', 'nggallery'); ?> &raquo;</span></span>
176
+ <?php } ?>
177
+ </div>
178
+ <?php endif; ?>
179
+ </div>
180
+ </fieldset>
181
+ </td>
182
+ <td class="forms_manage">
183
+ <h3><?php _e('Rename Tag', 'nggallery'); ?></h3>
184
+ <form action="<?php echo $action_url; ?>" method="post">
185
+ <input type="hidden" name="tag_action" value="renametag" />
186
+ <?php wp_nonce_field('nggallery_admin_tags'); ?>
187
+
188
+ <table class="form-table">
189
+ <tr valign="top">
190
+ <td colspan="2">
191
+ <p><?php _e('Enter the tag to rename and its new value. You can use this feature to merge tags too. Click "Rename" and all posts which use this tag will be updated.', 'nggallery'); ?></p>
192
+ <p><?php _e('You can specify multiple tags to rename by separating them with commas.', 'nggallery'); ?></p>
193
+ </td>
194
+ </tr>
195
+ <tr valign="top">
196
+ <th scope="row"><label for="renametag_old"><?php _e('Tag(s) to rename:', 'nggallery'); ?></label></th>
197
+ <td><input type="text" id="renametag_old" name="renametag_old" value="" size="40" /></td>
198
+ </tr>
199
+ <tr valign="top">
200
+ <th scope="row"><label for="renametag_new"><?php _e('New tag name(s):', 'nggallery'); ?></label></th>
201
+ <td>
202
+ <input type="text" id="renametag_new" name="renametag_new" value="" size="40" />
203
+ <input class="button" type="submit" name="rename" value="<?php _e('Rename', 'nggallery'); ?>" />
204
+ </td>
205
+ </tr>
206
+ </table>
207
+ </form>
208
+
209
+ <h3><?php _e('Delete Tag', 'nggallery'); ?></h3>
210
+ <form action="<?php echo $action_url; ?>" method="post">
211
+ <input type="hidden" name="tag_action" value="deletetag" />
212
+ <?php wp_nonce_field('nggallery_admin_tags'); ?>
213
+
214
+ <table class="form-table">
215
+ <tr valign="top">
216
+ <td colspan="2">
217
+ <p><?php _e('Enter the name of the tag to delete. This tag will be removed from all posts.', 'nggallery'); ?></p>
218
+ <p><?php _e('You can specify multiple tags to delete by separating them with commas', 'nggallery'); ?>.</p>
219
+ </td>
220
+ </tr>
221
+ <tr valign="top">
222
+ <th scope="row"><label for="deletetag_name"><?php _e('Tag(s) to delete:', 'nggallery'); ?></label></th>
223
+ <td>
224
+ <input type="text" id="deletetag_name" name="deletetag_name" value="" size="40" />
225
+ <input class="button" type="submit" name="delete" value="<?php _e('Delete', 'nggallery'); ?>" />
226
+ </td>
227
+ </tr>
228
+ </table>
229
+ </form>
230
+
231
+ <h3><?php _e('Edit Tag Slug', 'nggallery'); ?></h3>
232
+ <form action="<?php echo $action_url; ?>" method="post">
233
+ <input type="hidden" name="tag_action" value="editslug" />
234
+ <?php wp_nonce_field('nggallery_admin_tags'); ?>
235
+
236
+ <table class="form-table">
237
+ <tr valign="top">
238
+ <td colspan="2">
239
+ <p><?php _e('Enter the tag name to edit and its new slug. <a href="http://codex.wordpress.org/Glossary#Slug">Slug definition</a>', 'nggallery'); ?></p>
240
+ <p><?php _e('You can specify multiple tags to rename by separating them with commas.', 'nggallery'); ?></p>
241
+ </td>
242
+ </tr>
243
+ <tr valign="top">
244
+ <th scope="row"><label for="tagname_match"><?php _e('Tag(s) to match:', 'nggallery'); ?></label></th>
245
+ <td><input type="text" id="tagname_match" name="tagname_match" value="" size="40" /></td>
246
+ </tr>
247
+ <tr valign="top">
248
+ <th scope="row"><label for="tagslug_new"><?php _e('Slug(s) to set:', 'nggallery'); ?></label></th>
249
+ <td>
250
+ <input type="text" id="tagslug_new" name="tagslug_new" value="" size="40" />
251
+ <input class="button" type="submit" name="edit" value="<?php _e('Edit', 'nggallery'); ?>" />
252
+ </td>
253
+ </tr>
254
+ </table>
255
+ </form>
256
+ </td>
257
+ </tr>
258
+ </table>
259
+ <script type="text/javascript">
260
+ // <![CDATA[
261
+ // Register onclick event
262
+ function registerClick() {
263
+ jQuery('#taglist ul li span').bind("click", function(){
264
+ addTag(this.innerHTML, "renametag_old");
265
+ addTag(this.innerHTML, "deletetag_name");
266
+ addTag(this.innerHTML, "tagname_match");
267
+ });
268
+ }
269
+
270
+ // Register initial event
271
+ jQuery(document).ready(function() {
272
+ registerClick();
273
+ });
274
+
275
+ // Add tag into input
276
+ function addTag( tag, name_element ) {
277
+ var input_element = document.getElementById( name_element );
278
+
279
+ if ( input_element.value.length > 0 && !input_element.value.match(/,\s*$/) )
280
+ input_element.value += ", ";
281
+
282
+ var re = new RegExp(tag + ",");
283
+ if ( !input_element.value.match(re) )
284
+ input_element.value += tag + ", ";
285
+
286
+ return true;
287
+ }
288
+ // ]]>
289
+ </script>
 
 
290
  </div>
admin/templates/facebook_like_button.php CHANGED
@@ -1,2 +1,2 @@
1
- <div id="fb-root"></div>
2
- <div id="ngg_facebook_like" class="fb-like" data-href="http://www.facebook.com/nextgengallery" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
1
+ <div id="fb-root"></div>
2
+ <div id="ngg_facebook_like" class="fb-like" data-href="http://www.facebook.com/nextgengallery" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
admin/templates/social_media_buttons.php CHANGED
@@ -1,6 +1,6 @@
1
- <div id="ngg_social_media">
2
- <?php
3
- //Disabled. To include in next iteration
4
- //include('twitter_follow_link.php'); ?>
5
- <?php //include('facebook_like_button.php'); ?>
6
  </div>
1
+ <div id="ngg_social_media">
2
+ <?php
3
+ //Disabled. To include in next iteration
4
+ //include('twitter_follow_link.php'); ?>
5
+ <?php //include('facebook_like_button.php'); ?>
6
  </div>
admin/templates/twitter_follow_link.php CHANGED
@@ -1,8 +1,8 @@
1
- <a
2
- href='https://twitter.com/NextGENGallery'
3
- id="ngg_twitter_follow"
4
- class='twitter-follow-button'
5
- data-show-count='false'
6
- data-lang='en'>
7
- Follow @NextGENGallery
8
  </a>
1
+ <a
2
+ href='https://twitter.com/NextGENGallery'
3
+ id="ngg_twitter_follow"
4
+ class='twitter-follow-button'
5
+ data-show-count='false'
6
+ data-lang='en'>
7
+ Follow @NextGENGallery
8
  </a>
admin/tinymce/editor_plugin.js CHANGED
@@ -1,77 +1,77 @@
1
- // Docu : http://wiki.moxiecode.com/index.php/TinyMCE:Create_plugin/3.x#Creating_your_own_plugins
2
-
3
- (function() {
4
- // Load plugin specific language pack
5
- tinymce.PluginManager.requireLangPack('NextGEN');
6
-
7
- tinymce.create('tinymce.plugins.NextGEN', {
8
- /**
9
- * Initializes the plugin, this will be executed after the plugin has been created.
10
- * This call is done before the editor instance has finished it's initialization so use the onInit event
11
- * of the editor instance to intercept that event.
12
- *
13
- * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
14
- * @param {string} url Absolute URL to where the plugin is located.
15
- */
16
- init : function(ed, url) {
17
- // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
18
-
19
- ed.addCommand('mceNextGEN', function() {
20
- ed.windowManager.open({
21
- // call content via admin-ajax, no need to know the full plugin path
22
- file : ajaxurl + '?action=ngg_tinymce',
23
- width : 360 + ed.getLang('NextGEN.delta_width', 0),
24
- height : 210 + ed.getLang('NextGEN.delta_height', 0),
25
- inline : 1
26
- }, {
27
- plugin_url : url // Plugin absolute URL
28
- });
29
- });
30
-
31
- // Register example button
32
- ed.addButton('NextGEN', {
33
- title : 'NextGEN.desc',
34
- cmd : 'mceNextGEN',
35
- image : url + '/nextgen.gif'
36
- });
37
-
38
- // Add a node change handler, selects the button in the UI when a image is selected
39
- ed.onNodeChange.add(function(ed, cm, n) {
40
- cm.setActive('NextGEN', n.nodeName == 'IMG');
41
- });
42
- },
43
-
44
- /**
45
- * Creates control instances based in the incomming name. This method is normally not
46
- * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
47
- * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
48
- * method can be used to create those.
49
- *
50
- * @param {String} n Name of the control to create.
51
- * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
52
- * @return {tinymce.ui.Control} New control instance or null if no control was created.
53
- */
54
- createControl : function(n, cm) {
55
- return null;
56
- },
57
-
58
- /**
59
- * Returns information about the plugin as a name/value array.
60
- * The current keys are longname, author, authorurl, infourl and version.
61
- *
62
- * @return {Object} Name/value array containing information about the plugin.
63
- */
64
- getInfo : function() {
65
- return {
66
- longname : 'NextGEN',
67
- author : 'Photocrati',
68
- authorurl : 'http://www.photocrati.com/',
69
- infourl : 'http://www.nextgen-gallery.com/',
70
- version : "2.0"
71
- };
72
- }
73
- });
74
-
75
- // Register plugin
76
- tinymce.PluginManager.add('NextGEN', tinymce.plugins.NextGEN);
77
- })();
1
+ // Docu : http://wiki.moxiecode.com/index.php/TinyMCE:Create_plugin/3.x#Creating_your_own_plugins
2
+
3
+ (function() {
4
+ // Load plugin specific language pack
5
+ tinymce.PluginManager.requireLangPack('NextGEN');
6
+
7
+ tinymce.create('tinymce.plugins.NextGEN', {
8
+ /**
9
+ * Initializes the plugin, this will be executed after the plugin has been created.
10
+ * This call is done before the editor instance has finished it's initialization so use the onInit event
11
+ * of the editor instance to intercept that event.
12
+ *
13
+ * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
14
+ * @param {string} url Absolute URL to where the plugin is located.
15
+ */
16
+ init : function(ed, url) {
17
+ // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
18
+
19
+ ed.addCommand('mceNextGEN', function() {
20
+ ed.windowManager.open({
21
+ // call content via admin-ajax, no need to know the full plugin path
22
+ file : ajaxurl + '?action=ngg_tinymce',
23
+ width : 360 + ed.getLang('NextGEN.delta_width', 0),
24
+ height : 210 + ed.getLang('NextGEN.delta_height', 0),
25
+ inline : 1
26
+ }, {
27
+ plugin_url : url // Plugin absolute URL
28
+ });
29
+ });
30
+
31
+ // Register example button
32
+ ed.addButton('NextGEN', {
33
+ title : 'NextGEN.desc',
34
+ cmd : 'mceNextGEN',
35
+ image : url + '/nextgen.gif'
36
+ });
37
+
38
+ // Add a node change handler, selects the button in the UI when a image is selected
39
+ ed.onNodeChange.add(function(ed, cm, n) {
40
+ cm.setActive('NextGEN', n.nodeName == 'IMG');
41
+ });
42
+ },
43
+
44
+ /**
45
+ * Creates control instances based in the incomming name. This method is normally not
46
+ * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
47
+ * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
48
+ * method can be used to create those.
49
+ *
50
+ * @param {String} n Name of the control to create.
51
+ * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
52
+ * @return {tinymce.ui.Control} New control instance or null if no control was created.
53
+ */
54
+ createControl : function(n, cm) {
55
+ return null;
56
+ },
57
+
58
+ /**
59
+ * Returns information about the plugin as a name/value array.
60
+ * The current keys are longname, author, authorurl, infourl and version.
61
+ *
62
+ * @return {Object} Name/value array containing information about the plugin.
63
+ */
64
+ getInfo : function() {
65
+ return {
66
+ longname : 'NextGEN',
67
+ author : 'Photocrati',
68
+ authorurl : 'http://www.photocrati.com/',
69
+ infourl : 'http://www.nextgen-gallery.com/',
70
+ version : "2.0"
71
+ };
72
+ }
73
+ });
74
+
75
+ // Register plugin
76
+ tinymce.PluginManager.add('NextGEN', tinymce.plugins.NextGEN);
77
+ })();
admin/tinymce/langs/de.js CHANGED
@@ -1,6 +1,6 @@
1
- // German lang variables for WP2.5
2
-
3
- tinyMCE.addI18n({de:{
4
- NextGEN:{
5
- desc : 'NextCellent Gallery hinzufuegen'
6
- }}});
1
+ // German lang variables for WP2.5
2
+
3
+ tinyMCE.addI18n({de:{
4
+ NextGEN:{
5
+ desc : 'NextCellent Gallery hinzufuegen'
6
+ }}});
admin/tinymce/langs/de_de.js CHANGED
@@ -1,6 +1,6 @@
1
- // German lang variables for WP2.5
2
-
3
- tinyMCE.addI18n({de:{
4
- NextGEN:{
5
- desc : 'NextCellent Gallery hinzufuegen'
6
- }}});
1
+ // German lang variables for WP2.5
2
+
3
+ tinyMCE.addI18n({de:{
4
+ NextGEN:{
5
+ desc : 'NextCellent Gallery hinzufuegen'
6
+ }}});
admin/tinymce/langs/en.js CHANGED
@@ -1,6 +1,6 @@
1
- // English lang variables for WP2.5
2
-
3
- tinyMCE.addI18n({en:{
4
- NextGEN:{
5
- desc : 'Add NextCellent Gallery'
6
- }}});
1
+ // English lang variables for WP2.5
2
+
3
+ tinyMCE.addI18n({en:{
4
+ NextGEN:{
5
+ desc : 'Add NextCellent Gallery'
6
+ }}});
admin/tinymce/langs/en_US.js CHANGED
@@ -1,6 +1,6 @@
1
- // English lang variables for WP2.5
2
-
3
- tinyMCE.addI18n({en_US:{
4
- NextGEN:{
5
- desc : 'Add NextCellent Gallery'
6
- }}});
1
+ // English lang variables for WP2.5
2
+
3
+ tinyMCE.addI18n({en_US:{
4
+ NextGEN:{
5
+ desc : 'Add NextCellent Gallery'
6
+ }}});
admin/tinymce/tinymce.js CHANGED
@@ -1,75 +1,75 @@
1
- function init() {
2
- tinyMCEPopup.resizeToInnerSize();
3
- }
4
-
5
- function getCheckedValue(radioObj) {
6
- if(!radioObj)
7
- return "";
8
- var radioLength = radioObj.length;
9
- if(radioLength == undefined)
10
- if(radioObj.checked)
11
- return radioObj.value;
12
- else
13
- return "";
14
- for(var i = 0; i < radioLength; i++) {
15
- if(radioObj[i].checked) {
16
- return radioObj[i].value;
17
- }
18
- }
19
- return "";
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;
33
- var showtype = getCheckedValue(document.getElementsByName('showtype'));
34
- if (galleryid != 0 )
35
- tagtext = "["+ showtype + " id=" + galleryid + "]";
36
- else
37
- tinyMCEPopup.close();
38
- }
39
-
40
- if (album.className.indexOf('current') != -1) {
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
- }
48
-
49
- if (singlepic.className.indexOf('current') != -1) {
50
- var singlepicid = document.getElementById('singlepictag').value;
51
- var imgWidth = document.getElementById('imgWidth').value;
52
- var imgHeight = document.getElementById('imgHeight').value;
53
- var imgeffect = document.getElementById('imgeffect').value;
54
- var imgfloat = document.getElementById('imgfloat').value;
55
-
56
- if (singlepicid != 0 ) {
57
- if (imgeffect == "none")
58
- tagtext = "[singlepic id=" + singlepicid + " w=" + imgWidth + " h=" + imgHeight + " float=" + imgfloat + "]";
59
- else
60
- tagtext = "[singlepic id=" + singlepicid + " w=" + imgWidth + " h=" + imgHeight + " mode=" + imgeffect + " float=" + imgfloat + "]";
61
- } else {
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
- }
74
- return;
75
- }
1
+ function init() {
2
+ tinyMCEPopup.resizeToInnerSize();
3
+ }
4
+
5
+ function getCheckedValue(radioObj) {
6
+ if(!radioObj)
7
+ return "";
8
+ var radioLength = radioObj.length;
9
+ if(radioLength == undefined)
10
+ if(radioObj.checked)
11
+ return radioObj.value;
12
+ else
13
+ return "";
14
+ for(var i = 0; i < radioLength; i++) {
15
+ if(radioObj[i].checked) {
16
+ return radioObj[i].value;
17
+ }
18
+ }
19
+ return "";
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;
33
+ var showtype = getCheckedValue(document.getElementsByName('showtype'));
34
+ if (galleryid != 0 )
35
+ tagtext = "["+ showtype + " id=" + galleryid + "]";
36
+ else
37
+ tinyMCEPopup.close();
38
+ }
39
+
40
+ if (album.className.indexOf('current') != -1) {
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
+ }
48
+
49
+ if (singlepic.className.indexOf('current') != -1) {
50
+ var singlepicid = document.getElementById('singlepictag').value;
51
+ var imgWidth = document.getElementById('imgWidth').value;
52
+ var imgHeight = document.getElementById('imgHeight').value;
53
+ var imgeffect = document.getElementById('imgeffect').value;
54
+ var imgfloat = document.getElementById('imgfloat').value;
55
+
56
+ if (singlepicid != 0 ) {
57
+ if (imgeffect == "none")
58
+ tagtext = "[singlepic id=" + singlepicid + " w=" + imgWidth + " h=" + imgHeight + " float=" + imgfloat + "]";
59
+ else
60
+ tagtext = "[singlepic id=" + singlepicid + " w=" + imgWidth + " h=" + imgHeight + " mode=" + imgeffect + " float=" + imgfloat + "]";
61
+ } else {
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
+ }
74
+ return;
75
+ }
admin/tinymce/tinymce.php CHANGED
@@ -1,102 +1,102 @@
1
- <?php
2
-
3
- /**
4
- * add_nextgen_button
5
- *
6
- * @package NextGEN Gallery
7
- * @title TinyMCE V3 Button Integration (for WP2.5 and higher)
8
- * @author Alex Rabe
9
- *
10
- * @access public
11
- */
12
- class add_nextgen_button {
13
-
14
- var $pluginname = 'NextGEN';
15
- var $path = '';
16
- var $internalVersion = 200;
17
-
18
- /**
19
- * add_nextgen_button::add_nextgen_button()
20
- * the constructor
21
- *
22
- * @return void
23
- */
24
- function add_nextgen_button() {
25
-
26
- // Set path to editor_plugin.js
27
- $this->path = NGGALLERY_URLPATH . 'admin/tinymce/';
28
-
29
- // Modify the version when tinyMCE plugins are changed.
30
- add_filter('tiny_mce_version', array (&$this, 'change_tinymce_version') );
31
-
32
- // init process for button control
33
- add_action('init', array (&$this, 'addbuttons') );
34
- }
35
-
36
- /**
37
- * add_nextgen_button::addbuttons()
38
- *
39
- * @return void
40
- */
41
- function addbuttons() {
42
-
43
- // Don't bother doing this stuff if the current user lacks permissions
44
- if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') )
45
- return;
46
-
47
- // Check for NextGEN capability
48
- if ( !current_user_can('NextGEN Use TinyMCE') )
49
- return;
50
-
51
- // Add only in Rich Editor mode
52
- if ( get_user_option('rich_editing') == 'true') {
53
-
54
- // add the button for wp2.5 in a new way
55
- add_filter("mce_external_plugins", array (&$this, 'add_tinymce_plugin' ), 5);
56
- add_filter('mce_buttons', array (&$this, 'register_button' ), 5);
57
- }
58
- }
59
-
60
- /**
61
- * add_nextgen_button::register_button()
62
- * used to insert button in wordpress 2.5x editor
63
- *
64
- * @return $buttons
65
- */
66
- function register_button($buttons) {
67
-
68
- array_push($buttons, 'separator', $this->pluginname );
69
-
70
- return $buttons;
71
- }
72
-
73
- /**
74
- * add_nextgen_button::add_tinymce_plugin()
75
- * Load the TinyMCE plugin : editor_plugin.js
76
- *
77
- * @return $plugin_array
78
- */
79
- function add_tinymce_plugin($plugin_array) {
80
-
81
- $plugin_array[$this->pluginname] = $this->path . 'editor_plugin.js';
82
-
83
- return $plugin_array;
84
- }
85
-
86
- /**
87
- * add_nextgen_button::change_tinymce_version()
88
- * A different version will rebuild the cache
89
- *
90
- * @return $versio
91
- */
92
- function change_tinymce_version($version) {
93
- $version = $version + $this->internalVersion;
94
- return $version;
95
- }
96
-
97
- }
98
-
99
- // Call it now
100
- $tinymce_button = new add_nextgen_button ();
101
-
102
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * add_nextgen_button
5
+ *
6
+ * @package NextGEN Gallery
7
+ * @title TinyMCE V3 Button Integration (for WP2.5 and higher)
8
+ * @author Alex Rabe
9
+ *
10
+ * @access public
11
+ */
12
+ class add_nextgen_button {
13
+
14
+ var $pluginname = 'NextGEN';
15
+ var $path = '';
16
+ var $internalVersion = 200;
17
+
18
+ /**
19
+ * add_nextgen_button::add_nextgen_button()
20
+ * the constructor
21
+ *
22
+ * @return void
23
+ */
24
+ function add_nextgen_button() {
25
+
26
+ // Set path to editor_plugin.js
27
+ $this->path = NGGALLERY_URLPATH . 'admin/tinymce/';
28
+
29
+ // Modify the version when tinyMCE plugins are changed.
30
+ add_filter('tiny_mce_version', array (&$this, 'change_tinymce_version') );
31
+
32
+ // init process for button control
33
+ add_action('init', array (&$this, 'addbuttons') );
34
+ }
35
+
36
+ /**
37
+ * add_nextgen_button::addbuttons()
38
+ *
39
+ * @return void
40
+ */
41
+ function addbuttons() {
42
+
43
+ // Don't bother doing this stuff if the current user lacks permissions
44
+ if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') )
45
+ return;
46
+
47
+ // Check for NextGEN capability
48
+ if ( !current_user_can('NextGEN Use TinyMCE') )
49
+ return;
50
+
51
+ // Add only in Rich Editor mode
52
+ if ( get_user_option('rich_editing') == 'true') {
53
+
54
+ // add the button for wp2.5 in a new way
55
+ add_filter("mce_external_plugins", array (&$this, 'add_tinymce_plugin' ), 5);
56
+ add_filter('mce_buttons', array (&$this, 'register_button' ), 5);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * add_nextgen_button::register_button()
62
+ * used to insert button in wordpress 2.5x editor
63
+ *
64
+ * @return $buttons
65
+ */
66
+ function register_button($buttons) {
67
+
68
+ array_push($buttons, 'separator', $this->pluginname );
69
+
70
+ return $buttons;
71
+ }
72
+
73
+ /**
74
+ * add_nextgen_button::add_tinymce_plugin()
75
+ * Load the TinyMCE plugin : editor_plugin.js
76
+ *
77
+ * @return $plugin_array
78
+ */
79
+ function add_tinymce_plugin($plugin_array) {
80
+
81
+ $plugin_array[$this->pluginname] = $this->path . 'editor_plugin.js';
82
+
83
+ return $plugin_array;
84
+ }
85
+
86
+ /**
87
+ * add_nextgen_button::change_tinymce_version()
88
+ * A different version will rebuild the cache
89
+ *
90
+ * @return $versio
91
+ */
92
+ function change_tinymce_version($version) {
93
+ $version = $version + $this->internalVersion;
94
+ return $version;
95
+ }
96
+
97
+ }
98
+
99
+ // Call it now
100
+ $tinymce_button = new add_nextgen_button ();
101
+
102
+ ?>
admin/tinymce/window.php CHANGED
@@ -1,152 +1,152 @@
1
- <?php
2
-
3
- if ( !defined('ABSPATH') )
4
- die('You are not allowed to call this page directly.');
5
-
6
- global $wpdb, $nggdb;
7
-
8
- @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
9
-
10
- // Get WordPress scripts and styles
11
- wp_enqueue_script('jquery-ui-core');
12
- wp_enqueue_script('jquery-ui-widget');
13
- wp_enqueue_script('jquery-ui-position');
14
- global $wp_scripts;
15
- if (!isset($wp_scripts->registered['jquery-ui-autocomplete'])) {
16
- wp_register_script( 'jquery-ui-autocomplete', NGGALLERY_URLPATH .'admin/js/jquery.ui.autocomplete.min.js', array('jquery-ui-core'), '1.8.15');
17
- }
18
- wp_enqueue_script('jquery-ui-autocomplete');
19
- ?>
20
- <html xmlns="http://www.w3.org/1999/xhtml">
21
- <head>
22
- <title>NextCellent Gallery</title>
23
- <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
24
- <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
25
- <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
26
- <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
27
- <?php wp_print_scripts() ?>
28
- <script language="javascript" type="text/javascript" src="<?php echo NGGALLERY_URLPATH ?>admin/js/ngg.autocomplete.js"></script>
29
- <script language="javascript" type="text/javascript" src="<?php echo NGGALLERY_URLPATH ?>admin/tinymce/tinymce.js"></script>
30
- <link rel="stylesheet" type="text/css" href="<?php echo NGGALLERY_URLPATH ?>admin/css/jquery.ui.css" media="all" />
31
- <base target="_self" />
32
- </head>
33
- <script type="text/javascript">
34
- jQuery(document).ready(function(){
35
- jQuery("#gallerytag").nggAutocomplete( {
36
- type: 'gallery',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>"
37
- });
38
- jQuery("#albumtag").nggAutocomplete( {
39
- type: 'album',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>"
40
- });
41
- jQuery("#singlepictag").nggAutocomplete( {
42
- type: 'image',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>"
43
- });
44
- });
45
- </script>
46
- <body class="nextgen_tinymce_window" id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
47
- <!-- <form onsubmit="insertLink();return false;" action="#"> -->
48
- <form name="NextGEN" action="#">
49
- <div class="tabs">
50
- <ul>
51
- <li id="gallery_tab" class="current"><span><a href="javascript:mcTabs.displayTab('gallery_tab','gallery_panel');" onmousedown="return false;"><?php echo _n( 'Gallery', 'Galleries', 1, 'nggallery' ) ?></a></span></li>
52
- <li id="album_tab"><span><a href="javascript:mcTabs.displayTab('album_tab','album_panel');" onmousedown="return false;"><?php echo _n( 'Album', 'Albums', 1, 'nggallery' ) ?></a></span></li>
53
- <li id="singlepic_tab"><span><a href="javascript:mcTabs.displayTab('singlepic_tab','singlepic_panel');" onmousedown="return false;"><?php _e('Picture', 'nggallery'); ?></a></span></li>
54
- </ul>
55
- </div>
56
-
57
- <div class="panel_wrapper">
58
- <!-- gallery panel -->
59
- <div id="gallery_panel" class="panel current">
60
- <br />
61
- <table border="0" cellpadding="4" cellspacing="0">
62
- <tr>
63
- <td nowrap="nowrap"><label for="gallerytag"><?php _e("Gallery", 'nggallery'); ?></label></td>
64
- <td><select id="gallerytag" name="gallerytag" style="width: 200px">
65
- <option value="0" selected="selected"><?php _e("Select or enter gallery", 'nggallery'); ?></option>
66
- </select>
67
- </td>
68
- </tr>
69
- <tr>
70
- <td nowrap="nowrap" valign="top"><label for="showtype"><?php _e("Show as", 'nggallery'); ?></label></td>
71
- <td><label><input name="showtype" type="radio" value="nggallery" checked="checked" /> <?php _e('Image list', 'nggallery') ;?></label><br />
72
- <label><input name="showtype" type="radio" value="slideshow" /> <?php _e('Slideshow', 'nggallery') ;?></label><br />
73
- <label><input name="showtype" type="radio" value="imagebrowser" /> <?php _e('Imagebrowser', 'nggallery') ;?></label></td>
74
- </tr>
75
- </table>
76
- </div>
77
- <!-- gallery panel -->
78
-
79
- <!-- album panel -->
80
- <div id="album_panel" class="panel">
81
- <br />
82
- <table border="0" cellpadding="4" cellspacing="0">
83
- <tr>
84
- <td nowrap="nowrap"><label for="albumtag"><?php _e("Album", 'nggallery'); ?></label></td>
85
- <td><select id="albumtag" name="albumtag" style="width: 200px">
86
- <option value="0" selected="selected"><?php _e("Select or enter album", 'nggallery'); ?></option>
87
- </select>
88
- </td>
89
- </tr>
90
- <tr>
91
- <td nowrap="nowrap" valign="top"><label for="showtype"><?php _e("Show as", 'nggallery'); ?></label></td>
92
- <td><label><input name="albumtype" type="radio" value="extend" checked="checked" /> <?php _e('Extended version', 'nggallery') ;?></label><br />
93
- <label><input name="albumtype" type="radio" value="compact" /> <?php _e('Compact version', 'nggallery') ;?></label></td>
94
- </tr>
95
- </table>
96
- </div>
97
- <!-- album panel -->
98
-
99
- <!-- single pic panel -->
100
- <div id="singlepic_panel" class="panel">
101
- <br />
102
- <table border="0" cellpadding="4" cellspacing="0">
103
- <tr>
104
- <td nowrap="nowrap"><label for="singlepictag"><?php _e("Picture", 'nggallery'); ?></label></td>
105
- <td><select id="singlepictag" name="singlepictag" style="width: 200px">
106
- <option value="0" selected="selected"><?php _e("Select or enter picture", 'nggallery'); ?></option>
107
- </select>
108
- </td>
109
- </tr>
110
- <tr>
111
- <td nowrap="nowrap"><?php _e("Width x Height", 'nggallery'); ?></td>
112
- <td><input type="text" size="5" id="imgWidth" name="imgWidth" value="320" /> x <input type="text" size="5" id="imgHeight" name="imgHeight" value="240" /></td>
113
- </tr>
114
- <tr>
115
- <td nowrap="nowrap" valign="top"><?php _e("Effect", 'nggallery'); ?></td>
116
- <td>
117
- <label><select id="imgeffect" name="imgeffect">
118
- <option value="none"><?php _e("No effect", 'nggallery'); ?></option>
119
- <option value="watermark"><?php _e("Watermark", 'nggallery'); ?></option>
120
- <option value="web20"><?php _e("Web 2.0", 'nggallery'); ?></option>
121
- </select></label>
122
- </td>
123
- </tr>
124
- <tr>
125
- <td nowrap="nowrap" valign="top"><?php _e("Float", 'nggallery'); ?></td>
126
- <td>
127
- <label><select id="imgfloat" name="imgfloat">
128
- <option value=""><?php _e("No float", 'nggallery'); ?></option>
129
- <option value="left"><?php _e("Left", 'nggallery'); ?></option>
130
- <option value="center"><?php _e("Center", 'nggallery'); ?></option>
131
- <option value="right"><?php _e("Right", 'nggallery'); ?></option>
132
- </select></label>
133
- </td>
134
- </tr>
135
-
136
- </table>
137
- </div>
138
- <!-- single pic panel -->
139
- </div>
140
-
141
- <div class="mceActionPanel">
142
- <div style="float: left">
143
- <input type="button" id="cancel" name="cancel" value="<?php _e("Cancel", 'nggallery'); ?>" onclick="tinyMCEPopup.close();" />
144
- </div>
145
-
146
- <div style="float: right">
147
- <input type="submit" id="insert" name="insert" value="<?php _e("Insert", 'nggallery'); ?>" onclick="insertNGGLink();" />
148
- </div>
149
- </div>
150
- </form>
151
- </body>
152
  </html>
1
+ <?php
2
+
3
+ if ( !defined('ABSPATH') )
4
+ die('You are not allowed to call this page directly.');
5
+
6
+ global $wpdb, $nggdb;
7
+
8
+ @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
9
+
10
+ // Get WordPress scripts and styles
11
+ wp_enqueue_script('jquery-ui-core');
12
+ wp_enqueue_script('jquery-ui-widget');
13
+ wp_enqueue_script('jquery-ui-position');
14
+ global $wp_scripts;
15
+ if (!isset($wp_scripts->registered['jquery-ui-autocomplete'])) {
16
+ wp_register_script( 'jquery-ui-autocomplete', NGGALLERY_URLPATH .'admin/js/jquery.ui.autocomplete.min.js', array('jquery-ui-core'), '1.8.15');
17
+ }
18
+ wp_enqueue_script('jquery-ui-autocomplete');
19
+ ?>
20
+ <html xmlns="http://www.w3.org/1999/xhtml">
21
+ <head>
22
+ <title>NextCellent Gallery</title>
23
+ <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
24
+ <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/tiny_mce_popup.js"></script>
25
+ <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/mctabs.js"></script>
26
+ <script language="javascript" type="text/javascript" src="<?php echo site_url(); ?>/wp-includes/js/tinymce/utils/form_utils.js"></script>
27
+ <?php wp_print_scripts() ?>
28
+ <script language="javascript" type="text/javascript" src="<?php echo NGGALLERY_URLPATH ?>admin/js/ngg.autocomplete.js"></script>
29
+ <script language="javascript" type="text/javascript" src="<?php echo NGGALLERY_URLPATH ?>admin/tinymce/tinymce.js"></script>
30
+ <link rel="stylesheet" type="text/css" href="<?php echo NGGALLERY_URLPATH ?>admin/css/jquery.ui.css" media="all" />
31
+ <base target="_self" />
32
+ </head>
33
+ <script type="text/javascript">
34
+ jQuery(document).ready(function(){
35
+ jQuery("#gallerytag").nggAutocomplete( {
36
+ type: 'gallery',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>"
37
+ });
38
+ jQuery("#albumtag").nggAutocomplete( {
39
+ type: 'album',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>"
40
+ });
41
+ jQuery("#singlepictag").nggAutocomplete( {
42
+ type: 'image',domain: "<?php echo home_url('index.php', is_ssl() ? 'https' : 'http'); ?>"
43
+ });
44
+ });
45
+ </script>
46
+ <body class="nextgen_tinymce_window" id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';" style="display: none">
47
+ <!-- <form onsubmit="insertLink();return false;" action="#"> -->
48
+ <form name="NextGEN" action="#">
49
+ <div class="tabs">
50
+ <ul>
51
+ <li id="gallery_tab" class="current"><span><a href="javascript:mcTabs.displayTab('gallery_tab','gallery_panel');" onmousedown="return false;"><?php echo _n( 'Gallery', 'Galleries', 1, 'nggallery' ) ?></a></span></li>
52
+ <li id="album_tab"><span><a href="javascript:mcTabs.displayTab('album_tab','album_panel');" onmousedown="return false;"><?php echo _n( 'Album', 'Albums', 1, 'nggallery' ) ?></a></span></li>
53
+ <li id="singlepic_tab"><span><a href="javascript:mcTabs.displayTab('singlepic_tab','singlepic_panel');" onmousedown="return false;"><?php _e('Picture', 'nggallery'); ?></a></span></li>
54
+ </ul>
55
+ </div>
56
+
57
+ <div class="panel_wrapper">
58
+ <!-- gallery panel -->
59
+ <div id="gallery_panel" class="panel current">
60
+ <br />
61
+ <table border="0" cellpadding="4" cellspacing="0" style="font-size:1em;">
62
+ <tr>
63
+ <td nowrap="nowrap"><label for="gallerytag"><?php _e("Gallery", 'nggallery'); ?></label></td>
64
+ <td><select id="gallerytag" name="gallerytag" style="width: 200px">
65
+ <option value="0" selected="selected"><?php _e("Select or enter gallery", 'nggallery'); ?></option>
66
+ </select>
67
+ </td>
68
+ </tr>
69
+ <tr>
70
+ <td nowrap="nowrap" valign="top"><label for="showtype"><?php _e("Show as", 'nggallery'); ?></label></td>
71
+ <td><label><input name="showtype" type="radio" value="nggallery" checked="checked" /> <?php _e('Image list', 'nggallery') ;?></label><br />
72
+ <label><input name="showtype" type="radio" value="slideshow" /> <?php _e('Slideshow', 'nggallery') ;?></label><br />
73
+ <label><input name="showtype" type="radio" value="imagebrowser" /> <?php _e('Imagebrowser', 'nggallery') ;?></label></td>
74
+ </tr>
75
+ </table>
76
+ </div>
77
+ <!-- gallery panel -->
78
+
79
+ <!-- album panel -->
80
+ <div id="album_panel" class="panel">
81
+ <br />
82
+ <table border="0" cellpadding="4" cellspacing="0" style="font-size:1em;">
83
+ <tr>
84
+ <td nowrap="nowrap"><label for="albumtag"><?php _e("Album", 'nggallery'); ?></label></td>
85
+ <td><select id="albumtag" name="albumtag" style="width: 200px">
86
+ <option value="0" selected="selected"><?php _e("Select or enter album", 'nggallery'); ?></option>
87
+ </select>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <td nowrap="nowrap" valign="top"><label for="showtype"><?php _e("Show as", 'nggallery'); ?></label></td>
92
+ <td><label><input name="albumtype" type="radio" value="extend" checked="checked" /> <?php _e('Extended version', 'nggallery') ;?></label><br />
93
+ <label><input name="albumtype" type="radio" value="compact" /> <?php _e('Compact version', 'nggallery') ;?></label></td>
94
+ </tr>
95
+ </table>
96
+ </div>
97
+ <!-- album panel -->
98
+
99
+ <!-- single pic panel -->
100
+ <div id="singlepic_panel" class="panel">
101
+ <br />
102
+ <table border="0" cellpadding="4" cellspacing="0" style="font-size:1em;">
103
+ <tr>
104
+ <td nowrap="nowrap"><label for="singlepictag"><?php _e("Picture", 'nggallery'); ?></label></td>
105
+ <td><select id="singlepictag" name="singlepictag" style="width: 200px">
106
+ <option value="0" selected="selected"><?php _e("Select or enter picture", 'nggallery'); ?></option>
107
+ </select>
108
+ </td>
109
+ </tr>
110
+ <tr>
111
+ <td nowrap="nowrap"><?php _e("Width x Height", 'nggallery'); ?></td>
112
+ <td><input type="text" size="5" id="imgWidth" name="imgWidth" value="320" /> x <input type="text" size="5" id="imgHeight" name="imgHeight" value="240" /></td>
113
+ </tr>
114
+ <tr>
115
+ <td nowrap="nowrap" valign="top"><?php _e("Effect", 'nggallery'); ?></td>
116
+ <td>
117
+ <label><select id="imgeffect" name="imgeffect">
118
+ <option value="none"><?php _e("No effect", 'nggallery'); ?></option>
119
+ <option value="watermark"><?php _e("Watermark", 'nggallery'); ?></option>
120
+ <option value="web20"><?php _e("Web 2.0", 'nggallery'); ?></option>
121
+ </select></label>
122
+ </td>
123
+ </tr>
124
+ <tr>
125
+ <td nowrap="nowrap" valign="top"><?php _e("Float", 'nggallery'); ?></td>
126
+ <td>
127
+ <label><select id="imgfloat" name="imgfloat">
128
+ <option value=""><?php _e("No float", 'nggallery'); ?></option>
129
+ <option value="left"><?php _e("Left", 'nggallery'); ?></option>
130
+ <option value="center"><?php _e("Center", 'nggallery'); ?></option>
131
+ <option value="right"><?php _e("Right", 'nggallery'); ?></option>
132
+ </select></label>
133
+ </td>
134
+ </tr>
135
+
136
+ </table>
137
+ </div>
138
+ <!-- single pic panel -->
139
+ </div>
140
+
141
+ <div class="mceActionPanel">
142
+ <div style="float: left">
143
+ <input type="button" id="cancel" name="cancel" value="<?php _e("Cancel", 'nggallery'); ?>" onclick="tinyMCEPopup.close();" />
144
+ </div>
145
+
146
+ <div style="float: right">
147
+ <input type="submit" id="insert" name="insert" value="<?php _e("Insert", 'nggallery'); ?>" onclick="insertNGGLink();" />
148
+ </div>
149
+ </div>
150
+ </form>
151
+ </body>
152
  </html>
admin/upload.php CHANGED
@@ -1,49 +1,49 @@
1
- <?php
2
- /**
3
- * Accepts file uploads from swfupload.
4
- *
5
- * @package NextGEN-Gallery
6
- * @subpackage Administration
7
- */
8
-
9
- // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
10
- // We then have to validate the cookie manually. NOTE: WordPress functions, like
11
- // get_current_user_id() and the like are NOT available in this file.
12
- if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
13
- $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
14
- elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
15
- $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
16
- if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
17
- $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
18
-
19
- header('Content-Type: text/plain; charset=' . get_option('blog_charset'));
20
-
21
- $logged_in = FALSE;
22
-
23
- if (wp_validate_auth_cookie()) {
24
- $results = wp_parse_auth_cookie();
25
- if (isset($results['username']) && isset($results['expiration'])) {
26
- if (time() < floatval($results['expiration'])) {
27
- if (($userdata = get_user_by('login', $results['username'])))
28
- $logged_in = $userdata->ID;
29
- }
30
- }
31
- }
32
-
33
- if (!$logged_in)
34
- die("Login failure. -1");
35
- else if (!user_can($logged_in, 'NextGEN Upload images'))
36
- die('You do not have permission to upload files. -2');
37
-
38
- //check for nggallery
39
- if ( !defined('NGGALLERY_ABSPATH') )
40
- die('NextCellent Gallery not available. -3');
41
-
42
- include_once (NGGALLERY_ABSPATH. 'admin/functions.php');
43
-
44
- // get the gallery
45
- $galleryID = (int) $_POST['galleryselect'];
46
-
47
- echo nggAdmin::swfupload_image($galleryID);
48
-
49
  ?>
1
+ <?php
2
+ /**
3
+ * Accepts file uploads from swfupload.
4
+ *
5
+ * @package NextGEN-Gallery
6
+ * @subpackage Administration
7
+ */
8
+
9
+ // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
10
+ // We then have to validate the cookie manually. NOTE: WordPress functions, like
11
+ // get_current_user_id() and the like are NOT available in this file.
12
+ if ( is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
13
+ $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
14
+ elseif ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) )
15
+ $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
16
+ if ( empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie']) )
17
+ $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
18
+
19
+ header('Content-Type: text/plain; charset=' . get_option('blog_charset'));
20
+
21
+ $logged_in = FALSE;
22
+
23
+ if (wp_validate_auth_cookie()) {
24
+ $results = wp_parse_auth_cookie();
25
+ if (isset($results['username']) && isset($results['expiration'])) {
26
+ if (time() < floatval($results['expiration'])) {
27
+ if (($userdata = get_user_by('login', $results['username'])))
28
+ $logged_in = $userdata->ID;
29
+ }
30
+ }
31
+ }
32
+
33
+ if (!$logged_in)
34
+ die("Login failure. -1");
35
+ else if (!user_can($logged_in, 'NextGEN Upload images'))
36
+ die('You do not have permission to upload files. -2');
37
+
38
+ //check for nggallery
39
+ if ( !defined('NGGALLERY_ABSPATH') )
40
+ die('NextCellent Gallery not available. -3');
41
+
42
+ include_once (NGGALLERY_ABSPATH. 'admin/functions.php');
43
+
44
+ // get the gallery
45
+ $galleryID = (int) $_POST['galleryselect'];
46
+
47
+ echo nggAdmin::swfupload_image($galleryID);
48
+
49
  ?>
admin/wpmu.php CHANGED
@@ -1,117 +1,117 @@
1
- <?php
2
- if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
-
4
- function nggallery_wpmu_setup() {
5
-
6
- //to be sure
7
- if ( !is_super_admin() )
8
- die('You are not allowed to call this page.');
9
-
10
- $messagetext = '';
11
-
12
- // get the options
13
- $ngg_options = get_site_option('ngg_options');
14
-
15
- if ( isset($_POST['updateoption']) ) {
16
- check_admin_referer('ngg_wpmu_settings');
17
- // get the hidden option fields, taken from WP core
18
- if ( $_POST['page_options'] )
19
- $options = explode(',', stripslashes($_POST['page_options']));
20
- if ($options) {
21
- foreach ($options as $option) {
22
- $option = trim($option);
23
- $value = isset($_POST[$option]) ? trim($_POST[$option]) : false;
24
- // $value = sanitize_option($option, $value); // This does strip slashes on those that need it
25
- $ngg_options[$option] = $value;
26
- }
27
- }
28
-
29
- // the path should always end with a slash
30
- $ngg_options['gallerypath'] = trailingslashit($ngg_options['gallerypath']);
31
- update_site_option('ngg_options', $ngg_options);
32
-
33
- $messagetext = __('Update successfully','nggallery');
34
- }
35
-
36
- // Show donation message only one time.
37
- if (isset ( $_GET['hideSupportInfo']) ) {
38
- $ngg_options['hideSupportInfo'] = true;
39
- update_site_option('ngg_options', $ngg_options);
40
- }
41
-
42
- // message windows
43
- if( !empty($messagetext) ) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$messagetext.'</p></div>'; }
44
-
45
- ?>
46
-
47
- <div class="wrap">
48
- <h2><?php _e('Network Options','nggallery'); ?></h2>
49
- <form name="generaloptions" method="post">
50
- <?php wp_nonce_field('ngg_wpmu_settings') ?>
51
- <input type="hidden" name="page_options" value="gallerypath,wpmuQuotaCheck,wpmuZipUpload,wpmuImportFolder,wpmuStyle,wpmuRoles,wpmuCSSfile" />
52
- <table class="form-table">
53
- <tr valign="top">
54
- <th align="left"><?php _e('Gallery path','nggallery') ?></th>
55
- <td><input type="text" size="50" name="gallerypath" value="<?php echo $ngg_options['gallerypath']; ?>" /><br />
56
- <?php _e('This is the default path for all blogs. With the placeholder %BLOG_ID% you can organize the folder structure better.','nggallery') ?>
57
- <?php echo str_replace('%s', '<code>wp-content/blogs.dir/%BLOG_ID%/files/</code>', __('The default setting should be %s', 'nggallery')); ?>
58
- </td>
59
- </tr>
60
- <tr>
61
- <th valign="top"><?php _e('Enable upload quota check','nggallery') ?>:</th>
62
- <td><input name="wpmuQuotaCheck" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuQuotaCheck']); ?> />
63
- <?php _e('Should work if the gallery is bellow the blog.dir','nggallery') ?>
64
- </td>
65
- </tr>
66
- <tr>
67
- <th valign="top"><?php _e('Enable zip upload option','nggallery') ?>:</th>
68
- <td><input name="wpmuZipUpload" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuZipUpload']); ?> />
69
- <?php _e('Allow users to upload zip folders.','nggallery') ?>
70
- </td>
71
- </tr>
72
- <tr>
73
- <th valign="top"><?php _e('Enable import function','nggallery') ?>:</th>
74
- <td><input name="wpmuImportFolder" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuImportFolder']); ?> />
75
- <?php _e('Allow users to import images folders from the server.','nggallery') ?>
76
- </td>
77
- </tr>
78
- <tr>
79
- <th valign="top"><?php _e('Enable style selection','nggallery') ?>:</th>
80
- <td><input name="wpmuStyle" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuStyle']); ?> />
81
- <?php _e('Allow users to choose a style for the gallery.','nggallery') ?>
82
- </td>
83
- </tr>
84
- <tr>
85
- <th valign="top"><?php _e('Enable roles/capabilities','nggallery') ?>:</th>
86
- <td><input name="wpmuRoles" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuRoles']); ?> />
87
- <?php _e('Allow users to change the roles for other blog authors.','nggallery') ?>
88
- </td>
89
- </tr>
90
- <tr>
91
- <th valign="top"><?php _e('Default style','nggallery') ?>:</th>
92
- <td>
93
- <select name="wpmuCSSfile">
94
- <?php
95
- $csslist = ngg_get_cssfiles();
96
- foreach ($csslist as $key =>$a_cssfile) {
97
- $css_name = $a_cssfile['Name'];
98
- if ($key == $ngg_options['wpmuCSSfile']) {
99
- $file_show = $key;
100
- $selected = " selected='selected'";
101
- }
102
- else $selected = '';
103
- $css_name = esc_attr($css_name);
104
- echo "\n\t<option value=\"$key\" $selected>$css_name</option>";
105
- }
106
- ?>
107
- </select><br />
108
- <?php _e('Choose the default style for the galleries.','nggallery') ?>
109
- </td>
110
- </tr>
111
- </table>
112
- <div class="submit"><input type="submit" name="updateoption" value="<?php _e('Update') ;?>"/></div>
113
- </form>
114
- </div>
115
-
116
- <?php
117
- }
1
+ <?php
2
+ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
3
+
4
+ function nggallery_wpmu_setup() {
5
+
6
+ //to be sure
7
+ if ( !is_super_admin() )
8
+ die('You are not allowed to call this page.');
9
+
10
+ $messagetext = '';
11
+
12
+ // get the options
13
+ $ngg_options = get_site_option('ngg_options');
14
+
15
+ if ( isset($_POST['updateoption']) ) {
16
+ check_admin_referer('ngg_wpmu_settings');
17
+ // get the hidden option fields, taken from WP core
18
+ if ( $_POST['page_options'] )
19
+ $options = explode(',', stripslashes($_POST['page_options']));
20
+ if ($options) {
21
+ foreach ($options as $option) {
22
+ $option = trim($option);
23
+ $value = isset($_POST[$option]) ? trim($_POST[$option]) : false;
24
+ // $value = sanitize_option($option, $value); // This does strip slashes on those that need it
25
+ $ngg_options[$option] = $value;
26
+ }
27
+ }
28
+
29
+ // the path should always end with a slash
30
+ $ngg_options['gallerypath'] = trailingslashit($ngg_options['gallerypath']);
31
+ update_site_option('ngg_options', $ngg_options);
32
+
33
+ $messagetext = __('Update successfully','nggallery');
34
+ }
35
+
36
+ // Show donation message only one time.
37
+ if (isset ( $_GET['hideSupportInfo']) ) {
38
+ $ngg_options['hideSupportInfo'] = true;
39
+ update_site_option('ngg_options', $ngg_options);
40
+ }
41
+
42
+ // message windows
43
+ if( !empty($messagetext) ) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$messagetext.'</p></div>'; }
44
+
45
+ ?>
46
+
47
+ <div class="wrap">
48
+ <h2><?php _e('Network Options','nggallery'); ?></h2>
49
+ <form name="generaloptions" method="post">
50
+ <?php wp_nonce_field('ngg_wpmu_settings') ?>
51
+ <input type="hidden" name="page_options" value="gallerypath,wpmuQuotaCheck,wpmuZipUpload,wpmuImportFolder,wpmuStyle,wpmuRoles,wpmuCSSfile" />
52
+ <table class="form-table">
53
+ <tr valign="top">
54
+ <th align="left"><?php _e('Gallery path','nggallery') ?></th>
55
+ <td><input type="text" size="50" name="gallerypath" value="<?php echo $ngg_options['gallerypath']; ?>" /><br />
56
+ <?php _e('This is the default path for all blogs. With the placeholder %BLOG_ID% you can organize the folder structure better.','nggallery') ?>
57
+ <?php echo str_replace('%s', '<code>wp-content/blogs.dir/%BLOG_ID%/files/</code>', __('The default setting should be %s', 'nggallery')); ?>
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <th valign="top"><?php _e('Enable upload quota check','nggallery') ?>:</th>
62
+ <td><input name="wpmuQuotaCheck" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuQuotaCheck']); ?> />
63
+ <?php _e('Should work if the gallery is bellow the blog.dir','nggallery') ?>
64
+ </td>
65
+ </tr>
66
+ <tr>
67
+ <th valign="top"><?php _e('Enable zip upload option','nggallery') ?>:</th>
68
+ <td><input name="wpmuZipUpload" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuZipUpload']); ?> />
69
+ <?php _e('Allow users to upload zip folders.','nggallery') ?>
70
+ </td>
71
+ </tr>
72
+ <tr>
73
+ <th valign="top"><?php _e('Enable import function','nggallery') ?>:</th>
74
+ <td><input name="wpmuImportFolder" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuImportFolder']); ?> />
75
+ <?php _e('Allow users to import images folders from the server.','nggallery') ?>
76
+ </td>
77
+ </tr>
78
+ <tr>
79
+ <th valign="top"><?php _e('Enable style selection','nggallery') ?>:</th>
80
+ <td><input name="wpmuStyle" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuStyle']); ?> />
81
+ <?php _e('Allow users to choose a style for the gallery.','nggallery') ?>
82
+ </td>
83
+ </tr>
84
+ <tr>
85
+ <th valign="top"><?php _e('Enable roles/capabilities','nggallery') ?>:</th>
86
+ <td><input name="wpmuRoles" type="checkbox" value="1" <?php checked('1', $ngg_options['wpmuRoles']); ?> />
87
+ <?php _e('Allow users to change the roles for other blog authors.','nggallery') ?>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <th valign="top"><?php _e('Default style','nggallery') ?>:</th>
92
+ <td>
93
+ <select name="wpmuCSSfile">
94
+ <?php
95
+ $csslist = ngg_get_cssfiles();
96
+ foreach ($csslist as $key =>$a_cssfile) {
97
+ $css_name = $a_cssfile['Name'];
98
+ if ($key == $ngg_options['wpmuCSSfile']) {
99
+ $file_show = $key;
100
+ $selected = " selected='selected'";
101
+ }
102
+ else $selected = '';
103
+ $css_name = esc_attr($css_name);
104
+ echo "\n\t<option value=\"$key\" $selected>$css_name</option>";
105
+ }
106
+ ?>
107
+ </select><br />
108
+ <?php _e('Choose the default style for the galleries.','nggallery') ?>
109
+ </td>
110
+ </tr>
111
+ </table>
112
+ <div class="submit"><input type="submit" name="updateoption" value="<?php _e('Update') ;?>"/></div>
113
+ </form>
114
+ </div>
115
+
116
+ <?php
117
+ }
changelog.txt CHANGED
@@ -1,5 +1,5 @@
1
- NextCellent Gallery
2
- by WPReady
3
-
4
- = V1.9.14 - 01.09.2013 =
5
- * NEW: Deactivate if NextGen is installed and activated
1
+ NextCellent Gallery
2
+ by WPReady
3
+
4
+ = V1.9.14 - 01.09.2013 =
5
+ * NEW: Deactivate if NextGen is installed and activated
css/Black_Minimalism.css CHANGED
@@ -1,375 +1,375 @@
1
- /*
2
- CSS Name: Black Minimalism Theme
3
- Description: For Black Minimalism Theme
4
- Author: Alex Rabe
5
- Version: 1.60
6
-
7
- This is a template stylesheet that can be used with NextGEN Gallery. I tested the
8
- styles with a default theme Kubrick. Modify it when your theme struggle with it,
9
- it's only a template design
10
-
11
- */
12
-
13
- /* ----------- Album Styles Extend -------------*/
14
-
15
- .ngg-albumoverview {
16
- margin-top: 10px;
17
- width: 100%;
18
- clear:both;
19
- display:block !important;
20
- }
21
-
22
- .ngg-album {
23
- /*height: 130px;*/
24
- overflow:hidden;
25
- padding: 5px;
26
- margin-bottom: 5px;
27
- border: 1px solid #cccccc;
28
- }
29
-
30
- .ngg-albumtitle {
31
- text-align: left;
32
- font-weight: bold;
33
- margin:0px;
34
- padding:0px;
35
- font-size: 1.4em;
36
- margin-bottom: 10px;
37
- }
38
-
39
- .ngg-thumbnail {
40
- float: left;
41
- margin: 0pt !important;
42
- margin-right: 12px !important;
43
- }
44
-
45
- .ngg-thumbnail img {
46
- background-color:#FFFFFF;
47
- border:1px solid #A9A9A9;
48
- margin:4px 0px 4px 5px;
49
- padding:4px;
50
- position:relative;
51
- }
52
-
53
- .ngg-thumbnail img:hover {
54
- background-color: #A9A9A9;
55
- }
56
-
57
- .ngg-description {
58
- text-align: left;
59
- }
60
-
61
- /* ----------- Album Styles Compact -------------*/
62
-
63
- .ngg-album-compact {
64
- float:left;
65
- height:180px;
66
- padding-right:6px !important;
67
- margin:0px !important;
68
- text-align:left;
69
- width:120px;
70
- }
71
-
72
- .ngg-album-compactbox {
73
- background:transparent url(albumset.gif) no-repeat scroll 0%;
74
- height:86px;
75
- margin:0pt 0pt 6px !important;
76
- padding:12px 0pt 0pt 7px !important;
77
- width:120px;
78
- }
79
-
80
-
81
- .ngg-album-compactbox .Thumb {
82
- border:1px solid #000000;
83
- margin:0px !important;
84
- padding:0px !important;
85
- width:91px;
86
- height:68px;
87
- }
88
-
89
- .ngg-album-compact h4 {
90
- font-size:15px;
91
- font-weight:bold;
92
- margin-bottom:0px;
93
- margin-top:0px;
94
- width:110px;
95
- }
96
-
97
- .ngg-album-compact p {
98
- font-size:11px;
99
- margin-top:2px;
100
- }
101
-
102
- /* ----------- Gallery style -------------*/
103
-
104
- .ngg-galleryoverview {
105
- overflow: hidden;
106
- margin-top: 10px;
107
- width: 100%;
108
- clear:both;
109
- display:block !important;
110
- }
111
-
112
- .ngg-gallery-thumbnail-box {
113
- float: left;
114
- width: 20%;
115
- }
116
-
117
- .ngg-gallery-thumbnail {
118
- float: left;
119
- background: url(shadowAlpha.png) no-repeat bottom right !important;
120
- background: url(shadow.gif) no-repeat bottom right;
121
- margin: 10px 0 0 10px !important;
122
- }
123
-
124
- .ngg-gallery-thumbnail img {
125
- margin: -6px 6px 6px -6px;
126
- background-color:#FFFFFF;
127
- border:1px solid #A9A9A9;
128
- display:block;
129
- padding:4px;
130
- position:relative;
131
- }
132
-
133
- .ngg-gallery-thumbnail img:hover {
134
- background-color: #A9A9A9;
135
- }
136
-
137
- .ngg-gallery-thumbnail span {
138
- /* Images description */
139
- font-size:90%;
140
- padding-left:5px;
141
- display:block;
142
- }
143
-
144
- .ngg-clear {
145
- clear: both;
146
- }
147
-
148
- /* ----------- Gallery navigation -------------*/
149
-
150
- .ngg-navigation {
151
- font-size:0.9em !important;
152
- clear:both !important;
153
- display:block !important;
154
- padding-top:15px;
155
- text-align:center;
156
- }
157
-
158
- .ngg-navigation span {
159
- font-weight:bold;
160
- margin:0pt 6px;
161
- }
162
-
163
- .ngg-navigation a.page-numbers,
164
- .ngg-navigation a.next,
165
- .ngg-navigation a.prev,
166
- .ngg-navigation span.page-numbers,
167
- .ngg-navigation span.next,
168
- .ngg-navigation span.prev {
169
- border:1px solid #660000;
170
- margin-right:3px;
171
- padding:3px 7px;
172
- }
173
-
174
- .ngg-navigation a.page-numbers:hover,
175
- .ngg-navigation a.next:hover,
176
- .ngg-navigation a.prev:hover,
177
- .ngg-navigation span.page-numbers:hover,
178
- .ngg-navigation span.next:hover,
179
- .ngg-navigation span.prev:hover {
180
- background-color: #660000;
181
- color: #FFFFFF;
182
- text-decoration: none;
183
- }
184
-
185
- /* ----------- Image browser style -------------*/
186
-
187
- .ngg-imagebrowser {
188
-
189
- }
190
-
191
- .ngg-imagebrowser h3 {
192
- text-align:center;
193
- }
194
-
195
- .ngg-imagebrowser img {
196
- border:1px solid #A9A9A9;
197
- margin-top: 10px;
198
- margin-bottom: 10px;
199
- width: 100%;
200
- display:block !important;
201
- padding:5px;
202
- }
203
-
204
- .ngg-imagebrowser-nav {
205
- padding:5px;
206
- margin-left:10px;
207
- }
208
-
209
- .ngg-imagebrowser-nav .back {
210
- float:left;
211
- border:1px solid #DDDDDD;
212
- margin-right:3px;
213
- padding:3px 7px;
214
- }
215
-
216
- .ngg-imagebrowser-nav .next {
217
- float:right;
218
- border:1px solid #DDDDDD;
219
- margin-right:3px;
220
- padding:3px 7px;
221
- }
222
-
223
- .ngg-imagebrowser-nav .counter {
224
- text-align:center;
225
- font-size:0.9em !important;
226
- }
227
-
228
- .exif-data {
229
- margin-left: auto !important;
230
- margin-right: auto !important;
231
- }
232
-
233
- /* ----------- Slideshow -------------*/
234
- .slideshow {
235
- margin-left: auto;
236
- margin-right: auto;
237
- text-align:center;
238
- outline: none;
239
- }
240
-
241
- .slideshowlink {
242
-
243
- }
244
-
245
- /* ----------- JS Slideshow -------------*/
246
- .ngg-slideshow {
247
- overflow:hidden;
248
- position: relative;
249
- }
250
-
251
- .ngg-slideshow * {
252
- vertical-align:middle;
253
- }
254
-
255
- /* See also : http://www.brunildo.org/test/img_center.html */
256
- .ngg-slideshow-loader{
257
- display: table-cell;
258
- text-align: center;
259
- vertical-align:middle;
260
- }
261
-
262
- .ngg-slideshow-loader img{
263
- background: none !important;
264
- border: 0 none !important;
265
- margin:auto !important;
266
- }
267
-
268
- /* ----------- Single picture -------------*/
269
- .ngg-singlepic {
270
- display:block;
271
- padding:4px;
272
- }
273
-
274
- .ngg-left {
275
- float: left;
276
- margin-right:10px;
277
- }
278
-
279
- .ngg-right {
280
- float: right;
281
- margin-left:10px;
282
- }
283
-
284
- .ngg-center {
285
- margin-left: auto !important;
286
- margin-right: auto !important;
287
- }
288
-
289
- /* ----------- Sidebar widget -------------*/
290
- .ngg-widget,
291
- .ngg-widget-slideshow {
292
- overflow: hidden;
293
- margin:0pt;
294
- padding:5px 0px 0px 0pt;
295
- }
296
-
297
- .ngg-widget img {
298
- border:2px solid #A9A9A9;
299
- margin:0pt 2px 2px 0px;
300
- padding:1px;
301
- }
302
-
303
- /* ----------- Related images -------------*/
304
- .ngg-related-gallery {
305
- background:#F9F9F9;
306
- border:1px solid #E0E0E0;
307
- overflow:hidden;
308
- margin-bottom:1em;
309
- margin-top:1em;
310
- padding:5px;
311
- }
312
- .ngg-related-gallery img {
313
- border: 1px solid #DDDDDD;
314
- float: left;
315
- margin: 0pt 2px;
316
- padding: 2px;
317
- height: 50px;
318
- width: 50px;
319
- }
320
-
321
- .ngg-related-gallery img:hover {
322
- border: 1px solid #000000;
323
- }
324
-
325
- /* ----------- Gallery list -------------*/
326
-
327
- .ngg-galleryoverview ul li:before {
328
- content: '' !important;
329
- }
330
-
331
- .ngg-gallery-list {
332
- list-style-type:none;
333
- padding: 0px !important;
334
- text-indent:0px !important;
335
- }
336
-
337
- .ngg-galleryoverview div.pic img{
338
- width: 100%;
339
- }
340
-
341
- .ngg-gallery-list li {
342
- float:left;
343
- margin:0 2px 0px 2px !important;
344
- overflow:hidden;
345
- }
346
-
347
- .ngg-gallery-list li a {
348
- border:1px solid #CCCCCC;
349
- display:block;
350
- padding:2px;
351
- }
352
-
353
- .ngg-gallery-list li.selected a{
354
- -moz-background-clip:border;
355
- -moz-background-inline-policy:continuous;
356
- -moz-background-origin:padding;
357
- background:#000000 none repeat scroll 0 0;
358
- }
359
-
360
- .ngg-gallery-list li img {
361
- height:40px;
362
- width:40px;
363
- }
364
-
365
- li.ngg-next, li.ngg-prev {
366
- height:40px;
367
- width:40px;
368
- font-size:3.5em;
369
- }
370
-
371
- li.ngg-next a, li.ngg-prev a {
372
- padding-top: 10px;
373
- border: none;
374
- text-decoration: none;
375
  }
1
+ /*
2
+ CSS Name: Black Minimalism Theme
3
+ Description: For Black Minimalism Theme
4
+ Author: Alex Rabe
5
+ Version: 1.60
6
+
7
+ This is a template stylesheet that can be used with NextGEN Gallery. I tested the
8
+ styles with a default theme Kubrick. Modify it when your theme struggle with it,
9
+ it's only a template design
10
+
11
+ */
12
+
13
+ /* ----------- Album Styles Extend -------------*/
14
+
15
+ .ngg-albumoverview {
16
+ margin-top: 10px;
17
+ width: 100%;
18
+ clear:both;
19
+ display:block !important;
20
+ }
21
+
22
+ .ngg-album {
23
+ /*height: 130px;*/
24
+ overflow:hidden;
25
+ padding: 5px;
26
+ margin-bottom: 5px;
27
+ border: 1px solid #cccccc;
28
+ }
29
+
30
+ .ngg-albumtitle {
31
+ text-align: left;
32
+ font-weight: bold;
33
+ margin:0px;
34
+ padding:0px;
35
+ font-size: 1.4em;
36
+ margin-bottom: 10px;
37
+ }
38
+
39
+ .ngg-thumbnail {
40
+ float: left;
41
+ margin: 0pt !important;
42
+ margin-right: 12px !important;
43
+ }
44
+
45
+ .ngg-thumbnail img {
46
+ background-color:#FFFFFF;
47
+ border:1px solid #A9A9A9;
48
+ margin:4px 0px 4px 5px;
49
+ padding:4px;
50
+ position:relative;
51
+ }
52
+
53
+ .ngg-thumbnail img:hover {
54
+ background-color: #A9A9A9;
55
+ }
56
+
57
+ .ngg-description {
58
+ text-align: left;
59
+ }
60
+
61
+ /* ----------- Album Styles Compact -------------*/
62
+
63
+ .ngg-album-compact {
64
+ float:left;
65
+ height:180px;
66
+ padding-right:6px !important;
67
+ margin:0px !important;
68
+ text-align:left;
69
+ width:120px;
70
+ }
71
+
72
+ .ngg-album-compactbox {
73
+ background:transparent url(albumset.gif) no-repeat scroll 0%;
74
+ height:86px;
75
+ margin:0pt 0pt 6px !important;
76
+ padding:12px 0pt 0pt 7px !important;
77
+ width:120px;
78
+ }
79
+
80
+
81
+ .ngg-album-compactbox .Thumb {
82
+ border:1px solid #000000;
83
+ margin:0px !important;
84
+ padding:0px !important;
85
+ width:91px;
86
+ height:68px;
87
+ }
88
+
89
+ .ngg-album-compact h4 {
90
+ font-size:15px;
91
+ font-weight:bold;
92
+ margin-bottom:0px;
93
+ margin-top:0px;
94
+ width:110px;
95
+ }
96
+
97
+ .ngg-album-compact p {
98
+ font-size:11px;
99
+ margin-top:2px;
100
+ }
101
+
102
+ /* ----------- Gallery style -------------*/
103
+
104
+ .ngg-galleryoverview {
105
+ overflow: hidden;
106
+ margin-top: 10px;
107
+ width: 100%;
108
+ clear:both;
109
+ display:block !important;
110
+ }
111
+
112
+ .ngg-gallery-thumbnail-box {
113
+ float: left;
114
+ width: 20%;
115
+ }
116
+
117
+ .ngg-gallery-thumbnail {
118
+ float: left;
119
+ background: url(shadowAlpha.png) no-repeat bottom right !important;
120
+ background: url(shadow.gif) no-repeat bottom right;
121
+ margin: 10px 0 0 10px !important;
122
+ }
123
+
124
+ .ngg-gallery-thumbnail img {
125
+ margin: -6px 6px 6px -6px;
126
+ background-color:#FFFFFF;
127
+ border:1px solid #A9A9A9;
128
+ display:block;
129
+ padding:4px;
130
+ position:relative;
131
+ }
132
+
133
+ .ngg-gallery-thumbnail img:hover {
134
+ background-color: #A9A9A9;
135
+ }
136
+
137
+ .ngg-gallery-thumbnail span {
138
+ /* Images description */
139
+ font-size:90%;
140
+ padding-left:5px;
141
+ display:block;
142
+ }
143
+
144
+ .ngg-clear {
145
+ clear: both;
146
+ }
147
+
148
+ /* ----------- Gallery navigation -------------*/
149
+
150
+ .ngg-navigation {
151
+ font-size:0.9em !important;
152
+ clear:both !important;
153
+ display:block !important;
154
+ padding-top:15px;
155
+ text-align:center;
156
+ }
157
+
158
+ .ngg-navigation span {
159
+ font-weight:bold;
160
+ margin:0pt 6px;
161
+ }
162
+
163
+ .ngg-navigation a.page-numbers,
164
+ .ngg-navigation a.next,
165
+ .ngg-navigation a.prev,
166
+ .ngg-navigation span.page-numbers,
167
+ .ngg-navigation span.next,
168
+ .ngg-navigation span.prev {
169
+ border:1px solid #660000;
170
+ margin-right:3px;
171
+ padding:3px 7px;
172
+ }
173
+
174
+ .ngg-navigation a.page-numbers:hover,
175
+ .ngg-navigation a.next:hover,
176
+ .ngg-navigation a.prev:hover,
177
+ .ngg-navigation span.page-numbers:hover,
178
+ .ngg-navigation span.next:hover,
179
+ .ngg-navigation span.prev:hover {
180
+ background-color: #660000;
181
+ color: #FFFFFF;
182
+ text-decoration: none;
183
+ }
184
+
185
+ /* ----------- Image browser style -------------*/
186
+
187
+ .ngg-imagebrowser {
188
+
189
+ }
190
+
191
+ .ngg-imagebrowser h3 {
192
+ text-align:center;
193
+ }
194
+
195
+ .ngg-imagebrowser img {
196
+ border:1px solid #A9A9A9;
197
+ margin-top: 10px;
198
+ margin-bottom: 10px;
199
+ width: 100%;
200
+ display:block !important;
201
+ padding:5px;
202
+ }
203
+
204
+ .ngg-imagebrowser-nav {
205
+ padding:5px;
206
+ margin-left:10px;
207
+ }
208
+
209
+ .ngg-imagebrowser-nav .back {
210
+ float:left;
211
+ border:1px solid #DDDDDD;
212
+ margin-right:3px;
213
+ padding:3px 7px;
214
+ }
215
+
216
+ .ngg-imagebrowser-nav .next {
217
+ float:right;
218
+ border:1px solid #DDDDDD;
219
+ margin-right:3px;
220
+ padding:3px 7px;
221
+ }
222
+
223
+ .ngg-imagebrowser-nav .counter {
224
+ text-align:center;
225
+ font-size:0.9em !important;
226
+ }
227
+
228
+ .exif-data {
229
+ margin-left: auto !important;
230
+ margin-right: auto !important;
231
+ }
232
+
233
+ /* ----------- Slideshow -------------*/
234
+ .slideshow {
235
+ margin-left: auto;
236
+ margin-right: auto;
237
+ text-align:center;
238
+ outline: none;
239
+ }
240
+
241
+ .slideshowlink {
242
+
243
+ }
244
+
245
+ /* ----------- JS Slideshow -------------*/
246
+ .ngg-slideshow {
247
+ overflow:hidden;
248
+ position: relative;
249
+ }
250
+
251
+ .ngg-slideshow * {
252
+ vertical-align:middle;
253
+ }
254
+
255
+ /* See also : http://www.brunildo.org/test/img_center.html */
256
+ .ngg-slideshow-loader{
257
+ display: table-cell;
258
+ text-align: center;
259
+ vertical-align:middle;
260
+ }
261
+
262
+ .ngg-slideshow-loader img{
263
+ background: none !important;
264
+ border: 0 none !important;
265
+ margin:auto !important;
266
+ }
267
+
268
+ /* ----------- Single picture -------------*/
269
+ .ngg-singlepic {
270
+ display:block;
271
+ padding:4px;
272
+ }
273
+
274
+ .ngg-left {
275
+ float: left;
276
+ margin-right:10px;
277
+ }
278
+
279
+ .ngg-right {
280
+ float: right;
281
+ margin-left:10px;
282
+ }
283
+
284
+ .ngg-center {
285
+ margin-left: auto !important;
286
+ margin-right: auto !important;
287
+ }
288
+
289
+ /* ----------- Sidebar widget -------------*/
290
+ .ngg-widget,
291
+ .ngg-widget-slideshow {
292
+ overflow: hidden;
293
+ margin:0pt;
294
+ padding:5px 0px 0px 0pt;
295
+ }
296
+
297
+ .ngg-widget img {
298
+ border:2px solid #A9A9A9;
299
+ margin:0pt 2px 2px 0px;
300
+ padding:1px;
301
+ }
302
+
303
+ /* ----------- Related images -------------*/
304
+ .ngg-related-gallery {
305
+ background:#F9F9F9;
306
+ border:1px solid #E0E0E0;
307
+ overflow:hidden;
308
+ margin-bottom:1em;
309
+ margin-top:1em;
310
+ padding:5px;
311
+ }
312
+ .ngg-related-gallery img {
313
+ border: 1px solid #DDDDDD;
314
+ float: left;
315
+ margin: 0pt 2px;
316
+ padding: 2px;
317
+ height: 50px;
318
+ width: 50px;
319
+ }
320
+
321
+ .ngg-related-gallery img:hover {
322
+ border: 1px solid #000000;
323
+ }
324
+
325
+ /* ----------- Gallery list -------------*/
326
+
327
+ .ngg-galleryoverview ul li:before {
328
+ content: '' !important;
329
+ }
330
+
331
+ .ngg-gallery-list {
332
+ list-style-type:none;
333
+ padding: 0px !important;
334
+ text-indent:0px !important;
335
+ }
336
+
337
+ .ngg-galleryoverview div.pic img{
338
+ width: 100%;
339
+ }
340
+
341
+ .ngg-gallery-list li {
342
+ float:left;
343
+ margin:0 2px 0px 2px !important;
344
+ overflow:hidden;
345
+ }
346
+
347
+ .ngg-gallery-list li a {
348
+ border:1px solid #CCCCCC;
349
+ display:block;
350
+ padding:2px;
351
+ }
352
+
353
+ .ngg-gallery-list li.selected a{
354
+ -moz-background-clip:border;
355
+ -moz-background-inline-policy:continuous;
356
+ -moz-background-origin:padding;
357
+ background:#000000 none repeat scroll 0 0;
358
+ }
359
+
360
+ .ngg-gallery-list li img {
361
+ height:40px;
362
+ width:40px;
363
+ }
364
+
365
+ li.ngg-next, li.ngg-prev {
366
+ height:40px;
367
+ width:40px;
368
+ font-size:3.5em;
369
+ }
370
+
371
+ li.ngg-next a, li.ngg-prev a {
372
+ padding-top: 10px;
373
+ border: none;
374
+ text-decoration: none;
375
  }
css/hovereffect.css CHANGED
@@ -1,425 +1,425 @@
1
- /*
2
- CSS Name: Hovereffect Styles
3
- Description: Hover Stylesheet based on the idea of Hoverbox from http://host.sonspring.com/hoverbox/
4
- Author: Alex Rabe - Orginal by Nathan Smith
5
- Version: 1.60
6
-
7
- This is a template stylesheet which doesn't support description below the thumbnails. It's a experimental version.
8
-
9
- */
10
-
11
- /* ----------- Album Styles Extend -------------*/
12
-
13
- .ngg-albumoverview {
14
- margin-top: 10px;
15
- width: 100%;
16
- clear:both;
17
- display:block !important;
18
- }
19
-
20
- .ngg-album {
21
- overflow: hidden;
22
- padding: 5px;
23
- margin-bottom: 5px;
24
- }
25
-
26
- .ngg-albumtitle {
27
- border-bottom:1px dashed #AAAAAA;
28
- text-align: left;
29
- font-weight: bold;
30
- margin:0px;
31
- padding-bottom: 3px;
32
- font-size: 1.4em;
33
- margin-bottom: 10px;
34
- }
35
-
36
- .ngg-thumbnail {
37
- float: left;
38
- margin-right: 12px;
39
- background:#EEEEEE none repeat scroll 0% 50%;
40
- border-color:#DDDDDD rgb(187, 187, 187) rgb(170, 170, 170) rgb(204, 204, 204);
41
- border-style:solid;
42
- border-width:1px;
43
- color:inherit;
44
- margin-right: 5px;
45
- padding:5px;
46
- }
47
-
48
- .ngg-thumbnail img {
49
- filter: alpha(opacity=100);
50
- -moz-opacity: .99;
51
- opacity: .99;
52
- background:#FFFFFF none repeat scroll 0%;
53
- border-color:#AAAAAA rgb(204, 204, 204) rgb(221, 221, 221) rgb(187, 187, 187);
54
- border-style:solid;
55
- border-width:1px;
56
- color:inherit;
57
- padding:2px;
58
- vertical-align:top;
59
- }
60
-
61
- .ngg-thumbnail img:hover {
62
- filter: alpha(opacity=90);
63
- -moz-opacity: .9;
64
- opacity: .9;
65
- border-color:#000000;
66
- }
67
-
68
- .ngg-description {
69
- text-align: left;
70
- }
71
-
72
- /* ----------- Album Styles Compact -------------*/
73
-
74
- .ngg-album-compact {
75
- float:left;
76
- height:180px;
77
- padding-right:6px !important;
78
- margin:0px !important;
79
- text-align:left;
80
- width:120px;
81
- }
82
-
83
- .ngg-album-compactbox {
84
- background:transparent url(albumset.gif) no-repeat scroll 0%;
85
- height:86px;
86
- margin:0pt 0pt 6px !important;
87
- padding:12px 0pt 0pt 7px !important;
88
- width:120px;
89
- }
90
-
91
-
92
- .ngg-album-compactbox .Thumb {
93
- border:1px solid #000000;
94
- margin:0px !important;
95
- padding:0px !important;
96
- width:91px;
97
- height:68px;
98
- }
99
-
100
- .ngg-album-compact h4 {
101
- font-size:15px;
102
- font-weight:bold;
103
- margin-bottom:0px;
104
- margin-top:0px;
105
- width:110px;
106
- }
107
-
108
- .ngg-album-compact p {
109
- font-size:11px;
110
- margin-top:2px;
111
- }
112
-
113
- /* ----------- Gallery style -------------*/
114
-
115
- .ngg-galleryoverview {
116
- overflow: hidden;
117
- margin-top: 10px;
118
- width: 100%;
119
- clear:both;
120
- display:block !important;
121
- }
122
-
123
- .ngg-gallery-thumbnail-box {
124
- float: left;
125
- background:#EEEEEE none repeat scroll 0% 50%;
126
- border-color:#DDDDDD rgb(187, 187, 187) rgb(170, 170, 170) rgb(204, 204, 204);
127
- border-style:solid;
128
- border-width:1px;
129
- color:inherit;
130
- display:inline;
131
- margin:3px;
132
- padding:5px;
133
- position:relative;
134
- }
135
-
136
- .ngg-gallery-thumbnail {
137
- float: left;
138
- }
139
-
140
- .ngg-gallery-thumbnail img {
141
- filter: alpha(opacity=100);
142
- -moz-opacity: .99;
143
- opacity: .99;
144
- background:#FFFFFF none repeat scroll 0%;
145
- border-color:#AAAAAA rgb(204, 204, 204) rgb(221, 221, 221) rgb(187, 187, 187);
146
- border-style:solid;
147
- border-width:1px;
148
- color:inherit;
149
- padding:2px;
150
- vertical-align:top;
151
- }
152
-
153
- .ngg-gallery-thumbnail img:hover {
154
- filter: alpha(opacity=90);
155
- -moz-opacity: .9;
156
- opacity: .9;
157
- border-color:#000000;
158
- }
159
-
160
- .ngg-gallery-thumbnail span {
161
- /* Images description */
162
- font-size:90%;
163
- padding-left:5px;
164
- display:block;
165
- }
166
-
167
- .ngg-clear {
168
- clear: both;
169
- }
170
-
171
- /* ----------- Gallery navigation -------------*/
172
-
173
- .ngg-navigation {
174
- font-size:0.9em !important;
175
- clear:both !important;
176
- display:block !important;
177
- padding-top:15px;
178
- text-align:center;
179
-
180
- }
181
-
182
- .ngg-navigation span {
183
- font-weight:bold;
184
- margin:0pt 6px;
185
- }
186
-
187
- .ngg-navigation a.page-numbers,
188
- .ngg-navigation a.next,
189
- .ngg-navigation a.prev,
190
- .ngg-navigation span.page-numbers,
191
- .ngg-navigation span.next,
192
- .ngg-navigation span.prev {
193
- border:1px solid #DDDDDD;
194
- margin-right:3px;
195
- padding:3px 7px;
196
- }
197
-
198
- .ngg-navigation a.page-numbers:hover,
199
- .ngg-navigation a.next:hover,
200
- .ngg-navigation a.prev:hover,
201
- .ngg-navigation span.page-numbers:hover,
202
- .ngg-navigation span.next:hover,
203
- .ngg-navigation span.prev:hover {
204
- background-color: #0066CC;
205
- color: #FFFFFF !important;
206
- text-decoration: none !important;
207
- }
208
-
209
- /* ----------- Image browser style -------------*/
210
-
211
- .ngg-imagebrowser {
212
-
213
- }
214
-
215
- .ngg-imagebrowser h3 {
216
- text-align:center;
217
- padding-bottom:10px;
218
- }
219
-
220
- .ngg-imagebrowser .pic {
221
- background:#EEEEEE none repeat scroll 0% 50%;
222
- border-color:#DDDDDD rgb(187, 187, 187) rgb(170, 170, 170) rgb(204, 204, 204);
223
- border-style:solid;
224
- border-width:1px;
225
- color:inherit;
226
- display:block;
227
- padding:10px;
228
- }
229
-
230
- .ngg-imagebrowser img {
231
- width: 100%;
232
- margin: -3px;
233
- background:#FFFFFF none repeat scroll 0%;
234
- border-color:#AAAAAA rgb(204, 204, 204) rgb(221, 221, 221) rgb(187, 187, 187);
235
- border-style:solid;
236
- border-width:1px;
237
- color:inherit;
238
- padding:2px;
239
- vertical-align:top;
240
- }
241
-
242
- .ngg-imagebrowser-nav {
243
- padding:10px;
244
- margin-left:10px;
245
-
246
- }
247
-
248
- .ngg-imagebrowser-nav .back {
249
- float:left;
250
- border:1px solid #DDDDDD;
251
- margin-right:3px;
252
- padding:3px 7px;
253
- }
254
-
255
- .ngg-imagebrowser-nav .next {
256
- float:right;
257
- border:1px solid #DDDDDD;
258
- margin-right:3px;
259
- padding:3px 7px;
260
- }
261
-
262
- .ngg-imagebrowser-nav .back:hover,
263
- .ngg-imagebrowser-nav .next:hover {
264
- border:1px solid #000000;
265
- }
266
-
267
- .ngg-imagebrowser-nav .back a:hover,
268
- .ngg-imagebrowser-nav .next a:hover {
269
- text-decoration: none !important;
270
- }
271
-
272
- .ngg-imagebrowser-nav .counter {
273
- text-align:center;
274
- font-size:0.9em !important;
275
- }
276
-
277
- .exif-data {
278
- margin-left: auto !important;
279
- margin-right: auto !important;
280
- }
281
-
282
- /* ----------- Slideshow -------------*/
283
- .slideshow {
284
- margin-left: auto;
285
- margin-right: auto;
286
- text-align:center;
287
- outline: none;
288
- }
289
-
290
- .slideshowlink {
291
-
292
- }
293
-
294
- /* ----------- JS Slideshow -------------*/
295
- .ngg-slideshow {
296
- overflow:hidden;
297
- position: relative;
298
- }
299
-
300
- .ngg-slideshow * {
301
- vertical-align:middle;
302
- }
303
-
304
- /* See also : http://www.brunildo.org/test/img_center.html */
305
- .ngg-slideshow-loader{
306
- display: table-cell;
307
- text-align: center;
308
- vertical-align:middle;
309
- }
310
-
311
- .ngg-slideshow-loader img{
312
- background: none !important;
313
- border: 0 none !important;
314
- margin:auto !important;
315
- }
316
-
317
- /* ----------- Single picture -------------*/
318
- .ngg-singlepic {
319
- background-color:#FFFFFF;
320
- display:block;
321
- padding:4px;
322
- }
323
-
324
- .ngg-left {
325
- float: left;
326
- margin-right:10px;
327
- }
328
-
329
- .ngg-right {
330
- float: right;
331
- margin-left:10px;
332
- }
333
-
334
- .ngg-center {
335
- margin-left: auto !important;
336
- margin-right: auto !important;
337
- }
338
-
339
- /* ----------- Sidebar widget -------------*/
340
- .ngg-widget,
341
- .ngg-widget-slideshow {
342
- overflow: hidden;
343
- margin:0pt;
344
- padding:5px 0px 0px 0pt;
345
- }
346
-
347
- .ngg-widget img {
348
- border:2px solid #A9A9A9;
349
- margin:0pt 2px 2px 0px;
350
- padding:1px;
351
- }
352
-
353
- /* ----------- Related images -------------*/
354
- .ngg-related-gallery {
355
- background:#F9F9F9;
356
- border:1px solid #E0E0E0;
357
- overflow:hidden;
358
- margin-bottom:1em;
359
- margin-top:1em;
360
- padding:5px;
361
- }
362
- .ngg-related-gallery img {
363
- border: 1px solid #DDDDDD;
364
- float: left;
365
- margin: 0pt 3px;
366
- padding: 2px;
367
- height: 50px;
368
- width: 50px;
369
- }
370
-
371
- .ngg-related-gallery img:hover {
372
- border: 1px solid #000000;
373
- }
374
-
375
- /* ----------- Gallery list -------------*/
376
-
377
- .ngg-galleryoverview ul li:before {
378
- content: '' !important;
379
- }
380
-
381
- .ngg-gallery-list {
382
- list-style-type:none;
383
- padding: 0px !important;
384
- text-indent:0px !important;
385
- }
386
-
387
- .ngg-galleryoverview div.pic img{
388
- width: 100%;
389
- }
390
-
391
- .ngg-gallery-list li {
392
- float:left;
393
- margin:0 2px 0px 2px !important;
394
- overflow:hidden;
395
- }
396
-
397
- .ngg-gallery-list li a {
398
- border:1px solid #CCCCCC;
399
- display:block;
400
- padding:2px;
401
- }
402
-
403
- .ngg-gallery-list li.selected a{
404
- -moz-background-clip:border;
405
- -moz-background-inline-policy:continuous;
406
- -moz-background-origin:padding;
407
- background:#000000 none repeat scroll 0 0;
408
- }
409
-
410
- .ngg-gallery-list li img {
411
- height:40px;
412
- width:40px;
413
- }
414
-
415
- li.ngg-next, li.ngg-prev {
416
- height:40px;
417
- width:40px;
418
- font-size:3.5em;
419
- }
420
-
421
- li.ngg-next a, li.ngg-prev a {
422
- padding-top: 10px;
423
- border: none;
424
- text-decoration: none;
425
  }
1
+ /*
2
+ CSS Name: Hovereffect Styles
3
+ Description: Hover Stylesheet based on the idea of Hoverbox from http://host.sonspring.com/hoverbox/
4
+ Author: Alex Rabe - Orginal by Nathan Smith
5
+ Version: 1.60
6
+
7
+ This is a template stylesheet which doesn't support description below the thumbnails. It's a experimental version.
8
+
9
+ */
10
+
11
+ /* ----------- Album Styles Extend -------------*/
12
+
13
+ .ngg-albumoverview {
14
+ margin-top: 10px;
15
+ width: 100%;
16
+ clear:both;
17
+ display:block !important;
18
+ }
19
+
20
+ .ngg-album {
21
+ overflow: hidden;
22
+ padding: 5px;
23
+ margin-bottom: 5px;
24
+ }
25
+
26
+ .ngg-albumtitle {
27
+ border-bottom:1px dashed #AAAAAA;
28
+ text-align: left;
29
+ font-weight: bold;
30
+ margin:0px;
31
+ padding-bottom: 3px;
32
+ font-size: 1.4em;
33
+ margin-bottom: 10px;
34
+ }
35
+
36
+ .ngg-thumbnail {
37
+ float: left;
38
+ margin-right: 12px;
39
+ background:#EEEEEE none repeat scroll 0% 50%;
40
+ border-color:#DDDDDD rgb(187, 187, 187) rgb(170, 170, 170) rgb(204, 204, 204);
41
+ border-style:solid;
42
+ border-width:1px;
43
+ color:inherit;
44
+ margin-right: 5px;
45
+ padding:5px;
46
+ }
47
+
48
+ .ngg-thumbnail img {
49
+ filter: alpha(opacity=100);
50
+ -moz-opacity: .99;
51
+ opacity: .99;
52
+ background:#FFFFFF none repeat scroll 0%;
53
+ border-color:#AAAAAA rgb(204, 204, 204) rgb(221, 221, 221) rgb(187, 187, 187);
54
+ border-style:solid;
55
+ border-width:1px;
56
+ color:inherit;
57
+ padding:2px;
58
+ vertical-align:top;
59
+ }
60
+
61
+ .ngg-thumbnail img:hover {
62
+ filter: alpha(opacity=90);
63
+ -moz-opacity: .9;
64
+ opacity: .9;
65
+ border-color:#000000;
66
+ }
67
+
68
+ .ngg-description {
69
+ text-align: left;
70
+ }
71
+
72
+ /* ----------- Album Styles Compact -------------*/
73
+
74
+ .ngg-album-compact {
75
+ float:left;
76
+ height:180px;
77
+ padding-right:6px !important;
78
+ margin:0px !important;
79
+ text-align:left;
80
+ width:120px;
81
+ }
82
+
83
+ .ngg-album-compactbox {
84
+ background:transparent url(albumset.gif) no-repeat scroll 0%;
85
+ height:86px;
86
+ margin:0pt 0pt 6px !important;
87
+ padding:12px 0pt 0pt 7px !important;
88
+ width:120px;
89
+ }
90
+
91
+
92
+ .ngg-album-compactbox .Thumb {
93
+ border:1px solid #000000;
94
+ margin:0px !important;
95
+ padding:0px !important;
96
+ width:91px;
97
+ height:68px;
98
+ }
99
+
100
+ .ngg-album-compact h4 {
101
+ font-size:15px;
102
+ font-weight:bold;
103
+ margin-bottom:0px;
104
+ margin-top:0px;
105
+ width:110px;
106
+ }
107
+
108
+ .ngg-album-compact p {
109
+ font-size:11px;
110
+ margin-top:2px;
111
+ }
112
+
113
+ /* ----------- Gallery style -------------*/
114
+
115
+ .ngg-galleryoverview {
116
+ overflow: hidden;
117
+ margin-top: 10px;
118
+ width: 100%;
119
+ clear:both;
120
+ display:block !important;
121
+ }
122
+
123
+ .ngg-gallery-thumbnail-box {
124
+ float: left;
125
+ background:#EEEEEE none repeat scroll 0% 50%;
126
+ border-color:#DDDDDD rgb(187, 187, 187) rgb(170, 170, 170) rgb(204, 204, 204);
127
+ border-style:solid;
128
+ border-width:1px;
129
+ color:inherit;
130
+ display:inline;
131
+ margin:3px;
132
+ padding:5px;
133
+ position:relative;
134
+ }
135
+
136
+ .ngg-gallery-thumbnail {
137
+ float: left;
138
+ }
139
+
140
+ .ngg-gallery-thumbnail img {
141
+ filter: alpha(opacity=100);
142
+ -moz-opacity: .99;
143
+ opacity: .99;
144
+ background:#FFFFFF none repeat scroll 0%;
145
+ border-color:#AAAAAA rgb(204, 204, 204) rgb(221, 221, 221) rgb(187, 187, 187);
146
+ border-style:solid;
147
+ border-width:1px;
148
+ color:inherit;
149
+ padding:2px;
150
+ vertical-align:top;
151
+ }
152
+
153
+ .ngg-gallery-thumbnail img:hover {
154
+ filter: alpha(opacity=90);
155
+ -moz-opacity: .9;
156
+ opacity: .9;
157
+ border-color:#000000;
158
+ }
159
+
160
+ .ngg-gallery-thumbnail span {
161
+ /* Images description */
162
+ font-size:90%;
163
+ padding-left:5px;
164
+ display:block;
165
+ }
166
+
167
+ .ngg-clear {
168
+ clear: both;
169
+ }
170
+
171
+ /* ----------- Gallery navigation -------------*/
172
+
173
+ .ngg-navigation {
174
+ font-size:0.9em !important;
175
+ clear:both !important;
176
+ display:block !important;
177
+ padding-top:15px;
178
+ text-align:center;
179
+
180
+ }
181
+
182
+ .ngg-navigation span {
183
+ font-weight:bold;
184
+ margin:0pt 6px;
185
+ }
186
+
187
+ .ngg-navigation a.page-numbers,
188
+ .ngg-navigation a.next,
189
+ .ngg-navigation a.prev,
190
+ .ngg-navigation span.page-numbers,
191
+ .ngg-navigation span.next,
192
+ .ngg-navigation span.prev {
193
+ border:1px solid #DDDDDD;
194
+ margin-right:3px;
195
+ padding:3px 7px;
196
+ }
197
+
198
+ .ngg-navigation a.page-numbers:hover,
199
+ .ngg-navigation a.next:hover,
200
+ .ngg-navigation a.prev:hover,
201
+ .ngg-navigation span.page-numbers:hover,
202
+ .ngg-navigation span.next:hover,
203
+ .ngg-navigation span.prev:hover {
204
+ background-color: #0066CC;
205
+ color: #FFFFFF !important;
206
+ text-decoration: none !important;
207
+ }
208
+
209
+ /* ----------- Image browser style -------------*/
210
+
211
+ .ngg-imagebrowser {
212
+
213
+ }
214
+
215
+ .ngg-imagebrowser h3 {
216
+ text-align:center;
217
+ padding-bottom:10px;
218
+ }
219
+
220
+ .ngg-imagebrowser .pic {
221
+ background:#EEEEEE none repeat scroll 0% 50%;
222
+ border-color:#DDDDDD rgb(187, 187, 187) rgb(170, 170, 170) rgb(204, 204, 204);
223
+ border-style:solid;
224
+ border-width:1px;
225
+ color:inherit;
226
+ display:block;
227
+ padding:10px;
228
+ }
229
+
230
+ .ngg-imagebrowser img {
231
+ width: 100%;
232
+ margin: -3px;
233
+ background:#FFFFFF none repeat scroll 0%;
234
+ border-color:#AAAAAA rgb(204, 204, 204) rgb(221, 221, 221) rgb(187, 187, 187);
235
+ border-style:solid;
236
+ border-width:1px;
237
+ color:inherit;
238
+ padding:2px;
239
+ vertical-align:top;
240
+ }
241
+
242
+ .ngg-imagebrowser-nav {
243
+ padding:10px;
244
+ margin-left:10px;
245
+
246
+ }
247
+
248
+ .ngg-imagebrowser-nav .back {
249
+ float:left;
250
+ border:1px solid #DDDDDD;
251
+ margin-right:3px;
252
+ padding:3px 7px;
253
+ }
254
+
255
+ .ngg-imagebrowser-nav .next {
256
+ float:right;
257
+ border:1px solid #DDDDDD;
258
+ margin-right:3px;
259
+ padding:3px 7px;
260
+ }
261
+
262
+ .ngg-imagebrowser-nav .back:hover,
263
+ .ngg-imagebrowser-nav .next:hover {
264
+ border:1px solid #000000;
265
+ }
266
+
267
+ .ngg-imagebrowser-nav .back a:hover,
268
+ .ngg-imagebrowser-nav .next a:hover {
269
+ text-decoration: none !important;
270
+ }
271
+
272
+ .ngg-imagebrowser-nav .counter {
273
+ text-align:center;
274
+ font-size:0.9em !important;
275
+ }
276
+
277
+ .exif-data {
278
+ margin-left: auto !important;
279
+ margin-right: auto !important;
280
+ }
281
+
282
+ /* ----------- Slideshow -------------*/
283
+ .slideshow {
284
+ margin-left: auto;
285
+ margin-right: auto;
286
+ text-align:center;
287
+ outline: none;
288
+ }
289
+
290
+ .slideshowlink {
291
+
292
+ }
293
+
294
+ /* ----------- JS Slideshow -------------*/
295
+ .ngg-slideshow {
296
+ overflow:hidden;
297
+ position: relative;
298
+ }
299
+
300
+ .ngg-slideshow * {
301
+ vertical-align:middle;
302
+ }
303
+
304
+ /* See also : http://www.brunildo.org/test/img_center.html */
305
+ .ngg-slideshow-loader{
306
+ display: table-cell;
307
+ text-align: center;
308
+ vertical-align:middle;
309
+ }
310
+
311
+ .ngg-slideshow-loader img{
312
+ background: none !important;
313
+ border: 0 none !important;
314
+ margin:auto !important;
315
+ }
316
+
317
+ /* ----------- Single picture -------------*/
318
+ .ngg-singlepic {
319
+ background-color:#FFFFFF;
320
+ display:block;
321
+ padding:4px;
322
+ }
323
+
324
+ .ngg-left {
325
+ float: left;
326
+ margin-right:10px;
327
+ }
328
+
329
+ .ngg-right {
330
+ float: right;
331
+ margin-left:10px;
332
+ }
333
+
334
+ .ngg-center {
335
+ margin-left: auto !important;
336
+ margin-right: auto !important;
337
+ }
338
+
339
+ /* ----------- Sidebar widget -------------*/
340
+ .ngg-widget,
341
+ .ngg-widget-slideshow {
342
+ overflow: hidden;
343
+ margin:0pt;
344
+ padding:5px 0px 0px 0pt;
345
+ }
346
+
347
+ .ngg-widget img {
348
+ border:2px solid #A9A9A9;
349
+ margin:0pt 2px 2px 0px;
350
+ padding:1px;
351
+ }
352
+
353
+ /* ----------- Related images -------------*/
354
+ .ngg-related-gallery {
355
+ background:#F9F9F9;
356
+ border:1px solid #E0E0E0;
357
+ overflow:hidden;
358
+ margin-bottom:1em;
359
+ margin-top:1em;
360
+ padding:5px;
361
+ }
362
+ .ngg-related-gallery img {
363
+ border: 1px solid #DDDDDD;
364
+ float: left;
365
+ margin: 0pt 3px;
366
+ padding: 2px;
367
+ height: 50px;
368
+ width: 50px;
369
+ }
370
+
371
+ .ngg-related-gallery img:hover {
372
+ border: 1px solid #000000;
373
+ }
374
+
375
+ /* ----------- Gallery list -------------*/
376
+
377
+ .ngg-galleryoverview ul li:before {
378
+ content: '' !important;
379
+ }
380
+
381
+ .ngg-gallery-list {
382
+ list-style-type:none;
383
+ padding: 0px !important;
384
+ text-indent:0px !important;
385
+ }
386
+
387
+ .ngg-galleryoverview div.pic img{
388
+ width: 100%;
389
+ }
390
+
391
+ .ngg-gallery-list li {
392
+ float:left;
393
+ margin:0 2px 0px 2px !important;
394
+ overflow:hidden;
395
+ }
396
+
397
+ .ngg-gallery-list li a {
398
+ border:1px solid #CCCCCC;
399
+ display:block;
400
+ padding:2px;
401
+ }
402
+
403
+ .ngg-gallery-list li.selected a{
404
+ -moz-background-clip:border;
405
+ -moz-background-inline-policy:continuous;
406
+ -moz-background-origin:padding;
407
+ background:#000000 none repeat scroll 0 0;
408
+ }
409
+
410
+ .ngg-gallery-list li img {
411
+ height:40px;
412
+ width:40px;
413
+ }
414
+
415
+ li.ngg-next, li.ngg-prev {
416
+ height:40px;
417
+ width:40px;
418
+ font-size:3.5em;
419
+ }
420
+
421
+ li.ngg-next a, li.ngg-prev a {
422
+ padding-top: 10px;
423
+ border: none;
424
+ text-decoration: none;
425
  }
css/ngg_dkret3.css CHANGED
@@ -1,318 +1,318 @@
1
- /*
2
- CSS Name: dkret3 Theme
3
- Description: NextGEN dkret3 style with a shadow effect
4
- Author: Jörn Kretzschmar (based on Alex Rabes Default Style)
5
- Version: 1.3
6
-
7
- This is a template stylesheet that can be used with NextGEN Gallery. I tested the
8
- styles with the theme dkret3. Modify it when your theme struggle with it,
9
- it's only a template design
10
-
11
- */
12
-
13
- /* ----------- Album Styles Extend -------------*/
14
-
15
- .ngg-albumoverview {
16
- margin-top: 10px;
17
- width: 100%;
18
- clear:both;
19
- display:block !important;
20
- }
21
-
22
- .ngg-album {
23
- height: 100%;
24
- padding: 5px;
25
- margin-bottom: 5px;
26
- border: 1px solid #cccccc;
27
- overflow:hidden;
28
- }
29
-
30
- .ngg-albumtitle {
31
- text-align: left;
32
- font-weight: bold;
33
- margin:0px;
34
- padding:0px;
35
- font-size: 1.4em;
36
- margin-bottom: 10px;
37
- }
38
-
39
- .ngg-thumbnail {
40
- float: left;
41
- margin-right: 12px;
42
- }
43
-
44
- .ngg-thumbnail img {
45
- background-color:#FFFFFF;
46
- border:1px solid #A9A9A9;
47
- margin:4px 0px 4px 5px;
48
- padding:4px;
49
- position:relative;
50
- }
51
-
52
- .ngg-thumbnail img:hover {
53
- background-color: #A9A9A9;
54
- }
55
-
56
- .ngg-description {
57
- text-align: left;
58
- }
59
-
60
- /* ----------- Album Styles Compact -------------*/
61
-
62
- .ngg-album-compact {
63
- float:left;
64
- height:180px;
65
- padding-right:6px !important;
66
- margin:0px !important;
67
- text-align:left;
68
- width:120px;
69
- }
70
-
71
- .ngg-album-compactbox {
72
- background:transparent url(albumset.gif) no-repeat scroll 0%;
73
- height:86px;
74
- margin:0pt 0pt 6px !important;
75
- padding:12px 0pt 0pt 7px !important;
76
- width:120px;
77
- }
78
-
79
-
80
- .ngg-album-compactbox .Thumb {
81
- border:1px solid #000000;
82
- margin:0px !important;
83
- padding:0px !important;
84
- width:91px;
85
- height:68px;
86
- }
87
-
88
- .ngg-album-compact h4 {
89
- font-size:15px;
90
- font-weight:bold;
91
- margin-bottom:0px;
92
- margin-top:0px;
93
- width:110px;
94
- }
95
-
96
- .ngg-album-compact p {
97
- font-size:11px;
98
- margin-top:2px;
99
- }
100
-
101
- /* ----------- Gallery style -------------*/
102
-
103
- .ngg-galleryoverview {
104
- margin-top: 10px;
105
- width: 100%;
106
- clear:both;
107
- display:block !important;
108
- }
109
-
110
- .ngg-gallery-thumbnail-box {
111
- float: left;
112
- }
113
-
114
- .ngg-gallery-thumbnail {
115
- float: left;
116
- background: url(shadowAlpha.png) no-repeat bottom right !important;
117
- background: url(shadow.gif) no-repeat bottom right;
118
- margin: 10px 0 0 10px !important;
119
- }
120
-
121
- .ngg-gallery-thumbnail img {
122
- margin: -6px 6px 6px -6px;
123
- background-color:#FFFFFF;
124
- border:1px solid #A9A9A9;
125
- display:block;
126
- padding:4px;
127
- position:relative;
128
- }
129
-
130
- .ngg-gallery-thumbnail img:hover {
131
- background-color: #A9A9A9;
132
- }
133
-
134
- .ngg-gallery-thumbnail span {
135
- display:none;
136
- }
137
-
138
- .ngg-clear {
139
- clear: both;
140
- }
141
-
142
- /* ----------- Gallery navigation -------------*/
143
-
144
- .ngg-navigation {
145
- font-size:0.9em !important;
146
- clear:both !important;
147
- display:block !important;
148
- padding-top:15px;
149
- text-align:center;
150
- }
151
-
152
- .ngg-navigation span {
153
- font-weight:bold;
154
- margin:0pt 6px;
155
- }
156
-
157
- .ngg-navigation a.page-numbers,
158
- .ngg-navigation a.next,
159
- .ngg-navigation a.prev,
160
- .ngg-navigation span.page-numbers,
161
- .ngg-navigation span.next,
162
- .ngg-navigation span.prev {
163
- border:1px solid #DDDDDD;
164
- margin-right:3px;
165
- padding:3px 7px;
166
- }
167
-
168
- .ngg-navigation a.page-numbers:hover,
169
- .ngg-navigation a.next:hover,
170
- .ngg-navigation a.prev:hover,
171
- .ngg-navigation span.page-numbers:hover,
172
- .ngg-navigation span.next:hover,
173
- .ngg-navigation span.prev:hover {
174
- background-color: #0066CC;
175
- color: #FFFFFF !important;
176
- text-decoration: none !important;
177
- }
178
-
179
- /* ----------- Image browser style -------------*/
180
-
181
- .ngg-imagebrowser {
182
-
183
- }
184
-
185
- .ngg-imagebrowser h3 {
186
- text-align:center;
187
- }
188
-
189
- .ngg-imagebrowser img {
190
- border:1px solid #A9A9A9;
191
- margin-top: 10px;
192
- margin-bottom: 10px;
193
- width: 100%;
194
- display:block !important;
195
- padding:5px;
196
- }
197
-
198
- .ngg-imagebrowser-nav {
199
- padding:5px;
200
- margin-left:10px;
201
- }
202
-
203
- .ngg-imagebrowser-nav .back {
204
- float:left;
205
- border:1px solid #DDDDDD;
206
- margin-right:3px;
207
- padding:3px 7px;
208
- }
209
-
210
- .ngg-imagebrowser-nav .next {
211
- float:right;
212
- border:1px solid #DDDDDD;
213
- margin-right:3px;
214
- padding:3px 7px;
215
- }
216
-
217
- .ngg-imagebrowser-nav .counter {
218
- text-align:center;
219
- font-size:0.9em !important;
220
- }
221
-
222
- .exif-data {
223
- margin-left: auto !important;
224
- margin-right: auto !important;
225
- }
226
-
227
- /* ----------- Slideshow -------------*/
228
- .slideshow {
229
- margin-left: auto;
230
- margin-right: auto;
231
- text-align:center;
232
- outline: none;
233
- }
234
-
235
- .slideshowlink {
236
-
237
- }
238
-
239
- /* ----------- JS Slideshow -------------*/
240
- .ngg-slideshow {
241
- overflow:hidden;
242
- position: relative;
243
- }
244
-
245
- .ngg-slideshow * {
246
- vertical-align:middle;
247
- }
248
-
249
- /* See also : http://www.brunildo.org/test/img_center.html */
250
- .ngg-slideshow-loader{
251
- display: table-cell;
252
- text-align: center;
253
- vertical-align:middle;
254
- }
255
-
256
- .ngg-slideshow-loader img{
257
- background: none !important;
258
- border: 0 none !important;
259
- margin:auto !important;
260
- }
261
-
262
- /* ----------- Single picture -------------*/
263
- .ngg-singlepic {
264
- background-color:#FFFFFF;
265
- display:block;
266
- padding:4px;
267
- }
268
-
269
- .ngg-left {
270
- float: left;
271
- }
272
-
273
- .ngg-right {
274
- float: right;
275
- }
276
-
277
- .ngg-center {
278
- margin-left: auto;
279
- margin-right: auto;
280
- }
281
-
282
- /* ----------- Sidebar widget -------------*/
283
-
284
- .ngg-widget,
285
- .ngg-widget-slideshow {
286
- overflow: hidden;
287
- margin:0pt;
288
- padding:5px 0px 0px 0pt;
289
- text-align: center;
290
- }
291
-
292
- .ngg-widget img {
293
- border:2px solid #A9A9A9;
294
- margin:0pt 2px 2px 0px;
295
- padding:1px;
296
- }
297
-
298
- /* ----------- Related images -------------*/
299
- .ngg-related-gallery {
300
- background:#F9F9F9;
301
- border:1px solid #E0E0E0;
302
- overflow:hidden;
303
- margin-bottom:1em;
304
- margin-top:1em;
305
- padding:5px;
306
- }
307
- .ngg-related-gallery img {
308
- border: 1px solid #DDDDDD;
309
- float: left;
310
- margin: 0pt 3px;
311
- padding: 2px;
312
- height: 50px;
313
- width: 50px;
314
- }
315
-
316
- .ngg-related-gallery img:hover {
317
- border: 1px solid #000000;
318
- }
1
+ /*
2
+ CSS Name: dkret3 Theme
3
+ Description: NextGEN dkret3 style with a shadow effect
4
+ Author: Jörn Kretzschmar (based on Alex Rabes Default Style)
5
+ Version: 1.3
6
+
7
+ This is a template stylesheet that can be used with NextGEN Gallery. I tested the
8
+ styles with the theme dkret3. Modify it when your theme struggle with it,
9
+ it's only a template design
10
+
11
+ */
12
+
13
+ /* ----------- Album Styles Extend -------------*/
14
+
15
+ .ngg-albumoverview {
16
+ margin-top: 10px;
17
+ width: 100%;
18
+ clear:both;
19
+ display:block !important;
20
+ }
21
+
22
+ .ngg-album {
23
+ height: 100%;
24
+ padding: 5px;
25
+ margin-bottom: 5px;
26
+ border: 1px solid #cccccc;
27
+ overflow:hidden;
28
+ }
29
+
30
+ .ngg-albumtitle {
31
+ text-align: left;
32
+ font-weight: bold;
33
+ margin:0px;
34
+ padding:0px;
35
+ font-size: 1.4em;
36
+ margin-bottom: 10px;
37
+ }
38
+
39
+ .ngg-thumbnail {
40
+ float: left;
41
+ margin-right: 12px;
42
+ }
43
+
44
+ .ngg-thumbnail img {
45
+ background-color:#FFFFFF;
46
+ border:1px solid #A9A9A9;
47
+ margin:4px 0px 4px 5px;
48
+ padding:4px;
49
+ position:relative;
50
+ }
51
+
52
+ .ngg-thumbnail img:hover {
53
+ background-color: #A9A9A9;
54
+ }
55
+
56
+ .ngg-description {
57
+ text-align: left;
58
+ }
59
+
60
+ /* ----------- Album Styles Compact -------------*/
61
+
62
+ .ngg-album-compact {
63
+ float:left;
64
+ height:180px;
65
+ padding-right:6px !important;
66
+ margin:0px !important;
67
+ text-align:left;
68
+ width:120px;
69
+ }
70
+
71
+ .ngg-album-compactbox {
72
+ background:transparent url(albumset.gif) no-repeat scroll 0%;
73
+ height:86px;
74
+ margin:0pt 0pt 6px !important;
75
+ padding:12px 0pt 0pt 7px !important;
76
+ width:120px;
77
+ }
78
+
79
+
80
+ .ngg-album-compactbox .Thumb {
81
+ border:1px solid #000000;
82
+ margin:0px !important;
83
+ padding:0px !important;
84
+ width:91px;
85
+ height:68px;
86
+ }
87
+
88
+ .ngg-album-compact h4 {
89
+ font-size:15px;
90
+ font-weight:bold;
91
+ margin-bottom:0px;
92
+ margin-top:0px;
93
+ width:110px;
94
+ }
95
+
96
+ .ngg-album-compact p {
97
+ font-size:11px;
98
+ margin-top:2px;
99
+ }
100
+
101
+ /* ----------- Gallery style -------------*/
102
+
103
+ .ngg-galleryoverview {
104
+ margin-top: 10px;
105
+ width: 100%;
106
+ clear:both;
107
+ display:block !important;
108
+ }
109
+
110
+ .ngg-gallery-thumbnail-box {
111
+ float: left;
112
+ }
113
+
114
+ .ngg-gallery-thumbnail {
115
+ float: left;
116
+ background: url(shadowAlpha.png) no-repeat bottom right !important;
117
+ background: url(shadow.gif) no-repeat bottom right;
118
+ margin: 10px 0 0 10px !important;
119
+ }
120
+
121
+ .ngg-gallery-thumbnail img {
122
+ margin: -6px 6px 6px -6px;
123
+ background-color:#FFFFFF;
124
+ border:1px solid #A9A9A9;
125
+ display:block;
126
+ padding:4px;
127
+ position:relative;
128
+ }
129
+
130
+ .ngg-gallery-thumbnail img:hover {
131
+ background-color: #A9A9A9;
132
+ }
133
+
134
+ .ngg-gallery-thumbnail span {
135
+ display:none;
136
+ }
137
+
138
+ .ngg-clear {
139
+ clear: both;
140
+ }
141
+
142
+ /* ----------- Gallery navigation -------------*/
143
+
144
+ .ngg-navigation {
145
+ font-size:0.9em !important;
146
+ clear:both !important;
147
+ display:block !important;
148
+ padding-top:15px;
149
+ text-align:center;
150
+ }
151
+
152
+ .ngg-navigation span {
153
+ font-weight:bold;
154
+ margin:0pt 6px;
155
+ }
156
+
157
+ .ngg-navigation a.page-numbers,
158
+ .ngg-navigation a.next,
159
+ .ngg-navigation a.prev,
160
+ .ngg-navigation span.page-numbers,
161
+ .ngg-navigation span.next,
162
+ .ngg-navigation span.prev {
163
+ border:1px solid #DDDDDD;
164
+ margin-right:3px;
165
+ padding:3px 7px;
166
+ }
167
+
168
+ .ngg-navigation a.page-numbers:hover,
169
+ .ngg-navigation a.next:hover,
170
+ .ngg-navigation a.prev:hover,
171
+ .ngg-navigation span.page-numbers:hover,
172
+ .ngg-navigation span.next:hover,
173
+ .ngg-navigation span.prev:hover {
174
+ background-color: #0066CC;
175
+ color: #FFFFFF !important;
176
+ text-decoration: none !important;
177
+ }
178
+
179
+ /* ----------- Image browser style -------------*/
180
+
181
+ .ngg-imagebrowser {
182
+
183
+ }
184
+
185
+ .ngg-imagebrowser h3 {
186
+ text-align:center;
187
+ }
188
+
189
+ .ngg-imagebrowser img {
190
+ border:1px solid #A9A9A9;
191
+ margin-top: 10px;
192
+ margin-bottom: 10px;
193
+ width: 100%;
194
+ display:block !important;
195
+ padding:5px;
196
+ }
197
+
198
+ .ngg-imagebrowser-nav {
199
+ padding:5px;
200
+ margin-left:10px;
201
+ }
202
+
203
+ .ngg-imagebrowser-nav .back {
204
+ float:left;
205
+ border:1px solid #DDDDDD;
206
+ margin-right:3px;
207
+ padding:3px 7px;
208
+ }
209
+
210
+ .ngg-imagebrowser-nav .next {
211
+ float:right;
212
+ border:1px solid #DDDDDD;
213
+ margin-right:3px;
214
+ padding:3px 7px;
215
+ }
216
+
217
+ .ngg-imagebrowser-nav .counter {
218
+ text-align:center;
219
+ font-size:0.9em !important;
220
+ }
221
+
222
+ .exif-data {
223
+ margin-left: auto !important;
224
+ margin-right: auto !important;
225
+ }
226
+
227
+ /* ----------- Slideshow -------------*/
228
+ .slideshow {
229
+ margin-left: auto;
230
+ margin-right: auto;
231
+ text-align:center;
232
+ outline: none;
233
+ }
234
+
235
+ .slideshowlink {
236
+
237
+ }
238
+
239
+ /* ----------- JS Slideshow -------------*/
240
+ .ngg-slideshow {
241
+ overflow:hidden;
242
+ position: relative;
243
+ }
244
+
245
+ .ngg-slideshow * {
246
+ vertical-align:middle;
247
+ }
248
+
249
+ /* See also : http://www.brunildo.org/test/img_center.html */
250
+ .ngg-slideshow-loader{
251
+ display: table-cell;
252
+ text-align: center;
253
+ vertical-align:middle;
254
+ }
255
+
256
+ .ngg-slideshow-loader img{
257
+ background: none !important;
258
+ border: 0 none !important;
259
+ margin:auto !important;
260
+ }
261
+
262
+ /* ----------- Single picture -------------*/
263
+ .ngg-singlepic {
264
+ background-color:#FFFFFF;
265
+ display:block;
266
+ padding:4px;
267
+ }
268
+
269
+ .ngg-left {
270
+ float: left;
271
+ }
272
+
273
+ .ngg-right {
274
+ float: right;
275
+ }
276
+
277
+ .ngg-center {
278
+ margin-left: auto;
279
+ margin-right: auto;
280
+ }
281
+
282
+ /* ----------- Sidebar widget -------------*/
283
+
284
+ .ngg-widget,
285
+ .ngg-widget-slideshow {
286
+ overflow: hidden;
287
+ margin:0pt;
288
+ padding:5px 0px 0px 0pt;
289
+ text-align: center;
290
+ }
291
+
292
+ .ngg-widget img {
293
+ border:2px solid #A9A9A9;
294
+ margin:0pt 2px 2px 0px;
295
+ padding:1px;
296
+ }
297
+
298
+ /* ----------- Related images -------------*/
299
+ .ngg-related-gallery {
300
+ background:#F9F9F9;
301
+ border:1px solid #E0E0E0;
302
+ overflow:hidden;
303
+ margin-bottom:1em;
304
+ margin-top:1em;
305
+ padding:5px;
306
+ }
307
+ .ngg-related-gallery img {
308
+ border: 1px solid #DDDDDD;
309
+ float: left;
310
+ margin: 0pt 3px;
311
+ padding: 2px;
312
+ height: 50px;
313
+ width: 50px;
314
+ }
315
+
316
+ .ngg-related-gallery img:hover {
317
+ border: 1px solid #000000;
318
+ }
css/ngg_k2.css CHANGED
@@ -1,330 +1,330 @@
1
- /*
2
- CSS Name: K2 Theme
3
- Description: NextGEN Style for K2 Theme
4
- Author: Alex Rabe
5
- Version: 1.60
6
-
7
- This is a template stylesheet that can be used with NextGEN Gallery. I tested the
8
- styles with a default theme Kubrick. Modify it when your theme struggle with it,
9
- it's only a template design
10
-
11
- */
12
-
13
- /* ----------- Album Styles Extend -------------*/
14
-
15
- .ngg-albumoverview {
16
- margin: 10px 0px 0px 0px !important;
17
- width: 100%;
18
- clear:both;
19
- display:block !important;
20
- }
21
-
22
- .ngg-album {
23
- /*height: 130px;*/
24
- overflow:hidden;
25
- margin: 0px 0px 5px !important;
26
- padding: 5px;
27
- border: 1px solid #cccccc;
28
- }
29
-
30
- .ngg-albumtitle {
31
- text-align: left;
32
- font-weight: bold;
33
- padding:0px;
34
- font-size: 1.4em;
35
- margin: 0px 0px 10px 0px !important;
36
- }
37
-
38
- .ngg-albumcontent {
39
- margin: 0px !important;
40
- }
41
-
42
- .ngg-thumbnail {
43
- margin:0px 12px 0px 0px !important;
44
- float: left;
45
- }
46
-
47
- .ngg-thumbnail img {
48
- background-color:#FFFFFF;
49
- border:1px solid #A9A9A9;
50
- margin:4px 0px 4px 5px !important;
51
- padding:4px;
52
- position:relative;
53
- }
54
-
55
- .ngg-thumbnail img:hover {
56
- background-color: #A9A9A9;
57
- }
58
-
59
- .ngg-description {
60
- text-align: left;
61
- }
62
-
63
- /* ----------- Album Styles Compact -------------*/
64
-
65
- .ngg-album-compact {
66
- float:left;
67
- height:180px;
68
- padding-right:6px !important;
69
- margin:0px !important;
70
- text-align:left;
71
- width:120px;
72
- }
73
-
74
- .ngg-album-compactbox {
75
- background:transparent url(albumset.gif) no-repeat scroll 0%;
76
- height:86px;
77
- margin:0pt 0pt 6px !important;
78
- padding:12px 0pt 0pt 7px !important;
79
- width:120px;
80
- }
81
-
82
- .ngg-album-link {
83
- margin:0px !important;
84
- }
85
-
86
- .ngg-album-compactbox .Thumb {
87
- border:1px solid #000000;
88
- margin:0px !important;
89
- padding:0px !important;
90
- width:91px;
91
- height:68px;
92
- }
93
-
94
- .ngg-album-compact h4 {
95
- font-size:15px;
96
- font-weight:bold;
97
- margin-bottom:0px !important;
98
- margin-top:0px !important;
99
- width:110px;
100
- padding:0px !important;
101
- }
102
-
103
- .ngg-album-compact p {
104
- font-size:11px;
105
- margin-top:2px;
106
- }
107
-
108
- /* ----------- Gallery style -------------*/
109
-
110
- .ngg-galleryoverview {
111
- margin-top: 10px;
112
- width: 100%;
113
- clear:both;
114
- display:block !important;
115
- }
116
-
117
- .ngg-gallery-thumbnail-box {
118
- margin:0px !important;
119
- float: left;
120
- }
121
-
122
- .ngg-gallery-thumbnail {
123
- float: left;
124
- background: url(shadowAlpha.png) no-repeat bottom right !important;
125
- background: url(shadow.gif) no-repeat bottom right;
126
- margin: 10px 0 0 10px !important;
127
- }
128
-
129
- .ngg-gallery-thumbnail img {
130
- margin: -6px 6px 6px -6px !important;
131
- background-color:#FFFFFF;
132
- border:1px solid #A9A9A9;
133
- display:block;
134
- padding:4px;
135
- position:relative;
136
- }
137
-
138
- .ngg-gallery-thumbnail img:hover {
139
- background-color: #A9A9A9;
140
- }
141
-
142
- .ngg-gallery-thumbnail span {
143
- /* Images description */
144
- font-size:90%;
145
- padding-left:5px;
146
- display:block;
147
- }
148
-
149
- .ngg-clear {
150
- clear: both;
151
- }
152
-
153
- /* ----------- Gallery navigation -------------*/
154
-
155
- .ngg-navigation {
156
- font-size:0.9em !important;
157
- clear:both !important;
158
- display:block !important;
159
- padding-top:15px;
160
- text-align:center;
161
- }
162
-
163
- .ngg-navigation span {
164
- font-weight:bold;
165
- margin:0pt 6px;
166
- }
167
-
168
- .ngg-navigation a.page-numbers,
169
- .ngg-navigation a.next,
170
- .ngg-navigation a.prev,
171
- .ngg-navigation span.page-numbers,
172
- .ngg-navigation span.next,
173
- .ngg-navigation span.prev {
174
- border:1px solid #DDDDDD;
175
- margin-right:3px;
176
- padding:3px 7px;
177
- }
178
-
179
- .ngg-navigation a.page-numbers:hover,
180
- .ngg-navigation a.next:hover,
181
- .ngg-navigation a.prev:hover,
182
- .ngg-navigation span.page-numbers:hover,
183
- .ngg-navigation span.next:hover,
184
- .ngg-navigation span.prev:hover {
185
- background-color: #0066CC;
186
- color: #FFFFFF;
187
- text-decoration: none;
188
- }
189
-
190
- /* ----------- Image browser style -------------*/
191
-
192
- .ngg-imagebrowser {
193
-
194
- }
195
-
196
- .ngg-imagebrowser h3 {
197
- text-align:center;
198
- }
199
-
200
- .ngg-imagebrowser img {
201
- border:1px solid #A9A9A9;
202
- margin-top: 10px;
203
- margin-bottom: 10px;
204
- width: 100%;
205
- display:block !important;
206
- padding:5px;
207
- }
208
-
209
- .ngg-imagebrowser-nav {
210
- padding:5px;
211
- margin-left:10px;
212
- }
213
-
214
- .ngg-imagebrowser-nav .back {
215
- float:left;
216
- border:1px solid #DDDDDD;
217
- margin-right:3px;
218
- padding:3px 7px;
219
- }
220
-
221
- .ngg-imagebrowser-nav .next {
222
- float:right;
223
- border:1px solid #DDDDDD;
224
- margin-right:3px;
225
- padding:3px 7px;
226
- }
227
-
228
- .ngg-imagebrowser-nav .counter {
229
- text-align:center;
230
- font-size:0.9em !important;
231
- }
232
-
233
- .exif-data {
234
- margin-left: auto !important;
235
- margin-right: auto !important;
236
- }
237
-
238
- /* ----------- Slideshow -------------*/
239
- .slideshow {
240
- margin-left: auto;
241
- margin-right: auto;
242
- text-align:center;
243
- outline: none;
244
- }
245
-
246
- .slideshowlink {
247
-
248
- }
249
-
250
- /* ----------- JS Slideshow -------------*/
251
- .ngg-slideshow {
252
- overflow:hidden;
253
- position: relative;
254
- }
255
-
256
- .ngg-slideshow * {
257
- vertical-align:middle;
258
- }
259
-
260
- /* See also : http://www.brunildo.org/test/img_center.html */
261
- .ngg-slideshow-loader{
262
- display: table-cell;
263
- text-align: center;
264
- vertical-align:middle;
265
- }
266
-
267
- .ngg-slideshow-loader img{
268
- background: none !important;
269
- border: 0 none !important;
270
- margin:auto !important;
271
- }
272
-
273
- /* ----------- Single picture -------------*/
274
- .ngg-singlepic {
275
- background-color:#FFFFFF;
276
- display:block;
277
- padding:4px;
278
- }
279
-
280
- .ngg-left {
281
- float: left;
282
- margin-right:10px;
283
- }
284
-
285
- .ngg-right {
286
- float: right;
287
- margin-left:10px;
288
- }
289
-
290
- .ngg-center {
291
- margin-left: auto !important;
292
- margin-right: auto !important;
293
- }
294
-
295
- /* ----------- Sidebar widget -------------*/
296
- .ngg-widget,
297
- .ngg-widget-slideshow {
298
- overflow: hidden;
299
- margin:0pt;
300
- padding:5px 0px 0px 0pt;
301
- text-align:left;
302
- }
303
-
304
- .ngg-widget img {
305
- border:2px solid #A9A9A9;
306
- margin:0pt 2px 2px 0px;
307
- padding:1px;
308
- }
309
-
310
- /* ----------- Related images -------------*/
311
- .ngg-related-gallery {
312
- background:#F9F9F9;
313
- border:1px solid #E0E0E0;
314
- overflow:hidden;
315
- margin-bottom:1em;
316
- margin-top:1em;
317
- padding:5px;
318
- }
319
- .ngg-related-gallery img {
320
- border: 1px solid #DDDDDD;
321
- float: left;
322
- margin: 0pt 2px;
323
- padding: 2px;
324
- height: 50px;
325
- width: 50px;
326
- }
327
-
328
- .ngg-related-gallery img:hover {
329
- border: 1px solid #000000;
330
- }
1
+ /*
2
+ CSS Name: K2 Theme
3
+ Description: NextGEN Style for K2 Theme
4
+ Author: Alex Rabe
5
+ Version: 1.60
6
+
7
+ This is a template stylesheet that can be used with NextGEN Gallery. I tested the
8
+ styles with a default theme Kubrick. Modify it when your theme struggle with it,
9
+ it's only a template design
10
+
11
+ */
12
+
13
+ /* ----------- Album Styles Extend -------------*/
14
+
15
+ .ngg-albumoverview {
16
+ margin: 10px 0px 0px 0px !important;
17
+ width: 100%;
18
+ clear:both;
19
+ display:block !important;
20
+ }
21
+
22
+ .ngg-album {
23
+ /*height: 130px;*/
24
+ overflow:hidden;
25
+ margin: 0px 0px 5px !important;
26
+ padding: 5px;
27
+ border: 1px solid #cccccc;
28
+ }
29
+
30
+ .ngg-albumtitle {
31
+ text-align: left;
32
+ font-weight: bold;
33
+ padding:0px;
34
+ font-size: 1.4em;
35
+ margin: 0px 0px 10px 0px !important;
36
+ }
37
+
38
+ .ngg-albumcontent {
39
+ margin: 0px !important;
40
+ }
41
+
42
+ .ngg-thumbnail {
43
+ margin:0px 12px 0px 0px !important;
44
+ float: left;
45
+ }
46
+
47
+ .ngg-thumbnail img {
48
+ background-color:#FFFFFF;
49
+ border:1px solid #A9A9A9;
50
+ margin:4px 0px 4px 5px !important;
51
+ padding:4px;
52
+ position:relative;
53
+ }
54
+
55
+ .ngg-thumbnail img:hover {
56
+ background-color: #A9A9A9;
57
+ }
58
+
59
+ .ngg-description {
60
+ text-align: left;
61
+ }
62
+
63
+ /* ----------- Album Styles Compact -------------*/
64
+
65
+ .ngg-album-compact {
66
+ float:left;
67
+ height:180px;
68
+ padding-right:6px !important;
69
+ margin:0px !important;
70
+ text-align:left;
71
+ width:120px;
72
+ }
73
+
74
+ .ngg-album-compactbox {
75
+ background:transparent url(albumset.gif) no-repeat scroll 0%;
76
+ height:86px;
77
+ margin:0pt 0pt 6px !important;
78
+ padding:12px 0pt 0pt 7px !important;
79
+ width:120px;
80
+ }
81
+
82
+ .ngg-album-link {
83
+ margin:0px !important;
84
+ }
85
+
86
+ .ngg-album-compactbox .Thumb {
87
+ border:1px solid #000000;
88
+ margin:0px !important;
89
+ padding:0px !important;
90
+ width:91px;
91
+ height:68px;
92
+ }
93
+
94
+ .ngg-album-compact h4 {
95
+ font-size:15px;
96
+ font-weight:bold;
97
+ margin-bottom:0px !important;
98
+ margin-top:0px !important;
99
+ width:110px;
100
+ padding:0px !important;
101
+ }
102
+
103
+ .ngg-album-compact p {
104
+ font-size:11px;
105
+ margin-top:2px;
106
+ }
107
+
108
+ /* ----------- Gallery style -------------*/
109
+
110
+ .ngg-galleryoverview {
111
+ margin-top: 10px;
112
+ width: 100%;
113
+ clear:both;
114
+ display:block !important;
115
+ }
116
+
117
+ .ngg-gallery-thumbnail-box {
118
+ margin:0px !important;
119
+ float: left;
120
+ }
121
+
122
+ .ngg-gallery-thumbnail {
123
+ float: left;
124
+ background: url(shadowAlpha.png) no-repeat bottom right !important;
125
+ background: url(shadow.gif) no-repeat bottom right;
126
+ margin: 10px 0 0 10px !important;
127
+ }
128
+
129
+ .ngg-gallery-thumbnail img {
130
+ margin: -6px 6px 6px -6px !important;
131
+ background-color:#FFFFFF;
132
+ border:1px solid #A9A9A9;
133
+ display:block;
134
+ padding:4px;
135
+ position:relative;
136
+ }
137
+
138
+ .ngg-gallery-thumbnail img:hover {
139
+ background-color: #A9A9A9;
140
+ }
141
+
142
+ .ngg-gallery-thumbnail span {
143
+ /* Images description */
144
+ font-size:90%;
145
+ padding-left:5px;
146
+ display:block;
147
+ }
148
+
149
+ .ngg-clear {
150
+ clear: both;
151
+ }
152
+
153
+ /* ----------- Gallery navigation -------------*/
154
+
155
+ .ngg-navigation {
156
+ font-size:0.9em !important;
157
+ clear:both !important;
158
+ display:block !important;
159
+ padding-top:15px;
160
+ text-align:center;
161
+ }
162
+
163
+ .ngg-navigation span {
164
+ font-weight:bold;
165
+ margin:0pt 6px;
166
+ }
167
+
168
+ .ngg-navigation a.page-numbers,
169
+ .ngg-navigation a.next,
170
+ .ngg-navigation a.prev,
171
+ .ngg-navigation span.page-numbers,
172
+ .ngg-navigation span.next,
173
+ .ngg-navigation span.prev {
174
+ border:1px solid #DDDDDD;
175
+ margin-right:3px;
176
+ padding:3px 7px;
177
+ }
178
+
179
+ .ngg-navigation a.page-numbers:hover,
180
+ .ngg-navigation a.next:hover,
181
+ .ngg-navigation a.prev:hover,
182
+ .ngg-navigation span.page-numbers:hover,
183
+ .ngg-navigation span.next:hover,
184
+ .ngg-navigation span.prev:hover {
185
+ background-color: #0066CC;
186
+ color: #FFFFFF;
187
+ text-decoration: none;
188
+ }
189
+
190
+ /* ----------- Image browser style -------------*/
191
+
192
+ .ngg-imagebrowser {
193
+
194
+ }
195
+
196
+ .ngg-imagebrowser h3 {
197
+ text-align:center;
198
+ }
199
+
200
+ .ngg-imagebrowser img {
201
+ border:1px solid #A9A9A9;
202
+ margin-top: 10px;
203
+ margin-bottom: 10px;
204
+ width: 100%;
205
+ display:block !important;
206
+ padding:5px;
207
+ }
208
+
209
+ .ngg-imagebrowser-nav {
210
+ padding:5px;
211
+ margin-left:10px;
212
+ }
213
+
214
+ .ngg-imagebrowser-nav .back {
215
+ float:left;
216
+ border:1px solid #DDDDDD;
217
+ margin-right:3px;
218
+ padding:3px 7px;
219
+ }
220
+
221
+ .ngg-imagebrowser-nav .next {
222
+ float:right;
223
+ border:1px solid #DDDDDD;
224
+ margin-right:3px;
225
+ padding:3px 7px;
226
+ }
227
+
228
+ .ngg-imagebrowser-nav .counter {
229
+ text-align:center;
230
+ font-size:0.9em !important;
231
+ }
232
+
233
+ .exif-data {
234
+ margin-left: auto !important;
235
+ margin-right: auto !important;
236
+ }
237
+
238
+ /* ----------- Slideshow -------------*/
239
+ .slideshow {
240
+ margin-left: auto;
241
+ margin-right: auto;
242
+ text-align:center;
243
+ outline: none;
244
+ }
245
+
246
+ .slideshowlink {
247
+
248
+ }
249
+
250
+ /* ----------- JS Slideshow -------------*/
251
+ .ngg-slideshow {
252
+ overflow:hidden;
253
+ position: relative;
254
+ }
255
+
256
+ .ngg-slideshow * {
257
+ vertical-align:middle;
258
+ }
259
+
260
+ /* See also : http://www.brunildo.org/test/img_center.html */
261
+ .ngg-slideshow-loader{
262
+ display: table-cell;
263
+ text-align: center;
264
+ vertical-align:middle;
265
+ }
266
+
267
+ .ngg-slideshow-loader img{
268
+ background: none !important;
269
+ border: 0 none !important;
270
+ margin:auto !important;
271
+ }
272
+
273
+ /* ----------- Single picture -------------*/
274
+ .ngg-singlepic {
275
+ background-color:#FFFFFF;
276
+ display:block;
277
+ padding:4px;
278
+ }
279
+
280
+ .ngg-left {
281
+ float: left;
282
+ margin-right:10px;
283
+ }
284
+
285
+ .ngg-right {
286
+ float: right;
287
+ margin-left:10px;
288
+ }
289
+
290
+ .ngg-center {
291
+ margin-left: auto !important;
292
+ margin-right: auto !important;
293
+ }
294
+
295
+ /* ----------- Sidebar widget -------------*/
296
+ .ngg-widget,
297
+ .ngg-widget-slideshow {
298
+ overflow: hidden;
299
+ margin:0pt;
300
+ padding:5px 0px 0px 0pt;
301
+ text-align:left;
302
+ }
303
+
304
+ .ngg-widget img {
305
+ border:2px solid #A9A9A9;
306
+ margin:0pt 2px 2px 0px;
307
+ padding:1px;
308
+ }
309
+
310
+ /* ----------- Related images -------------*/
311
+ .ngg-related-gallery {
312
+ background:#F9F9F9;
313
+ border:1px solid #E0E0E0;
314
+ overflow:hidden;
315
+ margin-bottom:1em;
316
+ margin-top:1em;
317
+ padding:5px;
318
+ }
319
+ .ngg-related-gallery img {
320
+ border: 1px solid #DDDDDD;
321
+ float: left;
322
+ margin: 0pt 2px;
323
+ padding: 2px;
324
+ height: 50px;
325
+ width: 50px;
326
+ }
327
+
328
+ .ngg-related-gallery img:hover {
329
+ border: 1px solid #000000;
330
+ }
css/ngg_shadow.css CHANGED
@@ -1,371 +1,371 @@
1
- /*
2
- CSS Name: Shadow Effect
3
- Description: NextGEN Default Style with a Shadow effect
4
- Author: Alex Rabe
5
- Version: 1.60
6
-
7
- This is a template stylesheet tha