Jeremy D commited on 2011-10-30 11:43:33
Showing 1 changed files, with 279 additions and 34 deletions.
... | ... |
@@ -25,10 +25,8 @@ |
25 | 25 |
|
26 | 26 |
class tbg_converter |
27 | 27 |
{ |
28 |
- // Where your config_inc.php is located |
|
29 |
- //const MBT_PATH = ''; |
|
30 |
- // Where your b2db_boostrap.inc.php is located |
|
31 |
- //const TBG_PATH = ''; |
|
28 |
+ // Credits for the converter. |
|
29 |
+ protected $main_credits = 'TBG converter © Joshua Dickerson & Jeremy Darwood'; |
|
32 | 30 |
|
33 | 31 |
// The host, user, and pass must be on the same server |
34 | 32 |
protected $db_driver = 'mysql'; |
... | ... |
@@ -83,7 +81,7 @@ class tbg_converter |
83 | 81 |
$this->loadSettings(); |
84 | 82 |
|
85 | 83 |
// Open a new theme. |
86 |
- $theme = new tbg_converter_wrapper(); |
|
84 |
+ $theme = new tbg_converter_wrapper($this->steps, array($this->main_credits, $this->credits)); |
|
87 | 85 |
|
88 | 86 |
// We can't process anymore until this exists. |
89 | 87 |
if (empty($this->db_user)) |
... | ... |
@@ -200,6 +198,8 @@ class tbg_converter |
200 | 198 |
$this->updateStep('doStep1'); |
201 | 199 |
$this->doConversion(); |
202 | 200 |
} |
201 |
+ else |
|
202 |
+ $theme->errors($errors); |
|
203 | 203 |
} |
204 | 204 |
|
205 | 205 |
// Prompt for some settings. |
... | ... |
@@ -412,11 +412,15 @@ class tbg_converter |
412 | 412 |
|
413 | 413 |
if ($this->is_json) |
414 | 414 |
$theme->return_json($data); |
415 |
+ $theme->updateData($data); |
|
415 | 416 |
} |
416 | 417 |
} |
417 | 418 |
|
418 | 419 |
class mbt_to_tbg extends tbg_converter |
419 | 420 |
{ |
421 |
+ // Credits for this part of the converter. |
|
422 |
+ protected $credits = 'Mantis -> TBG converter © Joshua Dickerson & Jeremy Darwood'; |
|
423 |
+ |
|
420 | 424 |
protected $mbt_db_prefix; |
421 | 425 |
|
422 | 426 |
// What steps shall we take. |
... | ... |
@@ -897,21 +901,22 @@ class tbg_converter_wrapper |
897 | 901 |
{ |
898 | 902 |
protected $page_title = 'Mantis to The Bug Genie converter'; |
899 | 903 |
protected $headers = array(); |
904 |
+ protected $errors = array(); |
|
905 |
+ protected $steps = array(); |
|
906 |
+ protected $step = 0; |
|
907 |
+ protected $substep = 0; |
|
908 |
+ protected $time = 0; |
|
909 |
+ protected $credits = array(); |
|
900 | 910 |
|
901 | 911 |
/** |
902 | 912 |
* Start the HTML. |
903 | 913 |
*/ |
904 |
- public function __construct($no_html = false) |
|
914 |
+ public function __construct($steps, $credits = array()) |
|
905 | 915 |
{ |
906 |
- // Do nothing! |
|
907 |
- if (!empty($no_html)) |
|
908 |
- return; |
|
909 |
- |
|
910 |
- // Some headers. |
|
911 |
- $this->printHeader(); |
|
916 |
+ $this->steps = $steps; |
|
917 |
+ $this->credits = $credits; |
|
912 | 918 |
|
913 |
- // Upper part of theme. |
|
914 |
- $this->upper(); |
|
919 |
+ ob_start(); |
|
915 | 920 |
} |
916 | 921 |
|
917 | 922 |
/** |
... | ... |
@@ -922,6 +927,17 @@ class tbg_converter_wrapper |
922 | 927 |
if ($is_cli) |
923 | 928 |
exit("\nConversion completed"); |
924 | 929 |
|
930 |
+ $contents = ob_get_contents(); |
|
931 |
+ ob_end_clean(); |
|
932 |
+ |
|
933 |
+ // Some headers. |
|
934 |
+ $this->printHeader(); |
|
935 |
+ |
|
936 |
+ // Upper part of theme. |
|
937 |
+ $this->upper(); |
|
938 |
+ |
|
939 |
+ echo $contents; |
|
940 |
+ |
|
925 | 941 |
$this->lower(); |
926 | 942 |
exit; |
927 | 943 |
} |
... | ... |
@@ -954,6 +970,16 @@ class tbg_converter_wrapper |
954 | 970 |
$this->headers[$type] = $data; |
955 | 971 |
} |
956 | 972 |
|
973 |
+ /* |
|
974 |
+ * Set the title. |
|
975 |
+ * @param $title: The page title to set |
|
976 |
+ */ |
|
977 |
+ public function updateData($data) |
|
978 |
+ { |
|
979 |
+ foreach ($data as $key => $value) |
|
980 |
+ $this->{$key} = $value; |
|
981 |
+ } |
|
982 |
+ |
|
957 | 983 |
/* |
958 | 984 |
* Return a json array. |
959 | 985 |
* @param $data: The json data. |
... | ... |
@@ -967,21 +993,14 @@ class tbg_converter_wrapper |
967 | 993 |
} |
968 | 994 |
|
969 | 995 |
/* |
970 |
- * We have some new data!. |
|
971 |
- * @param $data: The json data. |
|
996 |
+ * Set the title. |
|
997 |
+ * @param $errors: We have some errors! |
|
972 | 998 |
*/ |
973 |
- public function steps($steps) |
|
999 |
+ public function errors($errors) |
|
974 | 1000 |
{ |
975 |
- echo '<ol>'; |
|
976 |
- |
|
977 |
- foreach ($steps as $id_step => $step) |
|
978 |
- echo ' |
|
979 |
- <li id="step', $id_step, '"><span class="name">', $step[0], '</span><span class="progress"></span><span class="progress_percent" style="display: none;">0%</span></li>'; |
|
980 |
- |
|
981 |
- echo '</ol>'; |
|
1001 |
+ $this->errors = array_merge($this->errors, $errors); |
|
982 | 1002 |
} |
983 | 1003 |
|
984 |
- |
|
985 | 1004 |
/* |
986 | 1005 |
* The upper part of the theme. |
987 | 1006 |
* |
... | ... |
@@ -995,15 +1014,204 @@ class tbg_converter_wrapper |
995 | 1014 |
<title>', $this->page_title, '</title> |
996 | 1015 |
<style type="text/css"> |
997 | 1016 |
<!-- |
1017 |
+ html, body |
|
1018 |
+ { |
|
1019 |
+ height: 100%; |
|
1020 |
+ } |
|
1021 |
+ body |
|
1022 |
+ { |
|
1023 |
+ /* Copy SMFs background gradient if we are cool enough */ |
|
1024 |
+ background-color: #E9EEF2; |
|
1025 |
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#375976\', endColorstr=\'#e9eef2\'); |
|
1026 |
+ background: -webkit-gradient(linear, left top, left bottom, from(#375976), to(#e9eef2)); |
|
1027 |
+ background: -moz-linear-gradient(top, #375976, #e9eef2); |
|
1028 |
+ background: -o-linear-gradient(#375976, #e9eef2 30em); |
|
1029 |
+ font-family: "Geneva", "verdana", sans-serif; |
|
1030 |
+ |
|
1031 |
+ padding: 1em 4em 0 4em; |
|
1032 |
+ margin: auto; |
|
1033 |
+ min-width: 50em; |
|
1034 |
+ } |
|
1035 |
+ |
|
1036 |
+ #main_block |
|
1037 |
+ { |
|
1038 |
+ border: 2px solid #ffffff; |
|
1039 |
+ border-top-left-radius: 10px; |
|
1040 |
+ border-top-right-radius: 10px; |
|
1041 |
+ |
|
1042 |
+ /* Copy SMFs background gradient if we are cool enough */ |
|
1043 |
+ background-color: #c9d7e7; |
|
1044 |
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#c9d7e7\', endColorstr=\'#fcfdfe\'); |
|
1045 |
+ background: -webkit-gradient(linear, left top, left bottom, from(#c9d7e7), to(#fcfdfe)); |
|
1046 |
+ background: -moz-linear-gradient(top, #c9d7e7, #fcfdfe); |
|
1047 |
+ background: -o-linear-gradient(#c9d7e7, #fcfdfe 10em); |
|
1048 |
+ |
|
1049 |
+ } |
|
1050 |
+ #logo_block |
|
1051 |
+ { |
|
1052 |
+ padding: 0.3em 0 0.3em 0; |
|
1053 |
+ margin: 0 0 0 1em; |
|
1054 |
+ } |
|
1055 |
+ #logo_block h1 |
|
1056 |
+ { |
|
1057 |
+ padding: 0; |
|
1058 |
+ margin: 0; |
|
1059 |
+ |
|
1060 |
+ color: #334466; |
|
1061 |
+ text-decoration: bold; |
|
1062 |
+ font-size: 1.4em; |
|
1063 |
+ line-height: 45px; |
|
1064 |
+ } |
|
1065 |
+ #content_block |
|
1066 |
+ { |
|
1067 |
+ margin: 0 0.3em 0 0.3em; |
|
1068 |
+ padding: 1em; |
|
1069 |
+ |
|
1070 |
+ border-top-left-radius: 10px; |
|
1071 |
+ border-top-right-radius: 10px; |
|
1072 |
+ |
|
1073 |
+ /* Copy SMFs background gradient if we are cool enough */ |
|
1074 |
+ background-color: #c3cfde; |
|
1075 |
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#c3cfde\', endColorstr=\'#fcfdfe\'); |
|
1076 |
+ background: -webkit-gradient(linear, left top, left bottom, from(#c3cfde), to(#fcfdfe)); |
|
1077 |
+ background: -moz-linear-gradient(top, #c3cfde, #fcfdfe); |
|
1078 |
+ background: -o-linear-gradient(#c3cfde, #fcfdfe 5em); |
|
1079 |
+ |
|
1080 |
+ } |
|
1081 |
+ |
|
1082 |
+ #footer |
|
1083 |
+ { |
|
1084 |
+ /* Copy SMFs background gradient if we are cool enough */ |
|
1085 |
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\'#f3f6f9\', endColorstr=\'#e1e9f3\'); |
|
1086 |
+ background: -webkit-gradient(linear, left top, left bottom, from(#f3f6f9), to(#e1e9f3)); |
|
1087 |
+ background: -moz-linear-gradient(top, #f3f6f9, #e1e9f3); |
|
1088 |
+ background: -o-linear-gradient(#f3f6f9, #e1e9f3); |
|
1089 |
+ |
|
1090 |
+ border-left: 1px solid white; |
|
1091 |
+ border-right: 1px solid white; |
|
1092 |
+ |
|
1093 |
+ border-bottom-left-radius: 10px; |
|
1094 |
+ border-bottom-right-radius: 10px; |
|
1095 |
+ |
|
1096 |
+ padding: 0.5em 0; |
|
1097 |
+ margin: 0; |
|
1098 |
+ |
|
1099 |
+ text-align: center; |
|
1100 |
+ font-size: 70%; |
|
1101 |
+ } |
|
1102 |
+ #footer span |
|
1103 |
+ { |
|
1104 |
+ padding-left: 5em; |
|
1105 |
+ } |
|
1106 |
+ |
|
1107 |
+ dl |
|
1108 |
+ { |
|
1109 |
+ clear: right; |
|
1110 |
+ overflow: auto; |
|
1111 |
+ |
|
1112 |
+ border: 1px solid #bbb; |
|
1113 |
+ background: #f5f5f0; |
|
1114 |
+ |
|
1115 |
+ margin: 0 0 0 0; |
|
1116 |
+ padding: 0.5em; |
|
1117 |
+ } |
|
1118 |
+ dl dt |
|
1119 |
+ { |
|
1120 |
+ width: 40%; |
|
1121 |
+ float: left; |
|
1122 |
+ margin: 0 0 10px 0; |
|
1123 |
+ padding: 0; |
|
1124 |
+ clear: both; |
|
1125 |
+ } |
|
1126 |
+ dl dd |
|
1127 |
+ { |
|
1128 |
+ width: 56%; |
|
1129 |
+ float: right; |
|
1130 |
+ overflow: auto; |
|
1131 |
+ margin: 0 0 3px 0; |
|
1132 |
+ padding: 0; |
|
1133 |
+ } |
|
1134 |
+ dl input[type=text], dl input[type=password] |
|
1135 |
+ { |
|
1136 |
+ width: 25em; |
|
1137 |
+ } |
|
1138 |
+ |
|
1139 |
+ #steps .waiting, #steps .done, #steps .current |
|
1140 |
+ { |
|
1141 |
+ border-radius: 5px; |
|
1142 |
+ } |
|
1143 |
+ #steps li |
|
1144 |
+ { |
|
1145 |
+ margin: 0.5em; |
|
1146 |
+ padding: 0.5em; |
|
1147 |
+ } |
|
1148 |
+ #steps li span |
|
1149 |
+ { |
|
1150 |
+ color: white; |
|
1151 |
+ text-decoration: bold; |
|
1152 |
+ } |
|
1153 |
+ #steps li .name |
|
1154 |
+ { |
|
1155 |
+ width: 30em; |
|
1156 |
+ min-width: 30em; |
|
1157 |
+ padding-right: 3em; |
|
1158 |
+ } |
|
1159 |
+ #steps .waiting, #steps .done |
|
1160 |
+ { |
|
1161 |
+ background-color: #5a6c85; |
|
1162 |
+ } |
|
1163 |
+ #steps .current |
|
1164 |
+ { |
|
1165 |
+ background-color: #fd9604; |
|
1166 |
+ } |
|
1167 |
+ |
|
1168 |
+ #steps li .progress_bar, #steps li .progress_status |
|
1169 |
+ { |
|
1170 |
+ position: absolute; |
|
1171 |
+ left: 10em; |
|
1172 |
+ padding-left: 10em; |
|
1173 |
+ } |
|
1174 |
+ #steps li .progress_bar .progress_box |
|
1175 |
+ { |
|
1176 |
+ border: 1px solid black; |
|
1177 |
+ width: 20em; |
|
1178 |
+ display: block; |
|
1179 |
+ background-color: white; |
|
1180 |
+ padding: 1px; |
|
1181 |
+ border-radius: 5px; |
|
1182 |
+ } |
|
1183 |
+ #steps li .progress_bar .progress_box .progress_percent |
|
1184 |
+ { |
|
1185 |
+ background-color: red; |
|
1186 |
+ display: block; |
|
1187 |
+ border-radius: 5px; |
|
1188 |
+ padding-left: 0.3em; |
|
1189 |
+ color: black; |
|
1190 |
+ text-decoration: bold; |
|
1191 |
+ } |
|
998 | 1192 |
--> |
999 | 1193 |
</style> |
1000 | 1194 |
</head> |
1001 | 1195 |
<body> |
1002 |
- <div> |
|
1003 |
- <div style="padding: 10px; padding-right: 0px; padding-left: 0px; width:98% "> |
|
1004 |
- <div style="padding-left: 200px; padding-right: 0px;"> |
|
1196 |
+ <div id="main_block"> |
|
1197 |
+ <div id="logo_block"> |
|
1005 | 1198 |
<h1>', $this->page_title, '</h1> |
1006 |
- <div class="panel" style="padding-right: 0px; white-space: normal; overflow: hidden;">'; |
|
1199 |
+ </div> |
|
1200 |
+ <div id="content_block">'; |
|
1201 |
+ |
|
1202 |
+ if (!empty($this->errors)) |
|
1203 |
+ { |
|
1204 |
+ echo ' |
|
1205 |
+ <div class="error"> |
|
1206 |
+ <ul> |
|
1207 |
+ <li>', implode("</li>\n\t\t\t\t\t<li>", $this->errors), ' |
|
1208 |
+ </li> |
|
1209 |
+ </ul> |
|
1210 |
+ </div>'; |
|
1211 |
+ } |
|
1212 |
+ |
|
1213 |
+ echo ' |
|
1214 |
+ <div class="panel">'; |
|
1007 | 1215 |
} |
1008 | 1216 |
|
1009 | 1217 |
/* |
... | ... |
@@ -1016,7 +1224,7 @@ class tbg_converter_wrapper |
1016 | 1224 |
</div> |
1017 | 1225 |
</div> |
1018 | 1226 |
</div> |
1019 |
- </div> |
|
1227 |
+ <div id="footer"><span>', implode('</span><span>', $this->credits), '</span></div> |
|
1020 | 1228 |
</body></html>'; |
1021 | 1229 |
|
1022 | 1230 |
} |
... | ... |
@@ -1028,7 +1236,7 @@ class tbg_converter_wrapper |
1028 | 1236 |
public function showSettings($settings) |
1029 | 1237 |
{ |
1030 | 1238 |
echo ' |
1031 |
- <form action="', $_SERVER['PHP_SELF'], '" method="post" id="showSettings"> |
|
1239 |
+ <form action="', $_SERVER['PHP_SELF'], '" method="post"> |
|
1032 | 1240 |
<dl>'; |
1033 | 1241 |
|
1034 | 1242 |
foreach ($settings as $key => $data) |
... | ... |
@@ -1038,7 +1246,7 @@ class tbg_converter_wrapper |
1038 | 1246 |
<dd id="', $key, '_field">'; |
1039 | 1247 |
|
1040 | 1248 |
if ($data['type'] == 'textarea') |
1041 |
- echo '<textarea name="', $key, '"></textarea>'; |
|
1249 |
+ echo '<textarea name="', $key, '">', isset($data['default']) ? $data['default'] : '', '</textarea>'; |
|
1042 | 1250 |
elseif ($data['type'] == 'select') |
1043 | 1251 |
{ |
1044 | 1252 |
echo '<select name="', $key, '">'; |
... | ... |
@@ -1050,19 +1258,56 @@ class tbg_converter_wrapper |
1050 | 1258 |
echo ' |
1051 | 1259 |
</select>'; |
1052 | 1260 |
} |
1261 |
+ elseif ($data['type'] == 'password') |
|
1262 |
+ echo '<input type="password" name="', $key, '" />'; |
|
1053 | 1263 |
else |
1054 |
- echo '<input type="', $data['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" />'; |
|
1264 |
+ echo '<input type="text" name="', $key, '"', isset($data['default']) ? ' value="' . $data['default'] . '"' : '', ' />'; |
|
1055 | 1265 |
|
1056 | 1266 |
echo '</dd>'; |
1057 | 1267 |
} |
1058 | 1268 |
|
1059 | 1269 |
echo ' |
1060 |
- <dt><input type="submit" value="Start conversion" /></dt> |
|
1270 |
+ <dt><input name="save" type="submit" value="Start conversion" /></dt> |
|
1061 | 1271 |
</dl> |
1062 | 1272 |
</form>'; |
1063 | 1273 |
} |
1064 | 1274 |
|
1275 |
+ /* |
|
1276 |
+ * We have some new data!. |
|
1277 |
+ * @param $data: The json data. |
|
1278 |
+ */ |
|
1279 |
+ public function steps() |
|
1280 |
+ { |
|
1281 |
+ echo '<ol id="steps">'; |
|
1282 |
+ |
|
1283 |
+ foreach ($this->steps as $id_step => $step) |
|
1284 |
+ { |
|
1285 |
+ echo ' |
|
1286 |
+ <li id="step', $id_step, '" class="'; |
|
1287 |
+ |
|
1288 |
+ if ($id_step < $this->step) |
|
1289 |
+ echo 'done'; |
|
1290 |
+ elseif ($id_step == $this->step) |
|
1291 |
+ echo 'current'; |
|
1292 |
+ else |
|
1293 |
+ echo 'waiting'; |
|
1294 |
+ |
|
1295 |
+ echo '" ><span class="name">', $step[0], '</span><span class="progress_bar">'; |
|
1065 | 1296 |
|
1297 |
+ // The progress bar. |
|
1298 |
+ if ($id_step == $this->step) |
|
1299 |
+ echo '<span class="progress_box"><span class="progress_percent" id="progress_percent" style="width: 1%;">100%</span></span>'; |
|
1300 |
+ |
|
1301 |
+ echo '</span><span class="progress_status">'; |
|
1302 |
+ |
|
1303 |
+ if ($id_step < $this->step) |
|
1304 |
+ echo 'completed'; |
|
1305 |
+ |
|
1306 |
+ echo '</span></li>'; |
|
1307 |
+ } |
|
1308 |
+ |
|
1309 |
+ echo '</ol>'; |
|
1310 |
+ } |
|
1066 | 1311 |
} |
1067 | 1312 |
|
1068 | 1313 |
$convert = new mbt_to_tbg(); |
1069 | 1314 |
\ No newline at end of file |
1070 | 1315 |