QuickTranslationController
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
- actionAjaxtranslategoogleapi() : void
- actionIndex() : void
- createAbsoluteUrl() : string
- Returns an absolute URL based on the given controller and action information.
- 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
- Here we have to use the correct layout (NOT main.php)
- customInit() : mixed
- loadEditor() : mixed
- It loads the correct editor mode (inline, popup, modal).
- 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
- calcNRows() : float
- calcNRows($subject) calculates the vertical size of textbox for survey translation.
- cleanup() : string|null
- displayUntranslatedFields() : array<string|int, mixed>
- Collecting database data and ckeditor data for the views.
- translateGoogleApi() : mixed
- translateGoogleApi.php Creates a JSON interface for the auto-translate feature
- translateSave() : void
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
actionAjaxtranslategoogleapi()
public
actionAjaxtranslategoogleapi(mixed $surveyid) : void
Parameters
- $surveyid : mixed
actionIndex()
public
actionIndex( $surveyid) : void
Parameters
Tags
createAbsoluteUrl()
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 functionalty 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
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()
Here we have to use the correct layout (NOT main.php)
protected
beforeRender(string $view) : bool
Parameters
- $view : string
Return values
boolcustomInit()
protected
customInit() : mixed
loadEditor()
It loads the correct editor mode (inline, popup, modal).
protected
loadEditor( $htmleditor, array<string|int, string> $aData) : mixed
This is used in the view file translateFieldData.
Parameters
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 mehtod
Tags
calcNRows()
calcNRows($subject) calculates the vertical size of textbox for survey translation.
private
calcNRows(string $subject) : float
The function adds the number of line breaks
to the number of times a string wrap occurs.
Parameters
- $subject : string
-
The text string that is being translated
Return values
floatcleanup()
private
cleanup(string $string) : string|null
Parameters
- $string : string
Return values
string|nulldisplayUntranslatedFields()
Collecting database data and ckeditor data for the views.
private
displayUntranslatedFields( $quickTranslation, $tolang, $baselang, $baselangdesc, $tolangdesc) : array<string|int, mixed>
Parameters
- $quickTranslation :
-
\LimeSurvey\Models\Services\QuickTranslation the quick translation object
- $tolang :
-
string language to translate to
- $baselang :
-
string the base language
- $baselangdesc :
-
string the base language description
- $tolangdesc :
-
string the language to translate description
Tags
Return values
array<string|int, mixed>translateGoogleApi()
translateGoogleApi.php Creates a JSON interface for the auto-translate feature
private
translateGoogleApi() : mixed
Tags
translateSave()
private
translateSave( $tolang, $quickTranslation) : void