changeset 933:f05c896622e1

Moar work.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 27 Nov 2014 22:21:32 +0200
parents 0c1ab858a3c5
children 0db85a37aa96
files faptool.php
diffstat 1 files changed, 54 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/faptool.php	Thu Nov 27 22:19:48 2014 +0200
+++ b/faptool.php	Thu Nov 27 22:21:32 2014 +0200
@@ -211,12 +211,43 @@
 }
 
 
+function wtHandleSingleEntryPreview($compo, $entry, &$efile, $edata, $pdata)
+{
+/*
+  if (entry is module file)
+  {
+    render sample
+  }
+  else
+  if (entry is image file)
+  {
+    convert image
+  }
+*/
+  return FALSE;
+}
+
+
+function wtNiceName($compo, $entry, $efile = FALSE)
+{
+  return sprintf(
+    "%d: %s by %s%s",
+    $entry["id"],
+    $entry["name"],
+    $entry["author"],
+    ($efile !== false) ? " [".$efile["filename"]." / TYPE: '".$efile["filetype"]."']" : "");
+}
+
+
 function wtHandleEntryPreview($compo, $entry, $mode)
 {
-  // Get current preview file data
+  global $fileTypeData;
+
+  // Get current preview file(s) data
   if (!stGetPreviewFileData($compo, $entry, $pdata))
     return FALSE;
 
+  // Get entry file data
   if ($entry["file_id"] != 0)
     $efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["file_id"]);
   else
@@ -227,16 +258,25 @@
   {
     printf(" %03d | %s%s%s | %-40s | %-5s | %s\n",
       $entry["id"],
-      ($efile !== false) ? "1" : ".",
-      isset($pdata["file"]) ? "2" : ".",
-      $pdata["valid"] ? "3" : ".",
-      $entry["name"]." by ".$entry["author"],
+      ($efile !== false) ? "E" : ".",
+      isset($pdata["file"]) ? "P" : ".",
+      $pdata["valid"] ? "V" : ".",
+      substr($entry["name"]." by ".$entry["author"], 0, 40),
       isset($pdata["file"]) ? $pdata["file"]["filetype"] : "",
       isset($pdata["file"]) ? $pdata["file"]["filename"] : ""
       );
   }
   else
-  if ($mode == "upd")
+  if ($mode != "upd")
+    die("Unsupported previews mode ".$mode."\n");
+
+  // Check validity of previews
+  if ($pdata["valid"])
+    return TRUE;
+
+  // Okay, no valid previews .. lets see what we can do ..
+  // First, check if we have a source preview file
+  if (!isset($pdata["file"]))
   {
 /*
   if (previewSourceFile does not exist)
@@ -279,8 +319,7 @@
     "previewThumbQuality", TRUE);
 */
   }
-  else
-    die("OMG!\n");
+  return TRUE;
 }
 
 
@@ -352,14 +391,14 @@
     "\n".
     "  previews <cmd> [args]\n".
     "    Where <cmd> is one of:\n".
-    "    status   - List files and show what is missing, etc.\n".
+    "    status [cid]  - List files and show what is missing, etc. (All or <cid>)\n".
     "    update   - Generate preview files that are missing OR out of date.\n".
     "               (older then preview source file OR entry file where appropriate)\n".
 //    "    add <entry_id> <filename> - Add file as preview for entry_id.\n".
     "\n".
     "  entry <cmd> [args]\n".
-    "    status   - List entries for all compos.\n".
-    "    unpack   - Create subdirs and unpack archives under them.\n".
+    "    status [cid]  - List entries for all compos or <cid>.\n".
+    "    unpack        - Create subdirs and unpack archives under them.\n".
 /*
     "    add <filename> '<name>' '<author>' - Add file as entry file\n".
     "              (works same as uploading from admin interface)\n".
@@ -468,7 +507,8 @@
     {
       case "unp":
       case "sta":
-        foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
+        $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : "";
+        foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo)
         if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0)
         {
           printf(
@@ -510,7 +550,8 @@
     {
       case "upd":
       case "sta":
-        foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
+        $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : "";
+        foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo)
         if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0)
         {
           printf(