LSYii_Application
extends CWebApplication
in package
Uses
LSApplicationTrait
Implements global config
Table of Contents
Properties
- $baseUrl : string
- $bootstrap : TbApi
- $clientScript : CClientScript
- $db : CDbConnection
- $language : string
- $log : CLogRouter
- $pluginManager : PluginManager
- $request : CHttpRequest
- $session : CHttpSession
- $twigRenderer : LSETwigViewRenderer
- $user : CWebUser
- $api : LimesurveyApi
- $config : mixed
- $dbVersion : int|null
- The DB version, used to check if setup is all OK
- $plugin : iPlugin
- If a plugin action is accessed through the PluginHelper, store it here.
- $currentUserId : mixed
Methods
- __construct() : mixed
- Initiates the application
- beforeControllerAction() : bool
- The pre-filter for controller actions.
- createController() : mixed
- createPublicUrl() : string
- Creates an absolute URL based on the given controller and action information.
- getApi() : mixed
- Get the Api object.
- getAvailableConfigs() : array<string|int, mixed>
- Returns the array of available configurations
- getConfig() : string
- Returns a config variable from the config
- getCurrentUserId() : int|null
- get the current id of connected user, check if user exist before return for security
- getPlugin() : object
- Return plugin, if any
- getPluginManager() : PluginManager
- Get the pluginManager
- getPublicBaseUrl() : string
- Returns the relative URL for the application while considering if a "publicurl" config parameter is set to a valid url
- getTwigCustomExtensionsConfig() : mixed
- Look for user custom twig extension in upload directory, and add load their manifest in Twig Application and its sandbox TODO: database uploader + admin interface grid view instead of XML parsing.
- init() : mixed
- initLanguage() : mixed
- is_file() : bool
- Check if a file (with a full path) is inside a specific directory
- loadConfig() : void
- Loads a config from a file
- loadHelper() : void
- Loads a helper
- loadLibrary() : void
- Loads a library
- onError() : void
- onException() : void
- setConfig() : void
- Sets a configuration variable into the config
- setConfigs() : void
- Set the LimeSUrvey config array according to files and DB
- setFlashMessage() : LSYii_Application
- Set a 'flash message'.
- setLanguage() : void
- For future use, cache the language app wise as well.
- setPlugin() : void
- Used by PluginHelper to make the controlling plugin available from everywhere, e.g. from the plugin's models.
- createControllerFromShortUrl() : array<string|int, mixed>|null
- Create controller from short url if the route matches a survey alias.
- setSessionByDB() : void
- Set the session after start, Limited to DbHttpSession
Properties
$baseUrl
public
string
$baseUrl
The relative URL for the application.
$bootstrap
public
TbApi
$bootstrap
The bootstrap renderer
$clientScript
public
CClientScript
$clientScript
CClientScript manages JavaScript and CSS stylesheets for views.
$db
public
CDbConnection
$db
The database connection.
$language
public
string
$language
Returns the language that the user is using and the application should be targeted to.
$log
public
CLogRouter
$log
Log router component.
$pluginManager
public
PluginManager
$pluginManager
The LimeSurvey Plugin manager
$request
public
CHttpRequest
$request
The request component.
$session
public
CHttpSession
$session
The HTTP session
$twigRenderer
public
LSETwigViewRenderer
$twigRenderer
Twig rendering plugin
$user
public
CWebUser
$user
The user session information.
$api
protected
LimesurveyApi
$api
$config
protected
mixed
$config
= array()
$dbVersion
The DB version, used to check if setup is all OK
protected
int|null
$dbVersion
$plugin
If a plugin action is accessed through the PluginHelper, store it here.
protected
iPlugin
$plugin
$currentUserId
private
mixed
$currentUserId
Methods
__construct()
Initiates the application
public
__construct([array<string|int, mixed> $aApplicationConfig = null ]) : mixed
Parameters
- $aApplicationConfig : array<string|int, mixed> = null
Tags
beforeControllerAction()
The pre-filter for controller actions.
public
beforeControllerAction(CController $controller, CAction $action) : bool
This method is invoked before the currently requested controller action and all its filters are executed. You may override this method with logic that needs to be done before all controller actions.
Parameters
- $controller : CController
-
the controller
- $action : CAction
-
the action
Return values
bool —whether the action should be executed.
createController()
public
createController(mixed $route[, mixed $owner = null ]) : mixed
Parameters
- $route : mixed
- $owner : mixed = null
Tags
createPublicUrl()
Creates an absolute URL based on the given controller and action information.
public
createPublicUrl(string $route[, array<string|int, mixed> $params = array() ][, string $schema = '' ][, string $ampersand = '&' ]) : string
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
getApi()
Get the Api object.
public
getApi() : mixed
getAvailableConfigs()
Returns the array of available configurations
public
getAvailableConfigs() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getConfig()
Returns a config variable from the config
public
getConfig(string $name[, bool|mixed $default = false ]) : string
Parameters
- $name : string
- $default : bool|mixed = false
-
Value to return when not found, default is false
Tags
Return values
stringgetCurrentUserId()
get the current id of connected user, check if user exist before return for security
public
getCurrentUserId() : int|null
Return values
int|null —user id, 0 mean invalid user
getPlugin()
Return plugin, if any
public
getPlugin() : object
Return values
objectgetPluginManager()
Get the pluginManager
public
getPluginManager() : PluginManager
Return values
PluginManagergetPublicBaseUrl()
Returns the relative URL for the application while considering if a "publicurl" config parameter is set to a valid url
public
getPublicBaseUrl([bool $absolute = false ]) : string
Parameters
- $absolute : bool = false
-
whether to return an absolute URL. Defaults to false, meaning returning a relative one.
Return values
string —the relative or the configured public URL for the application
getTwigCustomExtensionsConfig()
Look for user custom twig extension in upload directory, and add load their manifest in Twig Application and its sandbox TODO: database uploader + admin interface grid view instead of XML parsing.
public
getTwigCustomExtensionsConfig(mixed $sUsertwigextensionrootdir, mixed $aApplicationConfig) : mixed
Parameters
- $sUsertwigextensionrootdir : mixed
- $aApplicationConfig : mixed
init()
public
init() : mixed
initLanguage()
public
initLanguage() : mixed
is_file()
Check if a file (with a full path) is inside a specific directory
public
is_file(mixed $filePath[, mixed $baseDir = null ][, mixed $throwException = null ]) : bool
Parameters
- $filePath : mixed
- $baseDir : mixed = null
- $throwException : mixed = null
Return values
boolloadConfig()
Loads a config from a file
public
loadConfig(string $file) : void
Parameters
- $file : string
Tags
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
-
Libraby name
Tags
onError()
public
onError(CErrorEvent $event) : void
Parameters
- $event : CErrorEvent
Tags
onException()
public
onException(CExceptionEvent $event) : void
Parameters
- $event : CExceptionEvent
Tags
setConfig()
Sets a configuration variable into the config
public
setConfig(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
Tags
setConfigs()
Set the LimeSUrvey config array according to files and DB
public
setConfigs() : void
setFlashMessage()
Set a 'flash message'.
public
setFlashMessage(string $message[, string $type = 'success' ]) : LSYii_Application
A flahs message will be shown on the next request and can contain a message
to tell that the action was successful or not. The message is displayed and
cleared when it is shown in the view using the widget:
$this->widget('application.extensions.FlashMessage.FlashMessage');
Parameters
- $message : string
-
The message you want to show on next page load
- $type : string = 'success'
-
Type can be 'success','info','warning','danger','error' which relate to the particular bootstrap alert classes - see http://getbootstrap.com/components/#alerts . Note: Option 'error' is synonymous to 'danger'
Return values
LSYii_Application —Provides a fluent interface
setLanguage()
For future use, cache the language app wise as well.
public
setLanguage(string $sLanguage) : void
Parameters
- $sLanguage : string
Tags
setPlugin()
Used by PluginHelper to make the controlling plugin available from everywhere, e.g. from the plugin's models.
public
setPlugin( $plugin) : void
Corresponds to Yii::app()->getController()
Parameters
createControllerFromShortUrl()
Create controller from short url if the route matches a survey alias.
private
createControllerFromShortUrl(string $route) : array<string|int, mixed>|null
Parameters
- $route : string
-
the route of the request.
Return values
array<string|int, mixed>|nullsetSessionByDB()
Set the session after start, Limited to DbHttpSession
private
setSessionByDB(mixed $aApplicationConfig) : void
Parameters
- $aApplicationConfig : mixed