Commit 1fd08c707d26d8969a3b29314cc849bb5021a52f

Authored by nbm
1 parent 55935085

Stop using tables - errors end up in weird places. Also colourise the

upgrade results.  And exit immediately after a failed result - no point
continuing with brokenness.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5442 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 18 additions and 10 deletions
setup/upgrade.php
@@ -55,15 +55,15 @@ function generateUpgradeTable () { @@ -55,15 +55,15 @@ function generateUpgradeTable () {
55 function showResult($res) { 55 function showResult($res) {
56 if (PEAR::isError($res)) { 56 if (PEAR::isError($res)) {
57 if (is_a($res, 'Upgrade_Already_Applied')) { 57 if (is_a($res, 'Upgrade_Already_Applied')) {
58 - return "Already applied"; 58 + return '<span style="color: orange">Already applied</span>';
59 } 59 }
60 - return $res->toString(); 60 + return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString()));
61 } 61 }
62 if ($res === true) { 62 if ($res === true) {
63 - return "Success"; 63 + return '<span style="color: green">Success</span>';
64 } 64 }
65 if ($res === false) { 65 if ($res === false) {
66 - return "Failure"; 66 + return '<span style="color: red">Failure</span>';
67 } 67 }
68 return $res; 68 return $res;
69 } 69 }
@@ -76,15 +76,23 @@ function performAllUpgrades () { @@ -76,15 +76,23 @@ function performAllUpgrades () {
76 76
77 $upgrades = describeUpgrade($lastVersion, $currentVersion); 77 $upgrades = describeUpgrade($lastVersion, $currentVersion);
78 78
79 - print "<table width=\"100%\">\n";  
80 - print "<tr><th>Description</th><th>Result</th></tr>\n";  
81 foreach ($upgrades as $upgrade) { 79 foreach ($upgrades as $upgrade) {
  80 + printf('<div style="float: right">%s</div>', htmlspecialchars($upgrade->getDescription()));
82 $res = $upgrade->performUpgrade(); 81 $res = $upgrade->performUpgrade();
83 - printf("<tr><td>%s</td><td>%s</td></tr>\n",  
84 - htmlspecialchars($upgrade->getDescription()),  
85 - htmlspecialchars(showResult($res))); 82 + printf('<div style="float: left">%s</div>', showResult($res));
  83 + print '<br style="clear: both">' . "\n";
  84 + ob_flush();
  85 + flush();
  86 + if (PEAR::isError($res)) {
  87 + if (!is_a($res, 'Upgrade_Already_Applied')) {
  88 + break;
  89 + }
  90 + }
  91 + if ($res === false) {
  92 + break;
  93 + }
  94 +
86 } 95 }
87 - print '</table>';  
88 return $ret; 96 return $ret;
89 } 97 }
90 98