# HG changeset patch # User Matti Hamalainen # Date 1425902621 -7200 # Node ID 8724b9de70bf2d821e20c3f47d297010231a1a65 # Parent 89262bdba0614000ef6594c372337ac7c53cf389 Variable renames, cleanups, etc. diff -r 89262bdba061 -r 8724b9de70bf materials/index.php --- a/materials/index.php Mon Mar 09 13:36:55 2015 +0200 +++ b/materials/index.php Mon Mar 09 14:03:41 2015 +0200 @@ -142,12 +142,12 @@ { $setSortColumn = 0; if ($setSortDirection) - krsort($matTable, SORT_STRING); + krsort($matDataTable, SORT_STRING); else - ksort($matTable, SORT_STRING); + ksort($matDataTable, SORT_STRING); } else - uasort($matTable, "stSortMatFunc"); + uasort($matDataTable, "stSortMatFunc"); // Print page header @@ -218,9 +218,9 @@ array("Organic + cloth (sewing)", 0, 1), - 1 => array("Wood + bone (carpentry)", 5, 3), - 2 => array("Metal + alloy (blacksmithing)", 4, 7), - 3 => array("Stone (masonry)", 6, -1), - 4 => array("Gem (gemcutting)", 10, -1), - 5 => array("Inorganic (sculpture)", 8, -1), - 6 => array("Glass (glassblowing)", 9, -1), - - 7 => array("Organic", 0, -1), - 8 => array("Wood", 5, -1), - 9 => array("Metal", 4, -1), - - 10 => array("Cloth", -1, 1), - 11 => array("Bone", -1, 3), - 12 => array("Alloy", -1, 7), -); - -foreach ($typeTable as $key => $value) +foreach ($matTypeTable as $key => $value) { $n = 0; - foreach ($matTable as $name => $data) + foreach ($matDataTable as $name => $data) { if ($data[14] == $value[1] || $data[14] == $value[2]) $n++; } - $typeTable[$key][] = $n; + $matTypeTable[$key][] = $n; printf( " \n", $key, - ($showOnly == $key ? " selected=\"selected\"" : ""), + ($setShowOnly == $key ? " selected=\"selected\"" : ""), chentities($value[0]), $n); } @@ -141,60 +147,53 @@ Error! No such material '".$showMatName."'\n". + "

Error! No such material '".$setShowMatName."'

\n". "

Material is not known. Check spelling.

\n"; } else { - echo "

".$showMatName."

\n". + echo "

".$setShowMatName."

\n". "\n". ""; $n = 0; - foreach ($matTable[$showMat] as $key => $val) + foreach ($matDataTable[$setShowMat] as $key => $val) { - echo ""; if ($n++ >= 2) { echo "\n"; $n = 0; } } - echo "\n
".chentities($transNameTable[$key+1]).""; + echo "".chentities($matTransNames[$key + 1]).""; if (is_array($val)) { - reset($val); - if (list($nam, $lode) = each($val)) - echo chentities($transTable[$key][$lode]); - - while (list($nam, $lode) = each($val)) - echo ", ".chentities($transTable[$key][$lode]); + $tmp = array(); + foreach ($val as $lode) + $tmp[] = chentities($matTransTable[$key][$lode]); + echo join(", ", $tmp); } else { - echo chentities($transTable[$key][$val]); + echo chentities($matTransTable[$key][$val]); } echo "
\n"; echo "

Alloy combinations

\n"; - if (isset($alloyRevTable[$showMat])) + if (isset($alloyRevTable[$setShowMat])) { echo "\n". @@ -211,37 +210,37 @@ /* $typeMats = array(); - foreach ($matTable as $name => $data) { - if ($data[14] == $matTable[$showMat][14] && $name != $showMat) + foreach ($matDataTable as $name => $data) { + if ($data[14] == $matDataTable[$setShowMat][14] && $name != $setShowMat) $typeMats[] = $name; } echo "Full mix: "; if (list($a, $b) = each($typeMats)) - echo matLink($b); + echo stGetMatLink($b); while (list($a, $b) = each($typeMats)) - echo " + ".matLink($b); + echo " + ".stGetMatLink($b); echo "
\n"; */ echo "

Mixtable

\n"; - if (count($alloyTable[$showMat]) > 0) + if (count($alloyTable[$setShowMat]) > 0) { echo "". " \n". " \n"; - foreach ($alloyTable[$showMat] as $key => $value) + foreach ($alloyTable[$setShowMat] as $key => $value) { - echo "\n"; + echo "\n"; } echo " \n". - " "; - foreach ($alloyTable[$showMat] as $key => $value) + " "; + foreach ($alloyTable[$setShowMat] as $key => $value) if (list($a, $b) = each($value)) { - echo ""; + echo ""; } echo "
+".matLink($key)."".stGetMatLink($key)."
".chentities($showMat)."
".chentities($setShowMat)."".matLink($a)."".stGetMatLink($a)."
\n"; } @@ -258,19 +257,19 @@ */ // Filter table from maintable matching desired material type(s) $currTable = array(); - foreach ($matTable as $name => $data) + foreach ($matDataTable as $name => $data) { - if ($data[14] == $typeTable[$showOnly][1] || - $data[14] == $typeTable[$showOnly][2]) + if ($data[14] == $matTypeTable[$setShowOnly][1] || + $data[14] == $matTypeTable[$setShowOnly][2]) $currTable[] = $name; } // Swap desired rows - if (count($swapRows) > 0) + if (count($setSwapRows) > 0) { $str = array(); $nkeys = count($currTable); - foreach ($swapRows as $from => $to) + foreach ($setSwapRows as $from => $to) if ($from >= 0 && $from < $nkeys && $to >= 0 && $to < $nkeys && $to != $from) { $str[] = $from." <=> ".$to; @@ -292,7 +291,7 @@ foreach ($currTable as $name) { - echo " ".matLink($name)."\n"; + echo " ".stGetMatLink($name)."\n"; } echo " \n"; @@ -301,7 +300,7 @@ foreach ($currTable as $mat1) { - echo " ".matLink($mat1).""; + echo " ".stGetMatLink($mat1).""; foreach ($currTable as $mat2) { // Is the combo possible? @@ -329,14 +328,14 @@ $slist = array(); foreach ($tmp as $a => $b) { - $slist[] = matLink($a, + $slist[] = stGetMatLink($a, $b." successful alloys (".$mat1." + ".$mat2." = ".$a.")". (count($tmp) > 1 ? " [UNSTABLE]" : "") ); // , " ".$b.""); } echo - " 1 ? " mitalic" : "").">". + " 1 ? " mitalic" : "").">". join(" / ", $slist).""; } else