コード例 #1
0
 /**
  * Step 6. Sanitize and create/update models using a sequential process.
  * @param integer $id - Import model id
  * @param null|string $step
  * @param null|int $pageSize
  */
 public function actionStep6($id, $step = null, $pageSize = null)
 {
     $getData = GetUtil::getData();
     if (isset($getData['nextParams'])) {
         $nextParams = $getData['nextParams'];
     } else {
         $nextParams = null;
     }
     assert('$step == null || is_string($step)');
     assert('$nextParams == null || is_array($nextParams)');
     $import = Import::getById((int) $id);
     $importWizardForm = ImportWizardUtil::makeFormByImport($import);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('bbq');
     $unserializedData = unserialize($import->serializedData);
     $passedInPageSize = $pageSize;
     if ($pageSize == null) {
         $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('importPageSize');
     }
     $config = array('pagination' => array('pageSize' => $pageSize));
     $filteredByStatus = $this->resolveFilteredByStatus();
     $dataProvider = new ImportDataProvider($import->getTempTableName(), (bool) $importWizardForm->firstRowIsHeaderRow, $config, (int) $filteredByStatus);
     $sequentialProcess = new ImportCreateUpdateModelsSequentialProcess($import, $dataProvider);
     Yii::app()->gameHelper->muteScoringModelsOnSave();
     $sequentialProcess->run($step, $nextParams);
     Yii::app()->gameHelper->unmuteScoringModelsOnSave();
     $nextStep = $sequentialProcess->getNextStep();
     $route = $this->getModule()->getId() . '/' . $this->getId() . '/step6';
     if ($sequentialProcess->isComplete()) {
         $this->resolveResettingPageOnCompletion($dataProvider);
         $importingIntoModelClassName = $unserializedData['importRulesType'] . 'ImportRules';
         Yii::app()->gameHelper->triggerImportEvent($importingIntoModelClassName::getModelClassName());
         if (isset($getData['ajax']) && $getData['ajax'] == 'import-temp-table-list-view') {
             $resolvedView = new ImportResultsImportTempTableListView($this->getId(), $this->getModule()->getId(), $dataProvider, $unserializedData['mappingData'], $importWizardForm->importRulesType, ImportWizardDataAnalysisCompleteView::resolveConfigurationForm(), new ZurmoActiveForm(), $import->id);
         } else {
             $importCompleteView = $this->makeImportCompleteView($import, $importWizardForm, $dataProvider, true, $passedInPageSize);
             $resolvedView = new ContainedViewCompleteSequentialProcessView($importCompleteView);
         }
     } else {
         $resolvedView = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route);
     }
     if ($step == null) {
         $title = Zurmo::t('ImportModule', 'Import Wizard - Import Data');
         $importRulesClassName = ImportRulesUtil::getImportRulesClassNameByType($importWizardForm->importRulesType);
         $stepToUse = ImportStepsAndProgressBarForWizardView::resolveAfterUploadStepByImportClassName(5, $importRulesClassName);
         $progressBarAndStepsView = new ImportStepsAndProgressBarForWizardView($importRulesClassName, $stepToUse);
         $wrapperView = new ImportSequentialProcessContainerView($resolvedView, $sequentialProcess->getAllStepsMessage(), $title);
         $wrapperView->setCssClasses(array('DetailsView'));
         $view = $this->getImportPageView($progressBarAndStepsView, $wrapperView);
     } else {
         $view = new AjaxPageView($resolvedView);
     }
     echo $view->render();
 }
コード例 #2
0
 /**
  * Step 6. Sanitize and create/update models using a sequential process.
  * @param integer id - Import model id
  * @param string $step
  */
 function actionStep6($id, $step = null)
 {
     if (isset($_GET['nextParams'])) {
         $nextParams = $_GET['nextParams'];
     } else {
         $nextParams = null;
     }
     assert('$step == null || is_string($step)');
     assert('$nextParams == null || is_array($nextParams)');
     $import = Import::getById((int) $id);
     $importWizardForm = ImportWizardUtil::makeFormByImport($import);
     $cs = Yii::app()->getClientScript();
     $cs->registerCoreScript('bbq');
     if (isset($_GET['ajax']) && $_GET['ajax'] == 'list-view') {
         $importCompleteView = $this->makeImportCompleteView($import, $importWizardForm);
         $view = new AjaxPageView($importCompleteView);
         echo $view->render();
         Yii::app()->end(0, false);
     }
     $unserializedData = unserialize($import->serializedData);
     $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('importPageSize');
     $config = array('pagination' => array('pageSize' => $pageSize));
     $dataProvider = new ImportDataProvider($import->getTempTableName(), (bool) $importWizardForm->firstRowIsHeaderRow, $config);
     $sequentialProcess = new ImportCreateUpdateModelsSequentialProcess($import, $dataProvider);
     Yii::app()->gameHelper->muteScoringModelsOnSave();
     $sequentialProcess->run($step, $nextParams);
     Yii::app()->gameHelper->unmuteScoringModelsOnSave();
     $nextStep = $sequentialProcess->getNextStep();
     $route = $this->getModule()->getId() . '/' . $this->getId() . '/step6';
     if ($sequentialProcess->isComplete()) {
         $importingIntoModelClassName = $unserializedData['importRulesType'] . 'ImportRules';
         Yii::app()->gameHelper->triggerImportEvent($importingIntoModelClassName::getModelClassName());
         $importCompleteView = $this->makeImportCompleteView($import, $importWizardForm, true);
         $sequenceView = new ContainedViewCompleteSequentialProcessView($importCompleteView);
     } else {
         $sequenceView = SequentialProcessViewFactory::makeBySequentialProcess($sequentialProcess, $route);
     }
     if ($step == null) {
         $title = Zurmo::t('ImportModule', 'Import Wizard: Step 6 of 6');
         $wrapperView = new ImportSequentialProcessContainerView($sequenceView, $sequentialProcess->getAllStepsMessage(), $title);
         $wrapperView->setCssClasses(array('DetailsView'));
         $view = new ImportPageView(ZurmoDefaultAdminViewUtil::makeStandardViewForCurrentUser($this, $wrapperView));
     } else {
         $view = new AjaxPageView($sequenceView);
     }
     echo $view->render();
 }