44 public $errors = array();
79 if ($newaction ==
'add') {
80 $newaction =
'create';
82 if ($newaction ==
'update') {
85 if (empty($newaction) || $newaction ==
'delete' || $newaction ==
'create_user' || $newaction ==
'presend' || $newaction ==
'send') {
102 global $conf, $langs;
105 $this->targetmodule = $module;
106 $this->canvas = $canvas;
108 $this->dirmodule = $module;
111 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $canvas, $regs)) {
112 $this->canvas = $regs[1];
113 $this->dirmodule = $regs[2];
116 if ($this->dirmodule ==
'thirdparty') {
117 $this->dirmodule =
'societe';
121 $controlclassfile =
dol_buildpath(
'/'.$this->dirmodule.
'/canvas/'.$this->canvas.
'/actions_'.$this->card.
'_'.$this->canvas.
'.class.php');
122 if (file_exists($controlclassfile)) {
124 $this->control_file = $controlclassfile;
125 require_once $controlclassfile;
128 $controlclassname =
'Actions'.ucfirst($this->card).ucfirst($this->canvas);
129 $this->control =
new $controlclassname($this->db, $this->dirmodule, $this->targetmodule, $this->canvas, $this->card);
133 $this->template_dir =
dol_buildpath(
'/'.$this->dirmodule.
'/canvas/'.$this->canvas.
'/tpl/');
134 if (!is_dir($this->template_dir)) {
135 $this->template_dir =
'';
154 if (is_object($this->control) && method_exists($this->control,
'assign_values')) {
155 $this->control->assign_values($action, $id, $ref);
168 if (empty($this->template_dir)) {
172 if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.
'_' :
'').$this->
_cleanaction($action).
'.tpl.php')) {
190 global $db, $conf, $langs, $user, $canvas;
191 global $form, $formfile;
194 include $this->template_dir.(!empty($this->card) ? $this->card.
'_' :
'').$this->
_cleanaction($action).
'.tpl.php';
208 return (is_object($this->control));
224 if (method_exists($this->control,
'doActions')) {
225 $ret = $this->control->doActions($action, $id);
hasActions()
Return if a canvas contains an action controller.
getCanvas($module, $card, $canvas)
Initialize properties: ->targetmodule, ->canvas, ->card, ->dirmodule, ->template_dir.
_cleanaction($action)
Return action code cleaned.
__construct($db, $actiontype='view')
Constructor.
display_canvas($action)
Display a canvas page.
doActions(&$action='view', $id=0)
Shared method for canvas to execute actions.
displayCanvasExists($action)
Return if a template exists to display as canvas (if it exists)
assign_values(&$action='view', $id=0, $ref='')
Shared method for canvas to assign values for templates.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.