function render_brilliant_gallery in Brilliant Gallery 5.3
Same name and namespace in other branches
- 5.4 brilliant_gallery.module \render_brilliant_gallery()
- 6.4 gallery_showtime.inc \render_brilliant_gallery()
- 6 brilliant_gallery.module \render_brilliant_gallery()
- 6.2 brilliant_gallery.module \render_brilliant_gallery()
- 6.3 brilliant_gallery.module \render_brilliant_gallery()
- 7.2 brilliant_gallery.inc \render_brilliant_gallery()
- 7.2 OLD_brilliant_gallery_showtime.inc \render_brilliant_gallery()
- 7 brilliant_gallery_showtime.inc \render_brilliant_gallery()
3 calls to render_brilliant_gallery()
- brilliant_gallery_all in ./
brilliant_gallery.module - brilliant_gallery_block in ./
brilliant_gallery.module - Generate HTML for the Brilliant gallery block
- replace_brilliant_gallery_tags in ./
brilliant_gallery.module
File
- ./
brilliant_gallery.module, line 486
Code
function render_brilliant_gallery($thisfolder = '', $colcountoverride = '', $widthoverride = '', $sortoverride = '', $maximumnumbertoshow = '', $colouroverride = '', $beginfromoverride = 1, $captionyesnotext = '') {
#drupal_add_css(drupal_get_path('module', 'brilliant_gallery') .'/brilliant_gallery.css');
# First some household cleaning. Delete expired cache files at 11:11 (if someone calls this script, of course!)
if (date('h') == '11' and date('i') == '11') {
#if ( date( 'h' ) == '12' ) {
#echo date( 'h' );
cleantmpdir();
}
# Patching a possible problem with i18n
$langcode = '';
if (function_exists('i18n_get_lang')) {
$langcode = i18n_get_lang();
}
#$result = '</p>';
$result = '';
$galleryfolder = variable_get('brilliant_gallery_folder', '');
if (substr($galleryfolder, strlen($galleryfolder) - 1, 1) == '/' or substr($galleryfolder, 0, 1) == '/') {
#watchdog('error', 'failed to notify "weblogs.com" (site)');
#form_set_error('yemail', t('Header injection attempt detected. Do not enter line feed characters into the from field!'));
return 'Main gallery folder path must not begin or end with a slash; please fix it in the <a href="/admin/settings/brilliant_gallery">settings page</a>.';
}
if ($thisfolder != '') {
$galleryfolder .= '/' . $thisfolder;
}
if ($colcountoverride == '') {
$columns = variable_get('brilliant_gallery_maxcol', 3);
}
else {
$columns = $colcountoverride;
}
if ($widthoverride == '') {
$imagewidth = variable_get('brilliant_gallery_maximagewidth', 150);
}
else {
$imagewidth = $widthoverride;
}
if ($sortoverride == '' or strtolower($sortoverride) == 'sort') {
$brilliant_gallery_sort = variable_get('brilliant_gallery_sort', '1');
}
else {
$brilliant_gallery_sort = $sortoverride;
}
if ($colouroverride == '') {
$bgcolour = variable_get('brilliant_gallery_bcgcolour_textfield', '#000000');
}
else {
$bgcolour = $colouroverride;
}
if ($captionyesornot == 'yes' or $captionyesornot == '' or variable_get('brilliant_gallery_caption', '') != '' and $captionyesornot != 'no') {
$showcaption = 'filename';
}
else {
if ($captionyesornot == 'no') {
$showcaption = '';
}
else {
$showcaption = $captionyesornot;
}
}
$padding = variable_get('brilliant_gallery_padding', 3);
$overbrowser = variable_get('brilliant_gallery_overbrowser', 'thickbox');
$fullresolutionmaxwidth = variable_get('brilliant_gallery_maxwidth', '1000');
# Totally full resolution display would be impractical, so this is the maximum width of "full" resolution.
$path = url(file_directory_path() . '/' . $galleryfolder, NULL, NULL, TRUE);
# url() ads i18n codes to the URL ... we need to remove them here...
if ($langcode != '') {
$path = str_replace('/' . $langcode . '/', '/', $path);
}
# Non-clean URLs need removing ?q=
$path = str_replace("?q=", "", $path);
$absolpath = realpath(file_directory_path() . '/' . $galleryfolder);
#$result .= $absolpath;
# Make an array with images in this folder, and their properties.
$temp = load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort);
$retval_dimensions = $temp[0];
$imagemaxh = $temp[1];
$maxpoct = count($retval_dimensions);
#print_r( $retval_dimensions );
# Get a list of images that are forbidden from display.
#$uid=$user->uid;
$excludedimgs = array();
// any checkbox id that starts with user- we remember the current user's settings
// any other id is global and we use user=0
/*
$result=db_query("select qid,state from brilliant_gallery_checklist ".
" where nid='$nid' and qid not like 'user-%' and user=0 ".
" union ".
"select qid,state from brilliant_gallery_checklist ".
"where nid='$nid' and qid like 'user-%' and user='$uid' ");
*/
$dbresult = db_query("select qid from brilliant_gallery_checklist where qid like 'user-%' and state='1' ");
while ($data = db_fetch_object($dbresult)) {
$excludedimgs[] = $data->qid;
}
#print_r($excludedimgs);
$style_ul = "width: " . ($imagewidth + 2 * $padding) * $columns . "px;";
# Total 'width' controls the number of thumbnails in each row. The number, in pixels, should be calculated thusly: [maximum width desired for thumbnails] + [padding - if any, x 2] + [margin - if any, x 2] + [border - if any, x 2] x [number of thumbnails desired in each row]
$column_count = 0;
#$pocetobr = 0;
$setname = mt_rand(1, 9999999);
#$result .= '<!-- Brilliant Gallery Table Beginning --><table border="0" rules="none" frame="box" cellpadding="0" cellspacing="0" bgcolor="' . $bgcolour . '"';
$result .= '<!-- Brilliant Gallery Table Beginning -->';
#$result .= '<ul class="brilliant_gallery" style="' . $style_ul . '">';
$result .= '<ul style="' . $style_ul . '">';
#if ( $thisfolder <> '' ) {
#$result .= ' align="center"';
# }
#$result .= ' style="width:' . $columns*$imagewidth . 'px;">'; #cell-spacing: 5px;
#$result .= ' style="width:' . $columns*$imagewidth . 'px;"';
#$result .= '>' . "\n"; #cell-spacing: 5px;
$maxpoct_show = '';
if ($maximumnumbertoshow != '' and is_numeric($maximumnumbertoshow)) {
$maxpoct_show = $maximumnumbertoshow;
}
$retval = array();
$cnt = 0;
for ($poct = 1; $poct <= $maxpoct; $poct++) {
# Skip any images that were excluded from display.
# md5() must be made of the main gallery path etc. ending with the file name (unique identifier). E.g. albums/2008/20080321-25_belgicko_zasypane_snehom/dsc02784_w1000.jpg
if (array_search('user-' . md5($galleryfolder . '/' . $retval_dimensions[$poct - 1]['file']), $excludedimgs) !== false) {
continue;
}
if ($poct < $beginfromoverride) {
continue;
}
# Begin only from $beginfromoverride image.
$cnt += 1;
if ($cnt > $maxpoct_show and $maxpoct_show != '') {
continue;
}
# Do not show more than $maxpoct_show (if defined).
$retval[$poct - 1] = $retval_dimensions[$poct - 1]['file'];
$fullimgpath = $path . '/' . $retval[$poct - 1];
#if ($column_count == 0) { $result .= ('<tr>'); }
#$result .= ('<td align="center" bgcolor="' . $bgcolour . '" style="padding: ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px;vertical-align: middle;">');
#$result .= ('<td align="center" bgcolor="' . $bgcolour . '" style="padding: ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px;vertical-align: middle;">' . "\n");
#$pocetobr += 1;
if (testext($retval[$poct - 1])) {
$caption = str_replace(array(
'.',
'_',
), ' ', basename($retval[$poct - 1], strrchr($retval[$poct - 1], '.')));
#$smallenough = false;
$imgw = $retval_dimensions[$poct - 1]['imgw'];
$imgh = $retval_dimensions[$poct - 1]['imgh'];
$imgwbig = $retval_dimensions[$poct - 1]['imgwbig'];
$imghbig = $retval_dimensions[$poct - 1]['imghbig'];
$smallenough = $retval_dimensions[$poct - 1]['smallenough'];
$style_li = "float: left; width: " . $imagewidth . "px; list-style: none; background: " . $bgcolour . "; height: " . $imagemaxh . "px; padding: " . $padding . "px; text-align: center; margin: 0; border: none;";
#$style_li = "float: left; list-style: none; background: #000; width: 44px; height: 33px; padding: 4px; text-align: center; margin: 0; border: none;";
$result .= '<li style="' . $style_li . '">' . "\n";
# Get this module's path:
$modulepath = url(drupal_get_path('module', 'brilliant_gallery'), NULL, NULL, TRUE);
# url() ads i18n codes to the URL ... we need to remove them here...
if ($langcode != '') {
$modulepath = str_replace('/' . $langcode . '/', '/', $modulepath);
}
# Non-clean URLs need removing ?q=
$modulepath = str_replace("?q=", "", $modulepath);
if ($smallenough === true) {
$result .= '<a href="' . $fullimgpath . '"';
}
else {
# Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
$result .= '<a href="' . $modulepath . '/image.php?imgp=' . base64_encode($absolpath . '/' . $retval[$poct - 1]) . '&imgw=' . $imgwbig . '&imgh=' . $imghbig . '"';
#&dummy=.jpg
}
switch ($overbrowser) {
case 'thickbox':
$result .= ' class="thickbox"';
$result .= ' rel="img_' . $setname . '"';
#$attributes['class'] = $link_class;
#$attributes['rel'] = 'img_' . ($node->nid? $node->nid: time()); // 'insert' has no $node->nid
break;
case 'lightbox':
$result .= ' rel="lightbox[' . $setname . ']"';
#$attributes['rel'] = 'lightbox[' . ($node->nid? $node->nid: time()) . ']'; // 'insert' has no $node->nid
break;
case 'greyboxr':
$result .= ' class="greybox"';
#$result .= ' rel="gb_imageset[' . $setname . ']"';
break;
default:
break;
}
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
/*
$modulepath = url(drupal_get_path('module', 'brilliant_gallery'), NULL, NULL, TRUE);
# url() ads i18n codes to the URL ... we need to remove them here...
if ( $langcode <> '' ) {
$modulepath = str_replace( '/' . $langcode . '/', '/', $modulepath );
}
# Non-clean URLs need removing ?q=
$modulepath = str_replace( "?q=", "", $modulepath );
*/
#$result .= '<img style="display: block;border:0" src="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&imgw=' . $imgw . '&imgh=' . $imgh . '" />'; # width="' . $imgw . '"
$result .= '<img style="border:0" alt="" src="' . $modulepath . '/image.php?imgp=' . base64_encode($absolpath . '/' . $retval[$poct - 1]) . '&imgw=' . $imgw . '&imgh=' . $imgh . '" />';
# width="' . $imgw . '"
#$result .= '</a>';
$result .= '</a>' . "\n";
}
else {
$result .= '<a href="' . $fullimgpath . '">';
#$result .= '<center>' . $retval[$poct-1] . '</center>';
$result .= $retval[$poct - 1];
#brokenimage("Error loading PNG");
#$result .= '</a>';
$result .= '</a>' . "\n";
}
#$result .= '</td>';
$result .= '</li>' . "\n";
$column_count += 1;
#if ($column_count == $columns) { $result .= ("</tr>\n"); $column_count = 0; }
}
#if ($column_count <> 0) { $result .= ("</tr>"); }
#if ($column_count <> 0) { $result .= ("</tr>\n"); }
#$result .= "</table>\n";
$result .= "</ul>\n";
$result .= '<br style="clear: both;" />';
#$result .= '<p>';
return $result;
}