--- brilliant_gallery.module	2009-07-03 12:21:56.000000000 -0400
+++ brilliant_gallery-new.module	2009-07-25 13:59:25.000000000 -0400
@@ -1,8 +1,6 @@
 <?php
 /* $Id: brilliant_gallery.module,v 1.49.2.6.2.8.2.7 2009/07/03 16:21:56 tjfulopp Exp $ */
 
-#sess_write('vacilando', 'this is a test');
-
 if (module_exists('views')) {
   module_load_include('inc', 'brilliant_gallery', 'views');
   #require(drupal_get_path('module', 'brilliant_gallery') .'/views.inc');
@@ -65,9 +63,6 @@
     // content variable that will be returned for display
     $block_content = '';
 
-    #$block_content .= l($links->title, 'node/'.$links->nid) . '<br />';
-    #$block_content .= l('vacilando', 'http://www.vacilando.org') . '<br />';
-
     $block_content .= render_brilliant_gallery();
 
     // set up the block
@@ -309,14 +304,6 @@
     'type' => MENU_CALLBACK,
   # The type MENU_CALLBACK tells Drupal to not display the link in the user's menu, just use this function when the URL is accessed. Use MENU_NORMAL_ITEM if you want the user to see the link in the side navigation block.
   );
-  /*
-  $items['brilliant_gallery/manage'] = array(
-    'title' => 'Manage galleries',
-    'page callback' => 'render_brilliant_gallery_manage',
-    'access arguments' => array('access administration pages'),
-    'type' => MENU_CALLBACK
-  ); # The type MENU_CALLBACK tells Drupal to not display the link in the user's menu, just use this function when the URL is accessed. Use MENU_NORMAL_ITEM if you want the user to see the link in the side navigation block.
-*/
 
   # 2 menu callback functions to implement the ajax load and save routines
   $items['bgchecklist/loadall'] = array(
@@ -363,7 +350,6 @@
   $absolpath = realpath($rp);
   $result .= '<p>';
   $result .= '<p>This page allows you to set or unset visibility of each image (data item) in all Brilliant galleries there are on this website.';
-  #$result .= '<p><b>Files folder:</b> ' . file_directory_path() . '/';
   ob_start();
   $recurs = bg_iterative_recurse_dir($absolpath);
   #echo '<pre>'; print_r( $recurs ); echo '</pre>';
@@ -396,12 +382,9 @@
       $retval_dimensions = $temp[0];
       $imagemaxh         = $temp[1];
       $maxpoct           = count($retval_dimensions);
-      #echo '<p>max: ' . $maxpoct;
-      #ob_start(); echo '<pre>'; print_r( $retval_dimensions ); echo '</pre>'; $result .= ob_get_contents();
       # Thanks to Micha³ Albrecht!
       $retval = array();
       $cnt = 0;
-      #$path = url($key, array('absolute' => TRUE));
       for ($poct = 1; $poct <= $maxpoct; $poct++) {
         $cnt += 1;
         $retval[$poct - 1] = $retval_dimensions[$poct - 1]['file'];
@@ -413,9 +396,7 @@
           $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'), array('absolute' => TRUE));
           # url() ads i18n codes to the URL ... we need to remove them here...
@@ -425,27 +406,17 @@
           # Non-clean URLs need removing ?q=
           $modulepath = str_replace("?q=", "", $modulepath);
           $displayimage = '';
-          #if ($smallenough === true) {
-          #  $displayimage .= '<br><a href="'. $fullimgpath .'"';
-          #}
-          #else {
-            # Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
-            #&dummy=.jpg
-            $displayimage .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath . $path_middle .'/'. $retval[$poct - 1]) .'&amp;imgw='. $imgwbig .'&amp;imgh='. $imghbig .'"';
-          #}
+          $displayimage .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath . $path_middle .'/'. $retval[$poct - 1]) .'&amp;imgw='. $imgwbig .'&amp;imgh='. $imghbig .'"';
 
           switch ($overbrowser) {
               
             case 'thickbox':
               $displayimage .= ' class="thickbox"';
               $displayimage .= ' rel="img_'. $setname .'"';
-              #$attributes['class'] = $link_class;
-              #$attributes['rel'] = 'img_' . ($node->nid? $node->nid: time()); // 'insert' has no $node->nid
               break;
 
             case 'lightbox':
               $displayimage .= ' rel="lightbox['. $setname .']"';
-              #$attributes['rel'] = 'lightbox[' . ($node->nid? $node->nid: time()) . ']'; // 'insert' has no $node->nid
               break;
 
             case 'greybox':
@@ -469,10 +440,7 @@
         }
         else {
           $displayimage .= '<a href="'. $fullimgpath .'">';
-          #$result .= '<center>' . $retval[$poct-1] . '</center>';
           $displayimage .= $retval[$poct - 1];
-          #brokenimage("Error loading PNG");
-          #$result .= '</a>';
           $displayimage .= '</a>';
         }
         #$result .= '<br><font size="-1">'. $retval[$poct-1] . '</font>'; # $fullimgpath
@@ -526,36 +494,30 @@
 function render_brilliant_gallery($thisfolder = '', $colcountoverride = '', $widthoverride = '', $sortoverride = '', $maximumnumbertoshow = '', $colouroverride = '', $beginfromoverride = 1, $captionyesnotext = '') {
   // Is this a Picasa gallery?
     $picasafolder = false;
-    #echo '....'.substr($thisfolder,0,29);
     if (substr($thisfolder,0,24) == 'http://picasaweb.google.') {
       // Must work for all variants - http://picasaweb.google.com, http://picasaweb.google.co.uk, etc.
       $picasafolder = true;
     }
+  // future add in of separate CSS support
   #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 ( $thisfolder <> '') {
     if ($galleryfolder <> '') {
       $galleryfolder .= '/' . $thisfolder;
@@ -564,42 +526,45 @@
     $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')) {
+
   if (($captionyesnotext == 'yes' or $captionyesnotext == '') and variable_get('brilliant_gallery_caption', '') <> '' ) {
     $showcaption = 'filename';
   }
-  #else if ($captionyesornot == 'no') {
   else if ($captionyesnotext == 'no' or (variable_get('brilliant_gallery_caption', '') == '' and ($captionyesnotext == 'yes' or $captionyesnotext == 'no'))) {
     $showcaption = '';
   }
   else {
-    #$showcaption = $captionyesornot;
     $showcaption = $captionyesnotext;
   }
+
   $padding = variable_get('brilliant_gallery_padding', 3);
   $overbrowser = variable_get('brilliant_gallery_overbrowser', 'lightbox');
   // Totally full resolution display would be impractical, so this is the maximum width of "full" resolution.
@@ -622,14 +587,11 @@
     $mkdirek = $pcachetemp . '/bg_picasa_'. $mgalleryurl;
     if (is_dir($mkdirek)===true) {
       // If it exists, we assume it is also populated, so we don't create it, and we don't go fetching the remote data!
-      #echo 'exists';
     }
     else {
-      #echo 'new';
       include ('./'. drupal_get_path('module', 'brilliant_gallery') ."/picasa.inc");
     }
     $absolpath = $mkdirek;
-    #$absolpath = '/tmp/bg_picasa_838e4e98afdffbec2ed6d34e6bfa497c';
     #echo $absolpath;
     #drupal_set_message(t('absol: '.$absolpath));
   }
@@ -640,7 +602,6 @@
     }
     $absolpath = realpath($rp);
   }
-  #$result .= $absolpath;
 
   # Make an array with images in this folder, and their properties.
   $temp              = load_dir_to_array($absolpath, $imagewidth, $fullresolutionmaxwidth, $brilliant_gallery_sort);
@@ -648,22 +609,10 @@
   $imagemaxh         = $temp[1];
   $maxpoct           = count($retval_dimensions);
   if (arg(2) == 'edit') {
-    #print_r( $retval_dimensions );
   }
 
   # Get a list of images that are forbidden from display.
-  #$uid=$user->uid;
-  #echo $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)) {
@@ -674,22 +623,14 @@
   # 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]
   $style_ul = "font-size:0; margin:0px; padding:0px; width: ". (($imagewidth + 2 * $padding) * $columns) ."px;";
   $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;
   }
+
   # Thanks to Micha³ Albrecht!
   $retval = array();
   $cnt = 0;
@@ -710,19 +651,13 @@
     }
     $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; list-style: none; background: #000; width: 44px; height: 33px; padding: 4px; text-align: center; margin: 0; border: none;";
       $style_li = "font-size:0; float: left; width: ". $imagewidth ."px; list-style: none; background: ". $bgcolour ."; height: ". $imagemaxh ."px; padding: ". $padding ."px; text-align: center; margin: 0px; border: none;";
       $result .= ('<li style="'. $style_li .'">' . "\n");
       # Get this module's path:
@@ -738,8 +673,6 @@
       #}
       #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] ) . '&amp;imgw=' . $imgwbig . '&amp;imgh=' . $imghbig . '"'; #&dummy=.jpg
-        #&dummy=.jpg
         $result .= '<a href="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $imgwbig .'&imgh='. $imghbig .'"';
       #}
 
@@ -747,8 +680,6 @@
         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':
@@ -771,22 +702,8 @@
         $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'), array('absolute' => 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; margin:0px; padding:0px;" alt="" src="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&amp;imgw=' . $imgw . '&amp;imgh=' . $imgh . '" />'; # width="' . $imgw . '"
-      # width="' . $imgw . '"
       $result .= '<img style="border: 0; margin:0px; padding:0px;" alt="" src="'. $modulepath .'/image.php?imgp='. base64_encode($absolpath .'/'. $retval[$poct - 1]) .'&imgw='. $imgw .'&imgh='. $imgh .'" />';
-      #$result .= '</a>';
       $result .= '</a>' . "\n";
     }
     else {
@@ -794,24 +711,15 @@
       $style_li = "font-size:". $fosiz ."px; float: left; width: ". $imagewidth ."px; list-style: none; background: ". $bgcolour ."; height: ". $imagemaxh ."px; padding: ". $padding ."px; text-align: center; margin: 0px; border: none;";
       $result .= ('<li style="'. $style_li .'">' . "\n");
       $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;
 }
