# HG changeset patch # User Matti Hamalainen # Date 1417119692 -7200 # Node ID f05c896622e1fdba8ee17c2c98e75d1f07d89f96 # Parent 0c1ab858a3c555d791cd02bb4bca1c1236cb936e Moar work. diff -r 0c1ab858a3c5 -r f05c896622e1 faptool.php --- 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 [args]\n". " Where 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 )\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 - Add file as preview for entry_id.\n". "\n". " entry [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 .\n". + " unpack - Create subdirs and unpack archives under them.\n". /* " add '' '' - 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(