JsonWriter
extends Writer
in package
Contains functions and properties that are common to all writers.
All extending classes must implement the internalWrite(...) method and have access to functionality as described below:
TODO Write more docs here
Table of Contents
Properties
- $filename : mixed
- $languageCode : mixed
- $webfilename : mixed
- $havePrev : mixed
- first don't need separator
- $sLanguageCode : mixed
- $translator : Translator
- $file : mixed
- The open filehandle
- $output : mixed
Methods
- __construct() : mixed
- close() : mixed
- getAbbreviatedHeading() : string
- Returns an abbreviated heading for the survey's question that matches Force headingTextLength to be set, set to 15 if is not set (old behaviour)
- getFullFieldSubHeading() : string
- Return the subquestion part, if not empty : add a space before it.
- getFullHeading() : string
- Returns a full heading for the question that matches the $fieldName.
- getFullQuestionHeading() : string
- Return the question text part without any subquestion
- getHeadingCode() : string
- Return the question code according to options
- getHeadingText() : string
- Return the question text according to options
- getLongAnswer() : string
- Return the answer text according to options
- getShortAnswer() : string
- Return the answer text according to options
- init() : mixed
- An initialization method that implementing classes can override to gain access to any information about the survey, language, or formatting options they may need for setup.
- setGroupMap() : array<string|int, mixed>
- Return map of questions groups
- write() : mixed
- This method is made final to prevent extending code from circumventing the initialization process that must take place prior to any of the translation infrastructure to work.
- outputRecord() : mixed
- This method will be called once for every row of data that needs to be output.
- stripTagsFull() : mixed
- transformResponseValue() : string
- Performs a transformation of the response value based on the value, the type of field the value is a response for, and the FormattingOptions.
- translate() : mixed
Properties
$filename
public
mixed
$filename
$languageCode
public
mixed
$languageCode
$webfilename
public
mixed
$webfilename
$havePrev
first don't need separator
protected
mixed
$havePrev
= \false
$sLanguageCode
protected
mixed
$sLanguageCode
$translator
protected
Translator
$translator
$file
The open filehandle
private
mixed
$file
= \null
$output
private
mixed
$output
Methods
__construct()
public
__construct() : mixed
close()
public
close() : mixed
getAbbreviatedHeading()
Returns an abbreviated heading for the survey's question that matches Force headingTextLength to be set, set to 15 if is not set (old behaviour)
public
getAbbreviatedHeading(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
Return values
stringgetFullFieldSubHeading()
Return the subquestion part, if not empty : add a space before it.
public
getFullFieldSubHeading(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
Return values
stringgetFullHeading()
Returns a full heading for the question that matches the $fieldName.
public
getFullHeading(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName) : string
Force headingTextLength to null (old behaviour)
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
Tags
Return values
stringgetFullQuestionHeading()
Return the question text part without any subquestion
public
getFullQuestionHeading(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
Return values
stringgetHeadingCode()
Return the question code according to options
public
getHeadingCode(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
Return values
stringgetHeadingText()
Return the question text according to options
public
getHeadingText(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
Return values
stringgetLongAnswer()
Return the answer text according to options
public
getLongAnswer(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName, string $sValue) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
- $sValue : string
Return values
stringgetShortAnswer()
Return the answer text according to options
public
getShortAnswer(SurveyObj $oSurvey, FormattingOptions $oOptions, string $fieldName, string $sValue) : string
Parameters
- $oSurvey : SurveyObj
- $oOptions : FormattingOptions
- $fieldName : string
- $sValue : string
Return values
stringinit()
An initialization method that implementing classes can override to gain access to any information about the survey, language, or formatting options they may need for setup.
public
init(SurveyObj $survey, mixed $sLanguageCode, FormattingOptions $oOptions) : mixed
Parameters
- $survey : SurveyObj
- $sLanguageCode : mixed
- $oOptions : FormattingOptions
setGroupMap()
Return map of questions groups
public
setGroupMap(SurveyObj $survey, FormattingOptions $oOptions) : array<string|int, mixed>
Parameters
- $survey : SurveyObj
- $oOptions : FormattingOptions
Return values
array<string|int, mixed>write()
This method is made final to prevent extending code from circumventing the initialization process that must take place prior to any of the translation infrastructure to work.
public
final write(SurveyObj $oSurvey, string $sLanguageCode, FormattingOptions $oOptions[, bool $bOutputHeaders = true ]) : mixed
The inialization process is dependent upon the survey being passed into the write function and so must be performed when the method is called and not prior to (such as in a constructor).
All extending classes must implement the internalWrite function which is the code that is called after all initialization is completed.
Parameters
- $oSurvey : SurveyObj
- $sLanguageCode : string
- $oOptions : FormattingOptions
- $bOutputHeaders : bool = true
-
Set if header should be given back
outputRecord()
This method will be called once for every row of data that needs to be output.
protected
outputRecord(mixed $headers, mixed $values, FormattingOptions $oOptions) : mixed
Implementations must use the data from these method calls to construct proper output for their output type and the given FormattingOptions.
Parameters
- $headers : mixed
- $values : mixed
- $oOptions : FormattingOptions
stripTagsFull()
protected
stripTagsFull(string $string) : mixed
Parameters
- $string : string
transformResponseValue()
Performs a transformation of the response value based on the value, the type of field the value is a response for, and the FormattingOptions.
protected
transformResponseValue(string $value, string $fieldType, FormattingOptions $oOptions[, string $column = null ]) : string
All transforms should be processed during the execution of this function!
The final step in the transform is to apply a stripTagsFull on the $value. This occurs for ALL values whether or not any other transform is applied.
Parameters
- $value : string
- $fieldType : string
- $oOptions : FormattingOptions
- $column : string = null
-
The name of the column
Return values
stringtranslate()
protected
translate(mixed $key, mixed $sLanguageCode) : mixed
Parameters
- $key : mixed
- $sLanguageCode : mixed