public function Go() { $this->Permission('Garden.Settings.Manage'); $Imp = new ImportModel(); $Imp->LoadState(); $this->SetData('Steps', $Imp->Steps()); $this->Form = new Gdn_Form(); if($Imp->CurrentStep < 1) { // Check for the import file. if($Imp->ImportPath) $Imp->CurrentStep = 1; else Redirect(strtolower($this->Application).'/import'); } if($Imp->CurrentStep >= 1) { if($this->Form->IsPostBack()) $Imp->FromPost($this->Form->FormValues()); try { $Result = $Imp->RunStep($Imp->CurrentStep); } catch(Exception $Ex) { $Result = FALSE; $this->Form->AddError($Ex); $this->SetJson('Error', TRUE); } if($Result === TRUE) { $Imp->CurrentStep++; } elseif($Result === 'COMPLETE') { $this->SetJson('Complete', TRUE); } /*elseif(is_array($Result)) { SaveToConfig(array( 'Garden.Import.CurrentStep' => $CurrentStep, 'Garden.Import.CurrentStepData' => ArrayValue('Data', $Result))); $this->SetData('CurrentStepMessage', ArrayValue('Message', $Result)); }*/ } $Imp->SaveState(); $this->Form->SetValidationResults($Imp->Validation->Results()); $this->SetData('Stats', GetValue('Stats', $Imp->Data, array())); $this->SetData('CurrentStep', $Imp->CurrentStep); $this->SetData('CurrentStepMessage', GetValue('CurrentStepMessage', $Imp->Data, '')); $this->SetData('ErrorType', GetValue('ErrorType', $Imp)); if ($this->Data('ErrorType')) $this->SetJson('Error', TRUE); $Imp->ToPost($Post); $this->Form->FormValues($Post); $this->AddJsFile('import.js'); $this->Render(); }
public function Go() { $this->Permission('Garden.Import'); $Imp = new ImportModel(); $Imp->LoadState(); $this->SetData('Steps', $Imp->Steps()); if ($Imp->CurrentStep < 1) { // Check for the import file. if ($Imp->ImportPath) { $Imp->CurrentStep = 1; } else { Redirect(strtolower($this->Application) . '/import'); } } if ($Imp->CurrentStep >= 1) { $Result = $Imp->RunStep($Imp->CurrentStep); if ($Result === TRUE) { $Imp->CurrentStep++; } elseif ($Result === 'COMPLETE') { $this->SetJson('Complete', TRUE); } /*elseif(is_array($Result)) { SaveToConfig(array( 'Garden.Import.CurrentStep' => $CurrentStep, 'Garden.Import.CurrentStepData' => ArrayValue('Data', $Result))); $this->SetData('CurrentStepMessage', ArrayValue('Message', $Result)); }*/ } $Imp->SaveState(); $this->Form = new Gdn_Form(); $this->Form->SetValidationResults($Imp->Validation->Results()); $this->SetData('CurrentStep', $Imp->CurrentStep); $this->SetData('CurrentStepMessage', GetValue('CurrentStepMessage', $Imp->Data, '')); $this->AddJsFile('import.js'); $this->Render(); }