class Canvas (View source)

Class to manage canvas

Properties

DoliDB $db
string $error
string[] $errors
string $actiontype
string $dirmodule
string $targetmodule
string $canvas
string $card
string $template_dir
ActionsContactCardCommon|ActionsAdherentCardCommon|ActionsCardProduct|ActionsCardService|ActionsCardCommon $control

Methods

__construct($db, string $actiontype = 'view')

Constructor

getCanvas($module, string $card, $canvas)

Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir

assign_values($action = 'view', int $id = 0, $ref = '')

Shared method for canvas to assign values for templates

int
displayCanvasExists(string $action)

Return if a template exists to display as canvas (if it exists)

void
display_canvas(string $action)

Display a canvas page. This will include the template for output.

hasActions()

Return if a canvas contains an action controller

doActions(string $action = 'view', $id = 0)

Shared method for canvas to execute actions.

Details

__construct($db, string $actiontype = 'view')

Constructor

@param DoliDB $db Database handler

Parameters

$db
string $actiontype

Action type ('create', 'view', 'edit', 'list')

getCanvas($module, string $card, $canvas)

Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir

@param  string  $module     Name of target module (thirdparty, contact, ...)

Parameters

$module
string $card

Tab name of card (ex: 'card', 'info', 'contactcard', ...) or '' for a list page @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) @return void

$canvas

assign_values($action = 'view', int $id = 0, $ref = '')

Shared method for canvas to assign values for templates

@param      string      $action Action string

Parameters

$action
int $id

Object id (if ref not provided) @param string $ref Object ref (if id not provided) @return void

$ref

int displayCanvasExists(string $action)

Return if a template exists to display as canvas (if it exists)

Parameters

string $action

Action code

Return Value

int

0=Canvas template file does not exist, 1=Canvas template file exists

void display_canvas(string $action)

Display a canvas page. This will include the template for output.

Variables used by templates may have been defined or loaded before into the assign_values function.

Parameters

string $action

Action code

Return Value

void

hasActions()

Return if a canvas contains an action controller

@return     boolean     Return if canvas contains actions (old feature. now actions should be inside hooks)

doActions(string $action = 'view', $id = 0)

Shared method for canvas to execute actions.

@deprecated Use the doActions of hooks instead of this. This function is called if you add a doActions class inside your canvas. Try to not do that and add action code into a hook instead.

Parameters

string $action

Action string @param int $id Object id @return ?mixed Return return code of doActions of canvas @see https://wiki.dolibarr.org/index.php/Canvas_development

$id