Works on canvas integration in third party module
This commit is contained in:
parent
33f996a039
commit
9b9fe10053
@ -35,10 +35,12 @@ class Canvas
|
|||||||
|
|
||||||
var $card;
|
var $card;
|
||||||
var $canvas;
|
var $canvas;
|
||||||
var $module;
|
|
||||||
var $object;
|
var $object;
|
||||||
var $control;
|
var $control;
|
||||||
|
var $module;
|
||||||
|
var $targetmodule;
|
||||||
var $aliasmodule; // for compatibility
|
var $aliasmodule; // for compatibility
|
||||||
|
var $aliastargetmodule; // for compatibility
|
||||||
var $template_dir; // Directory with all core and external templates files
|
var $template_dir; // Directory with all core and external templates files
|
||||||
var $action;
|
var $action;
|
||||||
var $smarty;
|
var $smarty;
|
||||||
@ -97,15 +99,17 @@ class Canvas
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get card and canvas type
|
* Get card and canvas type
|
||||||
* @param card Type of card
|
* @param module Name of target module (product, thirdparty, ...)
|
||||||
* @param canvas Name of canvas (ex: default@mymodule)
|
* @param card Type of card (ex: card, info, ...)
|
||||||
|
* @param canvas Name of canvas (ex: mycanvas@mymodule)
|
||||||
*/
|
*/
|
||||||
function getCanvas($card,$canvas)
|
function getCanvas($module,$card,$canvas)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$error='';
|
$error='';
|
||||||
$this->card = $card;
|
$this->card = $card;
|
||||||
|
$this->aliastargetmodule = $this->targetmodule = $module;
|
||||||
|
|
||||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
|
if (preg_match('/^([^@]+)@([^@]+)$/i',$canvas,$regs))
|
||||||
{
|
{
|
||||||
@ -114,6 +118,7 @@ class Canvas
|
|||||||
|
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($this->module == 'thirdparty') $this->aliasmodule = 'societe';
|
if ($this->module == 'thirdparty') $this->aliasmodule = 'societe';
|
||||||
|
if ($this->targetmodule == 'thirdparty') $this->aliastargetmodule = 'societe';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -121,15 +126,15 @@ class Canvas
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->module.'.'.$this->canvas.'.class.php') &&
|
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->targetmodule.'.'.$this->canvas.'.class.php') &&
|
||||||
file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php'))
|
file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->card.'.'.$this->canvas.'.class.php'))
|
||||||
{
|
{
|
||||||
// Include model class
|
// Include model class
|
||||||
$modelclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->module.'.'.$this->canvas.'.class.php';
|
$modelclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/'.$this->targetmodule.'.'.$this->canvas.'.class.php';
|
||||||
include_once($modelclassfile);
|
include_once($modelclassfile);
|
||||||
|
|
||||||
// Include common controller class
|
// Include common controller class
|
||||||
$controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->card.'.common.class.php';
|
$controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliastargetmodule.'/canvas/'.$this->card.'.common.class.php';
|
||||||
include_once($controlclassfile);
|
include_once($controlclassfile);
|
||||||
|
|
||||||
// Include canvas controller class
|
// Include canvas controller class
|
||||||
@ -141,7 +146,7 @@ class Canvas
|
|||||||
$this->control = new $controlclassname($this->db);
|
$this->control = new $controlclassname($this->db);
|
||||||
|
|
||||||
// Instantiate model class
|
// Instantiate model class
|
||||||
$modelclassname = ucfirst($this->module).ucfirst($this->canvas);
|
$modelclassname = ucfirst($this->targetmodule).ucfirst($this->canvas);
|
||||||
$this->control->object = new $modelclassname($this->db);
|
$this->control->object = new $modelclassname($this->db);
|
||||||
|
|
||||||
// Canvas
|
// Canvas
|
||||||
|
|||||||
@ -535,7 +535,7 @@ class CardCommon
|
|||||||
}
|
}
|
||||||
|
|
||||||
$oldsoccanvas = new Canvas($this->db);
|
$oldsoccanvas = new Canvas($this->db);
|
||||||
$oldsoccanvas->getCanvas('thirparty','card',$this->canvas);
|
$oldsoccanvas->getCanvas('thirdparty','card',$this->canvas);
|
||||||
$result=$oldsoccanvas->fetch($socid);
|
$result=$oldsoccanvas->fetch($socid);
|
||||||
|
|
||||||
// To not set code if third party is not concerned. But if it had values, we keep them.
|
// To not set code if third party is not concerned. But if it had values, we keep them.
|
||||||
|
|||||||
@ -1588,7 +1588,7 @@ else
|
|||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
|
|
||||||
$soccanvas = new Canvas($db);
|
$soccanvas = new Canvas($db);
|
||||||
$soccanvas->getCanvas('card',$canvas);
|
$soccanvas->getCanvas('thirdparty','card',$canvas);
|
||||||
|
|
||||||
// Load data control
|
// Load data control
|
||||||
$soccanvas->loadControl($socid);
|
$soccanvas->loadControl($socid);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user