예제 #1
0
 /**
  * Hook that loads the form data from $_POST or the model
  *
  * Or from whatever other source you specify here.
  */
 protected function loadFormData()
 {
     if ($this->request->isPost()) {
         $this->formData = $this->request->getPost() + $this->formData;
     } else {
         foreach ($this->importModel->getColNames('default') as $name) {
             if (!(isset($this->formData[$name]) && $this->formData[$name])) {
                 $this->formData[$name] = $this->importModel->get($name, 'default');
             }
         }
     }
     if (!(isset($this->formData['import_id']) && $this->formData['import_id'])) {
         $this->formData['import_id'] = mt_rand(10000, 99999) . time();
     }
     $this->_session = new \Zend_Session_Namespace(__CLASS__ . '-' . $this->formData['import_id']);
     if (isset($this->formData[$this->stepFieldName]) && $this->formData[$this->stepFieldName] > 1 && !(isset($this->_session->localfile) && $this->_session->localfile)) {
         $this->_session->localfile = \MUtil_File::createTemporaryIn($this->tempDirectory, $this->request->getControllerName() . '_');
     }
     // Must always exists
     $this->fileMode = 'file' === $this->formData['mode'];
     // Set the translator
     $translator = $this->getImportTranslator();
     if ($translator instanceof \MUtil_Model_ModelTranslatorInterface) {
         $this->importer->setImportTranslator($translator);
     }
     // \MUtil_Echo::track($_POST, $_FILES, $this->formData);
 }
 /**
  * Hook that loads the form data from $_POST or the model
  *
  * Or from whatever other source you specify here.
  */
 protected function loadFormData()
 {
     $model = $this->getModel();
     if ($this->request->isPost()) {
         $this->formData = $model->loadPostData($this->request->getPost() + $this->formData, true);
     } else {
         // Assume that if formData is set it is the correct formData
         if (!$this->formData) {
             $this->formData = $model->loadNew();
         }
     }
     if (isset($this->formData['gtr_id_track']) && $this->formData['gtr_id_track']) {
         $this->trackEngine = $this->loader->getTracker()->getTrackEngine($this->formData['gtr_id_track']);
     }
     if (!(isset($this->formData['importId']) && $this->formData['importId'])) {
         $this->formData['importId'] = mt_rand(10000, 99999) . time();
     }
     $this->_session = new \Zend_Session_Namespace(__CLASS__ . '-' . $this->formData['importId']);
     if (!(isset($this->_session->localfile) && $this->_session->localfile)) {
         $importLoader = $this->loader->getImportLoader();
         $this->_session->localfile = \MUtil_File::createTemporaryIn($importLoader->getTempDirectory(), $this->request->getControllerName() . '_');
     }
     // \MUtil_Echo::track($this->formData);
 }
 /**
  *
  * @return \Gems_Task_TaskRunnerBatch
  */
 protected function getExportBatch($load = true)
 {
     if ($this->_batch) {
         return $this->_batch;
     }
     $this->_batch = $this->loader->getTaskRunnerBatch('track_export_' . $this->trackEngine->getTrackId());
     if (!$load || $this->_batch->isFinished()) {
         return $this->_batch;
     }
     if (!$this->_batch->isLoaded()) {
         $filename = \MUtil_File::createTemporaryIn(GEMS_ROOT_DIR . '/var/tmp/export/track');
         $trackId = $this->trackEngine->getTrackId();
         $this->_batch->setSessionVariable('filename', $filename);
         $this->_batch->addTask('Tracker\\Export\\ProjectVersionExportTask');
         $this->_batch->addTask('Tracker\\Export\\MainTrackExportTask', $this->trackEngine->getTrackId(), $this->formData['orgs']);
         if (isset($this->formData['fields']) && is_array($this->formData['fields'])) {
             // \MUtil_Echo::track($this->formData['fields']);
             foreach ($this->formData['fields'] as $fieldId) {
                 $this->_batch->addTask('Tracker\\Export\\TrackFieldExportTask', $trackId, $fieldId);
             }
         }
         $model = $this->getModel();
         foreach ($model->getCol('surveyId') as $surveyId) {
             $this->_batch->addTask('Tracker\\Export\\TrackSurveyExportTask', $trackId, $surveyId);
         }
         if (isset($this->formData['rounds']) && is_array($this->formData['rounds'])) {
             foreach ($this->formData['rounds'] as $roundId) {
                 $this->_batch->addTask('Tracker\\Export\\TrackRoundExportTask', $trackId, $roundId);
             }
         }
     } else {
         $filename = $this->_batch->getSessionVariable('filename');
     }
     $this->_batch->setVariable('file', fopen($filename, 'a'));
     return $this->_batch;
 }