LimeSurvey API - Master branch

RDataWriter extends CsvWriter
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

$fieldmap  : mixed
$filename  : mixed
$languageCode  : mixed
$na  : string
The value to use when no data is present (for example unanswered because of relevance)
$webfilename  : mixed
$csvFilename  : string
The filename to use for the resulting file when output = display
$doHeaders  : bool
Should headers be output? For example spss and r export use more or less the same output but do not need headers at all.
$sLanguageCode  : mixed
$translator  : Translator
$file  : mixed
The open filehandle
$hasOutputHeader  : mixed
$output  : mixed
$separator  : 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.
csvEscape()  : string
Returns the value with all necessary escaping needed to place it into a CSV string.
outputRecord()  : mixed
This method will be called once for every row of data that needs to be output.
stripTagsFull()  : mixed
transformResponseValue()  : mixed
Perform response transformation, for example F/M for female/male will be mapped to 1/2 values
translate()  : mixed

Properties

$filename

public mixed $filename

$languageCode

public mixed $languageCode

$na

The value to use when no data is present (for example unanswered because of relevance)

public string $na = ''

$webfilename

public mixed $webfilename

$csvFilename

The filename to use for the resulting file when output = display

protected string $csvFilename = ''

$doHeaders

Should headers be output? For example spss and r export use more or less the same output but do not need headers at all.

protected bool $doHeaders = \true

$sLanguageCode

protected mixed $sLanguageCode

$file

The open filehandle

private mixed $file = \null

$hasOutputHeader

private mixed $hasOutputHeader

Methods

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
string

getFullFieldSubHeading()

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
string

getFullHeading()

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
deprecated
Return values
string

getFullQuestionHeading()

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
string

getLongAnswer()

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
string

getShortAnswer()

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
string

init()

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

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

csvEscape()

Returns the value with all necessary escaping needed to place it into a CSV string.

protected csvEscape(string|null $value) : string
Parameters
$value : string|null
Return values
string

outputRecord()

This method will be called once for every row of data that needs to be output.

protected abstract outputRecord(array<string|int, mixed> $headers, array<string|int, 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 : array<string|int, mixed>
$values : array<string|int, mixed>
$oOptions : FormattingOptions

stripTagsFull()

protected stripTagsFull(string $string) : mixed
Parameters
$string : string

transformResponseValue()

Perform response transformation, for example F/M for female/male will be mapped to 1/2 values

protected transformResponseValue(string $value, string $fieldType, FormattingOptions $oOptions[, string $column = null ]) : mixed
Parameters
$value : string
$fieldType : string
$oOptions : FormattingOptions
$column : string = null

translate()

protected translate(mixed $key, mixed $sLanguageCode) : mixed
Parameters
$key : mixed
$sLanguageCode : mixed

        
On this page

Search results