changeset 44:296902ecaefa misc

Sync.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 20 Apr 2009 15:34:14 +0000
parents 9ea5d70d501e
children b94ffda8cb46
files materials/alloy.php materials/index.php materials/submit.php
diffstat 3 files changed, 42 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/materials/alloy.php	Mon Apr 20 15:33:43 2009 +0000
+++ b/materials/alloy.php	Mon Apr 20 15:34:14 2009 +0000
@@ -69,10 +69,15 @@
 </table>
 </form>
 <?
-function matLink($mat) {
-  return "<a href=\"?m=".urlencode($mat)."\">".htmlentities($mat)."</a>";
+function matLink($mat, $title = "") {
+  if ($title != "")
+    $tmp = " title=\"".htmlentities($title)."\"";
+  else
+    $tmp = "";
+  return "<a href=\"?m=".urlencode($mat)."\"".$tmp.">".htmlentities($mat)."</a>";
 }
 
+
 if (isset($showMat)) {
   if (!isset($matTable[$showMat])) {
     echo "<h2>Error! No such material '".$showMatName."'</h2>\n".
@@ -83,7 +88,17 @@
     "<tr>";
     $n = 0;
     foreach ($matTable[$showMat] as $key => $val) {
-      echo "<th>".$transNameTable[$key+1]."</th><td>".$transTable[$key][$val]."</td>";
+      echo "<th>".htmlentities($transNameTable[$key+1])."</th><td>";
+      if (is_array($val)) {
+        reset($val);
+        if (list($nam, $lode) = each($val))
+          echo htmlentities($transTable[$key][$lode]);
+        while (list($nam, $lode) = each($val))
+          echo ", ".htmlentities($transTable[$key][$lode]);
+      } else {
+        echo htmlentities($transTable[$key][$val]);
+      }
+      echo "</td>";
       if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; }
     }
     
@@ -154,9 +169,9 @@
         echo "<td>";
       
       if (isset($alloyTable[$mat1][$mat2])) {
-        echo matLink($alloyTable[$mat1][$mat2]);
+        echo matLink($alloyTable[$mat1][$mat2], $mat1." + ".$mat2);
       } else if (isset($alloyTable[$mat2][$mat1])) {
-        echo matLink($alloyTable[$mat2][$mat1]);
+        echo matLink($alloyTable[$mat2][$mat1], $mat1." + ".$mat2);
       } else {
         echo "-";
       }
--- a/materials/index.php	Mon Apr 20 15:33:43 2009 +0000
+++ b/materials/index.php	Mon Apr 20 15:34:14 2009 +0000
@@ -132,14 +132,6 @@
   <td></td>
  </tr>
 </table>
-<?
-/*
-if ($sortColumn >= 0) {
-  echo "<input type=\"hidden\" name=\"s\" value=\"".$sortColumn."\" />\n";
-  echo "<input type=\"hidden\" name=\"d\" value=\"".$sortDirs[$sortDirection]."\" />\n";
-}
-*/
-?>
 </form>
 
 <table class="matTable">
@@ -167,12 +159,8 @@
 }
 echo " </tr>\n";
 
-reset($matTable);
-while (list($key, $value) = each($matTable)) {
-  if ($showOnlySet)
-    $doShow = ($value[14] == $showOnly);
-  else
-    $doShow = TRUE;
+foreach ($matTable as $key => $value) {
+  $doShow = $showOnlySet ? ($value[14] == $showOnly) : TRUE;
   
   if ($doShow) {
     $col = 0;
@@ -180,13 +168,17 @@
     printTC("td", $col++);
     echo "<a href=\"alloy.php?m=".urlencode($key)."\">".htmlentities($key)."</a></td>";
     
-    while (list($kkey, $kvalue) = each($value)) {
-      if (!isset($filterTable[$kkey+1])) {
+    foreach ($value as $kkey => $kvalue) {
+      if (!isset($filterTable[$kkey + 1])) {
         printTC("td", $col);
-        if (isset($transTable[$kkey][$kvalue])) {
+        if (is_array($kvalue)) {
+          reset($kvalue);
+          if (list($nam, $lode) = each($kvalue))
+            echo htmlentities($transTable[$kkey][$lode]);
+          while (list($nam, $lode) = each($kvalue))
+            echo ", ".htmlentities($transTable[$kkey][$lode]);
+        } else {
           echo htmlentities($transTable[$kkey][$kvalue]);
-        } else {
-          echo $kvalue;
         }
         echo "</td>";
       }
--- a/materials/submit.php	Mon Apr 20 15:33:43 2009 +0000
+++ b/materials/submit.php	Mon Apr 20 15:34:14 2009 +0000
@@ -258,6 +258,17 @@
       $errroSet = TRUE;
     }
   }
+
+  // Save the error messages, just in case
+  if ($errorSet) {
+    $filename = "error-".strtolower($submitGUIDS[$formGUID]).".log";
+    $outFile = fopen($filename, "a");
+    if ($outFile !== FALSE) {
+      chmod($filename, 0600);
+      fwrite($outFile, $errorStr);
+      fclose($outFile);
+    }
+  }
   
   // Show output
   if ($hasData) {