PluginBase

Extends\LimeSurvey\PluginManager\PluginBase

NB: Deleting this class will break plugin API, since plugins then would have to extend PluginBase in the namespace instead of this class. This is especially a problem for plugins that should work on both 2.73 and 3.x, so please don't delete this class.

package

Default

Methods

Constructor for the plugin

__construct(\LimeSurvey\PluginManager\PluginManager $manager,integer $id)
todo

Add proper type hint in 3.0

Arguments

$manager

\LimeSurvey\PluginManager\PluginManager

The plugin manager instantiating the object

$id

integer

The id for storage

Check if config field active is 1. If yes, activate the plugin.

checkActive(\Plugin $pluginModel): void

This is the 'active-by-default' feature.

Arguments

$pluginModel

\Plugin

Returns true if config file has a higher version than database.

configIsNewVersion(): boolean

Assumes $this->config is set.

Response

boolean

This function retrieves plugin data. Do not cache this data; the plugin storage engine will handling caching. After the first call to this function, subsequent calls will only consist of a few function calls and array lookups.

get(string $key = null,string $model = null,integer $id = null,mixed $default = null): boolean

Arguments

$key

string

$model

string

$id

integer

$default

mixed

The default value to use when not was set

Response

boolean

Return the description for this plugin

getDescription()
static

To find the plugin locale file, we need late runtime result of __DIR__.

getDir(): string|null

Get the current event this plugin is responding to

getEvent(): \LimeSurvey\PluginManager\PluginEvent

Returns the id of the plugin

getId(): integer

Used by storage model to find settings specific to this plugin

Response

integer

Gets the name for the plugin, this must be unique.

getName(): string
static

Response

string

Plugin name, max length: 20.

Provides meta data on the plugin settings that are available for this plugin.

getPluginSettings(boolean $getValues = true): array

This does not include enable / disable; a disabled plugin is never loaded.

Arguments

$getValues

boolean

Set to false to not get the current value for each plugin setting.

Response

array

Returns the plugin storage and takes care of instantiating it

getStore(): \LimeSurvey\PluginManager\iPluginStorage

Translation for plugin

gT(string $sToTranslate,string $sEscapeMode = 'html',string $sLanguage = null): string

Arguments

$sToTranslate

string

The message that are being translated

$sEscapeMode

string

$sLanguage

string

Response

string

Call the Yii::log function to log into tmp/runtime/plugin.log The plugin name is the category.

log(string $message,string $level = \CLogger::LEVEL_TRACE): void

Arguments

$message

string

$level

string

From CLogger, defaults to CLogger::LEVEL_TRACE

Publishes plugin assets.

publish( $fileName): string

Arguments

$fileName

Response

string

Read XML config file and store it in $this->config Assumes config file is config.xml and in plugin root folder.

readConfigFile(): boolean
todo

Could this be moved to plugin model?

Response

boolean

registerCss

registerCss(string $relativePathToCss,string $parentPlugin = null): void

Arguments

$relativePathToCss

string

$parentPlugin

string

registerScript

registerScript(string $relativePathToScript,string $parentPlugin = null): void

Arguments

$relativePathToScript

string

$parentPlugin

string

registerSetting

registerSetting(string $name,array $options = array('type' => 'string'))

Arguments

$name

string

Name of the setting. The type of the setting is either a basic type or choice. The choice type is either a single or a multiple choice setting.

$options

array

Contains parameters for the setting. The 'type' key contains the parameter type. The type is one of: string, int, float, choice. Supported keys per type: String: max-length(int), min-length(int), regex(string). Int: max(int), min(int). Float: max(float), min(float). Choice: choices(array containing values as keys and names as values), multiple(bool) Note that the values for choice will be translated.

Look for views in plugin views/ folder and render it

renderPartial(string $viewfile,array $data,boolean $return = false,boolean $processOutput = false): \LimeSurvey\PluginManager\string;

Arguments

$viewfile

string

Filename of view in views/ folder

$data

array

$return

boolean

$processOutput

boolean

Response

\LimeSurvey\PluginManager\string;

Saves the new version from config into database

saveNewVersion(): void

Saves the settings for this plugin

saveSettings( $settings): void

Assumes an array with valid key/value pairs is passed.

Arguments

$settings

This function stores plugin data.

set(string $key,mixed $data,string $model = null,integer $id = null): boolean

Arguments

$key

string

$data

mixed

$model

string

$id

integer

Response

boolean

Set the event to the plugin, this method is executed by the PluginManager just before dispatching the event.

setEvent(\LimeSurvey\PluginManager\PluginEvent $event): \LimeSurvey\PluginManager\PluginBase

We need a component for each plugin to load correct locale file.

setLocaleComponent(): void

Show an error message about malformed config.json file.

showConfigErrorNotification(): void

This function subscribes the plugin to receive an event.

subscribe(string $event,string $function = null)

Arguments

$event

string

$function

string

This function unsubscribes the plugin from an event.

unsubscribe(string $event)

Arguments

$event

string

Properties

api

api :\LimeSurvey\PluginManager\LimesurveyApi

event

event :\LimeSurvey\PluginManager\PluginEvent

id

id :integer
var

Type(s)

integer

storage

storage :string
var

Type(s)

string

description

description :string
static
var

Type(s)

string

name

name :string
static
var

Type(s)

string

store

store :\LimeSurvey\PluginManager\?
var

Type(s)

\LimeSurvey\PluginManager\?

Global settings of plugin

settings :array<mixed,array>
var

Type(s)

array<mixed,array>

This holds the pluginmanager that instantiated the plugin

pluginManager :\LimeSurvey\PluginManager\PluginManager

config.xml

config :\SimpleXMLElement|null
todo

Use ExtensionConfig

var

Type(s)

\SimpleXMLElement|null

List of allowed public method, null mean all method are allowed.

allowedPublicMethods :array<mixed,string>|null

Else method must be in the list. Used in public controller :

  • PluginHelper::ajax (admin/pluginhelper&sa=ajax)
  • PluginHelper::fullpagewrapper (admin/pluginhelper&sa=fullpagewrapper)
  • PluginHelper::sidebody (admin/pluginhelper&sa=sidebody)
var

Type(s)

array<mixed,string>|null

List of settings that should be encrypted before saving.

encryptedSettings :array<mixed,string>
var

Type(s)

array<mixed,string>