LimeReplacementFieldsController
extends LSBaseController
in package
Class LSBaseController
this controller will have all the necessary methods from the old AdminController
Table of Contents
Properties
- $aData : array<string|int, mixed>
- $navData : array<string|int, mixed>
- This array contains the survey / group / question id used by the menu widget.
- $sTemplate : null
- $userId : int
Methods
- __construct() : mixed
- Basic initialiser to the base controller class
- actionIndex() : false|string|array<string|int, string>|null
- action used to provide the html editor with data for the placeholder fields modal
- createAbsoluteUrl() : string
- Returns an absolute URL based on the given controller and action information.
- getNewTypeResponse() : array<string|int, mixed>
- Returns an multidimensional array containing the replacement fields for the given fieldtype.
- loadHelper() : void
- Loads a helper
- loadLibrary() : void
- Loads a library
- run() : void
- Checks for action specific authorization and then executes an action
- _checkInstallation() : void
- Check that installation was already done by looking for config.php Will redirect to the installer script if not exists.
- beforeRender() : bool
- This part comes from renderWrappedTemplate (not the best way to refactoring, but a temporary solution)
- customInit() : mixed
- loadPageStates() : array<string|int, mixed>
- Loads page states from a hidden input.
- renderJSON() : void
- Method to render an array as a json document (this one called by a lot of actions in different controllers)
- sessionControl() : void
- Load and set session vars
- addQuestionToList() : bool
- Updates the question list with info on previouspage (isPreviousPageQuestion).
- collectQuestionReplacements() : array<string|int, mixed>
- Should return previous questions as a multidimensional array.
- getChildQuestions() : array<string|int, mixed>
- Returns array with relevant question data especially for limeReplacementFields view to populate the replacement field list in the html editor
- getQuestionList() : array<string|int, mixed>
- Returns array of relevant questions based on the given fieldmap
- getReplacementCodeByArray() : string
- Analyzes the question parameters and returns the replacement code for html editor "Placeholder fields" simple questions: QUESTIONCODE.shown subquestions: QUESTIONCODE_SUBQCODE.shown other option: QUESTIONCODE_other (.shown is not working in that case) question types using scale_id: QUESTIONCODE_SUBQCODE_SCALEID.shown
- getReplacementFields() : array<string|int, mixed>
- Collect the general replacements
- shouldAddQuestion() : bool|void
- Returns true if the question should be added to the list or false if it should not depending on the passed parameters
Properties
$aData
public
array<string|int, mixed>
$aData
= []
import for all new controllers/actions (REFACTORING) to pass data before rendering the content
$navData
This array contains the survey / group / question id used by the menu widget.
public
array<string|int, mixed>
$navData
= array()
$sTemplate
public
null
$sTemplate
= \null
this is needed for the preview rendering inside the questioneditor
$userId
protected
int
$userId
= 0
userId of the logged in user
Methods
__construct()
Basic initialiser to the base controller class
public
__construct(string $id[, CWebModule $module = null ]) : mixed
Parameters
- $id : string
- $module : CWebModule = null
Tags
actionIndex()
action used to provide the html editor with data for the placeholder fields modal
public
actionIndex() : false|string|array<string|int, string>|null
Tags
Return values
false|string|array<string|int, string>|nullcreateAbsoluteUrl()
Returns an absolute URL based on the given controller and action information.
public
createAbsoluteUrl(string $route[, array<string|int, mixed> $params = array() ][, string $schema = '' ][, string $ampersand = '&' ]) : string
The functionality was moved to \LSYii_Application::createPublicUrl, to be safe the function remains here.
Parameters
- $route : string
-
the URL route. This should be in the format of 'ControllerID/ActionID'.
- $params : array<string|int, mixed> = array()
-
additional GET parameters (name=>value). Both the name and value will be URL-encoded.
- $schema : string = ''
-
schema to use (e.g. http, https). If empty, the schema used for the current request will be used.
- $ampersand : string = '&'
-
the token separating name-value pairs in the URL.
Return values
string —the constructed URL
getNewTypeResponse()
Returns an multidimensional array containing the replacement fields for the given fieldtype.
public
getNewTypeResponse(mixed $fieldtype[, int $surveyid = null ][, int $gid = null ][, int $qid = null ]) : array<string|int, mixed>
Probably never used.
Parameters
- $fieldtype : mixed
- $surveyid : int = null
- $gid : int = null
- $qid : int = null
Return values
array<string|int, mixed>loadHelper()
Loads a helper
public
loadHelper(string $helper) : void
Parameters
- $helper : string
Tags
loadLibrary()
Loads a library
public
loadLibrary(string $library) : void
Parameters
- $library : string
Tags
run()
Checks for action specific authorization and then executes an action
public
run(string $action) : void
TODO: check the dbupdate mechanism, do we really want to check db update before every action??
Parameters
- $action : string
Tags
_checkInstallation()
Check that installation was already done by looking for config.php Will redirect to the installer script if not exists.
protected
_checkInstallation() : void
Tags
beforeRender()
This part comes from renderWrappedTemplate (not the best way to refactoring, but a temporary solution)
protected
beforeRender(string $view) : bool
todo REFACTORING find all actions that set $aData['surveyid'] and change the layout directly in the action
Parameters
- $view : string
Return values
boolcustomInit()
protected
customInit() : mixed
loadPageStates()
Loads page states from a hidden input.
protected
loadPageStates() : array<string|int, mixed>
Return values
array<string|int, mixed> —the loaded page states
renderJSON()
Method to render an array as a json document (this one called by a lot of actions in different controllers)
protected
renderJSON(array<string|int, mixed> $aData[, mixed $success = true ]) : void
Parameters
- $aData : array<string|int, mixed>
- $success : mixed = true
sessionControl()
Load and set session vars
protected
sessionControl() : void
todo REFACTORING see comments in method
Tags
addQuestionToList()
Updates the question list with info on previouspage (isPreviousPageQuestion).
private
addQuestionToList(mixed $action, int $gid, array<string|int, mixed> $field, mixed $questionType, string $surveyformat, bool $isPreviousPageQuestion, array<string|int, mixed> &$questionList) : bool
Returns the value of $isPreviousPageQuestion
Parameters
- $action : mixed
- $gid : int
- $field : array<string|int, mixed>
- $questionType : mixed
- $surveyformat : string
- $isPreviousPageQuestion : bool
- $questionList : array<string|int, mixed>
Return values
boolcollectQuestionReplacements()
Should return previous questions as a multidimensional array.
private
collectQuestionReplacements( $surveyid[, int $gid = null ][, int $qid = null ]) : array<string|int, mixed>
[ QUESTIONCODE_SUBQUESTIONCODE = [ "type" => 'question', "value" => 'Question text' ], QUESTIONCODE = [ "type" => 'question', "value" => 'Question text' ], ]
Most likely not used anymore. The building of the criteria has a logical error when qid is passed. if group id is passed but no question id: -> we get all (parent) questions of the group and of the groups before. if question id is passed -> we get all questions of the group and of the groups before but only those with a sortorder below the ordernumber of the current question. (This is the error)
Parameters
Return values
array<string|int, mixed>getChildQuestions()
Returns array with relevant question data especially for limeReplacementFields view to populate the replacement field list in the html editor
private
getChildQuestions(array<string|int, mixed> $questions) : array<string|int, mixed>
Parameters
- $questions : array<string|int, mixed>
Return values
array<string|int, mixed>getQuestionList()
Returns array of relevant questions based on the given fieldmap
private
getQuestionList(mixed $action, int $gid, int $qid, array<string|int, mixed> $fieldmap, mixed $questionType, string $surveyformat) : array<string|int, mixed>
Parameters
- $action : mixed
- $gid : int
- $qid : int
- $fieldmap : array<string|int, mixed>
- $questionType : mixed
- $surveyformat : string
Return values
array<string|int, mixed>getReplacementCodeByArray()
Analyzes the question parameters and returns the replacement code for html editor "Placeholder fields" simple questions: QUESTIONCODE.shown subquestions: QUESTIONCODE_SUBQCODE.shown other option: QUESTIONCODE_other (.shown is not working in that case) question types using scale_id: QUESTIONCODE_SUBQCODE_SCALEID.shown
private
getReplacementCodeByArray(array<string|int, mixed> $question) : string
Parameters
- $question : array<string|int, mixed>
Return values
stringgetReplacementFields()
Collect the general replacements
private
getReplacementFields(string $fieldtype, int $surveyid) : array<string|int, mixed>
Parameters
- $fieldtype : string
-
The field to collect replacements for
- $surveyid : int
-
The transferred surveyid
Return values
array<string|int, mixed>shouldAddQuestion()
Returns true if the question should be added to the list or false if it should not depending on the passed parameters
private
shouldAddQuestion(mixed $action, int $gid, int $qid, array<string|int, mixed> $question, mixed $previousQuestion) : bool|void
Parameters
- $action : mixed
- $gid : int
- $qid : int
- $question : array<string|int, mixed>
- $previousQuestion : mixed