Index: brilliant_gallery.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/brilliant_gallery/brilliant_gallery.info,v
retrieving revision 1.6.2.2.4.2
diff -u -p -r1.6.2.2.4.2 brilliant_gallery.info
--- brilliant_gallery.info 15 Jan 2009 21:59:11 -0000 1.6.2.2.4.2
+++ brilliant_gallery.info 29 Sep 2009 22:31:44 -0000
@@ -1,7 +1,8 @@
; $Id: brilliant_gallery.info,v 1.6.2.2.4.2 2009/01/15 21:59:11 tjfulopp Exp $
name = Brilliant Gallery
description = Highly customizable Drupal module producing multiple table galleries of quality-scaled images from either a pre-defined local folder, or from any public Picasa gallery.
-dependencies[] = lightbox2
+;dependencies[] = lightbox2
;dependencies[] = colorpicker
+dependencies[] = getid3
package = Media
core = 6.x
\ No newline at end of file
Index: brilliant_gallery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/brilliant_gallery/brilliant_gallery.module,v
retrieving revision 1.49.2.6.2.8.2.11
diff -u -p -r1.49.2.6.2.8.2.11 brilliant_gallery.module
--- brilliant_gallery.module 22 Sep 2009 21:00:50 -0000 1.49.2.6.2.8.2.11
+++ brilliant_gallery.module 29 Sep 2009 22:32:09 -0000
@@ -220,6 +220,7 @@ function brilliant_gallery_admin() {
'lightbox' => t('Lightbox'),
'thickbox' => t('Thickbox'),
'greybox' => t('Greybox'),
+ 'shadowbox' => t('Shadowbox'),
'none' => t('None'),
),
'#default_value' => variable_get('brilliant_gallery_overbrowser', 'lightbox'),
@@ -396,7 +397,7 @@ HEADER;
if ($galleryfolder . $path_middle == $_GET['fld']) {
# User has asked to manage images in this folder.
$tablerows = array();
- $temp = load_dir_to_array($key, variable_get('brilliant_gallery_maximagewidth', 150), variable_get('brilliant_gallery_maxwidth', '1000'), 1);
+ $temp = load_dir_to_array($key, variable_get('brilliant_gallery_maximagewidth', 150), variable_get('brilliant_gallery_maxwidth', '1000'), 1, TRUE);
$retval_dimensions = $temp[0];
$imagemaxh = $temp[1];
$maxpoct = count($retval_dimensions);
@@ -411,7 +412,8 @@ HEADER;
$retval[$poct - 1] = $retval_dimensions[$poct - 1]['file'];
$fullimgpath = $path . $path_middle .'/'. $retval[$poct - 1];
if (testext($retval[$poct - 1])) {
- $caption = str_replace(array('.', '_'), ' ', basename($retval[$poct - 1], strrchr($retval[$poct - 1], '.')));
+// $caption = str_replace(array('.', '_'), ' ', basename($retval[$poct - 1], strrchr($retval[$poct - 1], '.')));
+ $caption = $retval_dimensions[$poct - 1]['caption'];
#$smallenough = false;
$imgw = $retval_dimensions[$poct - 1]['imgw'];
$imgh = $retval_dimensions[$poct - 1]['imgh'];
@@ -439,7 +441,7 @@ HEADER;
#}
switch ($overbrowser) {
-
+
case 'thickbox':
$displayimage .= ' class="thickbox"';
$displayimage .= ' rel="img_'. $setname .'"';
@@ -456,7 +458,12 @@ HEADER;
$displayimage .= ' class="greybox"';
break;
- default:
+ case 'shadowbox':
+ $displayimage .= ' rel="shadowbox['. $setname .'];player=img"';
+ #$attributes['rel'] = 'lightbox[' . ($node->nid? $node->nid: time()) . ']'; // 'insert' has no $node->nid
+ break;
+
+ default:
break;
}
@@ -722,7 +729,8 @@ function render_brilliant_gallery($thisf
#$result .= ('
' . "\n");
#$pocetobr += 1;
if (testext($retval[$poct - 1])) {
- $caption = str_replace(array('.', '_'), ' ', basename($retval[$poct - 1], strrchr($retval[$poct - 1], '.')));
+// $caption = str_replace(array('.', '_'), ' ', basename($retval[$poct - 1], strrchr($retval[$poct - 1], '.')));
+ $caption = $retval_dimensions[$poct - 1]['caption'] == '' ? '' : $retval_dimensions[$poct - 1]['caption'];
#$smallenough = false;
$imgw = $retval_dimensions[$poct - 1]['imgw'];
$imgh = $retval_dimensions[$poct - 1]['imgh'];
@@ -767,16 +775,21 @@ function render_brilliant_gallery($thisf
$result .= ' class="greybox"';
break;
+ case 'shadowbox':
+ $result .= ' rel="shadowbox['. $setname .'];player=img"';
+ #$attributes['rel'] = 'lightbox[' . ($node->nid? $node->nid: time()) . ']'; // 'insert' has no $node->nid
+ break;
+
default:
break;
}
- if ($showcaption <> '') {
- if ($showcaption <> 'filename') {
- $caption = $showcaption;
- }
+// if ($showcaption <> '') {
+// if ($showcaption <> 'filename') {
+// $caption = $showcaption;
+// }
$result .= ' title="'. $caption .'"';
- }
+// }
$result .= '>';
# Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
/*
Index: functions.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/brilliant_gallery/Attic/functions.inc,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 functions.inc
--- functions.inc 29 Jul 2009 18:09:13 -0000 1.1.4.2
+++ functions.inc 29 Sep 2009 22:32:17 -0000
@@ -36,8 +36,9 @@ function testext($filename) {
}
-function load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort) {
- # Load Directory Into Array
+function load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort, $compile_caption = FALSE) {
+ $caption_info = $compile_caption ? _brilliantgallery_compile_caption_info_file($absolpath) : _brilliantgallery_load_caption_info_file($absolpath);
+ # Load Directory Into Array
$poct = -1;
$retval_dimensions = array();
$handle = opendir($absolpath);
@@ -51,6 +52,7 @@ function load_dir_to_array($absolpath, $
$poct += 1;
#$retval[$poct] = $file;
$retval_dimensions[$poct]['file'] = $file;
+ $retval_dimensions[$poct]['caption'] = $caption_info[$file];
# Is image horizontally or vertically oriented?
$temp = getimagesize($absolpath .'/'. $file);
@@ -106,6 +108,94 @@ function load_dir_to_array($absolpath, $
return array($retval_dimensions, $imagemaxh);
}
+
+
+/**
+ * Load the captions into an info style array which has key as image file name
+ * and value the caption
+ *
+ * @param $path directory of the gallery
+ * @return info array containing the captions
+ */
+function _brilliantgallery_load_caption_info_file($path) {
+ if (file_exists($path .'/caption.info') === FALSE) {
+ return _brilliantgallery_compile_caption_info_file($path);
+ }
+ else {
+ return drupal_parse_info_file($path .'/caption.info');
+ }
+}
+
+
+/**
+ * Scan the gallery directory and create the captions.info file, if the
+ * captions.info file already exists, then only the new image files are updated
+ * to the file. Existing caption entries are not changed, thus preserving any
+ * user edit.
+ *
+ * @param $path the path to the gallery
+ * @return caption info array where
+ */
+function _brilliantgallery_compile_caption_info_file($path) {
+ $info = array();
+ if (file_exists($path .'/caption.info')) {
+ $info = drupal_parse_info_file($path .'/captions.info');
+ }
+ foreach (file_scan_directory($path, '.*\.gif|jpg|jpeg|png$', array('.', '..', 'CVS'), 0, FALSE) as $filename => $file_info) {
+ if (!$info[$file_info->basename] || empty($info[$file_info->basename])) {
+ $info[$file_info->basename] = _brilliantgallery_get_caption($file_info);
+ }
+ }
+ _brilliantgallery_write_info_file($path .'/caption.info', $info);
+ return $info;
+}
+
+
+/**
+ * Get the caption out of the image file, fallback to use the file name if
+ * no caption meta data can be found.
+ *
+ * @param $file_info the file info value array returned by file_scan_directory()
+ * @return the caption/title
+ */
+function _brilliantgallery_get_caption($file_info) {
+ $data = getid3_analyze($file_info->filename);
+ switch ($data['mime_type']) {
+ case 'image/jpeg':
+ if (isset($data['iptc']['IPTCApplication']['Caption-Abstract'][0])) {
+ return $data['iptc']['IPTCApplication']['Caption-Abstract'][0];
+ }
+ elseif (isset($data['jpg']['exif']['IFD0']['ImageDescription'])) {
+ return $data['jpg']['exif']['IFD0']['ImageDescription'];
+ }
+ break;
+ case 'image/png':
+ if (isset($data['comments']['title'][0])) {
+ return $data['comments']['title'][0];
+ }
+ break;
+ }
+ return $file_info->basename;
+}
+
+
+/**
+ * Save the info array to a file
+ *
+ * @param $path path to the file to save
+ * @param $info the info array
+ * @return file_save_data status
+ */
+function _brilliantgallery_write_info_file($path, $info) {
+ $output = array();
+ foreach ($info as $key => $value) {
+ $output[] = $key .' = "'. strtr($value, array('"' => '\"')) .'"';
+ }
+ return file_save_data(implode("\n", $output), $path, FILE_EXISTS_REPLACE);
+}
+
+
+
/*
# Define the cURL class:
# http://www.tellinya.com/read/2007/08/03/39.html
|