|
From: <txm...@us...> - 2014-05-24 16:06:56
|
Revision: 12547
http://sourceforge.net/p/xoops/svn/12547
Author: txmodxoops
Date: 2014-05-24 16:06:49 +0000 (Sat, 24 May 2014)
Log Message:
-----------
Updated
Work in progress
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_objects.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_pages.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_permissions.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/sql_files.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_xoopsversion.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/sql/mysql.sql
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -22,36 +22,23 @@
$op = TDMCreateRequest::getString('op', 'default');
$mid = TDMCreateRequest::getInt('mod_id');
$repObj = $tdmcreate->getHandler('repository')->get( $mid );
+$mod_name = $repObj->getVar('mod_name');
//
$tid = TDMCreateRequest::getInt('table_id');
$table = $tdmcreate->getHandler('tables')->get( $tid );
//
-$mod_id = $repObj->getVar('mod_id');
-$mod_name = $repObj->getVar('mod_name');
-// Id of tables
-$criteria_tables = new CriteriaCompo();
-$criteria_tables->add(new Criteria('table_mid', $mod_id));
-$tables = $tdmcreate->getHandler('tables')->getAll($criteria_tables);
-unset($criteria_tables);
-//
-$table_id = $table->getVar('table_id');
-$table_name = $table->getVar('table_name');
-//
-$criteria_fields = new CriteriaCompo();
-$criteria_fields->add(new Criteria('field_tid', $table_id));
-$fields = $tdmcreate->getHandler('fields')->getAll($criteria_fields);
-unset($criteria_fields);
-//
$from_dir = TDMC_UPLOAD_REPOSITORY_PATH.'/'.strtolower($mod_name);
$to_dir = XOOPS_ROOT_PATH.'/modules/'.strtolower($mod_name);
switch ($op) {
case 'build':
$template_main = 'building.tpl';
$GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('building.php'));
- // Clear repertory of new module if there are
- TDMCreate_clearDir($from_dir);
- // Clear repertory of new module if there are in root/modules
- TDMCreate_clearDir($to_dir);
+ if(isset($mod_name)) {
+ // Clear repertory of new module if there are
+ TDMCreate_clearDir($from_dir);
+ // Clear repertory of new module if there are in root/modules
+ TDMCreate_clearDir($to_dir);
+ }
// Structure
include_once TDMC_PATH . '/class/files/architecture.php';
$handler = TDMCreateArchitecture::getInstance();
@@ -66,7 +53,7 @@
}
// Get files
$builds = array();
- $files = $handler->createBuildingFiles( $repObj, $table, $tables, $fields );
+ $files = $handler->createBuildingFiles( $repObj, $table );
foreach($files as $file) {
if($file) {
$builds['list'] = $file;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -31,21 +31,21 @@
$start = TDMCreateRequest::getInt('start', 0);
$limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('modules_adminpager'));
// Define main template
- $template_main = 'modules.tpl';
+ $template_main = 'repository.tpl';
$GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
$GLOBALS['xoTheme']->addStylesheet( 'modules/TDMCreate/css/admin/style.css' );
$GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php'));
$adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'modules.php?op=new', 'add');
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
$GLOBALS['xoopsTpl']->assign('tdmc_url', TDMC_URL);
- $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgmod_url', TDMC_UPLOAD_IMGMOD_URL);
+ $GLOBALS['xoopsTpl']->assign('tdmc_upload_imgrep_url', TDMC_UPLOAD_IMGREP_URL);
$GLOBALS['xoopsTpl']->assign('modPathIcon16', $modPathIcon16);
$GLOBALS['xoopsTpl']->assign('sysPathIcon32', $sysPathIcon32);
$criteria = new CriteriaCompo();
$criteria->setSort('mod_id ASC, mod_name');
$criteria->setOrder('ASC');
- $nb_modules = $modulesHandler->getCount( $criteria );
- $mods_arr = $modulesHandler->getAll( $criteria );
+ $nb_modules = $tdmcreate->getHandler('repository')->getCount( $criteria );
+ $mods_arr = $tdmcreate->getHandler('repository')->getAll( $criteria );
unset($criteria);
// Redirect if there aren't modules
if ( $nb_modules == 0 ) {
@@ -66,7 +66,7 @@
$mod['comments'] = $mods_arr[$i]->getVar('mod_comments');
$mod['notifications'] = $mods_arr[$i]->getVar('mod_notifications');
$mod['permissions'] = $mods_arr[$i]->getVar('mod_permissions');
- $GLOBALS['xoopsTpl']->append('modules_list', $mod);
+ $GLOBALS['xoopsTpl']->append('repository_list', $mod);
unset($mod);
}
if ( $nb_modules > $limit ) {
@@ -81,13 +81,13 @@
case 'new':
// Define main template
- $template_main = 'modules.tpl';
+ $template_main = 'repository.tpl';
$GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
$GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php'));
$adminMenu->addItemButton(_AM_TDMCREATE_MODULES_LIST, 'modules.php', 'list');
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
- $obj =& $modulesHandler->create();
+ $obj =& $tdmcreate->getHandler('repository')->create();
$form = $obj->getForm();
$GLOBALS['xoopsTpl']->assign('form', $form->render());
break;
@@ -97,9 +97,9 @@
redirect_header('modules.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
}
if (isset($mod_id)) {
- $obj =& $modulesHandler->get($mod_id);
+ $obj =& $tdmcreate->getHandler('repository')->get($mod_id);
} else {
- $obj =& $modulesHandler->create();
+ $obj =& $tdmcreate->getHandler('repository')->create();
}
//Form module save
$obj->setVars(array('mod_name' => $_POST['mod_name'],
@@ -158,7 +158,7 @@
'mod_subversion' => $_POST['mod_subversion'])
);
- if ($modulesHandler->insert($obj)) {
+ if ($tdmcreate->getHandler('repository')->insert($obj)) {
redirect_header('modules.php', 2, _AM_TDMCREATE_FORMOK);
}
@@ -169,25 +169,25 @@
case 'edit':
// Define main template
- $template_main = 'modules.tpl';
+ $template_main = 'repository.tpl';
$GLOBALS['xoTheme']->addScript('modules/TDMCreate/js/functions.js');
$GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('modules.php'));
$adminMenu->addItemButton(_AM_TDMCREATE_ADD_MODULE, 'modules.php?op=new', 'add');
$adminMenu->addItemButton(_AM_TDMCREATE_MODULES_LIST, 'modules.php', 'list');
$GLOBALS['xoopsTpl']->assign('buttons', $adminMenu->renderButton());
- $obj = $modulesHandler->get($mod_id);
+ $obj = $tdmcreate->getHandler('repository')->get($mod_id);
$form = $obj->getForm();
$GLOBALS['xoopsTpl']->assign('form', $form->render());
break;
case 'delete':
- $obj =& $modulesHandler->get($mod_id);
+ $obj =& $tdmcreate->getHandler('repository')->get($mod_id);
if (isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1) {
if ( !$GLOBALS['xoopsSecurity']->check() ) {
redirect_header('modules.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
}
- if ($modulesHandler->delete($obj)) {
+ if ($tdmcreate->getHandler('repository')->delete($obj)) {
redirect_header('modules.php', 3, _AM_TDMCREATE_FORMDELOK);
} else {
$GLOBALS['xoopsTpl']->assign('error', $obj->getHtmlErrors());
@@ -206,7 +206,7 @@
$mod_permissions = TDMCreateRequest::getInt('mod_permissions');
if ( $mod_id > 0 ) {
- $obj =& $modulesHandler->get($mod_id);
+ $obj =& $tdmcreate->getHandler('repository')->get($mod_id);
if(isset($mod_adminm)) {
$obj->setVar('mod_admin', $mod_admin);
} elseif(isset($mod_user)) {
@@ -220,7 +220,7 @@
} elseif(isset($mod_permissions)) {
$obj->setVar('mod_permissions', $mod_permissions);
}
- if ($modulesHandler->insert($obj, true)) {
+ if ($tdmcreate->getHandler('repository')->insert($obj, true)) {
redirect_header('modules.php', 1, _AM_TDMCREATE_TOGGLE_SUCCESS);
} else {
redirect_header('modules.php', 1, _AM_TDMCREATE_TOGGLE_FAILED);
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_objects.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_objects.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_objects.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -35,30 +35,45 @@
return $instance;
}
/*
+ * @public function getSimpleSetVar
+ * @param string $table_name
+ * @param string $field_name
+ */
+ public function getSimpleSetVar($table_name, $field_name) {
+ $ret = <<<EOT
+ \${$table_name}_obj->setVar('{$field_name}', \$_POST['{$field_name}']);\n
+EOT;
+ return $ret;
+ }
+ /*
* @public function getTextDateSelect
- * @param null
+ * @param string $table_name
+ * @param string $field_name
*/
public function getTextDateSelect($table_name, $field_name) {
$ret = <<<EOT
- \${$table_name}_obj->setVar('{$field_name}', strtotime(\$_REQUEST['{$field_name}']));
+ \${$table_name}_obj->setVar('{$field_name}', strtotime(\$_POST['{$field_name}']));\n
EOT;
return $ret;
}
/*
* @public function getCheckBoxOrRadioYN
- * @param null
+ * @param string $table_name
+ * @param string $field_name
*/
public function getCheckBoxOrRadioYN($table_name, $field_name) {
$ret = <<<EOT
- \${$table_name}_obj->setVar('{$field_name}', strtotime(\$_REQUEST['{$field_name}'] == 1) ? '1' : '0');
+ \${$table_name}_obj->setVar('{$field_name}', ((\$_REQUEST['{$field_name}'] == 1) ? '1' : '0'));\n
EOT;
return $ret;
}
/*
* @public function getUploadImage
- * @param null
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $field_name
*/
- public function getUploadImage($module_name, $field_name) {
+ public function getUploadImage($module_name, $table_name, $field_name) {
$ret = <<<EOT
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
\$uploaddir = XOOPS_UPLOAD_PATH.'/{$module_name}/images/{$table_name}/';
@@ -74,16 +89,18 @@
\${$table_name}_obj->setVar('{$field_name}', \$uploader->getSavedFileName());
}
} else {
- \${$table_name}_obj->setVar('{$field_name}', \$_REQUEST['{$field_name}']);
- }
+ \${$table_name}_obj->setVar('{$field_name}', \$_POST['{$field_name}']);
+ }\n
EOT;
return $ret;
}
/*
* @public function getUploadFile
- * @param null
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $field_name
*/
- public function getUploadFile($module_name, $field_name) {
+ public function getUploadFile($module_name, $table_name, $field_name) {
$ret = <<<EOT
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
\$uploaddir = XOOPS_UPLOAD_PATH.'/{$module_name}/files/{$table_name}/';
@@ -98,7 +115,7 @@
} else {
\${$table_name}_obj->setVar('{$field_name}', \$uploader->getSavedFileName());
}
- }
+ }\n
EOT;
return $ret;
}
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_pages.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_pages.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_pages.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -19,21 +19,21 @@
* @version $Id: admin_pages.php 12258 2014-01-02 09:33:29Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
+require_once 'admin_objects.php';
class AdminPages extends TDMCreateFile
{
/*
* @var string
*/
- private $tdmcfile = null;
+ private $adminobjects = null;
/*
* @var string
*/
- private $table = null;
+ private $tdmcfile = null;
/*
* @var string
*/
- private $tables = null;
+ private $table_name = null;
/*
* @var string
*/
@@ -41,29 +41,31 @@
/*
* @public function constructor
* @param string $module
- * @param mixed $table
+ * @param string $table_name
+ * @param array $fields
* @param string $filename
*/
- public function __construct($module, $table, $tables, $fields, $filename) {
+ public function __construct($module, $table_name, $fields, $filename) {
+ $this->adminobjects = AdminObjects::getInstance();
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
//$this->setTable($table);
$this->setFileName($filename);
- $this->table = $table;
- $this->tables = $tables;
+ $this->table_name = $table_name;
$this->fields = $fields;
}
/*
* @static function &getInstance
* @param string $module
- * @param mixed $table
+ * @param string $table_name
+ * @param array $fields
* @param string $filename
*/
- public static function &getInstance($module, $table, $tables, $fields, $filename)
+ public static function &getInstance($module, $table_name, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $tables, $fields, $filename);
+ $instance = new self($module, $table_name, $fields, $filename);
}
return $instance;
}
@@ -80,9 +82,9 @@
//It recovered the value of argument op in URL$
\$op = {$mod_name}_CleanVars(\$_REQUEST, 'op', 'list', 'string');
-\n\necho \$adminMenu->addNavigation('{$table_name}.php');
+echo \$adminMenu->addNavigation('{$table_name}.php');
switch (\$op)
-{\n
+{\n
EOT;
return $ret;
}
@@ -93,13 +95,13 @@
* @param string $language
*/
public function getAdminPagesList($table_name, $language, $fpif, $fpmf) {
- $stu_table_name = strtoupper($table_name);
+ $stu_table_name = strtoupper($table_name);
$ret = <<<EOT
case 'list':
default:
\$limit = xoops_getModuleOption('adminpager');
\$start = TDMCreate_CleanVars(\$_REQUEST, 'start', 0);
- \$adminMenu->addItemButton({$language}_ADD_{$stu_table_name}, '{$table_name}.php?op=new', 'add');
+ \$adminMenu->addItemButton({$language}ADD_{$stu_table_name}, '{$table_name}.php?op=new', 'add');
echo \$adminMenu->renderButton();
\$criteria = new CriteriaCompo();
\$criteria->setSort('{$fpif} ASC, {$fpmf}');
@@ -112,12 +114,37 @@
if (\${$table_name}_rows > 0)
{
foreach (array_keys(\${$table_name}_arr) as \$i)
- {
- \${$table_name}['mid'] = \${$table_name}_arr[\$i]->getVar('table_mid');
+ {\n
+EOT;
+ foreach(array_keys($this->fields) as $f)
+ {
+ $field_name = $this->fields[$f]->getVar('field_name');
+ $rp_field_name = $field_name;
+ if(strpos($field_name, '_')) {
+ $str = strpos($field_name, '_');
+ if($str !== false){
+ $rp_field_name = substr($field_name, $str + 1, strlen($field_name));
+ }
}
- }
- break;
+ $lp_field_name = substr($field_name, 0, strpos($field_name, '_'));
+ $ret .= <<<EOT
+ \${$lp_field_name}['{$rp_field_name}'] = \${$table_name}_arr[\$i]->getVar('{$field_name}');\n
EOT;
+ }
+ $ret .= <<<EOT
+ \$GLOBALS['xoopsTpl']->append('{$table_name}_list', \${$lp_field_name});
+ unset(\${$lp_field_name});
+ }
+ if ( \${$table_name}_rows > \$limit ) {
+ include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
+ \$pagenav = new XoopsPageNav(\${$table_name}_rows, \$limit, \$start, 'start', 'op=list&limit=' . \$limit);
+ \$GLOBALS['xoopsTpl']->assign('pagenav', \$pagenav->renderNav(4));
+ }
+ } else {
+ \$GLOBALS['xoopsTpl']->assign('error', {$language}THEREARENT_{$stu_table_name});
+ }
+ break;\n
+EOT;
return $ret;
}
@@ -130,13 +157,13 @@
$stu_table_name = strtoupper($table_name);
$ret = <<<EOT
case 'new':
- \$adminMenu->addItemButton({$language}_{$stu_table_name}_LIST, '{$table_name}.php', 'list');
+ \$adminMenu->addItemButton({$language}{$stu_table_name}_LIST, '{$table_name}.php', 'list');
echo \$adminMenu->renderButton();
\${$table_name}_obj =& \${$table_name}Handler->create();
\$form = \${$table_name}_obj->getForm();
\$form->display();
- break;
+ break;\n
EOT;
return $ret;
}
@@ -158,39 +185,18 @@
} else {
\${$table_name}_obj =& \${$table_name}Handler->create();
}
-\n\t\tif (\${$table_name}Handler->insert(\${$table_name}_obj)) {
- redirect_header('{$table_name}.php?op=list', 2, {$language}_FORMOK);
+EOT;
+
+
+ $ret .= <<<EOT
+ if (\${$table_name}Handler->insert(\${$table_name}_obj)) {
+ redirect_header('{$table_name}.php?op=list', 2, {$language}FORMOK);
}
echo \${$table_name}_obj->getHtmlErrors();
\$form =& \${$table_name}_obj->getForm();
\$form->display();
- break;
-
- case 'edit':
- \$adminMenu->addItemButton({$language}_ADD_{$stu_table_name}, '{$table_name}.php?op=new', 'add');
- \$adminMenu->addItemButton({$language}_{$stu_table_name}_LIST, '{$table_name}.php', 'list');
- echo \$adminMenu->renderButton();
- \${$table_name}_obj = \${$table_name}Handler->get(\$_REQUEST['{$fpif}']);
- \$form = \${$table_name}_obj->getForm();
- \$form->display();
- break;
-
- case 'delete':
- \${$table_name}_obj =& \${$table_name}Handler->get(\$_REQUEST['{$fpif}']);
- if (isset(\$_REQUEST['ok']) && \$_REQUEST['ok'] == 1) {
- if ( !\$GLOBALS['xoopsSecurity']->check() ) {
- redirect_header('{$table_name}.php', 3, implode(', ', \$GLOBALS['xoopsSecurity']->getErrors()));
- }
- if (\${$table_name}Handler->delete(\${$table_name}_obj)) {
- redirect_header('{$table_name}.php', 3, {$language}_FORMDELOK);
- } else {
- echo \${$table_name}_obj->getHtmlErrors();
- }
- } else {
- xoops_confirm(array('ok' => 1, '{$fpif}' => \$_REQUEST['{$fpif}'], 'op' => 'delete'), \$_SERVER['REQUEST_URI'], sprintf({$language}_FORMSUREDEL, \${$table_name}_obj->getVar('{$fpmf}')));
- }
- break;
+ break;\n
EOT;
return $ret;
}
@@ -204,13 +210,13 @@
$stu_table_name = strtoupper($table_name);
$ret = <<<EOT
case 'edit':
- \$adminMenu->addItemButton({$language}_ADD_{$stu_table_name}, '{$table_name}.php?op=new', 'add');
- \$adminMenu->addItemButton({$language}_{$stu_table_name}_LIST, '{$table_name}.php', 'list');
+ \$adminMenu->addItemButton({$language}ADD_{$stu_table_name}, '{$table_name}.php?op=new', 'add');
+ \$adminMenu->addItemButton({$language}{$stu_table_name}_LIST, '{$table_name}.php', 'list');
echo \$adminMenu->renderButton();
\${$table_name}_obj = \${$table_name}Handler->get(\$_REQUEST['{$fpif}']);
\$form = \${$table_name}_obj->getForm();
\$form->display();
- break;
+ break;\n
EOT;
return $ret;
}
@@ -230,14 +236,14 @@
redirect_header('{$table_name}.php', 3, implode(', ', \$GLOBALS['xoopsSecurity']->getErrors()));
}
if (\${$table_name}Handler->delete(\${$table_name}_obj)) {
- redirect_header('{$table_name}.php', 3, {$language}_FORMDELOK);
+ redirect_header('{$table_name}.php', 3, {$language}FORMDELOK);
} else {
echo \${$table_name}_obj->getHtmlErrors();
}
} else {
- xoops_confirm(array('ok' => 1, '{$fpif}' => \$_REQUEST['{$fpif}'], 'op' => 'delete'), \$_SERVER['REQUEST_URI'], sprintf({$language}_FORMSUREDEL, \${$table_name}_obj->getVar('{$fpmf}')));
+ xoops_confirm(array('ok' => 1, '{$fpif}' => \$_REQUEST['{$fpif}'], 'op' => 'delete'), \$_SERVER['REQUEST_URI'], sprintf({$language}FORMSUREDEL, \${$table_name}_obj->getVar('{$fpmf}')));
}
- break;
+ break;\n
EOT;
return $ret;
}
@@ -248,7 +254,7 @@
*/
public function getAdminPagesFooter() {
$ret = <<<EOT
-\n}
+}
include_once 'footer.php';
EOT;
return $ret;
@@ -260,7 +266,8 @@
*/
public function render()
{
- foreach(array_keys($this->fields) as $f)
+ $fpif = ''; $fpmf = '';
+ foreach(array_keys($this->fields) as $f)
{
if($f == 1) {
$fpif = $this->fields[$f]->getVar('field_name');
@@ -270,17 +277,16 @@
}
}
$module = $this->getModule();
- $module_name = $module->getVar('mod_name');
- $table_name = $this->table->getVar('table_name');
+ $module_name = $module->getVar('mod_name');
$filename = $this->getFileName();
$language = $this->getLanguage($module_name, 'AM');
$content = $this->getHeaderFilesComments($module, $filename);
- $content .= $this->getAdminPagesHeader($module_name, $table_name);
- $content .= $this->getAdminPagesNew($table_name, $language);
- $content .= $this->getAdminPagesList($table_name, $language, $fpif, $fpmf);
- $content .= $this->getAdminPagesSave($table_name, $language, $fpif, $fpmf);
- $content .= $this->getAdminPagesEdit($table_name, $language, $fpif);
- $content .= $this->getAdminPagesDelete($table_name, $language, $fpif, $fpmf);
+ $content .= $this->getAdminPagesHeader($module_name, $this->table_name);
+ $content .= $this->getAdminPagesList($this->table_name, $language, $fpif, $fpmf);
+ $content .= $this->getAdminPagesNew($this->table_name, $language);
+ $content .= $this->getAdminPagesSave($this->table_name, $language, $fpif, $fpmf);
+ $content .= $this->getAdminPagesEdit($this->table_name, $language, $fpif);
+ $content .= $this->getAdminPagesDelete($this->table_name, $language, $fpif, $fpmf);
$content .= $this->getAdminPagesFooter();
//
$this->tdmcfile->create($module_name, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_permissions.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_permissions.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/admin_permissions.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -29,7 +29,7 @@
/*
* @var string
*/
- private $table = null;
+ private $tables = null;
/*
* @var string
*/
@@ -39,12 +39,12 @@
* @param string $module
* @param string $filename
*/
- public function __construct($module, $table, $fields, $filename) {
+ public function __construct($module, $tables, $fields, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
//$this->setTable($table);
$this->setFileName($filename);
- $this->table = $table;
+ $this->tables = $tables;
$this->fields = $fields;
}
/*
@@ -53,30 +53,22 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $fields, $filename)
+ public static function &getInstance($module, $tables, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $fields, $filename);
+ $instance = new self($module, $tables, $fields, $filename);
}
return $instance;
}
/*
* @public function render
- * @param null
+ * @param string $module_name
+ * @param string $language
*/
- public function getPermissionsCode($module_name, $table_name, $language)
- {
- foreach(array_keys($this->fields) as $f)
- {
- if($f == 1) {
- $fpif = $this->fields[$f]->getVar('field_name');
- }
- if($this->fields[$f]->getVar('field_main') == 1) {
- $fpmf = $this->fields[$f]->getVar('field_name');
- }
- }
- $ret = <<<EOT
+ public function getHeaderPermissionsCode($module_name, $language)
+ {
+ $ret = <<<PRM
\ninclude_once 'header.php';
include_once XOOPS_ROOT_PATH.'/class/xoopsform/grouppermform.php';
if( !empty(\$_POST['submit']) )
@@ -103,8 +95,19 @@
\$formSelect->addOption(\$selected[2], {$language}SUBMIT);
\$formSelect->addOption(\$selected[3], {$language}VIEW);
\$permTableForm->addElement(\$formSelect);
-\$permTableForm->display();
-
+\$permTableForm->display();\n\n
+PRM;
+ return $ret;
+ }
+
+ /*
+ * @public function render
+ * @param string $module_name
+ * @param string $language
+ */
+ public function getSwitchPermissionsCode($module_name, $language)
+ {
+ $ret = <<<PRM
\$module_id = \$xoopsModule->getVar('mid');
switch(\$permission)
{
@@ -131,8 +134,38 @@
\$permName = '{$module_name}_view';
\$permDesc = {$language}VIEW_DESC;
break;
-}
-
+}\n
+PRM;
+ return $ret;
+ }
+
+ /*
+ * @public function render
+ * @param string $module_name
+ * @param string $table_name
+ * @param string $language
+ */
+ public function getBodyPermissionsCode($module_name, $language)
+ {
+ $table_permissions = ''; $table_name = '';
+ foreach(array_keys($this->tables) as $t)
+ {
+ $table_permissions = $this->tables[$t]->getVar('table_permissions');
+ if($table_permissions == 1) {
+ $table_name = $this->tables[$t]->getVar('table_name');
+ }
+ }
+ $fpif = ''; $fpmf = '';
+ foreach(array_keys($this->fields) as $f)
+ {
+ if($f == 1) {
+ $fpif = $this->fields[$f]->getVar('field_name');
+ }
+ if($this->fields[$f]->getVar('field_main') == 1) {
+ $fpmf = $this->fields[$f]->getVar('field_name');
+ }
+ }
+ $ret = <<<PRM
\$permform = new XoopsGroupPermForm(\$formTitle, \$module_id, \$permName, \$permDesc, 'admin/permissions.php');
if (\$permission == 1) {
foreach (\$globalPerms as \$perm_id => \$perm_name) {
@@ -157,11 +190,21 @@
} else {
redirect_header ( '{$table_name}.php?op=new', 3, {$language}NOPERMSSET );
exit ();
- }
+ }\n
+PRM;
+ return $ret;
+ }
+
+ /*
+ * @public function getFooterPermissionsCode
+ * @param null
+ */
+ public function getFooterPermissionsCode() {
+ $ret = <<<PRM
}
unset(\$permform);
include_once 'footer.php';
-EOT;
+PRM;
return $ret;
}
@@ -172,11 +215,14 @@
public function render() {
$module = $this->getModule();
$filename = $this->getFileName();
- $module_name = $module->getVar('mod_name');
- $table_name = $this->table->getVar('table_name');
+ $module_name = strtolower($module->getVar('mod_name'));
+ //$table_name = $this->table->getVar('table_name');
$language = $this->getLanguage($module_name, 'AM');
$content = $this->getHeaderFilesComments($module, $filename);
- $content .= $this->getPermissionsCode($module_name, $table_name, $language);
+ $content .= $this->getHeaderPermissionsCode($module_name, $language);
+ $content .= $this->getSwitchPermissionsCode($module_name, $language);
+ $content .= $this->getBodyPermissionsCode($module_name, $language);
+ $content .= $this->getFooterPermissionsCode();
//
$this->tdmcfile->create($module_name, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/architecture.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -158,106 +158,124 @@
* @param string $module
* @param string $table
*/
- public function createBuildingFiles( $module, $table, $tables, $fields )
+ public function createBuildingFiles( $module, $table )
{
- $upload_module_folder = $this->upload_path.'/'.strtolower($module->geVar('mod_name'));
- $ret = array();
- // Admin Aboutr File
- $adminAbout = AdminAbout::getInstance($module, 'about.php');
- $ret[] = $adminAbout->render();
- // Admin Footer File
- $adminFooter = AdminFooter::getInstance($module, 'footer.php');
- $ret[] = $adminFooter->render();
- // Admin Header File
- $adminHeader = AdminHeader::getInstance($module, $table, $tables, 'header.php');
- $ret[] = $adminHeader->render();
- // Admin Index File
- $adminIndex = AdminIndex::getInstance($module, $table, $tables, 'index.php');
- $ret[] = $adminIndex->render();
- // Admin Menu File
- $adminMenu = AdminMenu::getInstance($module, $table, $tables, 'menu.php');
- $ret[] = $adminMenu->render();
- // Admin Permissions File
- $adminPermissions = AdminPermissions::getInstance($module, $table, $fields, 'permissions.php');
- $ret[] = $adminPermissions->render();
- // Admin Styles File
- $cssStyles = CssStyles::getInstance($module, 'style.css');
- $ret[] = $cssStyles->render();
- // Admin Common File
- $includeCommon = IncludeCommon::getInstance($module, 'common.php');
- $ret[] = $includeCommon->render();
- // Admin Functions File
- $includeFunctions = IncludeFunctions::getInstance($module, 'functions.php');
- $ret[] = $includeFunctions->render();
- // Admin Install File
- $includeInstall = IncludeInstall::getInstance($module, $table, $tables, $fields, 'install.php');
- $ret[] = $includeInstall->render();
- // Sql File
- $sqlFile = SqlFile::getInstance($module, $table, $fields, 'mysql.sql');
- $ret[] = $sqlFile->render();
- // Multiple files
- foreach (array_keys($tables) as $i)
- {
- $table_name = $tables[$i]->getVar('table_name');
- // Admin Pages File
- $adminPages = AdminPages::getInstance($module, $table, $tables, $fields, $table_name.'.php');
- $ret[] = $adminPages->render();
- // Admin Templates File
- $adminTemplates = AdminTemplates::getInstance($module, $tables, $table_name.'.tpl');
- $ret[] = $adminTemplates->render();
- // Blocks Files
- $blocksFiles = BlocksFiles::getInstance($module, $table, $fields, $table_name.'.php');
- $ret[] = $blocksFiles->render();
- // Blocks Templates File
- $blocksTemplates = BlocksTemplates::getInstance($module, $table, $fields, $table_name.'.tpl');
- $ret[] = $blocksTemplates->render();
- // Class Files
- $classFiles = ClassFiles::getInstance($module, $table, $tables, $fields, $table_name.'.php');
- $ret[] = $classFiles->render();
- // User Pages File
- $userPages = UserPages::getInstance($module, $table, $fields, $table_name.'.php');
- $ret[] = $userPages->render();
- // User Templates File
- $userTemplates = UserTemplates::getInstance($module, $table, $fields, $table_name.'.tpl');
- $ret[] = $userTemplates->render();
- }
- // Language Admin File
- $languageAdmin = LanguageAdmin::getInstance($module, $table, $tables, 'admin.php');
- $ret[] = $languageAdmin->render();
- // Language Blocks File
- $languageBlocks = LanguageBlocks::getInstance($module, $table, $tables, 'blocks.php');
- $ret[] = $languageBlocks->render();
- // Language Main File
- $languageMain = LanguageMain::getInstance($module, $table, $tables, 'main.php');
- $ret[] = $languageMain->render();
- // Language Modinfo File
- $languageModinfo = LanguageModinfo::getInstance($module, $table, $tables, 'modinfo.php');
- $ret[] = $languageModinfo->render();
- // Language Help File
- $languageHelp = LanguageHelp::getInstance($module, 'help.html');
- $ret[] = $languageHelp->render();
- // Templates Footer File
- $templatesFooter = TemplatesFooter::getInstance($module, $table, 'footer.tpl');
- $ret[] = $templatesFooter->render();
- // Templates Header File
- $templatesHeader = TemplatesHeader::getInstance($module, $tables, 'header.tpl');
- $ret[] = $templatesHeader->render();
- // Templates Index File
- $templatesIndex = TemplatesIndex::getInstance($module, $table, 'index.tpl');
- $ret[] = $templatesIndex->render();
- // User Footer File
- $userFooter = UserFooter::getInstance($module, 'footer.php');
- $ret[] = $userFooter->render();
- // User Header File
- $userHeader = UserHeader::getInstance($module, 'header.php');
- $ret[] = $userHeader->render();
- // User Index File
- $userIndex = UserIndex::getInstance($module, $table, 'index.php');
- $ret[] = $userIndex->render();
- // User Xoops Version File
- $userXoopsVersion = UserXoopsVersion::getInstance($module, $table, $tables, 'xoops_version.php');
- $ret[] = $userXoopsVersion->render();
-
+ // Module Id
+ $mod_id = $module->getVar('mod_id');
+ // Id of tables
+ $criteria_tables = new CriteriaCompo();
+ $criteria_tables->add(new Criteria('table_mid', $mod_id));
+ $tables = $this->tdmcreate->getHandler('tables')->getAll($criteria_tables);
+ unset($criteria_tables);
+ //
+ foreach (array_keys($tables) as $t)
+ {
+ $table_mid = $tables[$t]->getVar('table_mid');
+ $table_id = $tables[$t]->getVar('table_id');
+ $criteria_fields = new CriteriaCompo();
+ $criteria_fields->add(new Criteria('field_mid', $table_mid));
+ $criteria_fields->add(new Criteria('field_tid', $table_id));
+ $fields = $this->tdmcreate->getHandler('fields')->getAll($criteria_fields);
+ unset($criteria_fields);
+
+ $ret = array();
+ // Admin Aboutr File
+ $adminAbout = AdminAbout::getInstance($module, 'about.php');
+ $ret[] = $adminAbout->render();
+ // Admin Footer File
+ $adminFooter = AdminFooter::getInstance($module, 'footer.php');
+ $ret[] = $adminFooter->render();
+ // Admin Header File
+ $adminHeader = AdminHeader::getInstance($module, $table, $tables, 'header.php');
+ $ret[] = $adminHeader->render();
+ // Admin Index File
+ $adminIndex = AdminIndex::getInstance($module, $table, $tables, 'index.php');
+ $ret[] = $adminIndex->render();
+ // Admin Menu File
+ $adminMenu = AdminMenu::getInstance($module, $table, $tables, 'menu.php');
+ $ret[] = $adminMenu->render();
+ // Admin Permissions File
+ $adminPermissions = AdminPermissions::getInstance($module, $tables, $fields, 'permissions.php');
+ $ret[] = $adminPermissions->render();
+ // Admin Styles File
+ $cssStyles = CssStyles::getInstance($module, 'style.css');
+ $ret[] = $cssStyles->render();
+ // Admin Common File
+ $includeCommon = IncludeCommon::getInstance($module, 'common.php');
+ $ret[] = $includeCommon->render();
+ // Admin Functions File
+ $includeFunctions = IncludeFunctions::getInstance($module, 'functions.php');
+ $ret[] = $includeFunctions->render();
+ // Admin Install File
+ $includeInstall = IncludeInstall::getInstance($module, $table, $tables, $fields, 'install.php');
+ $ret[] = $includeInstall->render();
+ // Sql File
+ $sqlFile = SqlFile::getInstance($module, $tables, $fields, 'mysql.sql');
+ $ret[] = $sqlFile->render();
+ // Multiple files
+ foreach (array_keys($tables) as $i)
+ {
+ $table_name = $tables[$i]->getVar('table_name');
+ // Admin Pages File
+ $adminPages = AdminPages::getInstance($module, $table_name, $fields, $table_name.'.php');
+ $ret[] = $adminPages->render();
+ // Admin Templates File
+ $adminTemplates = AdminTemplates::getInstance($module, $tables, $table_name.'.tpl');
+ $ret[] = $adminTemplates->render();
+ // Blocks Files
+ $blocksFiles = BlocksFiles::getInstance($module, $table, $fields, $table_name.'.php');
+ $ret[] = $blocksFiles->render();
+ // Blocks Templates File
+ $blocksTemplates = BlocksTemplates::getInstance($module, $table, $fields, $table_name.'.tpl');
+ $ret[] = $blocksTemplates->render();
+ // Class Files
+ $classFiles = ClassFiles::getInstance($module, $table, $tables, $fields, $table_name.'.php');
+ $ret[] = $classFiles->render();
+ // User Pages File
+ $userPages = UserPages::getInstance($module, $table, $fields, $table_name.'.php');
+ $ret[] = $userPages->render();
+ // User Templates File
+ $userTemplates = UserTemplates::getInstance($module, $table, $fields, $table_name.'.tpl');
+ $ret[] = $userTemplates->render();
+ var_dump($table_name);
+ }
+ // Language Admin File
+ $languageAdmin = LanguageAdmin::getInstance($module, $table, $tables, 'admin.php');
+ $ret[] = $languageAdmin->render();
+ // Language Blocks File
+ $languageBlocks = LanguageBlocks::getInstance($module, $table, $tables, 'blocks.php');
+ $ret[] = $languageBlocks->render();
+ // Language Main File
+ $languageMain = LanguageMain::getInstance($module, $table, $tables, 'main.php');
+ $ret[] = $languageMain->render();
+ // Language Modinfo File
+ $languageModinfo = LanguageModinfo::getInstance($module, $table, $tables, 'modinfo.php');
+ $ret[] = $languageModinfo->render();
+ // Language Help File
+ $languageHelp = LanguageHelp::getInstance($module, 'help.html');
+ $ret[] = $languageHelp->render();
+ // Templates Footer File
+ $templatesFooter = TemplatesFooter::getInstance($module, $table, 'footer.tpl');
+ $ret[] = $templatesFooter->render();
+ // Templates Header File
+ $templatesHeader = TemplatesHeader::getInstance($module, $tables, 'header.tpl');
+ $ret[] = $templatesHeader->render();
+ // Templates Index File
+ $templatesIndex = TemplatesIndex::getInstance($module, $table, 'index.tpl');
+ $ret[] = $templatesIndex->render();
+ // User Footer File
+ $userFooter = UserFooter::getInstance($module, 'footer.php');
+ $ret[] = $userFooter->render();
+ // User Header File
+ $userHeader = UserHeader::getInstance($module, 'header.php');
+ $ret[] = $userHeader->render();
+ // User Index File
+ $userIndex = UserIndex::getInstance($module, $table, 'index.php');
+ $ret[] = $userIndex->render();
+ // User Xoops Version File
+ $userXoopsVersion = UserXoopsVersion::getInstance($module, $table, $tables, 'xoops_version.php');
+ $ret[] = $userXoopsVersion->render();
+ }
return $ret;
}
}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/blocks_files.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -183,6 +183,7 @@
*/
public function render()
{
+ $fpif = ''; $fpmf = '';
foreach(array_keys($this->fields) as $f)
{
if($f == 1) {
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/sql_files.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/sql_files.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/sql_files.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -25,11 +25,11 @@
/*
* @var string
*/
- private $tdmcfile = null;
+ private $tdmcfile = null;
/*
* @var string
*/
- private $table = null;
+ private $tables = null;
/*
* @var string
*/
@@ -37,14 +37,14 @@
/*
* @public function constructor
* @param string $module
- * @param string $file_name
+ * @param string $filename
*/
- public function __construct($module, $table, $fields, $file_name) {
+ public function __construct($module, $tables, $fields, $filename) {
$this->tdmcfile = TDMCreateFile::getInstance();
$this->setModule($module);
//$this->setTable($table);
- $this->setFileName($file_name);
- $this->table = $table;
+ $this->setFileName($filename);
+ $this->tables = $tables;
$this->fields = $fields;
}
@@ -54,11 +54,11 @@
* @param mixed $table
* @param string $filename
*/
- public static function &getInstance($module, $table, $fields, $filename)
+ public static function &getInstance($module, $tables, $fields, $filename)
{
static $instance = false;
if (!$instance) {
- $instance = new self($module, $table, $fields, $filename);
+ $instance = new self($module, $tables, $fields, $filename);
}
return $instance;
}
@@ -67,20 +67,26 @@
* @public function getHeaderSqlComments
* @param string $module_name
*/
- public function getHeaderSqlComments($module_name) {
- // Comma issue
+ public function getHeaderSqlComments($module_name)
+ {
+ $date = date('D M d, Y');
+ $time = date('G:i');
+ $server_name = $_SERVER['SERVER_NAME'];
+ $server_version = mysql_get_server_info();
+ $php_version = phpversion();
+ // Header Sql Comments
$ret = <<<SQL
--- phpMyAdmin SQL Dump for $module_name module
--- version 4.0.4
--- http://www.phpmyadmin.net
---
--- Host: localhost
--- Generato il: Apr 03, 2014 alle 18:00
--- Versione del server: 5.5.16-log
--- Versione PHP: 5.3.8\n\n
+# SQL Dump for $module_name module
+# PhpMyAdmin Version: 4.0.4
+# http://www.phpmyadmin.net
+#
+# Host: $server_name
+# Generated on: $date to $time
+# Server version: $server_version
+# PHP Version: $php_version\n
SQL;
return $ret;
- }
+ }
/*
* @public function getHeadDatabaseTable
@@ -90,23 +96,43 @@
*/
public function getHeadDatabaseTable($module_name, $table_name, $nb_fields)
{
- $ret = <<<EOT
+ $ret = <<<SQL
+
#
# Structure table for `mod_{$module_name}_{$table_name}` {$nb_fields}
#
CREATE TABLE IF NOT EXISTS `mod_{$module_name}_{$table_name}` (\n
-EOT;
+SQL;
return $ret;
}
+
/*
+ * @public function getDatabaseTables
+ * @param string $module_name
+ */
+ public function getDatabaseTables($module_name)
+ {
+ $ret = '';
+ foreach(array_keys($this->tables) as $t)
+ {
+ $table_name = $this->tables[$t]->getVar('table_name');
+ $table_autoincrement = $this->tables[$t]->getVar('table_autoincrement');
+ $nb_fields = $this->tables[$t]->getVar('table_nbfields');
+ $ret .= $this->getDatabaseTable($module_name, $table_name, $table_autoincrement, $nb_fields);
+ }
+ return $ret;
+ }
+
+ /*
* @public function getDatabaseTable
* @param string $module_name
* @param string $table_name
+ * @param boolean $table_autoincrement
+ * @param integer $nb_fields
*/
- public function getDatabaseTable($module_name, $table_name) {
-
- $nb_fields = $this->table->getVar('table_nbfields');
+ public function getDatabaseTable($module_name, $table_name, $table_autoincrement, $nb_fields)
+ {
$ret = '';
$j = 0;
foreach(array_keys($this->fields) as $f)
@@ -120,64 +146,58 @@
$field_null = $this->fields[$f]->getVar('field_null');
$field_default = $this->fields[$f]->getVar('field_default');
$field_key = $this->fields[$f]->getVar('field_key');
- if ( $field_name != ' ' )
- {
- //If as text, date or timestamp (not value)
- switch( $field_type ) {
- case 'text':
- case 'date':
- case 'timestamp':
- $type = $field_type;
- break;
- default:
- $type = $field_type.' ('.$field_value.')';
- break;
- }
- //If as empty is default not string(not value), if as text not default, if as numeric default is 0 or 0.0000
- if ( $field_default == '' ) {
- $default = "default ''";
- }
+ if ( !empty($field_name) )
+ {
switch( $field_type ) {
case 'text':
case 'tinytext':
case 'mediumtext':
case 'longtext':
- $default = "";
+ $type = $field_type;
+ $default = "{$field_default}";
break;
case 'int':
case 'tinyint':
case 'mediumint':
case 'smallint':
- $default = "default '0'";
+ $type = $field_type.'('.$field_value.')';
+ $default = "DEFAULT '{$field_default}'";
break;
case 'decimal':
case 'double':
case 'float':
- $default = "default '0.0000'";
+ $type = $field_type.'('.$field_value.')';
+ $default = "DEFAULT '{$field_default}'";
break;
- case 'date':
- $default = "default '0000-00-00'";
+ case 'date':
+ $type = $field_type;
+ $default = "DEFAULT '{$field_default}'";
break;
case 'datetime':
case 'timestamp':
- $default = "default '0000-00-00 00:00:00'";
+ $type = $field_type;
+ $default = "DEFAULT '{$field_default}'";
break;
- case 'time':
- $default = "default '0000-00-00'";
+ case 'time':
+ $type = $field_type.'('.$field_value.')';
+ $default = "DEFAULT '{$field_default}'";
break;
- case 'year':
- $default = "default '0000-00-00'";
+ case 'year':
+ $type = $field_type.'('.$field_value.')';
+ $default = "DEFAULT '{$field_default}'";
break;
- case 'other':
- $default = "default '{$field_default}'";
+ case 'other':
+ $type = $field_type.'('.$field_value.')';
+ $default = "DEFAULT '{$field_default}'";
break;
- default:
- $default = "default ''";
- break;
+ default:
+ $type = $field_type.'('.$field_value.')';
+ $default = "DEFAULT '{$field_default}'";
+ break;
}
- if ( ($f == 1) && ($this->table->getVar('table_autoincrement') == 1) ) {
- $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default, 'auto_increment');
+ if ( ($f == 1) && ($table_autoincrement == 1) ) {
+ $ret .= $this->getFieldRow($field_name, $type, $field_attribute, $field_null, $default, 'auto_increment');
$comma[$j] = $this->getKey(1, $field_name);
$j++;
} else {
@@ -187,28 +207,28 @@
case 'fulltext':
switch( $field_key ) {
case 'unique':
- $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $ret .= $this->getFieldRow($field_name, $type, $field_attribute, $field_null, $default);
$comma[$j] = $this->getKey(2, $field_name);
break;
case 'index':
- $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $ret .= $this->getFieldRow($field_name, $type, $field_attribute, $field_null, $default);
$comma[$j] = $this->getKey(3, $field_name);
break;
case 'fulltext':
- $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $ret .= $this->getFieldRow($field_name, $type, $field_attribute, $field_null, $default);
$comma[$j] = $this->getKey(4, $field_name);
break;
}
break;
default:
- $ret .= $this->getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default);
+ $ret .= $this->getFieldRow($field_name, $type, $field_attribute, $field_null, $default);
break;
}
$j++;
}
}
}
- $ret .= $this->getCommaCicle($j);
+ $ret .= $this->getCommaCicle($j, $comma);
unset($j);
$ret .= $this->getFootDatabaseTable();
return $ret;
@@ -218,57 +238,57 @@
* @param null
*/
public function getFootDatabaseTable() {
- $ret = <<<EOT
+ $ret = <<<SQL
\n) ENGINE=MyISAM;\n
-EOT;
+SQL;
return $ret;
}
/*
- * @public function constructor
+ * @public function getKey
* @param integer $key
* @param array $field_name
*/
public function getKey($key, $field_name) {
switch( $key ) {
case 1:
- $ret = $ret = <<<EOT
- PRIMARY KEY (`$field_name`)'
-EOT;
+ $ret = <<<SQL
+PRIMARY KEY (`$field_name`)
+SQL;
break;
- case 2:
- $ret = <<<EOT
- KEY `$field_name` (`$field_name`)'
-EOT;
+ case 2: // UNIQUE KEY
+ $ret = <<<SQL
+KEY `$field_name` (`$field_name`)
+SQL;
break;
case 3:
- $ret = <<<EOT
- INDEX (`$field_name`)'
-EOT;
+ $ret = <<<SQL
+INDEX (`$field_name`)
+SQL;
break;
case 4:
- $ret = <<<EOT
- FULLTEXT KEY `$field_name` (`$field_name`)'
-EOT;
+ $ret = <<<SQL
+FULLTEXT KEY `$field_name` (`$field_name`)
+SQL;
break;
}
return $ret;
}
/*
- * @public function getFieldNameLine
+ * @public function getFieldRow
* @param string $type
* @param array $struct
* @param string $field_default
*/
- public function getFieldNameLine($field_name, $field_type, $field_value, $field_attribute, $field_null, $field_default = '', $autoincrement = '')
+ public function getFieldRow($field_name, $type, $field_attribute, $field_null, $field_default = '', $autoincrement = '')
{
if(!empty($autoincrement)) {
- $ret = <<<EOT
-`{$field_name}` {$field_type}({$field_value}) {$field_attribute} {$field_null} {$field_default} {$autoincrement},\n
-EOT;
+ $ret = <<<SQL
+`{$field_name}` {$type} {$field_attribute} {$field_null} {$field_default} {$autoincrement},\n
+SQL;
} else {
- $ret = <<<EOT
-`{$field_name}` {$field_type}({$field_value}) {$field_attribute} {$field_null} {$field_default},\n
-EOT;
+ $ret = <<<SQL
+`{$field_name}` {$type} {$field_attribute} {$field_null} {$field_default},\n
+SQL;
}
return $ret;
@@ -279,25 +299,24 @@
* @param string $comma
*/
public function getComma($array, $comma = '') {
- $ret = <<<EOT
+ $ret = <<<SQL
{$array}{$comma}
-EOT;
+SQL;
return $ret;
}
/*
* @public function getCommaCicle
* @param integer $index
*/
- public function getCommaCicle($index) {
+ public function getCommaCicle($index, $comma = array()) {
// Comma issue
- $ret = '';
- $comma = array();
+ $ret = '';
for ($i = 1; $i <= $index; $i++)
{
if ( $i != $index - 1 ) {
- $ret .= $this->getComma($comma[$i], ',');
+ $ret .= $this->getComma(isset($comma[$i]), ',');
} else {
- $ret .= $this->getComma($comma[$i]);
+ $ret .= $this->getComma(isset($comma[$i]));
}
}
return $ret;
@@ -313,9 +332,8 @@
//$fields = $this->getFields();
$filename = $this->getFileName();
$module_name = strtolower($module->getVar('mod_name'));
- $table_name = $this->table->getVar('table_name');
$content = $this->getHeaderSqlComments($module_name);
- $content .= $this->getDatabaseTable($module_name, $table_name);
+ $content .= $this->getDatabaseTables($module_name);
$this->tdmcfile->create($module_name, 'sql', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
return $this->tdmcfile->renderFile();
}
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_xoopsversion.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_xoopsversion.php 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/files/user_xoopsversion.php 2014-05-24 16:06:49 UTC (rev 12547)
@@ -66,7 +66,30 @@
}
return $instance;
}
+
/*
+ * @public function setKeywords
+ * @param mixed $keywords
+ */
+ public function setKeywords($keywords)
+ {
+ if(is_array($keywords)) {
+ $this->keywords = $keywords;
+ } else {
+ $this->keywords[] = $keywords;
+ }
+ }
+
+ /*
+ * @public function getKeywords
+ * @param null
+ */
+ public function getKeywords()
+ {
+ return $this->keywords;
+ }
+
+ /*
* @private function getXoopsVersionHeader
* @param string $language
*/
@@ -241,6 +264,7 @@
$ret .= <<<EOT
\n\$modversion['templates'][] = array('file' => '{$table_name}.tpl', 'description' => '');
EOT;
+ $this->setKeywords($table_name);
}
$ret .= <<<EOT
\n\$modversion['templates'][] = array('file' => 'footer.tpl', 'description' => '');
@@ -252,7 +276,7 @@
* @param string $module_name
* @param string $language
*/
- private function getXoopsVersionBlocks($module_name, $table_name, $language)
+ private function getXoopsVersionBlocks($module_name, $language)
{
$stl_mod_name = strtolower($module_name);
$ret = '';
@@ -271,7 +295,7 @@
'options' => "{$this->tables[$i]->getVar('table_fieldname')}|5|25|0",
'template' => "{$table_name}_block.html");\n
EOT;
- $this->keywords[] = $table_name;
+ $this->setKeywords($table_name);
}
}
return $ret;
@@ -342,7 +366,7 @@
'valuetype' => "text",
'default' => "{$stl_mod_name},
EOT;
- $ret .= implode(', ', $this->keywords);
+ $ret .= implode(', ', $this->getKeywords());
$ret .= <<<EOT
");\n
EOT;
@@ -538,6 +562,7 @@
}
return $ret;
}
+
/*
* @public function render
* @param null
@@ -562,7 +587,7 @@
}
$content .= $this->getXoopsVersionTemplates($module_name);
if ($this->table->getVar('table_blocks') == 1) {
- $content .= $this->getXoopsVersionBlocks($module_name, $table_name, $language);
+ $content .= $this->getXoopsVersionBlocks($module_name, $language);
}
$content .= $this->getXoopsVersionConfig($module, $table_name, $language);
if ($this->table->getVar('table_notifications') == 1) {
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/sql/mysql.sql
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/sql/mysql.sql 2014-05-23 19:49:52 UTC (rev 12546)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/sql/mysql.sql 2014-05-24 16:06:49 UTC (rev 12547)
@@ -127,28 +127,28 @@
INSERT INTO `mod_tdmcreate_fieldtype` (`fieldtype_name`, `fieldtype_value`) VALUES
('', ''),
- ('INT', 'int'),
- ('TINYINT', 'tinyint'),
- ('MEDIUMINT', 'mediumint'),
- ('SMALLINT', 'smallint'),
- ('FLOAT', 'float'),
- ('DOUBLE', 'double'),
- ('DECIMAL', 'decimal'),
- ('SET', 'set'),
- ('ENUM', 'enum'),
- ('EMAIL', 'email'),
- ('URL', 'url'),
- ('CHAR', 'char'),
- ('VARCHAR', 'varchar'),
- ('TEXT', 'text'),
- ('TINYTEXT', 'tinytest'),
- ('MEDIUMTEXT', 'mediumtext'),
- ('LONGTEXT', 'longtext'),
- ('DATE', 'date'),
- ('DATETIME', 'datetime'),
- ('TIMESTAMP', 'timestamp'),
- ('TIME', 'time'),
- ('YEAR', 'year');
+ ('INT', 'INT'),
+ ('TINYINT', 'TINYINT'),
+ ('MEDIUMINT', 'MEDIUMINT'),
+ ('SMALLINT', 'SMALLINT'),
+ ('FLOAT', 'FLOAT'),
+ ('DOUBLE', 'DOUBLE'),
+ ('DECIMAL', 'DECIMAL'),
+ ('SET', 'SET'),
+ ('ENUM', 'ENUM'),
+ ('EMAIL', 'EMAIL'),
+ ('URL', 'URL'),
+ ('CHAR', 'CHAR'),
+ ('VARCHAR', 'VARCHAR'),
+ ('TEXT', 'TEXT'),
+ ('TINYTEXT', 'TINYTEXT'),
+ ('MEDIUMTEXT', 'MEDIUMTEXT'),
+ ('LONGTEXT', 'LONGTEXT'),
+ ('DATE', 'DATE'),
+ ('DATETIME', 'DATETIME'),
+ ('TIMESTAMP', 'TIMESTAMP'),
+ ('TIME', 'TIME'),
+ ('YEAR', 'YEAR');
#
# Table structure for table `mod_tdmcreate_fieldattributes` 3
@@ -163,10 +163,10 @@
INSERT INTO `mod_tdmcreate_fieldattributes` (`fieldattribute_name`, `fieldattribute_value`) VALUES
('', ''),
- ('BINARY', 'binary'),
- ('UNSIGNED', 'unsigned'),
- ('UNSIGNED ZEROFILL', 'unsigned_zerofill'),
- ('CURRENT_TIMESTAMP', 'current_timestamp');
+ ('BINARY', 'BINARY'),
+ ('UNSIGNED', 'UNSIGNED'),
+ ('UNSIGNED_ZEROFILL', 'UNSIGNED_ZEROFILL'),
+ ('CURRENT_TIMESTAMP', 'CURRENT_TIMESTAMP');
#
# Table structure for table `mod_tdmcreate_fieldnull` 3
@@ -180,8 +180,8 @@
ENGINE =MyISAM;
INSERT INTO `mod_tdmcreate_fieldnull` (`fieldnull_name`, `fieldnull_value`) VALUES
- ('not null', 'NOT NULL'),
- ('null', 'NULL');
+ ('NOT NULL', 'NOT NULL'),
+ ('NULL', 'NULL');
#
# Table structure for table `mod_tdmcreate_fieldkey` 3
@@ -196,10 +196,10 @@
INSERT INTO `mod_tdmcreate_fieldkey` (`fieldkey_name`, `fieldkey_value`) VALUES
('', ''),
- ('primary', 'PRIMARY'),
- ('unique', 'UNIQUE'),
- ('index', 'INDEX'),
- ('fulltext', 'FULLTEXT');
+ ('PRIMARY', 'PRIMARY KEY'),
+ ('UNIQUE', 'UNIQUE KEY'),
+ ('INDEX', 'INDEX'),
+ ('FULLTEXT', 'FULLTEXT');
#
# Table structure for table `mod_tdmcreate_fieldelements` 3
|