/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->importModel instanceof \MUtil_Model_ModelAbstract) { $model = new \MUtil_Model_SessionModel('import_for_' . $this->request->getControllerName()); $model->set('trackFile', 'label', $this->_('A .track.txt file'), 'count', 1, 'elementClass', 'File', 'extension', 'txt', 'description', $this->_('Import an exported track using a file with the extension ".track.txt".'), 'required', true); $model->set('importId'); $options = array('' => $this->_('<<create a new track>>')) + $this->util->getTrackData()->getAllTracks(); $model->set('gtr_id_track', 'label', $this->_('Merge with'), 'description', $this->_('Create a new track or choose a track to merge the import into.'), 'default', '', 'multiOptions', $options, 'size', min(12, count($options) + 1)); $trackModel = $this->loader->getTracker()->getTrackModel(); $trackModel->applyFormatting(true, true); $model->set('gtr_track_name', $trackModel->get('gtr_track_name') + array('respondentData' => true)); $model->set('gtr_organizations', $trackModel->get('gtr_organizations') + array('respondentData' => true)); $this->importModel = $model; } return $this->importModel; }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->importModel instanceof \MUtil_Model_ModelAbstract) { // $model = new \MUtil_Model_TableModel $model = new \MUtil_Model_SessionModel('import_for_' . $this->request->getControllerName()); $model->set('trans', 'label', $this->_('Import definition'), 'default', $this->defaultImportTranslator, 'description', $this->_('See import field definitions table'), 'multiOptions', $this->getTranslatorDescriptions(), 'required', true, 'elementClass', 'Radio', 'separator', ' '); $model->set('mode', 'label', $this->_('Choose work mode'), 'default', 'file', 'multiOptions', array('file' => $this->_('Upload a file'), 'textarea' => $this->_('Copy and paste into a text field')), 'required', true, 'elementClass', 'Radio', 'separator', ' '); $model->set('file', 'label', $this->_('Import file'), 'count', 1, 'elementClass', 'File', 'extension', 'csv,txt,xml', 'required', true); if ($this->tempDirectory) { \MUtil_File::ensureDir($this->tempDirectory); $model->set('file', 'destination', $this->tempDirectory); } // Storage for local copy of the file, kept through process $model->set('import_id'); $model->set('content', 'label', $this->_('Import text - user header line - separate fields using tabs'), 'description', $this->_('Empty fields remove any existing values. Add a field only when used.'), 'cols', 120, 'elementClass', 'Textarea'); $this->importModel = $model; } return $this->importModel; }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->importModel instanceof \MUtil_Model_ModelAbstract) { $model = new \MUtil_Model_SessionModel('import_for_' . $this->request->getControllerName()); $model->set('trackFile', 'label', $this->_('A .track.txt file'), 'count', 1, 'elementClass', 'File', 'extension', 'txt', 'description', $this->_('Import an exported track using a file with the extension ".track.txt".'), 'required', true); $model->set('import_id'); $trackModel = $this->loader->getTracker()->getTrackModel(); $trackModel->applyFormatting(true, true); $model->set('gtr_track_name', $trackModel->get('gtr_track_name') + array('respondentData' => true)); $model->set('gtr_organizations', $trackModel->get('gtr_organizations') + array('respondentData' => true)); $this->importModel = $model; } return $this->importModel; }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { if (!$this->exportModel instanceof \MUtil_Model_ModelAbstract) { $yesNo = $this->util->getTranslated()->getYesNo(); $model = new \MUtil_Model_SessionModel('export_for_' . $this->request->getControllerName()); $model->set('orgs', 'label', $this->_('Organization export'), 'default', 1, 'description', $this->_('Export the organizations for which the track is active'), 'multiOptions', $yesNo, 'required', true, 'elementClass', 'Checkbox'); $model->set('fields', 'label', $this->_('Field export')); $fields = $this->trackEngine->getFieldNames(); if ($fields) { $model->set('fields', 'default', array_keys($fields), 'description', $this->_('Check the fields to export'), 'elementClass', 'MultiCheckbox', 'multiOptions', $fields); } else { $model->set('fields', 'elementClass', 'Exhibitor', 'value', $this->_('No fields to export')); } $rounds = $this->trackEngine->getRoundDescriptions(); $model->set('rounds', 'label', $this->_('Round export')); if ($rounds) { $defaultRounds = array(); foreach ($rounds as $roundId => &$roundDescription) { $round = $this->trackEngine->getRound($roundId); if ($round && $round->isActive()) { $defaultRounds[] = $roundId; } else { $roundDescription = sprintf($this->_('%s (inactive)'), $roundDescription); } $survey = $round->getSurvey(); if ($survey) { $model->set('survey__' . $survey->getSurveyId(), 'label', $survey->getName(), 'default', $survey->getExportCode(), 'description', $this->_('A unique code indentifying this survey during track import'), 'maxlength', 64, 'required', true, 'size', 20, 'surveyId', $survey->getSurveyId()); } } $model->set('rounds', 'default', $defaultRounds, 'description', $this->_('Check the rounds to export'), 'elementClass', 'MultiCheckbox', 'multiOptions', $rounds); } else { $model->set('rounds', 'elementClass', 'Exhibitor', 'value', $this->_('No rounds to export')); } $this->exportModel = $model; } return $this->exportModel; }