changeset 968:c71afc1a3a85

Moar work.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 29 Nov 2014 08:38:34 +0200
parents 62c90ec5edce
children 26ae3f21a3bb
files faptool.php
diffstat 1 files changed, 37 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/faptool.php	Sat Nov 29 03:59:46 2014 +0200
+++ b/faptool.php	Sat Nov 29 08:38:34 2014 +0200
@@ -177,7 +177,12 @@
 
     case "RAR":
       $exe = "/usr/bin/rar";
-      $args = "x ".escapeshellarg($filename);
+      $args = "x -w".escapeshellarg($path)." ".escapeshellarg($filename);
+      break;
+
+    case "7ZIP":
+      $exe = "/usr/bin/7z";
+      $args = "x -o".escapeshellarg($path)." ".escapeshellarg($filename);
       break;
 
     default:
@@ -487,6 +492,22 @@
 }
 
 
+function wtPrintCompoHeader($compo)
+{
+  global $setTermWidth;
+  printf("==%'=-".($setTermWidth-2)."s\n",
+    sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40))
+    );
+}
+
+
+function wtPrintDivider($chr = "-")
+{
+  global $setTermWidth;
+  echo str_repeat($chr, $setTermWidth)."\n";
+}
+
+
 function wtShowHelp()
 {
   global $argv;
@@ -631,11 +652,8 @@
     foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
     if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0)
     {
-      printf(
-        "==%'=-".($setTermWidth-2)."s\n",
-        sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40))
-        );
-      echo str_repeat("-", $setTermWidth)."\n";
+      wtPrintCompoHeader($compo);
+      wtPrintDivider();
 
       foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
       {
@@ -648,7 +666,7 @@
         }
       }
       echo "\n";
-      echo str_repeat("-", $setTermWidth)."\n";
+      wtPrintDivider();
     }
     break;
 
@@ -665,16 +683,13 @@
         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(
-            "==%'=-".($setTermWidth-2)."s\n".
-            sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40))
-            );
-          echo str_repeat("-", $setTermWidth)."\n";
+          wtPrintCompoHeader($compo);
+          wtPrintDivider();
 
           foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
             wtHandleEntry($compo, $entry, $mode);
 
-          echo str_repeat("-", $setTermWidth)."\n";
+          wtPrintDivider();
         }
         break;
 
@@ -720,24 +735,27 @@
         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)
         {
+          wtPrintCompoHeader($compo);
           printf(
-            "==%'=-".($setTermWidth-2)."s\n".
             "PrevType : %s\n",
-            sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40)),
             $previewTypeList[$compo["preview_type"]][0]);
 
-          if ($mode == "sta")
+          if ($mode == "sta" || $mode == "lis")
           {
             printf(" %-3s | %-3s | %-40s |\n",
-              "#ID", "FLG", "Entry name/author");
+              "#ID", "EPV", "Entry name/author");
           }
 
-          echo str_repeat("-", $setTermWidth)."\n";
+          wtPrintDivider("-");
 
           foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
             wtHandleEntryPreview($compo, $entry, $mode);
 
-          echo str_repeat("=", $setTermWidth)."\n\n";
+          wtPrintDivider("=");
+        }
+        if ($mode == "sta" || $mode == "lis")
+        {
+          echo "Flags: E = Entry has file, P = Has preview file, V = Generated previews are up to date.\n";
         }
         break;