hi timgno
tdmcreate 1.91 alpa 3
clone from
https://github.com/txmodxoops/TDMCreate-1.91.git 03.06.2015, 21:27
Xoops 2.5.7.1
firefox 37.0.2
a) module installing
a.1) uninstalled previous version
a.2) cleaned up cache
a.3) installed 1.91 alpha 3 - ok
b) Testing module TDMCreate
b.1) created new module (named: mytestmodule) - ok
b.2) create new table (named: tables1) for this new module - ok
b.3) in parameter list there is 'TextDateSelect'. Please make additionally a 'TextDateTimeSelect'
b.4) changed later number of fields/add new field to this table - ok
b.5) create second table (named: tables2) for this new module - ok
no error, but: in parameter list 'tables1' appears two times
Searching for reason I found:
in admin/fields.php there is at switch 'save' after line 170 (if ($fieldsObj->isNew()) {)
// Fields Elements Handler
$fieldelementObj =& $tdmcreate->getHandler('fieldelements')->create();
$fieldelementObj->setVar( 'fieldelement_mid', $fieldMid );
$fieldelementObj->setVar( 'fieldelement_tid', $fieldTid );
$fieldelementObj->setVar( 'fieldelement_name', 'Table : '.ucfirst($tableName) );
$fieldelementObj->setVar( 'fieldelement_value', 'XoopsFormTables-'.ucfirst($tableName) );
// Insert new field element id for table name
if (!$tdmcreate->getHandler('fieldelements')->insert($fieldelementObj) ) {
$GLOBALS['xoopsTpl']->assign('error', $fieldelementObj->getHtmlErrors() . ' Field element');
}
and each time you add a new field you get a new item in table 'tdmcreate_fieldelements' for the same table (indicated by my test item 7)
please delete this and add in admin/tables.php after line 187 ($tableAction = '&field_mid=' . $tableMid . '&field_tid=' . $tableTid . '&field_numb=' . $tableNumbFields . '&field_name=' . $tableFieldname;)
// Fields Elements Handler
$fieldelementObj =& $tdmcreate->getHandler('fieldelements')->create();
$fieldelementObj->setVar( 'fieldelement_mid', $tableMid );
$fieldelementObj->setVar( 'fieldelement_tid', $tableTid );
$fieldelementObj->setVar( 'fieldelement_name', 'Table : '.ucfirst($_POST['table_name']) );
$fieldelementObj->setVar( 'fieldelement_value', 'XoopsFormTables-'.ucfirst($_POST['table_name']) );
// Insert new field element id for table name
if (!$tdmcreate->getHandler('fieldelements')->insert($fieldelementObj) ) {
$GLOBALS['xoopsTpl']->assign('error', $fieldelementObj->getHtmlErrors() . ' Field element');
}
, then you get only a new item in table 'tdmcreate_fieldelements', if you create a new table
b.6) if you delete a table, the item in table 'fieldelements' is not deleted and it will be still shown in parameter list for the fields (and this can only make troubles)
please add in admin/tables at switch 'delete' after 'if ($tdmcreate->getHandler('tables')->delete($tablesObj)) {'
//delete items in table fieldelements
$crit_fieldelements = new CriteriaCompo();
$crit_fieldelements->add(new Criteria('fieldelement_tid', $tableId));
$fieldelements = $tdmcreate->getHandler('fieldelements')->getAll($crit_fieldelements);
foreach (array_keys($fieldelements) as $fe) {
$fieldelementsObj =& $tdmcreate->getHandler('fieldelements')->get($fieldelements[$fe]->getVar('fieldelement_id'));
if (!$tdmcreate->getHandler('fieldelements')->delete($fieldelementsObj)) {
echo $fieldelementObj->getHtmlErrors();
}
unset ($fieldelementsObj);
}
b.7) after clicking on building module, all is marked es well done
c) testing new module
c.1) installing module - ok
c.2) after installation I went directly to module settings, after click on safe I got error:
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in C:\Homepages\Xampp\htdocs\xoops2571\htdocs\modules\mytestmodule\class\tables1.php on line 173
Searching for error I found:
- in my 'tables1' I have as last field a radio yes/no, named 't1_add_yesno'
- in class/tables1.php after the class MytestmoduleTables1 there is additionally
/**
* Get Options
*/
public function getOptions()
{
$ret = array();
if (1 == $this->getVar('t1_add_yesno')) {
array_push($ret, 'add_yesno');
}
return $ret;
}
}
and this causes the error
if I delete this, it works
c.3) adding new item to tables1 - ok
c.4) adding new item to tables2 works, but:
I have in my 'tables2' one field with type 'DhtmlTextArea'. In the form generated by class/tables2.php I get the always the editor defined by 'Preferences/Editor'
That's basically ok, but we have 3 possibilities:
- then we should name the field type e.g. 'Editor defined in module prefs'
- this field should be always 'DhtmlTextArea'
- make field type 'DhtmlTextArea' (which should be then always DhtmlTextArea) plus 'Editor defined in module prefs'
d) Testing user side of new module:
d.1) on the index pages there are following errors in debug area:
Notice: Undefined variable: sysPathIcon32 in file /modules/mytestmodule/footer.php line 26
Notice: Undefined variable: dirname in file /modules/mytestmodule/footer.php line 28
Notice: Undefined variable: dirname in file /modules/mytestmodule/footer.php line 30
Notice: Undefined variable: dirname in file /modules/mytestmodule/footer.php line 31
d.2) on the index pages there is e.g _MA_MYTESTMODULE_TABLES1, but in the language file is _MA_MYTESTMODULE_TABLE1 defined
now we can change _MA_MYTESTMODULE_TABLES1 or _MA_MYTESTMODULE_TABLE1
IMO we should change to _MA_MYTESTMODULE_TABLES1, otherwise we have later the same problem with _MA_MYTESTMODULE_TABLES1_DESC
in class/files/language/LanguageMain.php line 98 ff should be
$tableName = $tables[$i]->getVar('table_name');
$stuTableName = strtoupper($tableName);
$ucfTableName = UcFirstAndToLower($tableName);
$tableSoleName = $tables[$i]->getVar('table_solename');
$stuTableSoleName = strtoupper($tableSoleName);
$ucfTableSoleName = UcFirstAndToLower($tableSoleName);
$ret .= $this->defines->getAboveDefines($ucfTableName);
$ret .= $this->defines->getDefine($language, $stuTableName, $ucfTableName);
$ret .= $this->defines->getDefine($language, "{$stuTableName}_DESC", "{$ucfTableName} description");
$ret .= $this->defines->getAboveDefines("Caption of {$ucfTableName}");
instead of
$tableSoleName = $tables[$i]->getVar('table_solename');
$stuTableSoleName = strtoupper($tableSoleName);
$ucfTableSoleName = UcFirstAndToLower($tableSoleName);
$ret .= $this->defines->getAboveDefines($ucfTableSoleName);
$ret .= $this->defines->getDefine($language, $stuTableSoleName, $ucfTableSoleName);
$ret .= $this->defines->getDefine($language, "{$stuTableSoleName}_DESC", "{$ucfTableSoleName} description");
$ret .= $this->defines->getAboveDefines("Caption of {$ucfTableSoleName}");
d.3) if I want to show my 'tables1' I get errors:
Parse error: syntax error, unexpected ')' in C:\Homepages\Xampp\htdocs\xoops2571\htdocs\modules\mytestmodule\tables1.php on line 54
please check class/files/user/UserPages.php line 137
IMO the line
$xoBreadcrumbs[] = {$language}{$stuTableSoleName});
can be deleted
d.4) fixed bug d.3), if I want to show once more my 'tables1' I get error:
Notice: Use of undefined constant _MA_MYTESTMODULE_TABLE1 - assumed '_MA_MYTESTMODULE_TABLE1' in file /modules/mytestmodule/tables1.php line 53
Notice: Undefined variable: sysPathIcon32 in file /modules/mytestmodule/footer.php line 26
Notice: Undefined variable: dirname in file /modules/mytestmodule/footer.php line 28
Notice: Undefined variable: dirname in file /modules/mytestmodule/footer.php line 30
Notice: Undefined variable: dirname in file /modules/mytestmodule/footer.php line 31
d.5) in class/files/user/UserPages.php line 136
$xoBreadcrumbs[] = array('link' => {$stuModuleDirname}_URL . '/{$tableName}.php', 'title' => {$language}{$stuTableSoleName});
should be replace by
$xoBreadcrumbs[] = array('link' => {$stuModuleDirname}_URL . '/{$tableName}.php', 'title' => {$language}{$stuTableName});
d.6) the content of my tables1 is not shown, reason:
in tables1.php you create an array named 'tables1_list' which is appended to templates/mytestmodule/tables1.tpl, but there I find '<{foreach item=list from=$tables1}>'
therefore in class/files/templates/user/TemplatesUserPages.php line 129
<{foreach item=list from=${$tableName}}>;
should be replace by
<{foreach item=list from=${$tableName}_list}>
d.7) fixed d.5, but in the list header you find always '_MA_MYTESTMODULE_T1_ID', '_MA_MYTESTMODULE_T1_NAME' and so one
reason:
in tables1.tpl you have _MA_MYTESTMODULE_T1_ID, in language file main.php you have _MA_MYTESTMODULE_TABLE1_ID
Stop testing for the moment
done in my fork on github:
b.5)
b.6)
d.2)
d.3)
d.5)
d.6)
todos:
b.3)
c.2) - i do not know what is the reason for this code :-|
c.4)
d.1)
d.7)