/** * Performs a transformation of the response value. * Reload the survey to use own value * * @param string $sValue * @param string $fieldType * @param FormattingOptions $oOptions * @param string $sColumn The name of the column * @return string */ protected function transformResponseValue($sValue, $fieldType, FormattingOptions $oOptions, $sColumn = null) { static $aColumnDone = array(); // If $sValue is already done for column :; we can take it again, but a lot of memory .... if ($this->exportAnswerPosition == 'aseperatecodetext') { if (!array_key_exists($sColumn, $aColumnDone)) { $bExportAnswerCode = !self::sameTextAndCode($fieldType, $sColumn); $bExportAnswerText = self::sameTextAndCode($fieldType, $sColumn); $aColumnDone[$sColumn] = 1; } else { $bExportAnswerCode = false; $bExportAnswerText = true; unset($aColumnDone[$sColumn]); } } else { $bExportAnswerCode = $this->exportAnswerCode && !self::sameTextAndCode($fieldType, $sColumn); $bExportAnswerText = $this->exportAnswerText || self::sameTextAndCode($fieldType, $sColumn); } $sAnswerFull = ""; $sAnswerText = ""; $sAnswerCode = ""; $oSurvey = $this->oSurvey; // We need survey to get answers ... // New event to allow another plugin to do something $oEvent = new PluginEvent('exportCompleteAnswersTransformResponseValue'); $oEvent->set('sValue', $sValue); $oEvent->set('fieldType', $fieldType); $oEvent->set('oOptions', $oOptions); // Needed ? $oEvent->set('oSurvey', $oSurvey); App()->getPluginManager()->dispatchEvent($oEvent); $sAnswerFull = $oEvent->get('answerValue'); // if $sAnswerFull is done by plugin, return it if (null !== $sAnswerFull) { return $sAnswerFull; } if ($bExportAnswerCode) { if (is_null($sValue)) { $sAnswerCode = $this->codeStringForNull; } else { $sAnswerCode = Writer::transformResponseValue($sValue, $fieldType, $oOptions, $sColumn); } if ($sValue != "" || $sValue === "" && $this->exportNullEmptyAnswerCode != "notempty" || is_null($sValue) && $this->exportNullEmptyAnswerCode == "always") { if ($this->exportAnswerPosition != 'aseperatecodetext') { $sAnswerCode = $this->exportAnswerCodeBefore . $sAnswerCode . $this->exportAnswerCodeAfter; } } } if ($bExportAnswerText) { if (is_null($sValue)) { $sAnswerText = $this->textStringForNull; } else { $sAnswerText = Writer::transformResponseValue($oSurvey->getFullAnswer($sColumn, $sValue, $this->translator, $this->languageCode), $fieldType, $oOptions, $sColumn); } // Remove not needed N/A .... $aNaType = array('Y', 'G', 'M', 'P'); if (in_array($fieldType, $aNaType) && $sAnswerText == "N/A") { $sAnswerText = ""; } } if ($this->exportAnswerPosition == 'acodetext') { $sAnswerFull = $sAnswerCode . $sAnswerText; } elseif ($this->exportAnswerPosition == 'atextcode') { $sAnswerFull = $sAnswerText . $sAnswerCode; } return $sAnswerFull; }