本文整理匯總了PHP中Gems_Util::getTrackData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gems_Util::getTrackData方法的具體用法?PHP Gems_Util::getTrackData怎麽用?PHP Gems_Util::getTrackData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gems_Util
的用法示例。
在下文中一共展示了Gems_Util::getTrackData方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: afterRegistry
/**
* Called after the check that all required registry values
* have been set correctly has run.
*
* @return void
* /
public function afterRegistry()
{
parent::afterRegistry();
}
/**
* Creates the model
*
* @return \MUtil_Model_ModelAbstract
*/
protected function createModel()
{
if (!$this->importModel instanceof \MUtil_Model_ModelAbstract) {
$surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
if ($surveyId) {
$this->formData['survey'] = $surveyId;
$this->_survey = $this->loader->getTracker()->getSurvey($surveyId);
$surveys[$surveyId] = $this->_survey->getName();
$elementClass = 'Exhibitor';
$tracks = $this->util->getTranslated()->getEmptyDropdownArray() + $this->util->getTrackData()->getTracksBySurvey($surveyId);
} else {
$empty = $this->util->getTranslated()->getEmptyDropdownArray();
$trackData = $this->util->getTrackData();
$surveys = $empty + $trackData->getActiveSurveys();
$tracks = $empty + $trackData->getAllTracks();
$elementClass = 'Select';
}
parent::createModel();
$order = $this->importModel->getOrder('trans') - 5;
$this->importModel->set('survey', 'label', $this->_('Survey'), 'elementClass', $elementClass, 'multiOptions', $surveys, 'onchange', 'this.form.submit();', 'order', $order, 'required', true);
$this->importModel->set('track', 'label', $this->_('Track'), 'description', $this->_('Optionally assign answers only within a single track'), 'multiOptions', $tracks);
$this->importModel->set('skipUnknownPatients', 'label', $this->_('Skip unknowns'), 'default', 0, 'description', $this->_('What to do when the respondent does not exist'), 'elementClass', 'Checkbox', 'multiOptions', $this->util->getTranslated()->getYesNo());
$tokenCompleted = array(\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_OVERWRITE => $this->_('Delete old token and create new'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_DOUBLE => $this->_('Create new extra set of answers'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR => $this->_('Abort the import'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_SKIP => $this->_('Skip the token'));
$this->importModel->set('tokenCompleted', 'label', $this->_('When token completed'), 'default', \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, 'description', $this->_('What to do when an imported token has already been completed'), 'elementClass', 'Radio', 'multiOptions', $tokenCompleted);
$tokenTreatments = array(\Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR => $this->_('Abort the import'), \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_SKIP => $this->_('Skip the token'));
$this->importModel->set('noToken', 'label', $this->_('Token does not exist'), 'default', \Gems_Model_Translator_AnswerTranslatorAbstract::TOKEN_ERROR, 'description', $this->_('What to do when no token exist to import to'), 'elementClass', 'Radio', 'multiOptions', $tokenTreatments);
if (\MUtil_Bootstrap::enabled()) {
$this->importModel->set('tokenCompleted', 'separator', '');
} else {
$this->importModel->set('trans', 'separator', '<br/>');
}
}
return $this->importModel;
}
示例2: execute
/**
* Should handle execution of the task, taking as much (optional) parameters as needed
*
* The parameters should be optional and failing to provide them should be handled by
* the task
*/
public function execute($lineNr = null, $surveyData = null)
{
$batch = $this->getBatch();
$import = $batch->getVariable('import');
$trackData = $this->util->getTrackData();
if (isset($surveyData['gsu_export_code']) && $surveyData['gsu_export_code']) {
$name = 'survey__' . $surveyData['gsu_export_code'];
$required = $this->checkRequired($surveyData['gsu_export_code'], $import['rounds']);
if (isset($surveyData['gsu_survey_name']) && $surveyData['gsu_survey_name']) {
$import['modelSettings'][$name]['label'] = $surveyData['gsu_survey_name'];
} else {
$import['modelSettings'][$name]['label'] = $surveyData['gsu_export_code'];
}
$import['modelSettings'][$name]['description'] = sprintf($this->_('[%s]'), $surveyData['gsu_export_code']);
$import['modelSettings'][$name]['isSurvey'] = true;
$import['modelSettings'][$name]['required'] = $required;
$surveyId = $this->db->fetchOne("SELECT gsu_id_survey FROM gems__surveys WHERE gsu_export_code = ?", $surveyData['gsu_export_code']);
// The first search determines whether the user can select a survey
// or the survey is displayed as fixed
if ($surveyId) {
$import['modelSettings'][$name]['elementClass'] = 'Exhibitor';
$import['modelSettings'][$name]['multiOptions'] = $trackData->getAllSurveys();
$import['surveyCodes'][$surveyData['gsu_export_code']] = $surveyId;
} else {
$import['modelSettings'][$name]['elementClass'] = 'Select';
// Store the exportCode for rows that should be saved
$import['modelSettings'][$name]['exportCode'] = $surveyData['gsu_export_code'];
if ($required) {
$empty = $this->_('(survey required)');
} else {
$empty = $this->_('(skip rounds)');
}
$import['modelSettings'][$name]['multiOptions'] = array('' => $empty) + $trackData->getSurveysWithoutExportCode();
$import['surveyCodes'][$surveyData['gsu_export_code']] = false;
}
// Then try match on gsu_surveyor_id
if (!$surveyId && isset($surveyData['gsu_surveyor_id']) && $surveyData['gsu_surveyor_id']) {
$surveyId = $this->db->fetchOne("SELECT gsu_id_survey FROM gems__surveys WHERE gsu_surveyor_id = ?", $surveyData['gsu_surveyor_id']);
}
// Last try ny name
if (!$surveyId && isset($surveyData['gsu_survey_name']) && $surveyData['gsu_survey_name']) {
$surveyId = $this->db->fetchOne("SELECT gsu_id_survey FROM gems__surveys WHERE gsu_survey_name = ?", $surveyData['gsu_survey_name']);
}
// When we have a survey id that is in the options, add it as default
if ($surveyId) {
if (isset($import['modelSettings'][$name]['multiOptions'][$surveyId])) {
$import['formDefaults'][$name] = $surveyId;
}
}
} else {
$batch->addToCounter('import_errors');
$batch->addMessage(sprintf($this->_('No gsu_export_code specified for survey at line %d.'), $lineNr));
}
}
示例3: getRoundModel
/**
* Returns a model that can be used to retrieve or save the data.
*
* @param boolean $detailed Create a model for the display of detailed item data or just a browse table
* @param string $action The current action
* @return \MUtil_Model_ModelAbstract
*/
public function getRoundModel($detailed, $action)
{
$model = $this->createRoundModel();
$translated = $this->util->getTranslated();
// Set the keys to the parameters in use.
$model->setKeys(array(\MUtil_Model::REQUEST_ID => 'gro_id_track', \Gems_Model::ROUND_ID => 'gro_id_round'));
if ($detailed) {
$model->set('gro_id_track', 'label', $this->_('Track'), 'elementClass', 'exhibitor', 'multiOptions', $this->util->getTrackData()->getAllTracks);
}
$model->set('gro_id_survey', 'label', $this->_('Survey'), 'multiOptions', $this->util->getTrackData()->getAllSurveysAndDescriptions());
$model->set('gro_icon_file', 'label', $this->_('Icon'));
$model->set('gro_id_order', 'label', $this->_('Order'), 'default', 10, 'validators[uni]', $model->createUniqueValidator(array('gro_id_order', 'gro_id_track')));
$model->set('gro_round_description', 'label', $this->_('Description'), 'size', '30');
//, 'minlength', 4, 'required', true);
$list = $this->events->listRoundChangedEvents();
if (count($list) > 1) {
$model->set('gro_changed_event', 'label', $this->_('After change'), 'multiOptions', $list);
}
$list = $this->events->listSurveyDisplayEvents();
if (count($list) > 1) {
$model->set('gro_display_event', 'label', $this->_('Answer display'), 'multiOptions', $list);
}
$model->set('gro_active', 'label', $this->_('Active'), 'elementClass', 'checkbox', 'multiOptions', $translated->getYesNo());
$model->setIfExists('gro_code', 'label', $this->_('Round code'), 'description', $this->_('Optional code name to link the field to program code.'), 'size', 10);
$model->addColumn("CASE WHEN gro_active = 1 THEN '' ELSE 'deleted' END", 'row_class');
$model->addColumn("CASE WHEN gro_organizations IS NULL THEN 0 ELSE 1 END", 'org_specific_round');
$model->addColumn('gro_organizations', 'organizations');
$model->set('organizations', 'label', $this->_('Organizations'), 'elementClass', 'MultiCheckbox', 'multiOptions', $this->util->getDbLookup()->getOrganizations(), 'data-source', 'org_specific_round');
$tp = new \MUtil_Model_Type_ConcatenatedRow('|', $this->_(', '));
$tp->apply($model, 'organizations');
switch ($action) {
case 'create':
$this->_ensureRounds();
if ($this->_rounds && ($round = end($this->_rounds))) {
$model->set('gro_id_order', 'default', $round['gro_id_order'] + 10);
}
// Intentional fall through
// break;
// Intentional fall through
// break;
case 'edit':
case 'show':
$model->set('gro_icon_file', 'multiOptions', $translated->getEmptyDropdownArray() + $this->_getAvailableIcons());
$model->set('org_specific_round', 'label', $this->_('Organization specific round'), 'default', 0, 'multiOptions', $translated->getYesNo(), 'elementClass', 'radio');
break;
default:
$model->set('gro_icon_file', 'formatFunction', array('MUtil_Html_ImgElement', 'imgFile'));
break;
}
return $model;
}
示例4: loadFormData
/**
* Hook that loads the form data from $_POST or the model
*
* Or from whatever other source you specify here.
*/
protected function loadFormData()
{
parent::loadFormData();
if ($this->createData && !$this->request->isPost()) {
$this->formData = $this->trackEngine->getRoundDefaults() + $this->formData;
}
// Check the survey name
$surveys = $this->util->getTrackData()->getAllSurveys();
if (isset($surveys[$this->formData['gro_id_survey']])) {
$this->formData['gro_survey_name'] = $surveys[$this->formData['gro_id_survey']];
} else {
// Currently required
$this->formData['gro_survey_name'] = '';
}
}
示例5: createModel
/**
* 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;
}
示例6: applyDetailSettings
/**
* Set those settings needed for the detailed display
*
* @return \Gems\Tracker\Model\FieldMaintenanceModel (continuation pattern)
*/
public function applyDetailSettings()
{
$this->applyBrowseSettings(true);
$this->_addLoadDependency = true;
$this->set('gtf_id_track', 'label', $this->_('Track'), 'multiOptions', $this->util->getTrackData()->getAllTracks());
$this->set('gtf_field_description', 'label', $this->_('Description'), 'description', $this->_('Optional extra description to show the user.'));
$this->set('gtf_track_info_label', 'label', $this->_('Add name to description'));
$this->set('htmlUse', 'label', ' ');
// But do always transform gtf_calculate_using on load and save
// as otherwise we might not be sure what to do
$contact = new \MUtil_Model_Type_ConcatenatedRow(self::FIELD_SEP, '; ', false);
$contact->apply($this, 'gtf_calculate_using');
// Clean up data always show in browse view, but not always in detail views
$this->set('gtf_create_track', 'label', null);
$switches = array(0 => array('gtf_track_info_label' => array('elementClass' => 'Hidden', 'label' => null)));
$this->addDependency(array('ValueSwitchDependency', $switches), 'gtf_to_track_info');
}
示例7: createModel
/**
* Creates the model
*
* @return \MUtil_Model_ModelAbstract
*/
protected function createModel()
{
$model = $this->tracker->getTokenModel();
if ($model instanceof \Gems_Tracker_Model_StandardTokenModel) {
$model->addEditTracking();
if ($this->createData) {
$model->applyInsertionFormatting();
}
}
// Valid from can not be calculated for inserted rounds, and should always be manual
$model->set('gto_valid_from_manual', 'elementClass', 'Hidden', 'default', '1');
$trackData = $this->util->getTrackData();
$this->surveyList = $trackData->getInsertableSurveys();
$model->set('gto_id_survey', 'label', $this->_('Suvey to insert'), 'multiOptions', $this->surveyList, 'onchange', 'this.form.submit();');
$model->set('gto_id_track', 'label', $this->_('Existing track'), 'elementClass', 'Select', 'onchange', 'this.form.submit();');
$model->set('gto_round_order', 'label', $this->_('In round'), 'elementClass', 'Select', 'required', true);
$model->set('gto_valid_from', 'required', true);
return $model;
}
示例8: getFormElements
/**
* Get form elements for the specific Export
* @param \Gems_Form $form existing form type
* @param array data existing options set in the form
* @return array of form elements
*/
public function getFormElements(\Gems_Form $form, &$data)
{
$form->activateJQuery();
$dbLookup = $this->util->getDbLookup();
$translated = $this->util->getTranslated();
$noRound = array(self::NoRound => $this->_('No round description'));
$empty = $translated->getEmptyDropdownArray();
$dateOptions = array();
\MUtil_Model_Bridge_FormBridge::applyFixedOptions('date', $dateOptions);
$organizations = $this->currentUser->getRespondentOrganizations();
$tracks = $empty + $this->util->getTrackData()->getAllTracks();
$rounds = $empty + $noRound + $dbLookup->getRoundsForExport(isset($data['tid']) ? $data['tid'] : null);
$surveys = $dbLookup->getSurveysForExport(isset($data['tid']) ? $data['tid'] : null, isset($data['rounds']) ? $data['rounds'] : null);
$yesNo = $translated->getYesNo();
$elements = array();
$element = $form->createElement('textarea', 'ids');
$element->setLabel($this->_('Respondent id\'s'))->setAttrib('cols', 60)->setAttrib('rows', 4)->setDescription($this->_('Not respondent nr, but respondent id as exported here.'));
$elements[] = $element;
$element = $form->createElement('select', 'tid');
$element->setLabel($this->_('Tracks'))->setMultiOptions($tracks);
$elements[] = $element;
if (isset($data['tid']) && $data['tid']) {
$element = $form->createElement('radio', 'tid_fields');
$element->setLabel($this->_('Export fields'))->setMultiOptions($yesNo);
$elements[] = $element;
if (!array_key_exists('tid_fields', $data)) {
$data['tid_fields'] = 1;
}
}
$element = $form->createElement('select', 'rounds');
$element->setLabel($this->_('Round description'))->setMultiOptions($rounds);
$elements[] = $element;
$element = $form->createElement('multiselect', 'sid');
$element->setLabel($this->_('Survey'))->setMultiOptions($surveys)->setDescription($this->_('Use CTRL or Shift to select more'));
$elements[] = $element;
$element = $form->createElement('multiCheckbox', 'oid');
$element->setLabel($this->_('Organization'))->setMultiOptions($organizations);
$elements[] = $element;
if (\MUtil_Bootstrap::enabled()) {
$element = new \MUtil_Bootstrap_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
} else {
$element = new \Gems_JQuery_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
}
$element->setLabel($this->_('Toggle'));
$elements[] = $element;
$element = $form->createElement('datePicker', 'valid_from', $dateOptions);
$element->setLabel($this->_('Valid from'));
$elements[] = $element;
$element = $form->createElement('datePicker', 'valid_until', $dateOptions);
$element->setLabel($this->_('Valid until'));
$elements[] = $element;
if (\MUtil_Bootstrap::enabled()) {
$element = new \MUtil_Bootstrap_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
} else {
$element = new \Gems_JQuery_Form_Element_ToggleCheckboxes('toggleOrg', array('selector' => 'input[name^=oid]'));
}
$element = $form->createElement('checkbox', 'column_identifiers');
$element->setLabel($this->_('Column Identifiers'));
$element->setDescription($this->_('Prefix the column labels with an identifier. (A) Answers, (TF) Trackfields, (D) Description'));
$elements[] = $element;
//unset($data['records']);
if (!empty($data['sid'])) {
$filters = $this->getFilters($data);
foreach ($filters as $key => $filter) {
unset($data['records_' . $key]);
$model = $this->getModel($filter, $data);
$survey = $this->loader->getTracker()->getSurvey(intval($filter['gto_id_survey']));
$recordCount = $model->loadPaginator($filter)->getTotalItemCount();
$element = $form->createElement('exhibitor', 'records_' . $key);
$element->setValue($survey->getName() . ': ' . sprintf($this->_('%s records found.'), $recordCount));
//$element->setValue($survey->getName());
$elements[] = $element;
}
}
if ($this->project->hasResponseDatabase()) {
$this->addResponseDatabaseForm($form, $data, $elements);
}
return $elements;
}
示例9: getAllTrackTypes
/**
*
* @param string $orgWhere
* @param array $data The $form field values (can be usefull, but no need to set them)
* @return mixed SQL string or array
*/
protected function getAllTrackTypes($orgWhere, array $data)
{
return $this->util->getTrackData()->getActiveTracks($orgWhere);
}