Try to comment deprecated code to reduce code and keep only one pattern of development for canvas.

This commit is contained in:
Laurent Destailleur 2010-11-11 11:15:06 +00:00
parent 3d1d607158
commit f6dade1093
5 changed files with 52 additions and 80 deletions

View File

@ -46,7 +46,7 @@ class Canvas
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;
/** /**
* Constructor. * Constructor.
@ -56,7 +56,7 @@ class Canvas
{ {
$this->db = $DB; $this->db = $DB;
} }
/** /**
* Set action type * Set action type
*/ */
@ -64,7 +64,7 @@ class Canvas
{ {
return $this->action = $action; return $this->action = $action;
} }
/** /**
* Return the title of card * Return the title of card
@ -73,7 +73,7 @@ class Canvas
{ {
return $this->control->getTitle($this->action); return $this->control->getTitle($this->action);
} }
/** /**
* Return the head of card (tabs) * Return the head of card (tabs)
*/ */
@ -97,10 +97,10 @@ class Canvas
function doActions($id) function doActions($id)
{ {
$out = $this->control->doActions($id); $out = $this->control->doActions($id);
$this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors); $this->errors = ($this->control->errors?$this->control->errors:$this->control->object->errors);
$this->error = ($this->control->error?$this->control->error:$this->control->object->error); $this->error = ($this->control->error?$this->control->error:$this->control->object->error);
return $out; return $out;
} }
@ -134,7 +134,7 @@ class Canvas
$childmodule = $this->aliasmodule = $regs[2]; $childmodule = $this->aliasmodule = $regs[2];
$this->canvas = $regs[1]; $this->canvas = $regs[1];
} }
// For compatibility // For compatibility
if ($childmodule == 'thirdparty') { $childmodule = $this->aliasmodule = 'societe'; } if ($childmodule == 'thirdparty') { $childmodule = $this->aliasmodule = 'societe'; }
if ($targetmodule == 'thirdparty') { $targetmodule = 'societe'; } if ($targetmodule == 'thirdparty') { $targetmodule = 'societe'; }
@ -158,7 +158,7 @@ class Canvas
// Include actions class (controller) // Include actions class (controller)
$controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'; $controlclassfile = DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php';
require_once($controlclassfile); require_once($controlclassfile);
// Include specific library // Include specific library
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/lib/'.$this->aliasmodule.'.lib.php')) if (file_exists(DOL_DOCUMENT_ROOT.'/'.$this->aliasmodule.'/lib/'.$this->aliasmodule.'.lib.php'))
{ {
@ -190,7 +190,7 @@ class Canvas
return 1; return 1;
} }
/** /**
* Check permissions of a user to show a page and an object. Check read permission * Check permissions of a user to show a page and an object. Check read permission
* If $_REQUEST['action'] defined, we also check write permission. * If $_REQUEST['action'] defined, we also check write permission.
@ -209,12 +209,12 @@ class Canvas
} }
/** /**
* Assign templates values * Shared method for canvas to assign values of templates
* @param action Type of action * @param action Type of action
*/ */
function assign_values() function assign_values()
{ {
if (!empty($this->smarty)) /*if (!empty($this->smarty))
{ {
global $smarty; global $smarty;
@ -222,10 +222,9 @@ class Canvas
$smarty->template_dir = $this->template_dir; $smarty->template_dir = $this->template_dir;
} }
else else
{ {*/
$this->control->assign_values($this->action); $this->control->assign_values($this->action);
} /*}*/
} }
/** /**
@ -235,16 +234,16 @@ class Canvas
{ {
global $conf, $langs, $user, $canvas; global $conf, $langs, $user, $canvas;
if (!empty($this->smarty)) /*if (!empty($this->smarty))
{ {
global $smarty; global $smarty;
$smarty->display($this->action.'.tpl'); $smarty->display($this->action.'.tpl');
} }
else else
{ {*/
include($this->template_dir.$this->card.'_'.$this->action.'.tpl.php'); include($this->template_dir.$this->card.'_'.$this->action.'.tpl.php'); // Include native PHP template
} /*}*/
} }
} }

View File

@ -44,11 +44,11 @@ class ProductDefault extends Product
$this->db = $DB; $this->db = $DB;
$this->id = $id ; $this->id = $id ;
$this->user = $user; $this->user = $user;
$this->smarty = 0; //$this->smarty = 0;
$this->module = "produit"; $this->module = "produit";
$this->canvas = "default"; $this->canvas = "default";
$this->name = "default"; $this->name = "default";
$this->definition = "Canvas des produits (défaut)"; $this->definition = "Product canvas (défaut)";
$this->fieldListName = "product_default"; $this->fieldListName = "product_default";
$this->next_prev_filter = "canvas='default'"; $this->next_prev_filter = "canvas='default'";

View File

@ -31,9 +31,9 @@ class ProductService extends Product
{ {
//! Numero d'erreur Plage 1280-1535 //! Numero d'erreur Plage 1280-1535
var $errno = 0; var $errno = 0;
var $tpl = array(); var $tpl = array();
/** /**
* \brief Constructeur de la classe * \brief Constructeur de la classe
* \param DB Handler acces base de donnees * \param DB Handler acces base de donnees
@ -44,21 +44,21 @@ class ProductService extends Product
$this->db = $DB; $this->db = $DB;
$this->id = $id ; $this->id = $id ;
$this->user = $user; $this->user = $user;
$this->smarty = 0; //$this->smarty = 0;
$this->module = "service"; $this->module = "service";
$this->canvas = "service"; $this->canvas = "service";
$this->name = "service"; $this->name = "service";
$this->definition = "Canvas des services"; $this->definition = "Services canvas";
$this->fieldListName = "product_service"; $this->fieldListName = "product_service";
$this->next_prev_filter = "canvas='service'"; $this->next_prev_filter = "canvas='service'";
} }
function getTitle() function getTitle()
{ {
return 'Services'; return 'Services';
} }
/** /**
* \brief Lecture des donnees dans la base * \brief Lecture des donnees dans la base
* \param id Product id * \param id Product id
@ -69,7 +69,7 @@ class ProductService extends Product
return $result; return $result;
} }
/** /**
* \brief Assigne les valeurs pour les templates * \brief Assigne les valeurs pour les templates
* \param object object * \param object object
@ -77,25 +77,25 @@ class ProductService extends Product
function assign_values($action='') function assign_values($action='')
{ {
global $conf,$langs; global $conf,$langs;
parent::assign_values($action); parent::assign_values($action);
// Duration // Duration
$this->tpl['duration_value'] = $this->duration_value; $this->tpl['duration_value'] = $this->duration_value;
if ($action == 'create') if ($action == 'create')
{ {
// Title // Title
$this->tpl['title'] = load_fiche_titre($langs->trans("NewService")); $this->tpl['title'] = load_fiche_titre($langs->trans("NewService"));
} }
if ($action == 'edit') if ($action == 'edit')
{ {
$this->tpl['title'] = load_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$this->ref, ""); $this->tpl['title'] = load_fiche_titre($langs->trans('Modify').' '.$langs->trans('Service').' : '.$this->ref, "");
} }
if ($action == 'create' || $action == 'edit') if ($action == 'create' || $action == 'edit')
{ {
// Duration unit // Duration unit
// TODO creer fonction // TODO creer fonction
$duration_unit = '<input name="duration_unit" type="radio" value="h"'.($this->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour"); $duration_unit = '<input name="duration_unit" type="radio" value="h"'.($this->duration_unit=='h'?' checked':'').'>'.$langs->trans("Hour");
@ -109,9 +109,9 @@ class ProductService extends Product
$duration_unit.= '<input name="duration_unit" type="radio" value="y"'.($this->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); $duration_unit.= '<input name="duration_unit" type="radio" value="y"'.($this->duration_unit=='y'?' checked':'').'>'.$langs->trans("Year");
$this->tpl['duration_unit'] = $duration_unit; $this->tpl['duration_unit'] = $duration_unit;
} }
if ($action == 'view') if ($action == 'view')
{ {
// Photo // Photo
$this->tpl['nblignes'] = 4; $this->tpl['nblignes'] = 4;
if ($this->is_photo_available($conf->service->dir_output)) if ($this->is_photo_available($conf->service->dir_output))
@ -131,14 +131,14 @@ class ProductService extends Product
$this->tpl['duration_unit'] = $langs->trans($dur[$this->duration_unit]); $this->tpl['duration_unit'] = $langs->trans($dur[$this->duration_unit]);
} }
} }
/** /**
* \brief Fetch datas list * \brief Fetch datas list
*/ */
function LoadListDatas($limit, $offset, $sortfield, $sortorder) function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{ {
global $conf; global $conf;
$sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,';
$sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.fk_product_type, p.tms as datem,';
$sql.= ' p.duration, p.tosell as statut, p.seuil_stock_alerte'; $sql.= ' p.duration, p.tosell as statut, p.seuil_stock_alerte';
@ -183,7 +183,7 @@ class ProductService extends Product
} }
$sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->order($sortfield,$sortorder);
$sql.= $this->db->plimit($limit + 1 ,$offset); $sql.= $this->db->plimit($limit + 1 ,$offset);
$this->list_datas = array(); $this->list_datas = array();
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -214,7 +214,7 @@ class ProductService extends Product
print $sql; print $sql;
} }
} }
} }
?> ?>

View File

@ -2856,31 +2856,6 @@ class Product extends CommonObject
$this->tpl['description'] = $this->description; $this->tpl['description'] = $this->description;
$this->tpl['note'] = $this->note; $this->tpl['note'] = $this->note;
/* Fix: La presentation ne doit pas etre gérée dans une classe métier
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC)
{
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
$doleditor=new DolEditor('desc',$this->description,160,'dolibarr_notes','',false);
$this->tpl['doleditor_description'] = $doleditor;
$doleditor=new DolEditor('note',$this->note,180,'dolibarr_notes','',false);
$this->tpl['doleditor_note'] = $doleditor;
}
else
{
$textarea = '<textarea name="desc" rows="4" cols="90">';
$textarea.= $this->description;
$textarea.= '</textarea>';
$this->tpl['description'] = $this->description
$textarea = '<textarea name="note" rows="8" cols="70">';
$textarea.= $this->note;
$textarea.= '</textarea>';
$this->tpl['textarea_note'] = $textarea;
}
*/
} }
if ($action == 'view') if ($action == 'view')
@ -2898,16 +2873,10 @@ class Product extends CommonObject
} }
} }
/** /**
* \brief Affecte les valeurs smarty * Return if object is a product
* \remarks Rodolphe : pour l'instant la fonction est vide mais necessaire pour compatibilite * @return boolean True if it's a product
* avec les canvas A terme la fiche produit utilisera aussi smarty */
*/
function assign_smarty_values(&$smarty)
{
}
function isproduct() function isproduct()
{ {
if ($this->type != 1) if ($this->type != 1)
@ -2920,6 +2889,10 @@ class Product extends CommonObject
} }
} }
/**
* Return if object is a product
* @return boolean True if it's a service
*/
function isservice() function isservice()
{ {
if ($this->type==1) if ($this->type==1)

View File

@ -243,7 +243,7 @@ if ($resql)
$template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/'; $template_dir = DOL_DOCUMENT_ROOT . '/theme/'.$conf->theme.'/tpl/product/'.$_GET["canvas"].'/';
} }
if ($object->smarty) /*if ($object->smarty)
{ {
$template = 'list.tpl'; $template = 'list.tpl';
$smarty->template_dir = $template_dir; $smarty->template_dir = $template_dir;
@ -267,9 +267,9 @@ if ($resql)
$smarty->clear_compiled_tpl($template); $smarty->clear_compiled_tpl($template);
} }
else else
{ {*/
include($template_dir.'list.tpl.php'); // To use native PHP include($template_dir.'list.tpl.php'); // Include native PHP templates
} /*}*/
} }
else else
{ {