ConditionsAction
extends SurveyCommonAction
in package
Condition Controller
This controller performs token actions
Tags
Table of Contents
Properties
- $iSurveyID : int
- $language : string
- $nonStringComparisonOperators : array<string|int, mixed>
- $stringComparisonOperators : array<string|int, mixed>
- $surveyCondition : mixed
- $tokenFieldsAndNames : array<string|int, mixed>
- $tokenTableExists : bool
- True if there exists a survey participant list for this survey
Methods
- __construct() : mixed
- Init some stuff
- addScript() : void
- Adds a script to the view so the service can be agnostic to paths and scripts
- createNavigatorUrl() : string
- getCopyForm() : string
- getCreateMenu() : Menu
- REFACTORED in LayoutHelper (necessary to have it here, until all controllers have been refactored...)
- getEditConditionForm() : string
- Get html for add/edit condition form
- getJavascriptForMatching() : string
- Javascript to match question with answer
- index() : void
- index() : void
- Main Entry Method.
- myCreateUrl() : string
- Maps $pathKey with $path
- quickAddCondition() : void
- Used by quick-add form to add conditions async
- renderInternal() : mixed
- renderPartialView() : string
- Maps keywords with paths so we can ensure that the service is agnostic to where the paths are which gives us flexibility
- run() : mixed
- Action classes require them to have a run method. We reroute it to index if called.
- runWithParams() : bool
- Override runWithParams() implementation in CAction to help us parse requests with subactions.
- applySubaction() : void
- Switch on action to update/copy/add condition etc
- beforeSideMenuRender() : string
- Returns content from event beforeSideMenuRender
- copyConditions() : void
- fetchExtraMenus() : array<string|int, ExtraMenu>
- Get extra menus from plugins that are using event beforeAdminMenuRender
- getConditionText() : void
- Gets the condition text based on a qid
- getEDITConditionConst() : string
- getEDITConditionRegexp() : string
- getEditFormJavascript() : string
- Generates some JS used by form
- getEditSourceTab() : string
- getEditTargetTab() : string
- getJsAnswersToSelect() : string
- getMethod() : array<string|int, mixed>
- This array will be used to explain which conditions is used to evaluate the question
- getQuickAddData() : array<string|int, mixed>
- Get posted data from quick-add modal form
- getSurveyIsAnonymized() : bool
- insertCondition() : void
- Add a new condition
- insertConditionAjax() : array<string|int, mixed>
- As insertCondition() but using Ajax, called from quickAddCondition
- listquestiongroups() : mixed
- REFACTORED in LayoutHelper
- listquestions() : mixed
- REFACTORED in LayoutHelper
- notifications() : mixed
- Display notifications
- nsurveysummary() : mixed
- REFACTORED in LayoutHelper
- organizequestionbar() : mixed
- Render the save/cancel bar for Organize question groups/questions
- redirectToConditionStart() : void
- After add/delete/etc, redirect to conditions start page
- renderCentralContents() : string
- Rendering the subviews and views of renderWrappedTemplate
- renderJSON() : void
- Method to render an array as a json document
- renderQuickmenu() : string
- Render the quick-menu that is shown when side-menu is hidden.
- renderWrappedTemplate() : void
- Renders template(s) wrapped in header and footer
- renumberScenarios() : void
- requirePostRequest() : mixed
- Validates that the request method is POST.
- resetSurveyLogic() : void
- route() : mixed
- Routes the action into correct subaction
- shouldShowScenario() : bool
- Decides if "Default scenario" should be shown or not
- showadminmenu() : string
- showadminmenu() function returns html text for the administration button bar
- showHeaders() : mixed
- Header
- titlebar() : mixed
- REFACTORED in LayoutHelper.php
- updateCondition() : void
- Update a condition
- updatenotification() : string|void
- Display the update notification
- addPseudoParams() : array<string|int, mixed>
- Some functions have different parameters, which are just an alias of the usual parameters we're getting in the url. This function just populates those variables so that we don't end up in an error.
Properties
$iSurveyID
private
int
$iSurveyID
$language
private
string
$language
$nonStringComparisonOperators
private
array<string|int, mixed>
$nonStringComparisonOperators
$stringComparisonOperators
private
array<string|int, mixed>
$stringComparisonOperators
$surveyCondition
private
mixed
$surveyCondition
$tokenFieldsAndNames
private
array<string|int, mixed>
$tokenFieldsAndNames
$tokenTableExists
True if there exists a survey participant list for this survey
private
bool
$tokenTableExists
Methods
__construct()
Init some stuff
public
__construct([null $controller = null ][, null $id = null ]) : mixed
Parameters
- $controller : null = null
- $id : null = null
addScript()
Adds a script to the view so the service can be agnostic to paths and scripts
public
addScript(string $key, string $which, int $how) : void
Parameters
- $key : string
-
the config
- $which : string
-
the filename
- $how : int
-
the way
createNavigatorUrl()
public
createNavigatorUrl(int $gid, int $qid) : string
Parameters
- $gid : int
-
Group id
- $qid : int
-
Questino id
Return values
string —url
getCopyForm()
public
getCopyForm(int $qid, int $gid, array<string|int, mixed> $conditionsList, array<string|int, mixed> $pquestions) : string
Parameters
- $qid : int
- $gid : int
- $conditionsList : array<string|int, mixed>
- $pquestions : array<string|int, mixed>
Tags
Return values
string —html
getCreateMenu()
REFACTORED in LayoutHelper (necessary to have it here, until all controllers have been refactored...)
public
getCreateMenu() : Menu
Returns extra menu for the new create process (including create, copy, and import survey).
Return values
MenugetEditConditionForm()
Get html for add/edit condition form
public
getEditConditionForm(array<string|int, mixed> $args) : string
Parameters
- $args : array<string|int, mixed>
Tags
Return values
stringgetJavascriptForMatching()
Javascript to match question with answer
public
getJavascriptForMatching(array<string|int, mixed> $canswers, array<string|int, mixed> $cquestions, bool $surveyIsAnonymized) : string
Parameters
- $canswers : array<string|int, mixed>
- $cquestions : array<string|int, mixed>
- $surveyIsAnonymized : bool
Return values
string —js
index()
public
index() : void
index()
Main Entry Method.
public
index(string $subaction[, int $iSurveyID = null ][, int $gid = null ][, int $qid = null ]) : void
Parameters
- $subaction : string
-
Given Subaction
- $iSurveyID : int = null
-
Given Survey ID
- $gid : int = null
-
Given Group ID
- $qid : int = null
-
Given Question ID
Tags
myCreateUrl()
Maps $pathKey with $path
public
myCreateUrl(string $pathKey[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $pathKey : string
-
the keyword of the path
- $params : array<string|int, mixed> = []
-
an array to be passed to createUrl
Return values
stringquickAddCondition()
Used by quick-add form to add conditions async
public
quickAddCondition() : void
Tags
renderInternal()
public
renderInternal(string $_viewFile_[, mixed $_data_ = null ][, mixed $_return_ = false ]) : mixed
Parameters
- $_viewFile_ : string
- $_data_ : mixed = null
- $_return_ : mixed = false
Tags
renderPartialView()
Maps keywords with paths so we can ensure that the service is agnostic to where the paths are which gives us flexibility
public
renderPartialView(string $what[, array<string|int, mixed>|null $data = null ][, bool $return = false ][, bool $processOutput = false ]) : string
Parameters
- $what : string
-
the keyname of the view to be rendered
- $data : array<string|int, mixed>|null = null
-
data array to be passed to the renderPartial method
- $return : bool = false
-
return to be passed to the renderPartial method
- $processOutput : bool = false
-
processOutput to be passed to the renderPartial method
Return values
stringrun()
Action classes require them to have a run method. We reroute it to index if called.
public
run() : mixed
runWithParams()
Override runWithParams() implementation in CAction to help us parse requests with subactions.
public
runWithParams(array<string|int, mixed> $params) : bool
Parameters
- $params : array<string|int, mixed>
-
URL Parameters
Return values
boolapplySubaction()
Switch on action to update/copy/add condition etc
protected
applySubaction(string $p_subaction, array<string|int, mixed> $args) : void
Parameters
- $p_subaction : string
- $args : array<string|int, mixed>
beforeSideMenuRender()
Returns content from event beforeSideMenuRender
protected
beforeSideMenuRender(array<string|int, mixed> $aData) : string
REFACTORED in LayoutHelper
Parameters
- $aData : array<string|int, mixed>
Return values
stringcopyConditions()
protected
copyConditions(array<string|int, mixed> $args) : void
Parameters
- $args : array<string|int, mixed>
Tags
fetchExtraMenus()
Get extra menus from plugins that are using event beforeAdminMenuRender
protected
fetchExtraMenus(array<string|int, mixed> $aData) : array<string|int, ExtraMenu>
Parameters
- $aData : array<string|int, mixed>
Return values
array<string|int, ExtraMenu>getConditionText()
Gets the condition text based on a qid
protected
getConditionText(int $qid) : void
Parameters
- $qid : int
-
the id of the question
getEDITConditionConst()
protected
getEDITConditionConst(string $subaction) : string
Parameters
- $subaction : string
Return values
stringgetEDITConditionRegexp()
protected
getEDITConditionRegexp(string $subaction) : string
Parameters
- $subaction : string
Return values
stringgetEditFormJavascript()
Generates some JS used by form
protected
getEditFormJavascript(string $subaction) : string
Parameters
- $subaction : string
Return values
string —JS
getEditSourceTab()
protected
getEditSourceTab() : string
Return values
string —Either '#SRCTOKENATTRS' or '#SRCPREVQUEST'; defaults to '#SRCPREVQUEST' if nothing is posted
getEditTargetTab()
protected
getEditTargetTab() : string
Return values
string —Predfined, constant, questions, token field or regexp; defaults to predefined
getJsAnswersToSelect()
protected
getJsAnswersToSelect(array<string|int, mixed> $cquestions, string $p_cquestions, array<string|int, mixed> $p_canswers) : string
Parameters
- $cquestions : array<string|int, mixed>
- $p_cquestions : string
-
Question SGID
- $p_canswers : array<string|int, mixed>
-
E.g. array('A2')
Return values
string —JS code
getMethod()
This array will be used to explain which conditions is used to evaluate the question
protected
getMethod() : array<string|int, mixed>
Return values
array<string|int, mixed>getQuickAddData()
Get posted data from quick-add modal form
protected
getQuickAddData(LSHttpRequest $request) : array<string|int, mixed>
Parameters
- $request : LSHttpRequest
Return values
array<string|int, mixed>getSurveyIsAnonymized()
protected
getSurveyIsAnonymized() : bool
Return values
bool —True if anonymized == 'Y' for this survey
insertCondition()
Add a new condition
protected
insertCondition(array<string|int, mixed> $args) : void
Parameters
- $args : array<string|int, mixed>
Tags
insertConditionAjax()
As insertCondition() but using Ajax, called from quickAddCondition
protected
insertConditionAjax(mixed $args) : array<string|int, mixed>
Parameters
- $args : mixed
Tags
Return values
array<string|int, mixed> —[message, result], where result = 'success' or 'error'
listquestiongroups()
REFACTORED in LayoutHelper
protected
listquestiongroups(array<string|int, mixed> $aData) : mixed
listquestion groups
Parameters
- $aData : array<string|int, mixed>
listquestions()
REFACTORED in LayoutHelper
protected
listquestions( $aData) : mixed
Parameters
Tags
notifications()
Display notifications
protected
notifications() : mixed
- REFACTORED (in LayoutHelper.php)
nsurveysummary()
REFACTORED in LayoutHelper
protected
nsurveysummary(array<string|int, mixed> $aData) : mixed
Survey summary
Parameters
- $aData : array<string|int, mixed>
organizequestionbar()
Render the save/cancel bar for Organize question groups/questions
protected
organizequestionbar(array<string|int, mixed> $aData) : mixed
REFACTORED in LayoutHelper
Parameters
- $aData : array<string|int, mixed>
Tags
redirectToConditionStart()
After add/delete/etc, redirect to conditions start page
protected
redirectToConditionStart(int $qid, int $gid) : void
Parameters
- $qid : int
- $gid : int
renderCentralContents()
Rendering the subviews and views of renderWrappedTemplate
protected
renderCentralContents(string $sAction, array<string|int, mixed>|string $aViewUrls[, array<string|int, mixed> $aData = [] ]) : string
Parameters
- $sAction : string
- $aViewUrls : array<string|int, mixed>|string
- $aData : array<string|int, mixed> = []
Return values
stringrenderJSON()
Method to render an array as a json document
protected
renderJSON(array<string|int, mixed> $aData[, mixed $success = true ]) : void
REFACTORED in LSBaseController (this one called by a lot of actions in different controllers)
Parameters
- $aData : array<string|int, mixed>
- $success : mixed = true
renderQuickmenu()
Render the quick-menu that is shown when side-menu is hidden.
protected
renderQuickmenu(array<string|int, mixed> $aData) : string
REFACTORED in LayoutHelper
Only show home-icon for now.
Add support for plugin to attach icon elements using event afterQuickMenuLoad
Parameters
- $aData : array<string|int, mixed>
Tags
Return values
stringrenderWrappedTemplate()
Renders template(s) wrapped in header and footer
protected
renderWrappedTemplate([string $sAction = 'conditions' ][, string|array<string|int, mixed> $aViewUrls = array() ][, array<string|int, mixed> $aData = array() ][, bool $sRenderFile = false ]) : void
Parameters
- $sAction : string = 'conditions'
-
Current action, the folder to fetch views from
- $aViewUrls : string|array<string|int, mixed> = array()
-
View url(s)
- $aData : array<string|int, mixed> = array()
-
Data to be passed on. Optional.
- $sRenderFile : bool = false
Tags
renumberScenarios()
protected
renumberScenarios(int $qid) : void
Parameters
- $qid : int
-
the id of the question
Tags
requirePostRequest()
Validates that the request method is POST.
protected
requirePostRequest() : mixed
This is intended to be used on subactions. When possible (eg. when refactoring a SurveyCommonAction into an actual controller), use 'postOnly' filter instead.
Tags
resetSurveyLogic()
protected
resetSurveyLogic( $iSurveyID) : void
Parameters
Tags
route()
Routes the action into correct subaction
protected
route(string $sa, array<string|int, string> $get_vars) : mixed
Parameters
- $sa : string
- $get_vars : array<string|int, string>
Tags
shouldShowScenario()
Decides if "Default scenario" should be shown or not
protected
shouldShowScenario(string $subaction, int $scenariocount) : bool
Parameters
- $subaction : string
- $scenariocount : int
Return values
boolshowadminmenu()
showadminmenu() function returns html text for the administration button bar
protected
showadminmenu( $aData) : string
REFACTORED (in LayoutHelper.php)
Parameters
Tags
Return values
stringshowHeaders()
Header
protected
showHeaders(array<string|int, mixed> $aData[, mixed $sendHTTPHeader = true ]) : mixed
- REFACTORED (in LayoutHelper.php)
Parameters
- $aData : array<string|int, mixed>
- $sendHTTPHeader : mixed = true
titlebar()
REFACTORED in LayoutHelper.php
protected
titlebar( $aData) : mixed
Parameters
Tags
updateCondition()
Update a condition
protected
updateCondition(array<string|int, mixed> $args) : void
Parameters
- $args : array<string|int, mixed>
updatenotification()
Display the update notification
protected
updatenotification() : string|void
REFACTORED (in LayoutHelper.php)
Passes security_update_available and stability_labels to the notification view.
Tags
Return values
string|void —Rendered notification HTML, or void if no update
addPseudoParams()
Some functions have different parameters, which are just an alias of the usual parameters we're getting in the url. This function just populates those variables so that we don't end up in an error.
private
addPseudoParams(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
Parameters to parse and populate
Tags
Return values
array<string|int, mixed> —Populated parameters