changeset 705:45750a346f3e

Add default preview_type for compos, and remove preview_file element from entries, we will just compute the filename.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Nov 2014 21:26:23 +0200
parents de13b834249f
children a91a91b8160e
files admajax.php admin.js dbdefs.inc.php
diffstat 3 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Mon Nov 10 21:25:28 2014 +0200
+++ b/admajax.php	Mon Nov 10 21:26:23 2014 +0200
@@ -41,6 +41,10 @@
   stChkRequestItemFail("show_authors", $fake, $res,
     array(CHK_TYPE, VT_BOOL, "Invalid data."));
 
+  stChkRequestItemFail("preview_type", $fake, $res,
+    array(CHK_TYPE, VT_INT, "Invalid data."),
+    array(CHK_RANGE, VT_INT, array(EPREV_NONE, EPREV_AUDIO), "Invalid preview type value."));
+
   stChkRequestItemFail("cpath", $fake, $res,
     array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long."));
 
@@ -97,7 +101,7 @@
 
 function stGetCompoData($id, $item, $prefix)
 {
-  global $compoModeData;
+  global $compoModeData, $previewTypeList;
 
   // XXX TODO Dropdown menu or so for selecting compo type
   switch ($item["ctype"])
@@ -119,6 +123,7 @@
     "  Name: ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."<br />\n".
     "  File path: ".stGetFormTextInput(40, SET_LEN_COMPO_PATH, "cpath", $id, $prefix, $item["cpath"])."<br />\n".
     "  ".stGetFormTextArea(8, 60, "description", $id, $prefix, $item["description"])."<br />\n".
+    "  ".stGetFormOptionListFromArray($prefix."preview_type".$id, "  ", FALSE, $previewTypeList, $item["preview_type"], 0)."\n".
     "  ".stGetFormButtonInput("update", $id, $prefix, "Update", "updateCompo(".$id.")")."\n".
     "  ".stGetFormButtonInput("delete", $id, $prefix, "Delete", "deleteCompo(".$id.")")."\n".
     "  ".stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible", "onChange=\"setCompoData(".$id.",'visible')\"")."\n".
@@ -1584,6 +1589,7 @@
             "description" => "Q",
             "visible" => "B",
             "show_authors" => "B",
+            "preview_type" => "D",
             "cpath" => "S",
           );
 
--- a/admin.js	Mon Nov 10 21:25:28 2014 +0200
+++ b/admin.js	Mon Nov 10 21:26:23 2014 +0200
@@ -293,7 +293,7 @@
 
 function updateCompo(id)
 {
-  var args = jsMakePostArgs({"name":1, "description":1, "visible":3, "voting":3, "show_authors":3, "cpath":1}, "co", id, true);
+  var args = jsMakePostArgs({"name":1, "description":1, "visible":3, "voting":3, "show_authors":3, "cpath":1, "preview_type":4}, "co", id, true);
 
   var msuccess = function(txt)
   {
--- a/dbdefs.inc.php	Mon Nov 10 21:25:28 2014 +0200
+++ b/dbdefs.inc.php	Mon Nov 10 21:26:23 2014 +0200
@@ -1,6 +1,6 @@
 <?
 
-$dbVersion = 19;
+$dbVersion = 20;
 
 //
 // Site settings and defaults we put in
@@ -237,9 +237,16 @@
     array("description"  , "VARCHAR(".SET_LEN_COMPO_DESC.")"),
     array("visible"      , "INT", "DEFAULT 0"),
     array("voting"       , "INT", "DEFAULT 0"),
+    
+    // Default preview type (see PREV_* in msite.inc.php)
+    // Global for the compo (entry-specific overrides if it is != PREV_NONE)
+    // Preview filename/path is determined internally
+    array("preview_type" , "INT", "DEFAULT 0"),
+
     array("show_authors" , "INT", "DEFAULT 0"),
     // Show author(s) on compo main screen/voting page for COMPO_NORMAL compos
     // For COMPO_POINTS and COMPO_ASSIGN, show on results page or not
+    
     array("ctype"        , "INT", "DEFAULT 0"),
     array("cpath"        , "VARCHAR(".SET_LEN_COMPO_PATH.")"),
   ),
@@ -253,7 +260,6 @@
     array("filename"     , "VARCHAR(".SET_LEN_ENTRY_FILENAME.")", "DEFAULT NULL"),
     array("info"         , "VARCHAR(".SET_LEN_ENTRY_INFO.")", "DEFAULT NULL"),
     array("notes"        , "VARCHAR(".SET_LEN_ENTRY_NOTES.")", "DEFAULT NULL"),
-    array("preview_file" , "VARCHAR(".SET_LEN_ENTRY_PREVIEW_FILE.")", "DEFAULT NULL"),
     array("preview_type" , "INT", "DEFAULT 0"),
     array("flags"        , "INT", "DEFAULT 0"),
     array("evalue"       , "INT", "DEFAULT 0"),