changeset 19:59075f5e7a62

Add configuration setting to enable and disable use of HTML table elements.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 14 Sep 2015 12:49:56 +0300
parents 8c1599a30120
children 12916fcdb8b8
files example.cfg mgallery.inc.php mgallery.php
diffstat 3 files changed, 31 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/example.cfg	Mon Sep 14 12:49:29 2015 +0300
+++ b/example.cfg	Mon Sep 14 12:49:56 2015 +0300
@@ -22,6 +22,8 @@
 ; Use image from sub-album as album cover image
 cover_images         = yes
 
+; Use table elements? If disabled, CSS is responsible for formatting
+use_tables           = yes
 
 ;;;
 ;;; Important paths and urls
--- a/mgallery.inc.php	Mon Sep 14 12:49:29 2015 +0300
+++ b/mgallery.inc.php	Mon Sep 14 12:49:56 2015 +0300
@@ -59,6 +59,7 @@
   "cache_file"       => array(MG_STR, ".mgallery.cache"),
 
   "cover_images"     => array(MG_BOOL, TRUE),
+  "use_tables"       => array(MG_BOOL, TRUE),
   "clean_urls"       => array(MG_BOOL, FALSE),
 
   "title_prefix"     => array(MG_STR, ""),
--- a/mgallery.php	Mon Sep 14 12:49:29 2015 +0300
+++ b/mgallery.php	Mon Sep 14 12:49:56 2015 +0300
@@ -125,7 +125,7 @@
 
 function mgPrintTable($class, &$galEntries, &$galIndex, $start, $limit)
 {
-  global $galAlbumIcon, $galPath, $galTNPath, $galImageURL, $galUseCoverImages;
+  global $galAlbumIcon, $galPath, $galTNPath, $galImageURL, $galUseCoverImages, $galUseTables;
 
   $galCount = count($galIndex);
   if ($start >= $galCount)
@@ -137,16 +137,20 @@
   $rowLimit = mgGetSetting("album_row_limit");
   $n = 0;
 
-  echo "<table class=\"".$class."\">\n";
+  if ($galUseTables)
+    echo "<table class=\"".$class."\">\n";
+
   for ($index = $start; $index < $end; $index++)
   {
     $filename = &$galIndex[$index];
     $data = &$galEntries[$filename];
 
-    if ($n == 0) echo " <tr>\n";
+    if ($galUseTables && $n == 0) echo " <tr>\n";
 
-    echo
-      "  <td id=\"cd".$data["base"]."\">\n";
+    if ($galUseTables)
+      echo "  <td id=\"cd".$data["base"]."\">\n";
+    else
+      echo "  <div class=\"albumEntry\">\n";
 
     if ($data["type"] == 0)
     {
@@ -181,22 +185,29 @@
       "<div class=\"albumTitle\">".chentities($data["caption"])."</div></a>\n";
     }
 
-    echo
-      "  </td>\n";
-
-    if (++$n >= $rowLimit)
+    if ($galUseTables)
     {
-      echo " </tr>\n";
-      $n = 0;
+      echo "  </td>\n";
+      if (++$n >= $rowLimit)
+      {
+        echo " </tr>\n";
+        $n = 0;
+      }
     }
+    else
+      echo "  </div>\n";
   }
-  if ($n > 0)
+
+  if ($galUseTables)
   {
-    while ($n++ < $rowLimit)
-      echo "  <td></td>\n";
-    echo " </tr>\n";
+    if ($n > 0)
+    {
+      while ($n++ < $rowLimit)
+        echo "  <td></td>\n";
+      echo " </tr>\n";
+    }
+    echo "</table>\n";
   }
-  echo "</table>\n";
   return $index;
 }
 
@@ -251,6 +262,7 @@
 $galImageURL = mgGetSetting("image_url", mgGetSetting("base_url"));
 
 $galUseCoverImages = mgGetSetting("cover_images");
+$galUseTables = mgGetSetting("use_tables");
 
 $galAlbumIcon = mgGetSetting("album_icon");
 $galCleanURLS = mgGetSetting("clean_urls");