Version Description
Download this release
Release Info
Developer | alexrabe |
Plugin | NextGEN Gallery – WordPress Gallery Plugin |
Version | 1.3.4 |
Comparing to | |
See all releases |
Code changes from version 1.3.3 to 1.3.4
- admin/ajax.php +2 -2
- changelog.txt +8 -1
- lib/core.php +0 -1
- nggallery.php +4 -4
- nggfunctions.php +954 -951
admin/ajax.php
CHANGED
@@ -18,8 +18,8 @@ function ngg_ajax_operation() {
|
|
18 |
if ( !is_user_logged_in() )
|
19 |
die('-1');
|
20 |
|
21 |
-
// check for correct NextGEN capability
|
22 |
-
if ( !current_user_can('NextGEN Upload images')
|
23 |
die('-1');
|
24 |
|
25 |
// include the ngg function
|
18 |
if ( !is_user_logged_in() )
|
19 |
die('-1');
|
20 |
|
21 |
+
// check for correct NextGEN capability. TODO : Can we check here already for "can_manage_this_gallery($gallery->author)" ?
|
22 |
+
if ( !current_user_can('NextGEN Upload images') && !current_user_can('NextGEN Manage gallery') )
|
23 |
die('-1');
|
24 |
|
25 |
// include the ngg function
|
changelog.txt
CHANGED
@@ -1,7 +1,14 @@
|
|
1 |
NextGEN Gallery
|
2 |
by Alex Rabe & NextGEN DEV Team
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- Changed : Load Thickbox images via wp_footer()
|
6 |
- Bugfix : Widget setting couldnot be saved
|
7 |
|
1 |
NextGEN Gallery
|
2 |
by Alex Rabe & NextGEN DEV Team
|
3 |
|
4 |
+
V1.3.4 - 07.06.2009
|
5 |
+
- Added : New filter ngg_gallery_object and ngg_image_object
|
6 |
+
- Bugfix : Fix double rendering of a gallery if two album shortcodes are used
|
7 |
+
- Bugfix : Fix for custom field ngg_gal_sort
|
8 |
+
- Bugfix : Changed capapbility check for upload
|
9 |
+
- Bugfix : Check for correct version OR memory limit
|
10 |
+
|
11 |
+
V1.3.3 - 11.06.2009
|
12 |
- Changed : Load Thickbox images via wp_footer()
|
13 |
- Bugfix : Widget setting couldnot be saved
|
14 |
|
lib/core.php
CHANGED
@@ -231,7 +231,6 @@ class nggGallery {
|
|
231 |
|
232 |
'int' => array(
|
233 |
'ngg_gal_Images' => 'galImages',
|
234 |
-
'ngg_gal_Sort' => 'galSort',
|
235 |
'ngg_gal_Columns' => 'galColumns',
|
236 |
'ngg_paged_Galleries' => 'galPagedGalleries',
|
237 |
'ngg_ir_Width' => 'irWidth',
|
231 |
|
232 |
'int' => array(
|
233 |
'ngg_gal_Images' => 'galImages',
|
|
|
234 |
'ngg_gal_Columns' => 'galColumns',
|
235 |
'ngg_paged_Galleries' => 'galPagedGalleries',
|
236 |
'ngg_ir_Width' => 'irWidth',
|
nggallery.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: NextGEN Gallery
|
|
4 |
Plugin URI: http://alexrabe.boelinger.com/?page_id=80
|
5 |
Description: A NextGENeration Photo gallery for the Web 2.0.
|
6 |
Author: Alex Rabe
|
7 |
-
Version: 1.3.
|
8 |
|
9 |
Author URI: http://alexrabe.boelinger.com/
|
10 |
|
@@ -44,7 +44,7 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
|
|
44 |
if (!class_exists('nggLoader')) {
|
45 |
class nggLoader {
|
46 |
|
47 |
-
var $version = '1.3.
|
48 |
var $dbversion = '1.3.1';
|
49 |
var $minium_WP = '2.7';
|
50 |
var $minium_WPMU = '2.7';
|
@@ -59,7 +59,7 @@ class nggLoader {
|
|
59 |
$this->load_textdomain();
|
60 |
|
61 |
// Stop the plugin if we missed the requirements
|
62 |
-
if ( ( !$this->required_version() )
|
63 |
return;
|
64 |
|
65 |
// Get some constants first
|
@@ -229,7 +229,7 @@ class nggLoader {
|
|
229 |
require_once (dirname (__FILE__) . '/lib/core.php'); // 94.840
|
230 |
require_once (dirname (__FILE__) . '/lib/ngg-db.php'); // 132.400
|
231 |
require_once (dirname (__FILE__) . '/lib/image.php'); // 59.424
|
232 |
-
require_once (dirname (__FILE__) . '/widgets/widgets.php');
|
233 |
|
234 |
// We didn't need all stuff during a AJAX operation
|
235 |
if ( defined('DOING_AJAX') )
|
4 |
Plugin URI: http://alexrabe.boelinger.com/?page_id=80
|
5 |
Description: A NextGENeration Photo gallery for the Web 2.0.
|
6 |
Author: Alex Rabe
|
7 |
+
Version: 1.3.4
|
8 |
|
9 |
Author URI: http://alexrabe.boelinger.com/
|
10 |
|
44 |
if (!class_exists('nggLoader')) {
|
45 |
class nggLoader {
|
46 |
|
47 |
+
var $version = '1.3.4';
|
48 |
var $dbversion = '1.3.1';
|
49 |
var $minium_WP = '2.7';
|
50 |
var $minium_WPMU = '2.7';
|
59 |
$this->load_textdomain();
|
60 |
|
61 |
// Stop the plugin if we missed the requirements
|
62 |
+
if ( ( !$this->required_version() ) || ( !$this->check_memory_limit() ) )
|
63 |
return;
|
64 |
|
65 |
// Get some constants first
|
229 |
require_once (dirname (__FILE__) . '/lib/core.php'); // 94.840
|
230 |
require_once (dirname (__FILE__) . '/lib/ngg-db.php'); // 132.400
|
231 |
require_once (dirname (__FILE__) . '/lib/image.php'); // 59.424
|
232 |
+
require_once (dirname (__FILE__) . '/widgets/widgets.php'); // 298.792
|
233 |
|
234 |
// We didn't need all stuff during a AJAX operation
|
235 |
if ( defined('DOING_AJAX') )
|
nggfunctions.php
CHANGED
@@ -1,951 +1,954 @@
|
|
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 |
-
* Return a script for the Imagerotator flash slideshow. Can be used in any tmeplate with <?php echo nggShowSlideshow($galleryID, $width, $height) ?>
|
7 |
-
* Require the script swfobject.js in the header or footer
|
8 |
-
*
|
9 |
-
* @access public
|
10 |
-
* @param integer $galleryID ID of the gallery
|
11 |
-
* @param integer $irWidth Width of the flash container
|
12 |
-
* @param integer $irHeight Height of the flash container
|
13 |
-
* @return the content
|
14 |
-
*/
|
15 |
-
function nggShowSlideshow($galleryID, $width, $height) {
|
16 |
-
|
17 |
-
require_once (dirname (__FILE__).'/lib/swfobject.php');
|
18 |
-
|
19 |
-
$ngg_options = nggGallery::get_option('ngg_options');
|
20 |
-
|
21 |
-
// remove media file from RSS feed
|
22 |
-
if ( is_feed() ) {
|
23 |
-
$out = '[' . nggGallery::i18n($ngg_options['galTextSlide']) . ']';
|
24 |
-
return $out;
|
25 |
-
}
|
26 |
-
|
27 |
-
// If the Imagerotator didn't exist, skip the output
|
28 |
-
if ( NGGALLERY_IREXIST == false )
|
29 |
-
return;
|
30 |
-
|
31 |
-
if (empty($width) ) $width = (int) $ngg_options['irWidth'];
|
32 |
-
if (empty($height)) $height = (int) $ngg_options['irHeight'];
|
33 |
-
|
34 |
-
// init the flash output
|
35 |
-
$swfobject = new swfobject( $ngg_options['irURL'] , 'so' . $galleryID, $width, $height, '7.0.0', 'false');
|
36 |
-
|
37 |
-
$swfobject->message = '<p>'. __('The <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> and <a href="http://www.mozilla.com/firefox/">a browser with Javascript support</a> are needed..', 'nggallery').'</p>';
|
38 |
-
$swfobject->add_params('wmode', 'opaque');
|
39 |
-
$swfobject->add_params('allowfullscreen', 'true');
|
40 |
-
$swfobject->add_params('bgcolor', $ngg_options['irScreencolor'], '000000', 'string', '#');
|
41 |
-
$swfobject->add_attributes('styleclass', 'slideshow');
|
42 |
-
$swfobject->add_attributes('name', 'so' . $galleryID);
|
43 |
-
|
44 |
-
// adding the flash parameter
|
45 |
-
$swfobject->add_flashvars( 'file', NGGALLERY_URLPATH.'xml/imagerotator.php?gid=' . $galleryID );
|
46 |
-
$swfobject->add_flashvars( 'shuffle', $ngg_options['irShuffle'], 'true', 'bool');
|
47 |
-
$swfobject->add_flashvars( 'linkfromdisplay', $ngg_options['irLinkfromdisplay'], 'false', 'bool');
|
48 |
-
$swfobject->add_flashvars( 'shownavigation', $ngg_options['irShownavigation'], 'true', 'bool');
|
49 |
-
$swfobject->add_flashvars( 'showicons', $ngg_options['irShowicons'], 'true', 'bool');
|
50 |
-
$swfobject->add_flashvars( 'kenburns', $ngg_options['irKenburns'], 'false', 'bool');
|
51 |
-
$swfobject->add_flashvars( 'overstretch', $ngg_options['irOverstretch'], 'false', 'string');
|
52 |
-
$swfobject->add_flashvars( 'rotatetime', $ngg_options['irRotatetime'], 5, 'int');
|
53 |
-
$swfobject->add_flashvars( 'transition', $ngg_options['irTransition'], 'random', 'string');
|
54 |
-
$swfobject->add_flashvars( 'backcolor', $ngg_options['irBackcolor'], 'FFFFFF', 'string', '0x');
|
55 |
-
$swfobject->add_flashvars( 'frontcolor', $ngg_options['irFrontcolor'], '000000', 'string', '0x');
|
56 |
-
$swfobject->add_flashvars( 'lightcolor', $ngg_options['irLightcolor'], '000000', 'string', '0x');
|
57 |
-
$swfobject->add_flashvars( 'screencolor', $ngg_options['irScreencolor'], '000000', 'string', '0x');
|
58 |
-
if ($ngg_options['irWatermark'])
|
59 |
-
$swfobject->add_flashvars( 'logo', $ngg_options['wmPath'], '', 'string');
|
60 |
-
$swfobject->add_flashvars( 'audio', $ngg_options['irAudio'], '', 'string');
|
61 |
-
$swfobject->add_flashvars( 'width', $width, '260');
|
62 |
-
$swfobject->add_flashvars( 'height', $height, '320');
|
63 |
-
// create the output
|
64 |
-
$out = '<div class="slideshow">' . $swfobject->output() . '</div>';
|
65 |
-
// add now the script code
|
66 |
-
$out .= "\n".'<script type="text/javascript" defer="defer">';
|
67 |
-
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'<!--';
|
68 |
-
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'//<![CDATA[';
|
69 |
-
$out .= $swfobject->javascript();
|
70 |
-
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'//]]>';
|
71 |
-
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'-->';
|
72 |
-
$out .= "\n".'</script>';
|
73 |
-
|
74 |
-
$out = apply_filters('ngg_show_slideshow_content', $out);
|
75 |
-
|
76 |
-
return $out;
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* nggShowGallery() - return a gallery
|
81 |
-
*
|
82 |
-
* @access public
|
83 |
-
* @param int $galleryID
|
84 |
-
* @param string $template (optional) name for a template file, look for gallery-$template
|
85 |
-
* @return the content
|
86 |
-
*/
|
87 |
-
function nggShowGallery( $galleryID, $template = '' ) {
|
88 |
-
|
89 |
-
global $nggRewrite;
|
90 |
-
|
91 |
-
$ngg_options = nggGallery::get_option('ngg_options');
|
92 |
-
|
93 |
-
//Set sort order value, if not used (upgrade issue)
|
94 |
-
$ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
|
95 |
-
$ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
|
96 |
-
|
97 |
-
// get gallery values
|
98 |
-
$picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
|
99 |
-
|
100 |
-
if ( !$picturelist->gid )
|
101 |
-
__('[Gallery not found]','nggallery');
|
102 |
-
else
|
103 |
-
$galleryID = (int) $picturelist->gid;
|
104 |
-
|
105 |
-
// $_GET from wp_query
|
106 |
-
$show = get_query_var('show');
|
107 |
-
$pid = get_query_var('pid');
|
108 |
-
$pageid = get_query_var('pageid');
|
109 |
-
|
110 |
-
// set $show if slideshow first
|
111 |
-
if ( empty( $show ) AND ($ngg_options['galShowOrder'] == 'slide')) {
|
112 |
-
if ( is_home() )
|
113 |
-
$pageid = get_the_ID();
|
114 |
-
|
115 |
-
$show = 'slide';
|
116 |
-
}
|
117 |
-
|
118 |
-
// go on only on this page
|
119 |
-
if ( !is_home() || $pageid == get_the_ID() ) {
|
120 |
-
|
121 |
-
// 1st look for ImageBrowser link
|
122 |
-
if ( !empty($pid) && $ngg_options['galImgBrowser'] ) {
|
123 |
-
$out = nggShowImageBrowser( $galleryID, $mode );
|
124 |
-
return $out;
|
125 |
-
}
|
126 |
-
|
127 |
-
// 2nd look for slideshow
|
128 |
-
if ( $show == 'slide' ) {
|
129 |
-
$args['show'] = "gallery";
|
130 |
-
$out = '<div class="ngg-galleryoverview">';
|
131 |
-
$out .= '<div class="slideshowlink"><a class="slideshowlink" href="' . $nggRewrite->get_permalink($args) . '">'.nggGallery::i18n($ngg_options['galTextGallery']).'</a></div>';
|
132 |
-
$out .= nggShowSlideshow($galleryID, $ngg_options['irWidth'], $ngg_options['irHeight']);
|
133 |
-
$out .= '</div>'."\n";
|
134 |
-
$out .= '<div class="ngg-clear"></div>'."\n";
|
135 |
-
return $out;
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
// get all picture with this galleryid
|
140 |
-
if ( is_array($picturelist) )
|
141 |
-
$out = nggCreateGallery($picturelist, $galleryID, $template);
|
142 |
-
|
143 |
-
$out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID));
|
144 |
-
return $out;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Build a gallery output
|
149 |
-
*
|
150 |
-
* @access internal
|
151 |
-
* @param array $picturelist
|
152 |
-
* @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link
|
153 |
-
* @param string $template (optional) name for a template file, look for gallery-$template
|
154 |
-
* @return the content
|
155 |
-
*/
|
156 |
-
function nggCreateGallery($picturelist, $galleryID = false, $template = '') {
|
157 |
-
global $nggRewrite;
|
158 |
-
|
159 |
-
$ngg_options = nggGallery::get_option('ngg_options');
|
160 |
-
|
161 |
-
// $_GET from wp_query
|
162 |
-
$nggpage = get_query_var('nggpage');
|
163 |
-
$pageid = get_query_var('pageid');
|
164 |
-
|
165 |
-
// we need to know the current page id
|
166 |
-
$current_page = (get_the_ID() == false) ? 0 : get_the_ID();
|
167 |
-
|
168 |
-
if ( !is_array($picturelist) )
|
169 |
-
$picturelist = array($picturelist);
|
170 |
-
|
171 |
-
// Populate galleries values from the first image
|
172 |
-
$first_image = current($picturelist);
|
173 |
-
$gallery = new stdclass;
|
174 |
-
$gallery->ID = (int) $galleryID;
|
175 |
-
$gallery->show_slideshow = false;
|
176 |
-
$gallery->name = stripslashes ( $first_image->name );
|
177 |
-
$gallery->title = stripslashes( $first_image->title );
|
178 |
-
$gallery->description = html_entity_decode(stripslashes( $first_image->galdesc));
|
179 |
-
$gallery->pageid = $first_image->pageid;
|
180 |
-
$gallery->anchor = 'ngg-gallery-' . $galleryID . '-' . $current_page;
|
181 |
-
reset($picturelist);
|
182 |
-
|
183 |
-
$maxElement = $ngg_options['galImages'];
|
184 |
-
$thumbwidth = $ngg_options['thumbwidth'];
|
185 |
-
$thumbheight = $ngg_options['thumbheight'];
|
186 |
-
|
187 |
-
// fixed width if needed
|
188 |
-
$gallery->columns = intval($ngg_options['galColumns']);
|
189 |
-
$gallery->imagewidth = ($gallery->columns > 0) ? 'style="width:'. floor(100/$gallery->columns) .'%;"' : '';
|
190 |
-
|
191 |
-
// set thumb size
|
192 |
-
$thumbsize = '';
|
193 |
-
if ($ngg_options['thumbfix']) $thumbsize = 'width="'.$thumbwidth.'" height="'.$thumbheight.'"';
|
194 |
-
if ($ngg_options['thumbcrop']) $thumbsize = 'width="'.$thumbwidth.'" height="'.$thumbwidth.'"';
|
195 |
-
|
196 |
-
// show slideshow link
|
197 |
-
if ($galleryID) {
|
198 |
-
if (($ngg_options['galShowSlide']) AND (NGGALLERY_IREXIST)) {
|
199 |
-
$gallery->show_slideshow = true;
|
200 |
-
$gallery->slideshow_link = $nggRewrite->get_permalink(array ('show' => "slide"));
|
201 |
-
$gallery->slideshow_link_text = nggGallery::i18n($ngg_options['galTextSlide']);
|
202 |
-
}
|
203 |
-
|
204 |
-
if ($ngg_options['usePicLens']) {
|
205 |
-
$gallery->show_piclens = true;
|
206 |
-
$gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars( nggMediaRss::get_gallery_mrss_url($gallery->ID) ) . "'});";
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
// check for page navigation
|
211 |
-
if ($maxElement > 0) {
|
212 |
-
if ( !is_home() || $pageid == $current_page ) {
|
213 |
-
$page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
|
214 |
-
}
|
215 |
-
else $page = 1;
|
216 |
-
|
217 |
-
$start = $offset = ( $page - 1 ) * $maxElement;
|
218 |
-
|
219 |
-
$total = count($picturelist);
|
220 |
-
|
221 |
-
// remove the element if we didn't start at the beginning
|
222 |
-
if ($start > 0 ) array_splice($picturelist, 0, $start);
|
223 |
-
|
224 |
-
// return the list of images we need
|
225 |
-
array_splice($picturelist, $maxElement);
|
226 |
-
|
227 |
-
$navigation = nggGallery::create_navigation($page, $total, $maxElement);
|
228 |
-
} else {
|
229 |
-
$navigation = '<div class="ngg-clear"> </div>';
|
230 |
-
}
|
231 |
-
|
232 |
-
foreach ($picturelist as $key => $picture) {
|
233 |
-
// choose link between imagebrowser or effect
|
234 |
-
$link = ($ngg_options['galImgBrowser']) ? $nggRewrite->get_permalink( array('pid'=>$picture->pid) ) : $picture->imageURL;
|
235 |
-
|
236 |
-
// get the effect code
|
237 |
-
if ($galleryID)
|
238 |
-
$thumbcode = ($ngg_options['galImgBrowser']) ? '' : $picture->get_thumbcode($picturelist[0]->name);
|
239 |
-
else
|
240 |
-
$thumbcode = ($ngg_options['galImgBrowser']) ? '' : $picture->get_thumbcode(get_the_title());
|
241 |
-
|
242 |
-
// add a filter for the link
|
243 |
-
$picturelist[$key]->imageURL = apply_filters('ngg_create_gallery_link', $link, $picture);
|
244 |
-
$picturelist[$key]->thumbnailURL = $picture->thumbURL;
|
245 |
-
$picturelist[$key]->size = $thumbsize;
|
246 |
-
$picturelist[$key]->thumbcode = $thumbcode;
|
247 |
-
$picturelist[$key]->caption = ( empty($picture->description) ) ? ' ' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->description)) );
|
248 |
-
$picturelist[$key]->description = ( empty($picture->description) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->description)) );
|
249 |
-
$picturelist[$key]->alttext = ( empty($picture->alttext) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->alttext)) );
|
250 |
-
// filter to add custom content for the output
|
251 |
-
$picturelist[$key] = apply_filters('ngg_image_object', $picturelist[$key], $picture->pid);
|
252 |
-
}
|
253 |
-
|
254 |
-
// look for gallery-$template.php or pure gallery.php
|
255 |
-
$filename = ( empty($template) ) ? 'gallery' : 'gallery-' . $template;
|
256 |
-
|
257 |
-
//
|
258 |
-
$
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
*
|
272 |
-
*
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
//
|
281 |
-
$
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
*
|
329 |
-
*
|
330 |
-
* @
|
331 |
-
* @
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
$
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
$
|
345 |
-
|
346 |
-
|
347 |
-
$
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
$
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
//
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
$galleries[$key]->
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
$
|
392 |
-
|
393 |
-
|
394 |
-
$
|
395 |
-
$
|
396 |
-
$
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
$
|
410 |
-
$galleries[$key]->
|
411 |
-
|
412 |
-
$
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
$
|
421 |
-
|
422 |
-
|
423 |
-
$galleries[$key]->pagelink = get_permalink(
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
//
|
430 |
-
$galleries[$key]->
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
//
|
448 |
-
array_splice($galleries, $
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
//
|
459 |
-
$
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
*
|
470 |
-
*
|
471 |
-
* @
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
$ngg_options
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
$
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
*
|
502 |
-
*
|
503 |
-
* @
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
//
|
515 |
-
$
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
$act_pid =
|
528 |
-
}
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
$
|
541 |
-
|
542 |
-
//
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
$picture->
|
551 |
-
$picture->
|
552 |
-
$picture->
|
553 |
-
$picture->
|
554 |
-
$picture->
|
555 |
-
$picture->
|
556 |
-
$picture->
|
557 |
-
$picture->
|
558 |
-
|
559 |
-
|
560 |
-
$picture =
|
561 |
-
|
562 |
-
//
|
563 |
-
$
|
564 |
-
|
565 |
-
|
566 |
-
$
|
567 |
-
|
568 |
-
|
569 |
-
$
|
570 |
-
|
571 |
-
//
|
572 |
-
$
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
*
|
583 |
-
*
|
584 |
-
* @
|
585 |
-
* @param
|
586 |
-
* @param
|
587 |
-
* @param
|
588 |
-
* @param string $
|
589 |
-
* @
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
$
|
598 |
-
|
599 |
-
//
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
//
|
627 |
-
$
|
628 |
-
|
629 |
-
//
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
$picture->
|
642 |
-
$picture->
|
643 |
-
$picture->
|
644 |
-
$picture->
|
645 |
-
$picture->
|
646 |
-
$picture->
|
647 |
-
|
648 |
-
|
649 |
-
$picture =
|
650 |
-
|
651 |
-
//
|
652 |
-
$
|
653 |
-
|
654 |
-
|
655 |
-
$
|
656 |
-
|
657 |
-
|
658 |
-
$
|
659 |
-
|
660 |
-
//
|
661 |
-
$
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
*
|
673 |
-
*
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
$
|
683 |
-
|
684 |
-
//
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
$
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
*
|
711 |
-
*
|
712 |
-
* @
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
$
|
720 |
-
|
721 |
-
//
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
$
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
*
|
752 |
-
*
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
$
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
$
|
770 |
-
$
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
//
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
$picturelist[$key]->
|
789 |
-
$picturelist[$key]->
|
790 |
-
$picturelist[$key]->
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
//
|
797 |
-
$
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
*
|
809 |
-
*
|
810 |
-
* @
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
*
|
857 |
-
*
|
858 |
-
* @
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
*
|
869 |
-
*
|
870 |
-
* @
|
871 |
-
* @
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
$
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
*
|
913 |
-
*
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
$
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
|
|
|
|
|
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 |
+
* Return a script for the Imagerotator flash slideshow. Can be used in any tmeplate with <?php echo nggShowSlideshow($galleryID, $width, $height) ?>
|
7 |
+
* Require the script swfobject.js in the header or footer
|
8 |
+
*
|
9 |
+
* @access public
|
10 |
+
* @param integer $galleryID ID of the gallery
|
11 |
+
* @param integer $irWidth Width of the flash container
|
12 |
+
* @param integer $irHeight Height of the flash container
|
13 |
+
* @return the content
|
14 |
+
*/
|
15 |
+
function nggShowSlideshow($galleryID, $width, $height) {
|
16 |
+
|
17 |
+
require_once (dirname (__FILE__).'/lib/swfobject.php');
|
18 |
+
|
19 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
20 |
+
|
21 |
+
// remove media file from RSS feed
|
22 |
+
if ( is_feed() ) {
|
23 |
+
$out = '[' . nggGallery::i18n($ngg_options['galTextSlide']) . ']';
|
24 |
+
return $out;
|
25 |
+
}
|
26 |
+
|
27 |
+
// If the Imagerotator didn't exist, skip the output
|
28 |
+
if ( NGGALLERY_IREXIST == false )
|
29 |
+
return;
|
30 |
+
|
31 |
+
if (empty($width) ) $width = (int) $ngg_options['irWidth'];
|
32 |
+
if (empty($height)) $height = (int) $ngg_options['irHeight'];
|
33 |
+
|
34 |
+
// init the flash output
|
35 |
+
$swfobject = new swfobject( $ngg_options['irURL'] , 'so' . $galleryID, $width, $height, '7.0.0', 'false');
|
36 |
+
|
37 |
+
$swfobject->message = '<p>'. __('The <a href="http://www.macromedia.com/go/getflashplayer">Flash Player</a> and <a href="http://www.mozilla.com/firefox/">a browser with Javascript support</a> are needed..', 'nggallery').'</p>';
|
38 |
+
$swfobject->add_params('wmode', 'opaque');
|
39 |
+
$swfobject->add_params('allowfullscreen', 'true');
|
40 |
+
$swfobject->add_params('bgcolor', $ngg_options['irScreencolor'], '000000', 'string', '#');
|
41 |
+
$swfobject->add_attributes('styleclass', 'slideshow');
|
42 |
+
$swfobject->add_attributes('name', 'so' . $galleryID);
|
43 |
+
|
44 |
+
// adding the flash parameter
|
45 |
+
$swfobject->add_flashvars( 'file', NGGALLERY_URLPATH.'xml/imagerotator.php?gid=' . $galleryID );
|
46 |
+
$swfobject->add_flashvars( 'shuffle', $ngg_options['irShuffle'], 'true', 'bool');
|
47 |
+
$swfobject->add_flashvars( 'linkfromdisplay', $ngg_options['irLinkfromdisplay'], 'false', 'bool');
|
48 |
+
$swfobject->add_flashvars( 'shownavigation', $ngg_options['irShownavigation'], 'true', 'bool');
|
49 |
+
$swfobject->add_flashvars( 'showicons', $ngg_options['irShowicons'], 'true', 'bool');
|
50 |
+
$swfobject->add_flashvars( 'kenburns', $ngg_options['irKenburns'], 'false', 'bool');
|
51 |
+
$swfobject->add_flashvars( 'overstretch', $ngg_options['irOverstretch'], 'false', 'string');
|
52 |
+
$swfobject->add_flashvars( 'rotatetime', $ngg_options['irRotatetime'], 5, 'int');
|
53 |
+
$swfobject->add_flashvars( 'transition', $ngg_options['irTransition'], 'random', 'string');
|
54 |
+
$swfobject->add_flashvars( 'backcolor', $ngg_options['irBackcolor'], 'FFFFFF', 'string', '0x');
|
55 |
+
$swfobject->add_flashvars( 'frontcolor', $ngg_options['irFrontcolor'], '000000', 'string', '0x');
|
56 |
+
$swfobject->add_flashvars( 'lightcolor', $ngg_options['irLightcolor'], '000000', 'string', '0x');
|
57 |
+
$swfobject->add_flashvars( 'screencolor', $ngg_options['irScreencolor'], '000000', 'string', '0x');
|
58 |
+
if ($ngg_options['irWatermark'])
|
59 |
+
$swfobject->add_flashvars( 'logo', $ngg_options['wmPath'], '', 'string');
|
60 |
+
$swfobject->add_flashvars( 'audio', $ngg_options['irAudio'], '', 'string');
|
61 |
+
$swfobject->add_flashvars( 'width', $width, '260');
|
62 |
+
$swfobject->add_flashvars( 'height', $height, '320');
|
63 |
+
// create the output
|
64 |
+
$out = '<div class="slideshow">' . $swfobject->output() . '</div>';
|
65 |
+
// add now the script code
|
66 |
+
$out .= "\n".'<script type="text/javascript" defer="defer">';
|
67 |
+
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'<!--';
|
68 |
+
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'//<![CDATA[';
|
69 |
+
$out .= $swfobject->javascript();
|
70 |
+
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'//]]>';
|
71 |
+
if ($ngg_options['irXHTMLvalid']) $out .= "\n".'-->';
|
72 |
+
$out .= "\n".'</script>';
|
73 |
+
|
74 |
+
$out = apply_filters('ngg_show_slideshow_content', $out);
|
75 |
+
|
76 |
+
return $out;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* nggShowGallery() - return a gallery
|
81 |
+
*
|
82 |
+
* @access public
|
83 |
+
* @param int $galleryID
|
84 |
+
* @param string $template (optional) name for a template file, look for gallery-$template
|
85 |
+
* @return the content
|
86 |
+
*/
|
87 |
+
function nggShowGallery( $galleryID, $template = '' ) {
|
88 |
+
|
89 |
+
global $nggRewrite;
|
90 |
+
|
91 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
92 |
+
|
93 |
+
//Set sort order value, if not used (upgrade issue)
|
94 |
+
$ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
|
95 |
+
$ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
|
96 |
+
|
97 |
+
// get gallery values
|
98 |
+
$picturelist = nggdb::get_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
|
99 |
+
|
100 |
+
if ( !$picturelist->gid )
|
101 |
+
__('[Gallery not found]','nggallery');
|
102 |
+
else
|
103 |
+
$galleryID = (int) $picturelist->gid;
|
104 |
+
|
105 |
+
// $_GET from wp_query
|
106 |
+
$show = get_query_var('show');
|
107 |
+
$pid = get_query_var('pid');
|
108 |
+
$pageid = get_query_var('pageid');
|
109 |
+
|
110 |
+
// set $show if slideshow first
|
111 |
+
if ( empty( $show ) AND ($ngg_options['galShowOrder'] == 'slide')) {
|
112 |
+
if ( is_home() )
|
113 |
+
$pageid = get_the_ID();
|
114 |
+
|
115 |
+
$show = 'slide';
|
116 |
+
}
|
117 |
+
|
118 |
+
// go on only on this page
|
119 |
+
if ( !is_home() || $pageid == get_the_ID() ) {
|
120 |
+
|
121 |
+
// 1st look for ImageBrowser link
|
122 |
+
if ( !empty($pid) && $ngg_options['galImgBrowser'] ) {
|
123 |
+
$out = nggShowImageBrowser( $galleryID, $mode );
|
124 |
+
return $out;
|
125 |
+
}
|
126 |
+
|
127 |
+
// 2nd look for slideshow
|
128 |
+
if ( $show == 'slide' ) {
|
129 |
+
$args['show'] = "gallery";
|
130 |
+
$out = '<div class="ngg-galleryoverview">';
|
131 |
+
$out .= '<div class="slideshowlink"><a class="slideshowlink" href="' . $nggRewrite->get_permalink($args) . '">'.nggGallery::i18n($ngg_options['galTextGallery']).'</a></div>';
|
132 |
+
$out .= nggShowSlideshow($galleryID, $ngg_options['irWidth'], $ngg_options['irHeight']);
|
133 |
+
$out .= '</div>'."\n";
|
134 |
+
$out .= '<div class="ngg-clear"></div>'."\n";
|
135 |
+
return $out;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
// get all picture with this galleryid
|
140 |
+
if ( is_array($picturelist) )
|
141 |
+
$out = nggCreateGallery($picturelist, $galleryID, $template);
|
142 |
+
|
143 |
+
$out = apply_filters('ngg_show_gallery_content', $out, intval($galleryID));
|
144 |
+
return $out;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Build a gallery output
|
149 |
+
*
|
150 |
+
* @access internal
|
151 |
+
* @param array $picturelist
|
152 |
+
* @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link
|
153 |
+
* @param string $template (optional) name for a template file, look for gallery-$template
|
154 |
+
* @return the content
|
155 |
+
*/
|
156 |
+
function nggCreateGallery($picturelist, $galleryID = false, $template = '') {
|
157 |
+
global $nggRewrite;
|
158 |
+
|
159 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
160 |
+
|
161 |
+
// $_GET from wp_query
|
162 |
+
$nggpage = get_query_var('nggpage');
|
163 |
+
$pageid = get_query_var('pageid');
|
164 |
+
|
165 |
+
// we need to know the current page id
|
166 |
+
$current_page = (get_the_ID() == false) ? 0 : get_the_ID();
|
167 |
+
|
168 |
+
if ( !is_array($picturelist) )
|
169 |
+
$picturelist = array($picturelist);
|
170 |
+
|
171 |
+
// Populate galleries values from the first image
|
172 |
+
$first_image = current($picturelist);
|
173 |
+
$gallery = new stdclass;
|
174 |
+
$gallery->ID = (int) $galleryID;
|
175 |
+
$gallery->show_slideshow = false;
|
176 |
+
$gallery->name = stripslashes ( $first_image->name );
|
177 |
+
$gallery->title = stripslashes( $first_image->title );
|
178 |
+
$gallery->description = html_entity_decode(stripslashes( $first_image->galdesc));
|
179 |
+
$gallery->pageid = $first_image->pageid;
|
180 |
+
$gallery->anchor = 'ngg-gallery-' . $galleryID . '-' . $current_page;
|
181 |
+
reset($picturelist);
|
182 |
+
|
183 |
+
$maxElement = $ngg_options['galImages'];
|
184 |
+
$thumbwidth = $ngg_options['thumbwidth'];
|
185 |
+
$thumbheight = $ngg_options['thumbheight'];
|
186 |
+
|
187 |
+
// fixed width if needed
|
188 |
+
$gallery->columns = intval($ngg_options['galColumns']);
|
189 |
+
$gallery->imagewidth = ($gallery->columns > 0) ? 'style="width:'. floor(100/$gallery->columns) .'%;"' : '';
|
190 |
+
|
191 |
+
// set thumb size
|
192 |
+
$thumbsize = '';
|
193 |
+
if ($ngg_options['thumbfix']) $thumbsize = 'width="'.$thumbwidth.'" height="'.$thumbheight.'"';
|
194 |
+
if ($ngg_options['thumbcrop']) $thumbsize = 'width="'.$thumbwidth.'" height="'.$thumbwidth.'"';
|
195 |
+
|
196 |
+
// show slideshow link
|
197 |
+
if ($galleryID) {
|
198 |
+
if (($ngg_options['galShowSlide']) AND (NGGALLERY_IREXIST)) {
|
199 |
+
$gallery->show_slideshow = true;
|
200 |
+
$gallery->slideshow_link = $nggRewrite->get_permalink(array ('show' => "slide"));
|
201 |
+
$gallery->slideshow_link_text = nggGallery::i18n($ngg_options['galTextSlide']);
|
202 |
+
}
|
203 |
+
|
204 |
+
if ($ngg_options['usePicLens']) {
|
205 |
+
$gallery->show_piclens = true;
|
206 |
+
$gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars( nggMediaRss::get_gallery_mrss_url($gallery->ID) ) . "'});";
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
// check for page navigation
|
211 |
+
if ($maxElement > 0) {
|
212 |
+
if ( !is_home() || $pageid == $current_page ) {
|
213 |
+
$page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
|
214 |
+
}
|
215 |
+
else $page = 1;
|
216 |
+
|
217 |
+
$start = $offset = ( $page - 1 ) * $maxElement;
|
218 |
+
|
219 |
+
$total = count($picturelist);
|
220 |
+
|
221 |
+
// remove the element if we didn't start at the beginning
|
222 |
+
if ($start > 0 ) array_splice($picturelist, 0, $start);
|
223 |
+
|
224 |
+
// return the list of images we need
|
225 |
+
array_splice($picturelist, $maxElement);
|
226 |
+
|
227 |
+
$navigation = nggGallery::create_navigation($page, $total, $maxElement);
|
228 |
+
} else {
|
229 |
+
$navigation = '<div class="ngg-clear"> </div>';
|
230 |
+
}
|
231 |
+
|
232 |
+
foreach ($picturelist as $key => $picture) {
|
233 |
+
// choose link between imagebrowser or effect
|
234 |
+
$link = ($ngg_options['galImgBrowser']) ? $nggRewrite->get_permalink( array('pid'=>$picture->pid) ) : $picture->imageURL;
|
235 |
+
|
236 |
+
// get the effect code
|
237 |
+
if ($galleryID)
|
238 |
+
$thumbcode = ($ngg_options['galImgBrowser']) ? '' : $picture->get_thumbcode($picturelist[0]->name);
|
239 |
+
else
|
240 |
+
$thumbcode = ($ngg_options['galImgBrowser']) ? '' : $picture->get_thumbcode(get_the_title());
|
241 |
+
|
242 |
+
// add a filter for the link
|
243 |
+
$picturelist[$key]->imageURL = apply_filters('ngg_create_gallery_link', $link, $picture);
|
244 |
+
$picturelist[$key]->thumbnailURL = $picture->thumbURL;
|
245 |
+
$picturelist[$key]->size = $thumbsize;
|
246 |
+
$picturelist[$key]->thumbcode = $thumbcode;
|
247 |
+
$picturelist[$key]->caption = ( empty($picture->description) ) ? ' ' : html_entity_decode ( stripslashes(nggGallery::i18n($picture->description)) );
|
248 |
+
$picturelist[$key]->description = ( empty($picture->description) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->description)) );
|
249 |
+
$picturelist[$key]->alttext = ( empty($picture->alttext) ) ? ' ' : htmlspecialchars ( stripslashes(nggGallery::i18n($picture->alttext)) );
|
250 |
+
// filter to add custom content for the output
|
251 |
+
$picturelist[$key] = apply_filters('ngg_image_object', $picturelist[$key], $picture->pid);
|
252 |
+
}
|
253 |
+
|
254 |
+
// look for gallery-$template.php or pure gallery.php
|
255 |
+
$filename = ( empty($template) ) ? 'gallery' : 'gallery-' . $template;
|
256 |
+
|
257 |
+
//filter functions for custom addons
|
258 |
+
$gallery = apply_filters( 'ngg_gallery_object', $gallery, $galleryID );
|
259 |
+
$picturelist = apply_filters( 'ngg_image_object', $picturelist, $galleryID );
|
260 |
+
|
261 |
+
// create the output
|
262 |
+
$out = nggGallery::capture ( $filename, array ('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation) );
|
263 |
+
|
264 |
+
// apply a filter after the output
|
265 |
+
$out = apply_filters('ngg_gallery_output', $out, $picturelist);
|
266 |
+
|
267 |
+
return $out;
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* nggShowAlbum() - return a album based on the id
|
272 |
+
*
|
273 |
+
* @access public
|
274 |
+
* @param int | string $albumID
|
275 |
+
* @param string (optional) $template
|
276 |
+
* @return the content
|
277 |
+
*/
|
278 |
+
function nggShowAlbum($albumID, $template = 'extend') {
|
279 |
+
|
280 |
+
// $_GET from wp_query
|
281 |
+
$gallery = get_query_var('gallery');
|
282 |
+
$album = get_query_var('album');
|
283 |
+
|
284 |
+
// in the case somebody uses the '0', it should be 'all' to show all galleries
|
285 |
+
$albumID = ($albumID == 0) ? 'all' : $albumID;
|
286 |
+
|
287 |
+
// first look for gallery variable
|
288 |
+
if (!empty( $gallery )) {
|
289 |
+
|
290 |
+
// subalbum support only one instance, you can't use more of them in one post
|
291 |
+
if ( isset($GLOBALS['subalbum']) || isset($GLOBALS['nggShowGallery']) )
|
292 |
+
return;
|
293 |
+
|
294 |
+
// if gallery is is submit , then show the gallery instead
|
295 |
+
$out = nggShowGallery( intval($gallery) );
|
296 |
+
$GLOBALS['nggShowGallery'] = true;
|
297 |
+
|
298 |
+
return $out;
|
299 |
+
}
|
300 |
+
|
301 |
+
if ( (empty( $gallery )) && (isset($GLOBALS['subalbum'])) )
|
302 |
+
return;
|
303 |
+
|
304 |
+
//redirect to subalbum only one time
|
305 |
+
if (!empty( $album )) {
|
306 |
+
$GLOBALS['subalbum'] = true;
|
307 |
+
$albumID = $album;
|
308 |
+
}
|
309 |
+
|
310 |
+
// lookup in the database
|
311 |
+
$album = nggdb::find_album( $albumID );
|
312 |
+
|
313 |
+
// still no success ? , die !
|
314 |
+
if( !$album )
|
315 |
+
return __('[Album not found]','nggallery');
|
316 |
+
|
317 |
+
$mode = ltrim($mode, ',');
|
318 |
+
|
319 |
+
if ( is_array($album->gallery_ids) )
|
320 |
+
$out = nggCreateAlbum( $album->gallery_ids, $template, $album );
|
321 |
+
|
322 |
+
$out = apply_filters( 'ngg_show_album_content', $out, $album->id );
|
323 |
+
|
324 |
+
return $out;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* nggCreateAlbum()
|
329 |
+
*
|
330 |
+
* @access internal
|
331 |
+
* @param array $galleriesID
|
332 |
+
* @param string (optional) $template name for a template file, look for album-$template
|
333 |
+
* @param object (optional) $album result from the db
|
334 |
+
* @return the content
|
335 |
+
*/
|
336 |
+
function nggCreateAlbum( $galleriesID, $template = 'extend', $album = 0) {
|
337 |
+
// create a gallery overview div
|
338 |
+
|
339 |
+
global $wpdb, $nggRewrite, $nggdb;
|
340 |
+
|
341 |
+
// $_GET from wp_query
|
342 |
+
$nggpage = get_query_var('nggpage');
|
343 |
+
|
344 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
345 |
+
|
346 |
+
//this option can currently only set via the custom fields
|
347 |
+
$maxElement = (int) $ngg_options['galPagedGalleries'];
|
348 |
+
|
349 |
+
$sortorder = $galleriesID;
|
350 |
+
$galleries = array();
|
351 |
+
|
352 |
+
// get the galleries information
|
353 |
+
foreach ($galleriesID as $i => $value)
|
354 |
+
$galleriesID[$i] = addslashes($value);
|
355 |
+
|
356 |
+
$unsort_galleries = $wpdb->get_results('SELECT * FROM '.$wpdb->nggallery.' WHERE gid IN (\''.implode('\',\'', $galleriesID).'\')', OBJECT_K);
|
357 |
+
|
358 |
+
//TODO: Check this, problem exist when previewpic = 0
|
359 |
+
//$galleries = $wpdb->get_results('SELECT t.*, tt.* FROM '.$wpdb->nggallery.' AS t INNER JOIN '.$wpdb->nggpictures.' AS tt ON t.previewpic = tt.pid WHERE t.gid IN (\''.implode('\',\'', $galleriesID).'\')', OBJECT_K);
|
360 |
+
|
361 |
+
// get the counter values
|
362 |
+
$picturesCounter = $wpdb->get_results('SELECT galleryid, COUNT(*) as counter FROM '.$wpdb->nggpictures.' WHERE galleryid IN (\''.implode('\',\'', $galleriesID).'\') AND exclude != 1 GROUP BY galleryid', OBJECT_K);
|
363 |
+
if ( is_array($picturesCounter) ) {
|
364 |
+
foreach ($picturesCounter as $key => $value)
|
365 |
+
$unsort_galleries[$key]->counter = $value->counter;
|
366 |
+
}
|
367 |
+
|
368 |
+
// get the id's of the preview images
|
369 |
+
$imagesID = array();
|
370 |
+
if ( is_array($unsort_galleries) ) {
|
371 |
+
foreach ($unsort_galleries as $gallery_row)
|
372 |
+
$imagesID[] = $gallery_row->previewpic;
|
373 |
+
}
|
374 |
+
$albumPreview = $wpdb->get_results('SELECT pid, filename FROM '.$wpdb->nggpictures.' WHERE pid IN (\''.implode('\',\'', $imagesID).'\')', OBJECT_K);
|
375 |
+
|
376 |
+
// re-order them and populate some
|
377 |
+
foreach ($sortorder as $key) {
|
378 |
+
|
379 |
+
//if we have a prefix 'a' then it's a subalbum, instead a gallery
|
380 |
+
if (substr( $key, 0, 1) == 'a') {
|
381 |
+
// get the album content
|
382 |
+
if ( !$subalbum = $nggdb->find_album(substr( $key, 1)) )
|
383 |
+
continue;
|
384 |
+
|
385 |
+
//populate the sub album values
|
386 |
+
$galleries[$key]->counter = 0;
|
387 |
+
if ($subalbum->previewpic > 0)
|
388 |
+
$image = $nggdb->find_image( $subalbum->previewpic );
|
389 |
+
$galleries[$key]->previewpic = $subalbum->previewpic;
|
390 |
+
$galleries[$key]->previewurl = ($image->thumbURL) ? $image->thumbURL : '';
|
391 |
+
$galleries[$key]->previewname = $subalbum->name;
|
392 |
+
|
393 |
+
//link to the subalbum
|
394 |
+
$args['album'] = $subalbum->id;
|
395 |
+
$args['gallery'] = false;
|
396 |
+
$args['nggpage'] = false;
|
397 |
+
$galleries[$key]->pagelink = $nggRewrite->get_permalink($args);
|
398 |
+
$galleries[$key]->galdesc = html_entity_decode ( nggGallery::i18n($subalbum->albumdesc) );
|
399 |
+
$galleries[$key]->title = html_entity_decode ( nggGallery::i18n($subalbum->name) );
|
400 |
+
|
401 |
+
continue;
|
402 |
+
}
|
403 |
+
|
404 |
+
// Add the counter value if avaible
|
405 |
+
$galleries[$key] = $unsort_galleries[$key];
|
406 |
+
|
407 |
+
// add the file name and the link
|
408 |
+
if ($galleries[$key]->previewpic != 0) {
|
409 |
+
$galleries[$key]->previewname = $albumPreview[$galleries[$key]->previewpic]->filename;
|
410 |
+
$galleries[$key]->previewurl = get_option ('siteurl').'/' . $galleries[$key]->path . '/thumbs/thumbs_' . $albumPreview[$galleries[$key]->previewpic]->filename;
|
411 |
+
} else {
|
412 |
+
$first_image = $wpdb->get_row('SELECT * FROM '. $wpdb->nggpictures .' WHERE exclude != 1 AND galleryid = '. $key .' ORDER by pid DESC limit 0,1');
|
413 |
+
$galleries[$key]->previewpic = $first_image->pid;
|
414 |
+
$galleries[$key]->previewname = $first_image->filename;
|
415 |
+
$galleries[$key]->previewurl = get_option ('siteurl') . '/' . $galleries[$key]->path . '/thumbs/thumbs_' . $first_image->filename;
|
416 |
+
}
|
417 |
+
|
418 |
+
// choose between variable and page link
|
419 |
+
if ($ngg_options['galNoPages']) {
|
420 |
+
$args['album'] = $album->id;
|
421 |
+
$args['gallery'] = $key;
|
422 |
+
$args['nggpage'] = false;
|
423 |
+
$galleries[$key]->pagelink = $nggRewrite->get_permalink($args);
|
424 |
+
|
425 |
+
} else {
|
426 |
+
$galleries[$key]->pagelink = get_permalink( $galleries[$key]->pageid );
|
427 |
+
}
|
428 |
+
|
429 |
+
// description can contain HTML tags
|
430 |
+
$galleries[$key]->galdesc = html_entity_decode ( stripslashes($galleries[$key]->galdesc) ) ;
|
431 |
+
|
432 |
+
// i18n
|
433 |
+
$galleries[$key]->title = html_entity_decode ( nggGallery::i18n($galleries[$key]->title) ) ;
|
434 |
+
}
|
435 |
+
|
436 |
+
// check for page navigation
|
437 |
+
if ($maxElement > 0) {
|
438 |
+
if ( !is_home() || $pageid == get_the_ID() ) {
|
439 |
+
$page = ( !empty( $nggpage ) ) ? (int) $nggpage : 1;
|
440 |
+
}
|
441 |
+
else $page = 1;
|
442 |
+
|
443 |
+
$start = $offset = ( $page - 1 ) * $maxElement;
|
444 |
+
|
445 |
+
$total = count($galleries);
|
446 |
+
|
447 |
+
// remove the element if we didn't start at the beginning
|
448 |
+
if ($start > 0 ) array_splice($galleries, 0, $start);
|
449 |
+
|
450 |
+
// return the list of images we need
|
451 |
+
array_splice($galleries, $maxElement);
|
452 |
+
|
453 |
+
$navigation = nggGallery::create_navigation($page, $total, $maxElement);
|
454 |
+
} else {
|
455 |
+
$navigation = '<div class="ngg-clear"> </div>';
|
456 |
+
}
|
457 |
+
|
458 |
+
// if sombody didn't enter any template , take the extend version
|
459 |
+
$filename = ( empty($template) ) ? 'album-extend' : 'album-' . $template ;
|
460 |
+
|
461 |
+
// create the output
|
462 |
+
$out = nggGallery::capture ( $filename, array ('album' => $album, 'galleries' => $galleries, 'pagination' => $navigation) );
|
463 |
+
|
464 |
+
return $out;
|
465 |
+
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* nggShowImageBrowser()
|
470 |
+
*
|
471 |
+
* @access public
|
472 |
+
* @param int|string $galleryID or gallery name
|
473 |
+
* @param string $template (optional) name for a template file, look for imagebrowser-$template
|
474 |
+
* @return the content
|
475 |
+
*/
|
476 |
+
function nggShowImageBrowser($galleryID, $template = '') {
|
477 |
+
|
478 |
+
global $wpdb;
|
479 |
+
|
480 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
481 |
+
|
482 |
+
//Set sort order value, if not used (upgrade issue)
|
483 |
+
$ngg_options['galSort'] = ($ngg_options['galSort']) ? $ngg_options['galSort'] : 'pid';
|
484 |
+
$ngg_options['galSortDir'] = ($ngg_options['galSortDir'] == 'DESC') ? 'DESC' : 'ASC';
|
485 |
+
|
486 |
+
// get the pictures
|
487 |
+
$picturelist = nggdb::get_ids_from_gallery($galleryID, $ngg_options['galSort'], $ngg_options['galSortDir']);
|
488 |
+
|
489 |
+
if ( is_array($picturelist) )
|
490 |
+
$out = nggCreateImageBrowser($picturelist, $template);
|
491 |
+
else
|
492 |
+
$out = __('[Gallery not found]','nggallery');
|
493 |
+
|
494 |
+
$out = apply_filters('ngg_show_imagebrowser_content', $out, $galleryID);
|
495 |
+
|
496 |
+
return $out;
|
497 |
+
|
498 |
+
}
|
499 |
+
|
500 |
+
/**
|
501 |
+
* nggCreateImageBrowser()
|
502 |
+
*
|
503 |
+
* @access internal
|
504 |
+
* @param array $picarray with pid
|
505 |
+
* @param string $template (optional) name for a template file, look for imagebrowser-$template
|
506 |
+
* @return the content
|
507 |
+
*/
|
508 |
+
function nggCreateImageBrowser($picarray, $template = '') {
|
509 |
+
|
510 |
+
global $nggRewrite;
|
511 |
+
|
512 |
+
require_once( dirname (__FILE__) . '/lib/meta.php' );
|
513 |
+
|
514 |
+
// $_GET from wp_query
|
515 |
+
$pid = get_query_var('pid');
|
516 |
+
|
517 |
+
// we need to know the current page id
|
518 |
+
$current_page = (get_the_ID() == false) ? 0 : get_the_ID();
|
519 |
+
|
520 |
+
if ( !is_array($picarray) )
|
521 |
+
$picarray = array($picarray);
|
522 |
+
|
523 |
+
$total = count($picarray);
|
524 |
+
|
525 |
+
// look for gallery variable
|
526 |
+
if ( !empty( $pid )) {
|
527 |
+
$act_pid = (int) $pid;
|
528 |
+
} else {
|
529 |
+
reset($picarray);
|
530 |
+
$act_pid = current($picarray);
|
531 |
+
}
|
532 |
+
|
533 |
+
// get ids for back/next
|
534 |
+
$key = array_search($act_pid,$picarray);
|
535 |
+
if (!$key) {
|
536 |
+
$act_pid = reset($picarray);
|
537 |
+
$key = key($picarray);
|
538 |
+
}
|
539 |
+
$back_pid = ( $key >= 1 ) ? $picarray[$key-1] : end($picarray) ;
|
540 |
+
$next_pid = ( $key < ($total-1) ) ? $picarray[$key+1] : reset($picarray) ;
|
541 |
+
|
542 |
+
// get the picture data
|
543 |
+
$picture = nggdb::find_image($act_pid);
|
544 |
+
|
545 |
+
// if we didn't get some data, exit now
|
546 |
+
if ($picture == null)
|
547 |
+
return;
|
548 |
+
|
549 |
+
// add more variables for render output
|
550 |
+
$picture->href_link = $picture->get_href_link();
|
551 |
+
$picture->previous_image_link = $nggRewrite->get_permalink(array ('pid' => $back_pid));
|
552 |
+
$picture->previous_pid = $back_pid;
|
553 |
+
$picture->next_image_link = $nggRewrite->get_permalink(array ('pid' => $next_pid));
|
554 |
+
$picture->next_pid = $next_pid;
|
555 |
+
$picture->number = $key + 1;
|
556 |
+
$picture->total = $total;
|
557 |
+
$picture->linktitle = htmlspecialchars( stripslashes($picture->description) );
|
558 |
+
$picture->alttext = html_entity_decode( stripslashes($picture->alttext) );
|
559 |
+
$picture->description = html_entity_decode( stripslashes($picture->description) );
|
560 |
+
$picture->anchor = 'ngg-imagebrowser-' . $picture->galleryid . '-' . $current_page;
|
561 |
+
|
562 |
+
// filter to add custom content for the output
|
563 |
+
$picture = apply_filters('ngg_image_object', $picture, $act_pid);
|
564 |
+
|
565 |
+
// let's get the meta data
|
566 |
+
$meta = new nggMeta($picture->imagePath);
|
567 |
+
$exif = $meta->get_EXIF();
|
568 |
+
$iptc = $meta->get_IPTC();
|
569 |
+
$xmp = $meta->get_XMP();
|
570 |
+
|
571 |
+
// look for imagebrowser-$template.php or pure imagebrowser.php
|
572 |
+
$filename = ( empty($template) ) ? 'imagebrowser' : 'imagebrowser-' . $template;
|
573 |
+
|
574 |
+
// create the output
|
575 |
+
$out = nggGallery::capture ( $filename , array ('image' => $picture , 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp) );
|
576 |
+
|
577 |
+
return $out;
|
578 |
+
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* nggSinglePicture() - show a single picture based on the id
|
583 |
+
*
|
584 |
+
* @access public
|
585 |
+
* @param int $imageID, db-ID of the image
|
586 |
+
* @param int (optional) $width, width of the image
|
587 |
+
* @param int (optional) $height, height of the image
|
588 |
+
* @param string $mode (optional) could be none, watermark, web20
|
589 |
+
* @param string $float (optional) could be none, left, right
|
590 |
+
* @param string $template (optional) name for a template file, look for singlepic-$template
|
591 |
+
* @param string $caption (optional) additional caption text
|
592 |
+
* @return the content
|
593 |
+
*/
|
594 |
+
function nggSinglePicture($imageID, $width = 250, $height = 250, $mode = '', $float = '' , $template = '', $caption = '') {
|
595 |
+
global $post;
|
596 |
+
|
597 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
598 |
+
|
599 |
+
// get picturedata
|
600 |
+
$picture = nggdb::find_image($imageID);
|
601 |
+
|
602 |
+
// if we didn't get some data, exit now
|
603 |
+
if ($picture == null)
|
604 |
+
return __('[SinglePic not found]','nggallery');
|
605 |
+
|
606 |
+
// add float to img
|
607 |
+
switch ($float) {
|
608 |
+
|
609 |
+
case 'left':
|
610 |
+
$float =' ngg-left';
|
611 |
+
break;
|
612 |
+
|
613 |
+
case 'right':
|
614 |
+
$float =' ngg-right';
|
615 |
+
break;
|
616 |
+
|
617 |
+
case 'center':
|
618 |
+
$float =' ngg-center';
|
619 |
+
break;
|
620 |
+
|
621 |
+
default:
|
622 |
+
$float ='';
|
623 |
+
break;
|
624 |
+
}
|
625 |
+
|
626 |
+
// clean mode if needed
|
627 |
+
$mode = ( eregi('web20|watermark', $mode) ) ? $mode : '';
|
628 |
+
|
629 |
+
//let's initiate the url
|
630 |
+
$picture->thumbnailURL = false;
|
631 |
+
|
632 |
+
// check fo cached picture
|
633 |
+
if ( ($ngg_options['imgCacheSinglePic']) && ($post->post_status == 'publish') )
|
634 |
+
$picture->thumbnailURL = $picture->cached_singlepic_file($width, $height, $mode );
|
635 |
+
|
636 |
+
// if we didn't use a cached image then we take the on-the-fly mode
|
637 |
+
if (!$picture->thumbnailURL)
|
638 |
+
$picture->thumbnailURL = NGGALLERY_URLPATH . 'nggshow.php?pid=' . $imageID . '&width=' . $width . '&height=' . $height . '&mode=' . $mode;
|
639 |
+
|
640 |
+
// add more variables for render output
|
641 |
+
$picture->href_link = $picture->get_href_link();
|
642 |
+
$picture->alttext = html_entity_decode( stripslashes($picture->alttext) );
|
643 |
+
$picture->linktitle = htmlspecialchars( stripslashes($picture->description) );
|
644 |
+
$picture->description = html_entity_decode( stripslashes($picture->description) );
|
645 |
+
$picture->classname = 'ngg-singlepic'. $float;
|
646 |
+
$picture->thumbcode = $picture->get_thumbcode( 'singlepic' . $imageID);
|
647 |
+
$picture->height = (int) $height;
|
648 |
+
$picture->width = (int) $width;
|
649 |
+
$picture->caption = $caption;
|
650 |
+
|
651 |
+
// filter to add custom content for the output
|
652 |
+
$picture = apply_filters('ngg_image_object', $picture, $imageID);
|
653 |
+
|
654 |
+
// let's get the meta data
|
655 |
+
$meta = new nggMeta($picture->imagePath);
|
656 |
+
$exif = $meta->get_EXIF();
|
657 |
+
$iptc = $meta->get_IPTC();
|
658 |
+
$xmp = $meta->get_XMP();
|
659 |
+
|
660 |
+
// look for singlepic-$template.php or pure singlepic.php
|
661 |
+
$filename = ( empty($template) ) ? 'singlepic' : 'singlepic-' . $template;
|
662 |
+
|
663 |
+
// create the output
|
664 |
+
$out = nggGallery::capture ( $filename, array ('image' => $picture , 'meta' => $meta, 'exif' => $exif, 'iptc' => $iptc, 'xmp' => $xmp) );
|
665 |
+
|
666 |
+
$out = apply_filters('ngg_show_singlepic_content', $out, $picture );
|
667 |
+
|
668 |
+
return $out;
|
669 |
+
}
|
670 |
+
|
671 |
+
/**
|
672 |
+
* nggShowGalleryTags() - create a gallery based on the tags
|
673 |
+
*
|
674 |
+
* @access public
|
675 |
+
* @param string $taglist list of tags as csv
|
676 |
+
* @return the content
|
677 |
+
*/
|
678 |
+
function nggShowGalleryTags($taglist) {
|
679 |
+
|
680 |
+
// $_GET from wp_query
|
681 |
+
$pid = get_query_var('pid');
|
682 |
+
$pageid = get_query_var('pageid');
|
683 |
+
|
684 |
+
// get now the related images
|
685 |
+
$picturelist = nggTags::find_images_for_tags($taglist , 'ASC');
|
686 |
+
|
687 |
+
// look for ImageBrowser if we have a $_GET('pid')
|
688 |
+
if ( $pageid == get_the_ID() || !is_home() )
|
689 |
+
if (!empty( $pid )) {
|
690 |
+
foreach ($picturelist as $picture) {
|
691 |
+
$picarray[] = $picture->pid;
|
692 |
+
}
|
693 |
+
$out = nggCreateImageBrowser($picarray);
|
694 |
+
return $out;
|
695 |
+
}
|
696 |
+
|
697 |
+
// go on if not empty
|
698 |
+
if ( empty($picturelist) )
|
699 |
+
return;
|
700 |
+
|
701 |
+
// show gallery
|
702 |
+
if ( is_array($picturelist) )
|
703 |
+
$out = nggCreateGallery($picturelist, false);
|
704 |
+
|
705 |
+
$out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist);
|
706 |
+
return $out;
|
707 |
+
}
|
708 |
+
|
709 |
+
/**
|
710 |
+
* nggShowRelatedGallery() - create a gallery based on the tags
|
711 |
+
*
|
712 |
+
* @access public
|
713 |
+
* @param string $taglist list of tags as csv
|
714 |
+
* @param integer $maxImages (optional) limit the number of images to show
|
715 |
+
* @return the content
|
716 |
+
*/
|
717 |
+
function nggShowRelatedGallery($taglist, $maxImages = 0) {
|
718 |
+
|
719 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
720 |
+
|
721 |
+
// get now the related images
|
722 |
+
$picturelist = nggTags::find_images_for_tags($taglist, 'RAND');
|
723 |
+
|
724 |
+
// go on if not empty
|
725 |
+
if ( empty($picturelist) )
|
726 |
+
return;
|
727 |
+
|
728 |
+
// cut the list to maxImages
|
729 |
+
if ( $maxImages > 0 )
|
730 |
+
array_splice($picturelist, $maxImages);
|
731 |
+
|
732 |
+
// *** build the gallery output
|
733 |
+
$out = '<div class="ngg-related-gallery">';
|
734 |
+
foreach ($picturelist as $picture) {
|
735 |
+
|
736 |
+
// get the effect code
|
737 |
+
$thumbcode = $picture->get_thumbcode( __('Related images for', 'nggallery') . ' ' . get_the_title());
|
738 |
+
|
739 |
+
$out .= '<a href="' . $picture->imageURL . '" title="' . stripslashes(nggGallery::i18n($picture->description)) . '" ' . $thumbcode . ' >';
|
740 |
+
$out .= '<img title="' . stripslashes(nggGallery::i18n($picture->alttext)) . '" alt="' . stripslashes(nggGallery::i18n($picture->alttext)) . '" src="' . $picture->thumbURL . '" />';
|
741 |
+
$out .= '</a>' . "\n";
|
742 |
+
}
|
743 |
+
$out .= '</div>' . "\n";
|
744 |
+
|
745 |
+
$out = apply_filters('ngg_show_related_gallery_content', $out, $taglist);
|
746 |
+
|
747 |
+
return $out;
|
748 |
+
}
|
749 |
+
|
750 |
+
/**
|
751 |
+
* nggShowAlbumTags() - create a gallery based on the tags
|
752 |
+
*
|
753 |
+
* @access public
|
754 |
+
* @param string $taglist list of tags as csv
|
755 |
+
* @return the content
|
756 |
+
*/
|
757 |
+
function nggShowAlbumTags($taglist) {
|
758 |
+
|
759 |
+
global $wpdb, $nggRewrite;
|
760 |
+
|
761 |
+
// $_GET from wp_query
|
762 |
+
$tag = get_query_var('gallerytag');
|
763 |
+
$pageid = get_query_var('pageid');
|
764 |
+
|
765 |
+
// look for gallerytag variable
|
766 |
+
if ( $pageid == get_the_ID() || !is_home() ) {
|
767 |
+
if (!empty( $tag )) {
|
768 |
+
|
769 |
+
// avoid this evil code $sql = 'SELECT name FROM wp_ngg_tags WHERE slug = \'slug\' union select concat(0x7c,user_login,0x7c,user_pass,0x7c) from wp_users WHERE 1 = 1';
|
770 |
+
$slug = attribute_escape( $tag );
|
771 |
+
$tagname = $wpdb->get_var( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE slug = %s", $slug ) );
|
772 |
+
$out = '<div id="albumnav"><span><a href="' . get_permalink() . '" title="' . __('Overview', 'nggallery') .' ">'.__('Overview', 'nggallery').'</a> | '.$tagname.'</span></div>';
|
773 |
+
$out .= nggShowGalleryTags($slug);
|
774 |
+
return $out;
|
775 |
+
|
776 |
+
}
|
777 |
+
}
|
778 |
+
|
779 |
+
// get now the related images
|
780 |
+
$picturelist = nggTags::get_album_images($taglist);
|
781 |
+
|
782 |
+
// go on if not empty
|
783 |
+
if ( empty($picturelist) )
|
784 |
+
return;
|
785 |
+
|
786 |
+
// re-structure the object that we can use the standard template
|
787 |
+
foreach ($picturelist as $key => $picture) {
|
788 |
+
$picturelist[$key]->previewpic = $picture->pid;
|
789 |
+
$picturelist[$key]->previewname = $picture->filename;
|
790 |
+
$picturelist[$key]->previewurl = get_option ('siteurl') . '/' . $picture->path . '/thumbs/thumbs_' . $picture->filename;
|
791 |
+
$picturelist[$key]->counter = $picture->count;
|
792 |
+
$picturelist[$key]->title = $picture->name;
|
793 |
+
$picturelist[$key]->pagelink = $nggRewrite->get_permalink( array('gallerytag'=>$picture->slug) );
|
794 |
+
}
|
795 |
+
|
796 |
+
//TODO: Add pagination later
|
797 |
+
$navigation = '<div class="ngg-clear"> </div>';
|
798 |
+
|
799 |
+
// create the output
|
800 |
+
$out = nggGallery::capture ('album-compact', array ('album' => 0, 'galleries' => $picturelist, 'pagination' => $navigation) );
|
801 |
+
|
802 |
+
$out = apply_filters('ngg_show_album_tags_content', $out, $taglist);
|
803 |
+
|
804 |
+
return $out;
|
805 |
+
}
|
806 |
+
|
807 |
+
/**
|
808 |
+
* nggShowRelatedImages() - return related images based on category or tags
|
809 |
+
*
|
810 |
+
* @access public
|
811 |
+
* @param string $type could be 'tags' or 'category'
|
812 |
+
* @param integer $maxImages of images
|
813 |
+
* @return the content
|
814 |
+
*/
|
815 |
+
function nggShowRelatedImages($type = '', $maxImages = 0) {
|
816 |
+
$ngg_options = nggGallery::get_option('ngg_options');
|
817 |
+
|
818 |
+
if ($type == '') {
|
819 |
+
$type = $ngg_options['appendType'];
|
820 |
+
$maxImages = $ngg_options['maxImages'];
|
821 |
+
}
|
822 |
+
|
823 |
+
$sluglist = array();
|
824 |
+
|
825 |
+
switch ($type) {
|
826 |
+
case 'tags':
|
827 |
+
if (function_exists('get_the_tags')) {
|
828 |
+
$taglist = get_the_tags();
|
829 |
+
|
830 |
+
if (is_array($taglist)) {
|
831 |
+
foreach ($taglist as $tag) {
|
832 |
+
$sluglist[] = $tag->slug;
|
833 |
+
}
|
834 |
+
}
|
835 |
+
}
|
836 |
+
break;
|
837 |
+
|
838 |
+
case 'category':
|
839 |
+
$catlist = get_the_category();
|
840 |
+
|
841 |
+
if (is_array($catlist)) {
|
842 |
+
foreach ($catlist as $cat) {
|
843 |
+
$sluglist[] = $cat->category_nicename;
|
844 |
+
}
|
845 |
+
}
|
846 |
+
break;
|
847 |
+
}
|
848 |
+
|
849 |
+
$sluglist = implode(',', $sluglist);
|
850 |
+
$out = nggShowRelatedGallery($sluglist, $maxImages);
|
851 |
+
|
852 |
+
return $out;
|
853 |
+
}
|
854 |
+
|
855 |
+
/**
|
856 |
+
* Template function for theme authors
|
857 |
+
*
|
858 |
+
* @access public
|
859 |
+
* @param string (optional) $type could be 'tags' or 'category'
|
860 |
+
* @param integer (optional) $maxNumbers of images
|
861 |
+
* @return void
|
862 |
+
*/
|
863 |
+
function the_related_images($type = 'tags', $maxNumbers = 7) {
|
864 |
+
echo nggShowRelatedImages($type, $maxNumbers);
|
865 |
+
}
|
866 |
+
|
867 |
+
/**
|
868 |
+
* nggShowRandomRecent($type, $maxImages,$template) - return recent or random images
|
869 |
+
*
|
870 |
+
* @access public
|
871 |
+
* @param string $type 'recent' or 'random'
|
872 |
+
* @param integer $maxImages of images
|
873 |
+
* @param string $template (optional) name for a template file, look for gallery-$template
|
874 |
+
* @return the content
|
875 |
+
*/
|
876 |
+
function nggShowRandomRecent($type, $maxImages, $template = '') {
|
877 |
+
|
878 |
+
// $_GET from wp_query
|
879 |
+
$pid = get_query_var('pid');
|
880 |
+
$pageid = get_query_var('pageid');
|
881 |
+
|
882 |
+
// get now the recent or random images
|
883 |
+
if ($type == 'random')
|
884 |
+
$picturelist = nggdb::get_random_images($maxImages);
|
885 |
+
else
|
886 |
+
$picturelist = nggdb::find_last_images(0, $maxImages, true);
|
887 |
+
|
888 |
+
// look for ImageBrowser if we have a $_GET('pid')
|
889 |
+
if ( $pageid == get_the_ID() || !is_home() )
|
890 |
+
if (!empty( $pid )) {
|
891 |
+
foreach ($picturelist as $picture) {
|
892 |
+
$picarray[] = $picture->pid;
|
893 |
+
}
|
894 |
+
$out = nggCreateImageBrowser($picarray);
|
895 |
+
return $out;
|
896 |
+
}
|
897 |
+
|
898 |
+
// go on if not empty
|
899 |
+
if ( empty($picturelist) )
|
900 |
+
return;
|
901 |
+
|
902 |
+
// show gallery
|
903 |
+
if ( is_array($picturelist) )
|
904 |
+
$out = nggCreateGallery($picturelist, false, $template);
|
905 |
+
|
906 |
+
$out = apply_filters('ngg_show_images_content', $out, $taglist);
|
907 |
+
|
908 |
+
return $out;
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* nggTagCloud() - return a tag cloud based on the wp core tag cloud system
|
913 |
+
*
|
914 |
+
* @param array $args
|
915 |
+
* @param string $template (optional) name for a template file, look for gallery-$template
|
916 |
+
* @return the content
|
917 |
+
*/
|
918 |
+
function nggTagCloud($args ='', $template = '') {
|
919 |
+
global $nggRewrite;
|
920 |
+
|
921 |
+
// $_GET from wp_query
|
922 |
+
$tag = get_query_var('gallerytag');
|
923 |
+
$pageid = get_query_var('pageid');
|
924 |
+
|
925 |
+
// look for gallerytag variable
|
926 |
+
if ( $pageid == get_the_ID() || !is_home() ) {
|
927 |
+
if (!empty( $tag )) {
|
928 |
+
|
929 |
+
$slug = attribute_escape( $tag );
|
930 |
+
$out = nggShowGalleryTags( $slug );
|
931 |
+
return $out;
|
932 |
+
}
|
933 |
+
}
|
934 |
+
|
935 |
+
$defaults = array(
|
936 |
+
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
937 |
+
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
|
938 |
+
'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'ngg_tag'
|
939 |
+
);
|
940 |
+
$args = wp_parse_args( $args, $defaults );
|
941 |
+
|
942 |
+
$tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags
|
943 |
+
|
944 |
+
foreach ($tags as $key => $tag ) {
|
945 |
+
|
946 |
+
$tags[ $key ]->link = $nggRewrite->get_permalink(array ('gallerytag' => $tag->slug));
|
947 |
+
$tags[ $key ]->id = $tag->term_id;
|
948 |
+
}
|
949 |
+
|
950 |
+
$out = '<div class="ngg-tagcloud">' . wp_generate_tag_cloud( $tags, $args ) . '</div>';
|
951 |
+
|
952 |
+
return $out;
|
953 |
+
}
|
954 |
+
?>
|