diff msite.inc.php @ 774:d6668b73bb01

Modularize preview HTML stuff into a function stPrintPreviewElements().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 20 Nov 2014 15:38:33 +0200
parents c714140541d5
children f8d09e0de027
line wrap: on
line diff
--- a/msite.inc.php	Thu Nov 20 14:56:44 2014 +0200
+++ b/msite.inc.php	Thu Nov 20 15:38:33 2014 +0200
@@ -726,6 +726,44 @@
 }
 
 
+function stPrintPreviewElements($compo, $entry)
+{
+  if (($pdata = stGetEntryPreviewData($compo, $entry, FALSE, TRUE)) === FALSE)
+    return FALSE;
+
+  switch ($pdata["previewType"])
+  {
+    case EPREV_IMAGE:
+      if ($pdata["previewSize"] === FALSE || $pdata["thumbSize"] === FALSE)
+      {
+        echo
+          "<img class=\"imagePreview\" src=\"img/nopreview_tn.png\" alt=\"Preview\" />";
+      }
+      else
+      {
+        echo
+          "<a href=\"".ihentities($pdata["previewURL"]).
+          "\" onClick=\"jsShowPreviewImage('".ihentities($pdata["previewURL"])."')\">".
+          "<img class=\"imagePreview\" src=\"".ihentities($pdata["thumbURL"]).
+          "\" alt=\"Preview\" /></a>";
+      }
+      break;
+
+    case EPREV_AUDIO:
+      if ($pdata["previewSize"] !== FALSE)
+      {
+        echo
+          "<audio controls class=\"audioPreview\">".
+          "<source src=\"".ihentities($pdata["previewURL"])."\" type=\"audio/mpeg\">-".
+          "</audio>";
+      }
+      break;
+  }
+
+  return TRUE;
+}
+
+
 // Get link helper function
 function stGetMainPageLink($id, $name, $show = TRUE)
 {