mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
created alteration_message method to replace all the code used to echo changes when dbbuild runs, with appropriate colouring.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@40809 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
46c9efaecc
commit
e386cbae57
@ -1595,9 +1595,7 @@ class DataObject extends Controller {
|
||||
$obj = new $baseClass($record);
|
||||
$obj->write();
|
||||
}
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">Added default records to $baseClass table</li>";
|
||||
}
|
||||
Database::alteration_message("Added default records to $baseClass table","created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,9 +204,7 @@ abstract class Database extends Object {
|
||||
function requireTable($table, $fieldSchema = null, $indexSchema = null) {
|
||||
if(!isset($this->tableList[strtolower($table)])) {
|
||||
$this->transCreateTable($table);
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">Table $table: created</li>";
|
||||
}
|
||||
Database::alteration_message("Table $table: created","created");
|
||||
} else {
|
||||
$this->checkAndRepairTable($table);
|
||||
}
|
||||
@ -239,9 +237,7 @@ abstract class Database extends Object {
|
||||
$suffix = $suffix ? ($suffix+1) : 2;
|
||||
}
|
||||
$this->renameTable($table, "_obsolete_{$table}$suffix");
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: red\">Table $table: renamed to _obsolete_{$table}$suffix</li>";
|
||||
}
|
||||
Database::alteration_message("Table $table: renamed to _obsolete_{$table}$suffix","obsolete");
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,14 +262,10 @@ abstract class Database extends Object {
|
||||
}
|
||||
if($newTable || !isset($this->indexList[$table][$index])) {
|
||||
$this->transCreateIndex($table, $index, $spec);
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">Index $table.$index: created as $spec</li>";
|
||||
}
|
||||
Database::alteration_message("Index $table.$index: created as $spec","created");
|
||||
} else if($this->indexList[$table][$index] != $spec) {
|
||||
$this->transAlterIndex($table, $index, $spec);
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: blue\">Index $table.$index: changed to $spec <i style=\"color: #AAA\">(from {$this->indexList[$table][$index]})</i></li>";
|
||||
}
|
||||
Database::alteration_message("Index $table.$index: changed to $spec <i style=\"color: #AAA\">(from {$this->indexList[$table][$index]})</i>","changed");
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,16 +294,12 @@ abstract class Database extends Object {
|
||||
Profiler::mark('createField');
|
||||
$this->transCreateField($table, $field, $spec);
|
||||
Profiler::unmark('createField');
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">Field $table.$field: created as $spec</li>";
|
||||
}
|
||||
Database::alteration_message("Field $table.$field: created as $spec","created");
|
||||
} else if($this->fieldList[$table][$field] != $spec) {
|
||||
Profiler::mark('alterField');
|
||||
$this->transAlterField($table, $field, $spec);
|
||||
Profiler::unmark('alterField');
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: blue\">Field $table.$field: changed to $spec <i style=\"color: #AAA\">(from {$this->fieldList[$table][$field]})</i></li>";
|
||||
}
|
||||
Database::alteration_message("Field $table.$field: changed to $spec <i style=\"color: #AAA\">(from {$this->fieldList[$table][$field]})</i>","changed");
|
||||
}
|
||||
Profiler::unmark('requireField');
|
||||
}
|
||||
@ -387,6 +375,35 @@ abstract class Database extends Object {
|
||||
Database::$supressOutput = true;
|
||||
}
|
||||
|
||||
static function alteration_message($message,$type=""){
|
||||
if(!Database::$supressOutput) {
|
||||
$color = "";
|
||||
switch ($type){
|
||||
case "created":
|
||||
$color = "green";
|
||||
break;
|
||||
case "obsolete":
|
||||
$color = "red";
|
||||
break;
|
||||
case "error":
|
||||
$color = "red";
|
||||
break;
|
||||
case "deleted":
|
||||
$color = "red";
|
||||
break;
|
||||
case "changed":
|
||||
$color = "blue";
|
||||
break;
|
||||
case "repaired":
|
||||
$color = "blue";
|
||||
break;
|
||||
default:
|
||||
$color="";
|
||||
}
|
||||
echo "<li style=\"color: $color\">$message</li>";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,11 +33,8 @@ class ErrorPage extends Page {
|
||||
$errorpage->write();
|
||||
// Don't publish, as the manifest may not be built yet
|
||||
// $errorpage->publish("Stage", "Live");
|
||||
|
||||
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">404 page created</li>";
|
||||
}
|
||||
Database::alteration_message("404 page created","created");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,10 +206,7 @@ class MySQLDatabase extends Database {
|
||||
*/
|
||||
public function checkAndRepairTable($tableName) {
|
||||
if(!$this->runTableCheckCommand("CHECK TABLE `$tableName`")) {
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: blue\">Table $tableName: repaired</li>";
|
||||
}
|
||||
|
||||
Database::alteration_message("Table $tableName: repaired","repaired");
|
||||
return $this->runTableCheckCommand("REPAIR TABLE `$tableName` USE_FRM");
|
||||
} else {
|
||||
return true;
|
||||
|
@ -406,10 +406,7 @@ class SiteTree extends DataObject {
|
||||
$homepage->write();
|
||||
$homepage->publish("Stage", "Live");
|
||||
$homepage->flushCache();
|
||||
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">Home page created</li>";
|
||||
}
|
||||
Database::alteration_message("Home page created","created");
|
||||
}
|
||||
|
||||
if(DB::query("SELECT COUNT(*) FROM SiteTree")->value() == 1) {
|
||||
@ -420,10 +417,7 @@ class SiteTree extends DataObject {
|
||||
$aboutus->Status = "Published";
|
||||
$aboutus->write();
|
||||
$aboutus->publish("Stage", "Live");
|
||||
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">About Us created</li>";
|
||||
}
|
||||
Database::alteration_message("About Us created","created");
|
||||
|
||||
$contactus = new Page();
|
||||
$contactus->Title = "Contact Us";
|
||||
|
@ -426,10 +426,7 @@ class Member extends DataObject {
|
||||
|
||||
if(!DB::query("SELECT * FROM Member")->value() && isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
|
||||
Security::findAnAdministrator($_REQUEST['username'], $_REQUEST['password']);
|
||||
|
||||
if(!Database::$supressOutput) {
|
||||
echo "<li style=\"color: green\">Added admin account</li>";
|
||||
}
|
||||
Database::alteration_message("Added admin account","created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user