I find some issues in TDMCreate 1.38 Final (latest trunk)
but the most important question is:
where is the latest revision?
I am really confused by too many releases and branches.
branches: mamba, timgno
releases: releases/1.39/TDMCreate
IMO you should always keep the trunk most uptodate version.
for xoops26 developing please create another folder in
http://svn.code.sf.net/p/xoops/svn/XoopsModules26/I dont want to report notices and warnings. i just want to report functional bugs for now.
here is my findings:
1- bug: in TDMCreate/admin/building.php it didnt show any table in "Select the table you want to build" select box. there is some notices and i think you should take a look at those notices.
2- bug: when i build a module it just create one language in MYMODULE/language folder. e.g.: in persian i just have MYMODULE/language/persian and dont have MYMODULE/language/english but i should have both languages.
3- need improve: in TDMCreate/admin/tables.php?op=edit_champs&tables_id=XXX it is better to set some defaults for field's structure. e.g.:
Type: int (now it is correct)
Value: 11 (now it is empty)
Attributes: unsigned (now it is empty)
Null: NOT NULL (now it is correct)
default: 0 (now it is empty)
4- need improve: it should use xoops standard table name mod_MODULEDIRNAME_MODULETABLENAME and standardize the class naming.
class ModuledirnameModuletablename extends XoopsObject
e.g.:
moduledirname = userlog
moduletablename = log
then TDMCreate should create this table:
standardtablename = mod_userlog_log
and TDMCreate should create this class:
class UserlogLog extends XoopsObject
and
class UserlogLogHandler extends XoopsPersistableObjectHandler
{
public $userlog = null;
/**
* @param null|object $db
*/
public function __construct(&$db)
{
$this->userlog = Userlog::getInstance();
parent::__construct($db, "mod_userlog_log", 'UserlogLog', "log_id", "log_time");
}
}
now it create this:
class userloguserlog_logHandler extends XoopsPersistableObjectHandler
{
function __construct(&$db)
{
parent::__construct($db, "userlog_log", "userlog_log", "log_id", "log_time");
}
}
5- bug: it always build the auto increment field class handler using the table name (TABLENAME_id) regardless of what i defined in table structure.
e.g: i add a table name = log
then i add a filed = id
but it always create the class like this:
class userloguserlog_logHandler extends XoopsPersistableObjectHandler
{
function __construct(&$db)
{
parent::__construct($db, "userlog_log", "userlog_log", "log_id", "time_create");
}
}
solution:
in TDMCreate\const\const_class.php line 112:
change this:
parent::__construct($db, "'.$tables_module_table.'", "'.$tables_module_table.'", "'.$tables_name.'_id", "'.$champs_param_main_field.'");
with this:
parent::__construct($db, "'.$tables_module_table.'", "'.$tables_module_table.'", "'.$champs_param_increment_field.'", "'.$champs_param_main_field.'");
and add this line
if( $i == 0 ) {
$champs_param_elements[$i] = '0';
$champs_param_display_form[$i] = '0';
$champs_param_increment_field = $champs[0]; // irmtfan added
the whole file would be this:
/**
* ****************************************************************************
* - TDMCreate By TDM - TEAM DEV MODULE FOR XOOPS
* - Licence GPL Copyright (c) (http://www.tdmxoops.net)
*
* Cette licence, contient des limitations!!!
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @license TDM GPL license
* @author TDM TEAM DEV MODULE
*
* ****************************************************************************
*/
include_once XOOPS_ROOT_PATH.'/modules/TDMCreate/include/functions_const.php';
function const_class($modules, $modules_name, $tables_module_table, $tables_name, $tables_champs, $tables_parametres)
{
$language = '_AM_'.strtoupper($modules_name).'_';
$modules_name_minuscule = strtolower($modules_name);
$class_name = $tables_name;
$file = $modules_name.'_'.$class_name. ".php";
$path_file = TDM_CREATE_MURL."/".$modules_name."/class/".$file;
$constructor = const_champs($modules_name, $tables_module_table, $tables_name, $tables_champs, $language, 0, 0, 0, 0);
$en_tete = const_entete($modules, 0);
//Champs
$champs_total = explode("|", $tables_champs);
$nb_champs = count($champs_total);
//print_r($champs_total);
//Parametres
$parametres_total = explode("|", $tables_parametres);
//Recuperation des parametres affichage dans le formulaire
for($i=0; $i<$nb_champs; $i++)
{
$champs = explode(":", $champs_total[$i]);
//Afficher dans les elements du formulaire et choisir le type
if( $i == 0 ) {
$champs_param_elements[$i] = '0';
$champs_param_display_form[$i] = '0';
$champs_param_increment_field = $champs[0]; // irmtfan added
} else {
$parametres1 = explode(":", $parametres_total[$i-1]);
//print_r($parametres1);
$champs_param_display_form[$i] = $parametres1[3];
$champs_param_elements[$i] = $parametres1[0];
$champs_param_required_field[$i] = $parametres1[6];
if ( $parametres1[4] == 1 ) {
$champs_param_main_field = $champs[0];
}
}
}
$form = const_champs($modules_name, $tables_module_table, $tables_name, $tables_champs, $language, $champs_param_display_form, $champs_param_elements,$champs_param_required_field, 1);
$text = '.$en_tete.'
if (!defined("XOOPS_ROOT_PATH")) {
die("XOOPS root path not defined");
}
class '.$tables_module_table.' extends XoopsObject
{
//Constructor
function __construct()
{
$this->XoopsObject();
';
$text .= $constructor.'
}
function '.$tables_module_table.'()
{
$this->__construct();
}
function getForm($action = false)
{
global $xoopsDB, $xoopsModuleConfig;
if ($action === false) {
$action = $_SERVER["REQUEST_URI"];
}
$title = $this->isNew() ? sprintf('.$language.strtoupper($tables_name).'_ADD) : sprintf('.$language.strtoupper($tables_name).'_EDIT);
include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");
$form = new XoopsThemeForm($title, "form", $action, "post", true);
$form->setExtra('enctype="multipart/form-data"');
';
$text .= ''.$form.'';
$text .= '
$form->addElement(new XoopsFormHidden("op", "save_'.$tables_name.'"));
$form->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
return $form;
}
}';
$text .= '
class '.$modules_name.$tables_module_table.'Handler extends XoopsPersistableObjectHandler
{
function __construct(&$db)
{
parent::__construct($db, "'.$tables_module_table.'", "'.$tables_module_table.'", "'.$champs_param_increment_field.'", "'.$champs_param_main_field.'");
}
}
?>'; // irmtfan added
createFile($path_file, $text,
_AM_TDMCREATE_CONST_OK_CLASSES,
_AM_TDMCREATE_CONST_NOTOK_CLASSES, $file);
}
?>