FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Controller Class Reference
Inheritance diagram for Controller:
Component Thing

Public Member Functions

 clientConfig ()
 
 reset ()
 Reset the controller. More...
 
 expect ($id, $action)
 Note if an action is expected. More...
 
 expected ($id, $action)
 Was the action expected? More...
 
 routeParams ()
 Parameters for the route to this controller. More...
 
 route ($type=null, $params=null)
 Route to this controller. More...
 
 redir ($levels=1, $suffix=null, $params=null)
 Navigate to another controller. More...
 
 caption ($id)
 Default caption for a widget. More...
 
 hint ($id)
 Default hint for a widget. More...
 
 arrayTotal ($values, $type)
 Calculate the total for an array. More...
 
 execute ()
 Execute the action (if specified) on the controller. More...
 
 actions ($prefix=null)
 Available actions for current user. More...
 
- Public Member Functions inherited from Component
 __construct ($fred, $config=null)
 
 __destruct ()
 
 clientConfig ()
 Public configuration. More...
 
 config ($key, $default=null)
 Retrieve a config value. More...
 
 ping ()
 Ping function. More...
 
 filemtime ($filename)
 Filemtime with session cache. More...
 
 component ($name)
 Get a component (local or default). More...
 
 components (... $names)
 Get multiple components in an array. More...
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

const TOTAL_COUNT = 'count'
 
const TOTAL_SUM = 'sum'
 
const TOTAL_AVG = 'avg'
 
const TOTAL_MAX = 'max'
 
const TOTAL_MIN = 'min'
 
const TOTAL_UNIQUE = 'unique'
 
const TOTAL_NULL = 'null'
 
const TOTAL_NOT_NULL = 'not_null'
 
 $domainRedir = []
 Prefered domain notation (key = domain mask regex, value = prefered domain, incl. protocol). More...
 
 $domainRedirPermanent = false
 True to make a redirection permanent (HTTP status code = 301; defaults to 302). More...
 
 $defaultWidgetNamespace = __CLASS__ . '\\Widget'
 
 $defaultViewNamespace = __CLASS__ . '\\View'
 
 $defaultViewType = 'html'
 
 $viewClassName = null
 Fix the view to a certain View or Controller class (empty = same as called class). More...
 
 $fragmentId = null
 
 $display = Controller\Widget::DISPLAY_WRITEABLE
 Default display mode for widgets. More...
 
 $defaultCaption = null
 An asterisk will be replaced with widget ID. More...
 
 $defaultHint = null
 An asterisk will be replaced with the widget ID or type. More...
 
 $helpCaption = 'Help'
 
 $errorStr = '[caption]{[!caption]{[id]}}: [error]'
 
 $inactiveMessage = '[@inactiveMessage]'
 Message for inactive user who is redirected to login controller. More...
 
 $clientErrorPrio = null
 Log client errors with this prio (empty = do not log). More...
 
 $clientErrorBanDelay = 10
 Ban delay for the first error in a new session (prevent flooding via multiple. More...
 
 $clientErrorMax = 25
 Maximum number of client errors to log in one session. More...
 
- Data Fields inherited from Component
 $filemtimeTtl = 0
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 init ()
 
 domainRedir ()
 
 addAuth ($name)
 Add an authentication check to all sets, or create a new one if none exists. More...
 
 removeAuth ($name)
 Remove an authentication check from all sets. More...
 
 addWidget ($id, $widget)
 Add a single widget. More...
 
 addWidgets ($widgets)
 Add multiple widgets. More...
 
 widgetByType ($type, $config)
 Create a widget by type. More...
 
 addByType ($id, $type, $config)
 Add a widget by type. More...
 
 widgetFromDef ($table, $column, $extra=null)
 Create a widget from a database definition. More...
 
 addFromDef ($table, $columns=null, $extra=null, $prefix=null)
 Add widgets from a database definition. More...
 
 addFromRecord ($record, $prefix=null)
 Add widgets from a definition record. More...
 
 dataFromRecord ($record, $prefix=null)
 Copy data from a definition record to the request. More...
 
 dataToRecord ($record, $prefix=null)
 Copy data from the request to a definition record. More...
 
 deleteWidget (... $ids)
 Remove one or more widget(s). More...
 
 addConstraint ($ids, $operator,$group=null, $total=null)
 Add a constraint. More...
 
 initWidgets ()
 Initialize the widgets. More...
 
 unkownAction ()
 Unknwon action called. More...
 
 actionDefault ()
 Default action (if no action specified). More...
 
 actionFragment ()
 Return a fragment from the view. More...
 
 actionPingAlive ()
 Ping to keep the session alive. More...
 
 actionClientError ()
 Log client-side errors. More...
 
 actionFeatureHint ()
 Return a feature hint translation. More...
 
 actionRequestSocket ()
 Request a socket. More...
 
 addError ($id, $error)
 Add an error to the request. More...
 
 checkConstraint ($widget_ids, $ids, $operator,$group=null, $total=null)
 Check a constraint. More...
 
 checkWidgets ($ids=null)
 Check widget values. More...
 
 actionRight ($action)
 Necessary right for an action. More...
 
 getAction ()
 
 setCheckWidgets ($check_widgets)
 
 getConstraints ()
 
 getName ()
 
 getRight ()
 
 setRights ($rights)
 
 getSecurityChecksIgnore ()
 
 setSecurityChecksIgnore ($security_checks_ignore)
 
 getView ()
 
 getWidgets ()
 
 setWidgets ($value)
 
 _get ($key)
 
 _set ($key, $value)
 
- Protected Member Functions inherited from Component
 init ()
 
 done ()
 
 getSession ()
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_securityChecksIgnore = []
 Security checks to ignore (key = action, null = default; value = array with. More...
 
 $_authSets = []
 Possible sets of necessary authentication (array of arrays of authentication checks). More...
 
 $_rights = []
 Necessary right needed per action (key = action, null = default; value = right, optionally. More...
 
 $_checkWidgets = ['default' => false
 
 $_action = null
 Widgets to check per action (key = action; value = array with ID's of widget to check; null = default, otherwise all). More...
 
 $_widgets = null
 
 $_constraints = null
 
 $_view = null
 
- Protected Attributes inherited from Component
 $_fred = null
 
 $_config = null
 
 $_name = null
 
 $_components = []
 Local components (key = component name, value = component). More...
 
 $_session = null
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Detailed Description

Definition at line 5 of file Controller.php.

Member Function Documentation

◆ _get()

_get (   $key)
protected

Definition at line 609 of file Controller.php.

◆ _set()

_set (   $key,
  $value 
)
protected

Definition at line 613 of file Controller.php.

◆ actionClientError()

actionClientError ( )
protected

Log client-side errors.

Definition at line 316 of file Controller.php.

◆ actionDefault()

actionDefault ( )
protected

Default action (if no action specified).

Definition at line 289 of file Controller.php.

◆ actionFeatureHint()

actionFeatureHint ( )
protected

Return a feature hint translation.

Definition at line 340 of file Controller.php.

◆ actionFragment()

actionFragment ( )
protected

Return a fragment from the view.

Definition at line 294 of file Controller.php.

◆ actionPingAlive()

actionPingAlive ( )
protected

Ping to keep the session alive.

Definition at line 300 of file Controller.php.

◆ actionRequestSocket()

actionRequestSocket ( )
protected

Request a socket.

Definition at line 347 of file Controller.php.

◆ actionRight()

actionRight (   $action)
protected

Necessary right for an action.

Parameters
string$action
Returns
string Necessary right.

Definition at line 516 of file Controller.php.

◆ actions()

actions (   $prefix = null)

Available actions for current user.

Parameters
string$prefixPrefix where the action name has to start with.
Returns
array Array with action names.

Definition at line 531 of file Controller.php.

◆ addAuth()

addAuth (   $name)
protected

Add an authentication check to all sets, or create a new one if none exists.

Parameters
string$nameAuthentication check name.

Definition at line 80 of file Controller.php.

◆ addByType()

addByType (   $id,
  $type,
  $config 
)
protected

Add a widget by type.

Parameters
string$idWidget ID.
string$typeWidget type (class name).
string$configConfiguration.

Definition at line 126 of file Controller.php.

◆ addConstraint()

addConstraint (   $ids,
  $operator,
  $group = null,
  $total = null 
)
protected

Add a constraint.

Parameters
array$idsWidgets involved (an asterisk will be replaced with the current index during checking, '–' with the previous index, '++' with the next). Widgets that are empty (nothing) are ignored.
string$operatorLike used with \Rsi\Str::operator().
string$groupGroup widget values (use TOTAL_* constants), rather than checking them one-by-one.
number$totalGrouping reference value. Set to true to make this equal to the number of values.

Definition at line 194 of file Controller.php.

◆ addError()

addError (   $id,
  $error 
)
protected

Add an error to the request.

Parameters
string$idID of the widget involved.
string$errorError type.

Definition at line 361 of file Controller.php.

◆ addFromDef()

addFromDef (   $table,
  $columns = null,
  $extra = null,
  $prefix = null 
)
protected

Add widgets from a database definition.

Parameters
string$tableName of the table.
string | array$columnsOne or more column names (all table columns when empty).
array$extraExtra configuration to add to the definition.
string$prefixPrefix to add to the column name for the widget ID.

Definition at line 147 of file Controller.php.

◆ addFromRecord()

addFromRecord (   $record,
  $prefix = null 
)
protected

Add widgets from a definition record.

Parameters
Rsi\Fred\Def\Record$recordDefinition record.
string$prefixPrefix to add to the column name for the widget ID.

Definition at line 157 of file Controller.php.

◆ addWidget()

addWidget (   $id,
  $widget 
)
protected

Add a single widget.

Parameters
string$idWidget ID.
Rsi\Fred\Controller\Widget$widget

Definition at line 99 of file Controller.php.

◆ addWidgets()

addWidgets (   $widgets)
protected

Add multiple widgets.

Parameters
array$widgetsKey = ID, value = widget.

Definition at line 107 of file Controller.php.

◆ arrayTotal()

arrayTotal (   $values,
  $type 
)

Calculate the total for an array.

Parameters
array$valuesArray with values (string or numeric).
string$typeType of total (see TOTAL_* constants).
Returns
mixed Calculated value for array.

Definition at line 374 of file Controller.php.

◆ caption()

caption (   $id)

Default caption for a widget.

Parameters
string$idWidget ID.
Returns
string

Definition at line 269 of file Controller.php.

◆ checkConstraint()

checkConstraint (   $widget_ids,
  $ids,
  $operator,
  $group = null,
  $total = null 
)
protected

Check a constraint.

Parameters
array$widget_idsWidgets in the action.
array$idsWidgets involved.
string$operatorLike used with \Rsi\Str::operator().
string$groupGroup widget values (use TOTAL_* constants), rather than checking them one-by-one.
number$totalGrouping reference value.

Definition at line 393 of file Controller.php.

◆ checkWidgets()

checkWidgets (   $ids = null)
protected

Check widget values.

Widget data is taken from the request data array. Errors are added to the request.

Parameters
array$idsWidgets to check (empty = all).
Returns
bool True if everything is OK.

Definition at line 454 of file Controller.php.

◆ clientConfig()

clientConfig ( )

Definition at line 65 of file Controller.php.

◆ dataFromRecord()

dataFromRecord (   $record,
  $prefix = null 
)
protected

Copy data from a definition record to the request.

Parameters
Rsi\Fred\Def\Record$recordDefinition record.
string$prefixPrefix to add to the column name for the widget ID.

Definition at line 165 of file Controller.php.

◆ dataToRecord()

dataToRecord (   $record,
  $prefix = null 
)
protected

Copy data from the request to a definition record.

Parameters
Rsi\Fred\Def\Record$recordDefinition record.
string$prefixPrefix to add to the column name for the widget ID.

Definition at line 174 of file Controller.php.

◆ deleteWidget()

deleteWidget (   $ids)
protected

Remove one or more widget(s).

Parameters
string$ids,...Widget ID('s).

Definition at line 182 of file Controller.php.

◆ domainRedir()

domainRedir ( )
protected

Definition at line 57 of file Controller.php.

◆ execute()

execute ( )

Execute the action (if specified) on the controller.

Security checks are executed before. All input and output is handled through the request component. An action can only trust the values from the data array. If the value is not present, the user is not authorized to modify it. All other values must be checked.

Definition at line 471 of file Controller.php.

◆ expect()

expect (   $id,
  $action 
)

Note if an action is expected.

Parameters
string$idWidget ID.
string$action

Definition at line 216 of file Controller.php.

◆ expected()

expected (   $id,
  $action 
)

Was the action expected?

Parameters
string$idWidget ID.
string$action
Returns
bool

Definition at line 227 of file Controller.php.

◆ getAction()

getAction ( )
protected

Definition at line 541 of file Controller.php.

◆ getConstraints()

getConstraints ( )
protected

Definition at line 550 of file Controller.php.

◆ getName()

getName ( )
protected

Definition at line 555 of file Controller.php.

◆ getRight()

getRight ( )
protected

Definition at line 561 of file Controller.php.

◆ getSecurityChecksIgnore()

getSecurityChecksIgnore ( )
protected

Definition at line 569 of file Controller.php.

◆ getView()

getView ( )
protected

Definition at line 579 of file Controller.php.

◆ getWidgets()

getWidgets ( )
protected

Definition at line 596 of file Controller.php.

◆ hint()

hint (   $id)

Default hint for a widget.

Parameters
string$idWidget ID or type.
Returns
string

Definition at line 277 of file Controller.php.

◆ init()

init ( )
protected

Definition at line 51 of file Controller.php.

◆ initWidgets()

initWidgets ( )
protected

Initialize the widgets.

Called by the widget getter.

Definition at line 201 of file Controller.php.

◆ redir()

redir (   $levels = 1,
  $suffix = null,
  $params = null 
)

Navigate to another controller.

Parameters
int$levelsNumber of levels to go up.
string$suffixSuffix to add.
bool | array$paramsParameters for the controller (set to false to only change the view controller name).

Definition at line 258 of file Controller.php.

◆ removeAuth()

removeAuth (   $name)
protected

Remove an authentication check from all sets.

Parameters
string$nameAuthentication check name.

Definition at line 89 of file Controller.php.

◆ reset()

reset ( )

Reset the controller.

Called when the same controller is used for both the handling of the request ('post') and the view. Use this to perform actions between those two events.

Definition at line 208 of file Controller.php.

◆ route()

route (   $type = null,
  $params = null 
)

Route to this controller.

Parameters
string$type
array$paramsExtra params.
Returns
string

Definition at line 247 of file Controller.php.

◆ routeParams()

routeParams ( )

Parameters for the route to this controller.

Returns
array

Definition at line 238 of file Controller.php.

◆ setCheckWidgets()

setCheckWidgets (   $check_widgets)
protected

Definition at line 546 of file Controller.php.

◆ setRights()

setRights (   $rights)
protected

Definition at line 565 of file Controller.php.

◆ setSecurityChecksIgnore()

setSecurityChecksIgnore (   $security_checks_ignore)
protected

Definition at line 575 of file Controller.php.

◆ setWidgets()

setWidgets (   $value)
protected

Definition at line 604 of file Controller.php.

◆ unkownAction()

unkownAction ( )
protected

Unknwon action called.

Definition at line 283 of file Controller.php.

◆ widgetByType()

widgetByType (   $type,
  $config 
)
protected

Create a widget by type.

Parameters
string$typeWidget type (class name).
string$configConfiguration.
Returns
Widget

Definition at line 116 of file Controller.php.

◆ widgetFromDef()

widgetFromDef (   $table,
  $column,
  $extra = null 
)
protected

Create a widget from a database definition.

Parameters
string$tableName of the table.
string$columnColumn name.
array$extraExtra configuration to add to the definition.
Returns
Widget

Definition at line 136 of file Controller.php.

Field Documentation

◆ $_action

$_action = null
protected

Widgets to check per action (key = action; value = array with ID's of widget to check; null = default, otherwise all).

Definition at line 46 of file Controller.php.

◆ $_authSets

$_authSets = []
protected

Possible sets of necessary authentication (array of arrays of authentication checks).

Definition at line 39 of file Controller.php.

◆ $_checkWidgets

$_checkWidgets = ['default' => false
protected

Definition at line 43 of file Controller.php.

◆ $_constraints

$_constraints = null
protected

Definition at line 48 of file Controller.php.

◆ $_rights

$_rights = []
protected

Necessary right needed per action (key = action, null = default; value = right, optionally.

Definition at line 40 of file Controller.php.

◆ $_securityChecksIgnore

$_securityChecksIgnore = []
protected

Security checks to ignore (key = action, null = default; value = array with.

Definition at line 37 of file Controller.php.

◆ $_view

$_view = null
protected

Definition at line 49 of file Controller.php.

◆ $_widgets

$_widgets = null
protected

Definition at line 47 of file Controller.php.

◆ $clientErrorBanDelay

$clientErrorBanDelay = 10

Ban delay for the first error in a new session (prevent flooding via multiple.

Definition at line 33 of file Controller.php.

◆ $clientErrorMax

$clientErrorMax = 25

Maximum number of client errors to log in one session.

Definition at line 35 of file Controller.php.

◆ $clientErrorPrio

$clientErrorPrio = null

Log client errors with this prio (empty = do not log).

Definition at line 32 of file Controller.php.

◆ $defaultCaption

$defaultCaption = null

An asterisk will be replaced with widget ID.

Definition at line 25 of file Controller.php.

◆ $defaultHint

$defaultHint = null

An asterisk will be replaced with the widget ID or type.

Definition at line 26 of file Controller.php.

◆ $defaultViewNamespace

$defaultViewNamespace = __CLASS__ . '\\View'

Definition at line 19 of file Controller.php.

◆ $defaultViewType

$defaultViewType = 'html'

Definition at line 20 of file Controller.php.

◆ $defaultWidgetNamespace

$defaultWidgetNamespace = __CLASS__ . '\\Widget'

Definition at line 18 of file Controller.php.

◆ $display

Default display mode for widgets.

Definition at line 24 of file Controller.php.

◆ $domainRedir

$domainRedir = []

Prefered domain notation (key = domain mask regex, value = prefered domain, incl. protocol).

Definition at line 16 of file Controller.php.

◆ $domainRedirPermanent

$domainRedirPermanent = false

True to make a redirection permanent (HTTP status code = 301; defaults to 302).

Definition at line 17 of file Controller.php.

◆ $errorStr

$errorStr = '[caption]{[!caption]{[id]}}: [error]'

Definition at line 28 of file Controller.php.

◆ $fragmentId

$fragmentId = null

Definition at line 22 of file Controller.php.

◆ $helpCaption

$helpCaption = 'Help'

Definition at line 27 of file Controller.php.

◆ $inactiveMessage

$inactiveMessage = '[@inactiveMessage]'

Message for inactive user who is redirected to login controller.

Definition at line 30 of file Controller.php.

◆ $viewClassName

$viewClassName = null

Fix the view to a certain View or Controller class (empty = same as called class).

Definition at line 21 of file Controller.php.

◆ TOTAL_AVG

const TOTAL_AVG = 'avg'

Definition at line 9 of file Controller.php.

◆ TOTAL_COUNT

const TOTAL_COUNT = 'count'

Definition at line 7 of file Controller.php.

◆ TOTAL_MAX

const TOTAL_MAX = 'max'

Definition at line 10 of file Controller.php.

◆ TOTAL_MIN

const TOTAL_MIN = 'min'

Definition at line 11 of file Controller.php.

◆ TOTAL_NOT_NULL

const TOTAL_NOT_NULL = 'not_null'

Definition at line 14 of file Controller.php.

◆ TOTAL_NULL

const TOTAL_NULL = 'null'

Definition at line 13 of file Controller.php.

◆ TOTAL_SUM

const TOTAL_SUM = 'sum'

Definition at line 8 of file Controller.php.

◆ TOTAL_UNIQUE

const TOTAL_UNIQUE = 'unique'

Definition at line 12 of file Controller.php.


The documentation for this class was generated from the following file: