/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { // Apply translations if (!$this->showAnswersTranslated) { // Here, not in e.g. __construct as these vars may be set during initiation $this->showAnswersNone = $this->_($this->showAnswersNone); $this->showAnswersRemoved = $this->_($this->showAnswersRemoved); $this->showAnswersSeparator = $this->_($this->showAnswersSeparator); $this->showAnswersTranslated = true; } // Overrule any setting of these values from source $this->data = null; $this->repeater = null; if (!$this->surveyId) { if ($this->token instanceof \Gems_Tracker_Token && $this->token->exists) { $this->surveyId = $this->token->getSurveyId(); } elseif ($this->trackData && !$this->trackId) { // Look up key values from trackData if (isset($this->trackData['gsu_id_survey'])) { $this->surveyId = $this->trackData['gsu_id_survey']; } elseif (isset($this->trackData['gro_id_survey'])) { $this->surveyId = $this->trackData['gro_id_survey']; } elseif (!$this->trackId) { if (isset($this->trackData['gtr_id_track'])) { $this->trackId = $this->trackData['gtr_id_track']; } elseif (isset($this->trackData['gro_id_track'])) { $this->trackId = $this->trackData['gro_id_track']; } } } if (!$this->trackId && $this->trackEngine) { $this->trackId = $this->trackEngine->getTrackId(); } if ($this->trackId && !$this->surveyId) { // Use the track ID to get the id of the first active survey $this->surveyId = $this->db->fetchOne('SELECT gro_id_survey FROM gems__rounds WHERE gro_active = 1 AND gro_id_track = ? ORDER BY gro_id_order', $this->trackId); } } // \MUtil_Echo::track($this->surveyId, $this->trackId); // Get the survey if ($this->surveyId && !$this->survey instanceof \Gems_Tracker_Survey) { $this->survey = $this->loader->getTracker()->getSurvey($this->surveyId); } // Load the data if ($this->survey instanceof \Gems_Tracker_Survey && $this->survey->exists) { $this->data = \MUtil_Ra::addKey($this->survey->getQuestionInformation($this->locale->getLanguage()), 'key'); //\MUtil_Echo::track($this->data); } return parent::hasHtmlOutput(); }