Jeremy D commited on 2011-10-19 20:19:37
Showing 1 changed files, with 43 additions and 15 deletions.
... | ... |
@@ -51,6 +51,10 @@ class tbg_coverter |
51 | 51 |
// The start timer. |
52 | 52 |
protected $start_time = 0; |
53 | 53 |
|
54 |
+ // Step info. |
|
55 |
+ private $substep = 0; |
|
56 |
+ private $step = 0; |
|
57 |
+ |
|
54 | 58 |
// Is this CLI? |
55 | 59 |
protected $is_cli = false; |
56 | 60 |
protected $is_json = false; |
... | ... |
@@ -97,11 +101,20 @@ class tbg_coverter |
97 | 101 |
$this->loadSettings(); |
98 | 102 |
|
99 | 103 |
// Now restart. |
104 |
+ do |
|
105 |
+ { |
|
106 |
+ $data = $steps[$this->step]; |
|
107 |
+ |
|
100 | 108 |
$this->updateSubStep($this->substep); |
101 | 109 |
$this->updateStep('doStep' . $this->step); |
110 |
+ $this->step_size = $data[2]; |
|
111 |
+ } |
|
112 |
+ while |
|
113 |
+ { |
|
114 |
+ $count = $data[1](); |
|
102 | 115 |
|
103 |
- $function = 'doStep' . $this->step; |
|
104 |
- $function(); |
|
116 |
+ $this->checkTimeout($data[1], $this->substep, $data[2], $count); |
|
117 |
+ } |
|
105 | 118 |
} |
106 | 119 |
|
107 | 120 |
/** |
... | ... |
@@ -158,6 +171,10 @@ class tbg_coverter |
158 | 171 |
|
159 | 172 |
return; |
160 | 173 |
} |
174 |
+ |
|
175 |
+ // Load some from the url. |
|
176 |
+ $this->step = (int) $_GET['step']; |
|
177 |
+ $this->substep = (int) $_GET['substep']; |
|
161 | 178 |
} |
162 | 179 |
|
163 | 180 |
/** |
... | ... |
@@ -241,9 +258,10 @@ class tbg_coverter |
241 | 258 |
* |
242 | 259 |
* @param init $substep new value for substep. |
243 | 260 |
*/ |
244 |
- function updateStep($substep) |
|
261 |
+ function updateStep($step) |
|
245 | 262 |
{ |
246 | 263 |
$_GET['step'] = (int) $step; |
264 |
+ $this->step = (int) $step; |
|
247 | 265 |
|
248 | 266 |
return true; |
249 | 267 |
} |
... | ... |
@@ -256,10 +274,7 @@ class tbg_coverter |
256 | 274 |
*/ |
257 | 275 |
function getSubStep($step) |
258 | 276 |
{ |
259 |
- if (!isset($_GET['step']) || !isset($_GET['substep']) || str_replace('doStep', '', $step) != $_GET['step']) |
|
260 |
- return 0; |
|
261 |
- else |
|
262 |
- return (int) $_GET['substep']; |
|
277 |
+ return $this->substep; |
|
263 | 278 |
} |
264 | 279 |
|
265 | 280 |
/** |
... | ... |
@@ -271,6 +286,7 @@ class tbg_coverter |
271 | 286 |
function updateSubStep($substep) |
272 | 287 |
{ |
273 | 288 |
$_GET['substep'] = (int) $substep; |
289 |
+ $this->substep = (int) $substep; |
|
274 | 290 |
|
275 | 291 |
return true; |
276 | 292 |
} |
... | ... |
@@ -335,6 +351,18 @@ class mbt_to_tbg extends tbg_converter |
335 | 351 |
{ |
336 | 352 |
protected $mbt_db_prefix; |
337 | 353 |
|
354 |
+ // What steps shall we take. |
|
355 |
+ protected $steps = array( |
|
356 |
+ // Key => array('Descriptive', 'functionName', (int) step_size), |
|
357 |
+ 0 = > array('Users', 'doStep1', 500), |
|
358 |
+ 1 = > array('Projects', 'doStep2', 500), |
|
359 |
+ 2 = > array('Categories', 'doStep3', 500), |
|
360 |
+ 3 = > array('Versions', 'doStep4', 500), |
|
361 |
+ 4 = > array('Issues', 'doStep5', 500), |
|
362 |
+ 5 = > array('Comments', 'doStep6', 500), |
|
363 |
+ 6 = > array('Relationships', 'doStep7', 500), |
|
364 |
+ 7 = > array('Attachments', 'doStep8', 100), |
|
365 |
+ ); |
|
338 | 366 |
/** |
339 | 367 |
* Set the prefix that will be used prior to every reference of a table |
340 | 368 |
*/ |
... | ... |
@@ -438,7 +466,7 @@ class mbt_to_tbg extends tbg_converter |
438 | 466 |
++$i; |
439 | 467 |
} |
440 | 468 |
|
441 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
469 |
+ return $i; |
|
442 | 470 |
} |
443 | 471 |
|
444 | 472 |
/** |
... | ... |
@@ -467,7 +495,7 @@ class mbt_to_tbg extends tbg_converter |
467 | 495 |
++$i; |
468 | 496 |
} |
469 | 497 |
|
470 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
498 |
+ return $i; |
|
471 | 499 |
} |
472 | 500 |
|
473 | 501 |
/** |
... | ... |
@@ -495,7 +523,7 @@ class mbt_to_tbg extends tbg_converter |
495 | 523 |
++$i; |
496 | 524 |
} |
497 | 525 |
|
498 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
526 |
+ return $i; |
|
499 | 527 |
} |
500 | 528 |
|
501 | 529 |
/** |
... | ... |
@@ -536,7 +564,7 @@ class mbt_to_tbg extends tbg_converter |
536 | 564 |
++$i; |
537 | 565 |
} |
538 | 566 |
|
539 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
567 |
+ return $i; |
|
540 | 568 |
} |
541 | 569 |
|
542 | 570 |
|
... | ... |
@@ -600,7 +628,7 @@ class mbt_to_tbg extends tbg_converter |
600 | 628 |
++$i; |
601 | 629 |
} |
602 | 630 |
|
603 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
631 |
+ return $i; |
|
604 | 632 |
} |
605 | 633 |
|
606 | 634 |
/** |
... | ... |
@@ -630,7 +658,7 @@ class mbt_to_tbg extends tbg_converter |
630 | 658 |
++$i; |
631 | 659 |
} |
632 | 660 |
|
633 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
661 |
+ return $i; |
|
634 | 662 |
} |
635 | 663 |
|
636 | 664 |
/** |
... | ... |
@@ -658,7 +686,7 @@ class mbt_to_tbg extends tbg_converter |
658 | 686 |
++$i; |
659 | 687 |
} |
660 | 688 |
|
661 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
689 |
+ return $i; |
|
662 | 690 |
} |
663 | 691 |
|
664 | 692 |
/** |
... | ... |
@@ -694,7 +722,7 @@ class mbt_to_tbg extends tbg_converter |
694 | 722 |
++$i; |
695 | 723 |
} |
696 | 724 |
|
697 |
- $this->checkTimeout(__FUNCTION__, $substep, $step_size, $i); |
|
725 |
+ return $i; |
|
698 | 726 |
} |
699 | 727 |
|
700 | 728 |
// @ TODO: Duplicate function, merge or remove. |
701 | 729 |